添加京东im

This commit is contained in:
邹宗楠
2025-12-10 10:56:48 +08:00
parent cbe7ee196d
commit 69b568fb73
12 changed files with 332 additions and 81 deletions

View File

@@ -133,7 +133,7 @@ var (
VendorIDJD: "京东到家",
VendorIDMTWM: "美团外卖",
VendorIDELM: "饿了么",
VendorIDEBAI: "饿百新零售",
VendorIDEBAI: "淘宝闪购",
VendorIDYB: "银豹",
VendorIDJDShop: "京东商城",
VendorIDWSC: "微盟微商城",

View File

@@ -512,8 +512,6 @@ func UpdateFakeWayBillToTiktok() {
if handler != nil {
if err := handler.GetOrderRider(order.VendorOrgCode, order.VendorStoreID, paramsMap); err != nil {
partner.CurOrderManager.OnOrderMsg(order, tao_vegetable.OrderStatusDelivery, fmt.Sprintf("Fake Pull Rider Info Err :%s--%s--%v", riderInfo.OrderId, riderInfo.ThirdCarrierOrderId, err))
} else {
partner.CurOrderManager.OnOrderMsg(order, tao_vegetable.OrderStatusDelivery, "订单配送中")
}
if order.VendorID == model.VendorIDEBAI {

View File

@@ -6,6 +6,7 @@ import (
"encoding/json"
"errors"
"fmt"
"git.rosy.net.cn/baseapi/platformapi/jdapi"
"math/big"
"strings"
"time"
@@ -28,21 +29,58 @@ import (
)
func SendVendorV2(data SendData, vendorOrgCode string) (err error) {
if data.VendorID == model.VendorIDMTWM {
switch data.VendorID {
case model.VendorIDMTWM:
dataStr, _ := json.Marshal(data.Data)
temp := string(dataStr)
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 {
case model.VendorIDEBAI:
str, _ := json.Marshal(data.Data)
param := &ebaiapi.BusinessSendMsgReq{}
err = json.Unmarshal(str, &param)
globals.SugarLogger.Debugf("SendVendorV2 ebaiparam=%s", utils.Format4Output(param, false))
err = partner.CurAPIManager.GetAPI(model.VendorIDEBAI, vendorOrgCode).(*ebaiapi.API).BusinessSendMsg(param)
case model.VendorIDJD:
//uuid := utils.GetUUID()
//autoReplayParam := &jdapi.ContextMsg{
// Id: uuid,
// Lang: "zh_CN",
// Type: "chat_message",
// From: jdapi.ContextFrom{
// Pin: userMsg.From.Pin,
// App: "im.waiter",
// ClientType: "gw",
// },
// To: jdapi.ContextTo{
// Pin: userMsg.To.Pin,
// App: "im.customer",
// },
// Body: jdapi.ContextBody{
// Type: "text",
// Content: temp,
// Chatinfo: jdapi.ContextBodyChatInfo{
// VenderId: jd.VenderId,
// AskAllocateType: "multiChat",
// Sid: userMsg.Body.Chatinfo.Sid,
// Source: fmt.Sprintf("dd_msg_?_%s"?, uuid),
// },
// Template: struct {
// Source string `json:"source"`
// }{
// Source: fmt.Sprintf("dd_msg_?_%s"?, uuid),
// },
// Mt: 60,
// },
// Timestamp: time.Now().UnixNano(),
// ClientTime: time.Now().UnixNano(),
//}
//err = partner.CurAPIManager.GetAPI(model.VendorIDJD, vendorOrgCode).(*jdapi.API).MessagePushService(autoReplayParam)
}
err = ReadMsgFromClient(data.VendorID, vendorOrgCode, data.Data)
if err != nil {
globals.SugarLogger.Debugf("SendVendorV2:%v", err)
@@ -100,6 +138,9 @@ func GetPoiIMStatus(param []GetPoiIMStatusReq) (retVal []*GetPoiIMStatusResp) {
}
ans2.VendorID = model.VendorIDEBAI
ans2.ImStatus = utils.Str2Int(status)
case model.VendorIDJD:
//api := partner.CurAPIManager.GetAPI(model.VendorIDJD, v.VendorOrgCode).(*jdapi.API)
//api.ImWaiterStatusModify()
}
}
retVal = append(retVal, ans1, ans2)
@@ -129,6 +170,11 @@ func SetPoiIMStatus(param []SetPoiIMStatusReq) error {
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))
}
case model.VendorIDJD:
api := partner.CurAPIManager.GetAPI(model.VendorIDJD, v.VendorOrgCode).(*jdapi.API)
// 0忙碌1在线
err := api.ImWaiterStatusModify(1, v.VendorStoreID, v.ImStatus)
errList.AddErr(fmt.Errorf("jd:%v", err))
}
}
return errList.GetErrListAsOne()
@@ -149,7 +195,8 @@ func ReadMsgFromClient(vendorID int, elmAppID string, msg interface{}) error {
errList.AddErr(fmt.Errorf("json处理数据错误%v", err))
}
if vendorID == VendorIDMT {
switch vendorID {
case model.VendorIDMTWM:
var pushContent = mtwmapi.PushContentReq{}
err = json.Unmarshal(data, &pushContent)
jxMsg = &JXMsg{
@@ -157,7 +204,7 @@ func ReadMsgFromClient(vendorID int, elmAppID string, msg interface{}) error {
MsgContent: pushContent,
}
userList = &UserMessageList{
VendorID: VendorIDMT,
VendorID: model.VendorIDMTWM,
UserID: utils.Int2Str(pushContent.OpenUserID),
LatestMsg: pushContent.MsgContent,
LatestTime: pushContent.Cts,
@@ -166,8 +213,7 @@ func ReadMsgFromClient(vendorID int, elmAppID string, msg interface{}) error {
if pushContent.OrderID != 0 {
userList.OrderID = utils.Int2Str(pushContent.OrderID)
}
}
if vendorID == VendorIDELM {
case model.VendorIDEBAI:
var ElmData = ebaiapi.ImMessageSend{}
err = json.Unmarshal(data, &ElmData)
jxMsg = &JXMsg{
@@ -178,11 +224,24 @@ func ReadMsgFromClient(vendorID int, elmAppID string, msg interface{}) error {
elmTime = int(time.Now().Unix())
}
userList = &UserMessageList{
VendorID: VendorIDELM,
VendorID: model.VendorIDEBAI,
UserID: ElmData.PayLoad.GroupID,
LatestMsg: ElmData.PayLoad.Content,
LatestTime: elmTime,
}
case model.VendorIDJD:
var jdData = jdapi.ContextMsg{}
err = json.Unmarshal(data, &jdData)
jxMsg = &JXMsg{
SendType: SendTypeJx,
MsgContent: jdData,
}
userList = &UserMessageList{
VendorID: model.VendorIDJD,
UserID: jdData.From.Pin,
LatestMsg: utils.Interface2String(jdData.Body),
LatestTime: int(time.Now().Unix()),
}
}
//1 存储展示列表时单条数据
@@ -202,18 +261,19 @@ func ReadMsgFromClient(vendorID int, elmAppID string, msg interface{}) error {
// ReadMsgFromVendor 读取数据并存储到redis
func ReadMsgFromVendor(vendorID int, elmAppID string, msg []byte) error {
var (
err error
jxMsg = &JXMsg{}
vendorStoreID string
errList errlist.ErrList
userList = &UserMessageList{}
err error
jxMsg = &JXMsg{}
vendorStoreID string
errList errlist.ErrList
userList = &UserMessageList{}
systemMsg, userMsg, readMsg = &jdapi.ChatRisInfo{}, &jdapi.UserChatMsg{}, &jdapi.UserMsgReadAck{}
)
if len(string(msg)) == 0 {
errList.AddErr(fmt.Errorf("读取平台数据为空,请检查"))
}
switch vendorID {
case VendorIDMT:
case model.VendorIDMTWM:
var PushContentReq = mtwmapi.PushContentReq{}
err = json.Unmarshal(msg, &PushContentReq)
if len(PushContentReq.MsgContent) != 0 || PushContentReq.MsgContent != "" {
@@ -227,7 +287,7 @@ func ReadMsgFromVendor(vendorID int, elmAppID string, msg []byte) error {
MsgContent: PushContentReq,
}
userList = &UserMessageList{
VendorID: VendorIDMT,
VendorID: model.VendorIDMTWM,
UserID: utils.Int2Str(PushContentReq.OpenUserID),
LatestMsg: PushContentReq.MsgContent,
LatestTime: PushContentReq.Cts,
@@ -236,7 +296,7 @@ func ReadMsgFromVendor(vendorID int, elmAppID string, msg []byte) error {
if PushContentReq.OrderID != 0 {
userList.OrderID = utils.Int2Str(PushContentReq.OrderID)
}
case VendorIDELM:
case model.VendorIDEBAI:
var ElmData = ebaiapi.ImMessageSend{}
err = json.Unmarshal(msg, &ElmData)
jxMsg = &JXMsg{
@@ -244,12 +304,42 @@ func ReadMsgFromVendor(vendorID int, elmAppID string, msg []byte) error {
MsgContent: ElmData,
}
userList = &UserMessageList{
VendorID: VendorIDELM,
VendorID: model.VendorIDEBAI,
UserID: ElmData.PayLoad.GroupID,
LatestMsg: ElmData.PayLoad.Content,
LatestTime: int(ElmData.PayLoad.CreateTime / 1000),
}
vendorStoreID = ElmData.PlatformShopID
case model.VendorIDJD:
var risMsg *jdapi.ChatRisMsgCallback
if err = utils.UnmarshalUseNumber(msg, &risMsg); err != nil {
return err
}
jxMsg = &JXMsg{
SendType: SendTypeJd,
MsgContent: &risMsg,
}
systemMsg, userMsg, readMsg, err = jdapi.ImMsgChange(risMsg, elmAppID)
if err != nil {
return err
}
userList = &UserMessageList{
VendorID: model.VendorIDJD,
LatestMsg: risMsg.ExtendJsonData,
MsgFrom: elmAppID,
}
switch elmAppID {
case jdapi.ImCallbackRisMsg:
userList.UserID = systemMsg.From.Pin
userList.LatestTime = int(systemMsg.Timestamp)
case jdapi.ImCallbackUserMsg:
userList.UserID = userMsg.From.Pin
userList.LatestTime = int(userMsg.Timestamp)
case jdapi.ImCallbackReadMsg:
userList.UserID = readMsg.From.Pin
userList.LatestTime = int(userMsg.Timestamp)
}
vendorStoreID = risMsg.StationId
}
//1 存储详细聊天记录list
@@ -261,9 +351,20 @@ func ReadMsgFromVendor(vendorID int, elmAppID string, msg []byte) error {
errList.AddErr(fmt.Errorf("存储STU聊天记录错误%v", err))
}
//3 cid推送新消息
if err = PushMsgByCid(vendorStoreID, vendorID, string(msg)); err != nil {
errList.AddErr(fmt.Errorf("向商家cid推送新消息错误%v", err))
switch vendorID {
case model.VendorIDEBAI, model.VendorIDMTWM:
if err = PushMsgByCid(vendorStoreID, vendorID, string(msg)); err != nil {
errList.AddErr(fmt.Errorf("向商家cid推送新消息错误%v", err))
}
case model.VendorIDJD:
if elmAppID == jdapi.ImCallbackUserMsg {
err = PushMsgByCid(vendorStoreID, vendorID, "京东用户发送聊天消息,请及时查看")
}
if err != nil {
errList.AddErr(fmt.Errorf("京东向商家cid推送新消息错误%v", err))
}
}
//4 客服自动回复
if err = CheckAndReply(jxMsg, elmAppID); err != nil {
errList.AddErr(fmt.Errorf("客服自动回复出错:%v", err))
@@ -365,11 +466,11 @@ func GenMsgDetailID(jxMsg *JXMsg, vendorID int, elmAppID string) (msgID string)
if jxMsg == nil {
return ""
}
if vendorID == VendorIDMT {
switch vendorID {
case model.VendorIDMTWM:
var d1 = jxMsg.MsgContent.(mtwmapi.PushContentReq)
msgID = utils.Int2Str(d1.AppID) + ":" + d1.AppPoiCode + ":1:" + utils.Int2Str(d1.OpenUserID)
}
if vendorID == VendorIDELM {
case model.VendorIDEBAI:
var ElmData = ebaiapi.ImMessageSend{}
tempMsgContent, _ := json.Marshal(jxMsg.MsgContent)
if err := json.Unmarshal(tempMsgContent, &ElmData); err != nil {
@@ -378,31 +479,41 @@ func GenMsgDetailID(jxMsg *JXMsg, vendorID int, elmAppID string) (msgID string)
//var d2 = jxMsg.MsgContent.(ebaiapi.ImMessageSend)
//msgID = elmAppID + ":" + d2.PlatformShopID + ":3:" + d2.PayLoad.GroupID
msgID = elmAppID + ":" + ElmData.PlatformShopID + ":3:" + ElmData.PayLoad.GroupID
case model.VendorIDJD:
var data = jxMsg.MsgContent.(*jdapi.ChatRisMsgCallback)
msgID = data.VenderId + ":" + data.StationId + ":0:"
systemMsg, userMsg, readMsg, _ := jdapi.ImMsgChange(data, elmAppID)
switch elmAppID {
case jdapi.ImCallbackRisMsg:
msgID += systemMsg.From.Pin
case jdapi.ImCallbackUserMsg:
msgID += userMsg.From.Pin
case jdapi.ImCallbackReadMsg:
msgID += readMsg.From.Pin
}
}
return msgID
}
// 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)
if jxMsg == nil {
return ""
}
if vendorID == VendorIDMT {
switch vendorID {
case model.VendorIDMTWM:
var d1 = jxMsg.MsgContent.(mtwmapi.PushContentReq)
msgID = utils.Int2Str(d1.AppID) + ":" + d1.AppPoiCode + ":1"
}
if vendorID == VendorIDELM {
case model.VendorIDEBAI:
var ElmData = ebaiapi.ImMessageSend{}
tempMsgContent, _ := json.Marshal(jxMsg.MsgContent)
err := json.Unmarshal(tempMsgContent, &ElmData)
fmt.Println(err)
//var d2 = jxMsg.MsgContent.(ebaiapi.ImMessageSend)
//msgID = elmAppID + ":" + d2.PlatformShopID + ":3"
json.Unmarshal(tempMsgContent, &ElmData)
msgID = elmAppID + ":" + ElmData.PlatformShopID + ":3"
case model.VendorIDJD:
var data = jxMsg.MsgContent.(*jdapi.ChatRisMsgCallback)
msgID = data.VenderId + ":" + data.StationId + ":0"
}
return msgID
}
@@ -540,8 +651,9 @@ func CheckAndReply(req *JXMsg, elmAppID string) (err error) {
//userList = &UserMessageList{}
)
if req.SendType == SendTypeMt {
vendorID = VendorIDMT
switch req.SendType {
case SendTypeMt:
vendorID = model.VendorIDMTWM
mt := req.MsgContent.(mtwmapi.PushContentReq)
//跳过12小时内商家消息自动回复
if mt.MsgSource != mtwmapi.MsgSourceUser {
@@ -552,7 +664,7 @@ func CheckAndReply(req *JXMsg, elmAppID string) (err error) {
keyDetailMt := UserRelInfo{
AppID: utils.Int2Str(mt.AppID),
VendorStoreID: mt.AppPoiCode,
VendorID: VendorIDMTStr,
VendorID: utils.Int2Str(model.VendorIDMTWM),
UserID: utils.Int2Str(mt.OpenUserID),
}
//1 检测是否已自动回复
@@ -575,7 +687,7 @@ func CheckAndReply(req *JXMsg, elmAppID string) (err error) {
}
temp.MsgContent = template.Template
} else {
temp.MsgContent, err = GetDefaultTemplate(utils.Int2Str(mt.AppID), mt.AppPoiCode, VendorIDMT)
temp.MsgContent, err = GetDefaultTemplate(utils.Int2Str(mt.AppID), mt.AppPoiCode, model.VendorIDMTWM)
if err != nil {
temp.MsgContent = AutoReplyByAppID[mt.AppID]
}
@@ -605,10 +717,8 @@ func CheckAndReply(req *JXMsg, elmAppID string) (err error) {
errList.AddErr(fmt.Errorf("自动回复:记录自动回复状态错误:%v", err))
}
}
}
if req.SendType == SendTypeElm {
vendorID = VendorIDELM
case SendTypeElm:
vendorID = model.VendorIDEBAI
elm := req.MsgContent.(ebaiapi.ImMessageSend)
key = elmAppID + ":" + elm.PayLoad.SenderID + ":autoReply"
@@ -619,7 +729,7 @@ func CheckAndReply(req *JXMsg, elmAppID string) (err error) {
keyDetailElm := UserRelInfo{
AppID: elmAppID,
VendorStoreID: elm.PlatformShopID,
VendorID: VendorIDELMStr,
VendorID: utils.Int2Str(model.VendorIDEBAI),
UserID: elm.PayLoad.GroupID,
}
//1 检测是否已自动回复
@@ -648,7 +758,7 @@ func CheckAndReply(req *JXMsg, elmAppID string) (err error) {
if template := GetCustomTemplate(elmAppID, elm.PlatformShopID); len(template.Template) > 0 {
temp = template.Template
} else {
temp, err = GetDefaultTemplate(elmAppID, elm.PlatformShopID, VendorIDELM)
temp, err = GetDefaultTemplate(elmAppID, elm.PlatformShopID, model.VendorIDEBAI)
if err != nil {
temp = LastTemplate
}
@@ -682,6 +792,98 @@ func CheckAndReply(req *JXMsg, elmAppID string) (err error) {
errList.AddErr(fmt.Errorf("自动回复:记录自动回复状态错误:%v", err))
}
}
case SendTypeJd:
//vendorID = model.VendorIDJD
//jd := req.MsgContent.(*jdapi.ChatRisMsgCallback)
////跳过12小时内商家消息自动回复
//if elmAppID != jdapi.ImCallbackUserMsg {
// return nil
//}
//var userMsg *jdapi.UserChatMsg
//if err = utils.UnmarshalUseNumber([]byte(jd.ExtendJsonData), &userMsg); err != nil {
// return err
//}
//
//key = jd.VenderId + ":" + userMsg.From.Pin + ":autoReply"
//keyDetailMt := UserRelInfo{
// AppID: jd.VenderId,
// VendorStoreID: jd.StationId,
// VendorID: utils.Int2Str(model.VendorIDJD),
// UserID: userMsg.From.Pin,
//}
////1 检测是否已自动回复
//flag = GetIfReply(key, keyDetailMt)
////判断flag状态
//if !flag {
// apply = &AutoReply{
// UserID: 1,
// MsgID: 1,
// IsApply: true,
// Timestamp: int(userMsg.Timestamp),
// }
// //jdapi.ContextMsg{}
// temp := ""
// //获取自定义回复模板
// if template := GetCustomTemplate(jd.VenderId, jd.StationId); len(template.Template) > 0 {
// temp = template.Template
// } else {
// temp, err = GetDefaultTemplate(jd.VenderId, jd.StationId, model.VendorIDJD)
// if err != nil {
// temp = LastTemplate
// }
// }
//
// uuid := utils.GetUUID()
// autoReplayParam := &jdapi.ContextMsg{
// Id: uuid,
// Lang: "zh_CN",
// Type: "chat_message",
// From: jdapi.ContextFrom{
// Pin: userMsg.From.Pin,
// App: "im.waiter",
// ClientType: "gw",
// },
// To: jdapi.ContextTo{
// Pin: userMsg.To.Pin,
// App: "im.customer",
// },
// Body: jdapi.ContextBody{
// Type: "text",
// Content: temp,
// Chatinfo: jdapi.ContextBodyChatInfo{
// VenderId: jd.VenderId,
// AskAllocateType: "multiChat",
// Sid: userMsg.Body.(map[string]interface{})["chatinfo"].(map[string]interface{})["sid"].(string),
// Source: fmt.Sprintf("dd_msg_?_%s"?, uuid),
// },
// Template: struct {
// Source string `json:"source"`
// }{
// Source: fmt.Sprintf("dd_msg_?_%s"?, uuid),
// },
// Mt: 60,
// },
// Timestamp: time.Now().UnixNano(),
// ClientTime: time.Now().UnixNano(),
// }
// if err = partner.CurAPIManager.GetAPI(model.VendorIDJD, jd.VenderId).(*jdapi.API).MessagePushService(autoReplayParam); err != nil {
// apply.IsApply = false
// globals.SugarLogger.Debugf("CheckAndReply jd send err:%v", err)
// } else {
// jxMsg = &JXMsg{
// SendType: SendTypeJx,
// MsgContent: temp,
// }
// // 存储详细聊天记录
// if err = SetMessageDetail(jxMsg, vendorID, elmAppID); err != nil {
// errList.AddErr(fmt.Errorf("自动回复:存储详细聊天记录错误:%v", err))
// }
// }
// //3 记录自动回复状态
// if err = RecordAutoStatus(key, apply); err != nil {
// errList.AddErr(fmt.Errorf("自动回复:记录自动回复状态错误:%v", err))
// }
//}
}
if errList.GetErrListAsOne() != nil {
@@ -881,12 +1083,12 @@ func GetIfReply(key string, keyDetail UserRelInfo) (flag bool) {
return false
}
switch keyDetail.VendorID {
case VendorIDMTStr:
case utils.Int2Str(model.VendorIDMTWM):
mt := lastMsg.MsgContent.(map[string]interface{})
if mt["msg_source"].(float64) == mtwmapi.MsgSourceStore {
return true
}
case VendorIDELMStr:
case utils.Int2Str(model.VendorIDEBAI):
elm := lastMsg.MsgContent.(map[string]interface{})
s := ""
if elm["payLoad"].(map[string]interface{})["senderId"] != nil {
@@ -895,6 +1097,12 @@ func GetIfReply(key string, keyDetail UserRelInfo) (flag bool) {
if s == "" || s[:2] == ebaiapi.SenderTypeBusiness || s[:2] == ebaiapi.SenderTypeChainedAccountLogin || s[:2] == ebaiapi.SenderTypeSystem {
return true
}
case utils.Int2Str(model.VendorIDJD):
mt := lastMsg.MsgContent.(map[string]interface{})
if mt["source"].(string) != "" {
return true
}
}
}
@@ -993,11 +1201,6 @@ func GetDefaultTemplate(appID, vendorStoreID string, vendorID int) (string, erro
if err != nil {
return "", err
}
//if err != nil && err == orm.ErrNoRows {
// t = BasePhoneNum
//}
if len(store.Tel1) > 0 {
t = store.Tel1
}
@@ -1005,17 +1208,18 @@ func GetDefaultTemplate(appID, vendorStoreID string, vendorID int) (string, erro
phoneNum = t[:3] + "-" + t[3:7] + "-" + t[7:]
temp := BaseTemplate + phoneNum
if vendorID == VendorIDMT {
switch vendorID {
case model.VendorIDMTWM:
data, err := EncryptIm(utils.Str2Int(appID), temp)
if err != nil {
return "", err
}
return data, nil
}
if vendorID == VendorIDELM {
case model.VendorIDEBAI:
return temp, nil
case model.VendorIDJD:
return temp, nil
}
return "", nil
}

View File

@@ -47,6 +47,7 @@ type UserMessageList struct {
NewMessageNum int `json:"NewMessageNum"` //新消息数量
LatestMsg string `json:"latestMsg"` //最新一条消息
LatestTime int `json:"latestTime"` //最新一条消息发送时间
MsgFrom string `json:"msgFrom"` // 京东消息来源
}
type RelInfo struct {
@@ -67,17 +68,12 @@ type StoreTemplate struct {
}
var (
rdb = api.Cacher
VendorIDMT = 1 //im美团
VendorIDELM = 3 //im饿了么
VendorIDJX = 3 //im京西
VendorIDMTStr = "1" //im美团
VendorIDELMStr = "3" //im饿了么
rdb = api.Cacher
SendTypeJx = "jx" //京西客户端发送方标识
SendTypeMt = "mt" //美团用户发送方标识符
SendTypeElm = "elm" //饿了么用户发送方标识符
SendTypeJd = "jd" //京东用户发送方标识符
OpTypeAdd = 1 //门店新增或修改自定义回复模板
OpTypeGet = 2 //门店获取
BaseCusKey = "customReply"

View File

@@ -37,7 +37,7 @@ func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel strin
orderParams := []interface{}{}
getCode := ""
if order.VendorID == model.VendorIDEBAI {
getCode = fmt.Sprintf("<B>饿百取货码:%s</B><BR><BR>\n", jxutils.GetEbaiOrderGetCode(order))
getCode = fmt.Sprintf("<B>淘宝闪购取货码:%s</B><BR><BR>\n", jxutils.GetEbaiOrderGetCode(order))
}
orderFmt := ``
if storeDetail != nil {
@@ -155,7 +155,7 @@ func (c *PrinterHandler) getOrderContentBig(order *model.GoodsOrder, storeTel st
}
getCode := ""
if order.VendorID == model.VendorIDEBAI {
getCode = fmt.Sprintf("<B>饿百取货码:%s</B><BR><BR>\n", jxutils.GetEbaiOrderGetCode(order))
getCode = fmt.Sprintf("<B>淘宝闪购取货码:%s</B><BR><BR>\n", jxutils.GetEbaiOrderGetCode(order))
}
orderParams := []interface{}{}
orderFmt := ``

View File

@@ -179,7 +179,7 @@ func (c *PrinterHandler) getOrderContentV2(order *model.GoodsOrder, storeTel str
}
getCode := ""
if order.VendorID == model.VendorIDEBAI {
getCode = fmt.Sprintf("<C>饿百取货码:%s</C>", jxutils.GetEbaiOrderGetCode(order))
getCode = fmt.Sprintf("<C>淘宝闪购取货码:%s</C>", jxutils.GetEbaiOrderGetCode(order))
}
if order.BuyerComment == "" {
order.BuyerComment = "客户电话: " + order.ConsigneeMobile + ",配送遇到问题,可联系18048531223取消配送单,禁止未配送直接完成订单!"
@@ -249,7 +249,7 @@ func (c *PrinterHandler) getOrderContentBigV2(order *model.GoodsOrder, storeTel
}
getCode := ""
if order.VendorID == model.VendorIDEBAI {
getCode = fmt.Sprintf("<C>饿百取货码:%s</C>", jxutils.GetEbaiOrderGetCode(order))
getCode = fmt.Sprintf("<C>淘宝闪购取货码:%s</C>", jxutils.GetEbaiOrderGetCode(order))
}
if order.BuyerComment == "" {
order.BuyerComment = "客户电话: " + order.ConsigneeMobile + ",配送遇到问题,可联系18048531223取消配送单,禁止未配送直接完成订单!"
@@ -321,7 +321,7 @@ func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel strin
}
getCode := ""
if order.VendorID == model.VendorIDEBAI {
getCode = fmt.Sprintf("<C>饿百取货码:%s</C>", jxutils.GetEbaiOrderGetCode(order))
getCode = fmt.Sprintf("<C>淘宝闪购取货码:%s</C>", jxutils.GetEbaiOrderGetCode(order))
}
if order.BuyerComment == "" {
order.BuyerComment = "客户电话: " + order.ConsigneeMobile + ",配送遇到问题,可联系18048531223取消配送单,禁止未配送直接完成订单!"
@@ -394,7 +394,7 @@ func (c *PrinterHandler) getOrderContentBig(order *model.GoodsOrder, storeTel st
}
getCode := ""
if order.VendorID == model.VendorIDEBAI {
getCode = fmt.Sprintf("<C>饿百取货码:%s</C>", jxutils.GetEbaiOrderGetCode(order))
getCode = fmt.Sprintf("<C>淘宝闪购取货码:%s</C>", jxutils.GetEbaiOrderGetCode(order))
}
order.BuyerComment = ""
if order.BuyerComment == "" {

View File

@@ -37,7 +37,7 @@ func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel strin
}
getCode := ""
if order.VendorID == model.VendorIDEBAI {
getCode = fmt.Sprintf("<big>饿百取货码:%s**\n", jxutils.GetEbaiOrderGetCode(order))
getCode = fmt.Sprintf("<big>淘宝闪购取货码:%s**\n", jxutils.GetEbaiOrderGetCode(order))
}
buyerComment := order.BuyerComment
if buyerComment == "" {
@@ -134,7 +134,7 @@ func (c *PrinterHandler) getOrderContentBig(order *model.GoodsOrder, storeTel st
}
getCode := ""
if order.VendorID == model.VendorIDEBAI {
getCode = fmt.Sprintf("<big>饿百取货码:%s**\n", jxutils.GetEbaiOrderGetCode(order))
getCode = fmt.Sprintf("<big>淘宝闪购取货码:%s**\n", jxutils.GetEbaiOrderGetCode(order))
}
buyerComment := order.BuyerComment
if buyerComment == "" {
@@ -217,7 +217,7 @@ func (c *PrinterHandler) getOrderContent2(order *model.GoodsOrder, storeTel stri
}
getCode := ""
if order.VendorID == model.VendorIDEBAI {
getCode = fmt.Sprintf("|7饿百取货码:%s\n\n", jxutils.GetEbaiOrderGetCode(order))
getCode = fmt.Sprintf("|7淘宝闪购取货码:%s\n\n", jxutils.GetEbaiOrderGetCode(order))
}
buyerComment := order.BuyerComment
if buyerComment == "" {

View File

@@ -176,7 +176,7 @@ func (c *PrinterHandler) getOrderContentV2(order *model.GoodsOrder, storeTel str
}
getCode := ""
if order.VendorID == model.VendorIDEBAI {
getCode = fmt.Sprintf("<CB>饿百取货码:%s</CB>", jxutils.GetEbaiOrderGetCode(order))
getCode = fmt.Sprintf("<CB>淘宝闪购取货码:%s</CB>", jxutils.GetEbaiOrderGetCode(order))
}
if order.BuyerComment == "" {
order.BuyerComment = "客户电话: " + order.ConsigneeMobile + ",配送遇到问题,可联系18048531223取消配送单,禁止未配送直接完成订单!"
@@ -244,7 +244,7 @@ func (c *PrinterHandler) getOrderContentBigV2(order *model.GoodsOrder, storeTel
}
getCode := ""
if order.VendorID == model.VendorIDEBAI {
getCode = fmt.Sprintf("<CB>饿百取货码:%s</CB>", jxutils.GetEbaiOrderGetCode(order))
getCode = fmt.Sprintf("<CB>淘宝闪购取货码:%s</CB>", jxutils.GetEbaiOrderGetCode(order))
}
if order.BuyerComment == "" {
order.BuyerComment = "客户电话: " + order.ConsigneeMobile + ",配送遇到问题,可联系18048531223取消配送单,禁止未配送直接完成订单!"
@@ -314,7 +314,7 @@ func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel strin
}
getCode := ""
if order.VendorID == model.VendorIDEBAI {
getCode = fmt.Sprintf("<CB>饿百取货码:%s</CB>", jxutils.GetEbaiOrderGetCode(order))
getCode = fmt.Sprintf("<CB>淘宝闪购取货码:%s</CB>", jxutils.GetEbaiOrderGetCode(order))
}
if order.BuyerComment == "" {
order.BuyerComment = "客户电话: " + order.ConsigneeMobile + ",配送遇到问题,可联系18048531223取消配送单,禁止未配送直接完成订单!"
@@ -399,7 +399,7 @@ func (c *PrinterHandler) getOrderContentBig(order *model.GoodsOrder, storeTel st
}
getCode := ""
if order.VendorID == model.VendorIDEBAI {
getCode = fmt.Sprintf("<CB>饿百取货码:%s</CB>", jxutils.GetEbaiOrderGetCode(order))
getCode = fmt.Sprintf("<CB>淘宝闪购取货码:%s</CB>", jxutils.GetEbaiOrderGetCode(order))
}
if order.BuyerComment == "" {
order.BuyerComment = "客户电话: " + order.ConsigneeMobile + ",配送遇到问题,可联系18048531223取消配送单,禁止未配送直接完成订单!"

View File

@@ -35,7 +35,7 @@ func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel strin
}
getCode := ""
if order.VendorID == model.VendorIDEBAI {
getCode = fmt.Sprintf("<FS2>饿百取货码:%s</FS2>\\n\n", jxutils.GetEbaiOrderGetCode(order))
getCode = fmt.Sprintf("<FS2>淘宝闪购取货码:%s</FS2>\\n\n", jxutils.GetEbaiOrderGetCode(order))
}
orderParams := []interface{}{}
orderFmt := ``
@@ -147,7 +147,7 @@ func (c *PrinterHandler) getOrderContentBig(order *model.GoodsOrder, storeTel st
}
getCode := ""
if order.VendorID == model.VendorIDEBAI {
getCode = fmt.Sprintf("<FS2>饿百取货码:%s</FS2>\\n\n", jxutils.GetEbaiOrderGetCode(order))
getCode = fmt.Sprintf("<FS2>淘宝闪购取货码:%s</FS2>\\n\n", jxutils.GetEbaiOrderGetCode(order))
}
orderParams := []interface{}{}
orderFmt := ``

View File

@@ -36,7 +36,7 @@ func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel strin
}
getCode := ""
if order.VendorID == model.VendorIDEBAI {
getCode = fmt.Sprintf("<S2>饿百取货码:%s</S2><RN>\n", jxutils.GetEbaiOrderGetCode(order))
getCode = fmt.Sprintf("<S2>淘宝闪购取货码:%s</S2><RN>\n", jxutils.GetEbaiOrderGetCode(order))
}
var orderParams []interface{}
orderFmt := ``
@@ -121,7 +121,7 @@ func (c *PrinterHandler) getOrderContentBig(order *model.GoodsOrder, storeTel st
}
getCode := ""
if order.VendorID == model.VendorIDEBAI {
getCode = fmt.Sprintf("<S2>饿百取货码:%s</S2><RN>\n", jxutils.GetEbaiOrderGetCode(order))
getCode = fmt.Sprintf("<S2>淘宝闪购取货码:%s</S2><RN>\n", jxutils.GetEbaiOrderGetCode(order))
}
orderParams := []interface{}{}
orderFmt := ``

View File

@@ -3,6 +3,7 @@ package localjx
import (
"encoding/json"
"fmt"
"git.rosy.net.cn/jx-callback/business/jxutils/weixinmsg"
"git.rosy.net.cn/jx-callback/business/partner"
"strings"
"time"
@@ -135,6 +136,24 @@ func onTLpayFinished(call *tonglianpayapi.CallBackResult) (err error) {
dao.UpdateEntity(db, orderPay)
if call.TrxStatus == tonglianpayapi.TrxStatusSuccess {
err = OnPayFinished(orderPay)
order, _ := partner.CurOrderManager.LoadOrder(orderPay.VendorOrderID, model.VendorIDJX)
if order != nil {
store, _ := dao.GetStoreDetail(db, order.FromStoreID, model.VendorIDJX, "")
if store != nil {
userID := make([]string, 0, 2)
for _, v := range []string{store.MarketManPhone, store.OperatorPhone2} {
if v == "" {
continue
}
user, _ := dao.GetUserByID(db, "mobile", v)
userID = append(userID, user.UserID)
if store.MarketManPhone == store.OperatorPhone2 {
break
}
}
weixinmsg.SendUserMessage(jxcontext.AdminCtx, "商户购买物料信息推送", fmt.Sprintf("门店%s:%d,在物料商城下单了:%s,请注意查看", store.Name, store.ID, order.VendorOrderID), userID, true, true)
}
}
}
} else {
globals.SugarLogger.Debugf("onTLpayFinished msg:%s, err:%v", utils.Format4Output(call, true), err)

View File

@@ -3,6 +3,8 @@ package controllers
import (
"bytes"
"fmt"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/business/partner/im"
"io/ioutil"
"net/http"
@@ -244,6 +246,38 @@ func (c *DjswController) ApplyOrderInvoiceStatus() {
}
}
func (c *DjswController) imMsg() {
if c.Ctx.Input.Method() == http.MethodPost {
var callbackResponse *jdapi.CallbackResponse
msg, url, err := jdapi.ImChatRiskMsg(getUsefulRequest(c.Ctx))
if err != nil {
callbackResponse = jdapi.Err2CallbackResponse(err, "")
} else {
callbackResponse = jdapi.Err2CallbackResponse(im.ReadMsgFromVendor(model.VendorIDJD, url, msg), "")
}
c.Data["json"] = c.transferResponse("orderStatus", callbackResponse)
c.ServeJSON()
} else {
c.Abort("404")
}
}
// ChatRiskMsg 风控消息推送
func (c *DjswController) ChatRiskMsg() {
c.imMsg()
}
// MsChatMessageMsg 用户消息
func (c *DjswController) MsChatMessageMsg() {
c.imMsg()
}
// MsgReadAckMsg 消息已读
func (c *DjswController) MsgReadAckMsg() {
c.imMsg()
}
//免费开卡接不到回调
//func (c *DjswController) MemberCreateCard() {
// if c.Ctx.Input.Method() == http.MethodPost {