新增最高价和最低价入参查询
This commit is contained in:
@@ -454,6 +454,13 @@ func getGetStoresSkusBaseSQL(db *dao.DaoDB, storeIDs, skuIDs []int, isFocus bool
|
|||||||
}
|
}
|
||||||
sql += ")"
|
sql += ")"
|
||||||
}
|
}
|
||||||
|
/*前台传入的最大值和最小值设置*/
|
||||||
|
if params["highestPrice"] != "" && params["highestPrice"] != nil {
|
||||||
|
sql += " AND t4.unit_price <= " + params["highestPrice"].(string)
|
||||||
|
}
|
||||||
|
if params["minimumPrice"] != "" && params["minimumPrice"] != nil {
|
||||||
|
sql += " AND t4.unit_price >= " + params["minimumPrice"].(string)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return sql, sqlParams, err
|
return sql, sqlParams, err
|
||||||
}
|
}
|
||||||
@@ -473,6 +480,27 @@ func GetStoresSkusNew(ctx *jxcontext.Context, storeIDs, skuIDs []int, isFocus, i
|
|||||||
if params["actVendorID"] != nil {
|
if params["actVendorID"] != nil {
|
||||||
actVendorID = int(utils.Interface2Int64WithDefault(params["actVendorID"], -1))
|
actVendorID = int(utils.Interface2Int64WithDefault(params["actVendorID"], -1))
|
||||||
}
|
}
|
||||||
|
var highestPrice, minimumPrice float64
|
||||||
|
if params["highestPrice"] != nil {
|
||||||
|
if _, ok := params["highestPrice"].(float64); !ok {
|
||||||
|
delete(params, "highestPrice")
|
||||||
|
} else {
|
||||||
|
highestPrice = params["highestPrice"].(float64)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if params["minimumPrice"] != nil {
|
||||||
|
if _, ok := params["minimumPrice"].(float64); !ok {
|
||||||
|
delete(params, "minimumPrice")
|
||||||
|
} else {
|
||||||
|
minimumPrice = params["minimumPrice"].(float64)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !(highestPrice > 0 && highestPrice > minimumPrice) || !(highestPrice > 0) {
|
||||||
|
delete(params, "highestPrice")
|
||||||
|
}
|
||||||
|
if !(minimumPrice >= 0 && highestPrice > 0 && highestPrice > minimumPrice) || !(minimumPrice >= 0) {
|
||||||
|
delete(params, "minimumPrice")
|
||||||
|
}
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
sql, sqlParams, err := getGetStoresSkusBaseSQL(db, storeIDs, skuIDs, isFocus, keyword, isBySku, isAct, isHighPrice, priceType, actVendorID, params)
|
sql, sqlParams, err := getGetStoresSkusBaseSQL(db, storeIDs, skuIDs, isFocus, keyword, isBySku, isAct, isHighPrice, priceType, actVendorID, params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -91,6 +91,8 @@ func (c *StoreSkuController) GetStoreSkus() {
|
|||||||
// @Param lockTime query string false "价格锁定时间"
|
// @Param lockTime query string false "价格锁定时间"
|
||||||
// @Param isHighPrice query bool false "是否查过高价格商品,0是忽略,1是高价,-1是低价"
|
// @Param isHighPrice query bool false "是否查过高价格商品,0是忽略,1是高价,-1是低价"
|
||||||
// @Param priceType query int false "是否查过高价格商品,0是忽略,1是高价,-1是低价"
|
// @Param priceType query int false "是否查过高价格商品,0是忽略,1是高价,-1是低价"
|
||||||
|
// @Param highestPrice query string false "查询最高价"
|
||||||
|
// @Param minimumPrice query string false "查询最低价"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// @Success 200 {object} controllers.CallResult
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// @Failure 200 {object} controllers.CallResult
|
||||||
// @router /GetStoresSkus [get,post]
|
// @router /GetStoresSkus [get,post]
|
||||||
|
|||||||
Reference in New Issue
Block a user