| @@ -0,0 +1,101 @@ | |||||
| alter table wx_coupon_0 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_1 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_2 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_3 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_4 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_5 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_6 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_7 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_8 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_9 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_10 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_11 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_12 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_13 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_14 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_15 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_16 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_17 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_18 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_19 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_20 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_21 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_22 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_23 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_24 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_25 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_26 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_27 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_28 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_29 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_30 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_31 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_32 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_33 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_34 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_35 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_36 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_37 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_38 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_39 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_40 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_41 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_42 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_43 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_44 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_45 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_46 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_47 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_48 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_49 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_50 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_51 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_52 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_53 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_54 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_55 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_56 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_57 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_58 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_59 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_60 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_61 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_62 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_63 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_64 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_65 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_66 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_67 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_68 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_69 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_70 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_71 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_72 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_73 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_74 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_75 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_76 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_77 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_78 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_79 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_80 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_81 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_82 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_83 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_84 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_85 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_86 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_87 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_88 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_89 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_90 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_91 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_92 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_93 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_94 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_95 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_96 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_97 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_98 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| alter table wx_coupon_99 add column press_pay_reduce_stock int(1) not null default 0 comment '砍价支付扣库存EnumYesOrNo' after press_limit_hours; | |||||
| @@ -123,6 +123,9 @@ public class WxPayOrderController extends BaseController { | |||||
| } catch (NumberFormatException e) { | } catch (NumberFormatException e) { | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "orderId参数不正确"); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "orderId参数不正确"); | ||||
| } | } | ||||
| //如果是砍价付款扣库存,则此时扣库存 | |||||
| WxPayOrder record = new WxPayOrder(); | WxPayOrder record = new WxPayOrder(); | ||||
| record.setOrderId(orderId); | record.setOrderId(orderId); | ||||
| record.setOpenId(getCUser().getOpenId()); | record.setOpenId(getCUser().getOpenId()); | ||||
| @@ -178,6 +178,9 @@ public class WxCoupon extends TenantEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value="砍价限制时间",name="pressLimitHours") | @io.swagger.annotations.ApiModelProperty(value="砍价限制时间",name="pressLimitHours") | ||||
| private Integer pressLimitHours; | private Integer pressLimitHours; | ||||
| @io.swagger.annotations.ApiModelProperty(value="砍价支付扣库存EnumYesOrNo",name="pressPayReduceStock") | |||||
| private Integer pressPayReduceStock; | |||||
| @io.swagger.annotations.ApiModelProperty(value="积分售价(适用于类型10,11)",name="creditPrice") | @io.swagger.annotations.ApiModelProperty(value="积分售价(适用于类型10,11)",name="creditPrice") | ||||
| private Integer creditPrice; | private Integer creditPrice; | ||||
| @@ -0,0 +1,63 @@ | |||||
| package com.iformall.service.helper; | |||||
| import com.iformall.enums.*; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.context.annotation.Lazy; | |||||
| import org.springframework.stereotype.Service; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.domain.po.WxCoupon; | |||||
| import com.iformall.domain.po.WxCouponChannel; | |||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.service.WxCouponChannelService; | |||||
| import com.iformall.service.WxCouponService; | |||||
| import com.iformall.utils.RedisLock; | |||||
| @Service | |||||
| public class WxOrderServiceHelper { | |||||
| private static final Logger logger = LoggerFactory.getLogger(WxOrderServiceHelper.class); | |||||
| @Lazy | |||||
| @Autowired | |||||
| WxCouponChannelService wxCouponChannelService; | |||||
| @Lazy | |||||
| @Autowired | |||||
| WxCouponService wxCouponService; | |||||
| @Autowired | |||||
| RedisLock redisLock; | |||||
| /** | |||||
| * 微信订单是否可以支付 | |||||
| */ | |||||
| public void reduceStock(boolean isChannelStockReduce, WxCoupon coupon,Long couponChannelId,int number) { | |||||
| if (isChannelStockReduce) { | |||||
| try { | |||||
| wxCouponChannelService.reduceChannelStock(coupon,couponChannelId,number); | |||||
| long stock = redisLock.decrease(EnumCacheKey.COUPON_CHANNEL_STOCK.getMessage()+couponChannelId, number); | |||||
| if (stock < 0 ) { | |||||
| throw new MallinkException(ErrorCode.ORDER_IS_FAIL.getCode(),"券["+coupon.getTitle()+"]渠道["+couponChannelId+"]库存已为零!"); | |||||
| } | |||||
| } catch (RuntimeException e) { | |||||
| throw new MallinkException(ErrorCode.ORDER_IS_FAIL.getCode(),"券["+coupon.getTitle()+"]渠道["+couponChannelId+"]库存更新失败!"+e.getMessage()); | |||||
| } | |||||
| }else { | |||||
| try { | |||||
| wxCouponService.reduceRemainInventory(coupon,coupon.getId(),number); | |||||
| long stock = redisLock.decrease(EnumCacheKey.COUPON_STOCK.getMessage()+coupon.getId(), number); | |||||
| if (stock < 0 ) { | |||||
| throw new MallinkException(ErrorCode.ORDER_IS_FAIL.getCode(),"券["+coupon.getTitle()+"]库存已为零!"); | |||||
| } | |||||
| } catch (RuntimeException e) { | |||||
| logger.error("此券减库存失败, couponId: " + coupon.getId(),e); | |||||
| throw new MallinkException(ErrorCode.ORDER_IS_FAIL.getCode(),"券["+coupon.getTitle()+"]库存更新失败!"+e.getMessage()); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -28,6 +28,7 @@ import com.iformall.douyin.payv2.result.CreateOrderCallback; | |||||
| import com.iformall.enums.*; | import com.iformall.enums.*; | ||||
| import com.iformall.mapper.*; | import com.iformall.mapper.*; | ||||
| import com.iformall.service.*; | import com.iformall.service.*; | ||||
| import com.iformall.service.helper.WxOrderServiceHelper; | |||||
| import com.iformall.service.order.OrderAdapterService; | import com.iformall.service.order.OrderAdapterService; | ||||
| import com.iformall.service.order.OrderFactory; | import com.iformall.service.order.OrderFactory; | ||||
| import com.iformall.service.order.entity.WxComposeChildOrderPrice; | import com.iformall.service.order.entity.WxComposeChildOrderPrice; | ||||
| @@ -241,6 +242,10 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| @Autowired | @Autowired | ||||
| WxCouponBatchService wxCouponBatchService; | WxCouponBatchService wxCouponBatchService; | ||||
| @Lazy | |||||
| @Autowired | |||||
| private WxOrderServiceHelper wxOrderServiceHelper; | |||||
| @Override | @Override | ||||
| public PageInfo<WxOrder> listAsPage(WxOrder record, Integer pageIndex, Integer pageSize) { | public PageInfo<WxOrder> listAsPage(WxOrder record, Integer pageIndex, Integer pageSize) { | ||||
| @@ -1097,29 +1102,13 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| throw new MallinkException(ErrorCode.ORDER_IS_LIMITED.getCode(),"此券[未支付+已支付]购买数量已超限["+coupon.getTitle()+"], couponId: " + coupon.getId()+ ", count: " + paidCount); | throw new MallinkException(ErrorCode.ORDER_IS_LIMITED.getCode(),"此券[未支付+已支付]购买数量已超限["+coupon.getTitle()+"], couponId: " + coupon.getId()+ ", count: " + paidCount); | ||||
| } | } | ||||
| //减库存, | |||||
| if (isChannelStockReduce) { | |||||
| try { | |||||
| wxCouponChannelService.reduceChannelStock(coupon,couponChannel.getId(),number); | |||||
| long stock = redisLock.decrease(EnumCacheKey.COUPON_CHANNEL_STOCK.getMessage()+couponChannel.getId(), number); | |||||
| if (stock < 0 ) { | |||||
| throw new MallinkException(ErrorCode.ORDER_IS_FAIL.getCode(),"券["+coupon.getTitle()+"]渠道["+couponChannel.getId()+"]库存已为零!"); | |||||
| } | |||||
| } catch (RuntimeException e) { | |||||
| throw new MallinkException(ErrorCode.ORDER_IS_FAIL.getCode(),"券["+coupon.getTitle()+"]渠道["+couponChannel.getId()+"]库存更新失败!"+e.getMessage()); | |||||
| } | |||||
| }else { | |||||
| try { | |||||
| wxCouponService.reduceRemainInventory(coupon,coupon.getId(),number); | |||||
| long stock = redisLock.decrease(EnumCacheKey.COUPON_STOCK.getMessage()+coupon.getId(), number); | |||||
| if (stock < 0 ) { | |||||
| throw new MallinkException(ErrorCode.ORDER_IS_FAIL.getCode(),"券["+coupon.getTitle()+"]库存已为零!"); | |||||
| } | |||||
| } catch (RuntimeException e) { | |||||
| logger.error("此券减库存失败, couponId: " + coupon.getId(),e); | |||||
| throw new MallinkException(ErrorCode.ORDER_IS_FAIL.getCode(),"券["+coupon.getTitle()+"]库存更新失败!"+e.getMessage()); | |||||
| } | |||||
| boolean isReduceStock = true; | |||||
| //减库存,砍价需要看券配置 | |||||
| if (isPressOrder && null != coupon.getPressPayReduceStock() && coupon.getPressPayReduceStock().intValue() == EnumYesOrNo.YES.getCode().intValue()) { | |||||
| isReduceStock = false; | |||||
| } | |||||
| if (isReduceStock) { | |||||
| wxOrderServiceHelper.reduceStock(isChannelStockReduce,coupon,couponChannel.getId(), number); | |||||
| } | } | ||||
| reduceResult.setChannelStockReduce(isChannelStockReduce); | reduceResult.setChannelStockReduce(isChannelStockReduce); | ||||
| reduceResult.setCurrentPrice(currentPrice); | reduceResult.setCurrentPrice(currentPrice); | ||||
| @@ -19,6 +19,7 @@ import com.iformall.exception.MallinkException; | |||||
| import com.iformall.mapper.*; | import com.iformall.mapper.*; | ||||
| import com.iformall.pay.*; | import com.iformall.pay.*; | ||||
| import com.iformall.service.*; | import com.iformall.service.*; | ||||
| import com.iformall.service.helper.WxOrderServiceHelper; | |||||
| import com.iformall.service.helper.WxPayOrderServiceHelper; | import com.iformall.service.helper.WxPayOrderServiceHelper; | ||||
| import com.iformall.service.order.OrderAdapterService; | import com.iformall.service.order.OrderAdapterService; | ||||
| import com.iformall.service.order.OrderFactory; | import com.iformall.service.order.OrderFactory; | ||||
| @@ -44,6 +45,7 @@ import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.aop.framework.AopContext; | import org.springframework.aop.framework.AopContext; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.context.annotation.Lazy; | |||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import org.springframework.transaction.annotation.Propagation; | import org.springframework.transaction.annotation.Propagation; | ||||
| import org.springframework.transaction.annotation.Transactional; | import org.springframework.transaction.annotation.Transactional; | ||||
| @@ -134,6 +136,10 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| @Autowired | @Autowired | ||||
| OrderFactory orderFactory; | OrderFactory orderFactory; | ||||
| @Lazy | |||||
| @Autowired | |||||
| WxOrderServiceHelper wxOrderServiceHelper; | |||||
| JSONObject errorMapQuery = JSON.parseObject("{" + | JSONObject errorMapQuery = JSON.parseObject("{" + | ||||
| "\"ORDERNOTEXIST\":{\"detail\":\"此交易订单号不存在\",\"reason\":\"查询系统中不存在此交易订单号\",\"resolution\":\"该API只能查提交支付交易返回成功的订单,请商户检查需要查询的订单号是否正确\"},\n" + | "\"ORDERNOTEXIST\":{\"detail\":\"此交易订单号不存在\",\"reason\":\"查询系统中不存在此交易订单号\",\"resolution\":\"该API只能查提交支付交易返回成功的订单,请商户检查需要查询的订单号是否正确\"},\n" + | ||||
| @@ -273,6 +279,12 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| for (WxOrder o : orderList) { | for (WxOrder o : orderList) { | ||||
| productNames.add(o.getProductName()); | productNames.add(o.getProductName()); | ||||
| checkSinglePayOrder(o, user, payWay); | checkSinglePayOrder(o, user, payWay); | ||||
| //如果是砍价,并且是付款扣库存 | |||||
| WxCoupon coupon = wxCouponMapper.selectById(o.getProductId(), appInfo.getTenantId()); | |||||
| if (null != coupon && coupon.getType().intValue() == EnumCouponType.COUPON_PRESS.getCode().intValue() | |||||
| && null != coupon.getPressPayReduceStock() && coupon.getPressPayReduceStock().intValue() == EnumYesOrNo.YES.getCode().intValue()) { | |||||
| wxOrderServiceHelper.reduceStock(false,coupon,o.getCouponChannelId(), 1); | |||||
| } | |||||
| } | } | ||||
| PayAdapterResult payResult = createPayOrder(appInfo, user, record,composeOrder,orderList,JSON.toJSONString(productNames), payWay, params,isCreatePay); | PayAdapterResult payResult = createPayOrder(appInfo, user, record,composeOrder,orderList,JSON.toJSONString(productNames), payWay, params,isCreatePay); | ||||
| if (payResult.isSuccess()) { | if (payResult.isSuccess()) { | ||||
| @@ -44,6 +44,7 @@ | |||||
| <result column="subsidy_num" jdbcType="INTEGER" property="subsidyNum"/> | <result column="subsidy_num" jdbcType="INTEGER" property="subsidyNum"/> | ||||
| <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/> | <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/> | ||||
| <result column="press_limit_hours" jdbcType="INTEGER" property="pressLimitHours"/> | <result column="press_limit_hours" jdbcType="INTEGER" property="pressLimitHours"/> | ||||
| <result column="press_pay_reduce_stock" jdbcType="INTEGER" property="pressPayReduceStock"/> | |||||
| <result column="auto_refund" jdbcType="INTEGER" property="autoRefund"/> | <result column="auto_refund" jdbcType="INTEGER" property="autoRefund"/> | ||||
| <result column="credit_price" jdbcType="INTEGER" property="creditPrice"/> | <result column="credit_price" jdbcType="INTEGER" property="creditPrice"/> | ||||
| <result column="credit_refund" jdbcType="INTEGER" property="creditRefund"/> | <result column="credit_refund" jdbcType="INTEGER" property="creditRefund"/> | ||||
| @@ -107,6 +108,7 @@ | |||||
| <result column="subsidy_num" jdbcType="INTEGER" property="subsidyNum"/> | <result column="subsidy_num" jdbcType="INTEGER" property="subsidyNum"/> | ||||
| <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/> | <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/> | ||||
| <result column="press_limit_hours" jdbcType="INTEGER" property="pressLimitHours"/> | <result column="press_limit_hours" jdbcType="INTEGER" property="pressLimitHours"/> | ||||
| <result column="press_pay_reduce_stock" jdbcType="INTEGER" property="pressPayReduceStock"/> | |||||
| <result column="auto_refund" jdbcType="INTEGER" property="autoRefund"/> | <result column="auto_refund" jdbcType="INTEGER" property="autoRefund"/> | ||||
| <result column="sale_count" property="saleCount"/> | <result column="sale_count" property="saleCount"/> | ||||
| @@ -128,7 +130,7 @@ | |||||
| c.`title`,c.`sub_title`,c.`item_group`,c.`sale_price`,c.`freight_price`,c.`use_price`,c.`use_limit_rule`,c.`use_limit_quantity`,c.`send_type`, | c.`title`,c.`sub_title`,c.`item_group`,c.`sale_price`,c.`freight_price`,c.`use_price`,c.`use_limit_rule`,c.`use_limit_quantity`,c.`send_type`, | ||||
| c.`valid_type`,c.`valid_start_date`,c.`valid_end_date`,c.pick_start_date,c.pick_end_date,c.`valid_days`,c.`detail`,c.`price`,c.tail_price,c.orig_price,c.`unit`,c.`remain_inventory`,c.`inventory`, | c.`valid_type`,c.`valid_start_date`,c.`valid_end_date`,c.pick_start_date,c.pick_end_date,c.`valid_days`,c.`detail`,c.`price`,c.tail_price,c.orig_price,c.`unit`,c.`remain_inventory`,c.`inventory`, | ||||
| c.`remark`,c.`status`,c.`create_date`,c.`update_date`,c.`business`,c.`sub_business`,c.`support_transfer`,c.`subsidy_num`,c.`subsidy_type`,c.`is_after_set_price`, | c.`remark`,c.`status`,c.`create_date`,c.`update_date`,c.`business`,c.`sub_business`,c.`support_transfer`,c.`subsidy_num`,c.`subsidy_type`,c.`is_after_set_price`, | ||||
| c.`press_limit_num`, c.`press_limit_hours`, c.`auto_refund`,c.`credit_price`,c.`credit_refund`,c.`put_apply_status`,c.`stock_apply_status`,c.`cancle_apply_status`, | |||||
| c.`press_limit_num`, c.`press_limit_hours`,c.`press_pay_reduce_stock`, c.`auto_refund`,c.`credit_price`,c.`credit_refund`,c.`put_apply_status`,c.`stock_apply_status`,c.`cancle_apply_status`, | |||||
| c.`conditions`,c.approval_type,c.content_type,c.source_type,c.merchant_type,c.password_support,c.gift_list,c.product_type,c.category_id,c.goods_id | c.`conditions`,c.approval_type,c.content_type,c.source_type,c.merchant_type,c.password_support,c.gift_list,c.product_type,c.category_id,c.goods_id | ||||
| </sql> | </sql> | ||||
| @@ -273,6 +275,10 @@ | |||||
| <if test=" null != pressLimitHours "> | <if test=" null != pressLimitHours "> | ||||
| and `press_limit_hours` = #{pressLimitHours} | and `press_limit_hours` = #{pressLimitHours} | ||||
| </if> | </if> | ||||
| <if test=" null != pressPayReduceStock "> | |||||
| and `press_pay_reduce_stock` = #{pressPayReduceStock} | |||||
| </if> | |||||
| <if test=" null != autoRefund "> | <if test=" null != autoRefund "> | ||||
| and `auto_refund` = #{autoRefund} | and `auto_refund` = #{autoRefund} | ||||
| @@ -624,6 +630,10 @@ | |||||
| <if test=" null != pressLimitHours "> | <if test=" null != pressLimitHours "> | ||||
| and c.`press_limit_hours` = #{pressLimitHours} | and c.`press_limit_hours` = #{pressLimitHours} | ||||
| </if> | </if> | ||||
| <if test=" null != pressPayReduceStock "> | |||||
| and c.`press_pay_reduce_stock` = #{pressPayReduceStock} | |||||
| </if> | |||||
| <if test=" null != autoRefund "> | <if test=" null != autoRefund "> | ||||
| and c.`auto_refund` = #{autoRefund} | and c.`auto_refund` = #{autoRefund} | ||||
| @@ -791,6 +801,7 @@ | |||||
| <result column="subsidy_num" jdbcType="INTEGER" property="subsidyNum"/> | <result column="subsidy_num" jdbcType="INTEGER" property="subsidyNum"/> | ||||
| <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/> | <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/> | ||||
| <result column="press_limit_hours" jdbcType="INTEGER" property="pressLimitHours"/> | <result column="press_limit_hours" jdbcType="INTEGER" property="pressLimitHours"/> | ||||
| <result column="press_pay_reduce_stock" jdbcType="INTEGER" property="pressPayReduceStock"/> | |||||
| <result column="conditions" jdbcType="VARCHAR" property="conditions"/> | <result column="conditions" jdbcType="VARCHAR" property="conditions"/> | ||||
| <result column="content_type" jdbcType="INTEGER" property="contentType"/> | <result column="content_type" jdbcType="INTEGER" property="contentType"/> | ||||
| <result column="source_type" jdbcType="INTEGER" property="sourceType"/> | <result column="source_type" jdbcType="INTEGER" property="sourceType"/> | ||||
| @@ -843,6 +854,7 @@ | |||||
| <result column="subsidy_num" jdbcType="INTEGER" property="subsidyNum"/> | <result column="subsidy_num" jdbcType="INTEGER" property="subsidyNum"/> | ||||
| <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/> | <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/> | ||||
| <result column="press_limit_hours" jdbcType="INTEGER" property="pressLimitHours"/> | <result column="press_limit_hours" jdbcType="INTEGER" property="pressLimitHours"/> | ||||
| <result column="press_pay_reduce_stock" jdbcType="INTEGER" property="pressPayReduceStock"/> | |||||
| <result column="conditions" jdbcType="VARCHAR" property="conditions"/> | <result column="conditions" jdbcType="VARCHAR" property="conditions"/> | ||||
| <result column="content_type" jdbcType="INTEGER" property="contentType"/> | <result column="content_type" jdbcType="INTEGER" property="contentType"/> | ||||
| <result column="source_type" jdbcType="INTEGER" property="sourceType"/> | <result column="source_type" jdbcType="INTEGER" property="sourceType"/> | ||||
| @@ -1340,7 +1352,7 @@ | |||||
| wc.tenant_id,wc.parent_tenant_id,wc.`type`,wc.`cover_img`,wc.`cover_picture`,wc.`detail_picture`,wc.`title`,wc.`sub_title`,wc.`item_group`,wc.`sale_price`,wc.`freight_price`,wc.`use_price`,wc.`use_limit_rule`,wc.`use_limit_quantity`,wc.`send_type`, | wc.tenant_id,wc.parent_tenant_id,wc.`type`,wc.`cover_img`,wc.`cover_picture`,wc.`detail_picture`,wc.`title`,wc.`sub_title`,wc.`item_group`,wc.`sale_price`,wc.`freight_price`,wc.`use_price`,wc.`use_limit_rule`,wc.`use_limit_quantity`,wc.`send_type`, | ||||
| wc.`valid_type`,wc.`valid_start_date`,wc.`valid_end_date`,wc.pick_start_date,wc.pick_end_date,wc.`valid_days`,wc.`detail`,wc.`price`,wc.tail_price,wc.orig_price,wc.`unit`,wc.`remain_inventory`,wc.`inventory`, | wc.`valid_type`,wc.`valid_start_date`,wc.`valid_end_date`,wc.pick_start_date,wc.pick_end_date,wc.`valid_days`,wc.`detail`,wc.`price`,wc.tail_price,wc.orig_price,wc.`unit`,wc.`remain_inventory`,wc.`inventory`, | ||||
| wc.`remark`,wc.`status`,wc.`create_date`,wc.`update_date`,wc.`business`,wc.`sub_business`,wc.`support_transfer`,wc.`subsidy_num`,wc.`subsidy_type`, | wc.`remark`,wc.`status`,wc.`create_date`,wc.`update_date`,wc.`business`,wc.`sub_business`,wc.`support_transfer`,wc.`subsidy_num`,wc.`subsidy_type`, | ||||
| wc.`press_limit_num`, wc.`press_limit_hours`, wc.`auto_refund`,wc.`credit_price`,wc.`credit_refund`,wc.`conditions`, | |||||
| wc.`press_limit_num`, wc.`press_limit_hours`,wc.`press_pay_reduce_stock`, wc.`auto_refund`,wc.`credit_price`,wc.`credit_refund`,wc.`conditions`, | |||||
| wc.title as couponName,wc.`cover_img` as couponPic,wc.`cover_picture` as couponPicture,wc.`detail_picture` as detailPicture,wc.id as couponId | wc.title as couponName,wc.`cover_img` as couponPic,wc.`cover_picture` as couponPicture,wc.`detail_picture` as detailPicture,wc.id as couponId | ||||
| from wx_coupon_channel ct | from wx_coupon_channel ct | ||||
| left join wx_coupon wc on wc.id = ct.coupon_id | left join wx_coupon wc on wc.id = ct.coupon_id | ||||