From b02c10cc0f53a3dac95045bea33eb9aa3c13e3e3 Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Fri, 02 Jul 2021 10:39:49 +0800
Subject: [PATCH] 20210630 积分拨付
---
gc-shop/src/main/java/com/xzx/gc/shop/service/OrderService.java | 51 +++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 49 insertions(+), 2 deletions(-)
diff --git a/gc-shop/src/main/java/com/xzx/gc/shop/service/OrderService.java b/gc-shop/src/main/java/com/xzx/gc/shop/service/OrderService.java
index 022caf0..86b4f88 100644
--- a/gc-shop/src/main/java/com/xzx/gc/shop/service/OrderService.java
+++ b/gc-shop/src/main/java/com/xzx/gc/shop/service/OrderService.java
@@ -61,7 +61,7 @@
private IdUtils idUtils;
public Map<String, Object> queryOrderList(QueryOrderListDto model) {
- String name = model.getName();
+ String name = StrUtil.isEmpty(model.getName())?model.getName():StringUtils.encode(model.getName());
String orderNo = model.getOrderNo();
Integer status = model.getStatus() == null ? 0 : model.getStatus();
Date createdTimeStart = model.getCreatedTimeStart();
@@ -72,6 +72,29 @@
for(QueryOrderListVo queryOrderListVo : maps){
String decode = StringUtils.decode(queryOrderListVo.getName());
queryOrderListVo.setName(decode);
+ BigDecimal totalPrice = new BigDecimal(StrUtil.isEmpty(queryOrderListVo.getTotalPrice()) ? "0" : queryOrderListVo.getTotalPrice())
+ .setScale( 2, BigDecimal.ROUND_DOWN );
+ queryOrderListVo.setTotalPrice(totalPrice.toString());
+
+ Long id = queryOrderListVo.getId();
+ Example example = new Example(ScoreOrderDetails.class);
+ Example.Criteria criteria = example.createCriteria();
+ criteria.andEqualTo("orderId",id);
+ List<ScoreOrderDetails> scoreOrderDetails = scoreOrderDetailsMapper.selectByExample(example);
+ if(CollUtil.isNotEmpty(scoreOrderDetails)){
+ StringBuffer stringBuffer = new StringBuffer();
+ for(ScoreOrderDetails scoreOrderDetail : scoreOrderDetails){
+ String goodsName = scoreOrderDetail.getGoodsName();
+ BigDecimal unitPrice = scoreOrderDetail.getUnitPrice();
+ String sku = scoreOrderDetail.getSku();
+ Integer cnt = scoreOrderDetail.getCnt();
+ BigDecimal totalPriceOrderDetail = scoreOrderDetail.getTotalPrice();
+ stringBuffer = stringBuffer.append(goodsName+"(")
+ .append("规格:"+sku+","+unitPrice.setScale( 2, BigDecimal.ROUND_DOWN ).toString()+"*"+cnt.toString()+",")
+ .append("总价:"+totalPriceOrderDetail.setScale( 2, BigDecimal.ROUND_DOWN ).toString()+";)");
+ }
+ queryOrderListVo.setOrderDetails(stringBuffer.toString());
+ }
}
}
PageInfo pageInfo = new PageInfo(maps);
@@ -152,7 +175,8 @@
public Long insureOrder(InsureOrderDto model) {
ScoreOrder scoreOrder = new ScoreOrder();
scoreOrder.setId(model.getId());
- scoreOrder.setStatus(ScoreOrder.STATUS_DONE);
+// scoreOrder.setStatus(ScoreOrder.STATUS_DONE);
+ scoreOrder.setIsFinish(ScoreOrder.ISFINISH_YES);
scoreOrder.setVoucherImg(CollUtil.join(model.getVoucherImgs(),","));
scoreOrderMapper.updateByPrimaryKeySelective(scoreOrder);
return scoreOrder.getId();
@@ -174,6 +198,10 @@
if (new Date().after(goods.getQgEndTime())) {
throw new RestException(-3, "抢购已结束");
}
+ }
+
+ if (addGoodsOrderDto.getCnt() > sku.getStock()) {
+ throw new RestException(-3, "库存不足");
}
AccountInfo accountInfo = accountInfoMapper.selectAccountInfoByUserId(addGoodsOrderDto.getUserId());
@@ -378,4 +406,23 @@
}
}
}
+
+ public StatisticsVo orderStatistics(String userId) {
+ BigDecimal score = scoreDetailsMapper.selectTotalScoreByUserId(userId, ScoreDetails.SCORE_TYPE_EXCHANGE);
+
+ Map<String, Object> userData = scoreOrderMapper.selectOrderStastics(userId);
+ Map<String, Object> allData = scoreOrderMapper.selectOrderStastics(null);
+
+ StatisticsVo statisticsVo = new StatisticsVo();
+ statisticsVo.setScore(score);
+ BigDecimal userPrice = (BigDecimal) userData.get("totalPrice");
+ statisticsVo.setReduceCarbon(userPrice.divide(BigDecimal.TEN, 2, BigDecimal.ROUND_DOWN));
+ statisticsVo.setOrderCnt(Integer.parseInt(userData.get("totalOrder").toString()));
+
+ BigDecimal totalPrice = (BigDecimal) allData.get("totalPrice");
+ statisticsVo.setTotalReduceCarbon(totalPrice.divide(BigDecimal.TEN, 2, BigDecimal.ROUND_DOWN));
+ statisticsVo.setTotalOrderCnt(Integer.parseInt(allData.get("totalOrder").toString()));
+ statisticsVo.setTotalBuyCnt(Integer.parseInt(allData.get("totalBuy").toString()));
+ return statisticsVo;
+ }
}
--
Gitblit v1.9.1