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 3d09da8c..e8ea385b 100644 --- a/hai-service/src/main/java/com/hai/dao/HighCouponMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/HighCouponMapperExt.java @@ -34,4 +34,12 @@ public interface HighCouponMapperExt { @Select("select sales_price from high_coupon where coupon_source = #{couponSource} GROUP BY sales_price ORDER BY sales_price") List getCouponSalesPrice(@Param("couponSource") Integer couponSource); + + @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 af48be43..209e9e95 100644 --- a/hai-service/src/main/java/com/hai/service/HighCouponService.java +++ b/hai-service/src/main/java/com/hai/service/HighCouponService.java @@ -151,6 +151,14 @@ public interface HighCouponService { **/ Boolean userBuyLimitNumber(Long userId,Long couponId); + /** + * 用户购买卡卷业务数量上限 + * @param userId 用户id + * @param couponSource 卡券业务来源 + * @return + */ + int userBuySourceLimitNumber(Long userId, Integer couponSource); + /** * 分配库存 * @param couponId @@ -165,7 +173,9 @@ public interface HighCouponService { */ int getMonthlySales(Long couponId); + List> getUseCouponStatistics(Map param) throws Exception; List getCouponSalesPrice(Integer couponSource); + } 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 f0d8696e..970e1abe 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 @@ -565,6 +565,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, "无法领取,优惠券已过期");