From 40477d8a6688a2b2672bcaca4d5fb5f9898b1155 Mon Sep 17 00:00:00 2001 From: xhxu Date: Thu, 5 May 2022 16:28:16 +0800 Subject: [PATCH] //update ref --- .../service/impl/WxCouponChannelServiceImpl.java | 9 +++++++++ .../src/main/resources/mapper/WxCouponChannelMapper.xml | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java index d5ec0c371..079c0df30 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java @@ -676,6 +676,11 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { @Transactional(isolation= Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) public void setChannelStock(WxCouponChannel record,Integer number) { //设置渠道库存, + WxCouponChannel couponChannel = wxCouponChannelMapper.selectById(record.getId(), record.getTenantId()); + if(null != couponChannel.getChannelStock() || couponChannel.getChannelStock().intValue() != 0){ + throw new MallinkException(ErrorCode.REMAIN_BACK_FAIL.getCode(),"请先释放原有库存"); + } + int num = wxCouponChannelMapper.setChannelStock(record.getId(), record.getTenantId(), number); if (num == 0) { throw new MallinkException(ErrorCode.REMAIN_BACK_FAIL); @@ -693,6 +698,10 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { public void releaseChannelStock(WxCouponChannel record) { //释放渠道库存 WxCouponChannel couponChannel = wxCouponChannelMapper.selectById(record.getId(), record.getTenantId()); + if(null == couponChannel.getChannelStock()){ + throw new MallinkException(ErrorCode.REMAIN_BACK_FAIL.getCode(),"暂无可释放库存"); + } + int num = wxCouponChannelMapper.clearChannelStock(record.getId(), record.getTenantId()); if (num == 0) { throw new MallinkException(ErrorCode.REMAIN_BACK_FAIL); diff --git a/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml index 2fb768fa3..984f51d52 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml @@ -346,7 +346,7 @@ - update wx_coupon_channel SET channel_stock = #{number} where id = #{id} and tenant_id =#{tenantId} and channel_stock is not null + update wx_coupon_channel SET channel_stock = #{number} where id = #{id} and tenant_id =#{tenantId} and (channel_stock is null or channel_stock = 0)