京东商城建商品开测

This commit is contained in:
苏尹岚
2020-05-13 09:43:27 +08:00
parent 7b05c7b87a
commit 5f901f8531
11 changed files with 243 additions and 34 deletions

View File

@@ -398,9 +398,9 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag
formalizeStoreSkuList(skus)
//京东商城的商品名规则不同
//name空格comment约xxg
if vendorID == model.VendorIDJDShop {
formalizeStoreSkuListForJds(skus)
}
// if vendorID == model.VendorIDJDShop {
// formalizeStoreSkuListForJds(skus)
// }
singleStoreHandler, _ := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.ISingleStoreStoreSkuHandler)
storeSkuHandler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.IPurchasePlatformStoreSkuHandler)
@@ -576,6 +576,14 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag
api.YinBaoAPI.SetCookie(".POSPALAUTH30220", yinbaoCookie)
}
}
//如果平台是京东商城则按商品skuname创建
if vendorID == model.VendorIDJDShop {
if len(createList) > 0 {
rList := changeList2Jds(createList)
createList = createList[:]
createList = rList
}
}
task := tasksch.NewParallelTask("syncStoreSkuNew", tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(isContinueWhenError2), ctx,
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
step := batchItemList[0].(int)
@@ -1346,3 +1354,26 @@ func changeList2Yb(list1 []*dao.StoreSkuSyncInfo, list2 []*partner.StoreSkuInfo)
}
return rList1, rList2
}
func changeList2Jds(list []*dao.StoreSkuSyncInfo) (rList []*dao.StoreSkuSyncInfo) {
var (
skuNameMap = make(map[int][]*dao.StoreSkuSyncInfo)
)
for _, v := range list {
skuNameMap[v.NameID] = append(skuNameMap[v.NameID], v)
}
for k, v := range skuNameMap {
storeSku := &dao.StoreSkuSyncInfo{
StoreSkuSyncInfoJds: v,
}
storeSku.NameID = k
storeSku.Name = v[0].Name
storeSku.VendorCatID = v[0].VendorCatID
storeSku.VendorVendorCatID = v[0].VendorVendorCatID
storeSku.UnitPrice = v[0].UnitPrice
storeSku.Img = v[0].Img
storeSku.Img2 = v[0].Img2
rList = append(rList, storeSku)
}
return rList
}