package response import ( "psi/models" ) type OutboundOrderWithInfo struct { models.OutboundOrder CustomerName string `gorm:"column:customer_name"` WarehouseName string `gorm:"column:warehouse_name"` } type OutboundOrderItemWithProduct struct { models.OutboundOrderItem ProductName string `gorm:"column:product_name"` ProductCode string `gorm:"column:product_code"` CategoryID int64 `gorm:"column:category_id"` CategoryName string `gorm:"column:category_name"` LocationName string `gorm:"column:location_name"` WarehouseName string `gorm:"column:warehouse_name"` WarehouseCode string `gorm:"column:warehouse_code"` SalesOrderNo string `gorm:"column:sales_order_no"` } // OutboundOrderListResponse 发货单列表响应 type OutboundOrderListResponse struct { List []OutboundOrderItem `json:"list"` Total int64 `json:"total"` Page int `json:"page"` PageSize int `json:"pageSize"` } type OutboundShopInfo struct { ShopName string `json:"shop_name"` ShopType int8 `json:"shop_type"` ShopTypeText string `json:"shop_type_text"` } // OutboundOrderItem 发货单项 type OutboundOrderItem struct { ID int64 `json:"id"` OutboundNo string `json:"outbound_no"` WaveTaskID int64 `json:"wave_task_id"` CustomerID int64 `json:"customer_id"` CustomerName string `json:"customer_name"` WarehouseID int64 `json:"warehouse_id"` WarehouseName string `json:"warehouse_name"` ShopList []OutboundShopInfo `json:"shop_list"` AssociationOrderNo string `json:"association_order_no"` //第三方订单编号 LogisticsNo string `json:"logistics_no"` //快递单号 Status int8 `json:"status"` StatusText string `json:"status_text"` Operator string `json:"operator"` OperatorID int64 `json:"operator_id"` Remark string `json:"remark"` CreatedAt int64 `json:"created_at"` UpdatedAt int64 `json:"updated_at"` } // OutboundOrderDetailResponse 发货单详情响应 type OutboundOrderDetailResponse struct { ID int64 `json:"id"` OutboundNo string `json:"outbound_no"` SalesOrderID int64 `json:"sales_order_id"` SalesOrderNo string `json:"sales_order_no"` WaveTaskID int64 `json:"wave_task_id"` CustomerID int64 `json:"customer_id"` CustomerName string `json:"customer_name"` WarehouseID int64 `json:"warehouse_id"` WarehouseName string `json:"warehouse_name"` Status int8 `json:"status"` StatusText string `json:"status_text"` Operator string `json:"operator"` OperatorID int64 `json:"operator_id"` Remark string `json:"remark"` CreatedAt int64 `json:"created_at"` UpdatedAt int64 `json:"updated_at"` Items []OutboundOrderDetailItem `json:"items"` } // OutboundOrderDetailItem 发货单明细项 type OutboundOrderDetailItem struct { ID int64 `json:"id"` OutboundOrderID int64 `json:"out_order_id"` SalesOrderNo string `json:"sales_order_no"` ProductID int64 `json:"product_id"` ProductName string `json:"product_name"` ProductCode string `json:"product_code"` CategoryID int64 `json:"category_id"` CategoryName string `json:"category_name"` LocationID int64 `json:"location_id"` LocationName string `json:"location_name"` WarehouseName string `json:"warehouse_name"` WarehouseCode string `json:"warehouse_code"` BatchNo string `json:"batch_no"` ProductionDate int64 `json:"production_date"` ExpiryDate int64 `json:"expiry_date"` Quantity int64 `json:"quantity"` CreatedAt int64 `json:"created_at"` UpdatedAt int64 `json:"updated_at"` } // ConvertOutboundOrderToItem 将发货单模型转换为响应项 func ConvertOutboundOrderToItem(order models.OutboundOrder, customerName string, warehouseName string, shopList []OutboundShopInfo, associationOrderNo string, logisticsNo string) OutboundOrderItem { return OutboundOrderItem{ ID: order.ID, OutboundNo: order.OutNo, WaveTaskID: order.WaveTaskID, CustomerID: order.CustomerID, CustomerName: customerName, WarehouseID: order.WarehouseID, WarehouseName: warehouseName, ShopList: shopList, AssociationOrderNo: associationOrderNo, LogisticsNo: logisticsNo, Status: order.Status, StatusText: GetOutboundOrderStatusText(order.Status), Operator: order.Operator, OperatorID: order.OperatorID, Remark: order.Remark, CreatedAt: order.CreatedAt, UpdatedAt: order.UpdatedAt, } } // ConvertOutboundOrderToDetail 将发货单模型转换为详情响应 func ConvertOutboundOrderToDetail(order models.OutboundOrder, customerName string, warehouseName string, items []OutboundOrderDetailItem) OutboundOrderDetailResponse { return OutboundOrderDetailResponse{ ID: order.ID, OutboundNo: order.OutNo, WaveTaskID: order.WaveTaskID, CustomerID: order.CustomerID, CustomerName: customerName, WarehouseID: order.WarehouseID, WarehouseName: warehouseName, Status: order.Status, StatusText: GetOutboundOrderStatusText(order.Status), Operator: order.Operator, OperatorID: order.OperatorID, Remark: order.Remark, CreatedAt: order.CreatedAt, UpdatedAt: order.UpdatedAt, Items: items, } } // GetOutboundOrderStatusText 获取发货单状态文本 func GetOutboundOrderStatusText(status int8) string { statusMap := map[int8]string{ 1: "已创建", 2: "拣货中", 3: "已完成", 4: "已取消", 5: "发货中", 6: "已发货", } if text, ok := statusMap[status]; ok { return text } return "未知" }