|
|
|
@@ -1,5 +1,6 @@ |
|
|
|
package com.iformall.controller.market; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
import com.iformall.annotation.SystemControllerLog; |
|
|
|
import com.iformall.common.ErrorCode; |
|
|
|
@@ -105,6 +106,24 @@ public class WxCouponSendController extends BaseController { |
|
|
|
if (!EnumCouponSendType.PASSIVE.getCode().equals(wxCoupon.getSendType())) { |
|
|
|
return new ResultData(ErrorCode.COUPON_TYPE_IS_NOT_PASSIVE); |
|
|
|
} |
|
|
|
|
|
|
|
//商户卡库存校验 |
|
|
|
if(Objects.equals(wxCouponSend.getSendType(),EnumCouponSendSendType.MERCHANT.getCode())) { |
|
|
|
JSONObject jo = JSONObject.parseObject(wxCouponSend.getConditions()) ; |
|
|
|
if(Objects.isNull(jo)||!jo.containsKey(WxCouponSend.KEY_LIMIT)) { |
|
|
|
return new ResultData(ErrorCode.COUPON_SEND_LIMIT_VERIFY); |
|
|
|
} |
|
|
|
WxCoupon queryById = new WxCoupon() ; |
|
|
|
queryById.setId(wxCouponSend.getId()); |
|
|
|
WxCoupon wxCouponOfDb = wxCouponService.findById(queryById); |
|
|
|
if(Objects.isNull(wxCouponOfDb)) { |
|
|
|
return new ResultData(ErrorCode.COUPON_IS_EMPTY); |
|
|
|
} |
|
|
|
if(jo.getInteger(WxCouponSend.KEY_LIMIT) >wxCouponOfDb.getRemainInventory()) { |
|
|
|
return new ResultData(ErrorCode.REMAIN_IS_EMPTY); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
wxCouponSend.setTenantId(wxCoupon.getTenantId()); |
|
|
|
wxCouponSend.setTitle(wxCoupon.getTitle()); |
|
|
|
|
|
|
|
|