From 448525cd91ed2e240789dc73986ab0d1c0c76f01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 15 Jun 2023 10:40:08 +0800 Subject: [PATCH] 1 --- controllers/taobao_vegetable.go | 59 ++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/controllers/taobao_vegetable.go b/controllers/taobao_vegetable.go index 818c4b24c..a8d6f0acd 100644 --- a/controllers/taobao_vegetable.go +++ b/controllers/taobao_vegetable.go @@ -1,7 +1,12 @@ package controllers import ( + "git.rosy.net.cn/baseapi/utils" + "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 { @@ -9,30 +14,30 @@ type TaoBaoVegetableController struct { } // GetCode 淘菜菜获取商户授权code -//func (c *TaoBaoVegetableController) GetCode() { -// 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 -//} +func (c *TaoBaoVegetableController) GetCode() { + 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") + } + globals.SugarLogger.Debugf("code:%s", utils.Format4Output(codeData, false)) + tokenInfo, err := api.TaoVegetableApi.GetStoreToken(codeData, "") + if err != nil { + globals.SugarLogger.Debugf("获取门店token错误:%s", err.Error()) + c.Data["json"] = MsgFail() + c.ServeJSON() + return + } + globals.SugarLogger.Debugf("token:%s", utils.Format4Output(tokenInfo, false)) + // 创建storeMap门店信息 + // 刷新token +}