diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighDiscountAgentRelController.java b/hai-bweb/src/main/java/com/bweb/controller/HighDiscountAgentRelController.java index ae436423..066d1fde 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighDiscountAgentRelController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighDiscountAgentRelController.java @@ -97,7 +97,7 @@ public class HighDiscountAgentRelController { // 是否已分配 if (highDiscountAgentRelService.getRelByDiscountAgent(highDiscountAgentRel.getDiscountId(), highDiscountAgentRel.getAgentId()) != null) { log.error("HighDiscountAgentRelController -> insertDiscountAgent() error!", discount.getDiscountName() + "重复分配给" + agent.getAgentName()); - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, discount.getDiscountName() + "重复分配给" + agent.getAgentName()); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, discount.getDiscountName() + "重复分配给" + agent.getAgentName()); } highDiscountAgentRel.setCreateTime(new Date()); highDiscountAgentRel.setStatus(1); @@ -110,7 +110,7 @@ public class HighDiscountAgentRelController { //参数 Map map = new HashMap<>(); map.put("type", QrCodeType.AGENT_QR_CODE); - map.put("code", AESEncodeUtil.aesEncrypt(Base64Util.encode(highDiscountAgentRel.getId().toString()))); + map.put("code", Base64Util.encode(AESEncodeUtil.aesEncrypt(highDiscountAgentRel.getId().toString()))); QRCodeGenerator.generateQRCodeImage(JSON.toJSONString(map), 350, 350, qrCodeUrl); highDiscountAgentRel.setQrCode(qrCodeImg); highDiscountAgentRelService.updateDiscountAgentRel(highDiscountAgentRel); diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighDiscountController.java b/hai-bweb/src/main/java/com/bweb/controller/HighDiscountController.java index 4a269c03..b57f9d17 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighDiscountController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighDiscountController.java @@ -112,7 +112,6 @@ public class HighDiscountController { if (highDiscount.getId() == null || StringUtils.isBlank(highDiscount.getDiscountName()) || StringUtils.isBlank(highDiscount.getDiscountImg()) - || StringUtils.isBlank(highDiscount.getDiscountCarouselImg()) || highDiscount.getEffectiveDay() == null || highDiscount.getSalesEndTime() == null) { log.error("HighDiscountController -> updateDiscount() error!","参数错误"); @@ -148,7 +147,7 @@ public class HighDiscountController { } - @RequestMapping(value="/updateDiscountStatus",method = RequestMethod.POST) + @RequestMapping(value="/updateDiscountStatus",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "修改优惠券状态") public ResponseData updateDiscountStatus(@RequestParam(name = "discountId", required = true) Long discountId, @@ -187,6 +186,7 @@ public class HighDiscountController { @RequestMapping(value="/getDiscountList",method = RequestMethod.GET) @ResponseBody + @ApiOperation(value = "查询优惠券列表") public ResponseData getDiscountList(@RequestParam(name = "discountKey", required = false) String discountKey, @RequestParam(name = "discountName", required = false) String discountName, diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighDiscountCouponRelController.java b/hai-bweb/src/main/java/com/bweb/controller/HighDiscountCouponRelController.java index 4dd37fa9..0a8161b2 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighDiscountCouponRelController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighDiscountCouponRelController.java @@ -49,7 +49,7 @@ public class HighDiscountCouponRelController { try { JSONObject jsonObject = JSONObject.parseObject(reqBody); Long discountId = jsonObject.getLong("discountId"); - String couponIdStr = jsonObject.getString("couponId"); + String couponIdStr = jsonObject.getString("couponIdStr"); if (discountId == null || StringUtils.isBlank(couponIdStr)) { log.error("HighDiscountCouponRelController -> insertDiscountCoupon() error!","参数错误"); @@ -110,9 +110,9 @@ public class HighDiscountCouponRelController { } } - @RequestMapping(value="/insertDiscount",method = RequestMethod.GET) + @RequestMapping(value="/getRelByDiscount",method = RequestMethod.GET) @ResponseBody - @ApiOperation(value = "根据卡卷 查询关联卡券") + @ApiOperation(value = "根据优惠券 查询关联卡券") public ResponseData getRelByDiscount(@RequestParam(name = "discountId", required = true) Long discountId) { try { diff --git a/hai-bweb/src/main/java/com/bweb/controller/LoginController.java b/hai-bweb/src/main/java/com/bweb/controller/LoginController.java index dc782524..53b32db6 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/LoginController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/LoginController.java @@ -60,6 +60,9 @@ public class LoginController { @Resource private SecPermissionService secPermissionService; + @Resource + private HighAgentService highAgentService; + @RequestMapping(value="/userLogin",method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "机构用户登录({'loginName':'','password':''})") @@ -156,6 +159,20 @@ public class LoginController { } userInfoModel.setMerchantStore(merchantStore); + } else if (secUser.getObjectType() == 4) { + // 查询门店 + HighAgent highAgent = highAgentService.findByAgentMsgId(secUser.getObjectId()); + if(highAgent == null){ + log.error("login error!","未找到代理商"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_AGENT, ""); + } + + if(highAgent.getStatus() != 1) { + log.error("login error!","未找到代理商"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_AGENT, ""); + } + userInfoModel.setHighAgent(highAgent); + } else { log.error("login error!","用户信息错误"); throw ErrorHelp.genException(SysCode.System, ErrorCode.SEC_USER_EXPIRED, ""); diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java b/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java index 4f3d53e2..676e6412 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java @@ -98,8 +98,12 @@ public class HighOrderController { log.error("HighOrderController --> addOrder() error!", "未找到卡卷信息"); throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_COUPON, ""); } - - // 校验优惠券是否可用 + // 是否达到限购数量 + if (highCouponService.userBuyLimitNumber(userInfoModel.getHighUser().getId(), coupon.getId()) == true) { + log.error("HighOrderController --> addOrder() error!", "已达到限购数量"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, coupon.getCouponName() + ",已达到限购数量"); + } + // 校验优惠券是否可用 如果使用优惠券就只能使用卡券的原价 if (highOrder.getMemDiscountId() != null) { List discountCouponRelList = highDiscountCouponRelService.getRelByCoupon(coupon.getId()); if (discountCouponRelList.size() > 0) { @@ -109,14 +113,11 @@ public class HighOrderController { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法使用优惠券"); } } + childOrder.setGoodsPrice(coupon.getSalesPrice()); + } else { + childOrder.setGoodsPrice(coupon.getDiscountPrice()); } - - // 是否到底限购数量 - if (highCouponService.userBuyLimitNumber(userInfoModel.getHighUser().getId(), coupon.getId()) == true) { - log.error("HighOrderController --> addOrder() error!", "已达到限购数量"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, coupon.getCouponName() + ",已达到限购数量"); - } if (highCouponCodeService.getStockCountByCoupon(coupon.getId()) <= 0) { log.error("HighOrderController --> addOrder() error!", "卡卷库存数量不足"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COUPON_STOCK_INSUFFICIENT, ""); @@ -124,7 +125,6 @@ public class HighOrderController { childOrder.setGoodsName(coupon.getCouponName()); childOrder.setGoodsImg(coupon.getCouponImg()); childOrder.setGoodsSpecName("默认"); - childOrder.setGoodsPrice(coupon.getDiscountPrice()); } if (childOrder.getGoodsType() == 2) { diff --git a/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java b/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java index ec8b0a5f..68c564db 100644 --- a/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java +++ b/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java @@ -30,7 +30,7 @@ public class HighCouponSchedule { * @Date 2021/4/4 22:44 **/ // @Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次 - //@Scheduled(cron = "0 0 0 * * ?") //每天 凌晨0点执行 + @Scheduled(cron = "0 0 0 * * ?") //每天 凌晨0点执行 public void expiredCoupon() { // 查询过期的卡券 List userCoupons = highUserCouponService.getOverdueCoupon(); diff --git a/hai-schedule/src/main/java/com/hai/schedule/HighDiscountSchedule.java b/hai-schedule/src/main/java/com/hai/schedule/HighDiscountSchedule.java index 8fd41af8..b370a79c 100644 --- a/hai-schedule/src/main/java/com/hai/schedule/HighDiscountSchedule.java +++ b/hai-schedule/src/main/java/com/hai/schedule/HighDiscountSchedule.java @@ -29,7 +29,7 @@ public class HighDiscountSchedule { * @Description 处理过期的优惠券 * @Date 2021/4/4 22:44 **/ - //@Scheduled(cron = "0 0 0 * * ?") //每1分钟执行一次 + @Scheduled(cron = "0 0 0 * * ?") //每1分钟执行一次 public void expiredDiscount() { List expiredDiscount = highDiscountUserRelService.getExpiredDiscount(); for (HighDiscountUserRel rel : expiredDiscount) { diff --git a/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java b/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java index 9573b7d0..789bef83 100644 --- a/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java +++ b/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java @@ -33,7 +33,7 @@ public class HighOrderSchedule { * @Description 取消订单 15分钟 * @Date 2021/4/4 22:45 **/ - //@Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次 + @Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次 public void cancelOrder() { List orderList = highOrderService.getCloseOrder(); if (orderList != null && orderList.size() > 0) { diff --git a/hai-schedule/src/main/java/com/hai/schedule/SynchronizeCNPC.java b/hai-schedule/src/main/java/com/hai/schedule/SynchronizeCNPC.java index 9bbdd083..21d355fe 100644 --- a/hai-schedule/src/main/java/com/hai/schedule/SynchronizeCNPC.java +++ b/hai-schedule/src/main/java/com/hai/schedule/SynchronizeCNPC.java @@ -29,7 +29,7 @@ public class SynchronizeCNPC { private static final String[] HEX_DIGITS = {"0" ,"1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"}; - @Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次 + //@Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次 public void certification() { Map tokenMap = new HashMap<>(); tokenMap.put("appId", "jsVpwDoHZfR2rrpjhA"); diff --git a/hai-service/src/main/java/com/hai/service/impl/HighDiscountUserRelServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighDiscountUserRelServiceImpl.java index a7c4e060..04d06dce 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighDiscountUserRelServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighDiscountUserRelServiceImpl.java @@ -52,6 +52,9 @@ public class HighDiscountUserRelServiceImpl implements HighDiscountUserRelServic if (rel == null || rel.getHighDiscount() == null || rel.getAgentId() == null){ throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_DISCOUNT, ""); } + rel.setStockCount(rel.getStockCount() - 1); + highDiscountAgentRelService.updateDiscountAgentRel(rel); + // 校验卡卷状态 if (rel.getHighDiscount().getStatus() != 2) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "卡券已下架"); diff --git a/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java index 2f4a897c..0d441ee8 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java @@ -367,7 +367,7 @@ public class HighOrderServiceImpl implements HighOrderService { HighDiscountUserRel rel = highDiscountUserRelService.getRelById(order.getMemDiscountId()); if (rel != null) { rel.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用 - rel.setUseTime(new Date()); + rel.setUseTime(null); highDiscountUserRelService.updateDiscountUserRel(rel); } }