- 京东到家新门店商品同步方式
This commit is contained in:
@@ -7,11 +7,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
FuncCreateStoreSkus = 1
|
FuncUpdateStoreSkusStock = 1
|
||||||
FuncDeleteStoreSkus = 2
|
FuncUpdateStoreSkusStatus = 2
|
||||||
FuncUpdateStoreSkusStatus = 3
|
FuncUpdateStoreSkusPrice = 3
|
||||||
FuncUpdateStoreSkusPrice = 4
|
|
||||||
FuncUpdateStoreSkus = 5
|
FuncCreateStoreSkus = 6
|
||||||
|
FuncUpdateStoreSkus = 7
|
||||||
|
FuncDeleteStoreSkus = 8
|
||||||
)
|
)
|
||||||
|
|
||||||
type BareStoreSkuInfo struct {
|
type BareStoreSkuInfo struct {
|
||||||
@@ -20,6 +22,7 @@ type BareStoreSkuInfo struct {
|
|||||||
NameID int `json:"nameID,omitempty"`
|
NameID int `json:"nameID,omitempty"`
|
||||||
VendorNameID string `json:"vendorNameID,omitempty"`
|
VendorNameID string `json:"vendorNameID,omitempty"`
|
||||||
|
|
||||||
|
Stock int `json:"stock,omitempty"`
|
||||||
Price int64 `json:"price,omitempty"`
|
Price int64 `json:"price,omitempty"`
|
||||||
Status int `json:"status,omitempty"`
|
Status int `json:"status,omitempty"`
|
||||||
}
|
}
|
||||||
@@ -65,8 +68,7 @@ type BareCategoryInfo struct {
|
|||||||
type IPurchasePlatformStoreSkuHandler interface {
|
type IPurchasePlatformStoreSkuHandler interface {
|
||||||
GetStoreSkusBatchSize(funcID int) int
|
GetStoreSkusBatchSize(funcID int) int
|
||||||
|
|
||||||
CreateStoreSkus(ctx *jxcontext.Context, vendorStoreID string, storeSkuList []*dao.StoreSkuSyncInfo) (err error)
|
UpdateStoreSkusStock(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*BareStoreSkuInfo) (err error)
|
||||||
DeleteStoreSkus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*BareStoreSkuInfo) (err error)
|
|
||||||
UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*BareStoreSkuInfo) (err error)
|
UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*BareStoreSkuInfo) (err error)
|
||||||
UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*BareStoreSkuInfo) (err error)
|
UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*BareStoreSkuInfo) (err error)
|
||||||
}
|
}
|
||||||
@@ -74,9 +76,12 @@ type IPurchasePlatformStoreSkuHandler interface {
|
|||||||
type ISingleStoreStoreSkuHandler interface {
|
type ISingleStoreStoreSkuHandler interface {
|
||||||
IPurchasePlatformStoreSkuHandler
|
IPurchasePlatformStoreSkuHandler
|
||||||
|
|
||||||
|
CreateStoreSkus(ctx *jxcontext.Context, vendorStoreID string, storeSkuList []*dao.StoreSkuSyncInfo) (err error)
|
||||||
|
UpdateStoreSkus(ctx *jxcontext.Context, vendorStoreID string, storeSkuList []*dao.StoreSkuSyncInfo) (err error)
|
||||||
|
DeleteStoreSkus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*BareStoreSkuInfo) (err error)
|
||||||
|
|
||||||
ReadStoreCategory(ctx *jxcontext.Context, vendorStoreID string) (cats []*BareCategoryInfo, err error)
|
ReadStoreCategory(ctx *jxcontext.Context, vendorStoreID string) (cats []*BareCategoryInfo, err error)
|
||||||
CreateStoreSkuCategory(ctx *jxcontext.Context, vendorStoreID string, storeCat *dao.SkuStoreCatInfo) (err error)
|
CreateStoreSkuCategory(ctx *jxcontext.Context, vendorStoreID string, storeCat *dao.SkuStoreCatInfo) (err error)
|
||||||
UpdateStoreSkuCategory(ctx *jxcontext.Context, vendorStoreID string, storeCat *dao.SkuStoreCatInfo) (err error)
|
UpdateStoreSkuCategory(ctx *jxcontext.Context, vendorStoreID string, storeCat *dao.SkuStoreCatInfo) (err error)
|
||||||
DeleteStoreSkuCategory(ctx *jxcontext.Context, vendorStoreID, vendorCatID string) (err error)
|
DeleteStoreSkuCategory(ctx *jxcontext.Context, vendorStoreID, vendorCatID string) (err error)
|
||||||
UpdateStoreSkus(ctx *jxcontext.Context, vendorStoreID string, storeSkuList []*dao.StoreSkuSyncInfo) (err error)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,14 @@ import (
|
|||||||
"git.rosy.net.cn/jx-callback/globals/api"
|
"git.rosy.net.cn/jx-callback/globals/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (p *PurchaseHandler) GetStoreSkusBatchSize(funcID int) (batchSize int) {
|
||||||
|
switch funcID {
|
||||||
|
case partner.FuncUpdateStoreSkusStock, partner.FuncUpdateStoreSkusStatus, partner.FuncUpdateStoreSkusPrice:
|
||||||
|
batchSize = jdapi.MaxStoreSkuBatchSize
|
||||||
|
}
|
||||||
|
return batchSize
|
||||||
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) GetStoreSkusInfo(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, vendorStoreID string, inStoreSkuList []*partner.BareStoreSkuInfo) (outStoreSkuList []*partner.BareStoreSkuInfo, err error) {
|
func (p *PurchaseHandler) GetStoreSkusInfo(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, vendorStoreID string, inStoreSkuList []*partner.BareStoreSkuInfo) (outStoreSkuList []*partner.BareStoreSkuInfo, err error) {
|
||||||
var batchSkuInfoList []*jdapi.BaseStockCenterRequest
|
var batchSkuInfoList []*jdapi.BaseStockCenterRequest
|
||||||
batchSkuList := partner.BareStoreSkuInfoList(inStoreSkuList).GetVendorSkuIDIntList()
|
batchSkuList := partner.BareStoreSkuInfoList(inStoreSkuList).GetVendorSkuIDIntList()
|
||||||
@@ -64,3 +72,49 @@ func jdStoreSkuStatus2Jx(jdStoreSkuStatus int) (jxSkuStatus int) {
|
|||||||
}
|
}
|
||||||
return jxSkuStatus
|
return jxSkuStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func jxStoreSkuStatus2Jd(jxStoreSkuStatus int) (isSale bool) {
|
||||||
|
return jxStoreSkuStatus == model.SkuStatusNormal
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.BareStoreSkuInfo) (err error) {
|
||||||
|
var skuStockList []*jdapi.SkuStock
|
||||||
|
for _, v := range storeSkuList {
|
||||||
|
skuStockList = append(skuStockList, &jdapi.SkuStock{
|
||||||
|
OutSkuId: utils.Int2Str(v.SkuID),
|
||||||
|
StockQty: v.Stock,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if globals.EnableJdStoreWrite {
|
||||||
|
_, err = api.JdAPI.BatchUpdateCurrentQtys("", vendorStoreID, skuStockList, ctx.GetUserName())
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.BareStoreSkuInfo) (err error) {
|
||||||
|
var skuVendibilityList []*jdapi.StockVendibility
|
||||||
|
for _, v := range storeSkuList {
|
||||||
|
skuVendibilityList = append(skuVendibilityList, &jdapi.StockVendibility{
|
||||||
|
OutSkuId: utils.Int2Str(v.SkuID),
|
||||||
|
DoSale: jxStoreSkuStatus2Jd(v.Status),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if globals.EnableJdStoreWrite {
|
||||||
|
_, err = api.JdAPI.BatchUpdateVendibility("", vendorStoreID, skuVendibilityList, ctx.GetUserName())
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.BareStoreSkuInfo) (err error) {
|
||||||
|
var skuPriceInfoList []*jdapi.SkuPriceInfo
|
||||||
|
for _, v := range storeSkuList {
|
||||||
|
skuPriceInfoList = append(skuPriceInfoList, &jdapi.SkuPriceInfo{
|
||||||
|
OutSkuId: utils.Int2Str(v.SkuID),
|
||||||
|
Price: int(v.Price),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if globals.EnableJdStoreWrite {
|
||||||
|
_, err = api.JdAPI.UpdateVendorStationPrice("", vendorStoreID, skuPriceInfoList)
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user