|
|
|
@@ -85,6 +85,7 @@ public class PushLimitServiceImpl implements PushLimitService { |
|
|
|
// 2. check time |
|
|
|
boolean isInDate = DateUtils.isInDate(curDate, pushLimit.getTimeStart(), pushLimit.getTimeEnd()); |
|
|
|
if (!isInDate) { |
|
|
|
logger.error("短信已达到每天上限"); |
|
|
|
throw new MallinkException(ErrorCode.COUPON_SEND_NOT_INRANG); |
|
|
|
} |
|
|
|
// TODO 3. check phone had up to limit |
|
|
|
@@ -107,14 +108,18 @@ public class PushLimitServiceImpl implements PushLimitService { |
|
|
|
params.put("cUserId", cUserId); |
|
|
|
int countForUser = wxCouponActionLogMapper.getCountByUser(params); |
|
|
|
if (countForUser >= pushLimit.getCouponAmount()) { |
|
|
|
throw new MallinkException(ErrorCode.COUPON_SEND_UP_TO_COUPONLIMIT); |
|
|
|
String errMsg = "每人每天领券已达到疲劳度上限: " + pushLimit.getCouponAmount(); |
|
|
|
logger.error(errMsg); |
|
|
|
throw new MallinkException(ErrorCode.COUPON_SEND_UP_TO_COUPONLIMIT.getCode(), errMsg); |
|
|
|
} |
|
|
|
// 4. check 每人多少天内不会重复收到一张券 |
|
|
|
params.put("couponId", couponId); |
|
|
|
params.put("dayNum", pushLimit.getCouponDay()); |
|
|
|
int countForUserCoupon = wxCouponActionLogMapper.getCountByUserAndCoupon(params); |
|
|
|
if (countForUserCoupon >= pushLimit.getCouponDay()) { |
|
|
|
throw new MallinkException(ErrorCode.COUPON_SEND_UP_TO_COUPONLIMIT); |
|
|
|
if (countForUserCoupon >= 1) { |
|
|
|
String errMsg = "每人" + pushLimit.getCouponDay() + "天领一张券已到疲劳度上限"; |
|
|
|
logger.error(errMsg); |
|
|
|
throw new MallinkException(ErrorCode.COUPON_SEND_UP_TO_COUPONLIMIT.getCode(), errMsg); |
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
|