This commit is contained in:
邹宗楠
2023-10-26 15:50:35 +08:00
parent 034a753655
commit a3aff03c98
2 changed files with 13 additions and 8 deletions

View File

@@ -171,7 +171,7 @@ func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, vendorOr
func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) { func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) {
api := getAPI(vendorOrgCode, storeID, vendorStoreID) api := getAPI(vendorOrgCode, storeID, vendorStoreID)
for _, v := range storeSkuList { for _, v := range storeSkuList {
tiktokSkuId, failedList := getProductSkuId4UpdateStock(api, v, storeID) tiktokSkuId, failedList := getProductSkuId4UpdateStock(api, v, storeID, vendorStoreID)
if len(failedList) > 0 { if len(failedList) > 0 {
return failedList, err return failedList, err
} }

View File

@@ -287,10 +287,15 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
} }
} }
if (err != nil || childrenProductId == 0) && !strings.Contains(err.Error(), "2010001") { // 2010001:重复创建渠道商品,就去更新 if err != nil && strings.Contains(err.Error(), "2010001") { // 2010001:重复创建渠道商品
failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) storeSkuDetail, err := api.GetSkuDetailLocalID(vendorStoreID, utils.Int2Str(storeSku.SkuID))
if err != nil {
failedList3 := putils.GetErrMsg2FailedSingleList(storeSku, errors.New("获取子品详情错误:"+err.Error()), storeID, model.VendorChineseNames[model.VendorIDDD], syncType)
failedList = append(failedList, failedList3...)
continue continue
} }
childrenProductId = storeSkuDetail.ProductId
}
// 同步价格,库存,上架 // 同步价格,库存,上架
failedList2 := upDateChildrenPriceStockLaunch(api, storeSku, childrenProductId, vendorStoreID, syncType) failedList2 := upDateChildrenPriceStockLaunch(api, storeSku, childrenProductId, vendorStoreID, syncType)
@@ -404,12 +409,12 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
param.ProductId = mainIdInt param.ProductId = mainIdInt
param.MainProductId = mainIdInt param.MainProductId = mainIdInt
param.SpecPrices = GetSpecPrices(param.Specs, vendorStoreID, param.MainProductId, storeSku) param.SpecPrices = GetSpecPrices(param.Specs, vendorStoreID, param.MainProductId, storeSku)
if err := api.EditStoreCommodity(param); err != nil { if err := api.EditStoreCommodity(param); err != nil && !strings.Contains(err.Error(), "您上传的商品主图存在重复") {
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType) failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType)
storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID) storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID)
} else { } else {
// todo 暂时关闭之后解开 // todo 暂时关闭之后解开
//upDateChildrenPriceStockLaunch(api, storeSku, utils.Str2Int64(storeSku.VendorSkuID), vendorStoreID, syncType) upDateChildrenPriceStockLaunch(api, storeSku, utils.Str2Int64(storeSku.VendorSkuID), vendorStoreID, syncType)
} }
//storeSku.SkuSyncStatus = model.SyncFlagStoreSkuModifiedMask // 品库修改 售卖状态待同步 价格待同步 //storeSku.SkuSyncStatus = model.SyncFlagStoreSkuModifiedMask // 品库修改 售卖状态待同步 价格待同步
@@ -691,7 +696,7 @@ func getProductSkuID(api *tiktokShop.API, storeSku *dao.StoreSkuSyncInfo, syncTy
return 0, putils.GetErrMsg2FailedSingleList(storeSku, fmt.Errorf("获取商品抖音skuId失败[%d]", productId), storeSku.StoreID, model.VendorChineseNames[model.VendorIDDD], syncType) return 0, putils.GetErrMsg2FailedSingleList(storeSku, fmt.Errorf("获取商品抖音skuId失败[%d]", productId), storeSku.StoreID, model.VendorChineseNames[model.VendorIDDD], syncType)
} }
func getProductSkuId4UpdateStock(api *tiktokShop.API, skuInfo *partner.StoreSkuInfo, storeId int) (tiktokSkuId int64, failedList []*partner.StoreSkuInfoWithErr) { func getProductSkuId4UpdateStock(api *tiktokShop.API, skuInfo *partner.StoreSkuInfo, storeId int, vendorStoreId string) (tiktokSkuId int64, failedList []*partner.StoreSkuInfoWithErr) {
if skuInfo.VendorSonSkuID != "" && skuInfo.VendorSonSkuID != skuInfo.VendorSkuID && len(skuInfo.VendorSonSkuID) >= len("3589393056912261100") { // 抖音长度 if skuInfo.VendorSonSkuID != "" && skuInfo.VendorSonSkuID != skuInfo.VendorSkuID && len(skuInfo.VendorSonSkuID) >= len("3589393056912261100") { // 抖音长度
return utils.Str2Int64(skuInfo.VendorSonSkuID), nil return utils.Str2Int64(skuInfo.VendorSonSkuID), nil
} }
@@ -705,7 +710,7 @@ func getProductSkuId4UpdateStock(api *tiktokShop.API, skuInfo *partner.StoreSkuI
return 0, failedList return 0, failedList
} }
} else { } else {
childrenSku, err = api.GetSkuDetailLocalID("", skuInfo.VendorSkuID) childrenSku, err = api.GetSkuDetailLocalID(vendorStoreId, skuInfo.VendorSkuID)
if err != nil || len(childrenSku.SpecPrices) <= 0 { if err != nil || len(childrenSku.SpecPrices) <= 0 {
failedList = append(failedList, putils.GetErrMsg2FailedSingleList(skuInfo, err, storeId, model.VendorChineseNames[model.VendorIDDD], "修改库存[err为空,子商品skuId未获取到]")...) failedList = append(failedList, putils.GetErrMsg2FailedSingleList(skuInfo, err, storeId, model.VendorChineseNames[model.VendorIDDD], "修改库存[err为空,子商品skuId未获取到]")...)
return 0, failedList return 0, failedList