1
This commit is contained in:
@@ -270,6 +270,12 @@ func storeSkuSyncInfo2Bare(inSku *dao.StoreSkuSyncInfo) (outSku *partner.StoreSk
|
||||
if !isStoreSkuSyncNeedDelete(inSku) {
|
||||
outSku.Stock = model.MaxStoreSkuStockQty
|
||||
}
|
||||
if inSku.VendorMainId != "" {
|
||||
outSku.VendorMainId = inSku.VendorMainId
|
||||
}
|
||||
if inSku.VendorSkuAttrId != "" {
|
||||
outSku.VendorSkuAttrId = inSku.VendorSkuAttrId
|
||||
}
|
||||
return outSku
|
||||
}
|
||||
|
||||
@@ -364,6 +370,12 @@ func sku2Update(vendorID int, sku *dao.StoreSkuSyncInfo, syncStatus int8) (item
|
||||
if sku.VendorPrice > 0 {
|
||||
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.ID = sku.BindID
|
||||
item = &dao.KVUpdateItem{
|
||||
|
||||
@@ -73,11 +73,13 @@ type StoreSkuSyncInfo struct {
|
||||
Stock int
|
||||
|
||||
// 平台相关的store sku信息
|
||||
StoreSkuStatus int // 库存状态
|
||||
SkuSyncStatus int8 // 锁定状态
|
||||
VendorSkuID string `orm:"column(vendor_sku_id)"`
|
||||
JdsWareID int64 `orm:"column(jds_ware_id)" json:"jdsWareID"`
|
||||
BindDeletedAt time.Time `orm:"type(datetime)" json:"bindDeletedAt"`
|
||||
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)"`
|
||||
JdsWareID int64 `orm:"column(jds_ware_id)" json:"jdsWareID"`
|
||||
BindDeletedAt time.Time `orm:"type(datetime)" json:"bindDeletedAt"`
|
||||
|
||||
model.Sku
|
||||
ExdSkuID string `orm:"column(exd_sku_id)"`
|
||||
@@ -563,7 +565,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,
|
||||
%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,
|
||||
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,
|
||||
|
||||
@@ -122,6 +122,8 @@ type StoreSkuBind struct {
|
||||
//GmID string `orm:"column(gm_id)"`
|
||||
// WscID int64 `orm:"column(wsc_id);index"` // 表示微盟skuId
|
||||
// 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)"`
|
||||
JdSyncStatus int8 `orm:"default(2)"`
|
||||
|
||||
@@ -55,6 +55,9 @@ type StoreSkuInfo struct {
|
||||
VendorOrgCode string `json:"vendorOrgCode"`
|
||||
SpecUnit string `json:"specUnit"`
|
||||
SpecQuality float32 `json:"specQuality"`
|
||||
|
||||
VendorMainId string `json:"vendorMainId"`
|
||||
VendorSkuAttrId string `json:"vendorSkuAttrId"`
|
||||
}
|
||||
|
||||
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_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_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"
|
||||
tiktokShop "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/tiktok_api"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
@@ -24,6 +25,7 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"math/rand"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -380,7 +382,13 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
||||
storeSku.VendorSkuID = utils.Int2Str(storeSku.SkuID)
|
||||
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 {
|
||||
syncType = "更新商品"
|
||||
@@ -429,13 +437,13 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
||||
param.SpecPrices = GetSpecPrices(param.Specs, vendorStoreID, utils.Str2Int64(storeSku.VendorSkuID), storeSku)
|
||||
// ProductFormatNew 获取商品属性
|
||||
productFormatNew, err := GetProductFormatNew(param.CategoryLeafId, storeDetail.VendorOrgCode)
|
||||
globals.SugarLogger.Debug("创建=============productFormatNew", productFormatNew)
|
||||
globals.SugarLogger.Debug("创建=============productFormatNew err", err)
|
||||
globals.SugarLogger.Debug("更新=============productFormatNew", productFormatNew)
|
||||
globals.SugarLogger.Debug("更新=============productFormatNew err", err)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
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)
|
||||
@@ -632,16 +640,11 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, vendorOrg
|
||||
//}
|
||||
//data, _ := json.Marshal(skuSize)
|
||||
//param.SpecPrices = string(data)
|
||||
param := &sku_editPrice_request.SkuEditPriceParam{
|
||||
err := api.EditPrice(&sku_editPrice_request.SkuEditPriceParam{
|
||||
Price: v.VendorPrice,
|
||||
Code: "",
|
||||
SkuId: 0,
|
||||
OutSkuId: int64(v.SkuID),
|
||||
SkuId: utils.Str2Int64(v.VendorSkuAttrId),
|
||||
ProductId: utils.Str2Int64(v.VendorSkuID),
|
||||
//OutProductId: int64(v.SkuID),
|
||||
}
|
||||
|
||||
err := api.EditPrice(param)
|
||||
})
|
||||
if err != nil {
|
||||
failedList = append(failedList, putils.GetErrMsg2FailedSingleList(v, err, storeID, model.VendorChineseNames[model.VendorIDDD], "更新价格异常")...)
|
||||
} else {
|
||||
@@ -655,11 +658,25 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, vendorOrg
|
||||
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) {
|
||||
if globals.EnableDdStoreWrite {
|
||||
return p.UpdateStoreSkusPrice(ctx, vendorOrgCode, storeID, vendorStoreID, storeSkuList)
|
||||
tiktokApi := getAPI(storeSkuList[0].VendorOrgCode, storeID, vendorStoreID)
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user