admin
2025-08-20 f318c9c7c127b00f353bf45f273096d1dc4b424f
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
package com.taoke.autopay.factory.js2;
 
import com.taoke.autopay.entity.js2.OrderTask;
import com.taoke.autopay.vo.admin.js2.OrderTaskVO;
import com.taoke.autopay.utils.TimeUtil;
import org.yeshi.utils.StringUtil;
 
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
 
/**
 * @author 
 * @title: OrderTaskFactory
 * @description: 下单任务工厂类
 * @date 2025/7/31
 */
public class OrderTaskFactory {
    
    /**
     * 将OrderTask转换为OrderTaskVO
     * @param orderTask OrderTask实体
     * @return OrderTaskVO对象
     */
    public static OrderTaskVO createOrderTaskVO(OrderTask orderTask) {
        if (orderTask == null) {
            return null;
        }
        
        OrderTaskVO.OrderTaskVOBuilder builder = OrderTaskVO.builder();
        
        builder.id(orderTask.getId())
                .keywordContent(orderTask.getKeywordContent())
                .keywordMd5(orderTask.getKeywordMd5())
                .productSource(orderTask.getProductSource())
                .productName(orderTask.getProductName())
                .shopName(orderTask.getShopName())
                .requiredOrderCount(orderTask.getRequiredOrderCount())
                .completedOrderCount(orderTask.getCompletedOrderCount())
                .receivedOrderCount(orderTask.getReceivedOrderCount())
                .reviewedOrderCount(orderTask.getReviewedOrderCount())
                .receiveCycleMinutes(orderTask.getReceiveCycleMinutes())
                .status(orderTask.getStatus())
                .statusDescription(orderTask.getStatusDescription());
        
        // 处理日期字段转换为字符串
        if (orderTask.getOrderStartTime() != null) {
            builder.orderStartTime(TimeUtil.getGernalTime(orderTask.getOrderStartTime().getTime(), "yyyy-MM-dd HH:mm:ss"));
        }
        
        if (orderTask.getOrderEndTime() != null) {
            builder.orderEndTime(TimeUtil.getGernalTime(orderTask.getOrderEndTime().getTime(), "yyyy-MM-dd HH:mm:ss"));
        }
        
        if (orderTask.getCreateTime() != null) {
            builder.createTime(TimeUtil.getGernalTime(orderTask.getCreateTime().getTime(), "yyyy-MM-dd HH:mm:ss"));
        }
        
        if (orderTask.getUpdateTime() != null) {
            builder.updateTime(TimeUtil.getGernalTime(orderTask.getUpdateTime().getTime(), "yyyy-MM-dd HH:mm:ss"));
        }
        
        if (orderTask.getEstimatedReceiveTime() != null) {
            builder.estimatedReceiveTime(TimeUtil.getGernalTime(orderTask.getEstimatedReceiveTime().getTime(), "yyyy-MM-dd HH:mm:ss"));
        }
        
        return builder.build();
    }
    
    /**
     * 将OrderTaskVO转换为OrderTask
     * @param orderTaskVO OrderTaskVO对象
     * @return OrderTask实体
     */
    public static OrderTask createOrderTask(OrderTaskVO orderTaskVO) throws ParseException {
        if (orderTaskVO == null) {
            return null;
        }
        
        OrderTask.OrderTaskBuilder builder = OrderTask.builder();
        
        builder.id(orderTaskVO.getId())
                .keywordContent(orderTaskVO.getKeywordContent())
                .keywordMd5(orderTaskVO.getKeywordMd5())
                .productSource(orderTaskVO.getProductSource())
                .productName(orderTaskVO.getProductName())
                .shopName(orderTaskVO.getShopName())
                .requiredOrderCount(orderTaskVO.getRequiredOrderCount())
                .completedOrderCount(orderTaskVO.getCompletedOrderCount())
                .receivedOrderCount(orderTaskVO.getReceivedOrderCount())
                .reviewedOrderCount(orderTaskVO.getReviewedOrderCount())
                .receiveCycleMinutes(orderTaskVO.getReceiveCycleMinutes())
                .status(orderTaskVO.getStatus())
                .statusDescription(orderTaskVO.getStatusDescription());
        
        // 处理字符串字段转换为日期
        SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        
        if (!StringUtil.isNullOrEmpty(orderTaskVO.getOrderStartTime())) {
            builder.orderStartTime(dateTimeFormat.parse(orderTaskVO.getOrderStartTime()));
        }
        
        if (!StringUtil.isNullOrEmpty(orderTaskVO.getOrderEndTime())) {
            builder.orderEndTime(dateTimeFormat.parse(orderTaskVO.getOrderEndTime()));
        }
        
        if (!StringUtil.isNullOrEmpty(orderTaskVO.getCreateTime())) {
            builder.createTime(dateTimeFormat.parse(orderTaskVO.getCreateTime()));
        }
        
        if (!StringUtil.isNullOrEmpty(orderTaskVO.getUpdateTime())) {
            builder.updateTime(dateTimeFormat.parse(orderTaskVO.getUpdateTime()));
        }
        
        if (!StringUtil.isNullOrEmpty(orderTaskVO.getEstimatedReceiveTime())) {
            builder.estimatedReceiveTime(dateTimeFormat.parse(orderTaskVO.getEstimatedReceiveTime()));
        }
        
        return builder.build();
    }
}