From 690b15947bf2d76596ee5ab4cbe0bd9c73beea4b Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Mon, 17 Jul 2023 16:12:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/web/controller/OrderPayController.java | 9 +++++++++ .../src/main/java/com/hai/dao/HighCouponMapperExt.java | 8 ++++++++ .../java/com/hai/dao/HighDiscountUserRelMapperExt.java | 5 +++++ .../service/impl/OrderCreateHandleServiceImpl.java | 6 ++++++ .../main/java/com/hai/service/HighCouponService.java | 10 ++++++++-- .../com/hai/service/impl/HighCouponServiceImpl.java | 5 +++++ .../service/impl/HighDiscountUserRelServiceImpl.java | 10 +++++++++- 7 files changed, 50 insertions(+), 3 deletions(-) diff --git a/hai-order/src/main/java/com/web/controller/OrderPayController.java b/hai-order/src/main/java/com/web/controller/OrderPayController.java index 7de9379b..e2a6fc0e 100644 --- a/hai-order/src/main/java/com/web/controller/OrderPayController.java +++ b/hai-order/src/main/java/com/web/controller/OrderPayController.java @@ -100,6 +100,9 @@ public class OrderPayController { @Resource private OrderPayBeforeService orderPayBeforeService; + @Resource + private SecConfigService secConfigService; + @RequestMapping(value="/wechatPay",method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "微信支付") @@ -162,6 +165,12 @@ public class OrderPayController { } else if (order.getProductType().equals(OrderProductType.PRODUCT_TYPE5.getNumber())) { HighCoupon coupon = couponService.getCouponById(order.getHighChildOrderList().get(0).getGoodsId()); if (coupon.getCouponSource() != null && coupon.getCouponSource().equals(4)) { + // GZ_SINOPEC_QUOTA 单日限购数量 + SecConfig gzSinopecQuota = secConfigService.findByCodeType("GZ_SINOPEC_QUOTA"); + if (gzSinopecQuota != null + && couponService.userBuySourceLimitNumber(order.getMemId(),4) >= Integer.parseInt(gzSinopecQuota.getCodeValue())) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂时无法支付,已达单日限购数量"); + } if (order.getMemDiscountId() != null) { weChatPayReqInfo.setSub_mch_id(WxOrderConfig.MCH_ID_1614670195); } else { diff --git a/hai-service/src/main/java/com/hai/dao/HighCouponMapperExt.java b/hai-service/src/main/java/com/hai/dao/HighCouponMapperExt.java index 742c2538..ff656244 100644 --- a/hai-service/src/main/java/com/hai/dao/HighCouponMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/HighCouponMapperExt.java @@ -15,4 +15,12 @@ public interface HighCouponMapperExt { @Select({"SELECT count(1) FROM `high_child_order` " + " where goods_type = 1 and goods_id = #{couponId} and child_order_status in (2,3,6,7) and DATE_FORMAT(pay_time,'%Y%m') = DATE_FORMAT(CURDATE(),'%Y%m')"}) int getMonthlySales(@Param("couponId") Long couponId); + + @Select(" select count(1) from high_child_order " + + " where mem_id = #{userId} " + + " and goods_type = 1 " + + " and child_order_status in (2,3)" + + " and pay_time BETWEEN CONCAT(CURDATE(),' 00:00:00') AND CONCAT(CURDATE(),' 23:59:59') " + + " and goods_id in (select id from high_coupon where coupon_source = #{couponSource})") + int userBuySourceLimitNumber(@Param("userId") Long userId, @Param("couponSource") Integer couponSource); } diff --git a/hai-service/src/main/java/com/hai/dao/HighDiscountUserRelMapperExt.java b/hai-service/src/main/java/com/hai/dao/HighDiscountUserRelMapperExt.java index ae6b984c..7d7845c0 100644 --- a/hai-service/src/main/java/com/hai/dao/HighDiscountUserRelMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/HighDiscountUserRelMapperExt.java @@ -43,4 +43,9 @@ public interface HighDiscountUserRelMapperExt { @Select({""}) Integer receiveDiscountCount(@Param("userId") Long userId, @Param("discountId") Long discountId); + + @Select(" select count(1) from high_discount_user_rel " + + " where user_id = #{userId} and discount_id in (select id from high_discount where using_range = #{usingRange}) " + + " and create_time BETWEEN CONCAT(CURDATE(),' 00:00:00') AND CONCAT(CURDATE(),' 23:59:59') ") + Integer userReceiveLimitNumber(@Param("userId") Long userId,@Param("usingRange") Integer usingRange); } diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java index 2c9a6ceb..e397a3d7 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java @@ -204,6 +204,12 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService { if (secConfigService.isConfig("GZ_SINOPEC_STATUS", "true") == true) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "卡券维护中,请稍后重试!"); } + // GZ_SINOPEC_QUOTA 单日限购数量 + SecConfig gzSinopecQuota = secConfigService.findByCodeType("GZ_SINOPEC_QUOTA"); + if (gzSinopecQuota != null + && couponService.userBuySourceLimitNumber(childOrder.getMemId(),4) >= Integer.parseInt(gzSinopecQuota.getCodeValue())) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂时无法下单,已达单日限购数量"); + } // 下单请求 JSONObject jsonObject = HuiLianTongConfig.recharge(createOrderChild.getOrderNo(), childOrder.getSaleCount(), 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 8b434316..20fd81db 100644 --- a/hai-service/src/main/java/com/hai/service/HighCouponService.java +++ b/hai-service/src/main/java/com/hai/service/HighCouponService.java @@ -150,6 +150,14 @@ public interface HighCouponService { **/ Boolean userBuyLimitNumber(Long userId,Long couponId); + /** + * 用户购买卡卷业务数量上限 + * @param userId 用户id + * @param couponSource 卡券业务来源 + * @return + */ + int userBuySourceLimitNumber(Long userId, Integer couponSource); + /** * 分配库存 * @param couponId @@ -164,6 +172,4 @@ public interface HighCouponService { */ int getMonthlySales(Long couponId); - - } 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 e97e7a09..ad96043a 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 @@ -563,6 +563,11 @@ public class HighCouponServiceImpl implements HighCouponService { return status; } + @Override + public int userBuySourceLimitNumber(Long userId, Integer couponSource) { + return highCouponMapper.userBuySourceLimitNumber(userId,couponSource); + } + @Override public HighCouponCode assignOrderStock(Long couponId, String childOrderNo) throws InterruptedException { String key = "coupon_" + couponId; 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 ddf407fa..9a5018fa 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 @@ -6,6 +6,7 @@ import com.hai.common.exception.SysCode; import com.hai.dao.HighDiscountUserRelMapper; import com.hai.entity.*; import com.hai.enum_type.DiscountPlatform; +import com.hai.enum_type.DiscountUseScope; import com.hai.service.*; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; @@ -46,6 +47,8 @@ public class HighDiscountUserRelServiceImpl implements HighDiscountUserRelServic @Resource private HighDiscountAgentCodeService highDiscountAgentCodeService; + @Resource + private SecConfigService secConfigService; @Override @Transactional(propagation= Propagation.REQUIRES_NEW,isolation= Isolation.SERIALIZABLE) @@ -85,7 +88,12 @@ public class HighDiscountUserRelServiceImpl implements HighDiscountUserRelServic if (discount.getReceiveNumber() > 0 && this.receiveDiscountCount(userId, discount.getId()).intValue() >= discount.getReceiveNumber().intValue()) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券已达到上线"); } - + if (discount.getUseScope().equals(DiscountUseScope.type8.getType())) { + SecConfig cqCnpcQuota = secConfigService.findByCodeType("CQ_CNPC_QUOTA"); + if (cqCnpcQuota != null && highDiscountUserRelMapper.userReceiveLimitNumber(userId,DiscountUseScope.type8.getType()).intValue() >= Integer.parseInt(cqCnpcQuota.getCodeValue())) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当日领取优惠券已达上限"); + } + } // 校验卡卷状态 if (rel.getHighDiscount().getStatus() != 2) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法领取,优惠券已过期");