From 6f23ade2503e6c9a81fc5ac7e4497f7bba5aee8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Wed, 8 Jan 2025 13:51:09 +0800 Subject: [PATCH] 1 --- controllers/ebai_callback.go | 45 +++++++++++++++++++--------------- controllers/mtwm_callback.go | 47 ++++++++++++++++++++++-------------- 2 files changed, 54 insertions(+), 38 deletions(-) diff --git a/controllers/ebai_callback.go b/controllers/ebai_callback.go index 62d02c535..1e780fbf6 100644 --- a/controllers/ebai_callback.go +++ b/controllers/ebai_callback.go @@ -4,9 +4,11 @@ import ( "encoding/json" "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/model" + "git.rosy.net.cn/jx-callback/business/model/dao" "io/ioutil" "net/http" "strings" + "sync" "git.rosy.net.cn/baseapi/platformapi/ebaiapi" "git.rosy.net.cn/jx-callback/business/partner/purchase/ebai" @@ -18,30 +20,33 @@ type EbaiController struct { web.Controller } +var EBaiVendorStoreIDList = new(sync.Map) + func (c *EbaiController) Msg() { if c.Ctx.Input.Method() == http.MethodPost { obj, callbackResponse := api.EbaiAPI.GetCallbackMsg(c.Ctx.Request) if callbackResponse == nil { - //vendorStoreId, _ := utils.TryInterface2Int64(obj.Body["platform_shop_id"]) - //if vendorStoreId != 0 { - // storeDetail, _ := dao.GetStoreDetailByVendorStoreID(dao.GetDB(), utils.Int64ToStr(vendorStoreId), model.VendorIDEBAI, "") - // if storeDetail == nil { - // globals.SugarLogger.Debugf("-----饿百订单非菜市消息推送-%s", utils.Format4Output(obj, false)) - // switch web.BConfig.RunMode { - // case model.ServerTypeVegetable: - // callbackResponse = c.EBaiMsgPush2FruitsOrPet(model.ServerTypeFruits, utils.Struct2Map(obj, "", false)) - // case model.ServerTypeFruits: - // callbackResponse = c.EBaiMsgPush2FruitsOrPet(model.ServerTypePet, utils.Struct2Map(obj, "", false)) - // case model.ServerTypePet: - // //ddmsg.SendUserMessage(dingdingapi.MsgTyeText, "47B1E94E8D2411EFB666525400E86DC0", "饿了么菜市推果园,果园退超市未找到门店", fmt.Sprintf("饿了么菜市推果园cmd:%s,storeId:%s", obj.Cmd, vendorStoreId)) - // callbackResponse = api.EbaiAPI.Err2CallbackResponse(ebaiapi.GetCmd(c.Ctx.Request), nil, nil) // api.EbaiAPI.Err2CallbackResponse(ebaiapi.GetCmd(c.Ctx.Request), fmt.Errorf("饿了么菜市推果园,果园退超市未找到门店cmd:%s,storeId:%s", obj.Cmd, vendorStoreId), nil) - // return - // } - // c.Data["json"] = callbackResponse - // c.ServeJSON() - // return - // } - //} + vendorStoreId, _ := utils.TryInterface2Int64(obj.Body["platform_shop_id"]) + if _, have := EBaiVendorStoreIDList.Load(vendorStoreId); vendorStoreId != 0 && !have { + storeDetail, _ := dao.GetStoreDetailByVendorStoreID(dao.GetDB(), utils.Int64ToStr(vendorStoreId), model.VendorIDEBAI, "") + if storeDetail == nil { + switch web.BConfig.RunMode { + case model.ServerTypeVegetable: + callbackResponse = c.EBaiMsgPush2FruitsOrPet(model.ServerTypeFruits, utils.Struct2Map(obj, "", false)) + case model.ServerTypeFruits: + callbackResponse = c.EBaiMsgPush2FruitsOrPet(model.ServerTypePet, utils.Struct2Map(obj, "", false)) + case model.ServerTypePet: + //ddmsg.SendUserMessage(dingdingapi.MsgTyeText, "47B1E94E8D2411EFB666525400E86DC0", "饿了么菜市推果园,果园退超市未找到门店", fmt.Sprintf("饿了么菜市推果园cmd:%s,storeId:%s", obj.Cmd, vendorStoreId)) + callbackResponse = api.EbaiAPI.Err2CallbackResponse(ebaiapi.GetCmd(c.Ctx.Request), nil, nil) // api.EbaiAPI.Err2CallbackResponse(ebaiapi.GetCmd(c.Ctx.Request), fmt.Errorf("饿了么菜市推果园,果园退超市未找到门店cmd:%s,storeId:%s", obj.Cmd, vendorStoreId), nil) + return + } + c.Data["json"] = callbackResponse + c.ServeJSON() + return + } else { + EBaiVendorStoreIDList.Store(vendorStoreId, model.YES) + } + } callbackResponse = ebai.OnCallbackMsg(obj) } if callbackResponse == nil { diff --git a/controllers/mtwm_callback.go b/controllers/mtwm_callback.go index 5d7541ed8..594c86e06 100644 --- a/controllers/mtwm_callback.go +++ b/controllers/mtwm_callback.go @@ -2,8 +2,12 @@ package controllers import ( "encoding/json" + "fmt" + "git.rosy.net.cn/baseapi/platformapi/dingdingapi" "git.rosy.net.cn/baseapi/platformapi/mtwmapi" + "git.rosy.net.cn/jx-callback/business/jxutils/ddmsg" "git.rosy.net.cn/jx-callback/business/model" + "git.rosy.net.cn/jx-callback/business/model/dao" "git.rosy.net.cn/jx-callback/business/partner/purchase/mtwm" "git.rosy.net.cn/jx-callback/globals/api" "github.com/astaxie/beego/server/web" @@ -11,6 +15,7 @@ import ( "net/http" "net/url" "strings" + "sync" "time" ) @@ -18,6 +23,8 @@ type MtwmController struct { web.Controller } +var MTWMVendorStoreIDMap = new(sync.Map) + func (c *MtwmController) onCallbackMsg(msgType string) { msg, callbackResponse := api.MtwmAPI.GetCallbackMsg(c.Ctx.Request) if callbackResponse == nil { @@ -30,24 +37,28 @@ func (c *MtwmController) onCallbackMsg(msgType string) { json.Unmarshal([]byte(msg.FormData.Get("pick_up_data")), &finishedPickup) vendorStoreId = finishedPickup.AppPoiCode } - //if vendorStoreId != "" { - // storeDetail, _ := dao.GetStoreDetailByVendorStoreID(dao.GetDB(), vendorStoreId, model.VendorIDMTWM, "") - // if storeDetail == nil { - // switch web.BConfig.RunMode { - // case model.ServerTypeVegetable, "dev": - // callbackResponse = pushMTWMOrder2GY(msg.FormData, msgType, model.ServerTypeFruits) - // case model.ServerTypeFruits: - // callbackResponse = pushMTWMOrder2GY(msg.FormData, msgType, model.ServerTypePet) - // case model.ServerTypePet: - // //ddmsg.SendUserMessage(dingdingapi.MsgTyeText, "47B1E94E8D2411EFB666525400E86DC0", "美团菜市推果园,果园退超市未找到门店", fmt.Sprintf("美团菜市推果园cmd:%s,storeId:%s", msgType, vendorStoreId)) - // callbackResponse = mtwmapi.Err2CallbackResponse(nil, "") // mtwmapi.Err2CallbackResponse(fmt.Errorf("美团菜市推果园,果园退超市未找到门店cmd:%s,storeId:%s", msgType, vendorStoreId), "") - // return - // } - // c.Data["json"] = callbackResponse - // c.ServeJSON() - // return - // } - //} + if vendorStoreId == "" { + ddmsg.SendUserMessage(dingdingapi.MsgTyeText, "2452A93EEB9111EC9B06525400E86DC0", "美团菜市推果园,果园退超市未找到门店", fmt.Sprintf("美团菜市推果园,获取平台门店ID异常cmd:%s,storeId:%s", msgType, vendorStoreId)) + } + if _, have := MTWMVendorStoreIDMap.Load(vendorStoreId); vendorStoreId != "" && !have { + storeDetail, _ := dao.GetStoreDetailByVendorStoreID(dao.GetDB(), vendorStoreId, model.VendorIDMTWM, "") + if storeDetail == nil { + switch web.BConfig.RunMode { + case model.ServerTypeVegetable, "dev": + callbackResponse = pushMTWMOrder2GY(msg.FormData, msgType, model.ServerTypeFruits) + case model.ServerTypeFruits: + callbackResponse = pushMTWMOrder2GY(msg.FormData, msgType, model.ServerTypePet) + case model.ServerTypePet: + callbackResponse = mtwmapi.Err2CallbackResponse(nil, "") // mtwmapi.Err2CallbackResponse(fmt.Errorf("美团菜市推果园,果园退超市未找到门店cmd:%s,storeId:%s", msgType, vendorStoreId), "") + return + } + c.Data["json"] = callbackResponse + c.ServeJSON() + return + } else { + MTWMVendorStoreIDMap.Store(vendorStoreId, model.YES) + } + } callbackResponse = mtwm.OnCallbackMsg(msg, msgType) if callbackResponse == nil {