159 lines
6.0 KiB
Go
159 lines
6.0 KiB
Go
package response
|
|
|
|
import (
|
|
"gorm.io/datatypes"
|
|
"psi/models"
|
|
)
|
|
|
|
type ReceivingOrderWithInfo struct {
|
|
models.ReceivingOrder
|
|
SupplierName string `gorm:"column:supplier_name"`
|
|
WarehouseName string `gorm:"column:warehouse_name"`
|
|
PoNo string `gorm:"column:po_no"`
|
|
TaskNo string `gorm:"column:task_no"`
|
|
}
|
|
|
|
type ReceivingOrderItemWithProduct struct {
|
|
models.ReceivingOrderItem
|
|
ProductName string `gorm:"column:product_name"`
|
|
ProductCode string `gorm:"column:product_code"`
|
|
CategoryID int64 `gorm:"column:category_id"`
|
|
CategoryName string `gorm:"column:category_name"`
|
|
LiveImage datatypes.JSON `gorm:"column:live_image"`
|
|
LocationCode string `gorm:"column:location_code"`
|
|
}
|
|
|
|
// ReceivingOrderListResponse 入库单列表响应
|
|
type ReceivingOrderListResponse struct {
|
|
List []ReceivingOrderItem `json:"list"`
|
|
Total int64 `json:"total"`
|
|
Page int `json:"page"`
|
|
PageSize int `json:"pageSize"`
|
|
}
|
|
|
|
// ReceivingOrderItem 入库单项
|
|
type ReceivingOrderItem struct {
|
|
ID int64 `json:"id"`
|
|
ReceivingNo string `json:"receiving_no"`
|
|
PurchaseOrderID int64 `json:"purchase_order_id"`
|
|
PoNo string `json:"po_no"`
|
|
TaskNo string `json:"task_no"`
|
|
WaveTaskID int64 `json:"wave_task_id"`
|
|
WarehouseID int64 `json:"warehouse_id"`
|
|
WarehouseName string `json:"warehouse_name"`
|
|
SupplierID int64 `json:"supplier_id"`
|
|
SupplierName string `json:"supplier_name"`
|
|
ReceivingDate int64 `json:"receiving_date"`
|
|
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"`
|
|
}
|
|
|
|
// ReceivingOrderDetailResponse 入库单详情响应
|
|
type ReceivingOrderDetailResponse struct {
|
|
ID int64 `json:"id"`
|
|
ReceivingNo string `json:"receiving_no"`
|
|
PurchaseOrderID int64 `json:"purchase_order_id"`
|
|
PoNo string `json:"po_no"`
|
|
WaveTaskID int64 `json:"wave_task_id"`
|
|
WarehouseID int64 `json:"warehouse_id"`
|
|
WarehouseName string `json:"warehouse_name"`
|
|
SupplierID int64 `json:"supplier_id"`
|
|
SupplierName string `json:"supplier_name"`
|
|
ReceivingDate int64 `json:"receiving_date"`
|
|
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 []ReceivingOrderDetailItem `json:"items"`
|
|
}
|
|
|
|
// ReceivingOrderDetailItem 入库单明细项
|
|
type ReceivingOrderDetailItem struct {
|
|
ID int64 `json:"id"`
|
|
ReceivingOrderID int64 `json:"receiving_order_id"`
|
|
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"`
|
|
LiveImage []string `json:"live_image"`
|
|
LocationID int64 `json:"location_id"`
|
|
LocationCode string `json:"location_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"`
|
|
}
|
|
|
|
// ConvertReceivingOrderToItem 将入库单模型转换为响应项
|
|
func ConvertReceivingOrderToItem(order models.ReceivingOrder, supplierName, warehouseName, poNo, taskNo string) ReceivingOrderItem {
|
|
return ReceivingOrderItem{
|
|
ID: order.ID,
|
|
ReceivingNo: order.ReceivingNo,
|
|
PurchaseOrderID: order.PurchaseOrderID,
|
|
PoNo: poNo,
|
|
TaskNo: taskNo,
|
|
WaveTaskID: order.WaveTaskID,
|
|
WarehouseID: order.WarehouseID,
|
|
WarehouseName: warehouseName,
|
|
SupplierID: order.SupplierID,
|
|
SupplierName: supplierName,
|
|
ReceivingDate: order.ReceivingDate,
|
|
Status: order.Status,
|
|
StatusText: GetReceivingOrderStatusText(order.Status),
|
|
Operator: order.Operator,
|
|
OperatorID: order.OperatorID,
|
|
Remark: order.Remark,
|
|
CreatedAt: order.CreatedAt,
|
|
UpdatedAt: order.UpdatedAt,
|
|
}
|
|
}
|
|
|
|
// ConvertReceivingOrderToDetail 将入库单模型转换为详情响应
|
|
func ConvertReceivingOrderToDetail(order models.ReceivingOrder, supplierName string, warehouseName string, poNo string, items []ReceivingOrderDetailItem) ReceivingOrderDetailResponse {
|
|
return ReceivingOrderDetailResponse{
|
|
ID: order.ID,
|
|
ReceivingNo: order.ReceivingNo,
|
|
PurchaseOrderID: order.PurchaseOrderID,
|
|
PoNo: poNo,
|
|
WaveTaskID: order.WaveTaskID,
|
|
WarehouseID: order.WarehouseID,
|
|
WarehouseName: warehouseName,
|
|
SupplierID: order.SupplierID,
|
|
SupplierName: supplierName,
|
|
ReceivingDate: order.ReceivingDate,
|
|
Status: order.Status,
|
|
StatusText: GetReceivingOrderStatusText(order.Status),
|
|
Operator: order.Operator,
|
|
OperatorID: order.OperatorID,
|
|
Remark: order.Remark,
|
|
CreatedAt: order.CreatedAt,
|
|
UpdatedAt: order.UpdatedAt,
|
|
Items: items,
|
|
}
|
|
}
|
|
|
|
// GetReceivingOrderStatusText 获取入库单状态文本
|
|
func GetReceivingOrderStatusText(status int8) string {
|
|
statusMap := map[int8]string{
|
|
1: "待收货",
|
|
2: "验收中",
|
|
3: "已完成",
|
|
4: "已取消",
|
|
}
|
|
if text, ok := statusMap[status]; ok {
|
|
return text
|
|
}
|
|
return "未知"
|
|
}
|