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 {
|
||||
|
||||
Reference in New Issue
Block a user