- 去掉DeleteRemoteStoreSkus
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/partner/putils"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||
@@ -64,3 +65,43 @@ func PruneMissingStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, ven
|
||||
}
|
||||
return hint, err
|
||||
}
|
||||
|
||||
func ClearRemoteStoreStuffAndSetNew(ctx *jxcontext.Context, parentTask tasksch.ITask, vendorID, storeID int, vendorStoreID string, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
userName := ctx.GetUserName()
|
||||
globals.SugarLogger.Debugf("ClearRemoteStoreStuffAndSetNew storeID:%d, isContinueWhenError:%t, userName:%s", storeID, isContinueWhenError, userName)
|
||||
handler, _ := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.ISingleStoreStoreSkuHandler)
|
||||
if handler == nil {
|
||||
return "", fmt.Errorf("平台:%s不支持此操作", model.VendorChineseNames[vendorID])
|
||||
}
|
||||
|
||||
db := dao.GetDB()
|
||||
var errDeleteSku error
|
||||
rootTask := tasksch.NewSeqTask(fmt.Sprintf("ClearRemoteStoreStuffAndSetNew:%s", model.VendorChineseNames[vendorID]), ctx,
|
||||
func(rootTask *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
|
||||
switch step {
|
||||
case 0:
|
||||
err = handler.DeleteStoreAllSkus(ctx, rootTask, storeID, vendorStoreID, isContinueWhenError)
|
||||
errDeleteSku = err
|
||||
// 强制忽略删除SKU错误
|
||||
if isContinueWhenError {
|
||||
err = nil
|
||||
}
|
||||
if err == nil {
|
||||
_, err = dao.SetStoreSkuSyncStatus(db, vendorID, []int{storeID}, nil, model.SyncFlagNewMask)
|
||||
}
|
||||
case 1:
|
||||
if err = handler.DeleteStoreAllCategories(ctx, rootTask, storeID, vendorStoreID, isContinueWhenError); err == nil {
|
||||
_, err = dao.SetStoreCategorySyncStatus(db, vendorID, []int{storeID}, nil, model.SyncFlagNewMask)
|
||||
}
|
||||
}
|
||||
return nil, err
|
||||
}, 2)
|
||||
tasksch.AddChild(parentTask, rootTask).Run()
|
||||
if !isAsync {
|
||||
_, err = rootTask.GetResult(0)
|
||||
}
|
||||
if err == nil {
|
||||
err = errDeleteSku
|
||||
}
|
||||
return rootTask.ID, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user