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();
|
}
|
}
|