GetStoresSkusNew中正确处理actVendorID
This commit is contained in:
@@ -193,7 +193,7 @@ func GetStoreSkus(ctx *jxcontext.Context, storeID int, skuIDs []int, isFocus boo
|
|||||||
return GetStoresSkus(ctx, []int{storeID}, skuIDs, isFocus, keyword, isBySku, isAct, params, offset, pageSize)
|
return GetStoresSkus(ctx, []int{storeID}, skuIDs, isFocus, keyword, isBySku, isAct, params, offset, pageSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getGetStoresSkusBaseSQL(db *dao.DaoDB, storeIDs, skuIDs []int, isFocus bool, keyword string, isBySku, isAct bool, params map[string]interface{}) (sql string, sqlParams []interface{}, err error) {
|
func getGetStoresSkusBaseSQL(db *dao.DaoDB, storeIDs, skuIDs []int, isFocus bool, keyword string, isBySku, isAct bool, actVendorID int, params map[string]interface{}) (sql string, sqlParams []interface{}, err error) {
|
||||||
sql = `
|
sql = `
|
||||||
FROM sku_name t1
|
FROM sku_name t1
|
||||||
JOIN sku t2 FORCE INDEX(PRIMARY) ON t1.id = t2.name_id AND t2.deleted_at = ?/* AND t2.status = ?*/
|
JOIN sku t2 FORCE INDEX(PRIMARY) ON t1.id = t2.name_id AND t2.deleted_at = ?/* AND t2.status = ?*/
|
||||||
@@ -227,6 +227,10 @@ func getGetStoresSkusBaseSQL(db *dao.DaoDB, storeIDs, skuIDs []int, isFocus bool
|
|||||||
time.Now(),
|
time.Now(),
|
||||||
time.Now(),
|
time.Now(),
|
||||||
})
|
})
|
||||||
|
if actVendorID >= 0 {
|
||||||
|
sql += " AND t1.vendor_mask & ? <> 0"
|
||||||
|
sqlParams = append(sqlParams, model.GetVendorMask(actVendorID))
|
||||||
|
}
|
||||||
if len(storeIDs) > 0 {
|
if len(storeIDs) > 0 {
|
||||||
sql += " AND t2.store_id IN (" + dao.GenQuestionMarks(len(storeIDs)) + ")"
|
sql += " AND t2.store_id IN (" + dao.GenQuestionMarks(len(storeIDs)) + ")"
|
||||||
sqlParams = append(sqlParams, storeIDs)
|
sqlParams = append(sqlParams, storeIDs)
|
||||||
@@ -380,8 +384,12 @@ func GetStoresSkusNew(ctx *jxcontext.Context, storeIDs, skuIDs []int, isFocus bo
|
|||||||
if len(storeIDs) == 0 && len(skuIDs) == 0 && pageSize == -1 {
|
if len(storeIDs) == 0 && len(skuIDs) == 0 && pageSize == -1 {
|
||||||
return nil, fmt.Errorf("GetStoresSkus必须指定storeIDs或skuIDs或分页")
|
return nil, fmt.Errorf("GetStoresSkus必须指定storeIDs或skuIDs或分页")
|
||||||
}
|
}
|
||||||
|
actVendorID := -1
|
||||||
|
if params["actVendorID"] != nil {
|
||||||
|
actVendorID = int(utils.Interface2Int64WithDefault(params["actVendorID"], -1))
|
||||||
|
}
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
sql, sqlParams, err := getGetStoresSkusBaseSQL(db, storeIDs, skuIDs, isFocus, keyword, isBySku, isAct, params)
|
sql, sqlParams, err := getGetStoresSkusBaseSQL(db, storeIDs, skuIDs, isFocus, keyword, isBySku, isAct, actVendorID, params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -499,10 +507,6 @@ func GetStoresSkusNew(ctx *jxcontext.Context, storeIDs, skuIDs []int, isFocus bo
|
|||||||
if true { //!(offset == 0 && pageSize == model.UnlimitedPageSize) {
|
if true { //!(offset == 0 && pageSize == model.UnlimitedPageSize) {
|
||||||
storeIDs, skuIDs = GetStoreAndSkuIDsFromInfo(skuNamesInfo)
|
storeIDs, skuIDs = GetStoreAndSkuIDsFromInfo(skuNamesInfo)
|
||||||
}
|
}
|
||||||
actVendorID := -1
|
|
||||||
if params["actVendorID"] != nil {
|
|
||||||
actVendorID = int(utils.Interface2Int64WithDefault(params["actVendorID"], -1))
|
|
||||||
}
|
|
||||||
beginTime := time.Now()
|
beginTime := time.Now()
|
||||||
err = updateActPrice4StoreSkuNameNew(db, storeIDs, skuIDs, skuNamesInfo, actVendorID)
|
err = updateActPrice4StoreSkuNameNew(db, storeIDs, skuIDs, skuNamesInfo, actVendorID)
|
||||||
globals.SugarLogger.Debugf("GetStoresSkusNew updateActPrice4StoreSkuName:%v", time.Now().Sub(beginTime))
|
globals.SugarLogger.Debugf("GetStoresSkusNew updateActPrice4StoreSkuName:%v", time.Now().Sub(beginTime))
|
||||||
|
|||||||
Reference in New Issue
Block a user