1
This commit is contained in:
@@ -142,12 +142,12 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
|||||||
}
|
}
|
||||||
// 根据本地商品id获取线上商品是否存在,存在则只创建子商品
|
// 根据本地商品id获取线上商品是否存在,存在则只创建子商品
|
||||||
// 获取本地存储映射关系,获取本地主商品id是否存在
|
// 获取本地存储映射关系,获取本地主商品id是否存在
|
||||||
var mainProductId int64 = 0
|
//var mainProductId int64 = 0
|
||||||
var mainOrderDetail *product_detail_response.ProductDetailData
|
//var mainOrderDetail *product_detail_response.ProductDetailData
|
||||||
localThing, _ := dao.GetThingToTiktokMapList(db, model.VendorIDDD, int64(storeSku.SkuID), storeDetail.VendorOrgCode)
|
localThing, _ := dao.GetThingToTiktokMapList(db, model.VendorIDDD, int64(storeSku.SkuID), storeDetail.VendorOrgCode)
|
||||||
if len(localThing) != 0 && localThing[0].VendorThingID != "" {
|
//if len(localThing) != 0 && localThing[0].VendorThingID != "" {
|
||||||
mainProductId = utils.Str2Int64(localThing[0].VendorThingID)
|
// mainProductId = utils.Str2Int64(localThing[0].VendorThingID)
|
||||||
}
|
//}
|
||||||
|
|
||||||
if len(localThing) == 0 {
|
if len(localThing) == 0 {
|
||||||
param, failedList2 := makeMainProductSku(db, api, storeSku, storeDetail, storeID, vendorStoreID, syncType)
|
param, failedList2 := makeMainProductSku(db, api, storeSku, storeDetail, storeID, vendorStoreID, syncType)
|
||||||
@@ -207,7 +207,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
|||||||
attrId = append(attrId, utils.Int64ToStr(v.SkuId))
|
attrId = append(attrId, utils.Int64ToStr(v.SkuId))
|
||||||
}
|
}
|
||||||
|
|
||||||
mainProductId = tiktokResult.ProductId
|
//mainProductId = tiktokResult.ProductId
|
||||||
storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID)
|
storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID)
|
||||||
storeSku.SkuSyncStatus = model.SyncFlagNewMask // 只创建主品,子品都没做
|
storeSku.SkuSyncStatus = model.SyncFlagNewMask // 只创建主品,子品都没做
|
||||||
storeSku.VendorMainId = utils.Int64ToStr(tiktokResult.ProductId)
|
storeSku.VendorMainId = utils.Int64ToStr(tiktokResult.ProductId)
|
||||||
@@ -240,7 +240,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
|||||||
for _, v := range tiktokResult.Sku {
|
for _, v := range tiktokResult.Sku {
|
||||||
attrId = append(attrId, utils.Int64ToStr(v.SkuId))
|
attrId = append(attrId, utils.Int64ToStr(v.SkuId))
|
||||||
}
|
}
|
||||||
mainProductId = tiktokResult.ProductId
|
//mainProductId = tiktokResult.ProductId
|
||||||
//storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID)
|
//storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID)
|
||||||
storeSku.SkuSyncStatus = model.SyncFlagNewMask // 只创建主品,子品都没做
|
storeSku.SkuSyncStatus = model.SyncFlagNewMask // 只创建主品,子品都没做
|
||||||
storeSku.VendorMainId = utils.Int64ToStr(tiktokResult.ProductId)
|
storeSku.VendorMainId = utils.Int64ToStr(tiktokResult.ProductId)
|
||||||
@@ -257,55 +257,55 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
|||||||
case model.ThingTypeSyncSuccess:
|
case model.ThingTypeSyncSuccess:
|
||||||
// 主商品存在,直接同步子商品
|
// 主商品存在,直接同步子商品
|
||||||
childrenProductId, sonSkuId, err := api.CreateSubProduct(utils.Str2Int64(localThing[0].VendorThingID), utils.Str2Int64(vendorStoreID))
|
childrenProductId, sonSkuId, err := api.CreateSubProduct(utils.Str2Int64(localThing[0].VendorThingID), utils.Str2Int64(vendorStoreID))
|
||||||
if err != nil && strings.Contains(err.Error(), "2010004") { // 2010004:主商品非在线审核通过状态,不允许绑定子商品
|
//if err != nil && strings.Contains(err.Error(), "2010004") { // 2010004:主商品非在线审核通过状态,不允许绑定子商品
|
||||||
// 线上本地都存在,但是线上审核不成功,就去更新主商品
|
// // 线上本地都存在,但是线上审核不成功,就去更新主商品
|
||||||
mainOrderDetail = loadMainProductId(api, storeSku, localThing[0].VendorThingID)
|
// mainOrderDetail = loadMainProductId(api, storeSku, localThing[0].VendorThingID)
|
||||||
if mainOrderDetail.CheckStatus == tiktokShop.SkuCheckStatusProhibit || mainOrderDetail.CheckStatus == tiktokShop.SkuCheckStatusNotPass {
|
// if mainOrderDetail.CheckStatus == tiktokShop.SkuCheckStatusProhibit || mainOrderDetail.CheckStatus == tiktokShop.SkuCheckStatusNotPass {
|
||||||
// 更新主商品,在同步到子门店,考虑审核时间
|
// // 更新主商品,在同步到子门店,考虑审核时间
|
||||||
param, failedList2 := makeMainProductSku(db, api, storeSku, storeDetail, storeID, vendorStoreID, syncType)
|
// param, failedList2 := makeMainProductSku(db, api, storeSku, storeDetail, storeID, vendorStoreID, syncType)
|
||||||
if len(failedList2) != 0 {
|
// if len(failedList2) != 0 {
|
||||||
failedList = append(failedList, failedList2...)
|
// failedList = append(failedList, failedList2...)
|
||||||
continue
|
// continue
|
||||||
}
|
// }
|
||||||
updateParam := &product_editV2_request.ProductEditV2Param{
|
// updateParam := &product_editV2_request.ProductEditV2Param{
|
||||||
PayType: tiktokShop.TiktokPayType1,
|
// PayType: tiktokShop.TiktokPayType1,
|
||||||
ReduceType: tiktokShop.SkuReduceTypePayMakeOrder,
|
// ReduceType: tiktokShop.SkuReduceTypePayMakeOrder,
|
||||||
Weight: utils.Int2Float64(storeSku.Weight),
|
// Weight: utils.Int2Float64(storeSku.Weight),
|
||||||
DeliveryDelayDay: tiktokShop.DeliveryDelayDayToDay,
|
// DeliveryDelayDay: tiktokShop.DeliveryDelayDayToDay,
|
||||||
PresellType: tiktokShop.SendGoodsTypeNow,
|
// PresellType: tiktokShop.SendGoodsTypeNow,
|
||||||
Mobile: storeDetail.Tel1,
|
// Mobile: storeDetail.Tel1,
|
||||||
Commit: true,
|
// Commit: true,
|
||||||
Specs: "重量|" + utils.Float64ToStr(float64(storeSku.SpecQuality)) + storeSku.SpecUnit,
|
// Specs: "重量|" + utils.Float64ToStr(float64(storeSku.SpecQuality)) + storeSku.SpecUnit,
|
||||||
NeedRechargeMode: false,
|
// NeedRechargeMode: false,
|
||||||
SellChannel: []int64{0},
|
// SellChannel: []int64{0},
|
||||||
StartSaleType: 0,
|
// StartSaleType: 0,
|
||||||
PickupMethod: "0",
|
// PickupMethod: "0",
|
||||||
CategoryLeafId: param.CategoryLeafId,
|
// CategoryLeafId: param.CategoryLeafId,
|
||||||
Name: param.Name,
|
// Name: param.Name,
|
||||||
ProductFormatNew: param.ProductFormatNew,
|
// ProductFormatNew: param.ProductFormatNew,
|
||||||
}
|
// }
|
||||||
// 是否支持七天无理由
|
// // 是否支持七天无理由
|
||||||
isAfterSale, rule := api.GetProductUpdateRule(param.CategoryLeafId)
|
// isAfterSale, rule := api.GetProductUpdateRule(param.CategoryLeafId)
|
||||||
if isAfterSale {
|
// if isAfterSale {
|
||||||
param.AfterSaleService = map[string]string{"supply_day_return_selector": fmt.Sprintf("%s", rule)}
|
// param.AfterSaleService = map[string]string{"supply_day_return_selector": fmt.Sprintf("%s", rule)}
|
||||||
}
|
// }
|
||||||
updateParam.Pic = param.Pic
|
// updateParam.Pic = param.Pic
|
||||||
updateParam.Description = param.Description
|
// updateParam.Description = param.Description
|
||||||
updateParam.WeightUnit = tiktokShop.WeightUint_G
|
// updateParam.WeightUnit = tiktokShop.WeightUint_G
|
||||||
|
//
|
||||||
updateParam.ProductId = mainOrderDetail.ProductId
|
// updateParam.ProductId = mainOrderDetail.ProductId
|
||||||
updateParam.MainProductId = mainProductId
|
// updateParam.MainProductId = mainProductId
|
||||||
updateParam.SpecPrices = param.SpecPrices
|
// updateParam.SpecPrices = param.SpecPrices
|
||||||
updateParam.StandardBrandId = param.StandardBrandId
|
// updateParam.StandardBrandId = param.StandardBrandId
|
||||||
if err2 := api.EditStoreCommodity(updateParam); err2 != nil {
|
// if err2 := api.EditStoreCommodity(updateParam); err2 != nil {
|
||||||
failedList = putils.GetErrMsg2FailedSingleList(storeSku, err2, storeID, model.VendorChineseNames[model.VendorIDDD], syncType)
|
// failedList = putils.GetErrMsg2FailedSingleList(storeSku, err2, storeID, model.VendorChineseNames[model.VendorIDDD], syncType)
|
||||||
storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID)
|
// storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID)
|
||||||
}
|
// }
|
||||||
storeSku.SkuSyncStatus = model.SyncFlagNewMask // 只创建主品,子品都没做
|
// storeSku.SkuSyncStatus = model.SyncFlagNewMask // 只创建主品,子品都没做
|
||||||
failedList = putils.GetErrMsg2FailedSingleList(storeSku, errors.New("修改主品,主品审核中/失败,子商品未创建"), storeID, model.VendorChineseNames[model.VendorIDDD], syncType)
|
// failedList = putils.GetErrMsg2FailedSingleList(storeSku, errors.New("修改主品,主品审核中/失败,子商品未创建"), storeID, model.VendorChineseNames[model.VendorIDDD], syncType)
|
||||||
continue
|
// continue
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
if sonSkuId != "" {
|
if sonSkuId != "" {
|
||||||
storeSku.VendorSonSkuID = sonSkuId
|
storeSku.VendorSonSkuID = sonSkuId
|
||||||
}
|
}
|
||||||
@@ -317,8 +317,10 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
|||||||
failedList = append(failedList, failedList3...)
|
failedList = append(failedList, failedList3...)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
storeSku.VendorSkuID = utils.Int64ToStr(storeSkuDetail.ProductId)
|
||||||
storeSku.VendorSonSkuID = utils.Int64ToStr(storeSkuDetail.SpecPrices[0].SkuId)
|
storeSku.VendorSonSkuID = utils.Int64ToStr(storeSkuDetail.SpecPrices[0].SkuId)
|
||||||
childrenProductId = storeSkuDetail.ProductId
|
childrenProductId = storeSkuDetail.ProductId
|
||||||
|
dao.ExecuteSQL(dao.GetDB(), ` UPDATE store_sku_bind s SET s.dd_id = ?,s.vendor_son_sku_id = ? WHERE s.store_id = ? AND s.sku_id = ?`, []interface{}{storeSku.VendorSkuID, storeSku.VendorSonSkuID, storeID, storeSku.SkuID}...)
|
||||||
}
|
}
|
||||||
|
|
||||||
if childrenProductId != model.NO {
|
if childrenProductId != model.NO {
|
||||||
@@ -763,6 +765,7 @@ func getProductSkuId4UpdateStock(api *tiktokShop.API, skuInfo *partner.StoreSkuI
|
|||||||
tiktokSkuId = v.SkuId
|
tiktokSkuId = v.SkuId
|
||||||
skuInfo.VendorSonSkuID = utils.Int64ToStr(v.SkuId)
|
skuInfo.VendorSonSkuID = utils.Int64ToStr(v.SkuId)
|
||||||
skuInfo.VendorSkuID = childrenSku.ProductIdStr
|
skuInfo.VendorSkuID = childrenSku.ProductIdStr
|
||||||
|
dao.ExecuteSQL(dao.GetDB(), ` UPDATE store_sku_bind s SET s.dd_id = ?,s.vendor_son_sku_id = ? WHERE s.store_id = ? AND s.sku_id = ?`, []interface{}{skuInfo.VendorSkuID, skuInfo.VendorSonSkuID, storeId, skuInfo.SkuID}...)
|
||||||
return tiktokSkuId, nil
|
return tiktokSkuId, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user