初始化项目
This commit is contained in:
206
model/dto/order.go
Normal file
206
model/dto/order.go
Normal file
@@ -0,0 +1,206 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// CreateOrderReq 创建订单请求
|
||||
|
||||
type CreateOrderReq struct {
|
||||
TenantID string `json:"tenant_id" binding:"required"` // 租户ID
|
||||
UserID string `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 {
|
||||
ProductID string `json:"product_id" binding:"required"` // 商品ID
|
||||
ProductName string `json:"product_name" binding:"required"` // 商品名称
|
||||
Price int64 `json:"price" binding:"required,min=1"` // 单价(分)
|
||||
Quantity int `json:"quantity" binding:"required,min=1"` // 数量
|
||||
ImageURL string `json:"image_url"` // 商品图片
|
||||
}
|
||||
|
||||
// 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 {
|
||||
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 {
|
||||
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 string `json:"tenant_id"` // 租户ID
|
||||
OrderNo string `json:"order_no"` // 订单号
|
||||
UserID string `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 {
|
||||
ProductID string `json:"product_id"` // 商品ID
|
||||
ProductName string `json:"product_name"` // 商品名称
|
||||
Price int64 `json:"price"` // 单价(分)
|
||||
Quantity int `json:"quantity"` // 数量
|
||||
TotalPrice int64 `json:"total_price"` // 小计(分)
|
||||
ImageURL string `json:"image_url"` // 商品图片
|
||||
}
|
||||
|
||||
// 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 {
|
||||
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 {
|
||||
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 {
|
||||
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"` // 支付时间
|
||||
}
|
||||
54
model/entity/order_base.go
Normal file
54
model/entity/order_base.go
Normal file
@@ -0,0 +1,54 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"time"
|
||||
)
|
||||
|
||||
// OrderBase 订单基础信息
|
||||
// 所有订单状态共有的字段
|
||||
// 按状态拆分的订单表会继承这个基础结构
|
||||
// 每个状态对应一个独立的MongoDB集合
|
||||
// 例如:orders_pending, orders_paid, orders_shipped, orders_completed, orders_cancelled
|
||||
|
||||
type OrderBase struct {
|
||||
ID primitive.ObjectID `bson:"_id,omitempty" json:"id"`
|
||||
TenantID string `bson:"tenant_id" json:"tenant_id"` // 租户ID
|
||||
OrderNo string `bson:"order_no" json:"order_no"` // 订单号
|
||||
UserID string `bson:"user_id" json:"user_id"` // 用户ID
|
||||
TotalAmount int64 `bson:"total_amount" json:"total_amount"` // 订单总金额(分)
|
||||
PayAmount int64 `bson:"pay_amount" json:"pay_amount"` // 实付金额(分)
|
||||
OrderType string `bson:"order_type" json:"order_type"` // 订单类型:normal-普通订单
|
||||
Subject string `bson:"subject" json:"subject"` // 订单标题
|
||||
Description string `bson:"description" json:"description"` // 订单描述
|
||||
CreatedAt time.Time `bson:"created_at" json:"created_at"` // 创建时间
|
||||
UpdatedAt time.Time `bson:"updated_at" json:"updated_at"` // 更新时间
|
||||
ExpiredAt *time.Time `bson:"expired_at,omitempty" json:"expired_at"` // 过期时间
|
||||
}
|
||||
|
||||
// OrderItem 订单商品项
|
||||
// 所有订单状态共有的商品信息
|
||||
// 按状态拆分的订单表会包含这个结构
|
||||
|
||||
type OrderItem struct {
|
||||
ProductID string `bson:"product_id" json:"product_id"` // 商品ID
|
||||
ProductName string `bson:"product_name" json:"product_name"` // 商品名称
|
||||
Price int64 `bson:"price" json:"price"` // 单价(分)
|
||||
Quantity int `bson:"quantity" json:"quantity"` // 数量
|
||||
TotalPrice int64 `bson:"total_price" json:"total_price"` // 小计(分)
|
||||
ImageURL string `bson:"image_url,omitempty" json:"image_url"` // 商品图片
|
||||
}
|
||||
|
||||
// ShippingInfo 收货信息
|
||||
// 所有订单状态共有的收货信息
|
||||
// 按状态拆分的订单表会包含这个结构
|
||||
|
||||
type ShippingInfo struct {
|
||||
Consignee string `bson:"consignee" json:"consignee"` // 收货人
|
||||
Phone string `bson:"phone" json:"phone"` // 手机号
|
||||
Province string `bson:"province" json:"province"` // 省份
|
||||
City string `bson:"city" json:"city"` // 城市
|
||||
District string `bson:"district" json:"district"` // 区县
|
||||
Address string `bson:"address" json:"address"` // 详细地址
|
||||
PostalCode string `bson:"postal_code,omitempty" json:"postal_code"` // 邮编
|
||||
}
|
||||
36
model/entity/order_completed.go
Normal file
36
model/entity/order_completed.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// OrderCompleted 已完成订单
|
||||
// 对应MongoDB集合:orders_completed
|
||||
// 用户确认收货后订单进入此状态
|
||||
|
||||
type OrderCompleted struct {
|
||||
OrderBase // 基础订单信息
|
||||
PayMethod string `bson:"pay_method" json:"pay_method"` // 支付方式:wechat/alipay
|
||||
OrderItems []OrderItem `bson:"order_items" json:"order_items"` // 订单商品列表
|
||||
ShippingInfo *ShippingInfo `bson:"shipping_info,omitempty" json:"shipping_info"` // 收货信息
|
||||
|
||||
// 支付成功信息
|
||||
PaidAt time.Time `bson:"paid_at" json:"paid_at"` // 支付时间
|
||||
TransactionID string `bson:"transaction_id" json:"transaction_id"` // 支付平台交易号
|
||||
TradeNo string `bson:"trade_no" json:"trade_no"` // 交易号
|
||||
PaymentChannel string `bson:"payment_channel" json:"payment_channel"` // 支付渠道:wechat/alipay
|
||||
|
||||
// 发货信息
|
||||
ShippedAt time.Time `bson:"shipped_at" json:"shipped_at"` // 发货时间
|
||||
ExpressCompany string `bson:"express_company" json:"express_company"` // 快递公司
|
||||
ExpressNo string `bson:"express_no" json:"express_no"` // 快递单号
|
||||
ShippingCost int64 `bson:"shipping_cost" json:"shipping_cost"` // 运费(分)
|
||||
|
||||
// 完成特有字段
|
||||
CompletedAt time.Time `bson:"completed_at" json:"completed_at"` // 完成时间
|
||||
ReceivedAt time.Time `bson:"received_at" json:"received_at"` // 收货时间
|
||||
|
||||
// 评价相关字段
|
||||
Rating int `bson:"rating,omitempty" json:"rating"` // 评分(1-5)
|
||||
Comment string `bson:"comment,omitempty" json:"comment"` // 评价内容
|
||||
}
|
||||
26
model/entity/order_paid.go
Normal file
26
model/entity/order_paid.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// OrderPaid 已支付订单
|
||||
// 对应MongoDB集合:orders_paid
|
||||
// 支付成功后订单进入此状态
|
||||
|
||||
type OrderPaid struct {
|
||||
OrderBase // 基础订单信息
|
||||
PayMethod string `bson:"pay_method" json:"pay_method"` // 支付方式:wechat/alipay
|
||||
PayType string `bson:"pay_type" json:"pay_type"` // 支付类型:native/jsapi/app/h5
|
||||
OrderItems []OrderItem `bson:"order_items" json:"order_items"` // 订单商品列表
|
||||
ShippingInfo *ShippingInfo `bson:"shipping_info,omitempty" json:"shipping_info"` // 收货信息
|
||||
|
||||
// 支付成功特有字段
|
||||
PaidAt time.Time `bson:"paid_at" json:"paid_at"` // 支付时间
|
||||
TransactionID string `bson:"transaction_id" json:"transaction_id"` // 支付平台交易号
|
||||
TradeNo string `bson:"trade_no" json:"trade_no"` // 交易号
|
||||
PaymentChannel string `bson:"payment_channel" json:"payment_channel"` // 支付渠道:wechat/alipay
|
||||
|
||||
// 发货准备相关字段
|
||||
ReadyToShip bool `bson:"ready_to_ship" json:"ready_to_ship"` // 是否准备发货
|
||||
}
|
||||
32
model/entity/order_pending.go
Normal file
32
model/entity/order_pending.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// OrderPending 待支付订单
|
||||
// 对应MongoDB集合:orders_pending
|
||||
// 订单创建后进入此状态
|
||||
|
||||
type OrderPending struct {
|
||||
OrderBase // 基础订单信息
|
||||
PayMethod string `bson:"pay_method" json:"pay_method"` // 支付方式:wechat/alipay
|
||||
PayType string `bson:"pay_type" json:"pay_type"` // 支付类型:native/jsapi/app/h5
|
||||
OrderItems []OrderItem `bson:"order_items" json:"order_items"` // 订单商品列表
|
||||
ShippingInfo *ShippingInfo `bson:"shipping_info,omitempty" json:"shipping_info"` // 收货信息
|
||||
|
||||
// 支付相关字段
|
||||
PayInfo PayInfo `bson:"pay_info" json:"pay_info"` // 支付信息
|
||||
}
|
||||
|
||||
// PayInfo 支付信息(待支付订单特有)
|
||||
// 包含支付二维码、支付链接等
|
||||
|
||||
type PayInfo struct {
|
||||
OutTradeNo string `bson:"out_trade_no" json:"out_trade_no"` // 商户订单号
|
||||
QRCode string `bson:"qrcode,omitempty" json:"qrcode"` // 支付二维码
|
||||
PayURL string `bson:"pay_url,omitempty" json:"pay_url"` // 支付链接
|
||||
PrepayID string `bson:"prepay_id,omitempty" json:"prepay_id"` // 预支付ID(微信)
|
||||
JSAPIParams string `bson:"jsapi_params,omitempty" json:"jsapi_params"` // JSAPI参数
|
||||
APPParams string `bson:"app_params,omitempty" json:"app_params"` // APP参数
|
||||
}
|
||||
31
model/entity/order_shipped.go
Normal file
31
model/entity/order_shipped.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// OrderShipped 已发货订单
|
||||
// 对应MongoDB集合:orders_shipped
|
||||
// 发货后订单进入此状态
|
||||
|
||||
type OrderShipped struct {
|
||||
OrderBase // 基础订单信息
|
||||
PayMethod string `bson:"pay_method" json:"pay_method"` // 支付方式:wechat/alipay
|
||||
OrderItems []OrderItem `bson:"order_items" json:"order_items"` // 订单商品列表
|
||||
ShippingInfo *ShippingInfo `bson:"shipping_info,omitempty" json:"shipping_info"` // 收货信息
|
||||
|
||||
// 支付成功信息
|
||||
PaidAt time.Time `bson:"paid_at" json:"paid_at"` // 支付时间
|
||||
TransactionID string `bson:"transaction_id" json:"transaction_id"` // 支付平台交易号
|
||||
TradeNo string `bson:"trade_no" json:"trade_no"` // 交易号
|
||||
PaymentChannel string `bson:"payment_channel" json:"payment_channel"` // 支付渠道:wechat/alipay
|
||||
|
||||
// 发货特有字段
|
||||
ShippedAt time.Time `bson:"shipped_at" json:"shipped_at"` // 发货时间
|
||||
ExpressCompany string `bson:"express_company" json:"express_company"` // 快递公司
|
||||
ExpressNo string `bson:"express_no" json:"express_no"` // 快递单号
|
||||
ShippingCost int64 `bson:"shipping_cost" json:"shipping_cost"` // 运费(分)
|
||||
|
||||
// 收货相关字段
|
||||
ExpectedArrival time.Time `bson:"expected_arrival,omitempty" json:"expected_arrival"` // 预计到达时间
|
||||
}
|
||||
48
model/entity/order_status.go
Normal file
48
model/entity/order_status.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package entity
|
||||
|
||||
// OrderStatus 订单状态枚举
|
||||
// 用于标识订单当前所处的状态
|
||||
// 每个状态对应一个独立的MongoDB集合
|
||||
|
||||
type OrderStatus string
|
||||
|
||||
const (
|
||||
OrderStatusPending OrderStatus = "pending" // 待支付 - orders_pending
|
||||
OrderStatusPaid OrderStatus = "paid" // 已支付 - orders_paid
|
||||
OrderStatusShipped OrderStatus = "shipped" // 已发货 - orders_shipped
|
||||
OrderStatusCompleted OrderStatus = "completed" // 已完成 - orders_completed
|
||||
OrderStatusCancelled OrderStatus = "cancelled" // 已取消 - orders_cancelled
|
||||
OrderStatusRefunded OrderStatus = "refunded" // 已退款 - orders_refunded
|
||||
)
|
||||
|
||||
// PayStatus 支付状态枚举
|
||||
// 用于标识订单的支付状态
|
||||
|
||||
type PayStatus string
|
||||
|
||||
const (
|
||||
PayStatusUnpaid PayStatus = "unpaid" // 未支付
|
||||
PayStatusPaid PayStatus = "paid" // 已支付
|
||||
PayStatusFailed PayStatus = "failed" // 支付失败
|
||||
PayStatusRefunded PayStatus = "refunded" // 已退款
|
||||
)
|
||||
|
||||
// PayMethod 支付方式枚举
|
||||
|
||||
type PayMethod string
|
||||
|
||||
const (
|
||||
PayMethodWechat PayMethod = "wechat" // 微信支付
|
||||
PayMethodAlipay PayMethod = "alipay" // 支付宝支付
|
||||
)
|
||||
|
||||
// PayType 支付类型枚举
|
||||
|
||||
type PayType string
|
||||
|
||||
const (
|
||||
PayTypeNative PayType = "native" // 扫码支付
|
||||
PayTypeJSAPI PayType = "jsapi" // JSAPI支付
|
||||
PayTypeAPP PayType = "app" // APP支付
|
||||
PayTypeH5 PayType = "h5" // H5支付
|
||||
)
|
||||
82
model/entity/payment_config.go
Normal file
82
model/entity/payment_config.go
Normal file
@@ -0,0 +1,82 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
// PaymentConfig 支付配置
|
||||
// 每个租户有独立的支付配置
|
||||
// 支持微信支付和支付宝支付
|
||||
|
||||
type PaymentConfig struct {
|
||||
ID primitive.ObjectID `bson:"_id,omitempty" json:"id"`
|
||||
TenantID string `bson:"tenant_id" json:"tenant_id"` // 租户ID
|
||||
PayMethod string `bson:"pay_method" json:"pay_method"` // 支付方式:wechat/alipay
|
||||
ConfigName string `bson:"config_name" json:"config_name"` // 配置名称
|
||||
Description string `bson:"description" json:"description"` // 配置描述
|
||||
Enabled bool `bson:"enabled" json:"enabled"` // 是否启用
|
||||
|
||||
// 通用配置
|
||||
AppID string `bson:"app_id" json:"app_id"` // 应用ID
|
||||
MchID string `bson:"mch_id" json:"mch_id"` // 商户号
|
||||
APIKey string `bson:"api_key" json:"api_key"` // API密钥
|
||||
NotifyURL string `bson:"notify_url" json:"notify_url"` // 回调地址
|
||||
ReturnURL string `bson:"return_url" json:"return_url"` // 返回地址
|
||||
|
||||
// 证书配置(微信支付)
|
||||
CertPath string `bson:"cert_path,omitempty" json:"cert_path"` // 证书路径
|
||||
KeyPath string `bson:"key_path,omitempty" json:"key_path"` // 密钥路径
|
||||
|
||||
// 支付宝特有配置
|
||||
AppPrivateKey string `bson:"app_private_key,omitempty" json:"app_private_key"` // 应用私钥
|
||||
AlipayPublicKey string `bson:"alipay_public_key,omitempty" json:"alipay_public_key"` // 支付宝公钥
|
||||
|
||||
// 环境配置
|
||||
Sandbox bool `bson:"sandbox" json:"sandbox"` // 是否沙箱环境
|
||||
GatewayURL string `bson:"gateway_url" json:"gateway_url"` // 网关地址
|
||||
|
||||
// 支持的支付类型
|
||||
SupportNative bool `bson:"support_native" json:"support_native"` // 支持扫码支付
|
||||
SupportJSAPI bool `bson:"support_jsapi" json:"support_jsapi"` // 支持JSAPI支付
|
||||
SupportAPP bool `bson:"support_app" json:"support_app"` // 支持APP支付
|
||||
SupportH5 bool `bson:"support_h5" json:"support_h5"` // 支持H5支付
|
||||
}
|
||||
|
||||
// PaymentRecord 支付记录
|
||||
// 记录每次支付操作的结果
|
||||
|
||||
type PaymentRecord struct {
|
||||
ID primitive.ObjectID `bson:"_id,omitempty" json:"id"`
|
||||
TenantID string `bson:"tenant_id" json:"tenant_id"` // 租户ID
|
||||
OrderID primitive.ObjectID `bson:"order_id" json:"order_id"` // 订单ID
|
||||
OrderNo string `bson:"order_no" json:"order_no"` // 订单号
|
||||
PayMethod string `bson:"pay_method" json:"pay_method"` // 支付方式
|
||||
PayType string `bson:"pay_type" json:"pay_type"` // 支付类型
|
||||
Amount int64 `bson:"amount" json:"amount"` // 支付金额(分)
|
||||
TransactionID string `bson:"transaction_id" json:"transaction_id"` // 支付平台交易号
|
||||
OutTradeNo string `bson:"out_trade_no" json:"out_trade_no"` // 商户订单号
|
||||
TradeNo string `bson:"trade_no" json:"trade_no"` // 交易号
|
||||
PrepayID string `bson:"prepay_id,omitempty" json:"prepay_id"` // 预支付ID
|
||||
Status string `bson:"status" json:"status"` // 支付状态:success/failed
|
||||
ErrorMsg string `bson:"error_msg,omitempty" json:"error_msg"` // 错误信息
|
||||
CreatedAt int64 `bson:"created_at" json:"created_at"` // 创建时间
|
||||
UpdatedAt int64 `bson:"updated_at" json:"updated_at"` // 更新时间
|
||||
}
|
||||
|
||||
// RefundRecord 退款记录
|
||||
// 记录每次退款操作的结果
|
||||
|
||||
type RefundRecord struct {
|
||||
ID primitive.ObjectID `bson:"_id,omitempty" json:"id"`
|
||||
TenantID string `bson:"tenant_id" json:"tenant_id"` // 租户ID
|
||||
OrderID primitive.ObjectID `bson:"order_id" json:"order_id"` // 订单ID
|
||||
OrderNo string `bson:"order_no" json:"order_no"` // 订单号
|
||||
RefundNo string `bson:"refund_no" json:"refund_no"` // 退款单号
|
||||
RefundID string `bson:"refund_id" json:"refund_id"` // 退款ID
|
||||
RefundAmount int64 `bson:"refund_amount" json:"refund_amount"` // 退款金额(分)
|
||||
Reason string `bson:"reason" json:"reason"` // 退款原因
|
||||
Status string `bson:"status" json:"status"` // 退款状态:success/failed
|
||||
ErrorMsg string `bson:"error_msg,omitempty" json:"error_msg"` // 错误信息
|
||||
CreatedAt int64 `bson:"created_at" json:"created_at"` // 创建时间
|
||||
UpdatedAt int64 `bson:"updated_at" json:"updated_at"` // 更新时间
|
||||
}
|
||||
Reference in New Issue
Block a user