Browse Source

管乐迷商城改造

zouxuan 1 năm trước cách đây
mục cha
commit
187a2d629f

+ 29 - 33
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderDetailServiceImpl.java

@@ -884,10 +884,9 @@ public class StudentPaymentOrderDetailServiceImpl extends BaseServiceImpl<Long,
             List<Goods> goodsList = goodsService.findGoodsByIds(goodsIdsStr);
             Map<Integer, Goods> goodsMap = goodsList.stream().collect(Collectors.toMap(Goods::getId, t -> t));
             BigDecimal totalGroupPurchasePrice =
-                    goodsSellDtos.stream().map(t -> goodsMap.get(t.getGoodsId()).getGroupPurchasePrice().
+                    goodsSellDtos.stream().map(t -> goodsMap.get(t.getGoodsId()).getDiscountPrice().
                             multiply(new BigDecimal(t.getGoodsNum()))).reduce(BigDecimal.ZERO, BigDecimal::add);
 
-            Goods goods = null;
             String[] goodsIds = goodsIdsStr.split(",");
             BigDecimal subTotalPrice = totalGroupPurchasePrice;
             for (int i = 0; i < goodsIds.length; i++) {
@@ -895,39 +894,36 @@ public class StudentPaymentOrderDetailServiceImpl extends BaseServiceImpl<Long,
                 if (StringUtils.isBlank(goodsIdStr)) {
                     continue;
                 }
-                goods = goodsMap.get(Integer.parseInt(goodsIdStr));
-
-                if (goods != null) {
-                    studentPaymentOrderDetail = new StudentPaymentOrderDetail();
-                    studentPaymentOrderDetail.setCreateTime(date);
-                    studentPaymentOrderDetail.setTenantId(studentPaymentOrder.getTenantId());
-                    if (goods.getType() == GoodsType.INSTRUMENT) {
-                        studentPaymentOrderDetail.setType(OrderDetailTypeEnum.MUSICAL);
-                    } else if (goods.getType() == GoodsType.ACCESSORIES) {
-                        studentPaymentOrderDetail.setType(OrderDetailTypeEnum.ACCESSORIES);
-                    } else if (goods.getType() == GoodsType.TEACHING || goods.getType() == GoodsType.STAFF) {
-                        studentPaymentOrderDetail.setType(OrderDetailTypeEnum.TEACHING);
-                    } else {
-                        studentPaymentOrderDetail.setType(OrderDetailTypeEnum.OTHER);
-                    }
-                    studentPaymentOrderDetail.setGoodsIdList(goodsIdStr);
+                Goods goods = goodsMap.get(Integer.parseInt(goodsIdStr));
+                studentPaymentOrderDetail = new StudentPaymentOrderDetail();
+                studentPaymentOrderDetail.setCreateTime(date);
+                studentPaymentOrderDetail.setTenantId(studentPaymentOrder.getTenantId());
+                if (goods.getType() == GoodsType.INSTRUMENT) {
+                    studentPaymentOrderDetail.setType(OrderDetailTypeEnum.MUSICAL);
+                } else if (goods.getType() == GoodsType.ACCESSORIES) {
+                    studentPaymentOrderDetail.setType(OrderDetailTypeEnum.ACCESSORIES);
+                } else if (goods.getType() == GoodsType.TEACHING || goods.getType() == GoodsType.STAFF) {
+                    studentPaymentOrderDetail.setType(OrderDetailTypeEnum.TEACHING);
+                } else {
+                    studentPaymentOrderDetail.setType(OrderDetailTypeEnum.OTHER);
+                }
+                studentPaymentOrderDetail.setGoodsIdList(goodsIdStr);
 
-                    //获取比例
-                    BigDecimal tempPrice = BigDecimal.ZERO;
-                    if (totalGroupPurchasePrice.compareTo(BigDecimal.ZERO) > 0) {
-                        tempPrice = goods.getDiscountPrice().divide(totalGroupPurchasePrice,6, RoundingMode.DOWN);
-                    }
-                    if(i == goodsIds.length - 1){
-                        studentPaymentOrderDetail.setPrice(subTotalPrice);
-                    }else {
-                        BigDecimal decimal = studentPaymentOrder.getExpectAmount().multiply(tempPrice).setScale(2, RoundingMode.DOWN);
-                        studentPaymentOrderDetail.setPrice(decimal);
-                        subTotalPrice = subTotalPrice.subtract(decimal);
-                    }
-                    studentPaymentOrderDetail.setUpdateTime(date);
-                    studentPaymentOrderDetail.setPaymentOrderId(studentPaymentOrder.getId());
-                    studentPaymentOrderDetailList.add(studentPaymentOrderDetail);
+                //获取比例
+                BigDecimal tempPrice = BigDecimal.ZERO;
+                if (totalGroupPurchasePrice.compareTo(BigDecimal.ZERO) > 0) {
+                    tempPrice = goods.getDiscountPrice().divide(totalGroupPurchasePrice,6, RoundingMode.DOWN);
+                }
+                if(i == goodsIds.length - 1){
+                    studentPaymentOrderDetail.setPrice(subTotalPrice);
+                }else {
+                    BigDecimal decimal = studentPaymentOrder.getExpectAmount().multiply(tempPrice).setScale(2, RoundingMode.DOWN);
+                    studentPaymentOrderDetail.setPrice(decimal);
+                    subTotalPrice = subTotalPrice.subtract(decimal);
                 }
+                studentPaymentOrderDetail.setUpdateTime(date);
+                studentPaymentOrderDetail.setPaymentOrderId(studentPaymentOrder.getId());
+                studentPaymentOrderDetailList.add(studentPaymentOrderDetail);
             }
         }