| | |
| | | import com.stylefeng.guns.modular.system.dao.PhoneMapper; |
| | | import com.stylefeng.guns.modular.system.model.Phone; |
| | | 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 org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | * @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(Double lat, Double lnt) throws Exception { |
| | | ReverseGeocodeVo reverseGeocode = GoogleMapUtil.getReverseGeocode(lat, lnt); |
| | | 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<Phone> list = phoneMapper.queryPhones(city); |
| | | 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(Double lat, Double lnt) throws Exception { |
| | | ReverseGeocodeVo reverseGeocode = GoogleMapUtil.getReverseGeocode(lat, lnt); |
| | | 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, city); |
| | | map.put("platform", null != query ? query.getPhone() : ""); |
| | | |
| | | //公司 |
| | | 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, city); |
| | | map.put("company", null != query ? query.getPhone() : ""); |
| | | return map; |
| | | } |