|
|
|
@@ -68,12 +68,47 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { |
|
|
|
wxCouponSendMapper.deleteByPrimaryKey(id); |
|
|
|
} |
|
|
|
|
|
|
|
private boolean isConditionAllowed(WxCouponSend wxCouponSend, Object param) { |
|
|
|
|
|
|
|
if (wxCouponSend.getSendType().equals(EnumCouponSendSendType.C_ORDER.getCode())){ |
|
|
|
WxOrder wxOrder = (WxOrder)param; |
|
|
|
if (wxCouponSend.getCondition() == null) |
|
|
|
return true; |
|
|
|
if (wxOrder.getProductId().equals(Long.valueOf(wxCouponSend.getCondition()))) |
|
|
|
return true; |
|
|
|
return false; |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
public boolean sendCouponToUser(String tenantId, Long cUserId, EnumCouponSendSendType type) { |
|
|
|
//查询开关是否打开 |
|
|
|
public boolean sendCouponToUser(EnumCouponSendSendType type, Object param) { |
|
|
|
|
|
|
|
String tenantId; |
|
|
|
Long cUserId; |
|
|
|
switch (type) { |
|
|
|
case CAR_STOP: |
|
|
|
if (!param.getClass().equals(WxCUserCar.class)) |
|
|
|
return false; |
|
|
|
WxCUserCar wxCUserCar= (WxCUserCar)param; |
|
|
|
cUserId = wxCUserCar.getCUserId(); |
|
|
|
tenantId = wxCUserCar.getTenantId(); |
|
|
|
break; |
|
|
|
case COUPON_VERIFY: |
|
|
|
case B_MICROPAY: |
|
|
|
case C_ORDER: |
|
|
|
if (!param.getClass().equals(WxOrder.class)) |
|
|
|
return false; |
|
|
|
WxOrder order = (WxOrder)param; |
|
|
|
cUserId = order.getcUserId(); |
|
|
|
tenantId = order.getTenantId(); |
|
|
|
break; |
|
|
|
default: |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
//查询停车或者核销的券 stopCarCouponSwitch, verifyCouponSwitch, microPayCouponSwitch |
|
|
|
//查询开关是否打开 |
|
|
|
WxCouponSendConfig wxCouponSendConfig = new WxCouponSendConfig(); |
|
|
|
wxCouponSendConfig.setSendType(type.getCode()); |
|
|
|
wxCouponSendConfig.setTenantId(tenantId); |
|
|
|
@@ -114,6 +149,11 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { |
|
|
|
if (!checkLimit) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
//检查条件 |
|
|
|
if (!isConditionAllowed(send,param)) |
|
|
|
continue; |
|
|
|
|
|
|
|
// 发放免费券 |
|
|
|
WxCouponOrder couponOrder = wxOrderService.sendFreeCouponToUser(cUserId, send.getCouponId()); |
|
|
|
if (couponOrder != null) { |
|
|
|
|