diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 96dd81e92..48e439258 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -98,14 +98,16 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa return nil, err } sqlVendorStoreCond := "" - if mapCond == "AND" { - sqlVendorStoreCond += " AND ( 1 = 1" - } else { - sqlVendorStoreCond += " AND ( 1 = 0" - } for vendor, cond := range vendorStoreConds { tableAlias := tableName + vendor if cond != 0 { + if sqlVendorStoreCond == "" { + if mapCond == "AND" { + sqlVendorStoreCond += " AND ( 1 = 1" + } else { + sqlVendorStoreCond += " AND ( 1 = 0" + } + } sql += " LEFT JOIN " + tableName + " " + tableAlias + " ON " + tableAlias + ".vendor_id = ? AND " + tableAlias + ".store_id = t1.id AND " + tableAlias + ".deleted_at = ?" sqlParams = append(sqlParams, vendor, utils.DefaultTimeValue) if cond == 1 { @@ -115,7 +117,7 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa } } } - if sqlVendorStoreCond != " AND ( 1 = 0" { + if sqlVendorStoreCond != "" { sqlWhere += sqlVendorStoreCond + ")" } } @@ -135,8 +137,8 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa sqlParams = append(sqlParams, keywordInt64, keywordInt64) sqlWhere += " OR wx1.id IS NOT NULL OR wx2.id IS NOT NULL" } - sqlWhere += " OR t1.id = ? OR t1.city_code = ? OR t1.district_code = ? OR t1.lng = ? OR t1.lat = ?" - sqlWhereParams = append(sqlWhereParams, keywordInt64, keywordInt64, keywordInt64, keywordInt64, keywordInt64) + sqlWhere += " OR t1.id = ? OR t1.city_code = ? OR t1.district_code = ?" + sqlWhereParams = append(sqlWhereParams, keywordInt64, keywordInt64, keywordInt64) } sqlWhere += ")" } @@ -201,6 +203,7 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa panic(r) } }() + // globals.SugarLogger.Debug(utils.Format4Output(sqlParams, false)) // globals.SugarLogger.Debug(sql) if err = dao.GetRows(db, &retVal.Stores, sql, sqlParams...); err == nil { countInfo := &struct{ Ct int }{}