This commit is contained in:
richboo111
2024-01-24 14:13:48 +08:00
parent 3bd5106b14
commit ca65ccf637
2 changed files with 16 additions and 12 deletions

View File

@@ -353,7 +353,7 @@ func GetNewAndTrim(key string, flag string) (cnt int, err error) {
// GenMsgDetailID 生成查询详细聊天记录ID
func GenMsgDetailID(jxMsg *JXMsg, vendorID int, elmAppID string) (msgID string) {
globals.SugarLogger.Debugf("GenMsgDetailID test0124 jxMsg=%s", utils.Format4Output(jxMsg, false))
//globals.SugarLogger.Debugf("GenMsgDetailID test0124 jxMsg=%s", utils.Format4Output(jxMsg, false))
if jxMsg == nil {
return ""
}
@@ -371,7 +371,7 @@ func GenMsgDetailID(jxMsg *JXMsg, vendorID int, elmAppID string) (msgID string)
// GenMsgListID 生成展示列表时单条数据ID部分
func GenMsgListID(jxMsg *JXMsg, vendorID int, elmAppID string) (msgID string) {
globals.SugarLogger.Debugf("GenMsgListID test0124 jxMsg=%s,vendorID=%d", utils.Format4Output(jxMsg, false), vendorID)
//globals.SugarLogger.Debugf("GenMsgListID test0124 jxMsg=%s,vendorID=%d", utils.Format4Output(jxMsg, false), vendorID)
if jxMsg == nil {
return ""
}
@@ -595,7 +595,7 @@ func CheckAndReply(req *JXMsg, elmAppID string) (err error) {
Timestamp: elm.PayLoad.CreateTime,
}
temp := &ebaiapi.BusinessSendMsgReq{
param := &ebaiapi.BusinessSendMsgReq{
PlatformShopId: elm.PlatformShopID,
BizType: ebaiapi.IMType,
SubBizType: ebaiapi.IMTypeSendMsg,
@@ -606,16 +606,20 @@ func CheckAndReply(req *JXMsg, elmAppID string) (err error) {
ContentType: utils.Int2Str(ebaiapi.ContentTypeNormal),
},
}
temp := ""
if template := GetCustomTemplate(elmAppID, elm.PlatformShopID); len(template) > 0 {
temp.Payload.Content = template
temp = template
} else {
temp.Payload.Content, err = GetDefaultTemplate(elmAppID, elm.PlatformShopID, VendorIDELM)
temp, err = GetDefaultTemplate(elmAppID, elm.PlatformShopID, VendorIDELM)
if err != nil {
temp.Payload.Content = LastTemplate
temp = LastTemplate
}
}
tempStr, _ := json.Marshal(temp)
param.Payload.Content = string(tempStr)
if err = partner.CurAPIManager.GetAPI(model.VendorIDEBAI, elmAppID).(*ebaiapi.API).BusinessSendMsg(temp); err != nil {
if err = partner.CurAPIManager.GetAPI(model.VendorIDEBAI, elmAppID).(*ebaiapi.API).BusinessSendMsg(param); err != nil {
apply.IsApply = false
globals.SugarLogger.Debugf("CheckAndReply mtSend err:%v", err)
} else {
@@ -737,12 +741,13 @@ func GetDefaultTemplate(appID, vendorStoreID string, vendorID int) (string, erro
if err != nil && err != orm.ErrNoRows {
return "", err
}
if err == orm.ErrNoRows || (len(store.Tel1) == 0 && len(store.Tel2) == 0) {
t = BasePhoneNum
}
if len(store.Tel1) > 0 {
t = store.Tel1
}
if len(store.Tel1) == 0 && len(store.Tel2) == 0 {
t = BasePhoneNum
}
phoneNum = t[:3] + "-" + t[3:7] + "-" + t[7:]
temp := BaseTemplate + phoneNum

View File

@@ -2,7 +2,6 @@ package mtwm
import (
"encoding/json"
"git.rosy.net.cn/baseapi/utils"
"net/http"
"strings"
@@ -123,7 +122,7 @@ func GetMsgCallBackUrl(msgType, appId string) string {
// OnImMsg im消息回调
func OnImMsg(msg *mtwmapi.ImCallbackMsg) (response *mtwmapi.CallbackResponse) {
globals.SugarLogger.Debugf("OnImMsg test0124 msg:=%s", utils.Format4Output(msg, false))
//globals.SugarLogger.Debugf("OnImMsg test0124 msg:=%s", utils.Format4Output(msg, false))
if str, err := json.Marshal(msg.PushContent); err == nil {
err = im.ReadMsgFromVendor(model.VendorIDMTWM, "", str)
if err != nil {