liujie
2025-08-05 415017b0673c08818997189b44af8f1d04a55078
DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java
@@ -15,7 +15,11 @@
import com.stylefeng.guns.modular.system.dao.UserInfoMapper;
import com.stylefeng.guns.modular.system.model.*;
import com.stylefeng.guns.modular.system.service.*;
import com.stylefeng.guns.modular.system.service.impl.OpenCityServiceImpl;
import com.stylefeng.guns.modular.system.util.*;
import com.stylefeng.guns.modular.system.util.qianyuntong.OrderUtil;
import com.stylefeng.guns.modular.system.util.qianyuntong.model.CreateTravelItineraryRequest;
import com.stylefeng.guns.modular.system.util.qianyuntong.model.ModifyTravelItineraryRequest;
import com.stylefeng.guns.modular.taxi.model.OrderTaxi;
import com.stylefeng.guns.modular.taxi.service.IOrderTaxiService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -36,6 +40,9 @@
    @Resource
    private SystemPriceMapper systemPriceMapper;
    @Autowired
    private ISystemPriceCityService systemPriceCityService;
    @Autowired
    private IDriverService driverService;
@@ -100,8 +107,13 @@
    
    @Resource
    private RedisTemplate<String, Object> redisTemplate;
    @Resource
    private IOpenCityService openCityService;
    /**
     * 获取司机端首页订单列表
     *
@@ -237,15 +249,49 @@
        // 是否推广订单
        Integer promotion = isPromotion(uid);
        if(promotion!=null){
        Integer promotion = isPromotion(orderPrivateCar.getUserId());
        if(null != promotion){
            orderPrivateCar.setPromotion(2);
            Driver driver1 = driverService.selectById(promotion);
            orderPrivateCar.setPromotionUser(driver1.getName());
            orderPrivateCar.setPromotionPhone(driver1.getPhone());
            orderPrivateCar.setPromotionDriverId(promotion);
        }else{
            orderPrivateCar.setPromotion(1);
        }
        if(null == oldDriverId){
            UserInfo userInfo = userInfoMapper.selectById(orderPrivateCar.getUserId());
            Company company = companyService.selectById(driver.getCompanyId());
            //调三方订单中心创建行程单
            CreateTravelItineraryRequest request = new CreateTravelItineraryRequest();
            request.setOrderNo("PR" + orderPrivateCar.getId());
            request.setCustomerId(userInfo.getOnconUUID());
            request.setDriverId(driver.getEmpId().toString());
            request.setSupplierShopId(company.getEnterCode());
            if(2 == orderPrivateCar.getPromotion()){
                Driver driver1 = driverService.selectById(orderPrivateCar.getPromotionDriverId());
                request.setPromoterId(driver1.getEmpId().toString());
            }
            request.setServiceType(2);
            String travelItinerary = OrderUtil.createTravelItinerary(request);
            orderPrivateCar.setTravelId(travelItinerary);
        }else{
            //改派抢单
            Company company1 = companyService.selectById(driver.getCompanyId());
            //中台修改订单状态
            ModifyTravelItineraryRequest request1 = new ModifyTravelItineraryRequest();
            request1.setOrderId(orderPrivateCar.getTravelId());
            request1.setStatus(orderPrivateCar.getState());
            request1.setDriverId(driver.getEmpId().toString());
            if(2 == orderPrivateCar.getPromotion()){
                Driver driver1 = driverService.selectById(orderPrivateCar.getPromotionDriverId());
                request1.setPromoterId(driver1.getEmpId().toString());
            }
            request1.setSupplierShopId(company1.getEnterCode());
            OrderUtil.modifyTravelItinerary(request1);
        }
        this.updateById(orderPrivateCar);
        //处理摆渡车的情况
@@ -325,7 +371,7 @@
            }).start();
        }
        
        return ResultUtil.success(orderPrivateCar.getId());
    }
@@ -334,9 +380,9 @@
        UserInfo userInfo = userInfoMapper.selectById(userId);
        if(userInfo.getBindDriverId()!=null && userInfo.getBindExpireDate().getTime()<=System.currentTimeMillis()){
            String registAreaCode = userInfo.getRegistAreaCode();
            TDriverPromotionActivity tDriverPromotionActivity = driverPromotionActivityService.selectOne(new EntityWrapper<TDriverPromotionActivity>().eq("districtCode", registAreaCode).ge("startTime", new Date()).lt("endTime", new Date()).last("AND FIND_IN_SET(" + 1 + ", bizType) limit 1"));
            TDriverPromotionActivity tDriverPromotionActivity = driverPromotionActivityService.selectOne(new EntityWrapper<TDriverPromotionActivity>().eq("state",1).eq("districtCode", registAreaCode).ge("startTime", new Date()).lt("endTime", new Date()).last("AND FIND_IN_SET(" + 1 + ", bizType) limit 1"));
            if(tDriverPromotionActivity!=null){
                return 2;
                return userInfo.getBindDriverId();
            }
        }
        return null;
@@ -432,7 +478,9 @@
        map.put("emergencyCall",  "110");
        map.put("orders", JSON.toJSONString(orders));
        return map;*/
        Map<String,Object> map = orderPrivateCarMapper.queryOrderInfo2(orderId);
        OrderPrivateCar orderPrivateCar1 = orderPrivateCarMapper.selectById(orderId);
        OpenCity openCity = openCityService.openCity1(orderPrivateCar1.getStartLon().toString(), orderPrivateCar1.getStartLat().toString());
        Map<String,Object> map = orderPrivateCarMapper.queryOrderInfo2(orderId, openCity.getId());
        OrderPrivateCar orderPrivateCar = this.baseMapper.selectById(orderId);
        Integer canOperation=1;
        if(orderPrivateCar.getState()<5){
@@ -522,6 +570,20 @@
                break;
        }
        this.updateById(orderPrivateCar);
        Driver driver = driverService.selectById(orderPrivateCar.getDriverId());
        Company company = companyService.selectById(driver.getCompanyId());
        //中台修改订单状态
        ModifyTravelItineraryRequest request = new ModifyTravelItineraryRequest();
        request.setOrderId(orderPrivateCar.getTravelId());
        request.setStatus(orderPrivateCar.getState());
        request.setDriverId(driver.getEmpId().toString());
        if(2 == orderPrivateCar.getPromotion()){
            Driver driver1 = driverService.selectById(orderPrivateCar.getPromotionDriverId());
            request.setPromoterId(driver1.getEmpId().toString());
        }
        request.setSupplierShopId(company.getEnterCode());
        OrderUtil.modifyTravelItinerary(request);
        // TODO: 2020/6/5 推送状态
        OrderPrivateCar finalOrderPrivateCar = orderPrivateCar;
