- user stationNo instead of outStationNo when calling jd store sku related apis.

This commit is contained in:
gazebo
2018-10-28 22:38:48 +08:00
parent 8604c1d2af
commit 8c726a98f0

View File

@@ -15,6 +15,7 @@ import (
type tStoreSkuBindExt struct {
model.StoreSkuBind
PricePercentage int
VendorStoreID string `orm:"column(vendor_store_id)"`
}
// 京东到家,以有库存表示关注(认领)
@@ -33,7 +34,7 @@ func (p *PurchaseHandler) SyncStoreSkus(ctx *jxcontext.Context, parentTask tasks
}
sql := `
SELECT t1.*, t2.price_percentage
SELECT t1.*, t2.price_percentage, t2.vendor_store_id
FROM store_sku_bind t1
JOIN store_map t2 ON t1.store_id = t2.store_id AND t2.vendor_id = ? AND t2.deleted_at = ?
` + sqlWhere
@@ -46,11 +47,11 @@ func (p *PurchaseHandler) SyncStoreSkus(ctx *jxcontext.Context, parentTask tasks
if err = dao.GetRows(db, &storeSkus, sql, append(sqlParams, sqlWhereParams...)...); err != nil {
return "", err
}
outStationNo := utils.Int2Str(storeID)
task := tasksch.NewParallelTask("SyncStoresSkus inner", tasksch.NewParallelConfig().SetBatchSize(jdapi.MaxStoreSkuBatchSize).SetIsContinueWhenError(isContinueWhenError), ctx.GetUserName(), func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (interface{}, error) {
var skuPriceInfoList []*jdapi.SkuPriceInfo
var skuVendibilityList []*jdapi.StockVendibility
var skuStockList []*jdapi.SkuStock
stationNo := batchItemList[0].(*tStoreSkuBindExt).VendorStoreID
for _, v := range batchItemList {
storeSku := v.(*tStoreSkuBindExt)
alreadyAddStock := false
@@ -95,13 +96,13 @@ func (p *PurchaseHandler) SyncStoreSkus(ctx *jxcontext.Context, parentTask tasks
// todo 以下可以优化为并行操作
globals.SugarLogger.Debug(utils.Format4Output(skuVendibilityList, false), utils.Format4Output(skuPriceInfoList, false), utils.Format4Output(skuStockList, false))
if len(skuVendibilityList) > 0 {
_, err = api.JdAPI.BatchUpdateVendibility(outStationNo, "", skuVendibilityList, ctx.GetUserName())
_, err = api.JdAPI.BatchUpdateVendibility("", stationNo, skuVendibilityList, ctx.GetUserName())
}
if err == nil && len(skuPriceInfoList) > 0 {
_, err = api.JdAPI.UpdateVendorStationPrice(outStationNo, "", skuPriceInfoList)
_, err = api.JdAPI.UpdateVendorStationPrice("", stationNo, skuPriceInfoList)
}
if err == nil && len(skuStockList) > 0 {
_, err = api.JdAPI.BatchUpdateCurrentQtys(outStationNo, "", skuStockList, ctx.GetUserName())
_, err = api.JdAPI.BatchUpdateCurrentQtys("", stationNo, skuStockList, ctx.GetUserName())
}
}
return nil, err