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

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