Authored by zhaoqing

联盟红人

@@ -49,7 +49,7 @@ public interface UnionShareOrdersMapper { @@ -49,7 +49,7 @@ public interface UnionShareOrdersMapper {
49 49
50 int updateByPrimaryKey(UnionShareOrders record); 50 int updateByPrimaryKey(UnionShareOrders record);
51 51
52 - UnionShareOrders selectRecentlyOrderLimitTen(@Param("uid") int uid); 52 + List<UnionShareOrders> selectRecentlyOrderLimitTen(@Param("uid") int uid);
53 53
54 List<UnionShareOrders> selectOrderList(@Param("params") UnionShareOrderReqBO unionShareOrderReqBO); 54 List<UnionShareOrders> selectOrderList(@Param("params") UnionShareOrderReqBO unionShareOrderReqBO);
55 } 55 }
@@ -15,12 +15,18 @@ public class UnionShareOrders { @@ -15,12 +15,18 @@ public class UnionShareOrders {
15 15
16 private BigDecimal lastOrderAmount; 16 private BigDecimal lastOrderAmount;
17 17
  18 + private String lastOrderAmountStr;
  19 +
18 private Integer orderTime; 20 private Integer orderTime;
19 21
  22 + private String orderTimeStr;
  23 +
20 private Byte isNew; 24 private Byte isNew;
21 25
22 private BigDecimal amount; 26 private BigDecimal amount;
23 27
  28 + private String amountStr;
  29 +
24 private Integer createTime; 30 private Integer createTime;
25 31
26 private Integer updateTime; 32 private Integer updateTime;
@@ -73,6 +79,14 @@ public class UnionShareOrders { @@ -73,6 +79,14 @@ public class UnionShareOrders {
73 this.orderTime = orderTime; 79 this.orderTime = orderTime;
74 } 80 }
75 81
  82 + public String getOrderTimeStr() {
  83 + return orderTimeStr;
  84 + }
  85 +
  86 + public void setOrderTimeStr(String orderTimeStr) {
  87 + this.orderTimeStr = orderTimeStr;
  88 + }
  89 +
76 public Byte getIsNew() { 90 public Byte getIsNew() {
77 return isNew; 91 return isNew;
78 } 92 }
@@ -112,4 +126,20 @@ public class UnionShareOrders { @@ -112,4 +126,20 @@ public class UnionShareOrders {
112 public void setSettlementCode(String settlementCode) { 126 public void setSettlementCode(String settlementCode) {
113 this.settlementCode = settlementCode; 127 this.settlementCode = settlementCode;
114 } 128 }
  129 +
  130 + public String getLastOrderAmountStr() {
  131 + return lastOrderAmountStr;
  132 + }
  133 +
  134 + public void setLastOrderAmountStr(String lastOrderAmountStr) {
  135 + this.lastOrderAmountStr = lastOrderAmountStr;
  136 + }
  137 +
  138 + public String getAmountStr() {
  139 + return amountStr;
  140 + }
  141 +
  142 + public void setAmountStr(String amountStr) {
  143 + this.amountStr = amountStr;
  144 + }
115 } 145 }
@@ -9,8 +9,12 @@ public class UnionShareSettlement { @@ -9,8 +9,12 @@ public class UnionShareSettlement {
9 9
10 private BigDecimal settlementAmount; 10 private BigDecimal settlementAmount;
11 11
  12 + private String settlementAmountStr;
  13 +
12 private Integer settlementTime; 14 private Integer settlementTime;
13 15
  16 + private String settlementTimeStr;
  17 +
14 private Integer promoteUid; 18 private Integer promoteUid;
15 19
16 private Byte status; 20 private Byte status;
@@ -41,6 +45,14 @@ public class UnionShareSettlement { @@ -41,6 +45,14 @@ public class UnionShareSettlement {
41 this.settlementAmount = settlementAmount; 45 this.settlementAmount = settlementAmount;
42 } 46 }
43 47
  48 + public String getSettlementAmountStr() {
  49 + return settlementAmountStr;
  50 + }
  51 +
  52 + public void setSettlementAmountStr(String settlementAmountStr) {
  53 + this.settlementAmountStr = settlementAmountStr;
  54 + }
  55 +
44 public Integer getSettlementTime() { 56 public Integer getSettlementTime() {
45 return settlementTime; 57 return settlementTime;
46 } 58 }
@@ -49,6 +61,14 @@ public class UnionShareSettlement { @@ -49,6 +61,14 @@ public class UnionShareSettlement {
49 this.settlementTime = settlementTime; 61 this.settlementTime = settlementTime;
50 } 62 }
51 63
  64 + public String getSettlementTimeStr() {
  65 + return settlementTimeStr;
  66 + }
  67 +
  68 + public void setSettlementTimeStr(String settlementTimeStr) {
  69 + this.settlementTimeStr = settlementTimeStr;
  70 + }
  71 +
52 public Integer getPromoteUid() { 72 public Integer getPromoteUid() {
53 return promoteUid; 73 return promoteUid;
54 } 74 }
@@ -97,8 +97,8 @@ public class UnionShareRest { @@ -97,8 +97,8 @@ public class UnionShareRest {
97 public UnionResponse queryRecentlyOrderLimitTen(int uid){ 97 public UnionResponse queryRecentlyOrderLimitTen(int uid){
98 log.info("UnionShareRest :: queryRecentlyOrderLimitTen uid is{}", uid); 98 log.info("UnionShareRest :: queryRecentlyOrderLimitTen uid is{}", uid);
99 try { 99 try {
100 - UnionShareOrders unionShareOrders = unionShareService.queryRecentlyOrderLimitTen(uid);  
101 - return new UnionResponse(200, "queryRecentlyOrderLimitTen success",unionShareOrders); 100 + List<UnionShareOrders> unionShareOrdersList = unionShareService.queryRecentlyOrderLimitTen(uid);
  101 + return new UnionResponse(200, "queryRecentlyOrderLimitTen success",unionShareOrdersList);
102 }catch (Exception e){ 102 }catch (Exception e){
103 log.error("UnionShareRest :: queryRecentlyOrderLimitTen error", e); 103 log.error("UnionShareRest :: queryRecentlyOrderLimitTen error", e);
104 return new UnionResponse(500,"queryRecentlyOrderLimitTen error!"); 104 return new UnionResponse(500,"queryRecentlyOrderLimitTen error!");
@@ -52,7 +52,7 @@ public interface IUnionShareService { @@ -52,7 +52,7 @@ public interface IUnionShareService {
52 * @param uid 52 * @param uid
53 * @return 53 * @return
54 */ 54 */
55 - UnionShareOrders queryRecentlyOrderLimitTen(int uid); 55 + List<UnionShareOrders> queryRecentlyOrderLimitTen(int uid);
56 56
57 /** 57 /**
58 * 订单明细 58 * 订单明细
@@ -34,6 +34,8 @@ import org.springframework.stereotype.Service; @@ -34,6 +34,8 @@ import org.springframework.stereotype.Service;
34 34
35 import javax.annotation.Resource; 35 import javax.annotation.Resource;
36 import java.math.BigDecimal; 36 import java.math.BigDecimal;
  37 +import java.text.DecimalFormat;
  38 +import java.text.SimpleDateFormat;
37 import java.util.*; 39 import java.util.*;
38 import java.util.concurrent.TimeUnit; 40 import java.util.concurrent.TimeUnit;
39 import java.util.concurrent.atomic.AtomicInteger; 41 import java.util.concurrent.atomic.AtomicInteger;
@@ -245,19 +247,35 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport @@ -245,19 +247,35 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
245 * @return 247 * @return
246 */ 248 */
247 @Override 249 @Override
248 - public UnionShareOrders queryRecentlyOrderLimitTen(int uid) { 250 + public List<UnionShareOrders> queryRecentlyOrderLimitTen(int uid) {
249 //先从缓存获取 251 //先从缓存获取
250 String key = "recentlyOrderLimitTen"; 252 String key = "recentlyOrderLimitTen";
251 - UnionShareOrders cacheResult = getFromRedis(ShareOrdersKeyEnum.RECENTLY_ORDER_LIMIT_TEN, uid, UnionShareOrders.class, key); 253 + UnionShareOrdersListBO cacheResult = getFromRedis(ShareOrdersKeyEnum.RECENTLY_ORDER_LIMIT_TEN, uid, UnionShareOrdersListBO.class, key);
252 if (cacheResult != null) { 254 if (cacheResult != null) {
253 logger.info("UnionShareServiceImpl :: queryRecentlyOrderLimitTen get redis cache ,uid is {},cacheResult is {}",uid,cacheResult); 255 logger.info("UnionShareServiceImpl :: queryRecentlyOrderLimitTen get redis cache ,uid is {},cacheResult is {}",uid,cacheResult);
254 - return cacheResult; 256 + return cacheResult.getList();
255 } 257 }
256 //获取数据库 258 //获取数据库
257 - UnionShareOrders unionShareOrders = unionShareOrdersMapper.selectRecentlyOrderLimitTen(uid); 259 + List<UnionShareOrders> unionShareOrdersList = unionShareOrdersMapper.selectRecentlyOrderLimitTen(uid);
  260 + //处理订单列表数据
  261 + dealShareOrderList(unionShareOrdersList);
  262 + UnionShareOrdersListBO unionShareOrdersListBO = new UnionShareOrdersListBO();
  263 + unionShareOrdersListBO.setList(unionShareOrdersList);
258 //设置缓存 264 //设置缓存
259 - addToRedis(ShareOrdersKeyEnum.RECENTLY_ORDER_LIMIT_TEN,uid,unionShareOrders,key);  
260 - return unionShareOrders; 265 + addToRedis(ShareOrdersKeyEnum.RECENTLY_ORDER_LIMIT_TEN,uid,unionShareOrdersListBO,key);
  266 + return unionShareOrdersList;
  267 + }
  268 +
  269 + private void dealShareOrderList(List<UnionShareOrders> unionShareOrdersList) {
  270 + if (CollectionUtils.isNotEmpty(unionShareOrdersList)){
  271 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd HH:mm");
  272 + DecimalFormat df1 = new DecimalFormat("0.00");
  273 + for (UnionShareOrders unionShareOrders : unionShareOrdersList){
  274 + unionShareOrders.setOrderTimeStr(sdf.format(unionShareOrders.getOrderTime()));
  275 + unionShareOrders.setLastOrderAmountStr(df1.format(unionShareOrders.getLastOrderAmount()));
  276 + unionShareOrders.setAmountStr("+"+df1.format(unionShareOrders.getAmount()));
  277 + }
  278 + }
261 } 279 }
262 280
263 @Override 281 @Override
@@ -276,12 +294,21 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport @@ -276,12 +294,21 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
276 } 294 }
277 List<UnionShareOrdersProduct> unionShareOrdersProductlist = unionShareOrdersProductMapper.selectOrdersProductByOrderCode(orderCode); 295 List<UnionShareOrdersProduct> unionShareOrdersProductlist = unionShareOrdersProductMapper.selectOrdersProductByOrderCode(orderCode);
278 List<ShareOrdersProductBo> shareOrdersProductBoList = convert.convertFromList(unionShareOrdersProductlist, ShareOrdersProductBo.class); 296 List<ShareOrdersProductBo> shareOrdersProductBoList = convert.convertFromList(unionShareOrdersProductlist, ShareOrdersProductBo.class);
  297 + //设置商品价格
  298 + DecimalFormat df1 = new DecimalFormat("0.00");
  299 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  300 + for (ShareOrdersProductBo shareOrdersProductBo : shareOrdersProductBoList){
  301 + shareOrdersProductBo.setPriceStr("¥"+df1.format(shareOrdersProductBo.getPrice()));
  302 + }
279 ShareOrderBo shareOrderBo = new ShareOrderBo(); 303 ShareOrderBo shareOrderBo = new ShareOrderBo();
280 shareOrderBo = convert.convertFrom(unionShareOrders,shareOrderBo,ShareOrderBo.class); 304 shareOrderBo = convert.convertFrom(unionShareOrders,shareOrderBo,ShareOrderBo.class);
281 shareOrderBo.setIsNew(unionShareOrders.getIsNew().toString()); 305 shareOrderBo.setIsNew(unionShareOrders.getIsNew().toString());
282 shareOrderBo.setProductList(shareOrdersProductBoList); 306 shareOrderBo.setProductList(shareOrdersProductBoList);
  307 + shareOrderBo.setOrderTimeStr(sdf.format(shareOrderBo.getOrderTime()));
  308 + shareOrderBo.setAmountStr("¥"+df1.format(shareOrderBo.getAmount()));
  309 + shareOrderBo.setLastOrderAmountStr("¥"+df1.format(shareOrderBo.getLastOrderAmount()));
283 //设置缓存 310 //设置缓存
284 - addToRedis(ShareOrdersKeyEnum.ORDER_INFO,uid,unionShareOrders,key, orderCode); 311 + addToRedis(ShareOrdersKeyEnum.ORDER_INFO,uid,shareOrderBo,key, orderCode);
285 return shareOrderBo; 312 return shareOrderBo;
286 } 313 }
287 314
@@ -296,13 +323,21 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport @@ -296,13 +323,21 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
296 return cacheResult.getList(); 323 return cacheResult.getList();
297 } 324 }
298 //数据库获取 325 //数据库获取
299 - List<UnionShareSettlement> unionShareSettlement = unionShareSettlementMapper.selectSettlementRecordByUid(unionShareOrderReqBO.getUid(), 326 + List<UnionShareSettlement> unionShareSettlementList = unionShareSettlementMapper.selectSettlementRecordByUid(unionShareOrderReqBO.getUid(),
300 unionShareOrderReqBO.getPage()*unionShareOrderReqBO.getSize(), unionShareOrderReqBO.getSize()); 327 unionShareOrderReqBO.getPage()*unionShareOrderReqBO.getSize(), unionShareOrderReqBO.getSize());
  328 + if (CollectionUtils.isNotEmpty(unionShareSettlementList)){
  329 + DecimalFormat df1 = new DecimalFormat("0.00");
  330 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd HH:mm");
  331 + for (UnionShareSettlement unionShareSettlement : unionShareSettlementList){
  332 + unionShareSettlement.setSettlementAmountStr("+"+df1.format(unionShareSettlement.getSettlementAmount()));
  333 + unionShareSettlement.setSettlementTimeStr(sdf.format(unionShareSettlement.getSettlementTime()));
  334 + }
  335 + }
301 //设置缓存 336 //设置缓存
302 UnionShareSettlementListBO unionShareSettlementListBO = new UnionShareSettlementListBO(); 337 UnionShareSettlementListBO unionShareSettlementListBO = new UnionShareSettlementListBO();
303 - unionShareSettlementListBO.setList(unionShareSettlement); 338 + unionShareSettlementListBO.setList(unionShareSettlementList);
304 addToRedis(ShareOrdersKeyEnum.SETTLEMENT_LIST,unionShareOrderReqBO.getUid(),unionShareSettlementListBO,key, String.valueOf(unionShareOrderReqBO.getPage()), String.valueOf(unionShareOrderReqBO.getSize())); 339 addToRedis(ShareOrdersKeyEnum.SETTLEMENT_LIST,unionShareOrderReqBO.getUid(),unionShareSettlementListBO,key, String.valueOf(unionShareOrderReqBO.getPage()), String.valueOf(unionShareOrderReqBO.getSize()));
305 - return unionShareSettlement; 340 + return unionShareSettlementList;
306 } 341 }
307 342
308 @Override 343 @Override
@@ -317,6 +352,8 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport @@ -317,6 +352,8 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
317 //数据库获取 352 //数据库获取
318 //tab1表示1、全部订单;2、有效订单;3、无效订单 tab2表示1、已付款;2、待结算;3、结算中 353 //tab1表示1、全部订单;2、有效订单;3、无效订单 tab2表示1、已付款;2、待结算;3、结算中
319 List<UnionShareOrders> unionShareOrdersList = unionShareOrdersMapper.selectOrderList(unionShareOrderReqBO); 354 List<UnionShareOrders> unionShareOrdersList = unionShareOrdersMapper.selectOrderList(unionShareOrderReqBO);
  355 + //处理订单列表数据
  356 + dealShareOrderList(unionShareOrdersList);
320 //设置缓存 357 //设置缓存
321 UnionShareOrdersListBO unionShareOrdersListBO = new UnionShareOrdersListBO(); 358 UnionShareOrdersListBO unionShareOrdersListBO = new UnionShareOrdersListBO();
322 unionShareOrdersListBO.setList(unionShareOrdersList); 359 unionShareOrdersListBO.setList(unionShareOrdersList);