From af6533fd9b4a49978d2049ed730ea5e0052bb737 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Wed, 9 Nov 2022 14:36:02 +0800 Subject: [PATCH] 1 --- business/jxstore/cms/sync_store_sku.go | 6 +++ business/model/dao/store_sku.go | 9 +++-- business/model/store_sku.go | 3 +- business/partner/partner_store_sku.go | 5 ++- .../purchase/tiktok_store/store_sku2.go | 39 +++++++------------ .../purchase/tiktok_store/store_sku2_utils.go | 5 +++ 6 files changed, 35 insertions(+), 32 deletions(-) diff --git a/business/jxstore/cms/sync_store_sku.go b/business/jxstore/cms/sync_store_sku.go index afa4d4c55..2a06c820b 100644 --- a/business/jxstore/cms/sync_store_sku.go +++ b/business/jxstore/cms/sync_store_sku.go @@ -279,6 +279,9 @@ func storeSkuSyncInfo2Bare(inSku *dao.StoreSkuSyncInfo) (outSku *partner.StoreSk if inSku.VendorSkuAttrId != "" { outSku.VendorSkuAttrId = inSku.VendorSkuAttrId } + if inSku.VendorSonSkuID != "" { + outSku.VendorSonSkuID = inSku.VendorSonSkuID + } return outSku } @@ -379,6 +382,9 @@ func sku2Update(vendorID int, sku *dao.StoreSkuSyncInfo, syncStatus int8) (item if sku.VendorSkuAttrId != "" { kvs["VendorSkuAttrId"] = sku.VendorSkuAttrId } + if sku.VendorSonSkuID != "" { + kvs["VendorSonSkuID"] = sku.VendorSonSkuID + } storeSku := &model.StoreSkuBind{} storeSku.ID = sku.BindID item = &dao.KVUpdateItem{ diff --git a/business/model/dao/store_sku.go b/business/model/dao/store_sku.go index cb5136be8..9edc32907 100644 --- a/business/model/dao/store_sku.go +++ b/business/model/dao/store_sku.go @@ -75,9 +75,10 @@ type StoreSkuSyncInfo struct { // 平台相关的store sku信息 StoreSkuStatus int // 库存状态 SkuSyncStatus int8 // 锁定状态 - VendorSkuID string `orm:"column(vendor_sku_id)"` - VendorSkuAttrId string `orm:"column(vendor_sku_attr_id)"` - VendorMainId string `orm:"column(vendor_main_id)"` + VendorSkuID string `orm:"column(vendor_sku_id)"` // 子商品id + VendorSonSkuID string `orm:"column(vendor_son_sku_id)"` // 子商品skuid + VendorSkuAttrId string `orm:"column(vendor_sku_attr_id)"` // 主商品skuid + VendorMainId string `orm:"column(vendor_main_id)"` // 主商品id JdsWareID int64 `orm:"column(jds_ware_id)" json:"jdsWareID"` BindDeletedAt time.Time `orm:"type(datetime)" json:"bindDeletedAt"` @@ -566,7 +567,7 @@ func GetStoreSkus2(db *DaoDB, vendorID, storeID int, skuIDs []int, mustDirty boo SELECT t14.vendor_id, t14.vendor_org_code, t1.id bind_id, t1.sku_id, t1.price, t1.unit_price, t1.status store_sku_status, - %s vendor_sku_id, t1.%s_sync_status sku_sync_status, t1.%s_price vendor_price, t1.%s_lock_time lock_time,t1.vendor_sku_attr_id,t1.vendor_main_id, + %s vendor_sku_id, t1.%s_sync_status sku_sync_status, t1.%s_price vendor_price, t1.%s_lock_time lock_time,t1.vendor_son_sku_id,t1.vendor_sku_attr_id,t1.vendor_main_id, t1.store_id, t1.deleted_at bind_deleted_at,t1.status_sale_begin,t1.status_sale_end, t1.jds_ware_id, t1.stock, t1.mt_ladder_box_price, t2.*, t3.id name_id, t3.prefix, t3.name, t3.unit, t3.upc, t3.status name_status, t3.category_id name_category_id, t3.yb_name_suffix,t3.tiktok_attribute, diff --git a/business/model/store_sku.go b/business/model/store_sku.go index 210462ab1..7e84ef0e8 100644 --- a/business/model/store_sku.go +++ b/business/model/store_sku.go @@ -115,13 +115,14 @@ type StoreSkuBind struct { // ElmID int64 `orm:"column(elm_id);index"` MtwmID int64 `orm:"column(mtwm_id);index"` EbaiID int64 `orm:"column(ebai_id);index"` - DdID int64 `orm:"column(dd_id);index"` // 子品主商品id YbID int64 `orm:"column(yb_id);index"` JdsID int64 `orm:"column(jds_id);index"` JdsWareID int64 `orm:"column(jds_ware_id)"` //GmID string `orm:"column(gm_id)"` // WscID int64 `orm:"column(wsc_id);index"` // 表示微盟skuId // WscID2 int64 `orm:"column(wsc_id2);index"` // 表示微盟goodsId + DdID int64 `orm:"column(dd_id);index"` // 子品主商品id + VendorSonSkuID string `orm:"column(vendor_son_sku_id)"` // 子商品skuid VendorSkuAttrId string `orm:"column(vendor_sku_attr_id)"` // 抖音需要,主品skuid VendorMainId string `orm:"column(vendor_Main_id)"` // 抖音需要,商品主id diff --git a/business/partner/partner_store_sku.go b/business/partner/partner_store_sku.go index bf12c3a6b..8b212223a 100644 --- a/business/partner/partner_store_sku.go +++ b/business/partner/partner_store_sku.go @@ -56,8 +56,9 @@ type StoreSkuInfo struct { SpecUnit string `json:"specUnit"` SpecQuality float32 `json:"specQuality"` - VendorMainId string `json:"vendorMainId"` - VendorSkuAttrId string `json:"vendorSkuAttrId"` + VendorMainId string `json:"vendorMainId"` // 主商品id + VendorSkuAttrId string `json:"vendorSkuAttrId"` //主商品sku_id + VendorSonSkuID string `json:"vendorSonSkuID"` // 子商品skuid } type StoreSkuInfoWithErr struct { diff --git a/business/partner/purchase/tiktok_store/store_sku2.go b/business/partner/purchase/tiktok_store/store_sku2.go index 5d2d351df..82b009442 100644 --- a/business/partner/purchase/tiktok_store/store_sku2.go +++ b/business/partner/purchase/tiktok_store/store_sku2.go @@ -281,33 +281,22 @@ 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) { api := getAPI(vendorOrgCode, storeID, vendorStoreID) for _, v := range storeSkuList { - //param := &product_editV2_request.ProductEditV2Param{} - //param.ProductId = utils.Str2Int64(v.VendorSkuID) - //param.Specs = "净重|" + fmt.Sprintf("%f", v.SpecQuality) + v.SpecUnit - // - //skuSize := make([]*tiktokShop.SpecDetailList, 0, 0) - //detail1 := strings.Split(param.Specs, "^") - //name1 := strings.Split(strings.Split(detail1[0], "|")[1], ",") - //for i := 0; i < len(name1); i++ { - // sku := &tiktokShop.SpecDetailList{ - // SpecDetailName1: name1[i], - // StockNum: v.Stock, - // Price: int(v.VendorPrice), - // Code: utils.Int2Str(v.SkuID), - // StepStockNum: 0, - // SupplierID: "", - // OuterSkuID: utils.Int2Str(v.NameID), - // DeliveryInfos: []*tiktokShop.DeliveryInfos{ - // {InfoType: "weight", InfoUnit: v.SpecUnit, InfoValue: fmt.Sprintf("%f", v.SpecQuality)}, - // }, - // } - // skuSize = append(skuSize, sku) - //} - //data, _ := json.Marshal(skuSize) - //param.SpecPrices = string(data) - err := api.EditPrice(&sku_editPrice_request.SkuEditPriceParam{ + // 更新主品 + err = api.EditPrice(&sku_editPrice_request.SkuEditPriceParam{ Price: v.VendorPrice, SkuId: utils.Str2Int64(v.VendorSkuAttrId), + ProductId: utils.Str2Int64(v.VendorMainId), + }) + if err != nil { + failedList = append(failedList, putils.GetErrMsg2FailedSingleList(v, err, storeID, model.VendorChineseNames[model.VendorIDDD], "更新主品价格异常")...) + } else { + failedList = append(failedList, putils.GetErrMsg2FailedSingleList(v, err, storeID, model.VendorChineseNames[model.VendorIDDD], "更新主品价格正常")...) + } + + // 更新子品 + err = api.EditPrice(&sku_editPrice_request.SkuEditPriceParam{ + Price: v.VendorPrice, + SkuId: utils.Str2Int64(v.VendorSonSkuID), ProductId: utils.Str2Int64(v.VendorSkuID), }) if err != nil { diff --git a/business/partner/purchase/tiktok_store/store_sku2_utils.go b/business/partner/purchase/tiktok_store/store_sku2_utils.go index 1683b5d9b..f9bbacaa4 100644 --- a/business/partner/purchase/tiktok_store/store_sku2_utils.go +++ b/business/partner/purchase/tiktok_store/store_sku2_utils.go @@ -275,6 +275,11 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID) continue } + var attrId2 []string + for _, v := range tiktokResultChildren.Sku { + attrId2 = append(attrId2, utils.Int64ToStr(v.SkuId)) + } + storeSku.VendorSonSkuID = strings.Join(attrId2, ",") // 属性id skuID storeSku.VendorSkuID = utils.Int64ToStr(tiktokResultChildren.ProductId) // 子商品主id storeSku.VendorMainId = utils.Int64ToStr(tiktokResultProductId) // 商品主id }