1
This commit is contained in:
@@ -27,14 +27,18 @@ func SendVendorV2(data SendData, vendorOrgCode string) (err error) {
|
||||
if data.VendorID == model.VendorIDMTWM {
|
||||
dataStr, _ := json.Marshal(data.Data)
|
||||
temp := string(dataStr)
|
||||
globals.SugarLogger.Debugf("SendVendorV2 temp=%s", temp)
|
||||
globals.SugarLogger.Debugf("SendVendorV2 mtwmtemp=%s", temp)
|
||||
if _, err = partner.CurAPIManager.GetAPI(model.VendorIDMTWM, vendorOrgCode).(*mtwmapi.API).MsgSend(string(dataStr)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
//if data.VendorID == model.VendorIDEBAI { //todo 后续添加
|
||||
// err = nil
|
||||
//}
|
||||
if data.VendorID == model.VendorIDEBAI {
|
||||
str, _ := json.Marshal(data.Data)
|
||||
param := &ebaiapi.BusinessSendMsgReq{}
|
||||
err = json.Unmarshal(str, ¶m)
|
||||
globals.SugarLogger.Debugf("SendVendorV2 ebaiparam=%s", utils.Format4Output(param, false))
|
||||
err = partner.CurAPIManager.GetAPI(model.VendorIDEBAI, vendorOrgCode).(*ebaiapi.API).BusinessSendMsg(param)
|
||||
}
|
||||
err = ReadMsgFromClient(data.VendorID, "", data.Data)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("SendVendorV2:%v", err)
|
||||
@@ -42,17 +46,76 @@ func SendVendorV2(data SendData, vendorOrgCode string) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
type GetPoiIMStatusReq struct {
|
||||
VendorID int `json:"vendorID"`
|
||||
VendorStoreID string `json:"vendorStoreID"`
|
||||
VendorOrgCode string `json:"vendorOrgCode"`
|
||||
}
|
||||
|
||||
type GetPoiIMStatusResp struct {
|
||||
VendorID int `json:"vendorID"`
|
||||
ImStatus int `json:"imStatus"`
|
||||
}
|
||||
|
||||
// GetPoiIMStatus 查询门店IM单聊开关状态
|
||||
//func GetPoiIMStatus(vendorID int, vendorStoreID, vendorOrgCode string) (retVal interface{}, err error) {
|
||||
// switch vendorID {
|
||||
// case model.VendorIDMTWM:
|
||||
// //retVal, err = mtwm.GetPoiIMStatus(vendorStoreID, vendorOrgCode)
|
||||
// retVal, err = api.MtwmAPI.GetPoiIMStatus(vendorStoreID, vendorOrgCode)
|
||||
// case model.VendorIDEBAI:
|
||||
// //retVal,err=
|
||||
// }
|
||||
// return nil, nil
|
||||
//}
|
||||
func GetPoiIMStatus(param []GetPoiIMStatusReq) (retVal []*GetPoiIMStatusResp, err error) {
|
||||
if len(param) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
for _, v := range param {
|
||||
switch v.VendorID {
|
||||
case model.VendorIDMTWM:
|
||||
temp, err := partner.CurAPIManager.GetAPI(model.VendorIDMTWM, v.VendorOrgCode).(*mtwmapi.API).GetPoiIMStatus(v.VendorStoreID)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
retVal = append(retVal, &GetPoiIMStatusResp{
|
||||
VendorID: model.VendorIDMTWM,
|
||||
ImStatus: temp.ImStatus,
|
||||
})
|
||||
case model.VendorIDEBAI:
|
||||
//status, err := api.EbaiAPI.GetStoreIMStatus(v.VendorStoreID)
|
||||
status, err := partner.CurAPIManager.GetAPI(model.VendorIDEBAI, v.VendorOrgCode).(*ebaiapi.API).GetStoreIMStatus(v.VendorStoreID)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
retVal = append(retVal, &GetPoiIMStatusResp{
|
||||
VendorID: model.VendorIDMTWM,
|
||||
ImStatus: utils.Str2Int(status),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return retVal, nil
|
||||
}
|
||||
|
||||
type SetPoiIMStatusReq struct {
|
||||
VendorID int `json:"vendorID"`
|
||||
VendorStoreID string `json:"vendorStoreID"`
|
||||
VendorOrgCode string `json:"vendorOrgCode"`
|
||||
ImStatus int `json:"imStatus"`
|
||||
}
|
||||
|
||||
// SetPoiIMStatus 设置平台门店im状态
|
||||
func SetPoiIMStatus(param []SetPoiIMStatusReq) error {
|
||||
var errList errlist.ErrList
|
||||
if len(param) == 0 {
|
||||
return nil
|
||||
}
|
||||
for _, v := range param {
|
||||
switch v.VendorID {
|
||||
case model.VendorIDMTWM:
|
||||
if err := partner.CurAPIManager.GetAPI(model.VendorIDMTWM, v.VendorOrgCode).(*mtwmapi.API).SetPoiIMStatus(v.VendorStoreID, v.ImStatus); err != nil {
|
||||
errList.AddErr(fmt.Errorf("mtwm:%v", err))
|
||||
}
|
||||
case model.VendorIDEBAI:
|
||||
if err := partner.CurAPIManager.GetAPI(model.VendorIDEBAI, v.VendorOrgCode).(*ebaiapi.API).UpdateIMStatus(v.VendorStoreID, v.ImStatus); err != nil {
|
||||
errList.AddErr(fmt.Errorf("ebai:%v", err))
|
||||
}
|
||||
}
|
||||
}
|
||||
return errList.GetErrListAsOne()
|
||||
}
|
||||
|
||||
// ReadMsgFromClient 存储客户端发送的消息
|
||||
func ReadMsgFromClient(vendorID int, elmAppID string, msg interface{}) error {
|
||||
|
||||
@@ -3,6 +3,9 @@ package ebai
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/ebaiapi"
|
||||
"git.rosy.net.cn/jx-callback/business/partner/im"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
@@ -14,21 +17,30 @@ const (
|
||||
|
||||
// OnImMessage 用户/骑手 发送/已读消息 回调
|
||||
func (p *PurchaseHandler) OnImMessage(msg *ebaiapi.CallbackMsg) (response *ebaiapi.CallbackResponse) {
|
||||
globals.SugarLogger.Debugf("ebaiOnImMessage msg=%s", utils.Format4Output(msg, false))
|
||||
str, err := json.Marshal(msg.Data)
|
||||
|
||||
im.ReadMsgFromVendor(IMVendorIDELM, msg.Source, str)
|
||||
//return nil
|
||||
return api.EbaiAPI.Err2CallbackResponse(msg.Cmd, err, nil)
|
||||
err = im.ReadMsgFromVendor(IMVendorIDELM, msg.Source, str)
|
||||
if err != nil {
|
||||
return api.EbaiAPI.Err2CallbackResponse(msg.Cmd, err, msg.Cmd)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// BusinessSendMsg 向门店发送消息
|
||||
//func BusinessSendMsg(param *ebaiapi.BusinessSendMsgReq) error {
|
||||
// err := api.EbaiAPI.BusinessSendMsg(param)
|
||||
// return err
|
||||
//}
|
||||
|
||||
// GetStoreIMStatus 查询门店IM开关状态
|
||||
func GetStoreIMStatus(platformShopId string) (string, error) {
|
||||
retVal, err := api.EbaiAPI.GetStoreIMStatus(platformShopId)
|
||||
return retVal, err
|
||||
}
|
||||
//func GetStoreIMStatus(platformShopId string) (string, error) {
|
||||
// retVal, err := api.EbaiAPI.GetStoreIMStatus(platformShopId)
|
||||
// return retVal, err
|
||||
//}
|
||||
|
||||
// UpdateIMStatus 更新店铺IM开关状态 1-开启,-1-关闭
|
||||
func UpdateIMStatus(platformShopId string, status int) error {
|
||||
err := api.EbaiAPI.UpdateIMStatus(platformShopId, status)
|
||||
return err
|
||||
}
|
||||
//func UpdateIMStatus(platformShopId string, status int) error {
|
||||
// err := api.EbaiAPI.UpdateIMStatus(platformShopId, status)
|
||||
// return err
|
||||
//}
|
||||
|
||||
@@ -15,7 +15,7 @@ func SetPoiIMStatus(appPoiCode, vendorOrgCode string, imStatus int) error {
|
||||
}
|
||||
|
||||
// MsgSend 向用户发送消息
|
||||
func MsgSend(vendorOrgCode, msg string) error {
|
||||
_, err := getAPI(vendorOrgCode, 0, "").MsgSend(msg)
|
||||
return err
|
||||
}
|
||||
//func MsgSend(vendorOrgCode, msg string) error {
|
||||
// _, err := getAPI(vendorOrgCode, 0, "").MsgSend(msg)
|
||||
// return err
|
||||
//}
|
||||
|
||||
@@ -5,8 +5,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/partner/purchase/mtwm"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/partner/im"
|
||||
"github.com/astaxie/beego/server/web"
|
||||
)
|
||||
@@ -89,33 +87,42 @@ func (c *IMController) SendToVendorV2() {
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 查询美团门店IM单聊开关状态
|
||||
// @Description 查询美团门店IM单聊开关状态
|
||||
// @Title 查询多平台门店IM单聊开关状态
|
||||
// @Description 查询多平台门店IM单聊开关状态
|
||||
// @Param token header string true "认证token"
|
||||
// @Param appPoiCode query string true "美团门店id"
|
||||
// @Param vendorOrgCode query string true "美团appid"
|
||||
// @Param data query string true "查询多门店im状态信息"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /GetPoiIMStatus [get]
|
||||
func (c *IMController) GetPoiIMStatus() {
|
||||
c.callGetPoiIMStatus(func(params *tImGetPoiIMStatusParams) (interface{}, string, error) {
|
||||
retVal, err := mtwm.GetPoiIMStatus(params.AppPoiCode, params.VendorOrgCode)
|
||||
return retVal, "", err
|
||||
var req []im.GetPoiIMStatusReq
|
||||
b := bytes.NewBufferString(params.Data)
|
||||
decoder := json.NewDecoder(b)
|
||||
if err := decoder.Decode(&req); err == nil {
|
||||
retVal, err := im.GetPoiIMStatus(req)
|
||||
return retVal, "", err
|
||||
}
|
||||
return nil, "", nil
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 设置美团门店IM线上状态
|
||||
// @Description 设置美团门店IM线上状态
|
||||
// @Title 设置多平台门店IM线上状态
|
||||
// @Description 设置多平台门店IM线上状态
|
||||
// @Param token header string true "认证token"
|
||||
// @Param appPoiCode formData string true "美团门店id"
|
||||
// @Param imStatus formData int true "状态 0-关闭 1-开启"
|
||||
// @Param vendorOrgCode formData string true "美团appid"
|
||||
// @Param data formData string true "设置多平台门店im状态信息"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /SetPoiIMStatus [post]
|
||||
func (c *IMController) SetPoiIMStatus() {
|
||||
c.callSetPoiIMStatus(func(params *tImSetPoiIMStatusParams) (interface{}, string, error) {
|
||||
err := mtwm.SetPoiIMStatus(params.AppPoiCode, params.VendorOrgCode, params.ImStatus)
|
||||
return nil, "", err
|
||||
var req []im.SetPoiIMStatusReq
|
||||
b := bytes.NewBufferString(params.Data)
|
||||
decoder := json.NewDecoder(b)
|
||||
if err := decoder.Decode(&req); err == nil {
|
||||
err := im.SetPoiIMStatus(req)
|
||||
return nil, "", err
|
||||
}
|
||||
return nil, "", nil
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user