提交代码

master
胡锐 1 year ago
parent 7dcbf23b19
commit 8feb8a2ed0
  1. 60
      schedule/src/main/java/com/hfkj/schedule/RebateActivitySchedule.java
  2. 2
      schedule/src/main/java/com/hfkj/schedule/TransferSchedule.java

@ -1,12 +1,12 @@
package com.hfkj.schedule;
import com.hfkj.entity.BsRebateActivity;
import com.hfkj.entity.BsTradeOrder;
import com.hfkj.common.utils.DateUtil;
import com.hfkj.entity.*;
import com.hfkj.service.rebate.BsRebateActivityService;
import com.hfkj.sysenum.RebateActivityEndTypeEnum;
import com.hfkj.sysenum.RebateActivityStatusEnum;
import com.hfkj.sysenum.TradeOrderCreateTypeEnum;
import com.hfkj.sysenum.TradeOrderStatusEnum;
import com.hfkj.service.rebate.BsRebatePartMerService;
import com.hfkj.service.rebate.BsRebateRewardRosterService;
import com.hfkj.service.rebate.BsRebateRewardService;
import com.hfkj.sysenum.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
@ -14,6 +14,8 @@ import org.springframework.scheduling.annotation.Scheduled;
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @className: RebateActivitySchedule
@ -28,6 +30,52 @@ public class RebateActivitySchedule {
@Resource
private BsRebateActivityService rebateActivityService;
@Resource
private BsRebateRewardService rebateRewardService;
@Resource
private BsRebatePartMerService rebatePartMerService;
/**
* 生成返利奖池
* 每个月1号 凌晨0点10分生成
*/
@Scheduled(cron="0 10 0 1 * ?")
public void generateReward() {
try {
Calendar startTime = Calendar.getInstance();
startTime.setTime(new Date());
startTime.add(Calendar.MONTH, - 1);
startTime.set(Calendar.DATE, startTime.getActualMinimum(Calendar.DAY_OF_MONTH));
startTime.set(Calendar.HOUR_OF_DAY, 00);
startTime.set(Calendar.MINUTE, 00);
startTime.set(Calendar.SECOND, 00);
Calendar endTime = Calendar.getInstance();
endTime.setTime(new Date());
endTime.add(Calendar.MONTH, -1);
endTime.set(Calendar.DATE, endTime.getActualMaximum(Calendar.DAY_OF_MONTH));
endTime.set(Calendar.HOUR_OF_DAY, 23);
endTime.set(Calendar.MINUTE, 59);
endTime.set(Calendar.SECOND, 59);
Map<String,Object> param = new HashMap<>();
param.put("status", RebatePartMerStatusEnum.status1.getNumber());
List<BsRebatePartMer> merList = rebatePartMerService.getMerList(param);
List<Long> merIdList = new ArrayList<>();
for (BsRebatePartMer partMer : merList) {
merIdList.add(partMer.getMerId());
}
// 生成奖池
rebateRewardService.createReward(startTime.getTime(), endTime.getTime(), merIdList.stream().distinct().collect(Collectors.toList()));
} catch (Exception e) {
log.error("生成奖池异常:" + e);
}
}
/**
* 取消订单
* 1分钟扫描一次

@ -76,7 +76,7 @@ public class TransferSchedule {
}
/**
* 活动金返利转账
* 活动金优惠 - 转账商户
*/
@Scheduled(cron = "0 0 1 * * ?") // 每日凌晨1点执行
public void tradeRebate() {

Loading…
Cancel
Save