zouxuan hace 4 años
padre
commit
634fb10b0a

+ 17 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRepairServiceImpl.java

@@ -9,6 +9,7 @@ import com.ym.mec.biz.dal.dao.StudentDao;
 import com.ym.mec.biz.dal.dao.StudentRepairDao;
 import com.ym.mec.biz.dal.dao.SysConfigDao;
 import com.ym.mec.biz.dal.dto.BasicUserDto;
+import com.ym.mec.biz.dal.dto.RepairGoodsDto;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.*;
 import com.ym.mec.biz.dal.page.RepairStudentQueryInfo;
@@ -112,6 +113,16 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
         repairInfo.setPayStatus(0);
         repairInfo.setCreateTime(date);
         repairInfo.setUpdateTime(date);
+        String goodsJson = repairInfo.getGoodsJson();
+        if(StringUtils.isNotEmpty(goodsJson)){
+            List<RepairGoodsDto> repairGoodsDtos = JSONObject.parseArray(goodsJson, RepairGoodsDto.class);
+            List<Integer> goodsIds = repairGoodsDtos.stream().map(e -> e.getId()).collect(Collectors.toList());
+            Map<Integer, BigDecimal> map = getMap("goods", "id_", "group_purchase_price_", goodsIds, Integer.class, BigDecimal.class);
+            repairGoodsDtos.forEach(e->{
+                e.setGroupPurchasePrice(map.get(e.getId()));
+            });
+            repairInfo.setGoodsJson(JSONObject.toJSONString(repairGoodsDtos));
+        }
         studentRepairDao.insert(repairInfo);
         if (repairInfo.getType() == 1) {
             Map<String, Object> repairInfoMap = new HashMap<>();
@@ -273,6 +284,12 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
         StudentRepair studentRepair = studentRepairDao.get(repairInfo.getId());
         studentDao.lockUser(studentRepair.getStudentId());
         BigDecimal amount = studentRepair.getAmount();
+        String goodsJson = studentRepair.getGoodsJson();
+        if(StringUtils.isNotEmpty(goodsJson)){
+            List<RepairGoodsDto> repairGoodsDtos = JSONObject.parseArray(goodsJson, RepairGoodsDto.class);
+            BigDecimal reduce = repairGoodsDtos.stream().map(e -> e.getGroupPurchasePrice()).reduce(BigDecimal.ZERO, BigDecimal::add);
+            amount = amount.add(reduce);
+        }
         String orderNo = idGeneratorService.generatorId("payment") + "";
         studentRepair.setIsUseBalancePayment(repairInfo.getIsUseBalancePayment());
         studentRepair.setTransNo(orderNo);