admin
2024-10-15 4995469ae28ce99f5e682895c0708d15f4dc63cd
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
package com.yeshi.fanli.job.order;
 
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.yeshi.fanli.dto.mq.order.body.CommonOrderMQMsg;
import com.yeshi.fanli.entity.order.CommonOrder;
import com.yeshi.fanli.service.inter.order.CommonOrderService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.mq.cmq.order.OrdersCMQManager;
import com.yeshi.fanli.util.mq.rabbit.RabbitmqManager;
import org.springframework.stereotype.Component;
 
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
 
/**
 * @author hxh
 * @title: UpdateOrderJob
 * @description: 订单更新任务
 * @date 2023/1/11 10:52
 */
@Component
public class UpdateCommonOrderJob {
 
    @Resource
    private CommonOrderService commonOrderService;
 
    @Resource
    private OrdersCMQManager ordersCMQManager;
 
    @XxlJob("order-update-pay-state")
    public ReturnT<String> updatePayState(String param) throws Exception {
        //更新20-25天之前的未处理订单
        List<CommonOrder> resultList = null;
        if (!StringUtil.isNullOrEmpty(param)) {
            if (param.length() > 1) {
                resultList = commonOrderService.getByOrderNo(null, param);
            } else {
                resultList = commonOrderService.listPayStateOrder(Integer.parseInt(param), new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24L * 25), new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24L * 10), 1, 500);
            }
        } else {
            resultList = commonOrderService.listPayStateOrder(null, new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24L * 25), new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24L * 20), 1, 500);
        }
        for (CommonOrder co : resultList) {
            ordersCMQManager.addOrder(new CommonOrderMQMsg(co.getOrderNo(), co.getSourceType()));
        }
        return ReturnT.SUCCESS;
    }
}