From 61a35f19c07132615bbed431fe964f2877b43b7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Wed, 17 Dec 2025 16:48:55 +0800 Subject: [PATCH] 1 --- platformapi/jdapi/im.go | 3 +- platformapi/jdapi/im_model.go | 79 +++++++++++++++++++++++------- platformapi/jdapi/im_test.go | 13 ++++- platformapi/mtwmapi/retail.go | 6 +++ platformapi/mtwmapi/retail_test.go | 6 +-- 5 files changed, 84 insertions(+), 23 deletions(-) diff --git a/platformapi/jdapi/im.go b/platformapi/jdapi/im.go index e4a027df..373fe780 100644 --- a/platformapi/jdapi/im.go +++ b/platformapi/jdapi/im.go @@ -17,7 +17,7 @@ const ( //#region im信息推送相关 // ImStatusModify 开启全平台或者单门店im通知 -func (a *API) ImStatusModify(waiterPin, stationId string, typePattern int, status bool) error { +func (a *API) ImStatusModify(stationId string, typePattern int, status bool) error { parameter := map[string]interface{}{ "stationId": stationId, "type": typePattern, @@ -78,6 +78,7 @@ func ImChatRiskMsg(request *http.Request) (back []byte, url string, err error) { valuesMap := utils.URLValues2Map(values) return utils.MustMarshal(valuesMap), msgURL, err } + func ImMsgChange(msg *JdParamJsonObj, msgURL string) (info *ChatRisInfo, user *UserChatMsg, read *UserMsgReadAck, err error) { var msgContext *ChatRisInfo var userMsg *UserChatMsg diff --git a/platformapi/jdapi/im_model.go b/platformapi/jdapi/im_model.go index ec264850..a671ed6a 100644 --- a/platformapi/jdapi/im_model.go +++ b/platformapi/jdapi/im_model.go @@ -11,6 +11,18 @@ type ContextTo struct { App string `json:"app"` // im.customer 固定值 } +// ContextMsg 消息发送接口 - 向用户发送在线消息 +type ContextMsg struct { + Id string `json:"id"` // uuid 随机生成字符串 + Lang string `json:"lang"` // 固定值 zh_CN + Type string `json:"type"` // 固定值 chat_message + From ContextFrom `json:"from"` + To ContextTo `json:"to"` + Body ContextBody `json:"body"` + Timestamp int64 `json:"timestamp"` + ClientTime int64 `json:"clientTime"` +} + type ContextBody struct { Type string `json:"type"` // 消息类型,根据需求场景 Content string `json:"content"` // 字符型,必须。文本消息内容。 @@ -27,19 +39,6 @@ type ContextBodyChatInfo struct { Source string `json:"source"` // dd_msg_产品线标识_消息标识“ 必传 } -// ContextMsg 消息发送接口 - 向用户发送在线消息 -type ContextMsg struct { - Id string `json:"id"` // uuid 随机生成字符串 - Lang string `json:"lang"` // 固定值 zh_CN - Type string `json:"type"` // 固定值 chat_message - From ContextFrom `json:"from"` - To ContextTo `json:"to"` - //Body ContextBody `json:"body"` - Body interface{} `json:"body"` - Timestamp int64 `json:"timestamp"` - ClientTime int64 `json:"clientTime"` -} - type BaseInfo struct { AppKey string `json:"app_key"` Token string `json:"token"` @@ -51,8 +50,8 @@ type BaseInfo struct { } type JdParamJsonObj struct { - StatusId string `json:"statusId"` - BillId string `json:"billId"` + StatusId string `json:"statusId"` // 由于推送消息不含有次参数,存储的为jxid + BillId string `json:"billId"` // 由于推送消息不含有次参数,存储的为平台id320406 ExtendJsonData string `json:"extendJsonData"` StoreId string `json:"storeId"` Timestamp string `json:"timestamp"` @@ -93,9 +92,53 @@ type UserChatMsg struct { App string `json:"app"` // 接收消息的app ClientType string `json:"clientType"` // 接收消息的终端" } `json:"to"` - Body interface{} `json:"body"` - Timestamp int64 `json:"timestamp"` - ClientTime int64 `json:"clientTime"` + Body UserChatMsgBody `json:"body"` + Timestamp int64 `json:"timestamp"` + ClientTime int64 `json:"clientTime"` +} + +type UserChatMsgBody struct { + Chatinfo struct { + IMService bool `json:"IMService"` + AppId string `json:"appId"` + AskAllocateType string `json:"askAllocateType"` + AskType string `json:"askType"` + DdSessionType string `json:"ddSessionType"` + DeviceNo string `json:"deviceNo"` + DisputeId int `json:"disputeId"` + DistinguishPersonJimi int `json:"distinguishPersonJimi"` + Eidtoken string `json:"eidtoken"` + Entry string `json:"entry"` + FirstMsg bool `json:"firstMsg"` + IsJdSuperMarket string `json:"isJdSuperMarket"` + Label int `json:"label"` + LeaveMsgTable int `json:"leaveMsgTable"` + OGroupId int `json:"oGroupId"` + OSid string `json:"oSid"` + ProVer string `json:"proVer"` + Region string `json:"region"` + RepeatConsult int `json:"repeatConsult"` + RepeatHuman int `json:"repeatHuman"` + Sid string `json:"sid"` + Source string `json:"source"` + StoreId string `json:"storeId"` + SystemVer string `json:"systemVer"` + VenderId string `json:"venderId"` + VenderName string `json:"venderName"` + Verification string `json:"verification"` + } `json:"chatinfo"` + Content string `json:"content"` + LlmStream int `json:"llmStream"` + Param struct { + Ref string `json:"$ref"` + } `json:"param"` + RequestData struct { + Entry string `json:"entry"` + VenderId string `json:"venderId"` + } `json:"requestData"` + Sid string `json:"sid"` + Thumbnail string `json:"thumbnail"` + Type string `json:"type"` } // UserMsgReadAck 已读消息推送 diff --git a/platformapi/jdapi/im_test.go b/platformapi/jdapi/im_test.go index d20df24b..aa13686f 100644 --- a/platformapi/jdapi/im_test.go +++ b/platformapi/jdapi/im_test.go @@ -19,10 +19,21 @@ func Test12(t *testing.T) { // TestImStatusModify 开启关闭门店im func TestImStatusModify(t *testing.T) { - api.ImStatusModify("", "19854102+320406", 0, true) + api.ImStatusModify("19854102+320406", 0, true) } // TestImWaiterStatusModify 设置门店im在想状态 func TestImWaiterStatusModify(t *testing.T) { api.ImWaiterStatusModify(1, "19854102", 1) } + +func TestImMsgChange(t *testing.T) { + data := &JdParamJsonObj{ + StatusId: "", + BillId: "320406", + ExtendJsonData: "{\"ver\":\"4.2\",\"fromChannelId\":-1,\"mid\":376841421,\"body\":{\"chatinfo\":{\"venderId\":\"store_10352814_1000051632\",\"firstMsg\":true,\"source\":\"jimitwo_service_smart_sdk\",\"IMService\":false,\"repeatConsult\":1,\"sid\":\"8b457541accd5e63eb4845f94c4852e8\",\"oGroupId\":113057083,\"askType\":\"o2o\",\"appId\":\"im.waiter\",\"verification\":\"slide\",\"repeatHuman\":1,\"isJdSuperMarket\":\"0\",\"deviceNo\":\"dd_dvc_aes_73FF2098F02392E999FE00A26817AE212E55DF89C9D405370B4B09A908F3A355\",\"label\":1,\"storeId\":\"1000051632\",\"oSid\":\"9ec16e789610328114db937025384666\",\"distinguishPersonJimi\":2,\"proVer\":\"smart_android_15.2.90\",\"entry\":\"sdk_recent\",\"askAllocateType\":\"multiChat\",\"leaveMsgTable\":1,\"venderName\":\"京西菜市-新都三河店\",\"disputeId\":-1,\"ddSessionType\":\"1\",\"systemVer\":\"android_12_BRA-AL00\",\"eidtoken\":\"jdd01SVZE72NCBZ6AXTRFHLIRLNUSF25PCOYF4OPNU3BOITK5SR62TUHMBIDGFBOYGQ7TWY7WRDPLHA3LP6NME42NE5IQNXASKIGJA6ULRAI01234567\",\"region\":\"CN\"},\"llmStream\":0,\"thumbnail\":\"\",\"param\":{\"$ref\":\"$.body.chatinfo\"},\"type\":\"text\",\"requestData\":{\"entry\":\"sdk_recent\",\"venderId\":\"store_10352814_1000051632\"},\"content\":\"低处不胜暖\",\"sid\":\"8b457541accd5e63eb4845f94c4852e8\"},\"type\":\"chat_message\",\"clientTime\":1765873013013,\"datetime\":1765873013299,\"len\":0,\"from\":{\"app\":\"im.customer\",\"art\":\"\",\"clientType\":\"android\",\"pin\":\"jd_52db6569f724f\"},\"subType\":\"text\",\"id\":\"bdf9475389e94265835d90c41912629c\",\"to\":{\"app\":\"im.waiter\",\"pin\":\"liyang12345ly\"},\"lang\":\"zh_CN\",\"timestamp\":1765873013299}", + StoreId: "11998833", + Timestamp: "2025-12-16 16:16:53", + } + ImMsgChange(data, "msChatMessage") +} diff --git a/platformapi/mtwmapi/retail.go b/platformapi/mtwmapi/retail.go index 143018cb..26a6245b 100644 --- a/platformapi/mtwmapi/retail.go +++ b/platformapi/mtwmapi/retail.go @@ -292,6 +292,12 @@ func handleRetailBatchResultByRegexp(result interface{}) (failedFoodList []*AppF // https://developer.waimai.meituan.com/home/myquestionDetail/6716 // 另外这个接口即使不指定operate_type为1,也可能报错:”商品spu名称在该店内分类中已存在“,原因就是已经存在两个相同的SKU了 func (a *API) RetailInitData(trackInfo, poiCode, foodCode string, params map[string]interface{}) (err error) { + if poiCode == "18698027" { + globals.SugarLogger.Debugf("--------poiCode%s", poiCode) + globals.SugarLogger.Debugf("--------foodCode%s", foodCode) + globals.SugarLogger.Debugf("--------params:%s", utils.Format4Output(params, false)) + + } _, err = a.AccessAPI2("retail/initdata", false, utils.MergeMaps(map[string]interface{}{ KeyAppPoiCode: poiCode, KeyAppFoodCode: foodCode, diff --git a/platformapi/mtwmapi/retail_test.go b/platformapi/mtwmapi/retail_test.go index aaefd94a..33c3e697 100644 --- a/platformapi/mtwmapi/retail_test.go +++ b/platformapi/mtwmapi/retail_test.go @@ -194,8 +194,8 @@ func TestMap(t *testing.T) { } func TestRetailDat(t *testing.T) { - err := api.RetailInitData("F71D0F0881A211ED9D81525400E86DC0", "26207799", "mtcode_1808750374413807658", map[string]interface{}{ - "app_food_code": "mtcode_1808750374413807658", + err := api.RetailInitData("F71D0F0881A211ED9D81525400E86DC0", "18698027", "25008", map[string]interface{}{ + "app_food_code": "25008", "category_name": "活动", "common_attr_value": "[{\"attrId\":1200000135,\"attrName\":\"包装方式\",\"valueList\":[{\"setValue\":true,\"setValueId\":true,\"value\":\"散装\",\"valueId\":1300000232}]},{\"attrId\":1200000202,\"attrName\":\"品种\",\"valueList\":[{\"setValue\":true,\"setValueId\":true,\"value\":\"韭菜\",\"valueId\":1300003045}]}]", "description": "", @@ -361,7 +361,7 @@ func TestRetailSellStatus2(t *testing.T) { //根据分类id查询属性列表 func TestCategoryAttrList(t *testing.T) { //result, err := api.CategoryAttrList(200002680) - result, err := api.CategoryAttrList(400000717) + result, err := api.CategoryAttrList(200002794) if err != nil { t.Fatal(err) }