CouponHandleJob.java
2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package com.zteits.business.job;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.zteits.business.dao.TdCBusinessCouponDao;
import com.zteits.business.dao.TdCBusinessCouponRuleParkRelDao;
import com.zteits.business.domain.TdCBusinessCouponRuleParkRel;
import com.zteits.clouds.api.dto.business.param.TdCBusinessCouponRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
/**
*
*
* Copyright: Copyright (c) 2022 zteits
*
* @ClassName: CouponHandleJob.java
* @Description:
* @version: v1.0.0
* @author: wangxin
* @date: 2022年09月02日 下午17:52:52
* Modification History:
* Date Author Version Description
*---------------------------------------------------------*
* 2022年09月02日 wangxin v1.0.0 创建
*/
// 老写法(xxl-job 1.9)是 `@JobHander(value=...) + extends IJobHandler + @Override execute(...)`,
// 1.9 的 IJobHandler/JobHander/XxlJobLogger 在 2.x 已删除,这里按 2.x 写法改:
// @JobHander(value="X") 从类上移到方法上 → @XxlJob("X")(该注解 @Target 是 METHOD);
// XxlJobLogger.log("{0}--{1}",a,b) → XxlJobHelper.log("{}--{}",a,b)。
// 返回值沿用 ReturnT<String> + String... params,与本仓其余 105 个 Job 保持一致
// (xxl-job 2.5 的 MethodJobHandler 会传 null 进可变参数,Job 内部再用 XxlJobHelper.getJobParam() 取参)。
@Component
public class CouponHandleJob {
@Autowired
private TdCBusinessCouponRuleParkRelDao tdCBusinessCouponRuleParkRelDao;
@Autowired
private TdCBusinessCouponDao tdCBusinessCouponDao;
@XxlJob("RemainingCouponCountHandlerJob")
public ReturnT<String> execute(String... params) throws Exception {
List<TdCBusinessCouponRuleParkRel> list = tdCBusinessCouponRuleParkRelDao.selectByExample(null);
for (int i = 0; i < list.size(); i++) {
TdCBusinessCouponRuleParkRel rel = list.get(i);
TdCBusinessCouponRequest couponRequest = new TdCBusinessCouponRequest();
couponRequest.setDataState(1);
couponRequest.setIssued(0);
couponRequest.setCardRelParkNo(rel.getCardRelParkNo());
int CouponSize = tdCBusinessCouponDao.getRemainingCount(couponRequest);
XxlJobHelper.log("{}--{}", rel.getCardRelParkNo(), CouponSize);
rel.setCardNum(CouponSize);
tdCBusinessCouponRuleParkRelDao.updateByPrimaryKeySelective(rel);
}
return ReturnT.SUCCESS;
}
}