From f53307a41a08bb123f1eeda4a3b7fbbf67863fc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B9=B3=E5=87=A1=E6=A2=A6?= Date: Wed, 8 Jul 2020 10:00:31 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=9C=80=E9=AB=98?= =?UTF-8?q?=E4=BB=B7=E5=92=8C=E6=9C=80=E4=BD=8E=E4=BB=B7=E5=85=A5=E5=8F=82?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store_sku.go | 28 ++++++++++++++++++++++++++++ controllers/cms_store_sku.go | 2 ++ 2 files changed, 30 insertions(+) diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index 735e15d35..830d9617d 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -454,6 +454,13 @@ func getGetStoresSkusBaseSQL(db *dao.DaoDB, storeIDs, skuIDs []int, isFocus bool } 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 } @@ -473,6 +480,27 @@ func GetStoresSkusNew(ctx *jxcontext.Context, storeIDs, skuIDs []int, isFocus, i if params["actVendorID"] != nil { 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() sql, sqlParams, err := getGetStoresSkusBaseSQL(db, storeIDs, skuIDs, isFocus, keyword, isBySku, isAct, isHighPrice, priceType, actVendorID, params) if err != nil { diff --git a/controllers/cms_store_sku.go b/controllers/cms_store_sku.go index fdf13d57e..4f7d3eec2 100644 --- a/controllers/cms_store_sku.go +++ b/controllers/cms_store_sku.go @@ -91,6 +91,8 @@ func (c *StoreSkuController) GetStoreSkus() { // @Param lockTime query string false "价格锁定时间" // @Param isHighPrice query bool 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 // @Failure 200 {object} controllers.CallResult // @router /GetStoresSkus [get,post] From 624f55e3fd60c8f89ddf66960bb6a72a6343a13d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B9=B3=E5=87=A1=E6=A2=A6?= Date: Wed, 8 Jul 2020 11:34:32 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=AD=A3best=5Fseller=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/sku.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/business/jxstore/cms/sku.go b/business/jxstore/cms/sku.go index 9d9d6d5f2..c0344b3eb 100644 --- a/business/jxstore/cms/sku.go +++ b/business/jxstore/cms/sku.go @@ -600,7 +600,8 @@ func GetSkuNames(ctx *jxcontext.Context, keyword string, isBySku, isQueryMidPric t1.ex_prefix_end, t1.yb_name_suffix, t1.jds_stock_switch, - t1.preparation_time + t1.preparation_time, + t1.best_seller ` if isQueryMidPrice { sql += `, @@ -645,6 +646,7 @@ func GetSkuNames(ctx *jxcontext.Context, keyword string, isBySku, isQueryMidPric t1.yb_name_suffix, t1.jds_stock_switch, t1.preparation_time, + t1.best_seller, ` if isQueryMidPrice { sqlData += " t4.mid_unit_price,"