From f9ce347bc1325ec05704b1213cdafdd9db8dd578 Mon Sep 17 00:00:00 2001
From: 44323 <443237572@qq.com>
Date: 星期一, 29 一月 2024 11:25:01 +0800
Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/PlayPai

---
 cloud-server-other/src/main/java/com/dsh/other/controller/StoreController.java |   39 ++++++++++++++++++++-------------------
 1 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/cloud-server-other/src/main/java/com/dsh/other/controller/StoreController.java b/cloud-server-other/src/main/java/com/dsh/other/controller/StoreController.java
index a5649bd..38e3a64 100644
--- a/cloud-server-other/src/main/java/com/dsh/other/controller/StoreController.java
+++ b/cloud-server-other/src/main/java/com/dsh/other/controller/StoreController.java
@@ -12,14 +12,17 @@
 import com.dsh.other.util.GeodesyUtil;
 import com.dsh.other.util.ResultUtil;
 import com.dsh.other.util.ToolUtil;
+import com.sun.javafx.binding.StringFormatter;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import java.math.BigDecimal;
 import java.math.RoundingMode;
+import java.text.DecimalFormat;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -202,37 +205,29 @@
 
         if (citycodeResp.getCityCode() == null) {
             Map<String, String> geocode = gdMapGeocodingUtil.geocode(citycodeResp.getLongitude(), citycodeResp.getLatitude());
-            String provinceCode = geocode.get("provinceCode");
-            String cityCode = geocode.get("cityCode");
-            citycodeResp.setCityCode(cityCode);
+            if(null != geocode){
+                String cityCode = geocode.get("cityCode");
+                citycodeResp.setCityCode(cityCode);
+            }
         }
 
         List<Store> list = storeService.list(new QueryWrapper<Store>()
                 .eq("state", 1)
                 .eq("cityCode", citycodeResp.getCityCode()));
         if (list.size() > 0) {
-//            if (ToolUtil.isEmpty(citycodeResp.getLongitude()) && ToolUtil.isEmpty(citycodeResp.getLatitude())){
-//                return detailLists;
-//            }
             for (Store store : list) {
                 String current = citycodeResp.getLongitude() + "," + citycodeResp.getLatitude();
                 String result = store.getLon() + "," + store.getLat();
-                String distanceTOKilometer = gdMapGeocodingUtil.getDistanceTOKilometer(current, result);
-//                long l = Long.parseLong(distanceTOKilometer);
-////                取5公里范围内的门店
-//                if ( l > 5){
-//                    continue;
-//                }
+                Map<String, Double> distance = GeodesyUtil.getDistance(current, result);
                 StoreDetailList detailList = new StoreDetailList();
                 detailList.setStoreId(store.getId());
                 detailList.setStoreImg(store.getCoverDrawing());
                 detailList.setStoreName(store.getName());
                 detailList.setStoreAddress(store.getAddress());
                 detailList.setStorePhone(store.getPhone());
-//                detailList.setStoreDistance(l);
                 detailList.setStoreTime(store.getStartTime() + "-" + store.getEndTime());
                 detailList.setStoreInfo(store.getIntroduce());
-                detailList.setStoreDistance(Double.valueOf(distanceTOKilometer));
+                detailList.setStoreDistance(null != distance ? Double.valueOf(String.format("%.2f", distance.get("WGS84") / 1000)) : 0D);
                 detailLists.add(detailList);
             }
         }
@@ -422,7 +417,7 @@
     @ApiImplicitParams({
             @ApiImplicitParam(value = "门店id", name = "id", dataType = "int", required = true),
     })
-    public ResultUtil<List<TStoreOtherConfigTrue>> queryIndexSet(Integer id) {
+    public ResultUtil<List<TStoreOtherVo>> queryIndexSet(Integer id) {
         try {
             List<TStoreOtherConfigTrue> tStoreOtherConfigTrues = new ArrayList<>();
 
@@ -430,14 +425,20 @@
             if (list.size() > 0) {
                 tStoreOtherConfigTrues = tStoreOtherConfigTrueService.list(new LambdaQueryWrapper<TStoreOtherConfigTrue>().in(TStoreOtherConfigTrue::getPid, list.stream().map(TStoreOther::getId).collect(Collectors.toList())).eq(TStoreOtherConfigTrue::getState, 1));
             }
-            for (TStoreOtherConfigTrue tStoreOtherConfigTrue : tStoreOtherConfigTrues) {
-                for (TStoreOther tStoreOther : list) {
+            List<TStoreOtherVo> list1 = new ArrayList<>();
+            for (TStoreOther tStoreOther : list) {
+                TStoreOtherVo storeOtherVo = new TStoreOtherVo();
+                BeanUtils.copyProperties(tStoreOther, storeOtherVo);
+                List<TStoreOtherConfigTrue> lists = new ArrayList<>();
+                for (TStoreOtherConfigTrue tStoreOtherConfigTrue : tStoreOtherConfigTrues) {
                     if (tStoreOtherConfigTrue.getPid() == tStoreOther.getId()) {
-                        tStoreOtherConfigTrue.setSort(tStoreOther.getSort());
+                        lists.add(tStoreOtherConfigTrue);
                     }
                 }
+                storeOtherVo.setList(lists);
+                list1.add(storeOtherVo);
             }
-            return ResultUtil.success(tStoreOtherConfigTrues);
+            return ResultUtil.success(list1);
         } catch (Exception e) {
             e.printStackTrace();
             return ResultUtil.runErr();

--
Gitblit v1.7.1