@@ -589,20 +651,33 @@
        orderPrivateCar.setOrderMoney(orderPrivateCar.getOrderMoney() + orderPrivateCar.getParkMoney() + orderPrivateCar.getRoadTollMoney());
        orderPrivateCar.setState(7);
        this.updateById(orderPrivateCar);
        Driver driver = driverService.selectById(orderPrivateCar.getDriverId());
        Company company = companyService.selectById(driver.getCompanyId());
        //中台修改订单状态
        ModifyTravelItineraryRequest request = new ModifyTravelItineraryRequest();
        request.setOrderId(orderPrivateCar.getTravelId());
        request.setStatus(7);
        request.setDriverId(driver.getEmpId().toString());
        if(2 == orderPrivateCar.getPromotion()){
            Driver driver1 = driverService.selectById(orderPrivateCar.getPromotionDriverId());
            request.setPromoterId(driver1.getEmpId().toString());
        }
        request.setSupplierShopId(company.getEnterCode());
        OrderUtil.modifyTravelItinerary(request);
        pushUtil.removeTask(orderId, 1);//删除定时任务,结束推送数据
        systemNoticeService.addSystemNotice(1, "司机已结束本次行程,谢谢使用", orderPrivateCar.getUserId(), 1);
        //回滚司机状态为空闲
        if(orderPrivateCar.getSpellSuccess()==0){
            Driver driver = driverService.selectById(orderPrivateCar.getDriverId());
            driver.setState(2);
            driverService.updateById(driver);
        }else{
            if(orderPrivateCar.getPid()==null){
                Integer number = this.selectCount(new EntityWrapper<OrderPrivateCar>().eq("pid",orderPrivateCar.getPid()==null?orderPrivateCar.getId():orderPrivateCar.getPid()).lt("state",6));
                if(number<=0){
                    Driver driver = driverService.selectById(orderPrivateCar.getDriverId());
                    driver.setState(2);
                    driverService.updateById(driver);
                }
@@ -610,7 +685,6 @@
                Integer number = this.selectCount(new EntityWrapper<OrderPrivateCar>().eq("pid",orderPrivateCar.getPid()==null?orderPrivateCar.getId():orderPrivateCar.getPid()).lt("state",6));
                Integer number1 = this.selectCount(new EntityWrapper<OrderPrivateCar>().eq("id",orderPrivateCar.getPid()).lt("state",6));
                if(number<=0 && number1<=0){
                    Driver driver = driverService.selectById(orderPrivateCar.getDriverId());
                    driver.setState(2);
                    driverService.updateById(driver);
                }
@@ -771,12 +845,25 @@
        orderPrivateCar.setOrderMoney(orderPrivateCar.getOrderMoney() + orderPrivateCar.getParkMoney() + orderPrivateCar.getRoadTollMoney() + orderPrivateCar.getHolidayFee() + t);
        orderPrivateCar.setState(7);
        this.updateById(orderPrivateCar);
        Driver driver = driverService.selectById(orderPrivateCar.getDriverId());
        Company company1 = companyService.selectById(driver.getCompanyId());
        //中台修改订单状态
        ModifyTravelItineraryRequest request1 = new ModifyTravelItineraryRequest();
        request1.setOrderId(orderPrivateCar.getTravelId());
        request1.setStatus(orderPrivateCar.getState());
        request1.setDriverId(driver.getEmpId().toString());
        if(2 == orderPrivateCar.getPromotion()){
            Driver driver1 = driverService.selectById(orderPrivateCar.getPromotionDriverId());
            request1.setPromoterId(driver1.getEmpId().toString());
        }
        request1.setSupplierShopId(company1.getEnterCode());
        OrderUtil.modifyTravelItinerary(request1);
        pushUtil.removeTask(orderId, 1);//删除定时任务,结束推送数据
        systemNoticeService.addSystemNotice(1, "司机已结束本次行程,谢谢使用", orderPrivateCar.getUserId(), 1);
        //回滚司机状态为空闲
        Driver driver = driverService.selectById(orderPrivateCar.getDriverId());
        driver.setState(2);
        driverService.updateById(driver);
@@ -820,7 +907,7 @@
        }
        Map<String, Object> map = new HashMap<>();
        map.put("orderMoney", new BigDecimal(orderPrivateCar.getOrderMoney()).setScale(2,BigDecimal.ROUND_DOWN));//订单金额
        map.put("orderMoney", orderPrivateCar.getOrderMoney()==null?0:new BigDecimal(orderPrivateCar.getOrderMoney()).setScale(2,BigDecimal.ROUND_DOWN));//订单金额
        map.put("startMileage", orderPrivateCar.getStartMileage());//起步价
        map.put("startMoney", orderPrivateCar.getStartMoney());//起步价
        map.put("mileageKilometers", orderPrivateCar.getMileageKilometers());//里程费
@@ -967,7 +1054,9 @@
     * @throws Exception
     */
    public OrderPrivateCar setMoney(OrderPrivateCar orderPrivateCar, Double parkingFee, Double crossingFee) throws Exception {
        Map<String, Object> query1 = systemPriceMapper.query(orderPrivateCar.getCompanyId(), 1, orderPrivateCar.getServerCarModelId());
        Map<String, String> geocode = gdMapGeocodingUtil.geocode(orderPrivateCar.getStartLon().toString(), orderPrivateCar.getStartLat().toString());
        SystemPriceCity systemPriceCity = systemPriceCityService.queryOne(geocode.get("provinceCode"), geocode.get("cityCode"), geocode.get("districtCode"));
        Map<String, Object> query1 = systemPriceMapper.query(systemPriceCity.getId(), 1, orderPrivateCar.getServerCarModelId());
        //开始根据不同的方式计算金额
        double amount = 0;
        JSONObject jsonObject = JSON.parseObject(String.valueOf(query1.get("content")));