From 1ac29a0099cac6fcf314b31d2c8ad6edec7014ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Tue, 13 Jun 2023 16:38:00 +0800 Subject: [PATCH] 1 --- business/model/api_config.go | 1 + conf/app.conf | 5 ++++ controllers/taobao_vegetable.go | 42 +++++++++++++++++++++++---------- globals/api/api.go | 25 ++++++++++---------- 4 files changed, 48 insertions(+), 25 deletions(-) diff --git a/business/model/api_config.go b/business/model/api_config.go index 55db48d36..ce9ba80c5 100644 --- a/business/model/api_config.go +++ b/business/model/api_config.go @@ -23,6 +23,7 @@ const ( VendorIDTT = 13 // 抖音平台小程序 VendorIDDD = 14 // 抖店 VendorIDKS = 15 // 快手小程序 + VendorIDTaoVegetable = 16 // 淘先达(淘菜菜) VendorIDPurchaseEnd = 20 VendorIDWXPay = 51 // 微信支付 diff --git a/conf/app.conf b/conf/app.conf index 09f86c90e..fde73f8a2 100644 --- a/conf/app.conf +++ b/conf/app.conf @@ -22,6 +22,11 @@ mtwmCallbackURL2 = "http://callback.jxc4.com" tiktokShopAppId = "7136048270014416392" tiktokShopAppSecret = "c397aa9f-3927-47c4-8cfe-4d84e02602e0" +taoVegetableAppKey = "34402634" +taoVegetableSecret = "fda9a7045262e3aa1f26ca508a9be242" +taoVegetableServerUrl = "https://eco.taobao.com/router/rest" + + # mtwmCookieStr = "_lxsdk_cuid=16ddced5e9a95-0a65869c427a14-48714616-15f900-16ddced5e9b2b; _hc.v=cfebbfd1-79a7-9823-d8df-77e59646cb34.1571369610; _lxsdk=16ddced5e9a95-0a65869c427a14-48714616-15f900-16ddced5e9b2b; uuid_update=true; uuid=7b28e71504f5414e382b.1579155871.1.0.0; device_uuid=!64dedf83-b510-4910-8a31-b2b13d0bdd73; pushToken=00kRvxlerO15kB0dJFWDwYuctAoe04xGMNd0r3BqvLUA*; acctId=57396785; brandId=-1; wmPoiId=-1; isOfflineSelfOpen=0; city_id=0; isChain=1; existBrandPoi=true; ignore_set_router_proxy=true; region_id=; region_version=0; newCategory=false; bsid=OyqgRLyV54i9JKP0zRCI9jPyXc4UBU-6KReDAkPIwSlljhb97JPyFUIXfYQvhlJb6G1erzHQKbvtZ2pSWOYDxQ; cityId=510100; provinceId=510000; city_location_id=0; location_id=0; igateApp=shangouepc; wpush_server_url=wss://wpush.meituan.com; token=0MScAPaSa57iwRpgpCmGLf21tiA4yU4Uy-nDZlv8wNWs*; shopCategory=food; set_info=%7B%22wmPoiId%22%3A-1%2C%22ignoreSetRouterProxy%22%3Atrue%7D; JSESSIONID=105dgww27nsy6yfp68q7wmcni; LX_SC_CONSTANT=c_shangou_online_e_znrurnrc; _lxsdk_s=17041b590ac-3d-689-a8c%7C%7C15" autonaviKey = "ef64f638f31e05cb7bde28790f7309fe" diff --git a/controllers/taobao_vegetable.go b/controllers/taobao_vegetable.go index 38c4c7ec0..9dba0d81d 100644 --- a/controllers/taobao_vegetable.go +++ b/controllers/taobao_vegetable.go @@ -1,7 +1,12 @@ package controllers import ( + "fmt" + "git.rosy.net.cn/jx-callback/globals" + "git.rosy.net.cn/jx-callback/globals/api" "github.com/astaxie/beego/server/web" + "io/ioutil" + "net/http" ) type TaoBaoVegetableController struct { @@ -10,18 +15,29 @@ type TaoBaoVegetableController struct { // GetCode 淘菜菜获取商户授权code func (c *TaoBaoVegetableController) GetCode() { - //if c.Ctx.Input.Method() == http. - //body, err := ioutil.ReadAll(c.Ctx.Request.Body) - //globals.SugarLogger.Debug("商户收取code获取:%s",string(body)) - //if err != nil { - // return - //} - // - //var codeObj *tao_vegetable.ShopCode - //if err := json.Unmarshal(body,&codeObj);err != nil { - // return - //} - // - //if codeObj.ResponseType + codeData := "" + if c.Ctx.Input.Method() == http.MethodPost { + body, err := ioutil.ReadAll(c.Ctx.Request.Body) + if err != nil { + globals.SugarLogger.Debugf("商户收取code获取:%s,%s", string(body), err.Error()) + c.Data["json"] = MsgFail() + c.ServeJSON() + return + } + globals.SugarLogger.Debugf("商户收取code获取:%s", string(body)) + codeData = string(body) + } else { + codeData = c.Ctx.Input.Query("code") + } + tokenInfo, err := api.TaoVegetableApi.GetStoreToken(codeData, "") + if err != nil { + globals.SugarLogger.Debugf("获取门店token错误:%s", err.Error()) + c.Data["json"] = MsgFail() + c.ServeJSON() + return + } + fmt.Println(tokenInfo) + // 创建storeMap门店信息 + // 刷新token } diff --git a/globals/api/api.go b/globals/api/api.go index ddd3b633b..1d8fa245c 100644 --- a/globals/api/api.go +++ b/globals/api/api.go @@ -7,6 +7,7 @@ import ( "git.rosy.net.cn/baseapi/platformapi/kuaishou_mini" "git.rosy.net.cn/baseapi/platformapi/qywxapi" "git.rosy.net.cn/baseapi/platformapi/sfps2" + "git.rosy.net.cn/baseapi/platformapi/tao_vegetable" "git.rosy.net.cn/baseapi/platformapi/tiktok" tiktokShop "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/tiktok_api" "git.rosy.net.cn/baseapi/platformapi/trenditapi" @@ -120,18 +121,17 @@ var ( Cacher cache.ICacher SMSClient *aliyunsmsclient.SmsClient - TiktokApi *tiktok.API // 抖音api - TiktokJXDJApi *tiktok.API //抖音京西到家api - TiktokApiID string //抖音商城ID - TiktokJXDJApiID string //抖音京西到家ID - TiktokStore *tiktokShop.API // 抖店 - - EnterpriseChatHeadApi *enterprise.API // 企业微信api - EnterpriseChatMin *enterprise.API // 企业微信小程序api - - LogisticsApi *ali_logistics_query.API // 阿里云提供获取物流订单的配送信息 - KuaiShouApi *kuaishou_mini.API // 快手平台 - UniAppApi *uinapp.API // uinapp 消息通知 + TiktokApi *tiktok.API // 抖音api + TiktokJXDJApi *tiktok.API //抖音京西到家api + TiktokApiID string //抖音商城ID + TiktokJXDJApiID string //抖音京西到家ID + TiktokStore *tiktokShop.API // 抖店 + EnterpriseChatHeadApi *enterprise.API // 企业微信api + EnterpriseChatMin *enterprise.API // 企业微信小程序api + LogisticsApi *ali_logistics_query.API // 阿里云提供获取物流订单的配送信息 + KuaiShouApi *kuaishou_mini.API // 快手平台 + UniAppApi *uinapp.API // uinapp 消息通知 + TaoVegetableApi tao_vegetable.API // 淘菜菜 ) func init() { @@ -340,4 +340,5 @@ func Init() { EnterpriseChatMin = enterprise.NewMin("ww9a156bfa070e1857", "JQsEmSTltHhNgdPIT320YJFphiYmRs-YZa-rCBwplss") // 小程序 KuaiShouApi = kuaishou_mini.New(beego.AppConfig.DefaultString("kuaiShouAppSecret", ""), beego.AppConfig.DefaultString("kuaiShouAppId", "")) UniAppApi = uinapp.NewUinappApi(beego.AppConfig.DefaultString("uniAppAppId", ""), beego.AppConfig.DefaultString("uniAppAppKey", ""), beego.AppConfig.DefaultString("uniAppAppSecret", ""), beego.AppConfig.DefaultString("uniAppMasterSecret", "")) + TaoVegetableApi = tao_vegetable.NewTaoVegetable(beego.AppConfig.DefaultString("taoVegetableAppKey", ""), beego.AppConfig.DefaultString("taoVegetableSecret", ""), beego.AppConfig.DefaultString("taoVegetableServerUrl", "")) }