1
This commit is contained in:
@@ -90,8 +90,11 @@ func (c *DeliveryHandler) OnWaybillExcept(msg *mtpsapi.CallbackOrderExceptionMsg
|
||||
func (c *DeliveryHandler) onWaybillMsg(msg *mtpsapi.CallbackOrderMsg) (retVal *mtpsapi.CallbackResponse) {
|
||||
order, goodsOrder := c.callbackMsg2Waybill(msg)
|
||||
//查不到订单可能就是果园的订单
|
||||
if goodsOrder == nil && beego.BConfig.RunMode != "jxgy" {
|
||||
c.pushToGy(msg)
|
||||
if goodsOrder == nil && beego.BConfig.RunMode == model.ServerTypeVegetable {
|
||||
c.pushToGy(msg, model.ServerTypeFruits)
|
||||
return mtpsapi.SuccessResponse
|
||||
} else if goodsOrder == nil && beego.BConfig.RunMode == model.ServerTypeFruits {
|
||||
c.pushToGy(msg, model.ServerTypePet)
|
||||
return mtpsapi.SuccessResponse
|
||||
}
|
||||
// 多次取消,送达,只处理第一次
|
||||
@@ -195,7 +198,7 @@ func pushMTPSToTiktok(msgStatus int, order *model.Waybill, lng, lat, vendorOrgCo
|
||||
}
|
||||
}
|
||||
|
||||
func (c *DeliveryHandler) pushToGy(msg *mtpsapi.CallbackOrderMsg) {
|
||||
func (c *DeliveryHandler) pushToGy(msg *mtpsapi.CallbackOrderMsg, serverType string) {
|
||||
cl := http.Client{}
|
||||
params := make(map[string]interface{})
|
||||
params["mt_peisong_id"] = msg.MtPeisongID
|
||||
@@ -211,10 +214,22 @@ func (c *DeliveryHandler) pushToGy(msg *mtpsapi.CallbackOrderMsg) {
|
||||
urls := utils.Map2URLValues(params)
|
||||
sign := signParams(urls)
|
||||
params["sign"] = sign
|
||||
request, err := http.NewRequest(http.MethodPost, "http://callback-jxgy.jxc4.com/mtps/status", strings.NewReader(utils.Map2URLValues(params).Encode()))
|
||||
if err != nil {
|
||||
return
|
||||
|
||||
var request *http.Request
|
||||
var err error
|
||||
switch serverType {
|
||||
case model.ServerTypeFruits:
|
||||
request, err = http.NewRequest(http.MethodPost, "http://callback-jxgy.jxc4.com/mtps/status", strings.NewReader(utils.Map2URLValues(params).Encode()))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
case model.ServerTypePet:
|
||||
request, err = http.NewRequest(http.MethodPost, "http://callback-jxpet.jxc4.com/mtps/status", strings.NewReader(utils.Map2URLValues(params).Encode()))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
request.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")
|
||||
cl.Do(request)
|
||||
}
|
||||
|
||||
@@ -391,8 +391,12 @@ func OnWaybillMsg(urlIndex string, msg interface{}) (resp *sfps2.CallbackRespons
|
||||
|
||||
order, goodsOrder := GetWaybillByStatus(urlIndex, msg)
|
||||
//判断是否是果园
|
||||
if goodsOrder == nil && beego.BConfig.RunMode != "jxgy" {
|
||||
pushCallbackToGy(urlIndex, msg)
|
||||
if goodsOrder == nil && beego.BConfig.RunMode == model.ServerTypeVegetable {
|
||||
pushCallbackToGy(urlIndex, msg, model.ServerTypeFruits)
|
||||
return sfps2.SuccessResponse
|
||||
}
|
||||
if goodsOrder == nil && beego.BConfig.RunMode == model.ServerTypeFruits {
|
||||
pushCallbackToGy(urlIndex, msg, model.ServerTypePet)
|
||||
return sfps2.SuccessResponse
|
||||
}
|
||||
//多次取消回调只取第一次
|
||||
@@ -470,7 +474,7 @@ func OnWaybillMsg(urlIndex string, msg interface{}) (resp *sfps2.CallbackRespons
|
||||
}
|
||||
|
||||
//转发到果园
|
||||
func pushCallbackToGy(urlIndex string, msg interface{}) {
|
||||
func pushCallbackToGy(urlIndex string, msg interface{}, serverType string) {
|
||||
var (
|
||||
err error
|
||||
client = &http.Client{}
|
||||
@@ -478,14 +482,24 @@ func pushCallbackToGy(urlIndex string, msg interface{}) {
|
||||
)
|
||||
|
||||
b, _ := json.Marshal(msg)
|
||||
|
||||
switch urlIndex {
|
||||
case sfps2.UrlIndexRiderException:
|
||||
request, err = http.NewRequest(http.MethodPost, "http://callback-jxgy.jxc4.com/SFPS/SfAbnormal", strings.NewReader(string(b)))
|
||||
default:
|
||||
//fullUrl := utils.GenerateGetURL("http://callback-jxgy.jxc4.com/SFPS/SfOrder", "", map[string]interface{}{"sign": sign})
|
||||
//request, err = http.NewRequest(http.MethodPost, fullUrl, strings.NewReader(string(b)))
|
||||
request, err = http.NewRequest(http.MethodPost, "http://callback-jxgy.jxc4.com/SFPS/SfOrder", strings.NewReader(string(b)))
|
||||
if serverType == model.ServerTypeFruits {
|
||||
switch urlIndex {
|
||||
case sfps2.UrlIndexRiderException:
|
||||
request, err = http.NewRequest(http.MethodPost, "http://callback-jxgy.jxc4.com/SFPS/SfAbnormal", strings.NewReader(string(b)))
|
||||
default:
|
||||
//fullUrl := utils.GenerateGetURL("http://callback-jxgy.jxc4.com/SFPS/SfOrder", "", map[string]interface{}{"sign": sign})
|
||||
//request, err = http.NewRequest(http.MethodPost, fullUrl, strings.NewReader(string(b)))
|
||||
request, err = http.NewRequest(http.MethodPost, "http://callback-jxgy.jxc4.com/SFPS/SfOrder", strings.NewReader(string(b)))
|
||||
}
|
||||
} else if serverType == model.ServerTypePet {
|
||||
switch urlIndex {
|
||||
case sfps2.UrlIndexRiderException:
|
||||
request, err = http.NewRequest(http.MethodPost, "http://callback-jxpet.jxc4.com/SFPS/SfAbnormal", strings.NewReader(string(b)))
|
||||
default:
|
||||
//fullUrl := utils.GenerateGetURL("http://callback-jxgy.jxc4.com/SFPS/SfOrder", "", map[string]interface{}{"sign": sign})
|
||||
//request, err = http.NewRequest(http.MethodPost, fullUrl, strings.NewReader(string(b)))
|
||||
request, err = http.NewRequest(http.MethodPost, "http://callback-jxpet.jxc4.com/SFPS/SfOrder", strings.NewReader(string(b)))
|
||||
}
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
||||
@@ -368,7 +368,7 @@ func (p *PurchaseHandler) AcceptOrRefuseOrder(order *model.GoodsOrder, isAcceptI
|
||||
if isAcceptIt {
|
||||
if globals.EnableEbaiStoreWrite {
|
||||
err = api.EbaiAPI.OrderConfirm(order.VendorOrderID)
|
||||
if beego.BConfig.RunMode == "jxgy" {
|
||||
if beego.BConfig.RunMode == model.ServerTypeFruits || beego.BConfig.RunMode == model.ServerTypePet {
|
||||
utils.AfterFuncWithRecover(time.Minute*10, func() {
|
||||
err = api.EbaiAPI.OrderPickComplete(order.VendorOrderID)
|
||||
})
|
||||
@@ -502,6 +502,15 @@ func (p *PurchaseHandler) SelfDeliverDelivering(order *model.GoodsOrder, userNam
|
||||
err = api.EbaiAPI.OrderselfDeliveryStateSync2(param2)
|
||||
}
|
||||
if err == nil {
|
||||
if order.VendorID == model.VendorIDEBAI && strings.Contains(order.ConsigneeAddress, "隐私保护") {
|
||||
// 部分订单在隐私条约的保护下会隐藏用户收货地址,转自送成功自后才可以获取到正确的地址.
|
||||
orderMap, err := api.EbaiAPI.OrderGet(order.VendorOrderID)
|
||||
if err == nil {
|
||||
userMap := orderMap["user"].(map[string]interface{})
|
||||
order.ConsigneeAddress = utils.Interface2String(userMap["address"])
|
||||
partner.CurOrderManager.UpdateOrderFields(order, []string{"ConsigneeAddress"})
|
||||
}
|
||||
}
|
||||
// 饿百不会发送配送中,模拟发送
|
||||
p.postFakeMsg(order.VendorOrderID, ebaiapi.OrderStatusCourierAccepted)
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ const (
|
||||
)
|
||||
|
||||
func getDefJdCategoryID() int {
|
||||
if beego.BConfig.RunMode == "jxgy" {
|
||||
if beego.BConfig.RunMode == model.ServerTypeFruits {
|
||||
return DefJdCategoryID4Jxgy
|
||||
}
|
||||
return DefJdCategoryID
|
||||
|
||||
@@ -55,8 +55,10 @@ func pay4OrderByKs(ctx *jxcontext.Context, order *model.GoodsOrder, vendorPayTyp
|
||||
CancelOrder: 0,
|
||||
}
|
||||
|
||||
if beego.BConfig.RunMode == "jxgy" {
|
||||
if beego.BConfig.RunMode == model.ServerTypeFruits {
|
||||
param.NotifyUrl = "https://callback-jxgy.jxc4.com/kuaishou/kuaiShouCallback"
|
||||
} else if beego.BConfig.RunMode == model.ServerTypePet {
|
||||
param.NotifyUrl = "https://callback.jxpet.com/kuaishou/kuaiShouCallback"
|
||||
} else {
|
||||
param.NotifyUrl = "https://callback.jxc4.com/kuaishou/kuaiShouCallback"
|
||||
}
|
||||
|
||||
@@ -66,14 +66,18 @@ func GetVendorAppIdFromMsg(msg *mtwmapi.CallbackMsg) string {
|
||||
// OnImMsg im消息回调
|
||||
func OnImMsg(msg *mtwmapi.ImCallbackMsg) (response *mtwmapi.CallbackResponse) {
|
||||
if str, err := json.Marshal(msg.PushContent); err == nil {
|
||||
if beego.BConfig.RunMode != "jxgy" {
|
||||
var PushContentReq = mtwmapi.PushContentReq{}
|
||||
if err = json.Unmarshal(str, &PushContentReq); err != nil {
|
||||
return mtwmapi.SignatureIsNotOk
|
||||
}
|
||||
storeDetail, err2 := dao.GetStoreDetailByVendorStoreID(dao.GetDB(), PushContentReq.AppPoiCode, model.VendorIDMTWM, utils.Int2Str(PushContentReq.AppID))
|
||||
if err2 != nil || storeDetail == nil {
|
||||
pushIMToGy(msg)
|
||||
var PushContentReq = mtwmapi.PushContentReq{}
|
||||
if err = json.Unmarshal(str, &PushContentReq); err != nil {
|
||||
return mtwmapi.SignatureIsNotOk
|
||||
}
|
||||
storeDetail, err2 := dao.GetStoreDetailByVendorStoreID(dao.GetDB(), PushContentReq.AppPoiCode, model.VendorIDMTWM, utils.Int2Str(PushContentReq.AppID))
|
||||
if err2 != nil || storeDetail == nil {
|
||||
switch beego.BConfig.RunMode {
|
||||
case model.ServerTypeFruits:
|
||||
pushIMToGyOrPet(msg, model.ServerTypePet)
|
||||
return mtwmapi.SuccessResponse
|
||||
case model.ServerTypeVegetable:
|
||||
pushIMToGyOrPet(msg, model.ServerTypeFruits)
|
||||
return mtwmapi.SuccessResponse
|
||||
}
|
||||
}
|
||||
@@ -87,18 +91,32 @@ func OnImMsg(msg *mtwmapi.ImCallbackMsg) (response *mtwmapi.CallbackResponse) {
|
||||
return mtwmapi.SuccessResponse
|
||||
}
|
||||
|
||||
func pushIMToGy(msg *mtwmapi.ImCallbackMsg) {
|
||||
cl := http.Client{}
|
||||
func pushIMToGyOrPet(msg *mtwmapi.ImCallbackMsg, serverType string) {
|
||||
var (
|
||||
cl = http.Client{}
|
||||
request = &http.Request{}
|
||||
err error
|
||||
)
|
||||
params := make(map[string]interface{})
|
||||
params["timestamp"] = msg.Timestamp
|
||||
params["sign"] = msg.Sig
|
||||
params["app_id"] = msg.AppID
|
||||
params["biz_type"] = msg.BizType
|
||||
params["push_content"] = msg.PushContent
|
||||
request, err := http.NewRequest(http.MethodPost, "http://callback-jxgy.jxc4.com/mtwm/iMCallback", strings.NewReader(utils.Map2URLValues(params).Encode()))
|
||||
if err != nil {
|
||||
return
|
||||
|
||||
switch serverType {
|
||||
case model.ServerTypeFruits:
|
||||
request, err = http.NewRequest(http.MethodPost, "http://callback-jxgy.jxc4.com/mtwm/iMCallback", strings.NewReader(utils.Map2URLValues(params).Encode()))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
case model.ServerTypePet:
|
||||
request, err = http.NewRequest(http.MethodPost, "http://callback-jxpet.jxc4.com/mtwm/iMCallback", strings.NewReader(utils.Map2URLValues(params).Encode()))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
request.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")
|
||||
cl.Do(request)
|
||||
}
|
||||
|
||||
@@ -343,8 +343,11 @@ func (p *PurchaseHandler) onStoreStatusChanged(msg *mtwmapi.CallbackMsg) (respon
|
||||
}
|
||||
|
||||
if err == nil && storeStatus == model.StoreStatusDisabled {
|
||||
if beego.BConfig.RunMode == "jxgy" {
|
||||
if beego.BConfig.RunMode == model.ServerTypeFruits {
|
||||
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, model.DefaultUserIdGuoYuan, "美团果园门店下线通知", fmt.Sprintf("果园美团门店被下线了:门店id[%s],平台门店id[%s]", "暂未获取", vendorStoreID))
|
||||
} else if beego.BConfig.RunMode == model.ServerTypePet {
|
||||
// todo 暂无服务部署,后面补
|
||||
//ddmsg.SendUserMessage(dingdingapi.MsgTyeText, model.DefaultUserIdGuoYuan, "美团果园门店下线通知", fmt.Sprintf("果园美团门店被下线了:门店id[%s],平台门店id[%s]", "暂未获取", vendorStoreID))
|
||||
} else {
|
||||
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, model.DefaultUserIdCaiShi, "美团果菜市店下线通知", fmt.Sprintf("菜市美团门店被下线了:门店id[%s],平台门店id[%s]", "暂未获取", vendorStoreID))
|
||||
}
|
||||
@@ -511,8 +514,11 @@ func (c *PurchaseHandler) UpdateStoreLineStatus(ctx *jxcontext.Context, vendorOr
|
||||
err = mtwmApi.PoiOffline(vendorStoreID)
|
||||
// 通知给石锋
|
||||
switch beego.BConfig.RunMode {
|
||||
case "jxgy":
|
||||
case model.ServerTypeFruits:
|
||||
err = ddmsg.SendUserMessage(dingdingapi.MsgTyeText, model.DefaultUserIdGuoYuan, fmt.Sprintf("(果园)美团门店被关闭了:门店id[%d],平台门店id[%s]", storeID, vendorStoreID), "!")
|
||||
case model.ServerTypePet:
|
||||
// todo 暂无服务器部署
|
||||
//err = ddmsg.SendUserMessage(dingdingapi.MsgTyeText, model.DefaultUserIdGuoYuan, fmt.Sprintf("(果园)美团门店被关闭了:门店id[%d],平台门店id[%s]", storeID, vendorStoreID), "!")
|
||||
default:
|
||||
err = ddmsg.SendUserMessage(dingdingapi.MsgTyeText, model.DefaultUserIdCaiShi, fmt.Sprintf("(菜市)美团门店被关闭了:门店id[%d],平台门店id[%s]", storeID, vendorStoreID), "!")
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
beego "github.com/astaxie/beego/server/web"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
@@ -40,19 +41,35 @@ func OnOrderMsg(msgId string, msg interface{}) (response *tiktokShop.CallbackRes
|
||||
if vendorStoreID != "" {
|
||||
storeDetail, err := dao.GetStoreDetailByVendorStoreID(dao.GetDB(), vendorStoreID, model.VendorIDDD, "")
|
||||
if err != nil || storeDetail == nil || storeDetail.Store.ID == 0 {
|
||||
// 当前订单所属门店不属于菜市时,将消息推送到果园
|
||||
gyMsg := map[string]interface{}{"tag": msgId, "msg_id": utils.Int64ToStr(time.Now().Unix()) + msgId, "data": msg}
|
||||
// 通知到果园
|
||||
gyResult, err := HttpToGuoYuan(gyMsg, CaiShiPushGyTagOrder)
|
||||
if err != nil {
|
||||
return tiktokShop.Err2CallbackResponse(err, "")
|
||||
switch beego.BConfig.RunMode {
|
||||
case model.ServerTypeFruits:
|
||||
// 当前订单所属门店不属于菜市时,将消息推送到果园
|
||||
gyResult, err := HttpToGuoYuan(gyMsg, CaiShiPushGyTagOrder, model.ServerTypePet)
|
||||
if err != nil {
|
||||
return tiktokShop.Err2CallbackResponse(err, "")
|
||||
}
|
||||
result, _ := ioutil.ReadAll(gyResult.Body)
|
||||
var guoYuan *tiktokShop.CallbackResponse
|
||||
if err2 := json.Unmarshal(result, guoYuan); err2 != nil {
|
||||
return tiktokShop.Err2CallbackResponse(err2, "")
|
||||
}
|
||||
return guoYuan
|
||||
case model.ServerTypeVegetable:
|
||||
// 当前订单所属门店不属于菜市时,将消息推送到果园
|
||||
gyResult, err := HttpToGuoYuan(gyMsg, CaiShiPushGyTagOrder, model.ServerTypeFruits)
|
||||
if err != nil {
|
||||
return tiktokShop.Err2CallbackResponse(err, "")
|
||||
}
|
||||
result, _ := ioutil.ReadAll(gyResult.Body)
|
||||
var guoYuan *tiktokShop.CallbackResponse
|
||||
if err2 := json.Unmarshal(result, guoYuan); err2 != nil {
|
||||
return tiktokShop.Err2CallbackResponse(err2, "")
|
||||
}
|
||||
return guoYuan
|
||||
case model.ServerTypePet:
|
||||
return nil
|
||||
}
|
||||
result, _ := ioutil.ReadAll(gyResult.Body)
|
||||
var guoYuan *tiktokShop.CallbackResponse
|
||||
if err2 := json.Unmarshal(result, guoYuan); err2 != nil {
|
||||
return tiktokShop.Err2CallbackResponse(err2, "")
|
||||
}
|
||||
return guoYuan
|
||||
}
|
||||
}
|
||||
jxutils.CallMsgHandler(func() {
|
||||
@@ -64,7 +81,9 @@ func OnOrderMsg(msgId string, msg interface{}) (response *tiktokShop.CallbackRes
|
||||
return response
|
||||
}
|
||||
|
||||
func HttpToGuoYuan(param map[string]interface{}, requestType string) (*http.Response, error) {
|
||||
// HttpToGuoYuan 暂时还未开通果园和宠物的抖音
|
||||
func HttpToGuoYuan(param map[string]interface{}, requestType string, serverType string) (*http.Response, error) {
|
||||
return nil, nil
|
||||
var paramData []byte
|
||||
var err error
|
||||
if requestType == "order" || requestType == "waybill" {
|
||||
@@ -81,18 +100,34 @@ func HttpToGuoYuan(param map[string]interface{}, requestType string) (*http.Resp
|
||||
}
|
||||
body := strings.NewReader(string(paramData))
|
||||
url := ""
|
||||
switch requestType {
|
||||
case CaiShiPushGyTagOrder: // 订单相关
|
||||
url = "http://callback-jxgy.jxc4.com/tiktok/callbackTiktokOrderMsg"
|
||||
case CaiShiPushGyTagToken: // 授权相关
|
||||
url = "http://callback-jxgy.jxc4.com/tiktokShop/jxcsToGyTiktokToken"
|
||||
case CaiShiPushGyTagDeliveryRegister: // 配送查询注册
|
||||
url = "http://callback-jxgy.jxc4.com/logistics/logisticsRegister"
|
||||
case CaiShiPushGyTagDeliveryDetail: // 配送查询详情
|
||||
url = "http://callback-jxgy.jxc4.com/logistics/logisticsQuery"
|
||||
case CaiShiPushGyTagWayBill: // 运单消息
|
||||
url = "http://callback-jxgy.jxc4.com/tiktok/callbackTiktokOrderMsg"
|
||||
if serverType == model.ServerTypeFruits {
|
||||
switch requestType {
|
||||
case CaiShiPushGyTagOrder: // 订单相关
|
||||
url = "http://callback-jxgy.jxc4.com/tiktok/callbackTiktokOrderMsg"
|
||||
case CaiShiPushGyTagToken: // 授权相关
|
||||
url = "http://callback-jxgy.jxc4.com/tiktokShop/jxcsToGyTiktokToken"
|
||||
case CaiShiPushGyTagDeliveryRegister: // 配送查询注册
|
||||
url = "http://callback-jxgy.jxc4.com/logistics/logisticsRegister"
|
||||
case CaiShiPushGyTagDeliveryDetail: // 配送查询详情
|
||||
url = "http://callback-jxgy.jxc4.com/logistics/logisticsQuery"
|
||||
case CaiShiPushGyTagWayBill: // 运单消息
|
||||
url = "http://callback-jxgy.jxc4.com/tiktok/callbackTiktokOrderMsg"
|
||||
}
|
||||
} else if serverType == model.ServerTypePet {
|
||||
switch requestType {
|
||||
case CaiShiPushGyTagOrder: // 订单相关
|
||||
url = "http://callback-jxpet.jxc4.com/tiktok/callbackTiktokOrderMsg"
|
||||
case CaiShiPushGyTagToken: // 授权相关
|
||||
url = "http://callback-jxpet.jxc4.com/tiktokShop/jxcsToGyTiktokToken"
|
||||
case CaiShiPushGyTagDeliveryRegister: // 配送查询注册
|
||||
url = "http://callback-jxpet.jxc4.com/logistics/logisticsRegister"
|
||||
case CaiShiPushGyTagDeliveryDetail: // 配送查询详情
|
||||
url = "http://callback-jxpet.jxc4.com/logistics/logisticsQuery"
|
||||
case CaiShiPushGyTagWayBill: // 运单消息
|
||||
url = "http://callback-jxpet.jxc4.com/tiktok/callbackTiktokOrderMsg"
|
||||
}
|
||||
}
|
||||
|
||||
httpReq, err := http.NewRequest(http.MethodPost, url, body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user