- 移除partner.GetStoresSku

This commit is contained in:
gazebo
2019-07-26 15:24:40 +08:00
parent 11dca2ebcc
commit a1d41ca99d
11 changed files with 123 additions and 183 deletions

View File

@@ -168,15 +168,13 @@ type IPurchasePlatformHandler interface {
// CloseStore(vendorStoreID, closeNotice, userName string) 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)
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)
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,

View File

@@ -12,7 +12,7 @@ import (
)
const (
FuncGetStoreSkusBareInfo = 1
// FuncGetStoreSkusBareInfo = 1 // 此接口要求实现为不限制批处理大小的
FuncUpdateStoreSkusStock = 2
FuncUpdateStoreSkusStatus = 3
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)
// 此接口要求实现为不限制批处理大小的
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)
UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*StoreSkuInfo, status int) (successList []*StoreSkuInfo, err error)

View File

@@ -571,7 +571,3 @@ func (p *PurchaseHandler) updateLocalCatAsNew(db *dao.DaoDB, localCatMap map[str
}
return nil
}
func (p *PurchaseHandler) GetStoresSku(ctx *jxcontext.Context, parentTask tasksch.ITask, storeIDs []int) (storeSkuList []*model.StoreSkuBind, err error) {
return storeSkuList, err
}

View File

@@ -28,8 +28,6 @@ func (p *PurchaseHandler) GetStoreSkusBatchSize(funcID int) (batchSize int) {
switch funcID {
case partner.FuncUpdateStoreSkusStock, partner.FuncUpdateStoreSkusStatus, partner.FuncUpdateStoreSkusPrice, partner.FuncDeleteStoreSkus:
batchSize = ebaiapi.MaxStoreSkuBatchSize
case partner.FuncGetStoreSkusBareInfo:
batchSize = partner.UnlimitedBatchSize
case partner.FuncCreateStoreSkus, partner.FuncUpdateStoreSkus:
batchSize = 1
case partner.FuncGetStoreSkusFullInfo:

View File

@@ -3,7 +3,6 @@ package elm
import (
"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/model"
)
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) {
return hint, err
}
func (p *PurchaseHandler) GetStoresSku(ctx *jxcontext.Context, parentTask tasksch.ITask, storeIDs []int) (storeSkuList []*model.StoreSkuBind, err error) {
return storeSkuList, err
}

View File

@@ -204,80 +204,3 @@ func constrainPrice(price int) int {
}
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
}

View File

@@ -15,13 +15,13 @@ import (
func (p *PurchaseHandler) GetStoreSkusBatchSize(funcID int) (batchSize int) {
switch funcID {
case partner.FuncGetStoreSkusBareInfo, partner.FuncUpdateStoreSkusStock, partner.FuncUpdateStoreSkusStatus, partner.FuncUpdateStoreSkusPrice:
case partner.FuncUpdateStoreSkusStock, partner.FuncUpdateStoreSkusStatus, partner.FuncUpdateStoreSkusPrice:
batchSize = jdapi.MaxStoreSkuBatchSize
}
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
batchSkuList := partner.BareStoreSkuInfoList(inStoreSkuList).GetVendorSkuIDIntList()
for _, v := range inStoreSkuList {
@@ -64,6 +64,20 @@ func (p *PurchaseHandler) GetStoreSkusBareInfo(ctx *jxcontext.Context, parentTas
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) {
if jdStoreSkuStatus == 0 {
jxSkuStatus = model.SkuStatusNormal

View File

@@ -457,7 +457,3 @@ func (p *PurchaseHandler) FullSyncStoreSkus(ctx *jxcontext.Context, parentTask t
}
return rootTask.ID, err
}
func (p *PurchaseHandler) GetStoresSku(ctx *jxcontext.Context, parentTask tasksch.ITask, storeIDs []int) (storeSkuList []*model.StoreSkuBind, err error) {
return storeSkuList, err
}

View File

@@ -28,8 +28,6 @@ func (p *PurchaseHandler) GetStoreSkusBatchSize(funcID int) (batchSize int) {
switch funcID {
case partner.FuncUpdateStoreSkusStock, partner.FuncUpdateStoreSkusStatus, partner.FuncUpdateStoreSkusPrice:
batchSize = mtwmapi.MaxStoreSkuBatchSize
case partner.FuncGetStoreSkusBareInfo:
batchSize = partner.UnlimitedBatchSize
case partner.FuncDeleteStoreSkus:
batchSize = 1 // 可考虑用批量操作
case partner.FuncCreateStoreSkus, partner.FuncUpdateStoreSkus:

View File

@@ -338,7 +338,3 @@ func composeFakeDelName(name string) string {
// func ComposeJXVendorSkuIDFromGoodsAndSkuID(goodsID, skuID int64) (vendorSkuID string) {
// 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
}