初始化项目
This commit is contained in:
@@ -204,3 +204,120 @@ type OrderSummary struct {
|
||||
CreatedAt time.Time `json:"created_at"` // 创建时间
|
||||
PaidAt *time.Time `json:"paid_at"` // 支付时间
|
||||
}
|
||||
|
||||
// PaymentNotifyReq 支付回调请求
|
||||
|
||||
type PaymentNotifyReq struct {
|
||||
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 {
|
||||
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"` // 是否成功
|
||||
}
|
||||
|
||||
// CreatePaymentConfigReq 创建支付配置请求
|
||||
|
||||
type CreatePaymentConfigReq struct {
|
||||
TenantID string `json:"tenant_id" binding:"required"` // 租户ID
|
||||
PayMethod string `json:"pay_method" binding:"required"` // 支付方式:wechat/alipay
|
||||
ConfigName string `json:"config_name" binding:"required"` // 配置名称
|
||||
Remark string `json:"remark"` // 备注
|
||||
IsEnabled bool `json:"is_enabled"` // 是否启用
|
||||
Config map[string]interface{} `json:"config" binding:"required"` // 配置参数
|
||||
}
|
||||
|
||||
// UpdatePaymentConfigReq 更新支付配置请求
|
||||
|
||||
type UpdatePaymentConfigReq struct {
|
||||
ID string `json:"id" binding:"required"` // 配置ID
|
||||
TenantID string `json:"tenant_id" binding:"required"` // 租户ID
|
||||
ConfigName string `json:"config_name" binding:"required"` // 配置名称
|
||||
Remark string `json:"remark"` // 备注
|
||||
IsEnabled bool `json:"is_enabled"` // 是否启用
|
||||
Config map[string]interface{} `json:"config" binding:"required"` // 配置参数
|
||||
}
|
||||
|
||||
// QueryPaymentConfigReq 查询支付配置请求
|
||||
|
||||
type QueryPaymentConfigReq struct {
|
||||
TenantID string `json:"tenant_id" binding:"required"` // 租户ID
|
||||
PayMethod string `json:"pay_method"` // 支付方式(可选)
|
||||
}
|
||||
|
||||
// PaymentConfigResp 支付配置响应
|
||||
|
||||
type PaymentConfigResp struct {
|
||||
ID string `json:"id"` // 配置ID
|
||||
TenantID string `json:"tenant_id"` // 租户ID
|
||||
PayMethod string `json:"pay_method"` // 支付方式
|
||||
ConfigName string `json:"config_name"` // 配置名称
|
||||
Remark string `json:"remark"` // 备注
|
||||
IsEnabled bool `json:"is_enabled"` // 是否启用
|
||||
Config map[string]interface{} `json:"config"` // 配置参数
|
||||
CreatedAt time.Time `json:"created_at"` // 创建时间
|
||||
UpdatedAt time.Time `json:"updated_at"` // 更新时间
|
||||
}
|
||||
|
||||
// WechatConfig 微信支付配置
|
||||
|
||||
type WechatConfig struct {
|
||||
ID string `json:"id"` // 配置ID
|
||||
TenantID string `json:"tenant_id"` // 租户ID
|
||||
ConfigName string `json:"config_name"` // 配置名称
|
||||
AppID string `json:"app_id"` // 应用ID
|
||||
MchID string `json:"mch_id"` // 商户号
|
||||
APIKey string `json:"api_key"` // API密钥
|
||||
NotifyURL string `json:"notify_url"` // 回调地址
|
||||
ReturnURL string `json:"return_url"` // 返回地址
|
||||
CertPath string `json:"cert_path"` // 证书路径
|
||||
KeyPath string `json:"key_path"` // 密钥路径
|
||||
Sandbox bool `json:"sandbox"` // 是否沙箱环境
|
||||
SupportNative bool `json:"support_native"` // 支持扫码支付
|
||||
SupportJSAPI bool `json:"support_jsapi"` // 支持JSAPI支付
|
||||
SupportAPP bool `json:"support_app"` // 支持APP支付
|
||||
SupportH5 bool `json:"support_h5"` // 支持H5支付
|
||||
GatewayURL string `json:"gateway_url"` // 网关地址
|
||||
}
|
||||
|
||||
// AlipayConfig 支付宝支付配置
|
||||
|
||||
type AlipayConfig struct {
|
||||
ID string `json:"id"` // 配置ID
|
||||
TenantID string `json:"tenant_id"` // 租户ID
|
||||
ConfigName string `json:"config_name"` // 配置名称
|
||||
AppID string `json:"app_id"` // 应用ID
|
||||
NotifyURL string `json:"notify_url"` // 回调地址
|
||||
ReturnURL string `json:"return_url"` // 返回地址
|
||||
AppPrivateKey string `json:"app_private_key"` // 应用私钥
|
||||
AlipayPublicKey string `json:"alipay_public_key"` // 支付宝公钥
|
||||
Sandbox bool `json:"sandbox"` // 是否沙箱环境
|
||||
GatewayURL string `json:"gateway_url"` // 网关地址
|
||||
SupportNative bool `json:"support_native"` // 支持扫码支付
|
||||
SupportJSAPI bool `json:"support_jsapi"` // 支持JSAPI支付
|
||||
SupportAPP bool `json:"support_app"` // 支持APP支付
|
||||
SupportH5 bool `json:"support_h5"` // 支持H5支付
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/v2/bson"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -12,18 +12,18 @@ import (
|
||||
// 例如: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"` // 过期时间
|
||||
ID bson.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 订单商品项
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// OrderPending 待支付订单
|
||||
// 对应MongoDB集合:orders_pending
|
||||
// 订单创建后进入此状态
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
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支付
|
||||
)
|
||||
@@ -1,7 +1,7 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/v2/bson"
|
||||
)
|
||||
|
||||
// PaymentConfig 支付配置
|
||||
@@ -9,12 +9,12 @@ import (
|
||||
// 支持微信支付和支付宝支付
|
||||
|
||||
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"` // 是否启用
|
||||
ID bson.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
|
||||
@@ -46,37 +46,37 @@ type PaymentConfig struct {
|
||||
// 记录每次支付操作的结果
|
||||
|
||||
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"` // 更新时间
|
||||
ID bson.ObjectID `bson:"_id,omitempty" json:"id"`
|
||||
TenantID string `bson:"tenant_id" json:"tenant_id"` // 租户ID
|
||||
OrderID bson.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"` // 更新时间
|
||||
ID bson.ObjectID `bson:"_id,omitempty" json:"id"`
|
||||
TenantID string `bson:"tenant_id" json:"tenant_id"` // 租户ID
|
||||
OrderID bson.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