- 新增订单变更类型 OrderChangeTypeJDOrderFailed 用于记录下单失败事件 - 调整订单创建逻辑,支持失败订单重试机制 - 新增 RecordOrderHistoryReq 结构体统一记录订单变更历史参数 - 修改数据库表结构,优化字段类型和索引 - 更新订单创建逻辑,分离本地订单与京东订单创建流程- 增加失败订单重新创建京东订单的处理逻辑 - 调整订单状态检查逻辑,支持更多状态处理 -优化订单历史记录方式,增加备注信息支持 - 更新数据库字符集为 utf8mb4_unicode_ci 提升兼容性
108 lines
5.1 KiB
Go
108 lines
5.1 KiB
Go
package model
|
|
|
|
import "kami/internal/consts"
|
|
|
|
// ====================================================================================
|
|
// JD Cookie 相关模型结构体
|
|
// ====================================================================================
|
|
|
|
// CreateOrderReq 创建订单请求参数
|
|
type CreateOrderReq struct {
|
|
UserOrderId string `json:"userOrderId" dc:"用户订单号"`
|
|
Amount float64 `json:"amount" dc:"订单金额"`
|
|
Category consts.RedeemOrderCardCategory `json:"category" dc:"卡券类别"`
|
|
}
|
|
|
|
// CreateOrderResult 创建订单返回结果
|
|
type CreateOrderResult struct {
|
|
WxPayUrl string `json:"wxPayUrl" dc:"微信支付链接"`
|
|
JdOrderId string `json:"jdOrderId" dc:"京东订单号"`
|
|
OrderId string `json:"orderId" dc:"内部订单号"`
|
|
}
|
|
|
|
// PaymentResult 支付结果
|
|
type PaymentResult struct {
|
|
WxPayUrl string `json:"wxPayUrl" dc:"微信支付链接"`
|
|
JdOrderId string `json:"jdOrderId" dc:"京东订单号"`
|
|
OrderId string `json:"orderId" dc:"内部订单号"`
|
|
}
|
|
|
|
// CreateNewJdOrderWithRetryReq 创建新的京东订单请求参数
|
|
type CreateNewJdOrderWithRetryReq struct {
|
|
UserOrderId string `json:"userOrderId" dc:"用户订单号"`
|
|
OrderId string `json:"orderId" dc:"内部订单号"`
|
|
Amount float64 `json:"amount" dc:"订单金额"`
|
|
Category consts.RedeemOrderCardCategory `json:"category" dc:"卡券类别"`
|
|
}
|
|
|
|
// CreateNewJdOrderWithRetryRes 创建新的京东订单返回结果
|
|
type CreateNewJdOrderWithRetryRes struct {
|
|
JdOrderId string `json:"jdOrderId" dc:"京东订单号"`
|
|
CookieId string `json:"cookieId" dc:"Cookie ID"`
|
|
WxPayUrl string `json:"wxPayUrl" dc:"微信支付链接"`
|
|
}
|
|
|
|
// CreateJdOrderRecordReq 创建京东订单记录请求参数
|
|
type CreateJdOrderRecordReq struct {
|
|
JdOrderId string `json:"jdOrderId" dc:"内部订单号"`
|
|
RealJdOrderId string `json:"realJdOrderId" dc:"京东客户端返回的真实订单ID"`
|
|
PayId string `json:"payId" dc:"支付ID"`
|
|
CookieId string `json:"cookieId" dc:"使用的Cookie ID"`
|
|
Category consts.RedeemOrderCardCategory `json:"category" dc:"商品品类"`
|
|
Amount float64 `json:"amount" dc:"订单金额"`
|
|
WxPayUrl string `json:"wxPayUrl" dc:"微信支付链接"`
|
|
}
|
|
|
|
// CallJdCreateOrderReq 调用京东下单接口请求参数
|
|
type CallJdCreateOrderReq struct {
|
|
JdOrderId string `json:"jdOrderId" dc:"京东订单ID"`
|
|
Amount float64 `json:"amount" dc:"订单金额"`
|
|
CookieId string `json:"cookieId" dc:"Cookie ID"`
|
|
Category consts.RedeemOrderCardCategory `json:"category" dc:"商品品类"`
|
|
}
|
|
|
|
// CallJdCreateOrderRes 调用京东下单接口返回结果
|
|
type CallJdCreateOrderRes struct {
|
|
RealJdOrderId string `json:"realJdOrderId" dc:"京东客户端返回的真实订单ID"`
|
|
PayId string `json:"payId" dc:"支付ID"`
|
|
WxPayUrl string `json:"wxPayUrl" dc:"微信支付链接"`
|
|
Remark string `json:"remark" dc:"备注信息"`
|
|
IsStockError bool `json:"isStockError" dc:"库存是否失败"`
|
|
IsCkError bool `json:"isCkError" dc:"Cookie是否失败"`
|
|
}
|
|
|
|
// RefreshPaymentUrlReq 刷新支付链接请求参数
|
|
type RefreshPaymentUrlReq struct {
|
|
JdOrderId string `json:"jdOrderId" dc:"京东订单ID"`
|
|
PayId string `json:"payId" dc:"支付ID"`
|
|
CookieId string `json:"cookieId" dc:"Cookie ID"`
|
|
}
|
|
|
|
// CallJdCheckPaymentReq 调用京东检查支付状态请求参数
|
|
type CallJdCheckPaymentReq struct {
|
|
JdOrderId string `json:"jdOrderId" dc:"京东订单ID"`
|
|
RealJdOrderId string `json:"realJdOrderId" dc:"京东客户端返回的真实订单ID"`
|
|
CookieValue string `json:"cookieValue" dc:"Cookie值"`
|
|
Category consts.RedeemOrderCardCategory `json:"category" dc:"商品品类"`
|
|
}
|
|
|
|
// RecordCookieHistoryReq 记录Cookie变更历史请求参数
|
|
type RecordCookieHistoryReq struct {
|
|
CookieId string `json:"cookieId" dc:"Cookie ID"`
|
|
ChangeType consts.CookieChangeType `json:"changeType" dc:"变更类型"`
|
|
StatusBefore consts.JdCookieStatus `json:"statusBefore" dc:"变更前状态"`
|
|
StatusAfter consts.JdCookieStatus `json:"statusAfter" dc:"变更后状态"`
|
|
OrderId string `json:"orderId" dc:"关联的订单号"`
|
|
UserOrderId string `json:"userOrderId" dc:"用户订单号"`
|
|
FailureCount int `json:"failureCount" dc:"失败次数"`
|
|
Remark string `json:"remark" dc:"备注信息,存储额外的信息"`
|
|
}
|
|
|
|
// RecordOrderHistoryReq 记录订单变更历史请求参数
|
|
type RecordOrderHistoryReq struct {
|
|
OrderId string `json:"orderId" dc:"订单号"`
|
|
ChangeType consts.OrderChangeType `json:"changeType" dc:"变更类型"`
|
|
JdOrderId string `json:"jdOrderId" dc:"京东订单号"`
|
|
Remark string `json:"remark" dc:"备注信息"`
|
|
}
|