<feat>订单回调
This commit is contained in:
		
							parent
							
								
									c8a188e362
								
							
						
					
					
						commit
						0834171ea3
					
				|  | @ -61,3 +61,10 @@ var OrderTypeList = map[int]string{ | ||||||
| 	ORDER_TYPE_PAY:    "付款", | 	ORDER_TYPE_PAY:    "付款", | ||||||
| 	ORDER_TYPE_REFUND: "退款", | 	ORDER_TYPE_REFUND: "退款", | ||||||
| } | } | ||||||
|  | var OrderStatusMap = map[int]string{ | ||||||
|  | 	ORDER_STATUS_WAITPAY: "等待执行", | ||||||
|  | 	ORDER_STATUS_PAYING:  "执行中", | ||||||
|  | 	ORDER_STATUS_PAYED:   "执行成功", | ||||||
|  | 	ORDER_STATUS_FAILED:  "执行失败", | ||||||
|  | 	ORDER_STATUS_CLOSE:   "订单关闭", | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -37,6 +37,7 @@ type OrderNotifySendContent struct { | ||||||
| 	OrderId      int64     `json:"order_id"` | 	OrderId      int64     `json:"order_id"` | ||||||
| 	OutTreadNo   string    `json:"out_tread_no"` | 	OutTreadNo   string    `json:"out_tread_no"` | ||||||
| 	CompleteTime time.Time `json:"complete_time"` | 	CompleteTime time.Time `json:"complete_time"` | ||||||
|  | 	OrderType    int       `json:"order-type"` | ||||||
| 	Status       int       `json:"status"` | 	Status       int       `json:"status"` | ||||||
| 	Msg          string    `json:"msg"` | 	Msg          string    `json:"msg"` | ||||||
| 	ErrCode      int       `json:"err_code"` | 	ErrCode      int       `json:"err_code"` | ||||||
|  | @ -85,7 +86,7 @@ func (o *OrderNotify) handle() (res *OrderNotifyResp) { | ||||||
| 	return &OrderNotifyResp{ | 	return &OrderNotifyResp{ | ||||||
| 		OrderId: o.OrderId, | 		OrderId: o.OrderId, | ||||||
| 		Send:    true, | 		Send:    true, | ||||||
| 		ErrCode: o.ErrCode, | 		ErrCode: o.code, | ||||||
| 		Content: o, | 		Content: o, | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  | @ -109,8 +110,9 @@ func (o *OrderNotify) setBody() *OrderNotifySendContent { | ||||||
| 		OutTreadNo:   o.order.OutTreadNo, | 		OutTreadNo:   o.order.OutTreadNo, | ||||||
| 		CompleteTime: o.CompleteTime, | 		CompleteTime: o.CompleteTime, | ||||||
| 		Status:       o.order.Status, | 		Status:       o.order.Status, | ||||||
|  | 		OrderType:    o.order.OrderType, | ||||||
| 		Msg:          o.Msg, | 		Msg:          o.Msg, | ||||||
| 		ErrCode:      o.ErrCode, | 		ErrCode:      o.Status, | ||||||
| 		AppId:        o.order.AppId, | 		AppId:        o.order.AppId, | ||||||
| 		ChannelId:    o.order.PayChannelId, | 		ChannelId:    o.order.PayChannelId, | ||||||
| 		MerchantId:   o.order.MerchantId, | 		MerchantId:   o.order.MerchantId, | ||||||
|  | @ -118,10 +120,9 @@ func (o *OrderNotify) setBody() *OrderNotifySendContent { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (o *OrderNotify) updateOrder() { | func (o *OrderNotify) updateOrder() { | ||||||
| 	if o.ErrCode != errorcode.Success { | 	if _, ok := common.OrderStatusMap[o.Status]; !ok { | ||||||
| 		o.order.Status = common.ORDER_STATUS_FAILED | 		o.code = errorcode.OrderStatusErr | ||||||
| 	} else { | 		return | ||||||
| 		o.order.Status = common.ORDER_STATUS_PAYED |  | ||||||
| 	} | 	} | ||||||
| 	o.code = services.OrderUpdate(o.order, "status") | 	o.code = services.OrderUpdate(o.order, "status") | ||||||
| 	return | 	return | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue