From 2f6274e204ac69ef233e19e5e1382faa41884dcc Mon Sep 17 00:00:00 2001 From: gazebo Date: Mon, 26 Nov 2018 09:24:24 +0800 Subject: [PATCH] - debug LockPromotionSkus --- business/jxstore/promotion/jd_promotion.go | 9 ++-- business/partner/purchase/mtwm/store_sku.go | 48 +++++++++++++++++++++ 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/business/jxstore/promotion/jd_promotion.go b/business/jxstore/promotion/jd_promotion.go index 7e9ccdd19..af635e2df 100644 --- a/business/jxstore/promotion/jd_promotion.go +++ b/business/jxstore/promotion/jd_promotion.go @@ -834,7 +834,7 @@ func RefreshJdPromotionLockStatus(ctx *jxcontext.Context, promotionID int) (err } func LockPromotionSkus(ctx *jxcontext.Context, promotionID int, isLock int, skuIDs []int) (num int64, err error) { - globals.SugarLogger.Debugf("LockPromotionSkus promotionID:%d, isLock:%t, skuIDs:%v", promotionID, isLock, skuIDs) + globals.SugarLogger.Debugf("begin LockPromotionSkus promotionID:%d, isLock:%t, skuIDs:%v", promotionID, isLock, skuIDs) if isLock != 0 { isLock = 1 } @@ -865,6 +865,7 @@ func LockPromotionSkus(ctx *jxcontext.Context, promotionID int, isLock int, skuI RefreshJdStoreSkuStock() } } + globals.SugarLogger.Debugf("end LockPromotionSkus promotionID:%d, isLock:%t, skuIDs:%v", promotionID, isLock, skuIDs) return num, err } @@ -1000,10 +1001,12 @@ func createLocalPromotionFromRemote(promotionInfoId int64) (retVal *jdapi.Callba return jdapi.Err2CallbackResponse(nil, "") } -func UpdatePromotionStatusFromRemote(ctx *jxcontext.Context, prommotionID int) (err error) { +func UpdatePromotionStatusFromRemote(ctx *jxcontext.Context, promotionID int) (err error) { + globals.SugarLogger.Debugf("UpdatePromotionStatusFromRemote promotionID:%d", promotionID) + db := dao.GetDB() promotion := &model.Promotion{} - promotion.ID = prommotionID + promotion.ID = promotionID if err = dao.GetEntity(db, promotion); err != nil { return err } diff --git a/business/partner/purchase/mtwm/store_sku.go b/business/partner/purchase/mtwm/store_sku.go index 55fe2351a..ea2ce2dc6 100644 --- a/business/partner/purchase/mtwm/store_sku.go +++ b/business/partner/purchase/mtwm/store_sku.go @@ -66,10 +66,58 @@ func (p *PurchaseHandler) SyncStoreCategory(ctx *jxcontext.Context, parentTask t } return rootTask.ID, err } + func (p *PurchaseHandler) ReadStoreCategories(storeID int) (cats []*model.SkuCategory, err error) { return nil, nil } +func (p *PurchaseHandler) SyncLocalStoreCategory(db *dao.DaoDB, storeID int, userName string) (err error) { + remoteCats, err := api.MtwmAPI.RetailCatList(utils.Int2Str(storeID)) + if err == nil { + return err + } + if db == nil { + db = dao.GetDB() + } + catMap := make(map[string]*dao.StoreCatSyncInfo) + for i := 0; i < 2; i++ { + localCats, err := dao.GetStoreCategories(db, model.VendorIDMTWM, storeID, i+1) + if err != nil { + return err + } + for _, cat := range localCats { + cat.StoreSkuCategoryMap.MtwmSyncStatus = model.SyncFlagNewMask + catMap[cat.ParentVendorCatID+"/"+cat.MtwmID] = cat + } + } + strStoreID := utils.Int2Str(storeID) + + processRemoteCat := func(catName, parentCatName string) (err error) { + localCat := catMap[parentCatName+"/"+catName] + if localCat == nil { + if err = api.MtwmAPI.RetailCatDelete(strStoreID, catName); err != nil { + return err + } + } else { + // localCat.StoreSkuCategoryMap.MtwmSyncStatus = model.SyncFlagModifiedMask + } + return nil + } + + for _, remoteCat := range remoteCats { + name := utils.Interface2String(remoteCat.Name) + if err = processRemoteCat("", name); err != nil { + return err + } + for _, subRemoteCat := range remoteCat.Children { + if err = processRemoteCat(name, utils.Interface2String(subRemoteCat.Name)); err != nil { + return err + } + } + } + return err +} + func (p *PurchaseHandler) ReadStoreSku(storeID, skuID int) (skuNameExt *model.SkuNameExt, err error) { return nil, nil }