Browse Source

生日积分定时任务时间修改为每天上午8:30

release_toaliyun_real
Burce 6 years ago
parent
commit
02cbb8b1a3
1 changed files with 19 additions and 5 deletions
  1. +19
    -5
      mallinkSchedule/src/main/java/com/iformall/schedule/CouponSendSchedule.java

+ 19
- 5
mallinkSchedule/src/main/java/com/iformall/schedule/CouponSendSchedule.java View File

@@ -1,6 +1,7 @@
package com.iformall.schedule; package com.iformall.schedule;


import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.iformall.common.ErrorCode;
import com.iformall.domain.dto.WxCUserBasicInfoDto; import com.iformall.domain.dto.WxCUserBasicInfoDto;
import com.iformall.domain.po.*; import com.iformall.domain.po.*;
import com.iformall.domain.po.msg.WxMsgRecord; import com.iformall.domain.po.msg.WxMsgRecord;
@@ -65,6 +66,8 @@ public class CouponSendSchedule {


@Autowired @Autowired
private MqBaseProducer mqBaseProducer; private MqBaseProducer mqBaseProducer;
@Autowired
private PushLimitService pushLimitService;




//@Scheduled(cron = "0 0 6 1 * ?") // 每月1号发放会员的权益券 //@Scheduled(cron = "0 0 6 1 * ?") // 每月1号发放会员的权益券
@@ -208,7 +211,7 @@ public class CouponSendSchedule {
/** /**
* 生日券发放 * 生日券发放
*/ */
@Scheduled(cron = "0 0 15 * * ?") // 测试每天6点发券
@Scheduled(cron = "0 30 8 * * ?") // 测试每天8:30点发券
public void birthdayCouponSendSchedule() { public void birthdayCouponSendSchedule() {
logger.info("生日发券: 任务开始"); logger.info("生日发券: 任务开始");
List<WxMall> mallList = wxMallMapper.findList(new WxMall()); List<WxMall> mallList = wxMallMapper.findList(new WxMall());
@@ -256,7 +259,7 @@ public class CouponSendSchedule {
logger.info("生日发券: 会员生日券投放列表为空 couponSendList = {}, 任务跳过不执行", couponSendList); logger.info("生日发券: 会员生日券投放列表为空 couponSendList = {}, 任务跳过不执行", couponSendList);
return; return;
} }
boolean sent = false;
boolean couponSent = false;
for (WxCouponSendVo cs : couponSendList) { for (WxCouponSendVo cs : couponSendList) {
String conditions = cs.getConditions(); String conditions = cs.getConditions();
JSONObject configJo = null; JSONObject configJo = null;
@@ -269,6 +272,12 @@ public class CouponSendSchedule {
logger.info("生日发券: 会员生日券配置不存在 conditions = {}, 任务跳过不执行", conditions); logger.info("生日发券: 会员生日券配置不存在 conditions = {}, 任务跳过不执行", conditions);
return; return;
} }

boolean couponLimit = pushLimitService.checkCoupon(cu.getTenantId(), cu.getId(), cs.getCouponId());
if (!couponLimit) {
logger.info("生日发券: {}", ErrorCode.PUSH_LIMIT_UP_TO_COUPONLIMIT.getMessage());
return;
}
//默认生日当天发送 //默认生日当天发送
int beforeDays = 0; int beforeDays = 0;
if (configJo.containsKey(WxCouponSend.KEY_BEFOREDAYS)) { if (configJo.containsKey(WxCouponSend.KEY_BEFOREDAYS)) {
@@ -309,7 +318,7 @@ public class CouponSendSchedule {
logger.error("定时发券:发券失败 levelId=" + cu.getId() + " couponId=" + cs.getCouponId() + " userId=" + cu.getId() + e.getMessage()); logger.error("定时发券:发券失败 levelId=" + cu.getId() + " couponId=" + cs.getCouponId() + " userId=" + cu.getId() + e.getMessage());
continue; continue;
} }
sent = true;
couponSent = true;
logger.info("定时发券:商场[" + mall.getName() + logger.info("定时发券:商场[" + mall.getName() +
"]会员生日[" + cu.getBirthdate().toInstant() + "]会员生日[" + cu.getBirthdate().toInstant() +
"]发送券[" + cs.getTitle() + "]发送券[" + cs.getTitle() +
@@ -317,11 +326,16 @@ public class CouponSendSchedule {
" 电话-" + cu.getPhone() + " 电话-" + cu.getPhone() +
" id-" + cu.getId()); " id-" + cu.getId());
} }
if (sent) {
if (couponSent) {
boolean couponLimit = pushLimitService.checkMsg(cu.getTenantId());
if (!couponLimit) {
logger.info("生日发券: {}", ErrorCode.PUSH_LIMIT_NOT_INRANG.getMessage());
return;
}
sendSMS(cu, mall); sendSMS(cu, mall);
// 记录积分倍率日期 // 记录积分倍率日期
try { try {
WxCUserBasicInfo toUpdate = new WxCUserBasicInfo() ;
WxCUserBasicInfo toUpdate = new WxCUserBasicInfo();
toUpdate.setId(cu.getId()); toUpdate.setId(cu.getId());
toUpdate.setScoreDate(cu.getBirthdate()); toUpdate.setScoreDate(cu.getBirthdate());
wxCUserBasicInfoMapper.updateByPrimaryKeySelective(toUpdate); wxCUserBasicInfoMapper.updateByPrimaryKeySelective(toUpdate);


Loading…
Cancel
Save