From d23f36a109964fc665dbfdfb0062e05ec9503bdb Mon Sep 17 00:00:00 2001 From: gazebo Date: Wed, 10 Oct 2018 11:34:31 +0800 Subject: [PATCH] - handle [] in GetOrders --- business/jxcallback/orderman/orderman_ext.go | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/business/jxcallback/orderman/orderman_ext.go b/business/jxcallback/orderman/orderman_ext.go index 1568711bc..25672a0b7 100644 --- a/business/jxcallback/orderman/orderman_ext.go +++ b/business/jxcallback/orderman/orderman_ext.go @@ -276,25 +276,31 @@ func (c *OrderManager) GetOrders(fromDateStr, toDateStr string, params map[strin if err = utils.UnmarshalUseNumber([]byte(params["storeIDs"].(string)), &storeIDs); err != nil { return nil, err } - sqlWhere += " AND IF(t1.jx_store_id != 0, t1.jx_store_id, t1.store_id) IN (" + dao.GenQuestionMarks(len(storeIDs)) + ")" - sqlParams = append(sqlParams, storeIDs) + if len(storeIDs) > 0 { + sqlWhere += " AND IF(t1.jx_store_id != 0, t1.jx_store_id, t1.store_id) IN (" + dao.GenQuestionMarks(len(storeIDs)) + ")" + sqlParams = append(sqlParams, storeIDs) + } } if params["statuss"] != nil { var statuss []int if err = utils.UnmarshalUseNumber([]byte(params["statuss"].(string)), &statuss); err != nil { return nil, err } - sqlWhere += " AND t1.status IN (" + dao.GenQuestionMarks(len(statuss)) + ")" - sqlParams = append(sqlParams, statuss) + if len(statuss) > 0 { + sqlWhere += " AND t1.status IN (" + dao.GenQuestionMarks(len(statuss)) + ")" + sqlParams = append(sqlParams, statuss) + } } if params["cities"] != nil { var cities []int if err = utils.UnmarshalUseNumber([]byte(params["cities"].(string)), &cities); err != nil { return nil, err } - sql += " JOIN store st ON t1.store_id = st.id" - sqlWhere += " AND st.city_code IN (" + dao.GenQuestionMarks(len(cities)) + ")" - sqlParams = append(sqlParams, cities) + if len(cities) > 0 { + sql += " JOIN store st ON t1.store_id = st.id" + sqlWhere += " AND st.city_code IN (" + dao.GenQuestionMarks(len(cities)) + ")" + sqlParams = append(sqlParams, cities) + } } sql += sqlWhere