- order right event added for weimob
This commit is contained in:
@@ -9,9 +9,18 @@ import (
|
|||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
MsgTopicOrder = "ec_order"
|
||||||
|
MsgTopicRights = "ec_rights"
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
MsgEventCreateOrder = "createOrder"
|
MsgEventCreateOrder = "createOrder"
|
||||||
MsgEventOrderStatusChange = "orderStatusChange"
|
MsgEventOrderStatusChange = "orderStatusChange"
|
||||||
|
|
||||||
|
MsgEventCreateRights = "createRights"
|
||||||
|
MsgEventCompleteRights = "completeRights"
|
||||||
|
MsgEventCancelRights = "cancelRights"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -28,10 +37,13 @@ const (
|
|||||||
type CallbackMsg struct {
|
type CallbackMsg struct {
|
||||||
IsFake bool `json:"isFake"` // 是否自己生成的假消息
|
IsFake bool `json:"isFake"` // 是否自己生成的假消息
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
MsgEvent string `json:"msgEvent"`
|
Topic string `json:"topic"`
|
||||||
|
Event string `json:"event"`
|
||||||
PublicAccountID string `json:"public_account_id"`
|
PublicAccountID string `json:"public_account_id"`
|
||||||
BusinessID string `json:"business_id"`
|
BusinessID string `json:"business_id"`
|
||||||
|
|
||||||
|
StoreID int64 `json:"storeId"`
|
||||||
|
RightsID int64 `json:"rightsId"`
|
||||||
OrderNo int64 `json:"orderNo"`
|
OrderNo int64 `json:"orderNo"`
|
||||||
StatusTime time.Time `json:"statusTime"`
|
StatusTime time.Time `json:"statusTime"`
|
||||||
ChannelType int `json:"channelType"`
|
ChannelType int `json:"channelType"`
|
||||||
@@ -94,7 +106,8 @@ func (a *API) GetCallbackMsg(body []byte) (msg *CallbackMsg, callbackResponse *C
|
|||||||
}
|
}
|
||||||
msg = &CallbackMsg{
|
msg = &CallbackMsg{
|
||||||
ID: utils.Interface2String(mapMsg["id"]),
|
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"]),
|
PublicAccountID: utils.Interface2String(mapMsg["public_account_id"]),
|
||||||
BusinessID: utils.Interface2String(mapMsg["business_id"]),
|
BusinessID: utils.Interface2String(mapMsg["business_id"]),
|
||||||
OrderNo: utils.MustInterface2Int64(msgBody["orderNo"]),
|
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) {
|
if !a.CheckCallbackValidation(sign, msgSignature, msg.ID, msgBodyStr) {
|
||||||
return nil, Err2CallbackResponse(fmt.Errorf("sign is not match"), "")
|
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.StatusTime = utils.Str2Time(strings.Replace(msgBody["createTime"].(string), ": ", ":", -1))
|
||||||
msg.ChannelType = int(utils.MustInterface2Int64(msgBody["channelType"]))
|
msg.ChannelType = int(utils.MustInterface2Int64(msgBody["channelType"]))
|
||||||
} else {
|
} else {
|
||||||
msg.StatusTime = time.Now()
|
msg.StatusTime = time.Now()
|
||||||
|
if msg.Topic == MsgTopicRights {
|
||||||
|
msg.RightsID = utils.MustInterface2Int64(msgBody["rightsId"])
|
||||||
|
msg.StoreID = utils.MustInterface2Int64(msgBody["storeId"])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return msg, nil
|
return msg, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user