admin
2025-08-08 035edfa382d349ba66240fbfef68c14c7cfc95d1
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
package com.taoke.autopay.factory.js2;
 
import com.taoke.autopay.entity.ClientAdditionalInfo;
import com.taoke.autopay.entity.js2.OrderTask;
import com.taoke.autopay.entity.js2.OrderTaskExecutionDetail;
import com.taoke.autopay.utils.TimeUtil;
import com.taoke.autopay.vo.OrderTaskExecutionDetailVO;
import org.yeshi.utils.StringUtil;
 
/**
 * @author 
 * @title: OrderTaskExecutionDetailFactory
 * @description: 下单任务执行详情工厂类
 * @date 2025/8/8
 */
public class OrderTaskExecutionDetailFactory {
    
    /**
     * 根据OrderTask、OrderTaskExecutionDetail和ClientAdditionalInfo创建OrderTaskExecutionDetailVO
     * 
     * @param orderTask 下单任务实体
     * @param orderTaskExecutionDetail 下单任务执行详情实体
     * @param clientAdditionalInfo 客户端附加信息
     * @return OrderTaskExecutionDetailVO对象
     */
    public static OrderTaskExecutionDetailVO createOrderTaskExecutionDetailVO(
            OrderTask orderTask, 
            OrderTaskExecutionDetail orderTaskExecutionDetail, 
            ClientAdditionalInfo clientAdditionalInfo) {
        
        if (orderTask == null || orderTaskExecutionDetail == null) {
            return null;
        }
        
        OrderTaskExecutionDetailVO.OrderTaskExecutionDetailVOBuilder builder = OrderTaskExecutionDetailVO.builder();
        
        // 设置基本字段
        builder.id(orderTaskExecutionDetail.getId())
                .taskId(orderTaskExecutionDetail.getTaskId())
                .clientId(orderTaskExecutionDetail.getClientId())
                .orderNo(orderTaskExecutionDetail.getOrderNo())
                .productName(orderTaskExecutionDetail.getProductName())
                .shopName(orderTaskExecutionDetail.getShopName());
        
        // 设置客户端附加信息
        if (clientAdditionalInfo != null) {
            builder.mobile(clientAdditionalInfo.getMobile())
                    .alipayAccount(clientAdditionalInfo.getAlipayAccount())
                    .alipayPassword(clientAdditionalInfo.getAlipayPassword());
        }
        
        // 根据执行状态设置执行类型
        Integer executionStatus = orderTaskExecutionDetail.getExecutionStatus();
        if (executionStatus != null) {
            if (executionStatus == OrderTaskExecutionDetail.STATUS_NOT_ORDERED) {
                builder.executionType(OrderTaskExecutionDetailVO.EXECUTION_TYPE_ORDER);
            } else if (executionStatus == OrderTaskExecutionDetail.STATUS_ORDERED) {
                builder.executionType(OrderTaskExecutionDetailVO.EXECUTION_TYPE_RECEIVE);
            } else if (executionStatus == OrderTaskExecutionDetail.STATUS_RECEIVE_SUCCESS) {
                builder.executionType(OrderTaskExecutionDetailVO.EXECUTION_TYPE_REVIEW);
            }
        }
        
        // 设置口令内容作为key
        if (!StringUtil.isNullOrEmpty(orderTask.getKeywordContent())) {
            builder.key(orderTask.getKeywordContent());
        }
        
        // 处理时间字段
        if (orderTaskExecutionDetail.getCreateTime() != null) {
            builder.createTime(TimeUtil.getGernalTime(orderTaskExecutionDetail.getCreateTime().getTime(), "yyyy-MM-dd HH:mm:ss"));
        }
 
        
        return builder.build();
    }
}