From 6a8aa0cfff9c32a73ca1bc6849d56d5b3671739a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Mon, 27 May 2024 15:44:38 +0800 Subject: [PATCH] 1 --- business/auth2/auth2.go | 3 - .../auth2/authprovider/dingding/qrcode.go | 11 ---- business/partner/delivery/sfps/waybill.go | 3 +- controllers/auth2.go | 5 -- controllers/mtwm_callback.go | 55 ++++++++++++++++++- 5 files changed, 55 insertions(+), 22 deletions(-) diff --git a/business/auth2/auth2.go b/business/auth2/auth2.go index d6f29f547..934ee56c4 100644 --- a/business/auth2/auth2.go +++ b/business/auth2/auth2.go @@ -5,7 +5,6 @@ import ( "encoding/base64" "encoding/json" "errors" - "git.rosy.net.cn/jx-callback/globals" "regexp" "strings" "time" @@ -250,8 +249,6 @@ func LoginInternal(ctx *Context, authType, authID, authIDType, authSecret string realAuthID = user.GetID() } authBindEx, err = handler.VerifySecret(realAuthID, authSecret) - globals.SugarLogger.Debugf("============authBindEx := %s", utils.Format4Output(authBindEx, false)) - globals.SugarLogger.Debugf("============authBindEx := %v", err) if err == nil { if authBindEx == nil { // mobile, email会返回nil(表示不会新建AuthBind实体) user = userProvider.GetUser(authID, authIDType) diff --git a/business/auth2/authprovider/dingding/qrcode.go b/business/auth2/authprovider/dingding/qrcode.go index a80a7ddcb..136a13f0a 100644 --- a/business/auth2/authprovider/dingding/qrcode.go +++ b/business/auth2/authprovider/dingding/qrcode.go @@ -4,7 +4,6 @@ import ( "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/auth2" "git.rosy.net.cn/jx-callback/business/auth2/authprovider" - "git.rosy.net.cn/jx-callback/globals" "git.rosy.net.cn/jx-callback/globals/api" ) @@ -23,26 +22,18 @@ func init() { func (a *QRCodeAuther) VerifySecret(dummy, code string) (*auth2.AuthBindEx, error) { userQRInfo, err := api.DingDingQRCodeAPI.GetUserInfoByCode(code) - globals.SugarLogger.Debugf("=========userQRInfo= := %s", utils.Format4Output(userQRInfo, false)) - globals.SugarLogger.Debugf("=========err= := %v", err) if err != nil { return nil, err } tmp_userID, err := api.DingDingAPI.GetByUnionID(userQRInfo.UnionID) - globals.SugarLogger.Debugf("=========userQRInfo= := %s", utils.Format4Output(tmp_userID, false)) - globals.SugarLogger.Debugf("=========err= := %v", err) if err != nil { return nil, err } userInfo, err := api.DingDingAPI.GetUser(tmp_userID.UserID) - globals.SugarLogger.Debugf("=========userInfo= := %s", utils.Format4Output(userInfo, false)) - globals.SugarLogger.Debugf("=========err= := %v", err) if err != nil { return nil, err } authBindEx, err := a.UnionFindAuthBind(AuthTypeQRCode, api.DingDingQRCodeAPI.GetAppID(), []string{AuthTypeStaff, AuthTypeQRCode}, userQRInfo.OpenID, userQRInfo.UnionID, userQRInfo) - globals.SugarLogger.Debugf("=========authBindEx= := %s", utils.Format4Output(authBindEx, false)) - globals.SugarLogger.Debugf("=========err= := %v", err) if err != nil { return nil, err } @@ -53,7 +44,5 @@ func (a *QRCodeAuther) VerifySecret(dummy, code string) (*auth2.AuthBindEx, erro Name: utils.Interface2String(userInfo["name"]), } - globals.SugarLogger.Debugf("=========authBindEx2= := %s", utils.Format4Output(authBindEx, false)) - globals.SugarLogger.Debugf("=========err= := %v", err) return authBindEx, err } diff --git a/business/partner/delivery/sfps/waybill.go b/business/partner/delivery/sfps/waybill.go index 01963da0c..b2778f474 100644 --- a/business/partner/delivery/sfps/waybill.go +++ b/business/partner/delivery/sfps/waybill.go @@ -494,8 +494,7 @@ func pushCallbackToGy(urlIndex string, msg interface{}) { } request.Header.Set("Content-Type", "application/json; charset=UTF-8") resp, err := client.Do(request) - resopp, _ := ioutil.ReadAll(resp.Body) - globals.SugarLogger.Debugf("============ %s %v", string(resopp), err) + ioutil.ReadAll(resp.Body) } func tiktokStatusPush(order *model.Waybill, orderStatus int64, lng, lat, vendorOrgCode string) { diff --git a/controllers/auth2.go b/controllers/auth2.go index 2678d731e..dd385c566 100644 --- a/controllers/auth2.go +++ b/controllers/auth2.go @@ -3,7 +3,6 @@ package controllers import ( "encoding/base64" "fmt" - "git.rosy.net.cn/jx-callback/globals" "net/http" "strings" @@ -173,8 +172,6 @@ func (c *Auth2Controller) GetTokenInfo() { c.callGetTokenInfo(func(params *tAuth2GetTokenInfoParams) (retVal interface{}, errCode string, err error) { if true { //auth2.IsV2Token(params.Token) { retVal, err = auth2.GetTokenInfo(params.Token) - globals.SugarLogger.Debugf("======params.Token= %s", params.Token) - globals.SugarLogger.Debugf("======params.retVal= %s", utils.Format4Output(retVal, false)) } else { // retVal, err = auth.GetUserInfo(params.Token) } @@ -298,8 +295,6 @@ func (c *Auth2Controller) DingDingOAuth2() { Desc: err.Error(), } } - globals.SugarLogger.Debugf("=========authInfo := %s", utils.Format4Output(authInfo, false)) - globals.SugarLogger.Debugf("=========callResult := %s", utils.Format4Output(callResult, false)) if params.Block != "" { redirectURL = fmt.Sprintf("%s?info=%s", params.Block, base64.StdEncoding.EncodeToString(utils.MustMarshal(callResult))) } diff --git a/controllers/mtwm_callback.go b/controllers/mtwm_callback.go index aabaf8b9e..d368223a2 100644 --- a/controllers/mtwm_callback.go +++ b/controllers/mtwm_callback.go @@ -1,10 +1,18 @@ package controllers import ( + "encoding/json" "git.rosy.net.cn/baseapi/platformapi/mtwmapi" + "git.rosy.net.cn/baseapi/utils" + "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" "git.rosy.net.cn/jx-callback/globals/api" "github.com/astaxie/beego/server/web" + "net/http" + "net/url" + "strings" ) type MtwmController struct { @@ -14,14 +22,37 @@ type MtwmController struct { func (c *MtwmController) onCallbackMsg(msgType string) { c.Data["json"] = mtwmapi.Err2CallbackResponse(nil, "") msg, callbackResponse := api.MtwmAPI.GetCallbackMsg(c.Ctx.Request) + if callbackResponse == nil { + if web.BConfig.RunMode != "jxgy" { // 订单查询不到所属门店默认为果园订单 + vendorStoreId := msg.FormData.Get("app_poi_code") + if vendorStoreId == "" { + vendorStoreId = msg.FormData.Get("wm_poi_id") + } + if msgType == mtwmapi.MsgTypeOrderFinishedPickup { + finishedPickup := FinishedPickup{} + 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 { + // 推送到果园 + pushMTWMOrder2GY(msg.FormData, msgType) + c.Data["json"] = mtwmapi.Err2CallbackResponse(nil, "") + c.ServeJSON() + return + } + } + } + callbackResponse = mtwm.OnCallbackMsg(msg, msgType) if callbackResponse == nil { callbackResponse = mtwmapi.Err2CallbackResponse(nil, "") } } - c.Data["json"] = mtwmapi.Err2CallbackResponse(nil, "") + c.Data["json"] = mtwmapi.Err2CallbackResponse(nil, "") //c.Data["json"] = callbackResponse c.ServeJSON() } @@ -106,3 +137,25 @@ func (c *MtwmController) OnIMCallback() { c.Data["json"] = callbackResponse c.ServeJSON() } + +type FinishedPickup struct { + AppPoiCode string `json:"app_poi_code"` + ConsumingTime int `json:"consuming_time"` + OrderId int64 `json:"order_id"` + OrderViewId int64 `json:"order_view_id"` + PickTime string `json:"pick_time"` + PickType string `json:"pick_type"` +} + +// 订单所属门店在菜市不存在时尝试推送到果园去 +func pushMTWMOrder2GY(value url.Values, msgType string) { + globals.SugarLogger.Debugf("=========pushMTWMOrder2GY := %s", utils.Format4Output(value, false)) + globals.SugarLogger.Debugf("=========msgType := %s", msgType) + cl := http.Client{} + request, err := http.NewRequest(http.MethodPost, "http://callback-jxgy.jxc4.com/mtwm/"+msgType, strings.NewReader(value.Encode())) + if err != nil { + return + } + request.Header.Set("Content-Type", "multipart/form-data; charset=UTF-8") + cl.Do(request) +}