This commit is contained in:
邹宗楠
2023-06-13 16:38:00 +08:00
parent d3f76de69f
commit 1ac29a0099
4 changed files with 48 additions and 25 deletions

View File

@@ -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
}