‘linchangsheng’ 1 周之前
父節點
當前提交
3c79c9bd3c
共有 1 個文件被更改,包括 3 次插入2 次删除
  1. 3 2
      src/main/java/com/gree/mall/miniapp/logic/user/UserLogic.java

+ 3 - 2
src/main/java/com/gree/mall/miniapp/logic/user/UserLogic.java

@@ -37,6 +37,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import javax.servlet.http.HttpServletRequest;
 import java.math.BigDecimal;
+import java.text.DecimalFormat;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
@@ -491,9 +492,9 @@ public class UserLogic {
                 Math.cos(lat1Rad) * Math.cos(lat2Rad) *
                         Math.sin(deltaLon / 2) * Math.sin(deltaLon / 2);
         double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
-
+        DecimalFormat df = new DecimalFormat("#.00");
         // 返回距离(单位:公里)
-        return EARTH_RADIUS * c;
+        return Convert.toDouble(df.format((EARTH_RADIUS * c)));
     }