- call SyncStoreSkus synchronously in mtwm.FullSyncStoreSkus
- handle mtps except event in status event handler too (美团配送的运单异常事件会发到status的回调来)
This commit is contained in:
@@ -62,7 +62,7 @@ func (p *PurchaseHandler) SyncStoreCategory(ctx *jxcontext.Context, parentTask t
|
||||
panic("catName is empty")
|
||||
}
|
||||
globals.SugarLogger.Debugf("RetailCatUpdate vendorStoreID:%s, originName:%s, catName:%s, subCatName:%s, seq:%d", vendorStoreID, originName, catName, subCatName, catInfo.Seq)
|
||||
if err := api.MtwmAPI.RetailCatUpdate(vendorStoreID, originName, catName, subCatName, catInfo.Seq); err == nil {
|
||||
if err = api.MtwmAPI.RetailCatUpdate(vendorStoreID, originName, catName, subCatName, catInfo.Seq); err == nil {
|
||||
catInfo.MtwmID = catInfo.CatName
|
||||
updateFields = append(updateFields, dao.GetVendorThingIDStructField(model.VendorNames[model.VendorIDMTWM]))
|
||||
}
|
||||
@@ -97,7 +97,7 @@ func (p *PurchaseHandler) SyncStoreCategory(ctx *jxcontext.Context, parentTask t
|
||||
// 远程无,本地有,映射无, --> 添加本地
|
||||
// 远程无,本地有,映射有, --> 同步标记改为新增
|
||||
// hint,如果是异步,返回的是任务ID,如果是同步,返回是本次需要同步的目录数
|
||||
func (p *PurchaseHandler) SyncLocalStoreCategory(ctx *jxcontext.Context, db *dao.DaoDB, storeID int, isCheckRemote, isAsync bool) (hint string, err error) {
|
||||
func (p *PurchaseHandler) SyncLocalStoreCategory(ctx *jxcontext.Context, db *dao.DaoDB, storeID int, isCheckRemote bool) (hint string, err error) {
|
||||
if db == nil {
|
||||
db = dao.GetDB()
|
||||
}
|
||||
@@ -214,7 +214,7 @@ func TranverseRemoteCatList(parentCatName string, remoteCats []*mtwmapi.RetailCa
|
||||
func (p *PurchaseHandler) SyncStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, skuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
db := dao.GetDB()
|
||||
for i := 0; i < 3; i++ { // 最多重试三次
|
||||
if hint, err = p.SyncLocalStoreCategory(ctx, db, storeID, false, false); err != nil {
|
||||
if hint, err = p.SyncLocalStoreCategory(ctx, db, storeID, false); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if hint != "0" {
|
||||
@@ -317,11 +317,11 @@ func (p *PurchaseHandler) FullSyncStoreSkus(ctx *jxcontext.Context, parentTask t
|
||||
case 1:
|
||||
_, err = dao.SetStoreSkuSyncStatus(db, model.VendorIDMTWM, storeID, nil, model.SyncFlagNewMask)
|
||||
case 2:
|
||||
_, err = p.SyncLocalStoreCategory(ctx, db, storeID, true, false)
|
||||
_, err = p.SyncLocalStoreCategory(ctx, db, storeID, true)
|
||||
case 3:
|
||||
_, err = p.SyncStoreCategory(ctx, rootTask, storeID, false)
|
||||
case 4:
|
||||
_, err = p.SyncStoreSkus(ctx, rootTask, storeID, nil, true, isContinueWhenError)
|
||||
_, err = p.SyncStoreSkus(ctx, rootTask, storeID, nil, false, isContinueWhenError)
|
||||
}
|
||||
return nil, err
|
||||
}, 5)
|
||||
|
||||
@@ -3,6 +3,7 @@ package controllers
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/mtpsapi"
|
||||
"git.rosy.net.cn/jx-callback/business/partner/delivery/mtps"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
"github.com/astaxie/beego"
|
||||
@@ -15,9 +16,19 @@ type MtpsController struct {
|
||||
|
||||
func (c *MtpsController) Status() {
|
||||
if c.Ctx.Input.Method() == http.MethodPost {
|
||||
obj, callbackResponse := api.MtpsAPI.GetOrderCallbackMsg(c.Ctx.Request)
|
||||
if callbackResponse == nil {
|
||||
callbackResponse = mtps.OnWaybillMsg(obj)
|
||||
var callbackResponse *mtpsapi.CallbackResponse
|
||||
if c.GetString("exception_id") != "" { // 美团配送的回调设置好象有问题,配送异常也会发到这里来,作一下兼容处理
|
||||
var obj *mtpsapi.CallbackOrderExceptionMsg
|
||||
obj, callbackResponse = api.MtpsAPI.GetOrderExceptionCallbackMsg(c.Ctx.Request)
|
||||
if callbackResponse == nil {
|
||||
callbackResponse = mtps.OnWaybillExcept(obj)
|
||||
}
|
||||
} else {
|
||||
var obj *mtpsapi.CallbackOrderMsg
|
||||
obj, callbackResponse = api.MtpsAPI.GetOrderCallbackMsg(c.Ctx.Request)
|
||||
if callbackResponse == nil {
|
||||
callbackResponse = mtps.OnWaybillMsg(obj)
|
||||
}
|
||||
}
|
||||
c.Data["json"] = callbackResponse
|
||||
c.ServeJSON()
|
||||
|
||||
Reference in New Issue
Block a user