1
This commit is contained in:
@@ -1,8 +1,17 @@
|
||||
package mtwmapi
|
||||
|
||||
import "net/url"
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
const (
|
||||
ImStatusOpen = 1 //单聊状态开启
|
||||
ImStatusClose = 0 //关闭
|
||||
|
||||
OnlineStatusBusy = 1 //忙碌
|
||||
OnlineStatusOnline = 0 //在线
|
||||
|
||||
MsgSourceStore = 1 //商家
|
||||
MsgSourceUser = 2 //用户
|
||||
MsgTypeText = 1 //文字
|
||||
@@ -12,27 +21,6 @@ const (
|
||||
MsgTypeOrderCard = 5 //订单卡片
|
||||
)
|
||||
|
||||
// SingleChat 单聊信息体
|
||||
type SingleChat struct {
|
||||
AppID int `json:"app_id"` //应用标识
|
||||
AppPoiCode string `json:"app_poi_code"` //门店标识
|
||||
Cts int `json:"cts"` //消息发送时间,10位时间戳
|
||||
MsgContent string `json:"msg_content"` //消息内容
|
||||
MsgID int `json:"msg_id"` //消息id,确保消息唯一性,发送消息时,为三方的消息id,接收消息时,为美团的消息id
|
||||
MsgSource int `json:"msg_source"` //消息发送方 商家:1,用户:2
|
||||
MsgType int `json:"msg_type"` //消息类型: 文字-1; 图片-2;语音-3,注意b2c不支持语音; 商品卡片-4(发送商品卡片类型则不关注msg_content); 订单卡片-5(订单卡片类型商家只能接收消息,不支持给用户发送消息,只支持单聊)
|
||||
OpenUserID int `json:"open_user_id"` //用户id
|
||||
OrderID int `json:"order_id"` // 订单id
|
||||
AppSpuCodes string `json:"app_spu_codes"` //开放平台侧商品标识(无须加密)
|
||||
}
|
||||
|
||||
// GetConnTokenResp 获取长链接token返回参数
|
||||
type GetConnTokenResp struct {
|
||||
ConnectionToken string `json:"connectionToken"` //建立长连接的token
|
||||
UserCount int `json:"userCount"` //30分钟内,消息发送失败的用户数
|
||||
AppKey string `json:"appKey"` //建立长连接的appkey
|
||||
}
|
||||
|
||||
// ImCallbackMsg im消息回调参数
|
||||
type ImCallbackMsg struct {
|
||||
Timestamp int `json:"timestamp"` //调用接口时的时间戳,即当前时间戳(当前距离Epoch(1970年1月1日) 以秒计算的时间,即unix - timestamp),注意传输时间戳与当前北京时间前后相差不能超过10分钟
|
||||
@@ -59,14 +47,10 @@ type PushContentReq struct {
|
||||
AppSpuCodes string `json:"app_spu_codes"` //开放平台侧商品标识(无须加密)
|
||||
}
|
||||
|
||||
type PushContentResp struct {
|
||||
ResultCode int `json:"result_code"` //1-全部操作成功,查询到的数据在data字段中;2-部分成功,成功的数据存储在data字段中,失败的数据存在error_list字段中;3-全部操作失败,失败的数据存在error_list字段中;4-请求失败,一般为签名或限流问题,关注error字段中的具体描述即可
|
||||
ErrorList []ErrorList `json:"error_list"` //返回失败原因,根据失败原因判断是否重发消息
|
||||
}
|
||||
|
||||
type ErrorList struct {
|
||||
Code int `json:"code"` //错误码
|
||||
Msg string `json:"msg"` //错误描述
|
||||
type GetPoiIMStatusResp struct {
|
||||
AppPoiCode string `json:"app_poi_code"`
|
||||
AppID int `json:"app_id"`
|
||||
ImStatus int `json:"im_status"`
|
||||
}
|
||||
|
||||
// MsgSend 商家发送IM消息 https://open-shangou.meituan.com/home/docDetail/10087
|
||||
@@ -78,11 +62,32 @@ func (a *API) MsgSend(pushContent string) (interface{}, error) {
|
||||
return retVal, err
|
||||
}
|
||||
|
||||
// GetConnectionToken 获取长连接的token https://developer.waimai.meituan.com/home/docDetail/461
|
||||
//func (a *API) GetConnectionToken() (retVal interface{}, err error) {
|
||||
// retVal, err = a.AccessAPI("wm/IM/getConnectionToken", false, nil)
|
||||
// return retVal, err
|
||||
//}
|
||||
// SetPoiIMStatus 设置门店IM线上状态 0-关闭 1-开启
|
||||
func (a *API) SetPoiIMStatus(appPoiCode string, imStatus int) error {
|
||||
_, err := a.AccessAPI("wm/IM/setPoiIMStatus", false, map[string]interface{}{
|
||||
"app_poi_code": appPoiCode,
|
||||
"online_status": imStatus,
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
// SetPoiIMOnlineStatus 设置门店IM线上状态 0-在线或1-忙碌
|
||||
func (a *API) SetPoiIMOnlineStatus(appPoiCode string, onlineStatus int) error {
|
||||
_, err := a.AccessAPI("wm/IM/setPoiIMOnlineStatus", false, map[string]interface{}{
|
||||
"app_poi_code": appPoiCode,
|
||||
"online_status": onlineStatus,
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
// GetPoiIMStatus 查询门店IM单聊开关状态
|
||||
func (a *API) GetPoiIMStatus(appPoiCode string) (retVal GetPoiIMStatusResp, err error) {
|
||||
resp, err := a.AccessAPI("wm/IM/getPoiIMStatus", false, map[string]interface{}{
|
||||
"app_poi_code": appPoiCode,
|
||||
})
|
||||
utils.Map2StructByJson(resp, &retVal, false)
|
||||
return retVal, err
|
||||
}
|
||||
|
||||
// MsgRead 设置消息已读 https://open-shangou.meituan.com/home/docDetail/465
|
||||
//func (a *API) MsgRead(appPoiCode string, msgID, openUserID int) error {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -375,22 +375,24 @@ func TestRetailSellStatus2(t *testing.T) {
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
//根据分类id查询属性列表
|
||||
func TestCategoryAttrList(t *testing.T) {
|
||||
//result, err := api.CategoryAttrList(200002680)
|
||||
result, err := api.CategoryAttrList(200005621)
|
||||
result, err := api.CategoryAttrList(200002685)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
//func TestCategoryAttrValueList(t *testing.T) {
|
||||
// result, err := api.CategoryAttrValueList(1200000088, "苹果", 1, 5)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// t.Log(utils.Format4Output(result, false))
|
||||
//}
|
||||
//特殊属性查询
|
||||
func TestCategoryAttrValueList(t *testing.T) {
|
||||
result, err := api.CategoryAttrValueList(1200000094, "青团")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestRetailRecommendTag(t *testing.T) {
|
||||
result, err := api.RetailRecommendTag("飞利浦电吹风", "", 0, 1)
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -15,8 +14,6 @@ func (a *API) PreCreateOrder(preOrder *PreCreateOrderReq) (price float64, err er
|
||||
preOrder.PushTime = time.Now().Unix()
|
||||
preOrder.DevId = a.devId
|
||||
resp := a.HttpPostJson("precreateorder", preOrder)
|
||||
globals.SugarLogger.Debugf("sfps PreCreateOrder:preOrder=%s", utils.Format4Output(preOrder, false))
|
||||
globals.SugarLogger.Debugf("sfps PreCreateOrder:resp=%s", utils.Format4Output(resp, false))
|
||||
if resp.HttpStatusCode != HttpStatusSuccessCode {
|
||||
return 0, errors.New("HTTP请求错误,请检查重试")
|
||||
}
|
||||
@@ -41,9 +38,7 @@ func (a *API) CreateOrder(order *CreateOrderReq) (sfOrderID, sfBillID string, to
|
||||
order.PushTime = time.Now().Unix()
|
||||
order.Version = DefaultVersion
|
||||
order.DevId = a.devId
|
||||
globals.SugarLogger.Debugf("sfps CreateOrder req=%s", utils.Format4Output(order, false))
|
||||
resp := a.HttpPostJson("createorder", order)
|
||||
globals.SugarLogger.Debugf("sfps CreateOrder:resp=%s", utils.Format4Output(resp, false))
|
||||
if resp.HttpStatusCode != HttpStatusSuccessCode {
|
||||
return "", "", 0, 0, errors.New("HTTP请求错误,请检查重试")
|
||||
}
|
||||
@@ -53,7 +48,6 @@ func (a *API) CreateOrder(order *CreateOrderReq) (sfOrderID, sfBillID string, to
|
||||
retVal := CreateOrderResp{}
|
||||
s, _ := json.Marshal(resp.BaseRetVal.Result)
|
||||
if err = json.Unmarshal(s, &retVal); err == nil {
|
||||
globals.SugarLogger.Debugf("CreateOrder resp=%s", utils.Format4Output(retVal, false))
|
||||
return retVal.SFOrderID, retVal.SFBillID, retVal.TotalPrice, retVal.RealPayMoney, nil
|
||||
} else {
|
||||
return "", "", 0, 0, err
|
||||
@@ -68,8 +62,6 @@ func (a *API) PreCancelOrder(sfOrderID string) (deductionFee float64, err error)
|
||||
PushTime: time.Now().Unix(),
|
||||
}
|
||||
resp := a.HttpPostJson("precancelorder", param)
|
||||
globals.SugarLogger.Debugf("sfps precancelorder:param=%s", utils.Format4Output(param, false))
|
||||
globals.SugarLogger.Debugf("sfps precancelorder:resp=%s", utils.Format4Output(resp, false))
|
||||
if resp.HttpStatusCode != HttpStatusSuccessCode {
|
||||
return 0, errors.New("HTTP请求错误,请检查重试")
|
||||
}
|
||||
@@ -79,7 +71,6 @@ func (a *API) PreCancelOrder(sfOrderID string) (deductionFee float64, err error)
|
||||
retVal := PreCancelOrderResp{}
|
||||
s, _ := json.Marshal(resp.BaseRetVal.Result)
|
||||
if err = json.Unmarshal(s, &retVal); err == nil {
|
||||
globals.SugarLogger.Debugf("PreCancelOrder resp=%s", utils.Format4Output(retVal, false))
|
||||
return retVal.DeductionFee, nil
|
||||
} else {
|
||||
return 0, err
|
||||
@@ -122,7 +113,6 @@ func (a *API) GetOrderStatus(sfOrderID string) (retVal *GetOrderStatusResp, err
|
||||
s, _ := json.Marshal(resp.BaseRetVal.Result)
|
||||
if err = json.Unmarshal(s, &retVal); err == nil {
|
||||
retVal.TotalPrice += utils.Int2Float64(utils.WayBillDeliveryMarkUp)
|
||||
globals.SugarLogger.Debugf("GetOrderStatus resp=%s", utils.Format4Output(retVal, false))
|
||||
return retVal, nil
|
||||
} else {
|
||||
return nil, err
|
||||
@@ -146,7 +136,6 @@ func (a *API) GetRiderLatestPosition(sfOrderID string) (retVal *RiderLatestPosit
|
||||
}
|
||||
s, _ := json.Marshal(resp.BaseRetVal.Result)
|
||||
if err = json.Unmarshal(s, &retVal); err == nil {
|
||||
globals.SugarLogger.Debugf("GetRiderLatestPosition resp=%s", utils.Format4Output(retVal, false))
|
||||
return retVal, nil
|
||||
} else {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user