1
This commit is contained in:
@@ -270,6 +270,12 @@ func storeSkuSyncInfo2Bare(inSku *dao.StoreSkuSyncInfo) (outSku *partner.StoreSk
|
|||||||
if !isStoreSkuSyncNeedDelete(inSku) {
|
if !isStoreSkuSyncNeedDelete(inSku) {
|
||||||
outSku.Stock = model.MaxStoreSkuStockQty
|
outSku.Stock = model.MaxStoreSkuStockQty
|
||||||
}
|
}
|
||||||
|
if inSku.VendorMainId != "" {
|
||||||
|
outSku.VendorMainId = inSku.VendorMainId
|
||||||
|
}
|
||||||
|
if inSku.VendorSkuAttrId != "" {
|
||||||
|
outSku.VendorSkuAttrId = inSku.VendorSkuAttrId
|
||||||
|
}
|
||||||
return outSku
|
return outSku
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -364,6 +370,12 @@ func sku2Update(vendorID int, sku *dao.StoreSkuSyncInfo, syncStatus int8) (item
|
|||||||
if sku.VendorPrice > 0 {
|
if sku.VendorPrice > 0 {
|
||||||
kvs[dao.GetVendorPriceStructField(model.VendorNames[vendorID])] = sku.VendorPrice
|
kvs[dao.GetVendorPriceStructField(model.VendorNames[vendorID])] = sku.VendorPrice
|
||||||
}
|
}
|
||||||
|
if sku.VendorMainId != "" {
|
||||||
|
kvs["vendor_main_id"] = sku.VendorMainId
|
||||||
|
}
|
||||||
|
if sku.VendorSkuAttrId != "" {
|
||||||
|
kvs["vendor_sku_attr_id"] = sku.VendorSkuAttrId
|
||||||
|
}
|
||||||
storeSku := &model.StoreSkuBind{}
|
storeSku := &model.StoreSkuBind{}
|
||||||
storeSku.ID = sku.BindID
|
storeSku.ID = sku.BindID
|
||||||
item = &dao.KVUpdateItem{
|
item = &dao.KVUpdateItem{
|
||||||
|
|||||||
@@ -73,11 +73,13 @@ type StoreSkuSyncInfo struct {
|
|||||||
Stock int
|
Stock int
|
||||||
|
|
||||||
// 平台相关的store sku信息
|
// 平台相关的store sku信息
|
||||||
StoreSkuStatus int // 库存状态
|
StoreSkuStatus int // 库存状态
|
||||||
SkuSyncStatus int8 // 锁定状态
|
SkuSyncStatus int8 // 锁定状态
|
||||||
VendorSkuID string `orm:"column(vendor_sku_id)"`
|
VendorSkuID string `orm:"column(vendor_sku_id)"`
|
||||||
JdsWareID int64 `orm:"column(jds_ware_id)" json:"jdsWareID"`
|
VendorSkuAttrId string `orm:"column(vendor_sku_attr_id)"`
|
||||||
BindDeletedAt time.Time `orm:"type(datetime)" json:"bindDeletedAt"`
|
VendorMainId string `orm:"column(vendor_main_id)"`
|
||||||
|
JdsWareID int64 `orm:"column(jds_ware_id)" json:"jdsWareID"`
|
||||||
|
BindDeletedAt time.Time `orm:"type(datetime)" json:"bindDeletedAt"`
|
||||||
|
|
||||||
model.Sku
|
model.Sku
|
||||||
ExdSkuID string `orm:"column(exd_sku_id)"`
|
ExdSkuID string `orm:"column(exd_sku_id)"`
|
||||||
@@ -563,7 +565,7 @@ func GetStoreSkus2(db *DaoDB, vendorID, storeID int, skuIDs []int, mustDirty boo
|
|||||||
SELECT
|
SELECT
|
||||||
t14.vendor_id, t14.vendor_org_code,
|
t14.vendor_id, t14.vendor_org_code,
|
||||||
t1.id bind_id, t1.sku_id, t1.price, t1.unit_price, t1.status store_sku_status,
|
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,
|
%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,
|
||||||
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,
|
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.*,
|
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.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,
|
||||||
|
|||||||
@@ -122,6 +122,8 @@ type StoreSkuBind struct {
|
|||||||
//GmID string `orm:"column(gm_id)"`
|
//GmID string `orm:"column(gm_id)"`
|
||||||
// WscID int64 `orm:"column(wsc_id);index"` // 表示微盟skuId
|
// WscID int64 `orm:"column(wsc_id);index"` // 表示微盟skuId
|
||||||
// WscID2 int64 `orm:"column(wsc_id2);index"` // 表示微盟goodsId
|
// WscID2 int64 `orm:"column(wsc_id2);index"` // 表示微盟goodsId
|
||||||
|
VendorSkuAttrId string `orm:"column(vendor_sku_attr_id)"` // 抖音需要,抖音商品属性id
|
||||||
|
VendorMainId string `orm:"column(vendor_Main_id)"` // 抖音需要,商品主id
|
||||||
|
|
||||||
// ElmSyncStatus int8 `orm:"default(2)"`
|
// ElmSyncStatus int8 `orm:"default(2)"`
|
||||||
JdSyncStatus int8 `orm:"default(2)"`
|
JdSyncStatus int8 `orm:"default(2)"`
|
||||||
|
|||||||
@@ -55,6 +55,9 @@ type StoreSkuInfo struct {
|
|||||||
VendorOrgCode string `json:"vendorOrgCode"`
|
VendorOrgCode string `json:"vendorOrgCode"`
|
||||||
SpecUnit string `json:"specUnit"`
|
SpecUnit string `json:"specUnit"`
|
||||||
SpecQuality float32 `json:"specQuality"`
|
SpecQuality float32 `json:"specQuality"`
|
||||||
|
|
||||||
|
VendorMainId string `json:"vendorMainId"`
|
||||||
|
VendorSkuAttrId string `json:"vendorSkuAttrId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type StoreSkuInfoWithErr struct {
|
type StoreSkuInfoWithErr struct {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import (
|
|||||||
shop_bindStoreFreight_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_bindStoreFreight/request"
|
shop_bindStoreFreight_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_bindStoreFreight/request"
|
||||||
shop_bindStoreSaleLimit_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_bindStoreSaleLimit/request"
|
shop_bindStoreSaleLimit_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_bindStoreSaleLimit/request"
|
||||||
sku_editPrice_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/sku_editPrice/request"
|
sku_editPrice_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/sku_editPrice/request"
|
||||||
|
sku_syncStock_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/sku_syncStock/request"
|
||||||
trade_createTradeLimitTemplate_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/trade_createTradeLimitTemplate/request"
|
trade_createTradeLimitTemplate_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/trade_createTradeLimitTemplate/request"
|
||||||
tiktokShop "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/tiktok_api"
|
tiktokShop "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/tiktok_api"
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
@@ -24,6 +25,7 @@ import (
|
|||||||
"git.rosy.net.cn/jx-callback/globals"
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -380,7 +382,13 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
|||||||
storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID)
|
storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
storeSku.VendorSkuID = utils.Int64ToStr(tiktokResultChildren.ProductId)
|
storeSku.VendorSkuID = utils.Int64ToStr(tiktokResultChildren.ProductId) // 子商品主id
|
||||||
|
storeSku.VendorMainId = utils.Int64ToStr(tiktokResult.ProductId) // 商品主id
|
||||||
|
var attrId []string
|
||||||
|
for _, v := range tiktokResult.Sku {
|
||||||
|
attrId = append(attrId, utils.Int64ToStr(v.SkuId))
|
||||||
|
}
|
||||||
|
storeSku.VendorSkuAttrId = strings.Join(attrId, ",") // 属性id skuID
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
syncType = "更新商品"
|
syncType = "更新商品"
|
||||||
@@ -429,13 +437,13 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
|||||||
param.SpecPrices = GetSpecPrices(param.Specs, vendorStoreID, utils.Str2Int64(storeSku.VendorSkuID), storeSku)
|
param.SpecPrices = GetSpecPrices(param.Specs, vendorStoreID, utils.Str2Int64(storeSku.VendorSkuID), storeSku)
|
||||||
// ProductFormatNew 获取商品属性
|
// ProductFormatNew 获取商品属性
|
||||||
productFormatNew, err := GetProductFormatNew(param.CategoryLeafId, storeDetail.VendorOrgCode)
|
productFormatNew, err := GetProductFormatNew(param.CategoryLeafId, storeDetail.VendorOrgCode)
|
||||||
globals.SugarLogger.Debug("创建=============productFormatNew", productFormatNew)
|
globals.SugarLogger.Debug("更新=============productFormatNew", productFormatNew)
|
||||||
globals.SugarLogger.Debug("创建=============productFormatNew err", err)
|
globals.SugarLogger.Debug("更新=============productFormatNew err", err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
param.ProductFormatNew = productFormatNew
|
param.ProductFormatNew = productFormatNew
|
||||||
globals.SugarLogger.Debug("创建=============param", utils.Format4Output(param, false))
|
globals.SugarLogger.Debug("更新=============param", utils.Format4Output(param, false))
|
||||||
|
|
||||||
// 获取品牌
|
// 获取品牌
|
||||||
//brandID, err := api.GetSkuBrand(param.CategoryLeafId)
|
//brandID, err := api.GetSkuBrand(param.CategoryLeafId)
|
||||||
@@ -632,16 +640,11 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, vendorOrg
|
|||||||
//}
|
//}
|
||||||
//data, _ := json.Marshal(skuSize)
|
//data, _ := json.Marshal(skuSize)
|
||||||
//param.SpecPrices = string(data)
|
//param.SpecPrices = string(data)
|
||||||
param := &sku_editPrice_request.SkuEditPriceParam{
|
err := api.EditPrice(&sku_editPrice_request.SkuEditPriceParam{
|
||||||
Price: v.VendorPrice,
|
Price: v.VendorPrice,
|
||||||
Code: "",
|
SkuId: utils.Str2Int64(v.VendorSkuAttrId),
|
||||||
SkuId: 0,
|
|
||||||
OutSkuId: int64(v.SkuID),
|
|
||||||
ProductId: utils.Str2Int64(v.VendorSkuID),
|
ProductId: utils.Str2Int64(v.VendorSkuID),
|
||||||
//OutProductId: int64(v.SkuID),
|
})
|
||||||
}
|
|
||||||
|
|
||||||
err := api.EditPrice(param)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
failedList = append(failedList, putils.GetErrMsg2FailedSingleList(v, err, storeID, model.VendorChineseNames[model.VendorIDDD], "更新价格异常")...)
|
failedList = append(failedList, putils.GetErrMsg2FailedSingleList(v, err, storeID, model.VendorChineseNames[model.VendorIDDD], "更新价格异常")...)
|
||||||
} else {
|
} else {
|
||||||
@@ -655,11 +658,25 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, vendorOrg
|
|||||||
return failedList, err
|
return failedList, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 全量/增量更新商品sku库存
|
||||||
func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
||||||
if globals.EnableDdStoreWrite {
|
tiktokApi := getAPI(storeSkuList[0].VendorOrgCode, storeID, vendorStoreID)
|
||||||
return p.UpdateStoreSkusPrice(ctx, vendorOrgCode, storeID, vendorStoreID, storeSkuList)
|
for _, v := range storeSkuList {
|
||||||
|
err := tiktokApi.UpdateSkuStock(&sku_syncStock_request.SkuSyncStockParam{
|
||||||
|
SkuId: utils.Str2Int64(v.VendorSkuAttrId),
|
||||||
|
ProductId: utils.Str2Int64(v.VendorSkuID),
|
||||||
|
Incremental: false,
|
||||||
|
IdempotentId: "",
|
||||||
|
StockNum: int64(v.Stock),
|
||||||
|
})
|
||||||
|
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], "更新库存正常")...)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil, err
|
|
||||||
|
return p.UpdateStoreSkusPrice(ctx, vendorOrgCode, storeID, vendorStoreID, storeSkuList)
|
||||||
}
|
}
|
||||||
|
|
||||||
func tiktokSkuStatus2Jx(skuStatus int64) (jxSkuStatus int) {
|
func tiktokSkuStatus2Jx(skuStatus int64) (jxSkuStatus int) {
|
||||||
|
|||||||
Reference in New Issue
Block a user