This commit is contained in:
邹宗楠
2023-01-05 09:04:32 +08:00
parent 8a8b83d568
commit 1c390bc99b

View File

@@ -273,7 +273,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
// 主商品存在,直接同步子商品
childrenProductId, err := api.CreateSubProduct(utils.Str2Int64(localThing[0].VendorThingID), utils.Str2Int64(vendorStoreID))
globals.SugarLogger.Debugf("===============err %s", err.Error())
globals.SugarLogger.Debugf("===============err %s", utils.Format4Output(err != nil && strings.Contains(err.Error(), "2010004"), false))
globals.SugarLogger.Debugf("===============childrenProductId %d", childrenProductId)
if err != nil && strings.Contains(err.Error(), "2010004") { // 2010004:主商品非在线审核通过状态,不允许绑定子商品
// 线上本地都存在,但是线上审核不成功,就去更新主商品
mainOrderDetail = loadMainProductId(api, storeSku, localThing[0].VendorThingID)
@@ -486,6 +486,7 @@ func checkNameLenght(name string) string {
return name
}
func upDateChildrenPriceStockLaunch(api *tiktokShop.API, storeSku *dao.StoreSkuSyncInfo, childrenProductId int64, vendorStoreID, syncType string) (failedList []*partner.StoreSkuInfoWithErr) {
globals.SugarLogger.Debugf("===========1")
skuId, failed := getProductSkuID(api, storeSku, syncType, childrenProductId)
if skuId == 0 || len(failed) > 0 {
return failed
@@ -497,7 +498,10 @@ func upDateChildrenPriceStockLaunch(api *tiktokShop.API, storeSku *dao.StoreSkuS
ProductId: childrenProductId,
}); err != nil {
failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeSku.StoreID, model.VendorChineseNames[model.VendorIDDD], syncType)
globals.SugarLogger.Debugf("===========2 failedList %s", utils.Format4Output(failedList, false))
}
globals.SugarLogger.Debugf("===========2")
// 同步库存
paramStock := &sku_syncStock_request.SkuSyncStockParam{
ProductId: childrenProductId,
@@ -510,17 +514,21 @@ func upDateChildrenPriceStockLaunch(api *tiktokShop.API, storeSku *dao.StoreSkuS
}
if err := api.UpdateSkuStock(paramStock); err != nil {
failedList = append(failedList, putils.GetErrMsg2FailedSingleList(storeSku, err, storeSku.StoreID, model.VendorChineseNames[model.VendorIDDD], fmt.Sprintf("子商品添加固定库存.%s", err.Error()))...)
globals.SugarLogger.Debugf("===========3 failedList %s", utils.Format4Output(failedList, false))
}
globals.SugarLogger.Debugf("===========3")
// 上架
if err := api.LaunchProduct(childrenProductId); err != nil {
failedList = append(failedList, putils.GetErrMsg2FailedSingleList(storeSku, err, storeSku.StoreID, model.VendorChineseNames[model.VendorIDDD], fmt.Sprintf("上架子商品异常.%s", err.Error()))...)
globals.SugarLogger.Debugf("===========4 failedList %s", utils.Format4Output(failedList, false))
}
if len(failedList) > 0 {
storeSku.SkuSyncStatus = model.SyncFlagStoreSkuModifiedMask
} else {
storeSku.SkuSyncStatus = 0
}
globals.SugarLogger.Debugf("====upDateChildrenPriceStockLaunch===,%s", utils.Format4Output(failedList, false))
globals.SugarLogger.Debugf("====upDateChildrenPriceStockLaunch=== 444444,%s", utils.Format4Output(failedList, false))
return failedList
}
@@ -532,6 +540,7 @@ func getProductSkuID(api *tiktokShop.API, storeSku *dao.StoreSkuSyncInfo, syncTy
childrenDetail, err := api.GetSkuDetail(utils.Int64ToStr(productId), "")
if err != nil {
failedList = putils.GetErrMsg2FailedSingleList(storeSku, err, storeSku.StoreID, model.VendorChineseNames[model.VendorIDDD], syncType)
return 0, failedList
}
for _, v := range childrenDetail.SpecPrices {