Authored by zhaoqing

联盟红人

... ... @@ -49,7 +49,7 @@ public interface UnionShareOrdersMapper {
int updateByPrimaryKey(UnionShareOrders record);
UnionShareOrders selectRecentlyOrderLimitTen(@Param("uid") int uid);
List<UnionShareOrders> selectRecentlyOrderLimitTen(@Param("uid") int uid);
List<UnionShareOrders> selectOrderList(@Param("params") UnionShareOrderReqBO unionShareOrderReqBO);
}
\ No newline at end of file
... ...
... ... @@ -15,12 +15,18 @@ public class UnionShareOrders {
private BigDecimal lastOrderAmount;
private String lastOrderAmountStr;
private Integer orderTime;
private String orderTimeStr;
private Byte isNew;
private BigDecimal amount;
private String amountStr;
private Integer createTime;
private Integer updateTime;
... ... @@ -73,6 +79,14 @@ public class UnionShareOrders {
this.orderTime = orderTime;
}
public String getOrderTimeStr() {
return orderTimeStr;
}
public void setOrderTimeStr(String orderTimeStr) {
this.orderTimeStr = orderTimeStr;
}
public Byte getIsNew() {
return isNew;
}
... ... @@ -112,4 +126,20 @@ public class UnionShareOrders {
public void setSettlementCode(String settlementCode) {
this.settlementCode = settlementCode;
}
public String getLastOrderAmountStr() {
return lastOrderAmountStr;
}
public void setLastOrderAmountStr(String lastOrderAmountStr) {
this.lastOrderAmountStr = lastOrderAmountStr;
}
public String getAmountStr() {
return amountStr;
}
public void setAmountStr(String amountStr) {
this.amountStr = amountStr;
}
}
\ No newline at end of file
... ...
... ... @@ -9,8 +9,12 @@ public class UnionShareSettlement {
private BigDecimal settlementAmount;
private String settlementAmountStr;
private Integer settlementTime;
private String settlementTimeStr;
private Integer promoteUid;
private Byte status;
... ... @@ -41,6 +45,14 @@ public class UnionShareSettlement {
this.settlementAmount = settlementAmount;
}
public String getSettlementAmountStr() {
return settlementAmountStr;
}
public void setSettlementAmountStr(String settlementAmountStr) {
this.settlementAmountStr = settlementAmountStr;
}
public Integer getSettlementTime() {
return settlementTime;
}
... ... @@ -49,6 +61,14 @@ public class UnionShareSettlement {
this.settlementTime = settlementTime;
}
public String getSettlementTimeStr() {
return settlementTimeStr;
}
public void setSettlementTimeStr(String settlementTimeStr) {
this.settlementTimeStr = settlementTimeStr;
}
public Integer getPromoteUid() {
return promoteUid;
}
... ...
... ... @@ -97,8 +97,8 @@ public class UnionShareRest {
public UnionResponse queryRecentlyOrderLimitTen(int uid){
log.info("UnionShareRest :: queryRecentlyOrderLimitTen uid is{}", uid);
try {
UnionShareOrders unionShareOrders = unionShareService.queryRecentlyOrderLimitTen(uid);
return new UnionResponse(200, "queryRecentlyOrderLimitTen success",unionShareOrders);
List<UnionShareOrders> unionShareOrdersList = unionShareService.queryRecentlyOrderLimitTen(uid);
return new UnionResponse(200, "queryRecentlyOrderLimitTen success",unionShareOrdersList);
}catch (Exception e){
log.error("UnionShareRest :: queryRecentlyOrderLimitTen error", e);
return new UnionResponse(500,"queryRecentlyOrderLimitTen error!");
... ...
... ... @@ -52,7 +52,7 @@ public interface IUnionShareService {
* @param uid
* @return
*/
UnionShareOrders queryRecentlyOrderLimitTen(int uid);
List<UnionShareOrders> queryRecentlyOrderLimitTen(int uid);
/**
* 订单明细
... ...
... ... @@ -34,6 +34,8 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
... ... @@ -245,19 +247,35 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
* @return
*/
@Override
public UnionShareOrders queryRecentlyOrderLimitTen(int uid) {
public List<UnionShareOrders> queryRecentlyOrderLimitTen(int uid) {
//先从缓存获取
String key = "recentlyOrderLimitTen";
UnionShareOrders cacheResult = getFromRedis(ShareOrdersKeyEnum.RECENTLY_ORDER_LIMIT_TEN, uid, UnionShareOrders.class, key);
UnionShareOrdersListBO cacheResult = getFromRedis(ShareOrdersKeyEnum.RECENTLY_ORDER_LIMIT_TEN, uid, UnionShareOrdersListBO.class, key);
if (cacheResult != null) {
logger.info("UnionShareServiceImpl :: queryRecentlyOrderLimitTen get redis cache ,uid is {},cacheResult is {}",uid,cacheResult);
return cacheResult;
return cacheResult.getList();
}
//获取数据库
UnionShareOrders unionShareOrders = unionShareOrdersMapper.selectRecentlyOrderLimitTen(uid);
List<UnionShareOrders> unionShareOrdersList = unionShareOrdersMapper.selectRecentlyOrderLimitTen(uid);
//处理订单列表数据
dealShareOrderList(unionShareOrdersList);
UnionShareOrdersListBO unionShareOrdersListBO = new UnionShareOrdersListBO();
unionShareOrdersListBO.setList(unionShareOrdersList);
//设置缓存
addToRedis(ShareOrdersKeyEnum.RECENTLY_ORDER_LIMIT_TEN,uid,unionShareOrders,key);
return unionShareOrders;
addToRedis(ShareOrdersKeyEnum.RECENTLY_ORDER_LIMIT_TEN,uid,unionShareOrdersListBO,key);
return unionShareOrdersList;
}
private void dealShareOrderList(List<UnionShareOrders> unionShareOrdersList) {
if (CollectionUtils.isNotEmpty(unionShareOrdersList)){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd HH:mm");
DecimalFormat df1 = new DecimalFormat("0.00");
for (UnionShareOrders unionShareOrders : unionShareOrdersList){
unionShareOrders.setOrderTimeStr(sdf.format(unionShareOrders.getOrderTime()));
unionShareOrders.setLastOrderAmountStr(df1.format(unionShareOrders.getLastOrderAmount()));
unionShareOrders.setAmountStr("+"+df1.format(unionShareOrders.getAmount()));
}
}
}
@Override
... ... @@ -276,12 +294,21 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
}
List<UnionShareOrdersProduct> unionShareOrdersProductlist = unionShareOrdersProductMapper.selectOrdersProductByOrderCode(orderCode);
List<ShareOrdersProductBo> shareOrdersProductBoList = convert.convertFromList(unionShareOrdersProductlist, ShareOrdersProductBo.class);
//设置商品价格
DecimalFormat df1 = new DecimalFormat("0.00");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
for (ShareOrdersProductBo shareOrdersProductBo : shareOrdersProductBoList){
shareOrdersProductBo.setPriceStr("¥"+df1.format(shareOrdersProductBo.getPrice()));
}
ShareOrderBo shareOrderBo = new ShareOrderBo();
shareOrderBo = convert.convertFrom(unionShareOrders,shareOrderBo,ShareOrderBo.class);
shareOrderBo.setIsNew(unionShareOrders.getIsNew().toString());
shareOrderBo.setProductList(shareOrdersProductBoList);
shareOrderBo.setOrderTimeStr(sdf.format(shareOrderBo.getOrderTime()));
shareOrderBo.setAmountStr("¥"+df1.format(shareOrderBo.getAmount()));
shareOrderBo.setLastOrderAmountStr("¥"+df1.format(shareOrderBo.getLastOrderAmount()));
//设置缓存
addToRedis(ShareOrdersKeyEnum.ORDER_INFO,uid,unionShareOrders,key, orderCode);
addToRedis(ShareOrdersKeyEnum.ORDER_INFO,uid,shareOrderBo,key, orderCode);
return shareOrderBo;
}
... ... @@ -296,13 +323,21 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
return cacheResult.getList();
}
//数据库获取
List<UnionShareSettlement> unionShareSettlement = unionShareSettlementMapper.selectSettlementRecordByUid(unionShareOrderReqBO.getUid(),
List<UnionShareSettlement> unionShareSettlementList = unionShareSettlementMapper.selectSettlementRecordByUid(unionShareOrderReqBO.getUid(),
unionShareOrderReqBO.getPage()*unionShareOrderReqBO.getSize(), unionShareOrderReqBO.getSize());
if (CollectionUtils.isNotEmpty(unionShareSettlementList)){
DecimalFormat df1 = new DecimalFormat("0.00");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd HH:mm");
for (UnionShareSettlement unionShareSettlement : unionShareSettlementList){
unionShareSettlement.setSettlementAmountStr("+"+df1.format(unionShareSettlement.getSettlementAmount()));
unionShareSettlement.setSettlementTimeStr(sdf.format(unionShareSettlement.getSettlementTime()));
}
}
//设置缓存
UnionShareSettlementListBO unionShareSettlementListBO = new UnionShareSettlementListBO();
unionShareSettlementListBO.setList(unionShareSettlement);
unionShareSettlementListBO.setList(unionShareSettlementList);
addToRedis(ShareOrdersKeyEnum.SETTLEMENT_LIST,unionShareOrderReqBO.getUid(),unionShareSettlementListBO,key, String.valueOf(unionShareOrderReqBO.getPage()), String.valueOf(unionShareOrderReqBO.getSize()));
return unionShareSettlement;
return unionShareSettlementList;
}
@Override
... ... @@ -317,6 +352,8 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
//数据库获取
//tab1表示1、全部订单;2、有效订单;3、无效订单 tab2表示1、已付款;2、待结算;3、结算中
List<UnionShareOrders> unionShareOrdersList = unionShareOrdersMapper.selectOrderList(unionShareOrderReqBO);
//处理订单列表数据
dealShareOrderList(unionShareOrdersList);
//设置缓存
UnionShareOrdersListBO unionShareOrdersListBO = new UnionShareOrdersListBO();
unionShareOrdersListBO.setList(unionShareOrdersList);
... ...