|
|
|
@@ -131,6 +131,7 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { |
|
|
|
merchantLnventory = jo.getIntValue(WxCouponSend.KEY_MERCHANT_LNVENTORY); |
|
|
|
merchantIdStr = jo.getString("id"); |
|
|
|
jo.put(WxCouponSend.KEY_MERCHANT_SEND,0) ; |
|
|
|
jo.put(WxCouponSend.KEY_MERCHANT_REMAIN,merchantLnventory) ; |
|
|
|
record.setConditions(jo.toJSONString()); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error(" updateInvalid 解析异常:{}", e.getMessage()); |
|
|
|
@@ -181,20 +182,18 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { |
|
|
|
if (Objects.isNull(wxCouponOfDb)) { |
|
|
|
throw new MallinkException(ErrorCode.COUPON_IS_EMPTY); |
|
|
|
} |
|
|
|
//查询商家 |
|
|
|
int merchantLnventory = 0, merchantSend = 0; |
|
|
|
//查询商家库存和 |
|
|
|
int merchantRemain = 0; |
|
|
|
try { |
|
|
|
JSONObject jo = JSONObject.parseObject(record.getConditions()); |
|
|
|
merchantLnventory = jo.getIntValue(WxCouponSend.KEY_MERCHANT_LNVENTORY); |
|
|
|
merchantSend = jo.getIntValue(WxCouponSend.KEY_MERCHANT_SEND); |
|
|
|
merchantRemain = jo.getIntValue(WxCouponSend.KEY_MERCHANT_REMAIN); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error(" updateInvalid 解析异常:{}", e.getMessage()); |
|
|
|
} |
|
|
|
if (0 >= merchantLnventory || 0 > merchantSend) { |
|
|
|
throw new MallinkException(ErrorCode.COUPON_SEND_LIMIT_VERIFY); |
|
|
|
} |
|
|
|
//退回coupon库存 |
|
|
|
wxCouponService.backRemainInventory(queryById.getId(), wxCouponOfDb.getRemainInventory(), merchantLnventory - merchantSend); |
|
|
|
if(merchantRemain!=0) { |
|
|
|
wxCouponService.backRemainInventory(queryById.getId(), wxCouponOfDb.getRemainInventory(), merchantRemain); |
|
|
|
} |
|
|
|
} |
|
|
|
wxCouponSendMapper.updateByPrimaryKeySelective(record); |
|
|
|
} |
|
|
|
@@ -569,16 +568,16 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void reduceMerchantSend(Long id, Integer merchantSend, Integer number) { |
|
|
|
int num = wxCouponSendMapper.reduceMerchantSend(id, merchantSend, number); |
|
|
|
public void reduceMerchantSend(Long id, Integer merchantRemain, Integer number) { |
|
|
|
int num = wxCouponSendMapper.reduceMerchantSend(id, merchantRemain, number); |
|
|
|
if (num == 0) { |
|
|
|
throw new MallinkException(ErrorCode.ORDER_IS_FAIL); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void backMerchantRemainInventory(Long id, Integer merchantSend, Integer number) { |
|
|
|
int num = wxCouponSendMapper.backMerchantSend(id, merchantSend, number); |
|
|
|
public void backMerchantRemainInventory(Long id, Integer merchantRemain, Integer number) { |
|
|
|
int num = wxCouponSendMapper.backMerchantSend(id, merchantRemain, number); |
|
|
|
if (num == 0) { |
|
|
|
throw new MallinkException(ErrorCode.ORDER_IS_FAIL); |
|
|
|
} |
|
|
|
|