<feat>订单回调

This commit is contained in:
Rzy 2024-08-07 11:12:06 +08:00
parent c8a188e362
commit 0834171ea3
2 changed files with 14 additions and 6 deletions

View File

@ -61,3 +61,10 @@ var OrderTypeList = map[int]string{
ORDER_TYPE_PAY: "付款",
ORDER_TYPE_REFUND: "退款",
}
var OrderStatusMap = map[int]string{
ORDER_STATUS_WAITPAY: "等待执行",
ORDER_STATUS_PAYING: "执行中",
ORDER_STATUS_PAYED: "执行成功",
ORDER_STATUS_FAILED: "执行失败",
ORDER_STATUS_CLOSE: "订单关闭",
}

View File

@ -37,6 +37,7 @@ type OrderNotifySendContent struct {
OrderId int64 `json:"order_id"`
OutTreadNo string `json:"out_tread_no"`
CompleteTime time.Time `json:"complete_time"`
OrderType int `json:"order-type"`
Status int `json:"status"`
Msg string `json:"msg"`
ErrCode int `json:"err_code"`
@ -85,7 +86,7 @@ func (o *OrderNotify) handle() (res *OrderNotifyResp) {
return &OrderNotifyResp{
OrderId: o.OrderId,
Send: true,
ErrCode: o.ErrCode,
ErrCode: o.code,
Content: o,
}
}
@ -109,8 +110,9 @@ func (o *OrderNotify) setBody() *OrderNotifySendContent {
OutTreadNo: o.order.OutTreadNo,
CompleteTime: o.CompleteTime,
Status: o.order.Status,
OrderType: o.order.OrderType,
Msg: o.Msg,
ErrCode: o.ErrCode,
ErrCode: o.Status,
AppId: o.order.AppId,
ChannelId: o.order.PayChannelId,
MerchantId: o.order.MerchantId,
@ -118,10 +120,9 @@ func (o *OrderNotify) setBody() *OrderNotifySendContent {
}
func (o *OrderNotify) updateOrder() {
if o.ErrCode != errorcode.Success {
o.order.Status = common.ORDER_STATUS_FAILED
} else {
o.order.Status = common.ORDER_STATUS_PAYED
if _, ok := common.OrderStatusMap[o.Status]; !ok {
o.code = errorcode.OrderStatusErr
return
}
o.code = services.OrderUpdate(o.order, "status")
return