- PruneMissingStoreSkus
This commit is contained in:
@@ -185,6 +185,46 @@ func (p *PurchaseHandler) FullSyncStoreSkus(ctx *jxcontext.Context, parentTask t
|
||||
return rootTask.ID, err
|
||||
}
|
||||
|
||||
// todo 往上提
|
||||
func (p *PurchaseHandler) PruneMissingStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
db := dao.GetDB()
|
||||
localSkuList, err := dao.GetStoreSkus2(db, model.VendorIDEBAI, storeID, nil, false)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
localSkuMap := make(map[int]*dao.StoreSkuSyncInfo)
|
||||
for _, v := range localSkuList {
|
||||
localSkuMap[v.SkuID] = v
|
||||
}
|
||||
var vendorSkuID2Delete []string
|
||||
task := tasksch.NewSeqTask("ebai PruneMissingStoreSkus", ctx,
|
||||
func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
|
||||
switch step {
|
||||
case 0:
|
||||
remoteSkuList, err2 := p.GetAllRemoteSkus(ctx, storeID, parentTask)
|
||||
if err = err2; err == nil {
|
||||
for _, v := range remoteSkuList {
|
||||
if localSkuMap[int(utils.Str2Int64WithDefault(v.CustomSkuID, 0))] == nil {
|
||||
vendorSkuID2Delete = append(vendorSkuID2Delete, utils.Int64ToStr(v.SkuID))
|
||||
}
|
||||
}
|
||||
}
|
||||
case 1:
|
||||
if len(vendorSkuID2Delete) > 0 {
|
||||
err = p.DeleteRemoteSkus(ctx, task, storeID, vendorSkuID2Delete)
|
||||
}
|
||||
}
|
||||
return nil, err
|
||||
}, 2)
|
||||
tasksch.HandleTask(task, parentTask, true).Run()
|
||||
if isAsync {
|
||||
hint = task.GetID()
|
||||
} else {
|
||||
_, err = task.GetResult(0)
|
||||
}
|
||||
return hint, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) DeleteRemoteStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
userName := ctx.GetUserName()
|
||||
globals.SugarLogger.Debugf("ebai DeleteRemoteStoreSkus storeID:%d, isContinueWhenError:%t, userName:%s", storeID, isContinueWhenError, userName)
|
||||
|
||||
@@ -34,3 +34,7 @@ func (p *PurchaseHandler) GetStoresSku(ctx *jxcontext.Context, parentTask tasksc
|
||||
func (p *PurchaseHandler) GetStoreSkusInfo(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, vendorStoreID string, inStoreSkuList []*partner.BareStoreSkuInfo) (outStoreSkuList []*partner.BareStoreSkuInfo, err error) {
|
||||
return outStoreSkuList, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) PruneMissingStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
return hint, err
|
||||
}
|
||||
|
||||
@@ -518,6 +518,47 @@ func (p *PurchaseHandler) DeleteRemoteCategories(ctx *jxcontext.Context, parentT
|
||||
return err
|
||||
}
|
||||
|
||||
// todo 往上提
|
||||
func (p *PurchaseHandler) PruneMissingStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
db := dao.GetDB()
|
||||
localSkuList, err := dao.GetStoreSkus2(db, model.VendorIDEBAI, storeID, nil, false)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
localSkuMap := make(map[string]*dao.StoreSkuSyncInfo)
|
||||
for _, v := range localSkuList {
|
||||
localSkuMap[utils.Int2Str(v.SkuID)] = v
|
||||
}
|
||||
var vendorSkuID2Delete []string
|
||||
task := tasksch.NewSeqTask("mtwm PruneMissingStoreSkus", ctx,
|
||||
func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
|
||||
switch step {
|
||||
case 0:
|
||||
remoteSkuList, err2 := p.GetAllRemoteSkus(storeID)
|
||||
if err = err2; err == nil {
|
||||
for _, v := range remoteSkuList {
|
||||
skuIDStr := utils.Interface2String(v["app_food_code"])
|
||||
if localSkuMap[skuIDStr] == nil {
|
||||
vendorSkuID2Delete = append(vendorSkuID2Delete, skuIDStr)
|
||||
}
|
||||
}
|
||||
}
|
||||
case 1:
|
||||
if len(vendorSkuID2Delete) > 0 {
|
||||
err = p.DeleteRemoteSkus(ctx, task, storeID, vendorSkuID2Delete)
|
||||
}
|
||||
}
|
||||
return nil, err
|
||||
}, 2)
|
||||
tasksch.HandleTask(task, parentTask, true).Run()
|
||||
if isAsync {
|
||||
hint = task.GetID()
|
||||
} else {
|
||||
_, err = task.GetResult(0)
|
||||
}
|
||||
return hint, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) DeleteRemoteStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
userName := ctx.GetUserName()
|
||||
globals.SugarLogger.Debugf("mtwm DeleteRemoteStoreSkus storeID:%d, isContinueWhenError:%t, userName:%s", storeID, isContinueWhenError, userName)
|
||||
|
||||
@@ -341,3 +341,7 @@ func composeFakeDelName(name string) string {
|
||||
func (p *PurchaseHandler) GetStoresSku(ctx *jxcontext.Context, parentTask tasksch.ITask, storeIDs []int) (storeSkuList []*model.StoreSkuBind, err error) {
|
||||
return storeSkuList, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) PruneMissingStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
return hint, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user