diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighApproveController.java b/hai-bweb/src/main/java/com/bweb/controller/HighApproveController.java new file mode 100644 index 00000000..6b187c29 --- /dev/null +++ b/hai-bweb/src/main/java/com/bweb/controller/HighApproveController.java @@ -0,0 +1,94 @@ +package com.bweb.controller; + +import com.alibaba.fastjson.JSONObject; +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.HighApprove; +import com.hai.entity.HighCouponHandsel; +import com.hai.entity.HighMerchant; +import com.hai.model.HighCouponModel; +import com.hai.model.ResponseData; +import com.hai.model.UserInfoModel; +import com.hai.service.HighApproveService; +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.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.util.Date; + +/** + * @ClassName HighApproveController + * @Description: 审批操作 + * @Author 胡锐 + * @Date 2021/3/16 + **/ +@Controller +@RequestMapping(value = "/coupon") +@Api(value = "卡卷接口") +public class HighApproveController { + + private static Logger log = LoggerFactory.getLogger(HighApproveController.class); + + @Autowired + private UserCenter userCenter; + + @Resource + private HighApproveService highApproveService; + + @RequestMapping(value="/approveProcessed",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "审批") + public ResponseData approveProcessed(@RequestBody String reqBody, HttpServletRequest request) { + try { + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); + + JSONObject jsonObject = JSONObject.parseObject(reqBody); + Long approveId = jsonObject.getLong("approveId"); + Integer status = jsonObject.getInteger("status"); + String remarks = jsonObject.getString("remarks"); + if(approveId == null || status == null) { + log.error("HighCouponController -> approveProcessed() error!","参数错误"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + // 查询审批记录 + HighApprove approve = highApproveService.getApproveById(approveId); + if (approve == null) { + log.error("HighCouponController -> approveProcessed() error!","未找到审批记录"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_APPROVE, ""); + } + if (approve.getStatus() != 1) { + log.error("HighCouponController -> approveProcessed() error!","审批已处理"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.APPROVE_PROCESSED, ""); + } + + approve.setRemarks(remarks); + approve.setUpdateTime(new Date()); + approve.setApproveOperatorId(userInfoModel.getSecUser().getId()); + approve.setApproveOperatorName(userInfoModel.getSecUser().getUserName()); + highApproveService.approveProcessed(approve); + + return ResponseMsgUtil.success("操作成功"); + + } catch (Exception e) { + log.error("HighCouponController -> approveProcessed() error!",e); + return ResponseMsgUtil.exception(e); + } + } +} diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java b/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java index d3e916f7..de037112 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java @@ -232,7 +232,7 @@ public class HighCouponController { public ResponseData ofShelfApprove(@RequestParam(name = "id", required = true) Long id) { try { - highCouponService.ofShelfApprove(id); + highCouponService.ofShelfCoupon(id); return ResponseMsgUtil.success("操作成功"); } catch (Exception e) { @@ -258,13 +258,17 @@ public class HighCouponController { @RequestMapping(value="/getCouponList",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "卡卷列表") - public ResponseData getCouponList(@RequestParam(name = "couponName", required = false) String couponName, + public ResponseData getCouponList(@RequestParam(name = "companyId", required = false) Long companyId, + @RequestParam(name = "merchantId", required = false) Long merchantId, + @RequestParam(name = "couponName", required = false) String couponName, @RequestParam(name = "couponType", required = false) Integer couponType, @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("companyId", companyId); + map.put("merchantId", merchantId); map.put("couponName", couponName); map.put("couponType", couponType); map.put("status", status); 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 20d3004f..06a58bb5 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 @@ -83,7 +83,8 @@ public enum ErrorCode { NOT_FOUND_COUPON("2111","未找到卡卷信息"), WRITE_COUPON_NUMBER_ERROR("2112","请填写卡卷数量"), COUPON_UNABLE_UP_SHELF("2113","卡卷状态错误"), - + NOT_FOUND_APPROVE("2114","未找到审批记录"), + APPROVE_PROCESSED("2115","审批已处理"), STATUS_ERROR("3000","状态错误"), ADD_DATA_ERROR("3001","增加数据失败"), diff --git a/hai-service/src/main/java/com/hai/model/HighCouponCodeModel.java b/hai-service/src/main/java/com/hai/model/HighCouponCodeModel.java new file mode 100644 index 00000000..08cb1a56 --- /dev/null +++ b/hai-service/src/main/java/com/hai/model/HighCouponCodeModel.java @@ -0,0 +1,13 @@ +package com.hai.model; + +/** + * @ClassName HighCouponCodeModel + * @Description: + * @Author 胡锐 + * @Date 2021/3/16 + **/ +public interface HighCouponCodeModel { + + + +} diff --git a/hai-service/src/main/java/com/hai/model/HighCouponHandselModel.java b/hai-service/src/main/java/com/hai/model/HighCouponHandselModel.java index b315363e..e3369bc6 100644 --- a/hai-service/src/main/java/com/hai/model/HighCouponHandselModel.java +++ b/hai-service/src/main/java/com/hai/model/HighCouponHandselModel.java @@ -10,13 +10,13 @@ import com.hai.entity.HighCouponHandsel; */ public class HighCouponHandselModel extends HighCouponHandsel { - HighCoupon highCoupon; + HighCouponModel highCouponModel; - public HighCoupon getHighCoupon() { - return highCoupon; + public HighCouponModel getHighCouponModel() { + return highCouponModel; } - public void setHighCoupon(HighCoupon highCoupon) { - this.highCoupon = highCoupon; + public void setHighCouponModel(HighCouponModel highCouponModel) { + this.highCouponModel = highCouponModel; } } diff --git a/hai-service/src/main/java/com/hai/model/HighCouponModel.java b/hai-service/src/main/java/com/hai/model/HighCouponModel.java index 61b83ff5..8e47d115 100644 --- a/hai-service/src/main/java/com/hai/model/HighCouponModel.java +++ b/hai-service/src/main/java/com/hai/model/HighCouponModel.java @@ -12,8 +12,20 @@ import java.util.List; */ public class HighCouponModel extends HighCoupon { + // 库存数量 + private Integer stockCount; + + // 赠送卡卷 List handselCouponList; + public Integer getStockCount() { + return stockCount; + } + + public void setStockCount(Integer stockCount) { + this.stockCount = stockCount; + } + public List getHandselCouponList() { return handselCouponList; } 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 fde1e1c1..142f1460 100644 --- a/hai-service/src/main/java/com/hai/service/HighApproveService.java +++ b/hai-service/src/main/java/com/hai/service/HighApproveService.java @@ -2,6 +2,8 @@ package com.hai.service; import com.hai.entity.HighApprove; +import java.util.List; + /** * @Auther: 胡锐 * @Description: @@ -16,4 +18,26 @@ public interface HighApproveService { **/ void insertApprove(HighApprove highApprove); + /** + * + * @Title: getApproveById + * @Author 胡锐 + * @Description: 根据id查询审批记录 + * @Date 15:01 2021/3/16 + * @Param [id] + * @return com.hai.entity.HighApprove + **/ + HighApprove getApproveById(Long id); + + /** + * + * @Title: approveProcessed + * @Author 胡锐 + * @Description: 处理审批 + * @Date 15:31 2021/3/16 + * @Param [highApprove] + * @return void + **/ + void approveProcessed(HighApprove highApprove); + } diff --git a/hai-service/src/main/java/com/hai/service/HighCouponCodeService.java b/hai-service/src/main/java/com/hai/service/HighCouponCodeService.java index 44b20793..7c91a57a 100644 --- a/hai-service/src/main/java/com/hai/service/HighCouponCodeService.java +++ b/hai-service/src/main/java/com/hai/service/HighCouponCodeService.java @@ -1,6 +1,9 @@ package com.hai.service; import com.hai.entity.HighCouponCode; +import com.hai.model.HighCouponCodeModel; + +import java.util.List; /** * @Auther: 胡锐 @@ -16,4 +19,15 @@ public interface HighCouponCodeService { **/ void insertCouponCode(HighCouponCode highCouponCode); + /** + * + * @Title: getStockCountByCoupon + * @Author 胡锐 + * @Description: 查询卡卷的库存数量 + * @Date 11:24 2021/3/16 + * @Param [couponId] + * @return java.lang.Integer + **/ + Integer getStockCountByCoupon(Long couponId); + } diff --git a/hai-service/src/main/java/com/hai/service/HighCouponHandselService.java b/hai-service/src/main/java/com/hai/service/HighCouponHandselService.java new file mode 100644 index 00000000..76e5060b --- /dev/null +++ b/hai-service/src/main/java/com/hai/service/HighCouponHandselService.java @@ -0,0 +1,60 @@ +package com.hai.service; + +import com.hai.entity.HighCouponHandsel; +import com.hai.model.HighCouponHandselModel; + +import java.util.List; +import java.util.Map; + +/** + * @ClassName HighCouponHandselService + * @Description: 赠送卡卷配置 + * @Author 胡锐 + * @Date 2021/3/16 + **/ +public interface HighCouponHandselService { + + /** + * + * @Title: insertCouponHandsel + * @Author 胡锐 + * @Description: 增加 + * @Date 11:02 2021/3/16 + * @Param [highCouponHandsel] + * @return void + **/ + void insertCouponHandsel(HighCouponHandsel highCouponHandsel); + + /** + * + * @Title: updateCouponHandsel + * @Author 胡锐 + * @Description: 修改 + * @Date 11:04 2021/3/16 + * @Param [highCouponHandsel] + * @return void + **/ + void updateCouponHandsel(HighCouponHandsel highCouponHandsel); + + /** + * + * @Title: getCouponHandselById + * @Author 胡锐 + * @Description: 根据id查询 + * @Date 11:06 2021/3/16 + * @Param [id] + * @return com.hai.model.HighCouponHandselModel + **/ + HighCouponHandselModel getCouponHandselById(Long id); + + /** + * + * @Title: getHandselListByCoupon + * @Author 胡锐 + * @Description: 根据卡卷 查询赠送配置列表 + * @Date 14:18 2021/3/16 + * @Param [couponId] + * @return java.util.List + **/ + List getHandselListByCoupon(Long couponId); +} 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 04dd6bb7..f54ec0d3 100644 --- a/hai-service/src/main/java/com/hai/service/HighCouponService.java +++ b/hai-service/src/main/java/com/hai/service/HighCouponService.java @@ -1,5 +1,6 @@ package com.hai.service; +import com.hai.entity.HighApprove; import com.hai.entity.HighCoupon; import com.hai.model.HighCouponModel; @@ -41,21 +42,43 @@ public interface HighCouponService { **/ void upShelfApprove(Long id); + /** + * + * @Title: upShelfApproveResult + * @Author 胡锐 + * @Description: 卡卷上架审批结果 + * @Date 15:39 2021/3/16 + * @Param [highApprove] + * @return void + **/ + void upShelfApproveResult(HighApprove highApprove); + /** * @Author 胡锐 * @Description 卡卷下架 * @Date 2021/3/14 20:56 **/ - void ofShelfApprove(Long id); + void ofShelfCoupon(Long id); /** * @Author 胡锐 - * @Description 根据id查询 + * @Description 根据id查询卡卷基本信息、赠送信息 * @Date 2021/3/14 16:58 **/ HighCouponModel getCouponById(Long id); + /** + * + * @Title: getCouponDetail + * @Author 胡锐 + * @Description: 根据id查询卡卷基本信息 + * @Date 11:56 2021/3/16 + * @Param [id] + * @return com.hai.model.HighCouponModel + **/ + HighCouponModel getCouponDetail(Long id); + /** * @Author 胡锐 * @Description 获取卡卷集合 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 f681dd16..9a253765 100644 --- a/hai-service/src/main/java/com/hai/service/HighGoodsPriceReferService.java +++ b/hai-service/src/main/java/com/hai/service/HighGoodsPriceReferService.java @@ -19,6 +19,17 @@ public interface HighGoodsPriceReferService { **/ void insertPriceRefer(HighGoodsPriceRefer highGoodsPriceRefer); + /** + * + * @Title: updatePriceRefer + * @Author 胡锐 + * @Description: 修改 + * @Date 16:12 2021/3/16 + * @Param [highGoodsPriceRefer] + * @return void + **/ + void updatePriceRefer(HighGoodsPriceRefer highGoodsPriceRefer); + /** * @Author 胡锐 * @Description 卡卷价格 处于待编辑、已生效、待生效、审批中 全部失效 @@ -33,4 +44,14 @@ public interface HighGoodsPriceReferService { **/ void couponAllInvalidKeepCurrent(Long couponId); + /** + * + * @Title: getPriceList + * @Author 胡锐 + * @Description: 查询价格列表 + * @Date 16:04 2021/3/16 + * @Param [map] + * @return java.util.List + **/ + List getPriceList(Map map); } 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 65bf4932..d4292ccc 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 @@ -40,7 +40,18 @@ public class HighApproveServiceImpl implements HighApproveService { if (Objects.equals(highApprove.getObjectType(), ApproveType.UP_SHELF_APPROVE.getType())) { highCouponService.upShelfApprove(highApprove.getObjectId()); } - highApproveMapper.insert(highApprove); } + + @Override + public HighApprove getApproveById(Long id) { + return highApproveMapper.selectByPrimaryKey(id); + } + + @Override + public void approveProcessed(HighApprove highApprove) { + if (highApprove.getObjectType() == ApproveType.UP_SHELF_APPROVE.getType()) { + highCouponService.upShelfApproveResult(highApprove); + } + } } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java index f0a387b4..4b52bed2 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java @@ -1,13 +1,13 @@ package com.hai.service.impl; import com.hai.dao.HighCouponCodeMapper; -import com.hai.entity.HighCoupon; import com.hai.entity.HighCouponCode; -import com.hai.model.HighCouponModel; +import com.hai.entity.HighCouponCodeExample; import com.hai.service.HighCouponCodeService; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.Date; /** * @Auther: 胡锐 @@ -24,4 +24,13 @@ public class HighCouponCodeServiceImpl implements HighCouponCodeService { public void insertCouponCode(HighCouponCode highCouponCode) { highCouponCodeMapper.insert(highCouponCode); } + + @Override + public Integer getStockCountByCoupon(Long couponId) { + HighCouponCodeExample example = new HighCouponCodeExample(); + example.createCriteria().andStatusEqualTo(1).andSalesEndTimeLessThan(new Date()); + return highCouponCodeMapper.selectByExample(example).size(); + } + + } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighCouponHandselServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighCouponHandselServiceImpl.java new file mode 100644 index 00000000..0dfa582e --- /dev/null +++ b/hai-service/src/main/java/com/hai/service/impl/HighCouponHandselServiceImpl.java @@ -0,0 +1,74 @@ +package com.hai.service.impl; + +import com.hai.dao.HighCouponHandselMapper; +import com.hai.entity.HighCoupon; +import com.hai.entity.HighCouponHandsel; +import com.hai.entity.HighCouponHandselExample; +import com.hai.model.HighCouponHandselModel; +import com.hai.service.HighCouponHandselService; +import com.hai.service.HighCouponService; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * @ClassName HighCouponHandselServiceImpl + * @Description: TODO () + * @Author 胡锐 + * @Date 2021/3/16 + **/ +@Service("highCouponHandselService") +public class HighCouponHandselServiceImpl implements HighCouponHandselService { + + @Resource + private HighCouponHandselMapper highCouponHandselMapper; + + @Resource + private HighCouponService highCouponService; + + @Override + public void insertCouponHandsel(HighCouponHandsel highCouponHandsel) { + highCouponHandselMapper.insert(highCouponHandsel); + } + + @Override + public void updateCouponHandsel(HighCouponHandsel highCouponHandsel) { + highCouponHandselMapper.updateByPrimaryKey(highCouponHandsel); + } + + @Override + public HighCouponHandselModel getCouponHandselById(Long id) { + HighCouponHandsel handsel = highCouponHandselMapper.selectByPrimaryKey(id); + if (handsel != null) { + HighCouponHandselModel model = new HighCouponHandselModel(); + BeanUtils.copyProperties(handsel, model); + model.setHighCouponModel(highCouponService.getCouponDetail(handsel.getId())); + return model; + } + return null; + } + + @Override + public List getHandselListByCoupon(Long couponId) { + HighCouponHandselExample example = new HighCouponHandselExample(); + example.createCriteria().andCouponIdEqualTo(couponId).andStatusEqualTo(1); + List list = highCouponHandselMapper.selectByExample(example); + if (list != null && list.size() > 0) { + HighCouponHandselModel model; + List modelList = new ArrayList<>(); + for (HighCouponHandsel handsel : list) { + model = new HighCouponHandselModel(); + BeanUtils.copyProperties(handsel, model); + model.setHighCouponModel(highCouponService.getCouponDetail(handsel.getId())); + modelList.add(model); + } + return modelList; + } + return new ArrayList<>(); + } + +} 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 c352bc54..78a4d1f5 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 @@ -8,9 +8,7 @@ import com.hai.dao.HighCouponMapper; import com.hai.entity.*; import com.hai.model.HighCouponHandselModel; import com.hai.model.HighCouponModel; -import com.hai.service.HighCouponCodeService; -import com.hai.service.HighCouponService; -import com.hai.service.HighGoodsPriceReferService; +import com.hai.service.*; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; @@ -20,10 +18,7 @@ import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; /** * @Auther: 胡锐 @@ -37,7 +32,7 @@ public class HighCouponServiceImpl implements HighCouponService { private HighCouponMapper highCouponMapper; @Resource - private HighCouponHandselMapper highCouponHandselMapper; + private HighCouponHandselService highCouponHandselService; @Resource private HighGoodsPriceReferService highGoodsPriceReferService; @@ -45,6 +40,9 @@ public class HighCouponServiceImpl implements HighCouponService { @Resource private HighCouponCodeService highCouponCodeService; + @Resource + private HighApproveService highApproveService; + @Override @Transactional(propagation= Propagation.REQUIRES_NEW) public void insertCoupon(HighCouponModel highCouponModel) { @@ -54,7 +52,7 @@ public class HighCouponServiceImpl implements HighCouponService { if (highCouponModel.getHandselCouponList() != null && highCouponModel.getHandselCouponList().size() > 0) { for (HighCouponHandselModel handsel : highCouponModel.getHandselCouponList()) { handsel.setCouponId(highCouponModel.getId()); - highCouponHandselMapper.insert(handsel); + highCouponHandselService.insertCouponHandsel(handsel); } } @@ -82,12 +80,12 @@ public class HighCouponServiceImpl implements HighCouponService { for (HighCouponHandselModel handsel : highCouponModel.getHandselCouponList()) { // 状态标记为删除的,进行删除操作 if (handsel.getStatus() == 0) { - highCouponHandselMapper.deleteByPrimaryKey(handsel.getId()); + highCouponHandselService.updateCouponHandsel(handsel); } // id为空的,进行增加操作 if (handsel.getId() == null) { handsel.setCouponId(highCouponModel.getId()); - highCouponHandselMapper.insert(handsel); + highCouponHandselService.insertCouponHandsel(handsel); } } } @@ -135,7 +133,45 @@ public class HighCouponServiceImpl implements HighCouponService { @Override @Transactional(propagation= Propagation.REQUIRES_NEW) - public void ofShelfApprove(Long id) { + public void upShelfApproveResult(HighApprove highApprove) { + // 查询卡卷 + HighCouponModel couponDetail = getCouponDetail(highApprove.getObjectId()); + if (couponDetail == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_COUPON, ""); + } + if (couponDetail.getStatus() != 101) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COUPON_UNABLE_UP_SHELF, ""); + } + + // 状态: 1:待审批 2:驳回 3:通过 + if (highApprove.getStatus() == 1) { + couponDetail.setStatus(2); + + Map map = new HashMap<>(); + map.put("objectType", 1); + map.put("objectId", couponDetail.getId()); + map.put("status", 1); + List list = highGoodsPriceReferService.getPriceList(map); + if (list != null && list.size() > 0) { + for (HighGoodsPriceRefer priceRefer : list) { + priceRefer.setEffectiveTime(new Date()); + priceRefer.setStatus(3); + highGoodsPriceReferService.updatePriceRefer(priceRefer); + } + } + } + + if (highApprove.getStatus() == 2) { + couponDetail.setStatus(102); + } + + highCouponMapper.updateByPrimaryKey(couponDetail); + highApproveService.approveProcessed(highApprove); + } + + @Override + @Transactional(propagation= Propagation.REQUIRES_NEW) + public void ofShelfCoupon(Long id) { HighCouponModel coupon = getCouponById(id); if (coupon == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_COUPON, ""); @@ -159,8 +195,23 @@ public class HighCouponServiceImpl implements HighCouponService { } HighCouponModel model = new HighCouponModel(); BeanUtils.copyProperties(highCoupon, model); + // 查询有效库存 + model.setSalesCount(highCouponCodeService.getStockCountByCoupon(highCoupon.getId())); + // 查询赠送卡卷列表 + model.setHandselCouponList(highCouponHandselService.getHandselListByCoupon(highCoupon.getId())); + return model; + } - + @Override + public HighCouponModel getCouponDetail(Long id) { + HighCoupon highCoupon = highCouponMapper.selectByPrimaryKey(id); + if (highCoupon == null) { + return null; + } + HighCouponModel model = new HighCouponModel(); + BeanUtils.copyProperties(highCoupon, model); + // 查询有效库存 + model.setSalesCount(highCouponCodeService.getStockCountByCoupon(highCoupon.getId())); return model; } @@ -169,6 +220,14 @@ public class HighCouponServiceImpl implements HighCouponService { HighCouponExample example = new HighCouponExample(); HighCouponExample.Criteria criteria = example.createCriteria(); + if (MapUtils.getLong(map, "companyId") != null) { + criteria.andCompanyIdEqualTo(MapUtils.getLong(map, "companyId")); + } + + if (MapUtils.getLong(map, "merchantId") != null) { + criteria.andMerchantIdEqualTo(MapUtils.getLong(map, "merchantId")); + } + if (StringUtils.isNotBlank(MapUtils.getString(map, "couponName"))) { criteria.andCouponNameLike("%" + MapUtils.getString(map, "couponName") + "%"); } 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 d9141137..beedd683 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 @@ -29,6 +29,11 @@ public class HighGoodsPriceReferServiceImpl implements HighGoodsPriceReferServic highGoodsPriceReferMapper.insert(highGoodsPriceRefer); } + @Override + public void updatePriceRefer(HighGoodsPriceRefer highGoodsPriceRefer) { + highGoodsPriceReferMapper.updateByPrimaryKey(highGoodsPriceRefer); + } + @Override public void couponAllPriceInvalid(Long couponId) { List statusList = new ArrayList<>(); @@ -67,5 +72,26 @@ public class HighGoodsPriceReferServiceImpl implements HighGoodsPriceReferServic } } + @Override + public List getPriceList(Map map) { + HighGoodsPriceReferExample example = new HighGoodsPriceReferExample(); + HighGoodsPriceReferExample.Criteria criteria = example.createCriteria(); + + if (MapUtils.getInteger(map, "objectType") != null) { + criteria.andObjectTypeEqualTo(MapUtils.getInteger(map, "objectType")); + } + + if (MapUtils.getLong(map, "objectId") != null) { + criteria.andObjectIdEqualTo(MapUtils.getLong(map, "objectId")); + } + + if (MapUtils.getInteger(map, "status") != null) { + criteria.andStatusEqualTo(MapUtils.getInteger(map, "status")); + } + + criteria.andStatusNotEqualTo(0); + return highGoodsPriceReferMapper.selectByExample(example); + } + }