Commit 3e922cd8 authored by hezhen's avatar hezhen

123

parent c90c3dab
...@@ -66,7 +66,13 @@ public class TourGoodBiz extends BaseBiz<TourGoodMapper, TourGood> { ...@@ -66,7 +66,13 @@ public class TourGoodBiz extends BaseBiz<TourGoodMapper, TourGood> {
*/ */
public ObjectRestResponse<TourGood> getGoodList(int page, int limit , String query , Double latitude, Double longitude, Integer tagId, Double distance){ public ObjectRestResponse<TourGood> getGoodList(int page, int limit , String query , Double latitude, Double longitude, Integer tagId, Double distance){
Map<String, Object> params = initParam(page, limit, query, latitude, longitude, tagId, distance); Map<String, Object> params = initParam(page, limit, query, latitude, longitude, tagId, distance);
return new ObjectRestResponse().status(RestCode.SUCCESS.getStatus()).msg(RestCode.SUCCESS.getMsg()).data(PageDataVO.pageInfo(page, limit, () -> mapper.getGoodList(params))); PageDataVO<TourGood> dataVO=null;
if(latitude!=null&&latitude>0&&longitude!=null&&longitude>0){
dataVO=PageDataVO.pageInfo(page, limit, ()->mapper.getCoordinateList(params));
}else {
dataVO=PageDataVO.pageInfo(page, limit, ()->mapper.getGoodList(params));
}
return new ObjectRestResponse().status(RestCode.SUCCESS.getStatus()).msg(RestCode.SUCCESS.getMsg()).data(dataVO);
} }
private Map<String, Object> initParam(int page, int limit, String query, Double latitude, Double longitude, Integer tagId, Double distance) { private Map<String, Object> initParam(int page, int limit, String query, Double latitude, Double longitude, Integer tagId, Double distance) {
......
...@@ -23,6 +23,8 @@ public interface TourGoodMapper extends Mapper<TourGood> { ...@@ -23,6 +23,8 @@ public interface TourGoodMapper extends Mapper<TourGood> {
//查询旅游路线列表 //查询旅游路线列表
public List<TourGood> getGoodList(@Param("params") Map<String,Object> map); public List<TourGood> getGoodList(@Param("params") Map<String,Object> map);
//根据经纬度查询旅游路线列表
public List<TourGood> getCoordinateList(@Param("params") Map<String,Object> map);
//获取商品列表 //获取商品列表
public List<TourGoodVo> findGoodList(@Param("params") GoodSearchDTO tourGoodDTO); public List<TourGoodVo> findGoodList(@Param("params") GoodSearchDTO tourGoodDTO);
......
...@@ -36,7 +36,7 @@ public class TourGoodController extends BaseController<TourGoodBiz, TourGood> { ...@@ -36,7 +36,7 @@ public class TourGoodController extends BaseController<TourGoodBiz, TourGood> {
public ObjectRestResponse<TourGood> getGoodList(@RequestParam(value = "page", required = true) Integer page, @RequestParam(value = "limit", required = true) Integer limit, public ObjectRestResponse<TourGood> getGoodList(@RequestParam(value = "page", required = true) Integer page, @RequestParam(value = "limit", required = true) Integer limit,
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "latitude", required = false) Double latitude, @RequestParam(value = "query", required = false) String query, @RequestParam(value = "latitude", required = false) Double latitude,
@RequestParam(value = "longitude", required = false) Double longitude, @RequestParam(value = "tagId", required = false) Integer tagId, @RequestParam(value = "longitude", required = false) Double longitude, @RequestParam(value = "tagId", required = false) Integer tagId,
@RequestParam(value = "distance", defaultValue = "10.00") Double distance) { @RequestParam(value = "distance", defaultValue = "100.00") Double distance) {
return baseBiz.getGoodList(page, limit, query, latitude, longitude, tagId, distance); return baseBiz.getGoodList(page, limit, query, latitude, longitude, tagId, distance);
} }
......
...@@ -51,6 +51,21 @@ ...@@ -51,6 +51,21 @@
<result property="isOutside" column="is_outside"/> <result property="isOutside" column="is_outside"/>
</resultMap> </resultMap>
<!--查询旅游路线列表-->
<select id="getCoordinateList" parameterType="java.util.Map" resultMap="tourGoodMap">
SELECT t.* from tour_good t
left join (
select good_id,
IFNULL(ROUND(( (2 * ASIN( SQRT( POW( SIN((latitude * PI() / 180.0- #{params.latitude}* PI() / 180.0)/2), 2)+COS( latitude * PI() / 180.0)*COS( #{params.longitude} * PI() / 180.0)
*POW(SIN((longitude * PI() / 180.0 - #{params.longitude}* PI() /180.0)/2),2))))*6378.137)*10000)/10000 ,0 ) AS distance
FROM tour_good_site WHERE type=2 ) gs ON t.id=gs.good_id
where t.is_del=0 AND t.status=1 and gs.distance &lt; #{params.distance}
<if test="params.query != null and params.query != ''">
and (t.`name` like CONCAT('%',#{params.query},'%') or t.introduce like CONCAT('%',#{params.query},'%'))
</if>
order by gs.distance
</select>
<!--查询旅游路线列表--> <!--查询旅游路线列表-->
<select id="getGoodList" parameterType="java.util.Map" resultMap="tourGoodMap"> <select id="getGoodList" parameterType="java.util.Map" resultMap="tourGoodMap">
SELECT * from tour_good t SELECT * from tour_good t
...@@ -58,22 +73,11 @@ ...@@ -58,22 +73,11 @@
<if test="params.query != null and params.query != ''"> <if test="params.query != null and params.query != ''">
and (t.`name` like CONCAT('%',#{params.query},'%') or t.introduce like CONCAT('%',#{params.query},'%')) and (t.`name` like CONCAT('%',#{params.query},'%') or t.introduce like CONCAT('%',#{params.query},'%'))
</if> </if>
<if test="params.latitude != null and params.latitude != '' and params.longitude != null and params.longitude != ''"> <if test="params.tagId != null and params.tagId != '' ">
and t.id in (SELECT s.good_id from ( and t.id in (SELECT tg.good_id from tour_good_tag tg
select good_id, where tg.tag_id = #{params.tagId}) and t.recommend = 1
if(ROUND(( (2 * ASIN( SQRT( POW( SIN((latitude * PI() / 180.0- #{params.latitude}* PI() / 180.0)/2), 2)+COS( latitude * PI() / 180.0)*COS( #{params.longitude} * PI() / 180.0) ORDER BY t.recommend
*POW(SIN((longitude * PI() / 180.0 - #{params.longitude}* PI() /180.0)/2),2))))*6378.137)*10000)/10000 is null ,0,ROUND(( (2 * ASIN( SQRT( POW( SIN((latitude * PI() / 180.0- #{params.latitude}* PI() / 180.0)/2), 2)+COS( latitude * PI() / 180.0)*COS(#{params.longitude} * PI() / 180.0) </if>
*POW(SIN((longitude * PI() / 180.0 - #{params.longitude}* PI() /180.0)/2),2))))*6378.137)*10000)/10000 ) AS distance
FROM tour_good_site
order by distance
) s
where s.distance &lt; #{params.distance})
</if>
<if test="params.tagId != null and params.tagId != '' ">
and t.id in (SELECT tg.good_id from tour_good_tag tg
where tg.tag_id = #{params.tagId}) and t.recommend = 1
ORDER BY t.recommend
</if>
</select> </select>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment