- order right event added for weimob
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user