- 移除partner.GetStoresSku
This commit is contained in:
@@ -1983,84 +1983,109 @@ func RefreshStoresSkuByVendor(ctx *jxcontext.Context, storeIDs []int, vendorID i
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
skuList, err := dao.GetSkus(db, nil, nil, nil, nil)
|
||||||
handler := partner.GetPurchasePlatformFromVendorID(vendorID)
|
if err != nil {
|
||||||
var storeSkuList []*model.StoreSkuBind
|
return "", err
|
||||||
rootTask := tasksch.NewSeqTask(fmt.Sprintf("根据厂家门店商品信息相应刷新本地数据:%v", storeIDs), ctx,
|
}
|
||||||
func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
|
skuNameMap := make(map[int]*model.SkuName)
|
||||||
switch step {
|
skuMap := make(map[int]*model.SkuAndName)
|
||||||
case 0:
|
var bareStoreSkuList []*partner.StoreSkuInfo
|
||||||
storeSkuList, err = handler.GetStoresSku(ctx, task, storeIDs)
|
for _, sku := range skuList {
|
||||||
case 1:
|
if skuNameMap[sku.NameID] == nil {
|
||||||
if len(storeSkuList) > 0 {
|
skuNameMap[sku.NameID] = &model.SkuName{
|
||||||
var skuList []*model.SkuAndName
|
Unit: sku.Unit,
|
||||||
skuList, err = dao.GetSkus(db, nil, nil, nil, nil)
|
|
||||||
if err == nil {
|
|
||||||
skuNameMap := make(map[int]*model.SkuName)
|
|
||||||
skuMap := make(map[int]*model.SkuAndName)
|
|
||||||
for _, sku := range skuList {
|
|
||||||
if skuNameMap[sku.NameID] == nil {
|
|
||||||
skuNameMap[sku.NameID] = &model.SkuName{
|
|
||||||
Unit: sku.Unit,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
skuMap[sku.ID] = sku
|
|
||||||
}
|
|
||||||
for _, v := range storeSkuList {
|
|
||||||
sku := skuMap[v.SkuID]
|
|
||||||
skuName := skuNameMap[sku.NameID]
|
|
||||||
if skuName.IsGlobal == 0 && (jxutils.IsSkuSpecial(sku.SpecQuality, sku.SpecUnit) || skuName.Unit != model.SpecialUnit) {
|
|
||||||
skuName.Price = v.Price
|
|
||||||
skuName.IsGlobal = 1 // 标准价
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for _, v := range storeSkuList {
|
|
||||||
sku := skuMap[v.SkuID]
|
|
||||||
skuName := skuNameMap[sku.NameID]
|
|
||||||
if skuName.IsGlobal == 0 {
|
|
||||||
if skuName.Price == 0 {
|
|
||||||
skuName.Price = jxutils.CaculateUnitPrice(v.Price, sku.SpecQuality, sku.SpecUnit, skuName.Unit)
|
|
||||||
} else {
|
|
||||||
skuName.Price = (skuName.Price + jxutils.CaculateUnitPrice(v.Price, sku.SpecQuality, sku.SpecUnit, skuName.Unit)) / 2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for _, v := range storeSkuList {
|
|
||||||
pricePercentage := jxutils.GetPricePercentageByVendorPrice(storeMap[v.StoreID].PricePercentagePackObj, v.UnitPrice, int(storeMap[v.StoreID].PricePercentage))
|
|
||||||
skuName := skuNameMap[skuMap[v.SkuID].NameID]
|
|
||||||
v.Price = jxutils.CaculateSkuPriceFromVendor(v.Price, pricePercentage, 0)
|
|
||||||
v.UnitPrice = jxutils.CaculateSkuPriceFromVendor(skuName.Price, pricePercentage, 0)
|
|
||||||
dao.WrapAddIDCULDEntity(v, ctx.GetUserName())
|
|
||||||
setStoreSkuBindStatus(v, model.SyncFlagNewMask)
|
|
||||||
v.JdSyncStatus = 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 2:
|
|
||||||
if len(storeSkuList) > 0 {
|
|
||||||
dao.Begin(db)
|
|
||||||
defer func() {
|
|
||||||
if r := recover(); r != nil || err != nil {
|
|
||||||
dao.Rollback(db)
|
|
||||||
if r != nil {
|
|
||||||
panic(r)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
if _, err = dao.ExecuteSQL(db, `
|
|
||||||
DELETE t1
|
|
||||||
FROM store_sku_bind t1
|
|
||||||
WHERE t1.store_id IN (
|
|
||||||
`+dao.GenQuestionMarks(len(storeIDs))+")", storeIDs); err == nil {
|
|
||||||
if err = dao.CreateMultiEntities(db, storeSkuList); err == nil {
|
|
||||||
hint = utils.Int2Str(len(storeSkuList))
|
|
||||||
dao.Commit(db)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return nil, err
|
}
|
||||||
}, 3)
|
skuMap[sku.ID] = sku
|
||||||
|
|
||||||
|
bareStoreSkuList = append(bareStoreSkuList, &partner.StoreSkuInfo{
|
||||||
|
SkuID: sku.ID,
|
||||||
|
VendorSkuID: utils.Int64ToStr(sku.JdID),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
handler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.IPurchasePlatformStoreSkuHandler)
|
||||||
|
var storeSkuList []*model.StoreSkuBind
|
||||||
|
rootTask := tasksch.NewParallelTask(fmt.Sprintf("根据厂家门店商品信息相应刷新本地数据:%v", storeIDs), tasksch.NewParallelConfig().SetParallelCount(1), ctx,
|
||||||
|
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
|
oneStoreMap := batchItemList[0].(*model.StoreMap)
|
||||||
|
subTask := tasksch.NewSeqTask(fmt.Sprintf("根据厂家门店商品信息相应刷新本地数据:%s", model.VendorChineseNames[oneStoreMap.VendorID]), ctx,
|
||||||
|
func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
|
||||||
|
switch step {
|
||||||
|
case 0:
|
||||||
|
bareStoreSkuList, err2 := handler.GetStoreSkusBareInfo(ctx, task, oneStoreMap.StoreID, oneStoreMap.VendorStoreID, bareStoreSkuList)
|
||||||
|
// globals.SugarLogger.Debug(utils.Format4Output(bareStoreSkuList, false))
|
||||||
|
if err = err2; err == nil || len(bareStoreSkuList) > 0 {
|
||||||
|
err = nil // todo 如果部分失败,强制忽略错误
|
||||||
|
for _, v := range bareStoreSkuList {
|
||||||
|
storeSkuList = append(storeSkuList, &model.StoreSkuBind{
|
||||||
|
StoreID: oneStoreMap.StoreID,
|
||||||
|
SkuID: v.SkuID,
|
||||||
|
Status: v.Status,
|
||||||
|
Price: int(v.VendorPrice),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 1:
|
||||||
|
if len(storeSkuList) > 0 {
|
||||||
|
for _, v := range storeSkuList {
|
||||||
|
sku := skuMap[v.SkuID]
|
||||||
|
skuName := skuNameMap[sku.NameID]
|
||||||
|
if skuName.IsGlobal == 0 && (jxutils.IsSkuSpecial(sku.SpecQuality, sku.SpecUnit) || skuName.Unit != model.SpecialUnit) {
|
||||||
|
skuName.Price = v.Price // 标准价
|
||||||
|
skuName.IsGlobal = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, v := range storeSkuList {
|
||||||
|
sku := skuMap[v.SkuID]
|
||||||
|
skuName := skuNameMap[sku.NameID]
|
||||||
|
if skuName.IsGlobal == 0 {
|
||||||
|
if skuName.Price == 0 {
|
||||||
|
skuName.Price = jxutils.CaculateUnitPrice(v.Price, sku.SpecQuality, sku.SpecUnit, skuName.Unit)
|
||||||
|
} else {
|
||||||
|
skuName.Price = (skuName.Price + jxutils.CaculateUnitPrice(v.Price, sku.SpecQuality, sku.SpecUnit, skuName.Unit)) / 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, v := range storeSkuList {
|
||||||
|
pricePercentage := jxutils.GetPricePercentageByVendorPrice(storeMap[v.StoreID].PricePercentagePackObj, v.UnitPrice, int(storeMap[v.StoreID].PricePercentage))
|
||||||
|
skuName := skuNameMap[skuMap[v.SkuID].NameID]
|
||||||
|
v.Price = jxutils.CaculateSkuPriceFromVendor(v.Price, pricePercentage, 0)
|
||||||
|
v.UnitPrice = jxutils.CaculateSkuPriceFromVendor(skuName.Price, pricePercentage, 0)
|
||||||
|
dao.WrapAddIDCULDEntity(v, ctx.GetUserName())
|
||||||
|
setStoreSkuBindStatus(v, model.SyncFlagNewMask)
|
||||||
|
v.JdSyncStatus = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
if len(storeSkuList) > 0 {
|
||||||
|
dao.Begin(db)
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil || err != nil {
|
||||||
|
dao.Rollback(db)
|
||||||
|
if r != nil {
|
||||||
|
panic(r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
if _, err = dao.ExecuteSQL(db, `
|
||||||
|
DELETE t1
|
||||||
|
FROM store_sku_bind t1
|
||||||
|
WHERE t1.store_id IN (
|
||||||
|
`+dao.GenQuestionMarks(len(storeIDs))+")", storeIDs); err == nil {
|
||||||
|
if err = dao.CreateMultiEntities(db, storeSkuList); err == nil {
|
||||||
|
hint = utils.Int2Str(len(storeSkuList))
|
||||||
|
dao.Commit(db)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}, 3)
|
||||||
|
tasksch.HandleTask(subTask, task, true).Run()
|
||||||
|
_, err = subTask.GetResult(0)
|
||||||
|
return retVal, err
|
||||||
|
}, storeMapList)
|
||||||
tasksch.ManageTask(rootTask).Run()
|
tasksch.ManageTask(rootTask).Run()
|
||||||
if isAsync {
|
if isAsync {
|
||||||
hint = rootTask.GetID()
|
hint = rootTask.GetID()
|
||||||
|
|||||||
@@ -168,15 +168,13 @@ type IPurchasePlatformHandler interface {
|
|||||||
// CloseStore(vendorStoreID, closeNotice, userName string) error
|
// CloseStore(vendorStoreID, closeNotice, userName string) error
|
||||||
|
|
||||||
SyncStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, skuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error)
|
SyncStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, skuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error)
|
||||||
RefreshAllStoresID(ctx *jxcontext.Context, parentTask tasksch.ITask, isAsync bool) (hint string, err error)
|
|
||||||
|
|
||||||
// !!!注意,此操作会先清除门店已有的商品,一般用于初始化,小心使用
|
// !!!注意,此操作会先清除门店已有的商品,一般用于初始化,小心使用
|
||||||
FullSyncStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, isAsync, isContinueWhenError bool) (hint string, err error)
|
FullSyncStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, isAsync, isContinueWhenError bool) (hint string, err error)
|
||||||
|
|
||||||
|
RefreshAllStoresID(ctx *jxcontext.Context, parentTask tasksch.ITask, isAsync bool) (hint string, err error)
|
||||||
|
|
||||||
UploadImg(ctx *jxcontext.Context, imgURL string, imgData []byte, imgName string) (imgHint string, err error)
|
UploadImg(ctx *jxcontext.Context, imgURL string, imgData []byte, imgName string) (imgHint string, err error)
|
||||||
GetVendorCategories(ctx *jxcontext.Context) (vendorCats []*model.SkuVendorCategory, err error)
|
GetVendorCategories(ctx *jxcontext.Context) (vendorCats []*model.SkuVendorCategory, err error)
|
||||||
|
|
||||||
// todo GetStoresSku应该与GetStoreSkusInfo合并
|
|
||||||
GetStoresSku(ctx *jxcontext.Context, parentTask tasksch.ITask, storeIDs []int) (storeSkuList []*model.StoreSkuBind, err error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// db *dao.DaoDB,
|
// db *dao.DaoDB,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
FuncGetStoreSkusBareInfo = 1
|
// FuncGetStoreSkusBareInfo = 1 // 此接口要求实现为不限制批处理大小的
|
||||||
FuncUpdateStoreSkusStock = 2
|
FuncUpdateStoreSkusStock = 2
|
||||||
FuncUpdateStoreSkusStatus = 3
|
FuncUpdateStoreSkusStatus = 3
|
||||||
FuncUpdateStoreSkusPrice = 4
|
FuncUpdateStoreSkusPrice = 4
|
||||||
@@ -110,6 +110,7 @@ type IPurchasePlatformStoreSkuHandler interface {
|
|||||||
|
|
||||||
ListOrders(ctx *jxcontext.Context, parentTask tasksch.ITask, queryDate time.Time, vendorStoreID string) (vendorOrderIDs []string, err error)
|
ListOrders(ctx *jxcontext.Context, parentTask tasksch.ITask, queryDate time.Time, vendorStoreID string) (vendorOrderIDs []string, err error)
|
||||||
|
|
||||||
|
// 此接口要求实现为不限制批处理大小的
|
||||||
GetStoreSkusBareInfo(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, vendorStoreID string, inStoreSkuList []*StoreSkuInfo) (outStoreSkuList []*StoreSkuInfo, err error)
|
GetStoreSkusBareInfo(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, vendorStoreID string, inStoreSkuList []*StoreSkuInfo) (outStoreSkuList []*StoreSkuInfo, err error)
|
||||||
UpdateStoreSkusStock(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*StoreSkuInfo) (successList []*StoreSkuInfo, err error)
|
UpdateStoreSkusStock(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*StoreSkuInfo) (successList []*StoreSkuInfo, err error)
|
||||||
UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*StoreSkuInfo, status int) (successList []*StoreSkuInfo, err error)
|
UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*StoreSkuInfo, status int) (successList []*StoreSkuInfo, err error)
|
||||||
|
|||||||
@@ -571,7 +571,3 @@ func (p *PurchaseHandler) updateLocalCatAsNew(db *dao.DaoDB, localCatMap map[str
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) GetStoresSku(ctx *jxcontext.Context, parentTask tasksch.ITask, storeIDs []int) (storeSkuList []*model.StoreSkuBind, err error) {
|
|
||||||
return storeSkuList, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -28,8 +28,6 @@ func (p *PurchaseHandler) GetStoreSkusBatchSize(funcID int) (batchSize int) {
|
|||||||
switch funcID {
|
switch funcID {
|
||||||
case partner.FuncUpdateStoreSkusStock, partner.FuncUpdateStoreSkusStatus, partner.FuncUpdateStoreSkusPrice, partner.FuncDeleteStoreSkus:
|
case partner.FuncUpdateStoreSkusStock, partner.FuncUpdateStoreSkusStatus, partner.FuncUpdateStoreSkusPrice, partner.FuncDeleteStoreSkus:
|
||||||
batchSize = ebaiapi.MaxStoreSkuBatchSize
|
batchSize = ebaiapi.MaxStoreSkuBatchSize
|
||||||
case partner.FuncGetStoreSkusBareInfo:
|
|
||||||
batchSize = partner.UnlimitedBatchSize
|
|
||||||
case partner.FuncCreateStoreSkus, partner.FuncUpdateStoreSkus:
|
case partner.FuncCreateStoreSkus, partner.FuncUpdateStoreSkus:
|
||||||
batchSize = 1
|
batchSize = 1
|
||||||
case partner.FuncGetStoreSkusFullInfo:
|
case partner.FuncGetStoreSkusFullInfo:
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package elm
|
|||||||
import (
|
import (
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p *PurchaseHandler) SyncStoreCategory(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, isAsync bool) (hint string, err error) {
|
func (p *PurchaseHandler) SyncStoreCategory(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, isAsync bool) (hint string, err error) {
|
||||||
@@ -21,7 +20,3 @@ func (p *PurchaseHandler) RefreshStoresAllSkusID(ctx *jxcontext.Context, parentT
|
|||||||
func (p *PurchaseHandler) FullSyncStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
func (p *PurchaseHandler) FullSyncStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||||
return hint, err
|
return hint, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) GetStoresSku(ctx *jxcontext.Context, parentTask tasksch.ITask, storeIDs []int) (storeSkuList []*model.StoreSkuBind, err error) {
|
|
||||||
return storeSkuList, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -204,80 +204,3 @@ func constrainPrice(price int) int {
|
|||||||
}
|
}
|
||||||
return price
|
return price
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) GetStoresSku(ctx *jxcontext.Context, parentTask tasksch.ITask, storeIDs []int) (storeSkuList []*model.StoreSkuBind, err error) {
|
|
||||||
db := dao.GetDB()
|
|
||||||
skuList, err := dao.GetSkus(db, nil, nil, []int{model.SkuStatusNormal}, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
var skuInfoList []*jdapi.BaseStockCenterRequest
|
|
||||||
skuMap := make(map[int64]int)
|
|
||||||
for _, sku := range skuList {
|
|
||||||
if !jxutils.IsEmptyID(sku.JdID) {
|
|
||||||
skuInfoList = append(skuInfoList, &jdapi.BaseStockCenterRequest{
|
|
||||||
SkuId: sku.JdID,
|
|
||||||
})
|
|
||||||
skuMap[sku.JdID] = sku.ID
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for _, storeID := range storeIDs {
|
|
||||||
storeDetail, err := dao.GetStoreDetail(db, storeID, model.VendorIDJD)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
for _, sku := range skuInfoList {
|
|
||||||
sku.StationNo = storeDetail.VendorStoreID
|
|
||||||
}
|
|
||||||
task := tasksch.NewParallelTask("jd 获取京东门店商品信息", tasksch.NewParallelConfig().SetBatchSize(jdapi.MaxStoreSkuBatchSize), ctx,
|
|
||||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
|
||||||
batchSkuInfoList := make([]*jdapi.BaseStockCenterRequest, len(batchItemList))
|
|
||||||
batchSkuList := make([]int64, len(batchItemList))
|
|
||||||
for k, v := range batchItemList {
|
|
||||||
batchSkuInfoList[k] = v.(*jdapi.BaseStockCenterRequest)
|
|
||||||
batchSkuList[k] = batchSkuInfoList[k].SkuId
|
|
||||||
}
|
|
||||||
stockInfo, err := api.JdAPI.QueryOpenUseable(batchSkuInfoList)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
priceInfo, err := api.JdAPI.GetStationInfoList(storeDetail.VendorStoreID, batchSkuList)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
var batchStoreSkuList []*model.StoreSkuBind
|
|
||||||
batchStoreSkuMap := make(map[int64]*model.StoreSkuBind)
|
|
||||||
for _, v := range stockInfo {
|
|
||||||
if v.UsableQty > 0 {
|
|
||||||
batchSku := &model.StoreSkuBind{
|
|
||||||
StoreID: storeID,
|
|
||||||
SkuID: skuMap[v.SkuID],
|
|
||||||
}
|
|
||||||
if v.Vendibility == 0 {
|
|
||||||
batchSku.Status = model.SkuStatusNormal
|
|
||||||
} else {
|
|
||||||
batchSku.Status = model.SkuStatusDontSale
|
|
||||||
}
|
|
||||||
batchStoreSkuMap[v.SkuID] = batchSku
|
|
||||||
batchStoreSkuList = append(batchStoreSkuList, batchSku)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for _, v := range priceInfo {
|
|
||||||
if storeSku := batchStoreSkuMap[v.SkuID]; storeSku != nil {
|
|
||||||
storeSku.Price = int(v.Price)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return batchStoreSkuList, err
|
|
||||||
}, skuInfoList)
|
|
||||||
tasksch.AddChild(parentTask, task).Run()
|
|
||||||
result, err := task.GetResult(0)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
for _, v := range result {
|
|
||||||
storeSkuList = append(storeSkuList, v.(*model.StoreSkuBind))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return storeSkuList, err
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@@ -15,13 +15,13 @@ import (
|
|||||||
|
|
||||||
func (p *PurchaseHandler) GetStoreSkusBatchSize(funcID int) (batchSize int) {
|
func (p *PurchaseHandler) GetStoreSkusBatchSize(funcID int) (batchSize int) {
|
||||||
switch funcID {
|
switch funcID {
|
||||||
case partner.FuncGetStoreSkusBareInfo, partner.FuncUpdateStoreSkusStock, partner.FuncUpdateStoreSkusStatus, partner.FuncUpdateStoreSkusPrice:
|
case partner.FuncUpdateStoreSkusStock, partner.FuncUpdateStoreSkusStatus, partner.FuncUpdateStoreSkusPrice:
|
||||||
batchSize = jdapi.MaxStoreSkuBatchSize
|
batchSize = jdapi.MaxStoreSkuBatchSize
|
||||||
}
|
}
|
||||||
return batchSize
|
return batchSize
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) GetStoreSkusBareInfo(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, vendorStoreID string, inStoreSkuList []*partner.StoreSkuInfo) (outStoreSkuList []*partner.StoreSkuInfo, err error) {
|
func (p *PurchaseHandler) getStoreSkusBareInfoLimitSize(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, vendorStoreID string, inStoreSkuList []*partner.StoreSkuInfo) (outStoreSkuList []*partner.StoreSkuInfo, err error) {
|
||||||
var batchSkuInfoList []*jdapi.BaseStockCenterRequest
|
var batchSkuInfoList []*jdapi.BaseStockCenterRequest
|
||||||
batchSkuList := partner.BareStoreSkuInfoList(inStoreSkuList).GetVendorSkuIDIntList()
|
batchSkuList := partner.BareStoreSkuInfoList(inStoreSkuList).GetVendorSkuIDIntList()
|
||||||
for _, v := range inStoreSkuList {
|
for _, v := range inStoreSkuList {
|
||||||
@@ -64,6 +64,20 @@ func (p *PurchaseHandler) GetStoreSkusBareInfo(ctx *jxcontext.Context, parentTas
|
|||||||
return outStoreSkuList, err
|
return outStoreSkuList, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *PurchaseHandler) GetStoreSkusBareInfo(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, vendorStoreID string, inStoreSkuList []*partner.StoreSkuInfo) (outStoreSkuList []*partner.StoreSkuInfo, err error) {
|
||||||
|
result, err := putils.FreeBatchStoreSkuInfo(func(batchedStoreSkuList []*partner.StoreSkuInfo) (result interface{}, err error) {
|
||||||
|
list, err := p.getStoreSkusBareInfoLimitSize(ctx, nil, storeID, vendorStoreID, batchedStoreSkuList)
|
||||||
|
if err == nil {
|
||||||
|
result = list
|
||||||
|
}
|
||||||
|
return result, err
|
||||||
|
}, ctx, parentTask, inStoreSkuList, jdapi.MaxStoreSkuBatchSize, true)
|
||||||
|
for _, v := range result {
|
||||||
|
outStoreSkuList = append(outStoreSkuList, v.(*partner.StoreSkuInfo))
|
||||||
|
}
|
||||||
|
return outStoreSkuList, err
|
||||||
|
}
|
||||||
|
|
||||||
func jdStoreSkuStatus2Jx(jdStoreSkuStatus int) (jxSkuStatus int) {
|
func jdStoreSkuStatus2Jx(jdStoreSkuStatus int) (jxSkuStatus int) {
|
||||||
if jdStoreSkuStatus == 0 {
|
if jdStoreSkuStatus == 0 {
|
||||||
jxSkuStatus = model.SkuStatusNormal
|
jxSkuStatus = model.SkuStatusNormal
|
||||||
|
|||||||
@@ -457,7 +457,3 @@ func (p *PurchaseHandler) FullSyncStoreSkus(ctx *jxcontext.Context, parentTask t
|
|||||||
}
|
}
|
||||||
return rootTask.ID, err
|
return rootTask.ID, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) GetStoresSku(ctx *jxcontext.Context, parentTask tasksch.ITask, storeIDs []int) (storeSkuList []*model.StoreSkuBind, err error) {
|
|
||||||
return storeSkuList, err
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -28,8 +28,6 @@ func (p *PurchaseHandler) GetStoreSkusBatchSize(funcID int) (batchSize int) {
|
|||||||
switch funcID {
|
switch funcID {
|
||||||
case partner.FuncUpdateStoreSkusStock, partner.FuncUpdateStoreSkusStatus, partner.FuncUpdateStoreSkusPrice:
|
case partner.FuncUpdateStoreSkusStock, partner.FuncUpdateStoreSkusStatus, partner.FuncUpdateStoreSkusPrice:
|
||||||
batchSize = mtwmapi.MaxStoreSkuBatchSize
|
batchSize = mtwmapi.MaxStoreSkuBatchSize
|
||||||
case partner.FuncGetStoreSkusBareInfo:
|
|
||||||
batchSize = partner.UnlimitedBatchSize
|
|
||||||
case partner.FuncDeleteStoreSkus:
|
case partner.FuncDeleteStoreSkus:
|
||||||
batchSize = 1 // 可考虑用批量操作
|
batchSize = 1 // 可考虑用批量操作
|
||||||
case partner.FuncCreateStoreSkus, partner.FuncUpdateStoreSkus:
|
case partner.FuncCreateStoreSkus, partner.FuncUpdateStoreSkus:
|
||||||
|
|||||||
@@ -338,7 +338,3 @@ func composeFakeDelName(name string) string {
|
|||||||
// func ComposeJXVendorSkuIDFromGoodsAndSkuID(goodsID, skuID int64) (vendorSkuID string) {
|
// func ComposeJXVendorSkuIDFromGoodsAndSkuID(goodsID, skuID int64) (vendorSkuID string) {
|
||||||
// return utils.Int64ToStr(skuID) + "," + utils.Int64ToStr(goodsID)
|
// return utils.Int64ToStr(skuID) + "," + utils.Int64ToStr(goodsID)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
func (p *PurchaseHandler) GetStoresSku(ctx *jxcontext.Context, parentTask tasksch.ITask, storeIDs []int) (storeSkuList []*model.StoreSkuBind, err error) {
|
|
||||||
return storeSkuList, err
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user