瀏覽代碼

管乐迷商城改造

zouxuan 1 年之前
父節點
當前提交
b5d7d1af4d

+ 2 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SellOrderServiceImpl.java

@@ -280,7 +280,7 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
             mallOrder.setPayType(1);
         }
         mallOrder.setMemberId(studentPaymentOrder.getUserId()==null?0L:studentPaymentOrder.getUserId().longValue());
-        mallOrder.setPlatformType("STUDENT");
+        mallOrder.setPlatformType(studentPaymentOrder.getUserId()==null?"SCHOOL":"STUDENT");
         mallOrder.setSourceType(1);
 
         // 乐团学生报名默认收货地址
@@ -340,7 +340,7 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
 
         CommonResult<Boolean> result = mallFeignService.productOrderCreate(mallOrder);
         if (result.getCode() != 200) {
-            throw new BizException("同步商城订单失败",result.getMessage());
+            throw new BizException("同步商城订单失败:{}",result.getMessage());
         }
     }
 

+ 12 - 11
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderDetailServiceImpl.java

@@ -872,8 +872,6 @@ public class StudentPaymentOrderDetailServiceImpl extends BaseServiceImpl<Long,
         // 添加studentPaymentOrderDetail
         StudentPaymentOrderDetail studentPaymentOrderDetail = null;
 
-        BigDecimal totalPrice = BigDecimal.ZERO;
-
         if (goodsSellDtos != null) {
             StringBuffer sb = new StringBuffer();
             for (GoodsSellDto goodsSellDto : goodsSellDtos) {
@@ -890,7 +888,10 @@ public class StudentPaymentOrderDetailServiceImpl extends BaseServiceImpl<Long,
                             multiply(new BigDecimal(t.getGoodsNum()))).reduce(BigDecimal.ZERO, BigDecimal::add);
 
             Goods goods = null;
-            for (String goodsIdStr : goodsIdsStr.split(",")) {
+            String[] goodsIds = goodsIdsStr.split(",");
+            BigDecimal subTotalPrice = totalGroupPurchasePrice;
+            for (int i = 0; i < goodsIds.length; i++) {
+                String goodsIdStr = goodsIds[i];
                 if (StringUtils.isBlank(goodsIdStr)) {
                     continue;
                 }
@@ -911,20 +912,20 @@ public class StudentPaymentOrderDetailServiceImpl extends BaseServiceImpl<Long,
                     }
                     studentPaymentOrderDetail.setGoodsIdList(goodsIdStr);
 
+                    //获取比例
                     BigDecimal tempPrice = BigDecimal.ZERO;
                     if (totalGroupPurchasePrice.compareTo(BigDecimal.ZERO) > 0) {
-                        tempPrice = studentPaymentOrder.getExpectAmount().multiply(goods.getGroupPurchasePrice()).divide(totalGroupPurchasePrice, RoundingMode.DOWN).setScale(2, RoundingMode.DOWN);
+                        tempPrice = goods.getDiscountPrice().divide(totalGroupPurchasePrice,6, RoundingMode.DOWN);
                     }
-
-                    if (totalPrice.add(tempPrice).compareTo(studentPaymentOrder.getExpectAmount()) > 0 || goodsIdsStr.split(",").length == studentPaymentOrderDetailList.size() + 1) {
-                        studentPaymentOrderDetail.setPrice(studentPaymentOrder.getExpectAmount().subtract(totalPrice));
-                    } else {
-                        studentPaymentOrderDetail.setPrice(tempPrice);
+                    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());
-
-                    totalPrice = totalPrice.add(studentPaymentOrderDetail.getPrice());
                     studentPaymentOrderDetailList.add(studentPaymentOrderDetail);
                 }
             }