From 2e6458e20a7903bd50ba788e58b1275f3faa35da Mon Sep 17 00:00:00 2001 From: gazebo Date: Fri, 25 Jan 2019 16:49:46 +0800 Subject: [PATCH] - order right event added for weimob --- platformapi/weimobapi/callback.go | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/platformapi/weimobapi/callback.go b/platformapi/weimobapi/callback.go index 155ad9fd..7070c359 100644 --- a/platformapi/weimobapi/callback.go +++ b/platformapi/weimobapi/callback.go @@ -9,9 +9,18 @@ import ( "git.rosy.net.cn/baseapi/utils" ) +const ( + MsgTopicOrder = "ec_order" + MsgTopicRights = "ec_rights" +) + const ( MsgEventCreateOrder = "createOrder" MsgEventOrderStatusChange = "orderStatusChange" + + MsgEventCreateRights = "createRights" + MsgEventCompleteRights = "completeRights" + MsgEventCancelRights = "cancelRights" ) const ( @@ -28,10 +37,13 @@ const ( type CallbackMsg struct { IsFake bool `json:"isFake"` // 是否自己生成的假消息 ID string `json:"id"` - MsgEvent string `json:"msgEvent"` + Topic string `json:"topic"` + Event string `json:"event"` PublicAccountID string `json:"public_account_id"` BusinessID string `json:"business_id"` + StoreID int64 `json:"storeId"` + RightsID int64 `json:"rightsId"` OrderNo int64 `json:"orderNo"` StatusTime time.Time `json:"statusTime"` ChannelType int `json:"channelType"` @@ -94,7 +106,8 @@ func (a *API) GetCallbackMsg(body []byte) (msg *CallbackMsg, callbackResponse *C } msg = &CallbackMsg{ ID: utils.Interface2String(mapMsg["id"]), - MsgEvent: utils.Interface2String(mapMsg["event"]), + Topic: utils.Interface2String(mapMsg["topic"]), + Event: utils.Interface2String(mapMsg["event"]), PublicAccountID: utils.Interface2String(mapMsg["public_account_id"]), BusinessID: utils.Interface2String(mapMsg["business_id"]), OrderNo: utils.MustInterface2Int64(msgBody["orderNo"]), @@ -104,11 +117,15 @@ func (a *API) GetCallbackMsg(body []byte) (msg *CallbackMsg, callbackResponse *C if !a.CheckCallbackValidation(sign, msgSignature, msg.ID, msgBodyStr) { return nil, Err2CallbackResponse(fmt.Errorf("sign is not match"), "") } - if msg.MsgEvent == MsgEventCreateOrder { + if msg.Event == MsgEventCreateOrder { msg.StatusTime = utils.Str2Time(strings.Replace(msgBody["createTime"].(string), ": ", ":", -1)) msg.ChannelType = int(utils.MustInterface2Int64(msgBody["channelType"])) } else { msg.StatusTime = time.Now() + if msg.Topic == MsgTopicRights { + msg.RightsID = utils.MustInterface2Int64(msgBody["rightsId"]) + msg.StoreID = utils.MustInterface2Int64(msgBody["storeId"]) + } } return msg, nil }