diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighDiscountPackageController.java b/hai-bweb/src/main/java/com/bweb/controller/HighDiscountPackageController.java index 4ccd39ce..d1042d98 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighDiscountPackageController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighDiscountPackageController.java @@ -165,6 +165,8 @@ public class HighDiscountPackageController { highDiscountPackage.setCreatedUserId(userInfoModel.getSecUser().getId().intValue()); highDiscountPackage.setUpdatedTime(new Date()); highDiscountPackage.setUpdatedUserId(userInfoModel.getSecUser().getId().intValue()); + highDiscountPackage.setTotalStock(0); + highDiscountPackage.setSurplusStock(0); highDiscountPackageService.insertDiscountPackage(highDiscountPackage); @@ -376,7 +378,7 @@ public class HighDiscountPackageController { throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, ""); } - HighDiscountPackage highDiscountPackage = highDiscountPackageService.findDiscountPackageById(object.getInteger("discountId")); + HighDiscountPackage highDiscountPackage = highDiscountPackageService.findDiscountPackageById(object.getInteger("discountPackageId")); if (highDiscountPackage == null || highDiscountPackage.getStatus() == 1) { log.error("highCouponPackage -> highCouponPackageInfo() error!","状态错误"); @@ -412,7 +414,7 @@ public class HighDiscountPackageController { throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, ""); } - HighDiscountPackage highDiscountPackage = highDiscountPackageService.findDiscountPackageById(object.getInteger("discountId")); + HighDiscountPackage highDiscountPackage = highDiscountPackageService.findDiscountPackageById(object.getInteger("discountPackageId")); if (highDiscountPackage == null || highDiscountPackage.getStatus() == 1 ) { log.error("highCouponPackage -> highCouponPackageInfo() error!","状态错误"); @@ -448,7 +450,7 @@ public class HighDiscountPackageController { throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, ""); } - HighDiscountPackage highDiscountPackage = highDiscountPackageService.findDiscountPackageById(object.getInteger("discountId")); + HighDiscountPackage highDiscountPackage = highDiscountPackageService.findDiscountPackageById(object.getInteger("discountPackageId")); if (highDiscountPackage == null) { log.error("highCouponPackage -> highCouponPackageInfo() error!","状态错误"); @@ -501,4 +503,40 @@ public class HighDiscountPackageController { } } + @RequestMapping(value="/addDiscountPackageStock",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "增加优惠券包库存") + public ResponseData addDiscountPackageStock(@RequestBody JSONObject object, HttpServletRequest request) { + try { + //发布人员 + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); + + if (userInfoModel.getBsCompany() == null) { + log.error("highCouponPackage -> highCouponPackageInfo() error!","该主角色没有权限"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, ""); + } + + HighDiscountPackage highDiscountPackage = highDiscountPackageService.findDiscountPackageById(object.getInteger("discountPackageId")); + + if (highDiscountPackage == null) { + log.error("highCouponPackage -> highCouponPackageInfo() error!","当前优惠券包不存在"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, ""); + } + + if (object.getInteger("num") == null) { + log.error("highCouponPackage -> highCouponPackageInfo() error!","请传入库存数量"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, ""); + } + + highDiscountPackageService.addDiscountPackageStock(highDiscountPackage , userInfoModel , object.getInteger("num")); + + return ResponseMsgUtil.success("增加库存成功"); + + } catch (Exception e) { + log.error("HighDiscountController -> getDiscountById() error!",e); + return ResponseMsgUtil.exception(e); + } + } + } diff --git a/hai-service/src/main/java/com/hai/service/HighDiscountPackageService.java b/hai-service/src/main/java/com/hai/service/HighDiscountPackageService.java index 7bd74765..4b5c0527 100644 --- a/hai-service/src/main/java/com/hai/service/HighDiscountPackageService.java +++ b/hai-service/src/main/java/com/hai/service/HighDiscountPackageService.java @@ -3,8 +3,10 @@ package com.hai.service; import com.hai.entity.HighDiscount; import com.hai.entity.HighDiscountPackage; import com.hai.entity.HighDiscountPackageRecord; +import com.hai.model.UserInfoModel; import io.swagger.models.auth.In; +import javax.servlet.http.HttpServletRequest; import java.util.List; import java.util.Map; @@ -77,5 +79,15 @@ public interface HighDiscountPackageService { */ List getDiscountPackageRecordList(Map map); + /** + * @Author Sum1Dream + * @name addDiscountPackageStock.java + * @Description // 新增优惠券包库存 + * @Date 11:32 上午 2021/12/7 + * @Param [com.hai.entity.HighDiscountPackage] + * @return void + */ + void addDiscountPackageStock(HighDiscountPackage highDiscountPackage, UserInfoModel userInfoModel , Integer num); + } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageServiceImpl.java index 2d25a914..9692734a 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageServiceImpl.java @@ -1,16 +1,19 @@ package com.hai.service.impl; -import com.hai.dao.HighDiscountPackageMapper; -import com.hai.dao.HighDiscountPackageRecordMapper; +import com.hai.dao.*; import com.hai.entity.*; -import com.hai.service.HighDiscountPackageService; +import com.hai.model.UserInfoModel; +import com.hai.service.*; import com.hai.service.HighDiscountPackageService; import org.apache.commons.collections4.MapUtils; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Isolation; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; -import java.util.List; -import java.util.Map; +import javax.servlet.http.HttpServletRequest; +import java.util.*; /** * @serviceName HighDiscountPackageServiceImpl.java @@ -28,6 +31,24 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic @Resource private HighDiscountPackageRecordMapper highDiscountPackageRecordMapper; + @Resource + private HighDiscountPackageDetailsService highDiscountPackageDetailsService; + + @Resource + private HighDiscountAgentRelService highDiscountAgentRelService; + + @Resource + private HighDiscountAgentCodeService highDiscountAgentCodeService; + + @Resource + private HighDiscountInventoryRecordMapper highDiscountInventoryRecordMapper; + + @Resource + private HighDiscountPackageActualMapper discountPackageActualMapper; + + @Resource + private HighDiscountPackageDiscountActualMapper discountPackageDiscountActualMapper; + @Override public List getDiscountPackageList(Map map) { @@ -116,4 +137,35 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic return highDiscountPackageRecordMapper.selectByExample(example); } + + @Override + @Transactional(propagation= Propagation.REQUIRES_NEW,isolation= Isolation.SERIALIZABLE) + public void addDiscountPackageStock(HighDiscountPackage highDiscountPackage, UserInfoModel userInfoModel , Integer num) { + + Map mapRule = new HashMap<>(); + mapRule.put("discountPackageId", highDiscountPackage.getId()); + + // 查询优惠券包规则 + List discountPackageDetailsList = highDiscountPackageDetailsService.getDiscountPackageDetailsList(mapRule); + + // 生成优惠券包实际库存实体 + HighDiscountPackageActual discountPackageActual = new HighDiscountPackageActual(); + discountPackageActual.setDiscountPackageId(highDiscountPackage.getId()); + discountPackageActual.setCreatedUserId(userInfoModel.getSecUser().getId().intValue()); + // 状态: 1: 待分配 2:预分配(售卖)3:已分配 + discountPackageActual.setStatus(1); + + for (int i = 0; i < num; i++) { + discountPackageActual.setCreatedTime(new Date()); + discountPackageActualMapper.insert(discountPackageActual); + } + + // 循环 优惠券包规则详情 列表 + for (HighDiscountPackageDetails detailsList: discountPackageDetailsList) { + // 查询代理商与优惠券关系 列表 + List discountAgentRels = highDiscountAgentRelService.getRelByDiscountAgent(detailsList.getDiscountId().longValue() , detailsList.getAgentId()); + + } + + } } diff --git a/hai-service/src/main/java/com/hai/service/impl/OutRechargePriceServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/OutRechargePriceServiceImpl.java index 644dff08..82d0d5f1 100644 --- a/hai-service/src/main/java/com/hai/service/impl/OutRechargePriceServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/OutRechargePriceServiceImpl.java @@ -34,7 +34,7 @@ public class OutRechargePriceServiceImpl implements OutRechargePriceService { OutRechargePriceExample example = new OutRechargePriceExample(); OutRechargePriceExample.Criteria criteria = example.createCriteria(); - criteria.andStatusEqualTo(1); + criteria.andStatusNotEqualTo(0); if (StringUtils.isNotBlank(map.get("type"))) { criteria.andTypeEqualTo(Integer.valueOf(map.get("type")));