- GetStores添加参数:startStoreID, coordinateType。返回值添加provinceName省名

This commit is contained in:
gazebo
2019-08-21 18:21:07 +08:00
parent 2769f18ab4
commit 2be1c7b71d
2 changed files with 18 additions and 2 deletions

View File

@@ -13,6 +13,7 @@ import (
"git.rosy.net.cn/jx-callback/business/auth2"
"git.rosy.net.cn/jx-callback/business/authz"
"git.rosy.net.cn/baseapi/platformapi/autonavi"
"git.rosy.net.cn/baseapi/platformapi/dingdingapi"
"git.rosy.net.cn/baseapi/platformapi/jdapi"
"git.rosy.net.cn/baseapi/utils"
@@ -41,6 +42,7 @@ type StoreExt struct {
model.Store
FloatLng float64 `json:"lng"`
FloatLat float64 `json:"lat"`
ProvinceName string `json:"provinceName"`
CityName string `json:"cityName"`
DistrictName string `json:"districtName"`
StoreMapStr string `json:"-"`
@@ -175,6 +177,7 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa
t1.operator_role2,
t1.printer_font_size,
province.name province_name,
city.name city_name,
district.name district_name,
CONCAT('[', GROUP_CONCAT(DISTINCT CONCAT('{"vendorStoreID":"', m1.vendor_store_id, '", "vendorID":', m1.vendor_id,
@@ -191,6 +194,7 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa
FROM store t1
LEFT JOIN new_config bank ON bank.deleted_at = ? AND bank.type = ? AND bank.key = t1.payee_bank_code
LEFT JOIN place city ON t1.city_code = city.code AND city.level = 2
LEFT JOIN place province ON province.code = city.parent_code AND province.level = 1
LEFT JOIN place district ON t1.district_code = district.code AND district.level = 3
LEFT JOIN store_map m1 ON t1.id = m1.store_id AND m1.deleted_at = ?
LEFT JOIN ebde_shops eb ON eb.col_baidu_shop_id = m1.vendor_store_id
@@ -290,6 +294,10 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa
sqlWhereParams = append(sqlWhereParams, storeIDs)
}
}
if params["startStoreID"] != nil {
sqlWhere += " AND t1.id >= ?"
sqlWhereParams = append(sqlWhereParams, params["startStoreID"])
}
if params["name"] != nil {
sqlWhere += " AND t1.name LIKE ?"
sqlWhereParams = append(sqlWhereParams, "%"+params["name"].(string)+"%")
@@ -328,7 +336,7 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa
}
sql += sqlWhere + `
GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31, 32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62
GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31, 32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63
ORDER BY t1.id DESC
/*LIMIT ? OFFSET ?*/`
pageSize = jxutils.FormalizePageSize(pageSize)
@@ -350,6 +358,8 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa
// globals.SugarLogger.Debug(sql)
var storeList []*StoreExt
mapLimit := false
needConver2Baidu := int(utils.Interface2Int64WithDefault(params["coordinateType"], 0)) == model.CoordinateTypeBaiDu
if err = dao.GetRows(db, &storeList, sql, sqlParams...); err == nil {
// retVal.TotalCount = dao.GetLastTotalRowCount(db)
// dao.Commit(db)
@@ -365,7 +375,6 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa
mapRadius = params["mapRadius"].(int)
}
for _, v := range storeList {
globals.SugarLogger.Debug(v.StoreMapStr)
valid := !mapLimit
if mapLimit {
valid = jxutils.EarthDistance(mapLongitude, mapLatitude, v.FloatLng, v.FloatLat)*1000 <= float64(mapRadius)
@@ -394,6 +403,11 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa
}
retVal.Stores = retVal.Stores[offset : offset+pageSize]
}
if needConver2Baidu {
for _, v := range storeList {
v.FloatLng, v.FloatLat, _ = api.AutonaviAPI.CoordinateConvert(v.FloatLng, v.FloatLat, autonavi.CoordSysBaidu)
}
}
// if mapLimit {
// retVal.TotalCount = len(retVal.Stores)
// }

View File

@@ -18,6 +18,8 @@ type StoreController struct {
// @Param token header string true "认证token"
// @Param keyword query string false "查询关键字(可以为空,为空表示不限制)"
// @Param storeID query int false "门店ID"
// @Param startStoreID query int false "起始门店ID"
// @Param coordinateType query int false "返回坐标类型0火星坐标1百度缺省0"
// @Param storeIDs query string false "门店ID列表"
// @Param name query string false "门店名称(不要求完全一致)"
// @Param placeID query int false "所属地点ID"