- 重构partner_store_sku

This commit is contained in:
gazebo
2019-07-13 10:37:08 +08:00
parent cde87bb667
commit 01c522b5b0
9 changed files with 102 additions and 68 deletions

View File

@@ -2065,25 +2065,25 @@ func RefreshStoresSkuByVendor(ctx *jxcontext.Context, storeIDs []int, vendorID i
return hint, err
}
func GetVendorStoreSkusInfo(ctx *jxcontext.Context, storeID int, vendorIDs, skuIDs []int, isContinueWhenError bool) (skuVendorMap map[int][]*partner.BareStoreSkuInfo, err error) {
func GetVendorStoreSkusInfo(ctx *jxcontext.Context, storeID int, vendorIDs, skuIDs []int, isContinueWhenError bool) (skuVendorMap map[int][]*partner.StoreSkuInfo, err error) {
globals.SugarLogger.Debugf("GetVendorStoreSkusInfo, storeID:%d, vendorIDs:%v, skuID:%v", storeID, vendorIDs, skuIDs)
db := dao.GetDB()
var locker sync.RWMutex
skuVendorMap = make(map[int][]*partner.BareStoreSkuInfo)
skuVendorMap = make(map[int][]*partner.StoreSkuInfo)
_, err = CurVendorSync.LoopStoresMap(ctx, db, fmt.Sprintf("GetVendorStoreSkusInfo storeID:%d", storeID), false, false, vendorIDs, []int{storeID},
func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (interface{}, error) {
loopMapInfo := batchItemList[0].(*LoopStoreMapInfo)
if handler, _ := partner.GetPurchasePlatformFromVendorID(loopMapInfo.VendorID).(partner.IPurchasePlatformStoreSkuHandler); handler != nil {
storeSkuList, err2 := dao.GetStoreSkus2(db, loopMapInfo.VendorID, storeID, skuIDs, false)
if err = err2; err == nil && len(storeSkuList) > 0 {
bareStoreSkuInfoList := make([]*partner.BareStoreSkuInfo, len(skuIDs))
bareStoreSkuInfoList := make([]*partner.StoreSkuInfo, len(skuIDs))
for k, v := range storeSkuList {
bareStoreSkuInfoList[k] = &partner.BareStoreSkuInfo{
bareStoreSkuInfoList[k] = &partner.StoreSkuInfo{
SkuID: v.SkuID,
VendorSkuID: v.VendorSkuID,
}
}
outBareStoreSkuInfoList, err2 := handler.GetStoreSkusInfo(ctx, t, loopMapInfo.StoreMapList[0].StoreID, loopMapInfo.StoreMapList[0].VendorStoreID, bareStoreSkuInfoList)
outBareStoreSkuInfoList, err2 := handler.GetStoreSkusBareInfo(ctx, t, loopMapInfo.StoreMapList[0].StoreID, loopMapInfo.StoreMapList[0].VendorStoreID, bareStoreSkuInfoList)
if err = err2; err == nil && outBareStoreSkuInfoList != nil {
locker.Lock()
defer locker.Unlock()

View File

@@ -14,7 +14,7 @@ func SyncStoreSkuNew(ctx *jxcontext.Context, vendorIDs, storeIDs, nameIDs, skuID
}
func DeleteStoreAllSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, handler partner.ISingleStoreStoreSkuHandler, storeID int, vendorStoreID string, isContinueWhenError bool) (err error) {
skuNameList, err := handler.GetStoreAllSkus(ctx, storeID, vendorStoreID)
skuNameList, err := handler.GetStoreSkusFullInfo(ctx, parentTask, storeID, vendorStoreID, nil)
if err != nil {
return err
}
@@ -22,10 +22,10 @@ func DeleteStoreAllSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, handle
task := tasksch.NewParallelTask(fmt.Sprintf("DeleteStoreAllSkus, vendorStoreID:%s", vendorStoreID),
tasksch.NewParallelConfig().SetBatchSize(batchSize).SetIsContinueWhenError(isContinueWhenError), ctx,
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
var skuList []*partner.BareStoreSkuInfo
var skuList []*partner.StoreSkuInfo
for _, v := range batchItemList {
skuName := v.(*partner.SkuNameInfo)
skuList = append(skuList, &partner.BareStoreSkuInfo{
skuList = append(skuList, &partner.StoreSkuInfo{
VendorSkuID: skuName.SkuList[0].VendorSkuID,
})
}