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