zhibing.pu
2024-08-27 8f39e870ca9519d8a8190c038d15a030149de98e
UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/ServerCarModelServiceImpl.java
@@ -16,6 +16,7 @@
import com.stylefeng.guns.modular.system.util.GoogleMap.DistancematrixVo;
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 com.stylefeng.guns.modular.system.util.ResultUtil;
import com.stylefeng.guns.modular.system.warpper.ServerCarModelWarpper;
import org.springframework.beans.factory.annotation.Autowired;
@@ -46,6 +47,9 @@
    @Autowired
    private IUserInfoService userInfoService;
    @Resource
    private RedisUtil redisUtil;
@@ -61,9 +65,10 @@
     * @throws Exception
     */
    @Override
    public ResultUtil<List<ServerCarModelWarpper>> queryServerCarModel(String startLonLat, String endLonLat, Integer type, Integer language) throws Exception {
    public ResultUtil<List<ServerCarModelWarpper>> queryServerCarModel(Integer uid, String startLonLat, String endLonLat, Integer type, Integer language) throws Exception {
        String tripId = redisUtil.getValue("trip" + uid);
        //查找与起点匹配的企业(经营范围)
        ReverseGeocodeVo reverseGeocode = GoogleMapUtil.getReverseGeocode(Double.valueOf(startLonLat.split(",")[1]), Double.valueOf(startLonLat.split(",")[0]));
        ReverseGeocodeVo reverseGeocode = GoogleMapUtil.getReverseGeocode(Double.valueOf(startLonLat.split(",")[1]), Double.valueOf(startLonLat.split(",")[0]), tripId);
        if(null == language){
            language = 2;
        }
@@ -83,7 +88,7 @@
        Double slat = Double.valueOf(startLonLat.split(",")[1]);
        Double elnt = Double.valueOf(endLonLat.split(",")[0]);
        Double elat = Double.valueOf(endLonLat.split(",")[1]);
        DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(slat, slnt, elat, elnt);
        DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(slat, slnt, elat, elnt, tripId);
        if(null == distancematrix){
            return ResultUtil.error(language == 1 ? "获取预估距离出错" : language == 2 ? "Obtaining-estimated-distance error" : "Erreur d’obtention de la distance estimée", new ArrayList<>());
        }else if(distancematrix.getDistance() == 0){
@@ -94,7 +99,7 @@
        long duration = distancematrix.getDuration();//时间(秒)
        long duration_ = Long.valueOf(duration).longValue();
        List<ServerCarModelWarpper> price = this.getPrice(query.getId(), distance1_, duration_, 0, type);
        List<ServerCarModelWarpper> price = this.getPrice(query.getId(), distance1_, duration_, 0, type, language);
        if(price.size() == 0){
            return ResultUtil.error(language == 1 ? "未获取到可服务的车型" : language == 2 ? "Not obtaining available vehicle-type" : "Ne pas obtenir le type de véhicule disponible", new ArrayList<>());
        }
@@ -123,10 +128,19 @@
     * @return
     * @throws Exception
     */
    public List<ServerCarModelWarpper> getPrice(Integer companyId, double distance, long duration, long wait, Integer type) throws Exception {
    public List<ServerCarModelWarpper> getPrice(Integer companyId, double distance, long duration, long wait, Integer type, Integer language) throws Exception {
        List<Map<String, Object>> list = serverCarModelMapper.queryServerCarModel(type);
        List<ServerCarModelWarpper> data = new ArrayList<>();
        for(Map<String, Object> map : list){
            if(1 == language){
                map.put("name", map.get("chineseName"));
            }
            if(2 == language){
                map.put("name", map.get("englishName"));
            }
            if(3 == language){
                map.put("name", map.get("frenchName"));
            }
            Map<String, Object> query1 = systemPriceMapper.query(companyId, type, Integer.valueOf(map.get("id").toString()));
            if(null == query1){//排除没有设置价格的车型
                continue;