From 4c99ee7028c3fe58a2cd4b8273b22c75c45574fc Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期五, 16 五月 2025 10:27:41 +0800
Subject: [PATCH] 修改文档bug

---
 UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/PhoneServiceImpl.java |   66 +++++++++++++++++++++-----------
 1 files changed, 43 insertions(+), 23 deletions(-)

diff --git a/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/PhoneServiceImpl.java b/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/PhoneServiceImpl.java
index 67b912b..a3db1d2 100644
--- a/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/PhoneServiceImpl.java
+++ b/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/PhoneServiceImpl.java
@@ -2,8 +2,14 @@
 
 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
 import com.stylefeng.guns.modular.system.dao.PhoneMapper;
+import com.stylefeng.guns.modular.system.model.Company;
 import com.stylefeng.guns.modular.system.model.Phone;
+import com.stylefeng.guns.modular.system.service.ICompanyCityService;
 import com.stylefeng.guns.modular.system.service.IPhoneService;
+import com.stylefeng.guns.modular.system.util.GoogleMap.AddressComponentsVo;
+import com.stylefeng.guns.modular.system.util.GoogleMap.GoogleMapUtil;
+import com.stylefeng.guns.modular.system.util.GoogleMap.ReverseGeocodeVo;
+import com.stylefeng.guns.modular.system.util.RedisUtil;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -11,6 +17,7 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 
 @Service
@@ -18,6 +25,15 @@
 
     @Resource
     private PhoneMapper phoneMapper;
+    
+    @Resource
+    private RedisUtil redisUtil;
+    
+    @Resource
+    private ICompanyCityService companyCityService;
+    
+    
+    
 
     /**
      * 获取所有系统电话
@@ -25,45 +41,49 @@
      * @throws Exception
      */
     @Override
-    public List<Phone> queryPhones(String code) throws Exception {
-        String province = code.substring(0, 2) + "0000";
-        String city = code.substring(0, 4) + "00";
-
-        List<Phone> list = phoneMapper.queryPhones(province, city, code);
-        if(list.size() == 0){
-            list = phoneMapper.queryPhones(province, city, null);
+    public List<Phone> queryPhones(Integer uid, Double lat, Double lnt) throws Exception {
+        String tripId = redisUtil.getValue("trip" + uid);
+        ReverseGeocodeVo reverseGeocode = GoogleMapUtil.getReverseGeocode(lat, lnt, tripId);
+        if(null == reverseGeocode){
+            return new ArrayList<>();
         }
-        if(list.size() == 0){
-            list = phoneMapper.queryPhones(province, null, null);
+        AddressComponentsVo[] addressComponentsVos = reverseGeocode.getAddressComponentsVos();
+        String[] city = new String[addressComponentsVos.length];
+        for (int i = 0; i < addressComponentsVos.length; i++) {
+            city[i] = addressComponentsVos[i].getLongName();
         }
+        List<Company> companies = companyCityService.query2(city);
+        List<Integer> collect = companies.stream().map(Company::getId).collect(Collectors.toList());
+        List<Phone> list = phoneMapper.queryPhones(collect);
         return list;
     }
 
 
     /**
      * 获取客服电话(个人中心)
-     * @param code
      * @return
      * @throws Exception
      */
     @Override
-    public Map<String, Object> queryCustomerPhone(String code) throws Exception {
-        String province = code.substring(0, 2) + "0000";
-        String city = code.substring(0, 4) + "00";
-
+    public Map<String, Object> queryCustomerPhone(Integer uid, Double lat, Double lnt) throws Exception {
+        String tripId = redisUtil.getValue("trip" + uid);
+        ReverseGeocodeVo reverseGeocode = GoogleMapUtil.getReverseGeocode(lat, lnt, tripId);
+        if(null == reverseGeocode){
+            return new HashMap<>();
+        }
+        AddressComponentsVo[] addressComponentsVos = reverseGeocode.getAddressComponentsVos();
+        String[] city = new String[addressComponentsVos.length];
+        for (int i = 0; i < addressComponentsVos.length; i++) {
+            city[i] = addressComponentsVos[i].getLongName();
+        }
         Map<String, Object> map = new HashMap<>();
         //平台电话
-        Phone query = phoneMapper.query(2, 1, null, null, null);
+        Phone query = phoneMapper.query(2, 1, null);
         map.put("platform", null != query ? query.getPhone() : "");
-
+    
+        Company company = companyCityService.query1(city);
         //公司
-        query = phoneMapper.query(2, 2, province, city, code);
-        if(query == null){
-            query = phoneMapper.query(2, 2, province, city, null);
-        }
-        if(query == null){
-            query = phoneMapper.query(2, 2, province, null, null);
-        }
+        query = phoneMapper.query(2, 2, company.getId());
         map.put("company", null != query ? query.getPhone() : "");
         return map;
     }

--
Gitblit v1.7.1