- handle weimob createOrder and orderStatusChange correctly
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package weimobapi
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
@@ -25,7 +26,7 @@ const (
|
||||
type CallbackMsg struct {
|
||||
ID string `json:"id"`
|
||||
MsgEvent string `json:"msgEvent"`
|
||||
PublicAccountID int64 `json:"public_account_id"`
|
||||
PublicAccountID string `json:"public_account_id"`
|
||||
OrderNo int64 `json:"orderNo"`
|
||||
StatusTime time.Time `json:"statusTime"`
|
||||
ChannelType int `json:"channelType"`
|
||||
@@ -63,21 +64,25 @@ func Err2CallbackResponse(err error, data string) *CallbackResponse {
|
||||
}
|
||||
|
||||
func (a *API) GetCallbackMsg(body []byte) (msg *CallbackMsg, callbackResponse *CallbackResponse) {
|
||||
var mapMsg map[string]interface{}
|
||||
var (
|
||||
mapMsg, msgBody map[string]interface{}
|
||||
)
|
||||
err := utils.UnmarshalUseNumber(body, &mapMsg)
|
||||
if err != nil {
|
||||
return nil, Err2CallbackResponse(err, "")
|
||||
}
|
||||
msgBody := mapMsg["msg_body"].(map[string]interface{})
|
||||
err = utils.UnmarshalUseNumber([]byte(mapMsg["msg_body"].(string)), &msgBody)
|
||||
if err != nil {
|
||||
return nil, Err2CallbackResponse(err, "")
|
||||
}
|
||||
msg = &CallbackMsg{
|
||||
ID: utils.Interface2String(mapMsg["id"]),
|
||||
MsgEvent: utils.Interface2String(mapMsg["event"]),
|
||||
PublicAccountID: utils.MustInterface2Int64(mapMsg["public_account_id"]),
|
||||
PublicAccountID: utils.Interface2String(mapMsg["public_account_id"]),
|
||||
OrderNo: utils.MustInterface2Int64(msgBody["orderNo"]),
|
||||
}
|
||||
|
||||
if msg.MsgEvent == MsgEventCreateOrder {
|
||||
// msg.StatusTime = msgBody["createTime"]
|
||||
msg.StatusTime = utils.Str2Time(strings.Replace(msgBody["createTime"].(string), ": ", ":", -1))
|
||||
msg.ChannelType = int(utils.MustInterface2Int64(msgBody["channelType"]))
|
||||
} else {
|
||||
msg.StatusTime = time.Now()
|
||||
|
||||
Reference in New Issue
Block a user