|
|
@@ -1,6 +1,7 @@
|
|
|
package com.izouma.jiashanxia.service;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
@@ -128,13 +129,17 @@ public class UserPackageFlowService {
|
|
|
}
|
|
|
|
|
|
// 用户已有套餐
|
|
|
+// Map<Long, UserPackage> userPackageMap = userPackageRepo.findAllByUserId(writeOffSaveVO.getUserId())
|
|
|
+// .stream()
|
|
|
+// .collect(Collectors.toMap(UserPackage::getGoodsInfoId, userPackage -> userPackage));
|
|
|
+
|
|
|
Map<Long, UserPackage> userPackageMap = userPackageRepo.findAllByUserId(writeOffSaveVO.getUserId())
|
|
|
.stream()
|
|
|
.collect(Collectors.toMap(UserPackage::getGoodsInfoId, userPackage -> userPackage));
|
|
|
|
|
|
List<GoodsDTO> goodsDTOS = JSONObject.parseArray(writeOffSaveVO.getContent(), GoodsDTO.class);
|
|
|
goodsDTOS.forEach(goodsDTO -> {
|
|
|
- UserPackage userPackage = userPackageMap.get(goodsDTO.getGoodsInfoId());
|
|
|
+ UserPackage userPackage = userPackageMap.get(goodsDTO.getUserPackageId());
|
|
|
if (ObjectUtil.isEmpty(userPackage)) {
|
|
|
throw new BusinessException("无此项目");
|
|
|
}
|
|
|
@@ -145,6 +150,7 @@ public class UserPackageFlowService {
|
|
|
throw new BusinessException("核销数量大于套餐数量");
|
|
|
}
|
|
|
userPackage.setNum(userPackage.getNum() - goodsDTO.getNum());
|
|
|
+
|
|
|
userPackageRepo.save(userPackage);
|
|
|
goodsDTO.setNum(-goodsDTO.getNum());
|
|
|
});
|