443 lines
19 KiB
Go
443 lines
19 KiB
Go
package mtwm
|
||
|
||
// // hint,如果是异步,返回的是任务ID,如果是同步,返回是本次需要同步的目录数
|
||
// func (p *PurchaseHandler) SyncStoreCategory(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, isAsync bool) (hint string, err error) {
|
||
// globals.SugarLogger.Debugf("mtwm SyncStoreCategory storeID:%d, userName:%s", storeID, ctx.GetUserName())
|
||
// num := 0
|
||
// db := dao.GetDB()
|
||
// storeDetail, err := dao.GetStoreDetail(db, storeID, model.VendorIDMTWM)
|
||
// if err != nil {
|
||
// return hint, err
|
||
// }
|
||
// vendorStoreID := storeDetail.VendorStoreID
|
||
// rootTask := tasksch.NewSeqTask("美团外卖SyncStoreCategory step1", ctx,
|
||
// func(rootTask *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
|
||
// level := step + 1
|
||
// catList, err := dao.GetStoreCategories(db, model.VendorIDMTWM, storeID, level)
|
||
// if len(catList) > 0 {
|
||
// num += len(catList)
|
||
// task := tasksch.NewParallelTask(fmt.Sprintf("美团外卖SyncStoreCategory step2, level=%d", level), nil, ctx,
|
||
// func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||
// updateFields := []string{dao.GetSyncStatusStructField(model.VendorNames[model.VendorIDMTWM])}
|
||
// catInfo := batchItemList[0].(*dao.SkuStoreCatInfo)
|
||
// storeCatMap := &model.StoreSkuCategoryMap{}
|
||
// storeCatMap.ID = catInfo.MapID
|
||
// if catInfo.StoreCatSyncStatus&model.SyncFlagDeletedMask != 0 { // 删除
|
||
// if catInfo.StoreCatSyncStatus&model.SyncFlagNewMask == 0 && !dao.IsVendorThingIDEmpty(catInfo.VendorCatID) {
|
||
// globals.SugarLogger.Debugf("RetailCatDelete vendorStoreID:%s, MtwmID:%s", vendorStoreID, catInfo.VendorCatID)
|
||
// if globals.EnableMtwmStoreWrite {
|
||
// if err = api.MtwmAPI.RetailCatDelete(vendorStoreID, catInfo.VendorCatID); mtwmapi.IsErrCategoryNotExist(err) {
|
||
// err = nil
|
||
// }
|
||
// }
|
||
// }
|
||
// } else if catInfo.StoreCatSyncStatus&(model.SyncFlagNewMask|model.SyncFlagStoreSkuModifiedMask) != 0 { // 新增或修改
|
||
// catName := catInfo.Name
|
||
// subCatName := ""
|
||
// originName := ""
|
||
// if catInfo.StoreCatSyncStatus&model.SyncFlagNewMask == 0 {
|
||
// originName = catInfo.VendorCatID
|
||
// }
|
||
// if level == 2 {
|
||
// originName = catInfo.ParentCatName
|
||
// catName = catInfo.ParentCatName
|
||
// subCatName = catInfo.Name
|
||
// if catInfo.StoreCatSyncStatus&model.SyncFlagNewMask == 0 {
|
||
// originName = catInfo.VendorCatID
|
||
// catName = catInfo.Name
|
||
// subCatName = ""
|
||
// }
|
||
// }
|
||
// if catName == "" {
|
||
// 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 globals.EnableMtwmStoreWrite {
|
||
// if err = api.MtwmAPI.RetailCatUpdate(vendorStoreID, originName, catName, subCatName, catInfo.Seq); catInfo.StoreCatSyncStatus&model.SyncFlagNewMask != 0 && mtwmapi.IsErrCategoryExist(err) {
|
||
// err = nil
|
||
// }
|
||
// }
|
||
// if err == nil {
|
||
// storeCatMap.MtwmID = catInfo.Name
|
||
// updateFields = append(updateFields, dao.GetVendorThingIDStructField(model.VendorNames[model.VendorIDMTWM]))
|
||
// }
|
||
// }
|
||
// if err == nil {
|
||
// db2 := dao.GetDB()
|
||
// storeCatMap.MtwmSyncStatus = 0
|
||
// _, err = dao.UpdateEntity(db2, storeCatMap, updateFields...)
|
||
// }
|
||
// return nil, err
|
||
// }, catList)
|
||
// rootTask.AddChild(task).Run()
|
||
// _, err = task.GetResult(0)
|
||
// }
|
||
// return nil, err
|
||
// }, 2)
|
||
// tasksch.AddChild(parentTask, rootTask).Run()
|
||
// if !isAsync {
|
||
// hint = utils.Int2Str(num)
|
||
// _, err = rootTask.GetResult(0)
|
||
// } else {
|
||
// hint = rootTask.ID
|
||
// }
|
||
// return hint, err
|
||
// }
|
||
|
||
// // 此函数根据门店商品信息重建分类信息
|
||
// // 远程有,本地无, --> 删除远程
|
||
// // 远程有,本地有,映射无, --> 添加关联
|
||
// // 远程有,本地有,映射有, --> 不处理
|
||
// // 远程无,本地有,映射无, --> 添加本地
|
||
// // 远程无,本地有,映射有, --> 同步标记改为新增
|
||
// // hint,如果是异步,返回的是任务ID,如果是同步,返回是本次需要同步的目录数
|
||
// func (p *PurchaseHandler) SyncLocalStoreCategory(ctx *jxcontext.Context, db *dao.DaoDB, storeID int, isCheckRemote bool, skuIDs []int) (hint string, err error) {
|
||
// globals.SugarLogger.Debugf("mtwm SyncLocalStoreCategory storeID:%d, userName:%s", storeID, ctx.GetUserName())
|
||
// if db == nil {
|
||
// db = dao.GetDB()
|
||
// }
|
||
// catMap := make([]map[string]*dao.SkuStoreCatInfo, 2)
|
||
// for i := 0; i < 2; i++ {
|
||
// catMap[i] = make(map[string]*dao.SkuStoreCatInfo)
|
||
// localCats, err := dao.GetSkusCategories(db, model.VendorIDMTWM, storeID, skuIDs, i+1)
|
||
// // globals.SugarLogger.Debug(utils.Format4Output(localCats, false))
|
||
// if err != nil {
|
||
// return "", err
|
||
// }
|
||
// for _, cat := range localCats {
|
||
// catMap[i][cat.ParentCatName+"/"+cat.Name] = cat
|
||
// }
|
||
// }
|
||
// identityCatMap := make(map[int]int) // 这里面表示远程有,本地有,且完全相同,可擦掉本地的修改标记
|
||
// if isCheckRemote {
|
||
// storeDetail, err := dao.GetStoreDetail(db, storeID, model.VendorIDMTWM)
|
||
// if err != nil {
|
||
// return hint, err
|
||
// }
|
||
// vendorStoreID := storeDetail.VendorStoreID
|
||
// remoteCats, err := api.MtwmAPI.RetailCatList(vendorStoreID)
|
||
// if err != nil {
|
||
// return "", err
|
||
// }
|
||
// if err = TranverseRemoteCatList("", remoteCats, func(level int, parentCatName, catName string) (err error) {
|
||
// localCat := catMap[level-1][parentCatName+"/"+catName]
|
||
// // globals.SugarLogger.Debug(parentCatName, " ", catName, " ", localCat)
|
||
// if localCat == nil { // 本地分类就没有这个名字,直接删除
|
||
// if globals.EnableMtwmStoreWrite {
|
||
// globals.SugarLogger.Debugf("RetailCatDelete2 vendorStoreID:%s, catName:%s", vendorStoreID, catName)
|
||
// if err = api.MtwmAPI.RetailCatDelete(vendorStoreID, catName); err != nil {
|
||
// return err
|
||
// }
|
||
// }
|
||
// } else { // 本地分类有这个名字
|
||
// if localCat.MapID == 0 { // 本地映射没有
|
||
// localCat.MapID = -1 // 表示远程有同名的
|
||
// } else { // 本地映射有
|
||
// identityCatMap[localCat.MapID] = 1
|
||
// }
|
||
// }
|
||
// return nil
|
||
// }); err != nil {
|
||
// return "", err
|
||
// }
|
||
// }
|
||
// dao.Begin(db)
|
||
// defer func() {
|
||
// dao.Rollback(db)
|
||
// }()
|
||
// num := 0
|
||
// for i := 0; i < 2; i++ {
|
||
// for _, v := range catMap[i] {
|
||
// if v.MapID == -1 || v.MapID == 0 { // 本地缺失
|
||
// mtwmSyncStatus := int8(model.SyncFlagNewMask)
|
||
// if v.MapID == -1 { // 远程有同名的,只是简单增加一条本地记录关联
|
||
// mtwmSyncStatus = 0
|
||
// }
|
||
// catMap := &model.StoreSkuCategoryMap{
|
||
// StoreID: storeID,
|
||
// CategoryID: v.ID,
|
||
// MtwmID: v.Name,
|
||
// MtwmSyncStatus: mtwmSyncStatus,
|
||
// EbaiSyncStatus: model.SyncFlagNewMask,
|
||
// ElmSyncStatus: model.SyncFlagNewMask,
|
||
// WscSyncStatus: model.SyncFlagNewMask,
|
||
// }
|
||
// num++
|
||
// dao.WrapAddIDCULDEntity(catMap, ctx.GetUserName())
|
||
// if err = dao.CreateEntity(db, catMap); err != nil {
|
||
// return "", err
|
||
// }
|
||
// } else {
|
||
// if dao.IsVendorThingIDEmpty(v.VendorCatID) {
|
||
// num++
|
||
// }
|
||
// if isCheckRemote {
|
||
// catMap := &model.StoreSkuCategoryMap{
|
||
// MtwmSyncStatus: model.SyncFlagNewMask,
|
||
// }
|
||
// updateFields := []string{
|
||
// model.FieldUpdatedAt,
|
||
// model.FieldLastOperator,
|
||
// model.FieldMtwmSyncStatus,
|
||
// }
|
||
// if identityCatMap[v.MapID] == 1 { // 如果一样,则要刷新ID(对于MTWM其实就是名字)
|
||
// catMap.MtwmID = v.Name
|
||
// catMap.MtwmSyncStatus = 0
|
||
// updateFields = append(updateFields, model.FieldMtwmID)
|
||
// }
|
||
// catMap.ID = v.MapID
|
||
// num++
|
||
// dao.WrapUpdateULEntity(catMap, ctx.GetUserName())
|
||
// if _, err = dao.UpdateEntity(db, catMap, updateFields...); err != nil {
|
||
// return "", err
|
||
// }
|
||
// }
|
||
// }
|
||
// }
|
||
// }
|
||
// dao.Commit(db)
|
||
// return utils.Int2Str(num), err
|
||
// }
|
||
|
||
// func TranverseRemoteCatList(parentCatName string, remoteCats []*mtwmapi.RetailCategoryInfo, handler func(level int, parentCatName, catName string) error) (err error) {
|
||
// for _, remoteCat := range remoteCats {
|
||
// name := utils.Interface2String(remoteCat.Name)
|
||
// TranverseRemoteCatList(name, remoteCat.Children, handler)
|
||
// if err = handler(remoteCat.Level, parentCatName, name); err != nil {
|
||
// return err
|
||
// }
|
||
// }
|
||
// return nil
|
||
// }
|
||
|
||
// func (p *PurchaseHandler) SyncStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, skuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||
// db := dao.GetDB()
|
||
// storeDetail, err := dao.GetStoreDetail(db, storeID, model.VendorIDMTWM)
|
||
// if err != nil {
|
||
// return "", err
|
||
// }
|
||
// return p.syncStoreSkus(ctx, parentTask, storeDetail, skuIDs, isAsync, isContinueWhenError)
|
||
// }
|
||
|
||
// // hint,如果是异步,返回的是任务ID,如果是同步,返回是本次需要同步的目录数
|
||
// func (p *PurchaseHandler) syncStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeDetail *dao.StoreDetail, skuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||
// storeID := storeDetail.Store.ID
|
||
// globals.SugarLogger.Debugf("mtwm SyncStoreSkus storeID:%d, skuIDs:%v, isContinueWhenError:%t, userName:%s", storeID, skuIDs, isContinueWhenError, ctx.GetUserName())
|
||
// db := dao.GetDB()
|
||
// for i := 0; i < 3; i++ { // 最多重试三次
|
||
// if hint, err = p.SyncLocalStoreCategory(ctx, db, storeID, false, skuIDs); err != nil {
|
||
// return "", err
|
||
// }
|
||
// if hint != "0" {
|
||
// if hint, err = p.SyncStoreCategory(ctx, parentTask, storeID, false); err != nil {
|
||
// return "", err
|
||
// }
|
||
// }
|
||
// if hint == "0" {
|
||
// break
|
||
// }
|
||
// }
|
||
// if hint != "0" {
|
||
// return "", errors.New("同步门店商品所需目录失败")
|
||
// }
|
||
// skus, err := dao.GetStoreSkus(db, model.VendorIDMTWM, storeID, skuIDs)
|
||
// if err != nil {
|
||
// return "", err
|
||
// }
|
||
// // globals.SugarLogger.Debug(utils.Format4Output(skus, false))
|
||
// vendorStoreID := storeDetail.VendorStoreID
|
||
// rootTask := tasksch.NewParallelTask("美团外卖SyncStoreSkus", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError), ctx,
|
||
// func(rootTask *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||
// foodDataList := make([]map[string]interface{}, len(batchItemList))
|
||
// // for k, v := range batchItemList {
|
||
// v := batchItemList[0]
|
||
// skuItem := v.(*dao.StoreSkuSyncInfo)
|
||
// updateFields := []string{model.FieldMtwmSyncStatus}
|
||
// storeSkuBind := &model.StoreSkuBind{}
|
||
// storeSkuBind.ID = skuItem.BindID
|
||
// if skuItem.NameID == 0 || skuItem.StoreSkuSyncStatus&model.SyncFlagDeletedMask != 0 {
|
||
// if skuItem.StoreSkuSyncStatus&model.SyncFlagNewMask == 0 && !dao.IsVendorThingIDEmpty(skuItem.VendorSkuID) {
|
||
// if globals.EnableMtwmStoreWrite {
|
||
// if err = api.MtwmAPI.RetailDelete(ctx.GetTrackInfo(), vendorStoreID, skuItem.VendorSkuID); mtwmapi.IsErrSkuNotExist(err) {
|
||
// err = nil
|
||
// }
|
||
// }
|
||
// }
|
||
// if err == nil {
|
||
// if utils.IsTimeZero(storeSkuBind.DeletedAt) {
|
||
// storeSkuBind.DeletedAt = time.Now()
|
||
// updateFields = append(updateFields, model.FieldDeletedAt)
|
||
// }
|
||
// if !dao.IsVendorThingIDEmpty(skuItem.VendorSkuID) {
|
||
// storeSkuBind.MtwmID = 0
|
||
// updateFields = append(updateFields, model.FieldMtwmID)
|
||
// }
|
||
// }
|
||
// } else if skuItem.StoreSkuSyncStatus&(model.SyncFlagStoreSkuModifiedMask|model.SyncFlagNewMask) != 0 {
|
||
// foodData := make(map[string]interface{})
|
||
// foodDataList[0] = foodData
|
||
// foodData[mtwmapi.KeyAppFoodCode] = utils.Int2Str(skuItem.SkuID)
|
||
// skus := []map[string]interface{}{
|
||
// map[string]interface{}{
|
||
// "sku_id": foodData[mtwmapi.KeyAppFoodCode],
|
||
// },
|
||
// }
|
||
// foodData["skus"] = skus
|
||
// shouldCallSellStatus := !(skuItem.StoreSkuSyncStatus&(model.SyncFlagModifiedMask|model.SyncFlagNewMask|model.SyncFlagPriceMask) != 0)
|
||
// if !shouldCallSellStatus {
|
||
// globals.SugarLogger.Debugf("mtwm SyncStoreSkus3 skuID:%d, SkuSyncStatus:%d", skuItem.SkuID, skuItem.StoreSkuSyncStatus)
|
||
// mergeStoreSkuStatus := jxutils.MergeSkuStatus(skuItem.Status, skuItem.StoreSkuStatus)
|
||
// if !(skuItem.StoreSkuSyncStatus&model.SyncFlagNewMask != 0 && mergeStoreSkuStatus != model.SkuStatusNormal) { // 待创建且不可售的,暂不新建
|
||
// if skuItem.Img == "" {
|
||
// err = fmt.Errorf("SKUNAME%d:%s没有图片,同步失败", skuItem.NameID, skuItem.Name)
|
||
// } else {
|
||
// pricePercentage := jxutils.GetPricePercentage(storeDetail.PricePercentagePackObj, int(skuItem.Price), int(storeDetail.PricePercentage))
|
||
// // globals.SugarLogger.Debugf("skuID:%d, price:%d, pricePercentage:%d", skuItem.SkuID, skuItem.Price, pricePercentage)
|
||
// // globals.SugarLogger.Debugf(utils.Format4Output(storeDetail.PricePercentagePackObj, false))
|
||
// foodData["name"] = jxutils.ComposeSkuName(skuItem.Prefix, skuItem.Name, skuItem.Comment, skuItem.Unit, skuItem.SpecQuality, skuItem.SpecUnit, mtwmapi.MaxSkuNameCharCount)
|
||
// foodData["description"] = skuItem.Comment
|
||
// foodData["price"] = jxutils.IntPrice2Standard(int64(jxutils.CaculateSkuVendorPrice(int(skuItem.Price), pricePercentage, skuItem.CatPricePercentage)))
|
||
// foodData["min_order_count"] = 1
|
||
// foodData["unit"] = skuItem.Unit
|
||
// foodData["box_num"] = 0
|
||
// foodData["box_price"] = 0.0
|
||
// foodData["category_name"] = skuItem.VendorCatID
|
||
// foodData["is_sold_out"] = skuStatusJX2Mtwm(mergeStoreSkuStatus)
|
||
// foodData["picture"] = skuItem.Img
|
||
// if skuItem.DescImg != "" {
|
||
// foodData["picture_contents"] = skuItem.DescImg
|
||
// }
|
||
// foodData["sequence"] = skuItem.Price
|
||
// if skuItem.VendorVendorCatID != 0 {
|
||
// foodData["tag_id"] = utils.Int64ToStr(skuItem.VendorVendorCatID)
|
||
// } else {
|
||
// // foodData["tag_id"] = utils.Int64ToStr(defVendorCatID)
|
||
// }
|
||
// skus[0]["spec"] = jxutils.ComposeSkuSpec(skuItem.SpecQuality, skuItem.SpecUnit)
|
||
// skus[0]["price"] = foodData["price"]
|
||
// skus[0]["stock"] = "*"
|
||
// skus[0]["upc"] = skuItem.Upc
|
||
// if foodData["tag_id"] != nil {
|
||
// skus[0]["weight"] = skuItem.Weight // weight字段仅限服饰鞋帽、美妆、日用品、母婴、生鲜果蔬、生活超市下的便利店/超市门店品类的商家使用
|
||
// }
|
||
// if globals.EnableMtwmStoreWrite {
|
||
// // err = api.MtwmAPI.RetailBatchInitData(ctx.GetTrackInfo(), vendorStoreID, foodDataList)
|
||
|
||
// foodData["skus"] = string(utils.MustMarshal(skus))
|
||
// err = api.MtwmAPI.RetailInitData(ctx.GetTrackInfo(), vendorStoreID, utils.Int2Str(skuItem.SkuID), foodData)
|
||
// }
|
||
// if err == nil {
|
||
// storeSkuBind.MtwmID = int64(skuItem.SkuID)
|
||
// updateFields = append(updateFields, model.FieldMtwmID)
|
||
// }
|
||
// }
|
||
// } else {
|
||
// // 暂不创建
|
||
// updateFields = nil
|
||
// }
|
||
// }
|
||
// if err != nil {
|
||
// if isErrModifyPrice(err) {
|
||
// shouldCallSellStatus = true
|
||
// }
|
||
// }
|
||
// if shouldCallSellStatus {
|
||
// if skuItem.StoreSkuSyncStatus&(model.SyncFlagSaleMask) != 0 {
|
||
// globals.SugarLogger.Debugf("mtwm SyncStoreSkus4 skuID:%d, SkuSyncStatus:%d", skuItem.SkuID, skuItem.StoreSkuSyncStatus)
|
||
// sellStatus := skuStatusJX2Mtwm(jxutils.MergeSkuStatus(skuItem.Status, skuItem.StoreSkuStatus))
|
||
// if globals.EnableMtwmStoreWrite {
|
||
// if _, err2 := api.MtwmAPI.RetailSkuSellStatus(ctx.GetTrackInfo(), vendorStoreID, []*mtwmapi.BareStoreFoodInfo{
|
||
// &mtwmapi.BareStoreFoodInfo{
|
||
// AppFoodCode: utils.Int2Str(skuItem.SkuID),
|
||
// Skus: []*mtwmapi.BareStoreSkuInfo{
|
||
// &mtwmapi.BareStoreSkuInfo{
|
||
// SkuID: utils.Int2Str(skuItem.SkuID),
|
||
// },
|
||
// },
|
||
// },
|
||
// }, sellStatus); err2 != nil {
|
||
// err = err2
|
||
// }
|
||
// }
|
||
// }
|
||
// }
|
||
// }
|
||
// if err == nil {
|
||
// if len(updateFields) > 0 {
|
||
// _, err = dao.UpdateEntity(db, storeSkuBind, updateFields...)
|
||
// }
|
||
// } else if isErrModifyPrice(err) {
|
||
// // err = partner.NewErrorCode(err.Error(), partner.ErrCodeChangePriceFailed, model.VendorIDMTWM)
|
||
// }
|
||
// return nil, err
|
||
// }, skus)
|
||
// if parentTask != nil {
|
||
// parentTask.AddChild(rootTask)
|
||
// }
|
||
// rootTask.Run()
|
||
// if !isAsync {
|
||
// _, err = rootTask.GetResult(0)
|
||
// hint = utils.Int2Str(len(skus))
|
||
// } else {
|
||
// hint = rootTask.ID
|
||
// }
|
||
// return hint, err
|
||
// }
|
||
|
||
// func isErrModifyPrice(err error) bool {
|
||
// if errExt, ok := err.(*utils.ErrorWithCode); ok && errExt.IntCode() == 1 {
|
||
// for _, v := range []string{
|
||
// "折扣商品原价不允许修改",
|
||
// } {
|
||
// if strings.Index(errExt.ErrMsg(), v) >= 0 {
|
||
// return true
|
||
// }
|
||
// }
|
||
// }
|
||
// return false
|
||
// }
|
||
// func (p *PurchaseHandler) RefreshStoresAllSkusID(ctx *jxcontext.Context, parentTask tasksch.ITask, isAsync bool, storeIDs []int) (hint string, err error) {
|
||
// return hint, err
|
||
// }
|
||
|
||
// func (p *PurchaseHandler) FullSyncStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||
// userName := ctx.GetUserName()
|
||
// globals.SugarLogger.Debugf("mtwm FullSyncStoreSkus storeID:%d, isContinueWhenError:%t, userName:%s", storeID, isContinueWhenError, userName)
|
||
|
||
// db := dao.GetDB()
|
||
// storeDetail, err := dao.GetStoreDetail(db, storeID, model.VendorIDMTWM)
|
||
// if err != nil {
|
||
// return "", err
|
||
// }
|
||
|
||
// rootTask := tasksch.NewSeqTask("美团外卖FullSyncStoreSkus", ctx,
|
||
// func(rootTask *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
|
||
// switch step {
|
||
// case 0:
|
||
// err = p.DeleteStoreAllSkus(ctx, rootTask, storeID, storeDetail.VendorStoreID, isContinueWhenError)
|
||
// if isContinueWhenError {
|
||
// err = nil
|
||
// }
|
||
// if err == nil {
|
||
// _, err = dao.SetStoreSkuSyncStatus(db, model.VendorIDMTWM, []int{storeID}, nil, model.SyncFlagNewMask)
|
||
// }
|
||
// case 1:
|
||
// if err = p.DeleteStoreAllCategories(ctx, rootTask, storeID, storeDetail.VendorStoreID, isContinueWhenError); err == nil {
|
||
// _, err = dao.SetStoreCategorySyncStatus(db, model.VendorIDMTWM, []int{storeID}, nil, model.SyncFlagNewMask)
|
||
// }
|
||
// case 2:
|
||
// _, err = p.SyncLocalStoreCategory(ctx, db, storeID, true, nil)
|
||
// case 3:
|
||
// _, err = p.SyncStoreCategory(ctx, rootTask, storeID, false)
|
||
// case 4:
|
||
// _, err = p.SyncStoreSkus(ctx, rootTask, storeID, nil, false, isContinueWhenError)
|
||
// }
|
||
// return nil, err
|
||
// }, 5)
|
||
// tasksch.AddChild(parentTask, rootTask).Run()
|
||
// if !isAsync {
|
||
// _, err = rootTask.GetResult(0)
|
||
// }
|
||
// return rootTask.ID, err
|
||
// }
|