dadadelivery notify
This commit is contained in:
58
platformapi/dadaapi/notify.go
Normal file
58
platformapi/dadaapi/notify.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package dadaapi
|
||||
|
||||
import "git.rosy.net.cn/baseapi/utils"
|
||||
|
||||
const (
|
||||
MessageTypeRidderCancel = 1
|
||||
)
|
||||
|
||||
type RidderCancelNotify struct {
|
||||
OrderID string `json:"orderId"`
|
||||
DadaOrderID int64 `json:"dadaOrderId"`
|
||||
CancelReason string `json:"cancelReason"`
|
||||
}
|
||||
|
||||
type RidderCancelConfirm struct {
|
||||
OrderID string `json:"orderId"`
|
||||
DadaOrderID int64 `json:"dadaOrderId"`
|
||||
IsConfirm int `json:"isConfirm"`
|
||||
}
|
||||
|
||||
type NotifyMsg struct {
|
||||
MessageType int `json:"messageType"`
|
||||
MessageBody string `json:"messageBody"`
|
||||
CreateTime int64 `json:"createTime"`
|
||||
|
||||
MessageObj *RidderCancelNotify `json:"messageObj"`
|
||||
}
|
||||
|
||||
type NotifyResponse struct {
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
var (
|
||||
SuccessNotifyResponse = &NotifyResponse{Status: "ok"}
|
||||
FailedNotifyResponse = &NotifyResponse{Status: "fail"}
|
||||
)
|
||||
|
||||
func (a *API) GetNotifyMsg(data []byte) (msg *NotifyMsg, notifyResponse *NotifyResponse) {
|
||||
err := utils.UnmarshalUseNumber(data, &msg)
|
||||
if err == nil {
|
||||
err = utils.UnmarshalUseNumber([]byte(msg.MessageBody), &msg.MessageObj)
|
||||
}
|
||||
if err != nil {
|
||||
notifyResponse = FailedNotifyResponse
|
||||
}
|
||||
return msg, notifyResponse
|
||||
}
|
||||
|
||||
// 消息确认
|
||||
// http://newopen.imdada.cn/#/development/file/merchantConfirm?_k=gqkja3
|
||||
func (a *API) ConfirmRidderCancel(orderID string, dadaOrderID int64, isConfirm bool) (err error) {
|
||||
_, err = a.AccessAPI("message/confirm", utils.Struct2FlatMap(&RidderCancelConfirm{
|
||||
OrderID: orderID,
|
||||
DadaOrderID: dadaOrderID,
|
||||
IsConfirm: utils.Bool2Int(isConfirm),
|
||||
}))
|
||||
return err
|
||||
}
|
||||
Reference in New Issue
Block a user