This commit is contained in:
邹宗楠
2024-05-27 15:44:38 +08:00
parent cd8c78cc08
commit 6a8aa0cfff
5 changed files with 55 additions and 22 deletions

View File

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

View File

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

View File

@@ -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) {

View File

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

View File

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