提交代码

new-dev
胡锐 1 year ago
commit fd201b86d7
  1. 9
      hai-order/src/main/java/com/web/controller/OrderPayController.java
  2. 8
      hai-service/src/main/java/com/hai/dao/HighCouponMapperExt.java
  3. 5
      hai-service/src/main/java/com/hai/dao/HighDiscountUserRelMapperExt.java
  4. 6
      hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java
  5. 10
      hai-service/src/main/java/com/hai/service/HighCouponService.java
  6. 5
      hai-service/src/main/java/com/hai/service/impl/HighCouponServiceImpl.java
  7. 10
      hai-service/src/main/java/com/hai/service/impl/HighDiscountUserRelServiceImpl.java

@ -100,6 +100,9 @@ public class OrderPayController {
@Resource @Resource
private OrderPayBeforeService orderPayBeforeService; private OrderPayBeforeService orderPayBeforeService;
@Resource
private SecConfigService secConfigService;
@RequestMapping(value="/wechatPay",method = RequestMethod.POST) @RequestMapping(value="/wechatPay",method = RequestMethod.POST)
@ResponseBody @ResponseBody
@ApiOperation(value = "微信支付") @ApiOperation(value = "微信支付")
@ -162,6 +165,12 @@ public class OrderPayController {
} else if (order.getProductType().equals(OrderProductType.PRODUCT_TYPE5.getNumber())) { } else if (order.getProductType().equals(OrderProductType.PRODUCT_TYPE5.getNumber())) {
HighCoupon coupon = couponService.getCouponById(order.getHighChildOrderList().get(0).getGoodsId()); HighCoupon coupon = couponService.getCouponById(order.getHighChildOrderList().get(0).getGoodsId());
if (coupon.getCouponSource() != null && coupon.getCouponSource().equals(4)) { 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) { if (order.getMemDiscountId() != null) {
weChatPayReqInfo.setSub_mch_id(WxOrderConfig.MCH_ID_1614670195); weChatPayReqInfo.setSub_mch_id(WxOrderConfig.MCH_ID_1614670195);
} else { } else {

@ -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") @Select("select sales_price from high_coupon where coupon_source = #{couponSource} GROUP BY sales_price ORDER BY sales_price")
List<BigDecimal> getCouponSalesPrice(@Param("couponSource") Integer couponSource); List<BigDecimal> 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);
} }

@ -43,4 +43,9 @@ public interface HighDiscountUserRelMapperExt {
@Select({"<script> select count(1) count from high_discount_user_rel where user_id = #{userId} and discount_id = #{discountId} and `status` <![CDATA[ <> 100 ]]> </script>"}) @Select({"<script> select count(1) count from high_discount_user_rel where user_id = #{userId} and discount_id = #{discountId} and `status` <![CDATA[ <> 100 ]]> </script>"})
Integer receiveDiscountCount(@Param("userId") Long userId, @Param("discountId") Long discountId); 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);
} }

@ -204,6 +204,12 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService {
if (secConfigService.isConfig("GZ_SINOPEC_STATUS", "true") == true) { if (secConfigService.isConfig("GZ_SINOPEC_STATUS", "true") == true) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "卡券维护中,请稍后重试!"); 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(), JSONObject jsonObject = HuiLianTongConfig.recharge(createOrderChild.getOrderNo(),
childOrder.getSaleCount(), childOrder.getSaleCount(),

@ -151,6 +151,14 @@ public interface HighCouponService {
**/ **/
Boolean userBuyLimitNumber(Long userId,Long couponId); Boolean userBuyLimitNumber(Long userId,Long couponId);
/**
* 用户购买卡卷业务数量上限
* @param userId 用户id
* @param couponSource 卡券业务来源
* @return
*/
int userBuySourceLimitNumber(Long userId, Integer couponSource);
/** /**
* 分配库存 * 分配库存
* @param couponId * @param couponId
@ -165,7 +173,9 @@ public interface HighCouponService {
*/ */
int getMonthlySales(Long couponId); int getMonthlySales(Long couponId);
List<Map<String, Object>> getUseCouponStatistics(Map<String, Object> param) throws Exception; List<Map<String, Object>> getUseCouponStatistics(Map<String, Object> param) throws Exception;
List<BigDecimal> getCouponSalesPrice(Integer couponSource); List<BigDecimal> getCouponSalesPrice(Integer couponSource);
} }

@ -565,6 +565,11 @@ public class HighCouponServiceImpl implements HighCouponService {
return status; return status;
} }
@Override
public int userBuySourceLimitNumber(Long userId, Integer couponSource) {
return highCouponMapper.userBuySourceLimitNumber(userId,couponSource);
}
@Override @Override
public HighCouponCode assignOrderStock(Long couponId, String childOrderNo) throws InterruptedException { public HighCouponCode assignOrderStock(Long couponId, String childOrderNo) throws InterruptedException {
String key = "coupon_" + couponId; String key = "coupon_" + couponId;

@ -6,6 +6,7 @@ import com.hai.common.exception.SysCode;
import com.hai.dao.HighDiscountUserRelMapper; import com.hai.dao.HighDiscountUserRelMapper;
import com.hai.entity.*; import com.hai.entity.*;
import com.hai.enum_type.DiscountPlatform; import com.hai.enum_type.DiscountPlatform;
import com.hai.enum_type.DiscountUseScope;
import com.hai.service.*; import com.hai.service.*;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -46,6 +47,8 @@ public class HighDiscountUserRelServiceImpl implements HighDiscountUserRelServic
@Resource @Resource
private HighDiscountAgentCodeService highDiscountAgentCodeService; private HighDiscountAgentCodeService highDiscountAgentCodeService;
@Resource
private SecConfigService secConfigService;
@Override @Override
@Transactional(propagation= Propagation.REQUIRES_NEW,isolation= Isolation.SERIALIZABLE) @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()) { if (discount.getReceiveNumber() > 0 && this.receiveDiscountCount(userId, discount.getId()).intValue() >= discount.getReceiveNumber().intValue()) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券已达到上线"); 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) { if (rel.getHighDiscount().getStatus() != 2) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法领取,优惠券已过期"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法领取,优惠券已过期");

Loading…
Cancel
Save