191 lines
5.5 KiB
Go
191 lines
5.5 KiB
Go
package response
|
|
|
|
import (
|
|
"psi/models"
|
|
)
|
|
|
|
// OutTaskListResponse 外部任务列表响应
|
|
type OutTaskListResponse struct {
|
|
List []OutTaskItem `json:"list"`
|
|
Total int64 `json:"total"`
|
|
Page int `json:"page"`
|
|
PageSize int `json:"pageSize"`
|
|
}
|
|
|
|
// OutTaskItem 外部任务项
|
|
type OutTaskItem struct {
|
|
ID int64 `json:"id"`
|
|
ShopID int64 `json:"shop_id"`
|
|
WaveTaskID int64 `json:"wave_task_id"`
|
|
OutTaskID int64 `json:"out_task_id"`
|
|
ShopType int8 `json:"shop_type"`
|
|
ShopTypeText string `json:"shop_type_text"`
|
|
TaskType int8 `json:"task_type"`
|
|
TaskTypeText string `json:"task_type_text"`
|
|
ImgType int8 `json:"img_type"`
|
|
ImgTypeText string `json:"img_type_text"`
|
|
TaskCount int64 `json:"task_count"`
|
|
CreatedAt int64 `json:"created_at"`
|
|
UpdatedAt int64 `json:"updated_at"`
|
|
}
|
|
|
|
// OutTaskLogListResponse 外部任务日志列表响应
|
|
type OutTaskLogListResponse struct {
|
|
List []OutTaskLogItem `json:"list"`
|
|
Total int64 `json:"total"`
|
|
Page int `json:"page"`
|
|
PageSize int `json:"pageSize"`
|
|
}
|
|
|
|
// OutTaskLogItem 外部任务日志项
|
|
type OutTaskLogItem struct {
|
|
ID int64 `json:"id"`
|
|
ShopID int64 `json:"shop_id"`
|
|
WaveTaskID int64 `json:"wave_task_id"`
|
|
OutTaskID int64 `json:"out_task_id"`
|
|
ProductID int64 `json:"product_id"`
|
|
ISBN string `json:"isbn"`
|
|
LiveImage interface{} `json:"live_image"`
|
|
Stock int64 `json:"stock"`
|
|
SalePrice int64 `json:"sale_price"`
|
|
Cost int64 `json:"cost"`
|
|
Status int8 `json:"status"`
|
|
StatusText string `json:"status_text"`
|
|
Msg string `json:"msg"`
|
|
CreatedAt int64 `json:"created_at"`
|
|
UpdatedAt int64 `json:"updated_at"`
|
|
}
|
|
|
|
// OutTaskByShopResponse 按店铺分组的任务列表响应
|
|
type OutTaskByShopResponse struct {
|
|
List []OutTaskShopGroup `json:"list"`
|
|
Total int64 `json:"total"`
|
|
Page int `json:"page"`
|
|
PageSize int `json:"pageSize"`
|
|
}
|
|
|
|
// OutTaskShopGroup 店铺任务分组
|
|
type OutTaskShopGroup struct {
|
|
ShopID int64 `json:"shop_id"`
|
|
ShopName string `json:"shop_name"`
|
|
ShopType int8 `json:"shop_type"`
|
|
ShopTypeText string `json:"shop_type_text"`
|
|
Tasks []OutTaskDetail `json:"tasks"`
|
|
}
|
|
|
|
// OutTaskDetail 任务详情(包含日志明细)
|
|
type OutTaskDetail struct {
|
|
ID int64 `json:"id"`
|
|
WaveTaskID int64 `json:"wave_task_id"`
|
|
OutTaskID int64 `json:"out_task_id"`
|
|
TaskType int8 `json:"task_type"`
|
|
ImgType int8 `json:"img_type"`
|
|
ImgTypeText string `json:"img_type_text"`
|
|
TaskCount int64 `json:"task_count"`
|
|
SendStatus string `json:"send_status"`
|
|
Logs []OutTaskLogItem `json:"logs"`
|
|
CreatedAt int64 `json:"created_at"`
|
|
UpdatedAt int64 `json:"updated_at"`
|
|
}
|
|
|
|
// ConvertOutTaskToDetail 将任务模型转换为详情项
|
|
func ConvertOutTaskToDetail(task models.OutTask) OutTaskDetail {
|
|
sendStatus := "未发送"
|
|
if task.OutTaskID != 0 {
|
|
sendStatus = "已发送"
|
|
}
|
|
|
|
return OutTaskDetail{
|
|
ID: task.ID,
|
|
WaveTaskID: task.WaveTaskID,
|
|
OutTaskID: task.OutTaskID,
|
|
TaskType: task.TaskType,
|
|
ImgType: task.ImgType,
|
|
ImgTypeText: GetImgTypeText(task.ImgType),
|
|
TaskCount: task.TaskCount,
|
|
SendStatus: sendStatus,
|
|
Logs: []OutTaskLogItem{},
|
|
CreatedAt: task.CreatedAt,
|
|
UpdatedAt: task.UpdatedAt,
|
|
}
|
|
}
|
|
|
|
// ConvertOutTaskToItem 将外部任务模型转换为响应项
|
|
func ConvertOutTaskToItem(task models.OutTask) OutTaskItem {
|
|
return OutTaskItem{
|
|
ID: task.ID,
|
|
ShopID: task.ShopID,
|
|
WaveTaskID: task.WaveTaskID,
|
|
OutTaskID: task.OutTaskID,
|
|
ShopType: task.ShopType,
|
|
ShopTypeText: GetShopTypeText(task.ShopType),
|
|
TaskType: task.TaskType,
|
|
ImgType: task.ImgType,
|
|
ImgTypeText: GetImgTypeText(task.ImgType),
|
|
TaskCount: task.TaskCount,
|
|
CreatedAt: task.CreatedAt,
|
|
UpdatedAt: task.UpdatedAt,
|
|
}
|
|
}
|
|
|
|
// ConvertOutTaskLogToItem 将外部任务日志模型转换为响应项
|
|
func ConvertOutTaskLogToItem(log models.OutTaskLog) OutTaskLogItem {
|
|
return OutTaskLogItem{
|
|
ID: log.ID,
|
|
ShopID: log.ShopID,
|
|
WaveTaskID: log.WaveTaskID,
|
|
OutTaskID: log.OutTaskID,
|
|
ProductID: log.ProductID,
|
|
ISBN: log.ISBN,
|
|
LiveImage: log.LiveImage,
|
|
Stock: log.Stock,
|
|
SalePrice: log.SalePrice,
|
|
Cost: log.Cost,
|
|
Status: log.Status,
|
|
StatusText: GetTaskLogStatusText(log.Status),
|
|
Msg: log.Msg,
|
|
CreatedAt: log.CreatedAt,
|
|
UpdatedAt: log.UpdatedAt,
|
|
}
|
|
}
|
|
|
|
// GetShopTypeText 获取店铺类型文本
|
|
func GetShopTypeText(shopType int8) string {
|
|
shopTypeMap := map[int8]string{
|
|
1: "拼多多",
|
|
2: "孔夫子",
|
|
5: "闲鱼",
|
|
}
|
|
if text, ok := shopTypeMap[shopType]; ok {
|
|
return text
|
|
}
|
|
return "未知"
|
|
}
|
|
|
|
// GetImgTypeText 获取图片类型文本
|
|
func GetImgTypeText(imgType int8) string {
|
|
imgTypeMap := map[int8]string{
|
|
1: "仅官图",
|
|
2: "仅实拍图",
|
|
3: "优先官图",
|
|
4: "优先实拍图",
|
|
}
|
|
if text, ok := imgTypeMap[imgType]; ok {
|
|
return text
|
|
}
|
|
return "未知"
|
|
}
|
|
|
|
// GetTaskLogStatusText 获取任务日志状态文本
|
|
func GetTaskLogStatusText(status int8) string {
|
|
statusMap := map[int8]string{
|
|
0: "异常",
|
|
1: "推送成功",
|
|
2: "发布成功",
|
|
}
|
|
if text, ok := statusMap[status]; ok {
|
|
return text
|
|
}
|
|
return "未知"
|
|
}
|