+ GetStoresSkus添加平台同步参数条件
+ GetStoreAbnoramlSkuCount + GetVendorStoreSkusInfo
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"math"
|
||||
"sort"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||
@@ -201,14 +202,32 @@ func GetStoresSkus(ctx *jxcontext.Context, storeIDs []int, isFocus bool, keyword
|
||||
sqlParams = append(sqlParams, skuIDs)
|
||||
}
|
||||
}
|
||||
if isFocus && params["fromStatus"] != nil {
|
||||
fromStatus := params["fromStatus"].(int)
|
||||
toStatus := fromStatus
|
||||
if params["toStatus"] != nil {
|
||||
toStatus = params["toStatus"].(int)
|
||||
if isFocus {
|
||||
if params["fromStatus"] != nil {
|
||||
fromStatus := params["fromStatus"].(int)
|
||||
toStatus := fromStatus
|
||||
if params["toStatus"] != nil {
|
||||
toStatus = params["toStatus"].(int)
|
||||
}
|
||||
sql += " AND t4.status >= ? AND t4.status <= ?"
|
||||
sqlParams = append(sqlParams, fromStatus, toStatus)
|
||||
}
|
||||
if params["jdSyncStatus"] != nil || params["ebaiSyncStatus"] != nil || params["mtwmSyncStatus"] != nil {
|
||||
sql += "AND ( 1 = 0"
|
||||
if params["jdSyncStatus"] != nil {
|
||||
sql += " OR t4.jd_sync_status & ? <> 0"
|
||||
sqlParams = append(sqlParams, params["jdSyncStatus"])
|
||||
}
|
||||
if params["ebaiSyncStatus"] != nil {
|
||||
sql += " OR t4.ebai_sync_status & ? <> 0"
|
||||
sqlParams = append(sqlParams, params["ebaiSyncStatus"])
|
||||
}
|
||||
if params["mtwmSyncStatus"] != nil {
|
||||
sql += " OR t4.mtwm_sync_status & ? <> 0"
|
||||
sqlParams = append(sqlParams, params["mtwmSyncStatus"])
|
||||
}
|
||||
sql += ")"
|
||||
}
|
||||
sql += " AND t4.status >= ? AND t4.status <= ?"
|
||||
sqlParams = append(sqlParams, fromStatus, toStatus)
|
||||
}
|
||||
sql += `
|
||||
GROUP BY
|
||||
@@ -396,6 +415,30 @@ func GetStoresSkus(ctx *jxcontext.Context, storeIDs []int, isFocus bool, keyword
|
||||
return skuNamesInfo, err
|
||||
}
|
||||
|
||||
func GetStoreAbnoramlSkuCount(ctx *jxcontext.Context, storeID int) (count int, err error) {
|
||||
db := dao.GetDB()
|
||||
sql := `
|
||||
SELECT COUNT(*) ct
|
||||
FROM store_sku_bind t1
|
||||
JOIN sku t2 ON t2.id = t1.sku_id AND t2.deleted_at = ?
|
||||
JOIN sku_name t3 ON t3.id = t2.name_id AND t3.deleted_at = ?
|
||||
WHERE t1.deleted_at = ? AND t1.store_id = ? AND
|
||||
(t1.jd_sync_status <> 0 OR t1.ebai_sync_status <> 0 OR t1.mtwm_sync_status <> 0) AND
|
||||
((t2.status = ? AND t3.status = ?) OR t1.status = ?)
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
utils.DefaultTimeValue,
|
||||
utils.DefaultTimeValue,
|
||||
utils.DefaultTimeValue,
|
||||
storeID,
|
||||
model.SkuStatusNormal,
|
||||
model.SkuStatusNormal,
|
||||
model.SkuStatusNormal,
|
||||
}
|
||||
err = dao.GetRow(db, &count, sql, sqlParams...)
|
||||
return count, err
|
||||
}
|
||||
|
||||
func GetStoresSkusSaleInfo(ctx *jxcontext.Context, storeIDs []int, skuIDs []int, fromTime, toTime time.Time, fromCount, toCount int) (saleInfoList []*SkuSaleInfo, err error) {
|
||||
globals.SugarLogger.Debugf("GetStoresSkusSaleInfo storeIDs:%v, fromTime:%v, toTime:%v, fromCount:%d, toCount:%d", storeIDs, fromTime, toTime, fromCount, toCount)
|
||||
|
||||
@@ -1459,3 +1502,36 @@ func RefreshStoresSkuByVendor(ctx *jxcontext.Context, storeIDs []int, vendorID i
|
||||
}
|
||||
return hint, err
|
||||
}
|
||||
|
||||
func GetVendorStoreSkusInfo(ctx *jxcontext.Context, storeID int, vendorIDs, skuIDs []int, isContinueWhenError bool) (skuVendorMap map[int][]*partner.BareStoreSkuInfo, err error) {
|
||||
globals.SugarLogger.Debugf("GetVendorStoreSkusInfo, storeID:%d, vendorIDs:%v, skuID:%v", storeID, vendorIDs, skuIDs)
|
||||
db := dao.GetDB()
|
||||
var locker sync.RWMutex
|
||||
skuVendorMap = make(map[int][]*partner.BareStoreSkuInfo)
|
||||
_, err = CurVendorSync.LoopStoresMap(ctx, db, fmt.Sprintf("GetVendorStoreSkusInfo:%d", storeID), false, false, vendorIDs, []int{storeID},
|
||||
func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (interface{}, error) {
|
||||
loopMapInfo := batchItemList[0].(*LoopStoreMapInfo)
|
||||
if handler := CurVendorSync.GetStoreHandler(loopMapInfo.VendorID); handler != nil {
|
||||
storeSkuList, err2 := dao.GetStoreSkus2(db, loopMapInfo.VendorID, storeID, skuIDs, false)
|
||||
if err = err2; err == nil && len(storeSkuList) > 0 {
|
||||
bareStoreSkuInfoList := make([]*partner.BareStoreSkuInfo, len(skuIDs))
|
||||
for k, v := range storeSkuList {
|
||||
bareStoreSkuInfoList[k] = &partner.BareStoreSkuInfo{
|
||||
SkuID: v.SkuID,
|
||||
VendorSkuID: v.VendorSkuID,
|
||||
}
|
||||
}
|
||||
if _, err = handler.GetStoreSkusInfo(ctx, t, loopMapInfo.StoreMapList[0].StoreID, loopMapInfo.StoreMapList[0].VendorStoreID, bareStoreSkuInfoList); err == nil {
|
||||
locker.Lock()
|
||||
defer locker.Unlock()
|
||||
skuVendorMap[loopMapInfo.VendorID] = bareStoreSkuInfoList
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil, err
|
||||
})
|
||||
if err != nil {
|
||||
skuVendorMap = nil
|
||||
}
|
||||
return skuVendorMap, stripSyncError(err)
|
||||
}
|
||||
|
||||
@@ -586,6 +586,13 @@ func makeSyncError(err error) (newErr error) {
|
||||
return err
|
||||
}
|
||||
|
||||
func stripSyncError(err error) (newErr error) {
|
||||
if syncErr, ok := err.(*SyncError); ok && syncErr != nil {
|
||||
return syncErr.Original
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (e *SyncError) Error() string {
|
||||
return fmt.Sprintf("本地数据修改成功,但同步失败,请根据错误提示处理!,同步错误信息:%s", e.Original.Error())
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ func GetStoreCategories(db *DaoDB, vendorID, storeID int, level int) (cats []*Sk
|
||||
|
||||
// 以store_sku_bind为基础来做同步,正常情况下使用
|
||||
// 单多门店模式厂商通用
|
||||
func GetStoreSkus(db *DaoDB, vendorID, storeID int, skuIDs []int) (skus []*StoreSkuSyncInfo, err error) {
|
||||
func GetStoreSkus2(db *DaoDB, vendorID, storeID int, skuIDs []int, isDirty bool) (skus []*StoreSkuSyncInfo, err error) {
|
||||
isSingleStorePF := model.MultiStoresVendorMap[vendorID] != 1
|
||||
tableName := "t1"
|
||||
if !isSingleStorePF {
|
||||
@@ -200,9 +200,15 @@ func GetStoreSkus(db *DaoDB, vendorID, storeID int, skuIDs []int) (skus []*Store
|
||||
LEFT JOIN store_sku_category_map t5sku ON t2.category_id = t5sku.category_id AND t5sku.store_id = t1.store_id AND t5sku.deleted_at = ?`
|
||||
sqlParams = append(sqlParams, utils.DefaultTimeValue, utils.DefaultTimeValue)
|
||||
}
|
||||
sql += " WHERE t1.store_id = ? AND (t1.%s_sync_status <> 0 OR (%s.%s_id <> 0 AND t3.id IS NULL))"
|
||||
fmtParams = append(fmtParams, fieldPrefix, tableName, fieldPrefix)
|
||||
sql += " WHERE t1.store_id = ?"
|
||||
sqlParams = append(sqlParams, storeID)
|
||||
if isDirty {
|
||||
sql += " AND (t1.%s_sync_status <> 0 OR (%s.%s_id <> 0 AND t3.id IS NULL))"
|
||||
fmtParams = append(fmtParams, fieldPrefix, tableName, fieldPrefix)
|
||||
} else {
|
||||
sql += " AND t1.deleted_at = ?"
|
||||
sqlParams = append(sqlParams, utils.DefaultTimeValue)
|
||||
}
|
||||
if len(skuIDs) > 0 {
|
||||
sql += " AND t1.sku_id IN (" + GenQuestionMarks(len(skuIDs)) + ")"
|
||||
sqlParams = append(sqlParams, skuIDs)
|
||||
@@ -220,6 +226,10 @@ func GetStoreSkus(db *DaoDB, vendorID, storeID int, skuIDs []int) (skus []*Store
|
||||
return skus, err
|
||||
}
|
||||
|
||||
func GetStoreSkus(db *DaoDB, vendorID, storeID int, skuIDs []int) (skus []*StoreSkuSyncInfo, err error) {
|
||||
return GetStoreSkus2(db, vendorID, storeID, skuIDs, true)
|
||||
}
|
||||
|
||||
// 以sku为基础来做全同步,
|
||||
// 多门店模式厂商适用
|
||||
func GetFullStoreSkus(db *DaoDB, vendorID, storeID int) (skus []*StoreSkuSyncInfo, err error) {
|
||||
|
||||
@@ -236,6 +236,7 @@ type IPurchasePlatformHandler interface {
|
||||
GetVendorCategories(ctx *jxcontext.Context) (vendorCats []*model.SkuVendorCategory, err error)
|
||||
|
||||
GetStoresSku(ctx *jxcontext.Context, parentTask tasksch.ITask, storeIDs []int) (storeSkuList []*model.StoreSkuBind, err error)
|
||||
GetStoreSkusInfo(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, vendorStoreID string, inStoreSkuList []*BareStoreSkuInfo) (outStoreSkuList []*BareStoreSkuInfo, err error)
|
||||
}
|
||||
|
||||
// db *dao.DaoDB,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package partner
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
)
|
||||
@@ -19,8 +20,8 @@ type BareStoreSkuInfo struct {
|
||||
NameID int `json:"nameID,omitempty"`
|
||||
VendorNameID string `json:"vendorNameID,omitempty"`
|
||||
|
||||
Price int `json:"prrice,omitempty"`
|
||||
Status int `json:"status,omitempty"`
|
||||
Price int64 `json:"price,omitempty"`
|
||||
Status int `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
type BareStoreSkuInfoList []*BareStoreSkuInfo
|
||||
@@ -33,6 +34,22 @@ func (l BareStoreSkuInfoList) GetVendorSkuIDList() (vendorSkuIDList []string) {
|
||||
return vendorSkuIDList
|
||||
}
|
||||
|
||||
func (l BareStoreSkuInfoList) GetVendorSkuIDIntList() (vendorSkuIDIntList []int64) {
|
||||
vendorSkuIDIntList = make([]int64, len(l))
|
||||
for k, v := range l {
|
||||
vendorSkuIDIntList[k] = utils.Str2Int64(v.VendorSkuID)
|
||||
}
|
||||
return vendorSkuIDIntList
|
||||
}
|
||||
|
||||
func (l BareStoreSkuInfoList) GetSkuIDList() (skuIDList []int) {
|
||||
skuIDList = make([]int, len(l))
|
||||
for k, v := range l {
|
||||
skuIDList[k] = v.SkuID
|
||||
}
|
||||
return skuIDList
|
||||
}
|
||||
|
||||
type BareCategoryInfo struct {
|
||||
VendorCatID string `json:"vendorCatID"`
|
||||
|
||||
|
||||
@@ -335,9 +335,11 @@ func (p *PurchaseHandler) SyncStoreSkus(ctx *jxcontext.Context, parentTask tasks
|
||||
return rootTask.ID, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) GetAllRemoteSkus(ctx *jxcontext.Context, storeID int, parentTask tasksch.ITask) (skus []map[string]interface{}, err error) {
|
||||
func (p *PurchaseHandler) GetAllRemoteSkus(ctx *jxcontext.Context, storeID int, parentTask tasksch.ITask) (skus []*ebaiapi.SkuInfo, err error) {
|
||||
globals.SugarLogger.Debugf("ebai GetAllRemoteSkus storeID:%d, userName:%s", storeID, ctx.GetUserName())
|
||||
page1, err := api.EbaiAPI.SkuList(utils.Int2Str(storeID), utils.Params2Map("pagesize", MaxPageSize))
|
||||
page1, err := api.EbaiAPI.SkuList(utils.Int2Str(storeID), &ebaiapi.SkuListParams{
|
||||
PageSize: MaxPageSize,
|
||||
})
|
||||
if err == nil {
|
||||
skus = append(skus, page1.List...)
|
||||
if page1.Pages > 1 {
|
||||
@@ -347,9 +349,9 @@ func (p *PurchaseHandler) GetAllRemoteSkus(ctx *jxcontext.Context, storeID int,
|
||||
}
|
||||
task := tasksch.NewParallelTask("GetAllRemoteSkus", nil, ctx,
|
||||
func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
callParams := map[string]interface{}{
|
||||
"pagesize": MaxPageSize,
|
||||
"page": batchItemList[0],
|
||||
callParams := &ebaiapi.SkuListParams{
|
||||
PageSize: MaxPageSize,
|
||||
Page: batchItemList[0].(int),
|
||||
}
|
||||
pageSku, err2 := api.EbaiAPI.SkuList(utils.Int2Str(storeID), callParams)
|
||||
if err2 == nil {
|
||||
@@ -362,7 +364,7 @@ func (p *PurchaseHandler) GetAllRemoteSkus(ctx *jxcontext.Context, storeID int,
|
||||
result, err2 := task.GetResult(0)
|
||||
if err = err2; err == nil {
|
||||
for _, v := range result {
|
||||
skus = append(skus, v.(map[string]interface{}))
|
||||
skus = append(skus, v.(*ebaiapi.SkuInfo))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -378,7 +380,7 @@ func (p *PurchaseHandler) DeleteRemoteSkus(ctx *jxcontext.Context, parentTask ta
|
||||
if err = err2; err == nil {
|
||||
vendorSkuIDs = make([]string, len(result))
|
||||
for k, v := range result {
|
||||
vendorSkuIDs[k] = utils.Interface2String(v[ebaiapi.KeySkuID])
|
||||
vendorSkuIDs[k] = utils.Int64ToStr(v.SkuID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"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"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
@@ -190,3 +191,55 @@ func genSkuParamsFromStoreSkuInfo2(storeSku *dao.StoreSkuSyncInfo) (params map[s
|
||||
}
|
||||
return params
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) GetStoreSkusInfo(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, vendorStoreID string, inStoreSkuList []*partner.BareStoreSkuInfo) (outStoreSkuList []*partner.BareStoreSkuInfo, err error) {
|
||||
vendorSkuIDIntList := partner.BareStoreSkuInfoList(inStoreSkuList).GetVendorSkuIDIntList()
|
||||
var vendorSkuList []*ebaiapi.SkuInfo
|
||||
if len(inStoreSkuList) > 1 {
|
||||
task := tasksch.NewParallelTask("获取饿百平台门店商品信息", nil, ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
vendorSkuID := batchItemList[0].(int64)
|
||||
skuInfo, err := api.EbaiAPI.SkuList(utils.Int2Str(storeID), &ebaiapi.SkuListParams{
|
||||
SkuID: vendorSkuID,
|
||||
})
|
||||
if err == nil {
|
||||
vendorSkuList = skuInfo.List
|
||||
return skuInfo.List, nil
|
||||
}
|
||||
return nil, err
|
||||
}, vendorSkuIDIntList)
|
||||
tasksch.HandleTask(task, parentTask, false).Run()
|
||||
_, err = task.GetResult(0)
|
||||
} else {
|
||||
skuInfo, err2 := api.EbaiAPI.SkuList(utils.Int2Str(storeID), &ebaiapi.SkuListParams{
|
||||
SkuID: utils.Str2Int64(inStoreSkuList[0].VendorSkuID),
|
||||
})
|
||||
if err = err2; err == nil {
|
||||
vendorSkuList = skuInfo.List
|
||||
}
|
||||
}
|
||||
if err == nil {
|
||||
storeSkuMap := make(map[int64]*partner.BareStoreSkuInfo)
|
||||
for _, v := range inStoreSkuList {
|
||||
storeSkuMap[utils.Str2Int64(v.VendorSkuID)] = v
|
||||
}
|
||||
for _, skuInfo := range vendorSkuList {
|
||||
storeSku := storeSkuMap[skuInfo.SkuID]
|
||||
storeSku.Price = skuInfo.SalePrice
|
||||
storeSku.Status = ebaiSkuStatus2Jx(skuInfo.Status)
|
||||
}
|
||||
outStoreSkuList = inStoreSkuList
|
||||
}
|
||||
return outStoreSkuList, err
|
||||
}
|
||||
|
||||
func ebaiSkuStatus2Jx(ebaiSkuStatus int) (jxSkuStatus int) {
|
||||
if ebaiSkuStatus == ebaiapi.SkuStatusOnline {
|
||||
jxSkuStatus = model.SkuStatusNormal
|
||||
} else if ebaiSkuStatus == ebaiapi.SkuStatusOffline {
|
||||
jxSkuStatus = model.SkuStatusDontSale
|
||||
} else if ebaiSkuStatus == ebaiapi.SkuStatusOnline {
|
||||
jxSkuStatus = model.SkuStatusDeleted
|
||||
}
|
||||
return jxSkuStatus
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ 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"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
)
|
||||
|
||||
func (p *PurchaseHandler) SyncStoreCategory(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, isAsync bool) (hint string, err error) {
|
||||
@@ -29,3 +30,7 @@ func (p *PurchaseHandler) DeleteRemoteStoreSkus(ctx *jxcontext.Context, parentTa
|
||||
func (p *PurchaseHandler) GetStoresSku(ctx *jxcontext.Context, parentTask tasksch.ITask, storeIDs []int) (storeSkuList []*model.StoreSkuBind, err error) {
|
||||
return storeSkuList, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) GetStoreSkusInfo(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, vendorStoreID string, inStoreSkuList []*partner.BareStoreSkuInfo) (outStoreSkuList []*partner.BareStoreSkuInfo, err error) {
|
||||
return outStoreSkuList, err
|
||||
}
|
||||
|
||||
61
business/partner/purchase/jd/store_sku2.go
Normal file
61
business/partner/purchase/jd/store_sku2.go
Normal file
@@ -0,0 +1,61 @@
|
||||
package jd
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"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"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
)
|
||||
|
||||
func (p *PurchaseHandler) GetStoreSkusInfo(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, vendorStoreID string, inStoreSkuList []*partner.BareStoreSkuInfo) (outStoreSkuList []*partner.BareStoreSkuInfo, err error) {
|
||||
batchSkuInfoList := make([]*jdapi.BaseStockCenterRequest, len(inStoreSkuList))
|
||||
batchSkuList := partner.BareStoreSkuInfoList(inStoreSkuList).GetVendorSkuIDIntList()
|
||||
for k, v := range inStoreSkuList {
|
||||
batchSkuInfoList[k] = &jdapi.BaseStockCenterRequest{
|
||||
StationNo: vendorStoreID,
|
||||
SkuId: utils.Str2Int64(v.VendorSkuID),
|
||||
}
|
||||
}
|
||||
var stockInfo []*jdapi.QueryStockResponse
|
||||
var priceInfo []*jdapi.StorePriceInfo
|
||||
task := tasksch.NewParallelTask("获取京东到家平台门店商品信息", tasksch.NewParallelConfig().SetParallelCount(2), ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
subTaskID := batchItemList[0].(int)
|
||||
if subTaskID == 0 {
|
||||
stockInfo, err = api.JdAPI.QueryOpenUseable(batchSkuInfoList)
|
||||
} else {
|
||||
priceInfo, err = api.JdAPI.GetStationInfoList(vendorStoreID, batchSkuList)
|
||||
globals.SugarLogger.Debug(utils.Format4Output(priceInfo, false))
|
||||
}
|
||||
return nil, err
|
||||
}, []int{0, 1})
|
||||
tasksch.HandleTask(task, parentTask, false).Run()
|
||||
_, err = task.GetResult(0)
|
||||
if err == nil {
|
||||
storeSkuMap := make(map[int64]*partner.BareStoreSkuInfo)
|
||||
for _, v := range inStoreSkuList {
|
||||
storeSkuMap[utils.Str2Int64(v.VendorSkuID)] = v
|
||||
}
|
||||
for _, v := range stockInfo {
|
||||
storeSkuMap[v.SkuID].Status = jdStoreSkuStatus2Jx(v.Vendibility)
|
||||
}
|
||||
for _, v := range priceInfo {
|
||||
storeSkuMap[v.SkuID].Price = v.Price
|
||||
}
|
||||
outStoreSkuList = inStoreSkuList
|
||||
}
|
||||
return outStoreSkuList, err
|
||||
}
|
||||
|
||||
func jdStoreSkuStatus2Jx(jdStoreSkuStatus int) (jxSkuStatus int) {
|
||||
if jdStoreSkuStatus == 0 {
|
||||
jxSkuStatus = model.SkuStatusNormal
|
||||
} else {
|
||||
jxSkuStatus = model.SkuStatusDontSale
|
||||
}
|
||||
return jxSkuStatus
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"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"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
@@ -191,7 +192,7 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID i
|
||||
Skus: []*mtwmapi.BareStoreSkuInfo{
|
||||
&mtwmapi.BareStoreSkuInfo{
|
||||
SkuID: storeSku.VendorSkuID,
|
||||
Price: utils.Int2Str(storeSku.Price),
|
||||
Price: utils.Int64ToStr(storeSku.Price),
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -202,3 +203,50 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID i
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) GetStoreSkusInfo(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, vendorStoreID string, inStoreSkuList []*partner.BareStoreSkuInfo) (outStoreSkuList []*partner.BareStoreSkuInfo, err error) {
|
||||
vendorSkuIDList := partner.BareStoreSkuInfoList(inStoreSkuList).GetVendorSkuIDList()
|
||||
var vendorFoodList []*mtwmapi.AppFood
|
||||
if len(inStoreSkuList) > 1 {
|
||||
task := tasksch.NewParallelTask("获取饿百平台门店商品信息", nil, ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
vendorSkuID := batchItemList[0].(string)
|
||||
skuInfo, err := api.MtwmAPI.RetailGet(vendorStoreID, vendorSkuID)
|
||||
if err == nil {
|
||||
vendorFoodList = []*mtwmapi.AppFood{skuInfo}
|
||||
return vendorFoodList, nil
|
||||
}
|
||||
return nil, err
|
||||
}, vendorSkuIDList)
|
||||
tasksch.HandleTask(task, parentTask, false).Run()
|
||||
_, err = task.GetResult(0)
|
||||
} else {
|
||||
skuInfo, err2 := api.MtwmAPI.RetailGet(vendorStoreID, inStoreSkuList[0].VendorSkuID)
|
||||
if err = err2; err == nil {
|
||||
vendorFoodList = []*mtwmapi.AppFood{skuInfo}
|
||||
}
|
||||
}
|
||||
if err == nil {
|
||||
storeSkuMap := make(map[string]*partner.BareStoreSkuInfo)
|
||||
for _, v := range inStoreSkuList {
|
||||
storeSkuMap[v.VendorSkuID] = v
|
||||
}
|
||||
for _, foodInfo := range vendorFoodList {
|
||||
vendorSku := foodInfo.SkuList[0]
|
||||
storeSku := storeSkuMap[vendorSku.SkuID]
|
||||
storeSku.Price = jxutils.StandardPrice2Int(utils.Str2Float64WithDefault(vendorSku.Price, 0))
|
||||
storeSku.Status = mtwmSkuStatus2Jx(foodInfo.IsSoldOut)
|
||||
}
|
||||
outStoreSkuList = inStoreSkuList
|
||||
}
|
||||
return outStoreSkuList, err
|
||||
}
|
||||
|
||||
func mtwmSkuStatus2Jx(mtwmSkuStatus int) (jxSkuStatus int) {
|
||||
if mtwmSkuStatus == 0 {
|
||||
jxSkuStatus = model.SkuStatusNormal
|
||||
} else {
|
||||
jxSkuStatus = model.SkuStatusDontSale
|
||||
}
|
||||
return jxSkuStatus
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"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"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
@@ -185,3 +186,7 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID i
|
||||
err = fmt.Errorf("内部错误,微商城不支持UpdateStoreSkusPrice!")
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) GetStoreSkusInfo(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, vendorStoreID string, inStoreSkuList []*partner.BareStoreSkuInfo) (outStoreSkuList []*partner.BareStoreSkuInfo, err error) {
|
||||
return outStoreSkuList, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user