This commit is contained in:
邹宗楠
2022-10-21 18:22:34 +08:00
parent 42d8944e46
commit 04f1190953

View File

@@ -313,9 +313,11 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
return nil, err
}
globals.SugarLogger.Debugf("本地商品详情============%s,", utils.Format4Output(param, false))
// 根据本地商品id获取线上商品是否存在,存在则只创建子商品
var tiktokResultProductId int64 = 0
skuMain, err := api.GetSkuDetailLocalID("", param.OuterProductId)
globals.SugarLogger.Debugf("线上商品详情(主)============%s,", utils.Format4Output(skuMain, false))
if err != nil { // 线上不存在创建
tiktokResult, err := api.CreateStoreCommodity(param) // 创建主商品
if err != nil {
@@ -341,19 +343,14 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
// 创建子商品
temp, err := dao.QueryStoreBindInfo(storeDetail.ID)
globals.SugarLogger.Debugf("er2==============err创建子商品%s", utils.Format4Output(temp, false))
if err != nil || temp == nil || temp.TemplateID == 0 {
// 运费模板
param.FreightId, err = GetDeliveryTemp(api, vendorStoreID, storeDetail)
globals.SugarLogger.Debugf("er2==============FreightId%s", utils.Format4Output(param.FreightId, false))
globals.SugarLogger.Debugf("er2==============FreightId%s", utils.Format4Output(err, false))
if err != nil {
return nil, err
}
// 获取门店限售模板
param.SaleLimitId, err = CreateSaleTemp(utils.Str2Int64(vendorStoreID), api)
globals.SugarLogger.Debugf("er2==============SaleLimitId%s", utils.Format4Output(param.SaleLimitId, false))
globals.SugarLogger.Debugf("er2==============SaleLimitId%s", utils.Format4Output(err, false))
if err != nil {
return nil, err
}
@@ -366,11 +363,8 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
FenceID: "",
TradeLimitID: param.SaleLimitId,
}
globals.SugarLogger.Debugf("111111111111111111111=========%s", utils.Format4Output(freightTemplate, false))
dao.WrapAddIDCULDEntity(freightTemplate, "jxAdmin")
globals.SugarLogger.Debugf("22222222222222222=========%s", utils.Format4Output(freightTemplate, false))
err = dao.CreateEntity(dao.GetDB(), freightTemplate)
globals.SugarLogger.Debugf("er2==============CreateEntity%s", utils.Format4Output(err, false))
} else {
param.FreightId = temp.TemplateID
param.SaleLimitId = temp.TradeLimitID
@@ -380,8 +374,9 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
param.SpecPrices = GetSpecPrices(param.Specs, vendorStoreID, tiktokResultProductId, storeSku)
param.StoreId = utils.Str2Int64(vendorStoreID)
globals.SugarLogger.Debugf("============CreateStoreCommodity:%s", utils.Format4Output(param, false))
// 抖店创建子商品
globals.SugarLogger.Debugf("本地子商品详情============%s,", utils.Format4Output(param, false))
tiktokResultChildren, err := api.CreateStoreCommodity(param)
if err != nil {
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorChineseNames[model.VendorIDDD], syncType)