Commit 0db6895d by weijiguang

1、小程序查询店铺返回真实距离字段

2、小程序我的消息按创建时间倒序
parent a0410832
......@@ -569,6 +569,8 @@ public class WeixinServiceImpl {
if(StringUtils.isNotEmpty(lng)&&StringUtils.isNotEmpty(lat)){
String aa = AppServiceImpl.GetDistance(Double.parseDouble(lng), Double.parseDouble(lat), Double.parseDouble(shop1.getLng()), Double.parseDouble(shop1.getLat()));
shop1.setDistance(aa);
double realDistance = AppServiceImpl.GetRealDistance(Double.parseDouble(lng), Double.parseDouble(lat), Double.parseDouble(shop1.getLng()), Double.parseDouble(shop1.getLat()));
shop1.setRealDistance(realDistance);
}else{
shop1.setDistance("-1");
}
......
......@@ -87,6 +87,8 @@ public class Shop extends BaseEntity
private String distance;
private double realDistance;
private String machieStatus;
/** 创建时间 */
......@@ -293,6 +295,14 @@ public class Shop extends BaseEntity
return isDefault;
}
public double getRealDistance() {
return realDistance;
}
public void setRealDistance(double realDistance) {
this.realDistance = realDistance;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
......
......@@ -45,14 +45,7 @@ public class AppServiceImpl {
*/
public static String GetDistance(double lng1, double lat1, double lng2, double lat2)
{
double radLat1 = rad(lat1);
double radLat2 = rad(lat2);
double a = radLat1 - radLat2;
double b = rad(lng1) - rad(lng2);
double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a/2),2) +
Math.cos(radLat1)*Math.cos(radLat2)*Math.pow(Math.sin(b/2),2)));
s = s * EARTH_RADIUS;
s = Math.round(s * 10000) / 10000;
double s = GetRealDistance(lng1, lat1, lng2, lat2);
String distance = null;
if(s>1000&&s<10000){
DecimalFormat df = new DecimalFormat("######0.0");
......@@ -69,6 +62,18 @@ public class AppServiceImpl {
return aDouble.intValue()+"m";
}
}
public static double GetRealDistance(double lng1, double lat1, double lng2, double lat2)
{
double radLat1 = rad(lat1);
double radLat2 = rad(lat2);
double a = radLat1 - radLat2;
double b = rad(lng1) - rad(lng2);
double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a/2),2) +
Math.cos(radLat1)*Math.cos(radLat2)*Math.pow(Math.sin(b/2),2)));
s = s * EARTH_RADIUS;
s = Math.round(s * 10000) / 10000;
return s;
}
private static double rad(double d)
{
......
......@@ -35,6 +35,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="isDeleted != null and isDeleted != ''"> and is_deleted = #{isDeleted}</if>
<if test="createdAt != null "> and created_at = #{createdAt}</if>
<if test="updatedAt != null "> and updated_at = #{updatedAt}</if>
order by createdAt desc
</where>
</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