From 3eda219ba9abc0041469606aff1325130e833535 Mon Sep 17 00:00:00 2001 From: suyl <770236076@qq.com> Date: Wed, 1 Sep 2021 09:43:17 +0800 Subject: [PATCH] aa --- business/jxstore/cms/store.go | 56 ++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 79e91addf..c1e5e0b48 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -438,6 +438,14 @@ func getStoresSql(ctx *jxcontext.Context, keyword string, params map[string]inte } } + if params["mapLongitude"] != nil && params["mapLatitude"] != nil && params["mapRadius"] != nil { + mapLongitude := utils.Str2Float64(params["mapLongitude"].(string)) + mapLatitude := utils.Str2Float64(params["mapLatitude"].(string)) + mapRadius := params["mapRadius"].(int) + sqlWhere += " AND getDistance(?, ?, CAST(t1.lng AS DECIMAL(15,6))/1000000, CAST(t1.lat AS DECIMAL(15,6))/1000000) * 1000 <= ?" + sqlWhereParams = append(sqlWhereParams, mapLongitude, mapLatitude, mapRadius) + } + sql = sqlFrom + sqlWhere sqlParams = append(sqlParams, sqlFromParams...) sqlParams = append(sqlParams, sqlWhereParams...) @@ -512,8 +520,8 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa sql = ` SELECT DISTINCT t1.*, - CAST(t1.lng AS DECIMAL(15,6))/1000000 float_lng, - CAST(t1.lat AS DECIMAL(15,6))/1000000 float_lat, + -- CAST(t1.lng AS DECIMAL(15,6))/1000000 float_lng, + -- CAST(t1.lat AS DECIMAL(15,6))/1000000 float_lat, IF(mm.name <> '', mm.name, mm.user_id2) market_man_name, bank.value payee_bank_name, IF(om.name <> '', om.name, om.user_id2) operator_name, @@ -536,33 +544,33 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa var storeList []*StoreExt offset = jxutils.FormalizePageOffset(offset) pageSize = jxutils.FormalizePageSize(pageSize) - mapLimit := false + //mapLimit := false // globals.SugarLogger.Debug(sql) // globals.SugarLogger.Debug(utils.Format4Output(sqlParams, false)) if err = dao.GetRows(db, &storeList, sql, sqlParams...); err == nil { // 地图区域限制过滤 - if mapLongitude2, ok := params["mapLongitude"].(string); ok { - var ( - mapLatitude, mapLongitude float64 - mapRadius int - ) - mapLimit = true - mapLongitude = utils.Str2Float64(mapLongitude2) - mapLatitude = utils.Str2Float64(params["mapLatitude"].(string)) - mapRadius = params["mapRadius"].(int) - for _, v := range storeList { - valid := !mapLimit - if mapLimit { - valid = jxutils.EarthDistance(mapLongitude, mapLatitude, v.FloatLng, v.FloatLat)*1000 <= float64(mapRadius) - } - if valid { - retVal.Stores = append(retVal.Stores, v) - } - } - } else { - retVal.Stores = storeList - } + //if mapLongitude2, ok := params["mapLongitude"].(string); ok { + // var ( + // mapLatitude, mapLongitude float64 + // mapRadius int + // ) + // mapLimit = true + // mapLongitude = utils.Str2Float64(mapLongitude2) + // mapLatitude = utils.Str2Float64(params["mapLatitude"].(string)) + // mapRadius = params["mapRadius"].(int) + // for _, v := range storeList { + // valid := !mapLimit + // if mapLimit { + // valid = jxutils.EarthDistance(mapLongitude, mapLatitude, v.FloatLng, v.FloatLat)*1000 <= float64(mapRadius) + // } + // if valid { + // retVal.Stores = append(retVal.Stores, v) + // } + // } + //} else { + // retVal.Stores = storeList + //} //权限 if permission.IsRoled(ctx) { if storeIDsMap, err := permission.GetUserStoresResultMap(ctx.GetUserID()); err == nil {