+ 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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user