代码拉取完成,页面将自动刷新
package pmc
import (
"encoding/json"
"errors"
"fmt"
)
type CommandType string
const (
CommandType_COMMON CommandType = "Common"
CommandType_FAIL CommandType = "Fail"
)
type EventType string
const (
EventType_TradeModifiedEvent EventType = "pdd_ddjb_TradeModified"
)
// Command pmc record
type Command struct {
ID uint64 `json:"id,omitempty"`
CommandType CommandType `json:"commandType,omitempty"`
Time int64 `json:"time,omitempty"`
SendTime int64 `json:"sendTime,omitempty"`
Message Message `json:"message,omitempty"`
}
func (c Command) IsError() bool {
return c.CommandType == CommandType_FAIL
}
func (c Command) Error() string {
return c.Message.Content
}
func (c Command) Event() (Event, error) {
if c.IsError() {
return nil, c
}
switch c.Message.Type {
case EventType_TradeModifiedEvent:
var ev TradeModifiedEvent
if err := json.Unmarshal([]byte(c.Message.Content), &ev); err != nil {
fmt.Println(c.Message.Content)
return nil, err
}
return &ev, nil
}
return nil, errors.New("unknown event")
}
type Message struct {
// Type event type
Type EventType `json:"type,omitempty"`
// Content
Content string `json:"content,omitempty"`
}
// Event pmc event
type Event interface {
Type() EventType
}
// TradeModifiedEvent 多多进宝订单状态变更
type TradeModifiedEvent struct {
// Tid 订单号
Tid string `json:"tid,omitempty"`
// Status 订单状态:0-已支付;1-已成团;2-确认收货;3-审核成功;4-审核失败(不可提现);5-已经结算 ;10-已处罚
Status int `json:"status,omitempty"`
// Pid 推广位ID
Pid string `json:"pid,omitempty"`
// CustomParameters 代理身份自定义参数
CustomParameters string `json:"custom_parameters,omitempty"`
// ModifyTime 最后更新时间
ModifyTime int64 `json:"modify_time,omitempty"`
}
// Type implement Event interface
func (m TradeModifiedEvent) Type() EventType {
return EventType_TradeModifiedEvent
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。