diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighGoodsPriceReferController.java b/hai-bweb/src/main/java/com/bweb/controller/HighGoodsPriceReferController.java new file mode 100644 index 00000000..ca916280 --- /dev/null +++ b/hai-bweb/src/main/java/com/bweb/controller/HighGoodsPriceReferController.java @@ -0,0 +1,105 @@ +package com.bweb.controller; + +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.hai.common.exception.ErrorCode; +import com.hai.common.exception.ErrorHelp; +import com.hai.common.exception.SysCode; +import com.hai.common.security.SessionObject; +import com.hai.common.security.UserCenter; +import com.hai.common.utils.DateUtil; +import com.hai.common.utils.ResponseMsgUtil; +import com.hai.entity.HighCouponHandsel; +import com.hai.entity.HighGoodsPriceRefer; +import com.hai.entity.HighMerchant; +import com.hai.model.HighCouponModel; +import com.hai.model.ResponseData; +import com.hai.model.UserInfoModel; +import com.hai.service.HighGoodsPriceReferService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +/** + * @Auther: 胡锐 + * @Description: + * @Date: 2021/3/21 20:11 + */ +@Controller +@RequestMapping(value = "/highGoodsPriceRefer") +@Api(value = "产品价格配置接口") +public class HighGoodsPriceReferController { + + private static Logger log = LoggerFactory.getLogger(HighGoodsPriceReferController.class); + + @Autowired + private UserCenter userCenter; + + @Resource + private HighGoodsPriceReferService highGoodsPriceReferService; + + @RequestMapping(value="/insertGoodsPriceRefer",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "增加产品销售价格") + public ResponseData insertGoodsPriceRefer(@RequestBody HighGoodsPriceRefer highGoodsPriceRefer, HttpServletRequest request) { + try { + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); + if (highGoodsPriceRefer.getObjectType() == null + || highGoodsPriceRefer.getObjectId() == null + || highGoodsPriceRefer.getPromptlyType() == null + || highGoodsPriceRefer.getNewSalePrice() == null + || highGoodsPriceRefer.getEffectiveTime() == null) { + log.error("HighGoodsPriceReferController -> insertGoodsPriceRefer() error!","参数错误"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + highGoodsPriceRefer.setCreateTime(new Date()); + highGoodsPriceRefer.setStatus(101); // 状态: 0:删除 1:待编辑 2:待生效 3:已生效 4:已失效 101.审批中 102.审批驳回 + highGoodsPriceRefer.setOperatorId(userInfoModel.getSecUser().getId()); + highGoodsPriceRefer.setOperatorName(userInfoModel.getSecUser().getUserName()); + highGoodsPriceReferService.insertPriceRefer(highGoodsPriceRefer); + + return ResponseMsgUtil.success("操作成功"); + + } catch (Exception e) { + log.error("HighGoodsPriceReferController -> insertGoodsPriceRefer() error!",e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/getPriceReferList",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询价格列表") + public ResponseData getPriceReferList(@RequestParam(name = "objectType", required = true) Integer objectType, + @RequestParam(name = "objectId", required = true) Long objectId, + @RequestParam(name = "status", required = false) Integer status, + @RequestParam(name = "pageNum", required = true) Integer pageNum, + @RequestParam(name = "pageSize", required = true) Integer pageSize) { + try { + Map map = new HashMap<>(); + map.put("objectType", objectType); + map.put("objectId", objectId); + map.put("status", status); + + PageHelper.startPage(pageNum,pageSize); + return ResponseMsgUtil.success(new PageInfo<>(highGoodsPriceReferService.getPriceList(map))); + + } catch (Exception e) { + log.error("HighGoodsPriceReferController -> getPriceReferList() error!",e); + return ResponseMsgUtil.exception(e); + } + } + +} diff --git a/hai-cweb/src/main/resources/dev/config.properties b/hai-cweb/src/main/resources/dev/config.properties index 3ce860c5..4a9c0107 100644 --- a/hai-cweb/src/main/resources/dev/config.properties +++ b/hai-cweb/src/main/resources/dev/config.properties @@ -1,5 +1,5 @@ wxAppId=wx8d49e2f83025229d wxAppSecret=d8d6dcaef77d3b659258a01b5ddba5df -mvn + fileUrl=/home/project/hsg/filesystem cmsPath=/home/project/hsg/filesystem/cmsPath diff --git a/hai-service/src/main/java/com/hai/common/exception/ErrorCode.java b/hai-service/src/main/java/com/hai/common/exception/ErrorCode.java index bf99c7ad..9c97a781 100644 --- a/hai-service/src/main/java/com/hai/common/exception/ErrorCode.java +++ b/hai-service/src/main/java/com/hai/common/exception/ErrorCode.java @@ -88,6 +88,7 @@ public enum ErrorCode { COUPON_STOCK_ERROR("2116","卡卷库存数量错误"), COUPON_TYPE_ERROR("2117","卡卷类型错误"), COUPON_STATUS_ERROR("2118","卡卷状态错误"), + GOODS_PRICE_REFER_ERROR("2119","未找到价格信息"), STATUS_ERROR("3000","状态错误"), ADD_DATA_ERROR("3001","增加数据失败"), diff --git a/hai-service/src/main/java/com/hai/enum_type/ApproveType.java b/hai-service/src/main/java/com/hai/enum_type/ApproveType.java index 7a82fad3..ce26d044 100644 --- a/hai-service/src/main/java/com/hai/enum_type/ApproveType.java +++ b/hai-service/src/main/java/com/hai/enum_type/ApproveType.java @@ -6,7 +6,8 @@ package com.hai.enum_type; * @Date: 2021/3/14 20:41 */ public enum ApproveType { - UP_SHELF_APPROVE(1, "卡卷上架审批") + UP_SHELF_APPROVE(1, "卡卷上架审批"), + COUPON_PRICE_APPROVE(2, "卡卷价格审批") ; private Integer type; diff --git a/hai-service/src/main/java/com/hai/service/HighApproveService.java b/hai-service/src/main/java/com/hai/service/HighApproveService.java index 07fe8c39..8dfc7b4d 100644 --- a/hai-service/src/main/java/com/hai/service/HighApproveService.java +++ b/hai-service/src/main/java/com/hai/service/HighApproveService.java @@ -19,6 +19,13 @@ public interface HighApproveService { **/ void insertApprove(HighApprove highApprove); + /** + * @Author 胡锐 + * @Description 修改审批 + * @Date 2021/3/21 22:12 + **/ + void updateApprove(HighApprove highApprove); + /** * * @Title: getApproveById diff --git a/hai-service/src/main/java/com/hai/service/HighCouponService.java b/hai-service/src/main/java/com/hai/service/HighCouponService.java index c7f3da0e..49e48497 100644 --- a/hai-service/src/main/java/com/hai/service/HighCouponService.java +++ b/hai-service/src/main/java/com/hai/service/HighCouponService.java @@ -22,8 +22,6 @@ public interface HighCouponService { **/ void insertCoupon(HighCouponModel highCouponModel); - - /** * @Author 胡锐 * @Description 修改卡卷业务 @@ -63,7 +61,12 @@ public interface HighCouponService { **/ void ofShelfCoupon(Long id); - + /** + * @Author 胡锐 + * @Description 价格审批结果 + * @Date 2021/3/21 22:08 + **/ + void priceApproveResult(HighApprove highApprove); /** * @Author 胡锐 diff --git a/hai-service/src/main/java/com/hai/service/HighGoodsPriceReferService.java b/hai-service/src/main/java/com/hai/service/HighGoodsPriceReferService.java index 9a253765..0d4d9912 100644 --- a/hai-service/src/main/java/com/hai/service/HighGoodsPriceReferService.java +++ b/hai-service/src/main/java/com/hai/service/HighGoodsPriceReferService.java @@ -30,6 +30,13 @@ public interface HighGoodsPriceReferService { **/ void updatePriceRefer(HighGoodsPriceRefer highGoodsPriceRefer); + /** + * @Author 胡锐 + * @Description 根据id查询 + * @Date 2021/3/21 22:15 + **/ + HighGoodsPriceRefer getPriceReferById(Long id); + /** * @Author 胡锐 * @Description 卡卷价格 处于待编辑、已生效、待生效、审批中 全部失效 diff --git a/hai-service/src/main/java/com/hai/service/impl/HighApproveServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighApproveServiceImpl.java index 486b760d..c4c337a1 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighApproveServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighApproveServiceImpl.java @@ -47,6 +47,11 @@ public class HighApproveServiceImpl implements HighApproveService { highApproveMapper.insert(highApprove); } + @Override + public void updateApprove(HighApprove highApprove) { + highApproveMapper.updateByPrimaryKey(highApprove); + } + @Override public HighApprove getApproveById(Long id) { return highApproveMapper.selectByPrimaryKey(id); @@ -57,6 +62,12 @@ public class HighApproveServiceImpl implements HighApproveService { if (highApprove.getObjectType() == ApproveType.UP_SHELF_APPROVE.getType()) { highCouponService.upShelfApproveResult(highApprove); } + + if (highApprove.getObjectType() == ApproveType.COUPON_PRICE_APPROVE.getType()) { + highCouponService.priceApproveResult(highApprove); + } + + updateApprove(highApprove); } @Override diff --git a/hai-service/src/main/java/com/hai/service/impl/HighCouponServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighCouponServiceImpl.java index 78a4d1f5..ee44e081 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighCouponServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighCouponServiceImpl.java @@ -166,7 +166,6 @@ public class HighCouponServiceImpl implements HighCouponService { } highCouponMapper.updateByPrimaryKey(couponDetail); - highApproveService.approveProcessed(highApprove); } @Override @@ -187,6 +186,39 @@ public class HighCouponServiceImpl implements HighCouponService { highGoodsPriceReferService.couponAllInvalidKeepCurrent(coupon.getId()); } + @Override + @Transactional(propagation= Propagation.REQUIRES_NEW) + public void priceApproveResult(HighApprove highApprove) { + HighGoodsPriceRefer highGoodsPriceRefer = highGoodsPriceReferService.getPriceReferById(highApprove.getObjectId()); + if (highGoodsPriceRefer == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.GOODS_PRICE_REFER_ERROR, ""); + } + // 状态: 0:删除 1:待编辑 2:待生效 3:已生效 4:已失效 101.审批中 102.审批驳回 + if (highGoodsPriceRefer.getStatus() != 101) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.STATUS_ERROR, ""); + } + + // 卡卷信息 + HighCouponModel coupon = getCouponById(highGoodsPriceRefer.getObjectId()); + if (coupon == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_COUPON, ""); + } + + // 状态: 1:待审批 2:驳回 3:通过 + if (highApprove.getStatus() == 1) { + // 及时生效 0:否 1:是 + if (highGoodsPriceRefer.getPromptlyType() == true) { + coupon.setCouponPrice(highGoodsPriceRefer.getNewSalePrice()); + update(coupon); + } + highGoodsPriceRefer.setStatus(2); + } + if (highApprove.getStatus() == 2) { + highGoodsPriceRefer.setStatus(102); + } + highGoodsPriceReferService.updatePriceRefer(highGoodsPriceRefer); + } + @Override public HighCouponModel getCouponById(Long id) { HighCoupon highCoupon = highCouponMapper.selectByPrimaryKey(id); diff --git a/hai-service/src/main/java/com/hai/service/impl/HighGoodsPriceReferServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighGoodsPriceReferServiceImpl.java index beedd683..39782565 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighGoodsPriceReferServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighGoodsPriceReferServiceImpl.java @@ -34,6 +34,11 @@ public class HighGoodsPriceReferServiceImpl implements HighGoodsPriceReferServic highGoodsPriceReferMapper.updateByPrimaryKey(highGoodsPriceRefer); } + @Override + public HighGoodsPriceRefer getPriceReferById(Long id) { + return highGoodsPriceReferMapper.selectByPrimaryKey(id); + } + @Override public void couponAllPriceInvalid(Long couponId) { List statusList = new ArrayList<>();