From 918485a7c4be54f50da99785589f379aca9aca01 Mon Sep 17 00:00:00 2001 From: richboo111 Date: Thu, 11 May 2023 18:21:09 +0800 Subject: [PATCH 1/5] 1 --- business/jxstore/misc/misc.go | 15 ++-- business/model/dao/store.go | 1 - business/partner/purchase/im/im.go | 105 ++++++++++------------ business/partner/purchase/im/im_model.go | 9 +- business/partner/purchase/im/im_server.go | 18 ++-- globals/beegodb/beegodb.go | 13 ++- 6 files changed, 78 insertions(+), 83 deletions(-) diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index 33c0fa3fa..bcb2702de 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -2,13 +2,14 @@ package misc import ( "fmt" + "sync" + "time" + "git.rosy.net.cn/baseapi/platformapi/dingdingapi" "git.rosy.net.cn/jx-callback/business/bidding" "git.rosy.net.cn/jx-callback/business/jxcallback/auto_delivery" "git.rosy.net.cn/jx-callback/business/jxutils/ddmsg" "git.rosy.net.cn/jx-callback/business/partner/delivery" - "sync" - "time" "git.rosy.net.cn/jx-callback/business/partner/purchase/jdshop" @@ -261,11 +262,11 @@ func Init() { }, 5*time.Second, 10*time.Minute) // 抖音更新门店商品 ,接口收费暂不使用 - if beego.BConfig.RunMode != "jxgy" { - ScheduleTimerFunc("RefreshSyncSkuList", func() { - syncStoreSkuTiktok() - }, []string{"13:00:00"}) - } + //if beego.BConfig.RunMode != "jxgy" { + // ScheduleTimerFunc("RefreshSyncSkuList", func() { + // syncStoreSkuTiktok() + // }, []string{"13:00:00"}) + //} //刷新抖音门店token if beego.BConfig.RunMode != "jxgy" { diff --git a/business/model/dao/store.go b/business/model/dao/store.go index 86884ee2d..e1870c1c8 100644 --- a/business/model/dao/store.go +++ b/business/model/dao/store.go @@ -1653,7 +1653,6 @@ func GetStoreBaseByVendorStoreID(vendorStoreID string, vendorID int) (storeDetai return nil, errors.New("vendorStoreID不能为空") } - //DefaultTimeValue := utils.Str2Time("1970-01-01 00:00:00") sql := `SELECT t.* FROM store t WHERE t.id = (SELECT s.store_id FROM store_map s WHERE s.vendor_store_id= ? AND s.vendor_id= ? AND s.deleted_at= '1970-01-01 00:00:00' )` if err := GetRow(GetDB(), &storeDetail, sql, []interface{}{vendorStoreID, vendorID}); err != nil { return nil, err diff --git a/business/partner/purchase/im/im.go b/business/partner/purchase/im/im.go index df1d001f4..c5e71be31 100644 --- a/business/partner/purchase/im/im.go +++ b/business/partner/purchase/im/im.go @@ -44,6 +44,7 @@ func SendToVendor(msg []byte) { return } Send(temp, sendData.Data.(map[string]interface{})["app_id"]) + return } if sendData.VendorID == VendorIDELM { param := sendData.Data.(ebaiapi.BusinessSendMsgReq) @@ -53,18 +54,6 @@ func SendToVendor(msg []byte) { } } - //if err != nil { - // ClientRender(Fail, FailMsg, map[string]string{ - // "errMsg": fmt.Sprintf("%v", err), - // }) - // return err - //} else { - // ClientRender(SuccessCode, SuccessMsg, map[string]interface{}{ - // "vendorID": sendData.VendorID, - // "msg": "ok", - // }) - // return nil - //} return } @@ -92,16 +81,16 @@ func Send(data []byte, appID interface{}) { for { _, msg, err := conn.ReadMessage() temp := string(msg) + res := JsonCommon(HeartSuccessWord) + fmt.Printf("Send %s receive: %s\n", conn.RemoteAddr(), string(msg)) if err != nil { break + } else if temp == res { + continue } else { - if temp != HeartSuccessWord { - ReadMsgFromVendor(VendorIDMT, "", msg) - } + ReadMsgFromVendor(VendorIDMT, "", msg) } - fmt.Printf("%s receive: %s\n", conn.RemoteAddr(), string(msg)) } - return } // MtInit 发送心跳 @@ -135,53 +124,57 @@ func MtInit() { for { _, msg, err := conn.ReadMessage() temp := string(msg) - if err != nil || temp != "HB" { + res := JsonCommon(HeartCheckSuccess) + fmt.Printf("MtInit %s receive: %s\n", conn.RemoteAddr(), string(msg)) + if err != nil { break + } else if temp == res { + continue } else { ReadMsgFromVendor(VendorIDMT, "", msg) } - fmt.Printf("%s receive: %s\n", conn.RemoteAddr(), string(msg)) } }, url.ClientIDMain) //副连接 - if url.UrlSub != "" { - jxutils.CallMsgHandlerAsync(func() { - connSub, respSub, errSub := websocket.DefaultDialer.Dial(url.UrlSub, nil) - if errSub != nil || respSub.StatusCode != 101 { - fmt.Printf("连接失败:%v http响应不成功", errSub) - } - - //关闭 - defer func(conn *websocket.Conn) { - err := conn.Close() - if err != nil { - return - } - }(connSub) - - //client连接事件 - client := NewClient(url.ClientIDSub, connSub, ClientTypeMt) - Manager.Connect <- client - - errSub = connSub.WriteMessage(websocket.TextMessage, data) - if errSub != nil { - fmt.Println(errSub) - } - - for { - _, msg, err := connSub.ReadMessage() - temp := string(msg) - if err != nil || temp != HeartCheckSuccess { - break - } else { - ReadMsgFromVendor(VendorIDMT, "", msg) - } - fmt.Printf("%s connSub:receive: %s\n", connSub.RemoteAddr(), string(msg)) - } - - }, url.ClientIDSub) - } + //if url.UrlSub != "" { + // jxutils.CallMsgHandlerAsync(func() { + // connSub, respSub, errSub := websocket.DefaultDialer.Dial(url.UrlSub, nil) + // if errSub != nil || respSub.StatusCode != 101 { + // fmt.Printf("连接失败:%v http响应不成功", errSub) + // } + // + // //关闭 + // defer func(conn *websocket.Conn) { + // err := conn.Close() + // if err != nil { + // return + // } + // }(connSub) + // + // //client连接事件 + // client := NewClient(url.ClientIDSub, connSub, ClientTypeMt) + // Manager.Connect <- client + // + // errSub = connSub.WriteMessage(websocket.TextMessage, data) + // if errSub != nil { + // fmt.Println(errSub) + // } + // + // for { + // _, msg, err := connSub.ReadMessage() + // temp := string(msg) + // res := JsonCommon(HeartCheckSuccess) + // if err != nil || temp == res { + // break + // } else { + // ReadMsgFromVendor(VendorIDMT, "", msg) + // } + // fmt.Printf("MtInit %s connSub:receive: %s\n", connSub.RemoteAddr(), string(msg)) + // } + // + // }, url.ClientIDSub) + //} } diff --git a/business/partner/purchase/im/im_model.go b/business/partner/purchase/im/im_model.go index 49a984ea3..018c76f98 100644 --- a/business/partner/purchase/im/im_model.go +++ b/business/partner/purchase/im/im_model.go @@ -153,7 +153,7 @@ var ( CommonSetting = &commonConf{} GlobalSetting = &global{} //心跳相关 - heartbeatInterval = 60 * time.Second // 心跳间隔 + heartbeatInterval = 20 * time.Second // 心跳间隔 HeartCheckMsg = "~#HHHBBB#~" //心跳检测消息 HeartCheckSuccess = "HB" //成功发送返回心跳消息 HeartSuccessWord = "成功" //成功发送返回心跳消息 @@ -345,3 +345,10 @@ func RandString() string { } return string(bytes) } + +// JsonCommon json格式化 +func JsonCommon(str string) (retVal string) { + temp, _ := json.Marshal(str) + _ = json.Unmarshal(temp, &retVal) + return retVal +} diff --git a/business/partner/purchase/im/im_server.go b/business/partner/purchase/im/im_server.go index 798b39b71..2b9208bcb 100644 --- a/business/partner/purchase/im/im_server.go +++ b/business/partner/purchase/im/im_server.go @@ -90,18 +90,18 @@ func PingTimer() { if conn.ClientType == ClientTypeJx { if err := conn.Socket.WriteControl(websocket.PingMessage, []byte{}, time.Now().Add(time.Second)); err != nil { Manager.DisConnect <- conn - globals.SugarLogger.Debugf("发送心跳失败: %s 总连接数:%d", clientId, Manager.Count()) + fmt.Printf("发送心跳失败: %s 总连接数:%d", clientId, Manager.Count()) } if err := ConnRender(conn.Socket, renderData{ClientId: clientId}); err != nil { return } } else { if err := conn.Socket.WriteMessage(websocket.TextMessage, []byte(HeartCheckMsg)); err != nil { + fmt.Printf("PingTimer mtHeartBeat err:%v", err) //对美团重新建立连接 MtInit() } } - //globals.SugarLogger.Debugf("发送心跳 clientId=%s,i=%d", clientId, i) } } }() @@ -114,11 +114,11 @@ func WriteMessage() { clientInfo := <-ToClientChan //广播发送通知所有京西客户端 i++ - fmt.Printf("WriteMessage clientInfo=%s i=%d", utils.Format4Output(clientInfo, false), i) + fmt.Printf("WriteMessage clientInfo=%s i=%d\n", utils.Format4Output(clientInfo, false), i) if Manager.AllClient() != nil { for _, conn := range Manager.AllClient() { if conn.ClientType == ClientTypeJx { //只发送给京西 - globals.SugarLogger.Debugf("WriteMessage conn.ClientId=%s", conn.ClientId) + fmt.Printf("WriteMessage conn.ClientId=%s\n", conn.ClientId) if err := Render(conn.Socket, clientInfo.MessageId, clientInfo.Code, clientInfo.Msg, clientInfo.Data); err != nil { Manager.DisConnect <- conn } @@ -128,11 +128,6 @@ func WriteMessage() { globals.SugarLogger.Debugf("无客户端连接,请检查") return } - //if conn, err := Manager.GetByClientId(clientInfo.ClientId); err == nil && conn != nil { - // if err := Render(conn.Socket, clientInfo.MessageId, clientInfo.Code, clientInfo.Msg, clientInfo.Data); err != nil { - // Manager.DisConnect <- conn - // } - //} } } @@ -155,8 +150,8 @@ func (c *Client) Read() { go func() { for { messageType, msg, err := c.Socket.ReadMessage() - temp := string(msg) - fmt.Print(temp) + //temp := string(msg) + //fmt.Print(temp) if err != nil { if messageType == -1 && websocket.IsCloseError(err, websocket.CloseGoingAway, websocket.CloseNormalClosure, websocket.CloseNoStatusReceived) { Manager.DisConnect <- c @@ -165,6 +160,7 @@ func (c *Client) Read() { return } } + fmt.Printf("Client Read:receive: %s\n", string(msg)) SendToVendor(msg) } }() diff --git a/globals/beegodb/beegodb.go b/globals/beegodb/beegodb.go index b2b3d56a8..d2590df44 100644 --- a/globals/beegodb/beegodb.go +++ b/globals/beegodb/beegodb.go @@ -6,25 +6,24 @@ import ( "git.rosy.net.cn/jx-callback/business/model/legacymodel" "git.rosy.net.cn/jx-callback/globals" "github.com/astaxie/beego/client/orm" - "github.com/astaxie/beego/server/web" ) func Init() { // set default database // orm.RegisterDataBase(aliasName, driverName, dataSource, params) //正式服务器 - orm.RegisterDataBase("default", "mysql", web.AppConfig.DefaultString("dbConnectStr", "")) - orm.RegisterDataBase("c4beta", "mysql", "ubuntu:WebServer@1@tcp(111.231.218.230:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true") - orm.RegisterDataBase("api", "mysql", "root:WebServer@1@tcp(127.0.0.1:3306)/api?charset=utf8mb4&loc=Local&parseTime=true") + //orm.RegisterDataBase("default", "mysql", web.AppConfig.DefaultString("dbConnectStr", "")) + //orm.RegisterDataBase("c4beta", "mysql", "ubuntu:WebServer@1@tcp(111.231.218.230:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true") + //orm.RegisterDataBase("api", "mysql", "root:WebServer@1@tcp(127.0.0.1:3306)/api?charset=utf8mb4&loc=Local&parseTime=true") // 本地测试服调试 // orm.RegisterDataBase("default", "mysql", web.AppConfig.DefaultString("dbConnectStr", "")) //orm.RegisterDataBase("api", "mysql", "root:WebServer@1@tcp(127.0.0.1:3306)/api?charset=utf8mb4&loc=Local&parseTime=true") //orm.RegisterDataBase("c4beta", "mysql", "ubuntu:WebServer@1@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true") //本地服务器测试用 -ysq - //orm.RegisterDataBase("default", "mysql", "root:123456@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true") - //orm.RegisterDataBase("c4beta", "mysql", "root:123456@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true") - //orm.RegisterDataBase("api", "mysql", "root:123456@tcp(127.0.0.1:3306)/api?charset=utf8mb4&loc=Local&parseTime=true") + orm.RegisterDataBase("default", "mysql", "root:123456@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true") + orm.RegisterDataBase("c4beta", "mysql", "root:123456@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true") + orm.RegisterDataBase("api", "mysql", "root:123456@tcp(127.0.0.1:3306)/api?charset=utf8mb4&loc=Local&parseTime=true") // 开启sql打印 //orm.Debug = true From 21bf52219430c25733f0ffdbc08bb6d3d410082c Mon Sep 17 00:00:00 2001 From: richboo111 Date: Thu, 11 May 2023 18:23:46 +0800 Subject: [PATCH 2/5] 1 --- business/jxstore/misc/misc.go | 8 ++++---- globals/beegodb/beegodb.go | 13 +++++++------ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index bcb2702de..db2cbff27 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -77,8 +77,8 @@ var ( "16:00:00", "17:00:00", "18:00:00", - "19:00:00", - "22:00:00", + //"19:00:00", + //"22:00:00", } ChangeStoreSkuSaleStatusList = []string{ "7:00:00", @@ -93,8 +93,8 @@ var ( "16:00:00", "17:00:00", "18:00:00", - "19:00:00", - "20:00:00", + //"19:00:00", + //"20:00:00", } openRemoteStoreTimeList = []string{ "04:30:00", diff --git a/globals/beegodb/beegodb.go b/globals/beegodb/beegodb.go index d2590df44..b2b3d56a8 100644 --- a/globals/beegodb/beegodb.go +++ b/globals/beegodb/beegodb.go @@ -6,24 +6,25 @@ import ( "git.rosy.net.cn/jx-callback/business/model/legacymodel" "git.rosy.net.cn/jx-callback/globals" "github.com/astaxie/beego/client/orm" + "github.com/astaxie/beego/server/web" ) func Init() { // set default database // orm.RegisterDataBase(aliasName, driverName, dataSource, params) //正式服务器 - //orm.RegisterDataBase("default", "mysql", web.AppConfig.DefaultString("dbConnectStr", "")) - //orm.RegisterDataBase("c4beta", "mysql", "ubuntu:WebServer@1@tcp(111.231.218.230:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true") - //orm.RegisterDataBase("api", "mysql", "root:WebServer@1@tcp(127.0.0.1:3306)/api?charset=utf8mb4&loc=Local&parseTime=true") + orm.RegisterDataBase("default", "mysql", web.AppConfig.DefaultString("dbConnectStr", "")) + orm.RegisterDataBase("c4beta", "mysql", "ubuntu:WebServer@1@tcp(111.231.218.230:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true") + orm.RegisterDataBase("api", "mysql", "root:WebServer@1@tcp(127.0.0.1:3306)/api?charset=utf8mb4&loc=Local&parseTime=true") // 本地测试服调试 // orm.RegisterDataBase("default", "mysql", web.AppConfig.DefaultString("dbConnectStr", "")) //orm.RegisterDataBase("api", "mysql", "root:WebServer@1@tcp(127.0.0.1:3306)/api?charset=utf8mb4&loc=Local&parseTime=true") //orm.RegisterDataBase("c4beta", "mysql", "ubuntu:WebServer@1@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true") //本地服务器测试用 -ysq - orm.RegisterDataBase("default", "mysql", "root:123456@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true") - orm.RegisterDataBase("c4beta", "mysql", "root:123456@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true") - orm.RegisterDataBase("api", "mysql", "root:123456@tcp(127.0.0.1:3306)/api?charset=utf8mb4&loc=Local&parseTime=true") + //orm.RegisterDataBase("default", "mysql", "root:123456@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true") + //orm.RegisterDataBase("c4beta", "mysql", "root:123456@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true") + //orm.RegisterDataBase("api", "mysql", "root:123456@tcp(127.0.0.1:3306)/api?charset=utf8mb4&loc=Local&parseTime=true") // 开启sql打印 //orm.Debug = true From fdef98fb4b25c9d282bbc55f8b67c214acf5d4be Mon Sep 17 00:00:00 2001 From: richboo111 Date: Fri, 12 May 2023 09:01:35 +0800 Subject: [PATCH 3/5] 1 --- business/jxstore/misc/misc.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index db2cbff27..a665f25db 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -77,22 +77,22 @@ var ( "16:00:00", "17:00:00", "18:00:00", - //"19:00:00", - //"22:00:00", + "19:00:00", + "22:00:00", } ChangeStoreSkuSaleStatusList = []string{ "7:00:00", "8:00:00", "9:00:00", - "10:00:00", - "11:00:00", - "12:00:00", - "13:00:00", - "14:00:00", - "15:00:00", - "16:00:00", - "17:00:00", - "18:00:00", + //"10:00:00", + //"11:00:00", + //"12:00:00", + //"13:00:00", + //"14:00:00", + //"15:00:00", + //"16:00:00", + //"17:00:00", + //"18:00:00", //"19:00:00", //"20:00:00", } From 59d62adb3f6db1582cadfc949c37d90178ea877d Mon Sep 17 00:00:00 2001 From: richboo111 Date: Fri, 12 May 2023 15:47:50 +0800 Subject: [PATCH 4/5] 1 --- .../jxcallback/auto_delivery/auto_delivery.go | 7 +- business/partner/purchase/im/im.go | 94 ++++++++++--------- business/partner/purchase/im/im_model.go | 7 +- 3 files changed, 55 insertions(+), 53 deletions(-) diff --git a/business/jxcallback/auto_delivery/auto_delivery.go b/business/jxcallback/auto_delivery/auto_delivery.go index 424a6bccb..19a386d42 100644 --- a/business/jxcallback/auto_delivery/auto_delivery.go +++ b/business/jxcallback/auto_delivery/auto_delivery.go @@ -3,6 +3,9 @@ package auto_delivery import ( "crypto/rand" "encoding/json" + "math/big" + "strings" + "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/jxcallback/scheduler/defsch" "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext" @@ -10,8 +13,6 @@ import ( "git.rosy.net.cn/jx-callback/business/model/dao" "git.rosy.net.cn/jx-callback/business/partner" "git.rosy.net.cn/jx-callback/globals" - "math/big" - "strings" ) var riderListInfo = make(map[string][]map[string]string, 0) @@ -129,6 +130,8 @@ func AutoSettingFakeDelivery() { return } } + globals.SugarLogger.Debug("==========%s,%d", riderKey, len(riderListInfo[riderKey])) + globals.SugarLogger.Debug("==========%s", utils.Format4Output(riderListInfo[riderKey], false)) randNumber, _ := rand.Int(rand.Reader, big.NewInt(int64(len(riderListInfo[riderKey])))) randTime := randNumber.Int64() if randTime < 0 { diff --git a/business/partner/purchase/im/im.go b/business/partner/purchase/im/im.go index c5e71be31..aa16a6ffd 100644 --- a/business/partner/purchase/im/im.go +++ b/business/partner/purchase/im/im.go @@ -137,44 +137,44 @@ func MtInit() { }, url.ClientIDMain) //副连接 - //if url.UrlSub != "" { - // jxutils.CallMsgHandlerAsync(func() { - // connSub, respSub, errSub := websocket.DefaultDialer.Dial(url.UrlSub, nil) - // if errSub != nil || respSub.StatusCode != 101 { - // fmt.Printf("连接失败:%v http响应不成功", errSub) - // } - // - // //关闭 - // defer func(conn *websocket.Conn) { - // err := conn.Close() - // if err != nil { - // return - // } - // }(connSub) - // - // //client连接事件 - // client := NewClient(url.ClientIDSub, connSub, ClientTypeMt) - // Manager.Connect <- client - // - // errSub = connSub.WriteMessage(websocket.TextMessage, data) - // if errSub != nil { - // fmt.Println(errSub) - // } - // - // for { - // _, msg, err := connSub.ReadMessage() - // temp := string(msg) - // res := JsonCommon(HeartCheckSuccess) - // if err != nil || temp == res { - // break - // } else { - // ReadMsgFromVendor(VendorIDMT, "", msg) - // } - // fmt.Printf("MtInit %s connSub:receive: %s\n", connSub.RemoteAddr(), string(msg)) - // } - // - // }, url.ClientIDSub) - //} + if url.UrlSub != "" { + jxutils.CallMsgHandlerAsync(func() { + connSub, respSub, errSub := websocket.DefaultDialer.Dial(url.UrlSub, nil) + if errSub != nil || respSub.StatusCode != 101 { + fmt.Printf("连接失败:%v http响应不成功", errSub) + } + + //关闭 + defer func(conn *websocket.Conn) { + err := conn.Close() + if err != nil { + return + } + }(connSub) + + //client连接事件 + client := NewClient(url.ClientIDSub, connSub, ClientTypeMt) + Manager.Connect <- client + + errSub = connSub.WriteMessage(websocket.TextMessage, data) + if errSub != nil { + fmt.Println(errSub) + } + + for { + _, msg, err := connSub.ReadMessage() + temp := string(msg) + res := JsonCommon(HeartCheckSuccess) + if err != nil || temp == res { + break + } else { + ReadMsgFromVendor(VendorIDMT, "", msg) + } + fmt.Printf("MtInit %s connSub:receive: %s\n", connSub.RemoteAddr(), string(msg)) + } + + }, url.ClientIDSub) + } } @@ -213,7 +213,7 @@ func ReadMsgFromClient(vendorID int, elmAppID string, msg interface{}) { MsgContent: ElmData, } userList = &UserMessageList{ - VendorID: VendorIDMT, + VendorID: VendorIDELM, UserID: ElmData.PayLoad.GroupID, LatestMsg: ElmData.PayLoad.Content, LatestTime: int(ElmData.PayLoad.CreateTime), @@ -266,7 +266,7 @@ func ReadMsgFromVendor(vendorID int, elmAppID string, msg []byte) { MsgContent: ElmData, } userList = &UserMessageList{ - VendorID: VendorIDMT, + VendorID: VendorIDELM, UserID: ElmData.PayLoad.GroupID, LatestMsg: ElmData.PayLoad.Content, LatestTime: int(ElmData.PayLoad.CreateTime), @@ -286,7 +286,11 @@ func ReadMsgFromVendor(vendorID int, elmAppID string, msg []byte) { //3 cid推送新消息 err = PushMsgByCid(vendorStoreID, vendorID) //4 长链接通知给客户端 - ToClientChan <- clientInfo{Code: SuccessCode, Msg: fmt.Sprintf("%v", err), Data: jxMsg} + if err != nil { + ToClientChan <- clientInfo{Code: SuccessCode, Msg: fmt.Sprintf("%v", err), Data: jxMsg} + } else { + ToClientChan <- clientInfo{Code: SuccessCode, Msg: SuccessMsg, Data: jxMsg} + } return } @@ -365,11 +369,11 @@ func GetNewAndTrim(key string, flag string) (cnt int, err error) { func GenMsgDetailID(jxMsg *JXMsg, vendorID int, elmAppID string) (msgID string) { if vendorID == VendorIDMT { var d1 = jxMsg.MsgContent.(mtwmapi.SingleChat) - msgID = utils.Int2Str(d1.AppID) + ":" + d1.AppPoiCode + ":10:" + utils.Int2Str(d1.OpenUserID) + msgID = utils.Int2Str(d1.AppID) + ":" + d1.AppPoiCode + ":1:" + utils.Int2Str(d1.OpenUserID) } if vendorID == VendorIDELM { var d2 = jxMsg.MsgContent.(ebaiapi.ImMessageSend) - msgID = elmAppID + ":" + d2.PlatformShopID + ":11:" + d2.PayLoad.GroupID + msgID = elmAppID + ":" + d2.PlatformShopID + ":3:" + d2.PayLoad.GroupID } return msgID } @@ -378,11 +382,11 @@ func GenMsgDetailID(jxMsg *JXMsg, vendorID int, elmAppID string) (msgID string) func GenMsgListID(jxMsg *JXMsg, vendorID int, elmAppID string) (msgID string) { if vendorID == VendorIDMT { var d1 = jxMsg.MsgContent.(mtwmapi.SingleChat) - msgID = utils.Int2Str(d1.AppID) + ":" + d1.AppPoiCode + ":10" + msgID = utils.Int2Str(d1.AppID) + ":" + d1.AppPoiCode + ":1" } if vendorID == VendorIDELM { var d2 = jxMsg.MsgContent.(ebaiapi.ImMessageSend) - msgID = elmAppID + ":" + d2.PlatformShopID + ":11" + msgID = elmAppID + ":" + d2.PlatformShopID + ":3" } return msgID } diff --git a/business/partner/purchase/im/im_model.go b/business/partner/purchase/im/im_model.go index 018c76f98..d69edcaa9 100644 --- a/business/partner/purchase/im/im_model.go +++ b/business/partner/purchase/im/im_model.go @@ -82,13 +82,8 @@ type commonConf struct { // SendData 客户端写入参数 type SendData struct { - //ClientId string `json:"clientId" validate:"required"` //链接ID - VendorID int `json:"vendorID"` //消息来源平台ID 10-美团 11-饿了么 + VendorID int `json:"vendorID"` //消息来源平台ID 1-美团 3-饿了么 Data interface{} `json:"data"` //发送给平台 美团/饿了么消息结构体 - //返回值 - //Code int `json:"code"` - //Msg string `json:"msg"` - //SendUserId string `json:"sendUserId"` } // JXMsg 京西消息结构体 From d72d5dc75d2a1142dcc20e9fceb125826dab6c7c Mon Sep 17 00:00:00 2001 From: richboo111 Date: Mon, 15 May 2023 09:18:08 +0800 Subject: [PATCH 5/5] 1 --- business/partner/purchase/im/im.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/business/partner/purchase/im/im.go b/business/partner/purchase/im/im.go index aa16a6ffd..5e8fd4d02 100644 --- a/business/partner/purchase/im/im.go +++ b/business/partner/purchase/im/im.go @@ -238,10 +238,10 @@ func ReadMsgFromVendor(vendorID int, elmAppID string, msg []byte) { return } var ( - err error - vendorStoreID string - jxMsg = &JXMsg{} - userList = &UserMessageList{} + err error + //vendorStoreID string + jxMsg = &JXMsg{} + userList = &UserMessageList{} ) if vendorID == VendorIDMT { var MtSingleChat = mtwmapi.SingleChat{} @@ -256,7 +256,7 @@ func ReadMsgFromVendor(vendorID int, elmAppID string, msg []byte) { LatestMsg: MtSingleChat.MsgContent, LatestTime: MtSingleChat.Cts, } - vendorStoreID = MtSingleChat.AppPoiCode + //vendorStoreID = MtSingleChat.AppPoiCode } if vendorID == VendorIDELM { var ElmData = ebaiapi.ImMessageSend{} @@ -284,7 +284,7 @@ func ReadMsgFromVendor(vendorID int, elmAppID string, msg []byte) { //return } //3 cid推送新消息 - err = PushMsgByCid(vendorStoreID, vendorID) + //err = PushMsgByCid(vendorStoreID, vendorID) //4 长链接通知给客户端 if err != nil { ToClientChan <- clientInfo{Code: SuccessCode, Msg: fmt.Sprintf("%v", err), Data: jxMsg}