295 lines
12 KiB
Go
295 lines
12 KiB
Go
package dto
|
||
|
||
import (
|
||
"time"
|
||
|
||
"github.com/gogf/gf/v2/frame/g"
|
||
)
|
||
|
||
// CreateOrderReq 创建订单请求
|
||
|
||
type CreateOrderReq struct {
|
||
g.Meta `path:"/create" method:"post" tags:"订单管理" summary:"创建订单" dc:"创建新订单"`
|
||
TenantID interface{} `json:"tenant_id" binding:"required"` // 租户ID
|
||
UserID int64 `json:"user_id" binding:"required"` // 用户ID
|
||
OrderType string `json:"order_type" binding:"required"` // 订单类型
|
||
Subject string `json:"subject" binding:"required"` // 订单标题
|
||
Description string `json:"description"` // 订单描述
|
||
OrderItems []OrderItemReq `json:"order_items" binding:"required"` // 订单商品
|
||
ShippingInfo ShippingInfoReq `json:"shipping_info"` // 收货信息
|
||
}
|
||
|
||
// OrderItemReq 创建订单商品项请求
|
||
|
||
type OrderItemReq struct {
|
||
AssetID string `json:"asset_id" binding:"required"` // 资产ID
|
||
AssetName string `json:"asset_name" binding:"required"` // 资产名称
|
||
AssetType string `json:"asset_type" binding:"required"` // 资产类型:product-商品型,service-服务型,software-软件型
|
||
ImageURL string `json:"image_url"` // 资产图片
|
||
Stocks []OrderItemStockReq `json:"stocks" binding:"required"` // 库存项列表
|
||
}
|
||
|
||
// OrderItemStockReq 创建订单商品项库存明细请求
|
||
|
||
type OrderItemStockReq struct {
|
||
// 库存ID(明细模式必填,批次模式为空)
|
||
StockID string `json:"stock_id,omitempty"` // 库存ID
|
||
// 批次信息(批次模式必填,明细模式为空)
|
||
BatchID string `json:"batch_id,omitempty"` // 批次ID
|
||
BatchNo string `json:"batch_no,omitempty"` // 批次号
|
||
// 数量
|
||
Quantity int `json:"quantity" binding:"required,min=1"` // 使用数量
|
||
// 价格信息
|
||
Price int64 `json:"price" binding:"required,min=1"` // 单价(分)
|
||
// 库存管理模式
|
||
StockMode int `json:"stock_mode" binding:"required"` // 库存管理模式:1-明细模式,2-批次模式
|
||
// 库存项属性
|
||
StockAttrs map[string]interface{} `json:"stock_attrs"` // 库存项属性(动态字段)
|
||
}
|
||
|
||
// ShippingInfoReq 收货信息请求
|
||
|
||
type ShippingInfoReq struct {
|
||
Consignee string `json:"consignee" binding:"required"` // 收货人
|
||
Phone string `json:"phone" binding:"required"` // 手机号
|
||
Province string `json:"province" binding:"required"` // 省份
|
||
City string `json:"city" binding:"required"` // 城市
|
||
District string `json:"district" binding:"required"` // 区县
|
||
Address string `json:"address" binding:"required"` // 详细地址
|
||
PostalCode string `json:"postal_code"` // 邮编
|
||
}
|
||
|
||
// CreateOrderResp 创建订单响应
|
||
|
||
type CreateOrderResp struct {
|
||
OrderNo string `json:"order_no"` // 订单号
|
||
TotalAmount int64 `json:"total_amount"` // 订单总金额
|
||
PayAmount int64 `json:"pay_amount"` // 实付金额
|
||
ExpiredAt string `json:"expired_at"` // 过期时间
|
||
}
|
||
|
||
// PayOrderReq 支付订单请求
|
||
|
||
type PayOrderReq struct {
|
||
g.Meta `path:"/pay" method:"post" tags:"订单管理" summary:"支付订单" dc:"发起订单支付"`
|
||
TenantID string `json:"tenant_id" binding:"required"` // 租户ID
|
||
OrderNo string `json:"order_no" binding:"required"` // 订单号
|
||
PayMethod string `json:"pay_method" binding:"required"` // 支付方式:wechat/alipay
|
||
PayType string `json:"pay_type" binding:"required"` // 支付类型:native/jsapi/app/h5
|
||
ClientIP string `json:"client_ip"` // 客户端IP
|
||
OpenID string `json:"openid"` // 用户OpenID(JSAPI支付)
|
||
AuthCode string `json:"auth_code"` // 授权码(付款码支付)
|
||
ReturnURL string `json:"return_url"` // 支付完成跳转URL
|
||
}
|
||
|
||
// PayOrderResp 支付订单响应
|
||
|
||
type PayOrderResp struct {
|
||
OrderNo string `json:"order_no"` // 订单号
|
||
QRCode string `json:"qrcode"` // 支付二维码(Native支付)
|
||
PayURL string `json:"pay_url"` // 支付链接(H5支付)
|
||
PrepayID string `json:"prepay_id"` // 预支付ID(微信)
|
||
JSAPIParams string `json:"jsapi_params"` // JSAPI参数(微信)
|
||
APPParams string `json:"app_params"` // APP参数
|
||
}
|
||
|
||
// QueryOrderReq 查询订单请求
|
||
|
||
type QueryOrderReq struct {
|
||
g.Meta `path:"/query" method:"get" tags:"订单管理" summary:"查询订单详情" dc:"根据订单号查询订单详情"`
|
||
TenantID string `json:"tenant_id" binding:"required"` // 租户ID
|
||
OrderNo string `json:"order_no" binding:"required"` // 订单号
|
||
}
|
||
|
||
// QueryOrderResp 查询订单响应
|
||
|
||
type QueryOrderResp struct {
|
||
Order OrderDetail `json:"order"` // 订单详情
|
||
}
|
||
|
||
// OrderDetail 订单详情
|
||
|
||
type OrderDetail struct {
|
||
ID string `json:"id"` // 订单ID
|
||
TenantID interface{} `json:"tenant_id"` // 租户ID
|
||
OrderNo string `json:"order_no"` // 订单号
|
||
UserID int64 `json:"user_id"` // 用户ID
|
||
TotalAmount int64 `json:"total_amount"` // 订单总金额
|
||
PayAmount int64 `json:"pay_amount"` // 实付金额
|
||
Status string `json:"status"` // 订单状态
|
||
PayMethod string `json:"pay_method"` // 支付方式
|
||
PayStatus string `json:"pay_status"` // 支付状态
|
||
OrderType string `json:"order_type"` // 订单类型
|
||
Subject string `json:"subject"` // 订单标题
|
||
Description string `json:"description"` // 订单描述
|
||
OrderItems []OrderItem `json:"order_items"` // 订单商品
|
||
ShippingInfo ShippingInfo `json:"shipping_info"` // 收货信息
|
||
PayInfo PayInfo `json:"pay_info"` // 支付信息
|
||
CreatedAt time.Time `json:"created_at"` // 创建时间
|
||
UpdatedAt time.Time `json:"updated_at"` // 更新时间
|
||
PaidAt *time.Time `json:"paid_at"` // 支付时间
|
||
ExpiredAt *time.Time `json:"expired_at"` // 过期时间
|
||
}
|
||
|
||
// OrderItem 订单商品项(响应)
|
||
|
||
type OrderItem struct {
|
||
AssetID string `json:"asset_id"` // 资产ID
|
||
AssetName string `json:"asset_name"` // 资产名称
|
||
AssetType string `json:"asset_type"` // 资产类型:product-商品型,service-服务型,software-软件型
|
||
ImageURL string `json:"image_url"` // 资产图片
|
||
Quantity int `json:"quantity"` // 总数量
|
||
TotalPrice int64 `json:"total_price"` // 小计(分)
|
||
Stocks []OrderItemStock `json:"stocks"` // 库存项列表
|
||
}
|
||
|
||
// OrderItemStock 订单商品项库存明细(响应)
|
||
|
||
type OrderItemStock struct {
|
||
// 库存ID(明细模式)
|
||
StockID string `json:"stock_id,omitempty"` // 库存ID
|
||
// 批次信息(批次模式)
|
||
BatchID string `json:"batch_id,omitempty"` // 批次ID
|
||
BatchNo string `json:"batch_no,omitempty"` // 批次号
|
||
// 数量
|
||
Quantity int `json:"quantity"` // 使用数量
|
||
// 价格信息
|
||
Price int64 `json:"price"` // 单价(分)
|
||
// 库存管理模式
|
||
StockMode int `json:"stock_mode"` // 库存管理模式:1-明细模式,2-批次模式
|
||
// 库存项属性
|
||
StockAttrs map[string]interface{} `json:"stock_attrs"` // 库存项属性(动态字段)
|
||
}
|
||
|
||
// ShippingInfo 收货信息(响应)
|
||
|
||
type ShippingInfo struct {
|
||
Consignee string `json:"consignee"` // 收货人
|
||
Phone string `json:"phone"` // 手机号
|
||
Province string `json:"province"` // 省份
|
||
City string `json:"city"` // 城市
|
||
District string `json:"district"` // 区县
|
||
Address string `json:"address"` // 详细地址
|
||
PostalCode string `json:"postal_code"` // 邮编
|
||
}
|
||
|
||
// PayInfo 支付信息(响应)
|
||
|
||
type PayInfo struct {
|
||
TransactionID string `json:"transaction_id"` // 支付平台交易号
|
||
OutTradeNo string `json:"out_trade_no"` // 商户订单号
|
||
PrepayID string `json:"prepay_id"` // 预支付ID
|
||
QRCode string `json:"qrcode"` // 支付二维码
|
||
PayURL string `json:"pay_url"` // 支付链接
|
||
}
|
||
|
||
// CancelOrderReq 取消订单请求
|
||
|
||
type CancelOrderReq struct {
|
||
g.Meta `path:"/cancel" method:"post" tags:"订单管理" summary:"取消订单" dc:"取消指定订单"`
|
||
TenantID string `json:"tenant_id" binding:"required"` // 租户ID
|
||
OrderNo string `json:"order_no" binding:"required"` // 订单号
|
||
Reason string `json:"reason"` // 取消原因
|
||
}
|
||
|
||
// CancelOrderResp 取消订单响应
|
||
|
||
type CancelOrderResp struct {
|
||
OrderNo string `json:"order_no"` // 订单号
|
||
Status string `json:"status"` // 新状态
|
||
}
|
||
|
||
// RefundOrderReq 退款请求
|
||
|
||
type RefundOrderReq struct {
|
||
g.Meta `path:"/refund" method:"post" tags:"订单管理" summary:"订单退款" dc:"发起订单退款"`
|
||
TenantID string `json:"tenant_id" binding:"required"` // 租户ID
|
||
OrderNo string `json:"order_no" binding:"required"` // 订单号
|
||
RefundAmount int64 `json:"refund_amount" binding:"required"` // 退款金额(分)
|
||
Reason string `json:"reason"` // 退款原因
|
||
}
|
||
|
||
// RefundOrderResp 退款响应
|
||
|
||
type RefundOrderResp struct {
|
||
RefundNo string `json:"refund_no"` // 退款单号
|
||
RefundID string `json:"refund_id"` // 退款ID
|
||
RefundAmount int64 `json:"refund_amount"` // 退款金额
|
||
}
|
||
|
||
// ListOrdersReq 订单列表请求
|
||
|
||
type ListOrdersReq struct {
|
||
g.Meta `path:"/orders" method:"get" tags:"订单管理" summary:"订单列表" dc:"分页查询订单列表"`
|
||
TenantID string `json:"tenant_id" binding:"required"` // 租户ID
|
||
UserID string `json:"user_id"` // 用户ID(可选)
|
||
Status string `json:"status"` // 订单状态(可选)
|
||
Page int `json:"page"` // 页码
|
||
PageSize int `json:"page_size"` // 每页大小
|
||
}
|
||
|
||
// ListOrdersResp 订单列表响应
|
||
|
||
type ListOrdersResp struct {
|
||
Orders []OrderSummary `json:"orders"` // 订单列表
|
||
Total int64 `json:"total"` // 总记录数
|
||
Page int `json:"page"` // 当前页码
|
||
PageSize int `json:"page_size"` // 每页大小
|
||
}
|
||
|
||
// OrderSummary 订单摘要(用于列表)
|
||
|
||
type OrderSummary struct {
|
||
ID string `json:"id"` // 订单ID
|
||
OrderNo string `json:"order_no"` // 订单号
|
||
TotalAmount int64 `json:"total_amount"` // 订单总金额
|
||
PayAmount int64 `json:"pay_amount"` // 实付金额
|
||
Status string `json:"status"` // 订单状态
|
||
Subject string `json:"subject"` // 订单标题
|
||
CreatedAt time.Time `json:"created_at"` // 创建时间
|
||
PaidAt *time.Time `json:"paid_at"` // 支付时间
|
||
}
|
||
|
||
// PaymentNotifyReq 支付回调请求
|
||
|
||
type PaymentNotifyReq struct {
|
||
g.Meta `path:"/paymentNotify" method:"post" tags:"支付管理" summary:"支付回调" dc:"处理支付平台回调通知"`
|
||
TenantID string `json:"tenant_id"` // 租户ID
|
||
OrderNo string `json:"order_no"` // 订单号
|
||
PayMethod string `json:"pay_method"` // 支付方式
|
||
Status string `json:"status"` // 支付状态
|
||
TransactionID string `json:"transaction_id"` // 交易号
|
||
TradeNo string `json:"trade_no"` // 交易号
|
||
Sign string `json:"sign"` // 签名
|
||
}
|
||
|
||
// PaymentNotifyResp 支付回调响应
|
||
|
||
type PaymentNotifyResp struct {
|
||
Success bool `json:"success"` // 是否成功
|
||
}
|
||
|
||
// RefundNotifyReq 退款回调请求
|
||
|
||
type RefundNotifyReq struct {
|
||
g.Meta `path:"/refundNotify" method:"post" tags:"退款管理" summary:"退款回调" dc:"处理退款平台回调通知"`
|
||
TenantID string `json:"tenant_id"` // 租户ID
|
||
RefundNo string `json:"refund_no"` // 退款单号
|
||
Status string `json:"status"` // 退款状态
|
||
RefundID string `json:"refund_id"` // 退款ID
|
||
Sign string `json:"sign"` // 签名
|
||
}
|
||
|
||
// RefundNotifyResp 退款回调响应
|
||
|
||
type RefundNotifyResp struct {
|
||
Success bool `json:"success"` // 是否成功
|
||
}
|
||
|
||
// CommonResp 通用响应
|
||
|
||
type CommonResp struct {
|
||
Success bool `json:"success"` // 是否成功
|
||
Message string `json:"message"` // 消息
|
||
}
|