| | |
| | | import com.stylefeng.guns.modular.system.dao.CarServiceMapper; |
| | | import com.stylefeng.guns.modular.system.dao.RegionMapper; |
| | | import com.stylefeng.guns.modular.system.dao.SystemPriceMapper; |
| | | 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.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; |
| | |
| | | |
| | | @Resource |
| | | private SystemPriceMapper systemPriceMapper; |
| | | |
| | | @Autowired |
| | | private ISystemPriceCityService systemPriceCityService; |
| | | |
| | | @Autowired |
| | | private IDriverService driverService; |
| | |
| | | |
| | | @Resource |
| | | private CarServiceMapper carServiceMapper; |
| | | |
| | | @Resource |
| | | private UserInfoMapper userInfoMapper; |
| | | |
| | | |
| | | @Autowired |
| | | private TDriverPromotionActivityService driverPromotionActivityService; |
| | | |
| | | @Resource |
| | | private RedisTemplate<String, Object> redisTemplate; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @Resource |
| | | private IOpenCityService openCityService; |
| | | |
| | | |
| | | /** |
| | | * 获取司机端首页订单列表 |
| | | * |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public synchronized ResultUtil grabOrder(Integer orderId, Integer uid) throws Exception { |
| | | public ResultUtil grabOrder(Integer orderId, Integer uid) throws Exception { |
| | | OrderPrivateCar orderPrivateCar = this.selectById(orderId); |
| | | if(null == orderPrivateCar){ |
| | | return ResultUtil.error("订单已被抢了"); |
| | |
| | | orderPrivateCar.setSnatchOrderTime(new Date()); |
| | | |
| | | //调用高德创建轨迹 |
| | | String s = gdFalconUtil.selectTerminal(driver.getPhone()); |
| | | String track = gdFalconUtil.createTrack(s); |
| | | orderPrivateCar.setTrackId(track); |
| | | // String s = gdFalconUtil.selectTerminal(driver.getPhone()); |
| | | // String track = gdFalconUtil.createTrack(s); |
| | | // orderPrivateCar.setTrackId(track); |
| | | |
| | | //调用移动的小号接口 |
| | | Map<String, String> map = chinaMobileUtil.midAxbBindSend(orderPrivateCar.getPassengersPhone(), driver.getPhone(), (System.currentTimeMillis() + 86400000)); |
| | | if(String.valueOf(map.get("code")).equals("200")){ |
| | | orderPrivateCar.setTelX(map.get("telX")); |
| | | orderPrivateCar.setBindId(map.get("bindId")); |
| | | } |
| | | // Map<String, String> map = chinaMobileUtil.midAxbBindSend(orderPrivateCar.getPassengersPhone(), driver.getPhone(), (System.currentTimeMillis() + 86400000)); |
| | | // if(String.valueOf(map.get("code")).equals("200")){ |
| | | // orderPrivateCar.setTelX(map.get("telX")); |
| | | // orderPrivateCar.setBindId(map.get("bindId")); |
| | | // } |
| | | |
| | | |
| | | |
| | | // 是否推广订单 |
| | | 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); |
| | | |
| | | //处理摆渡车的情况 |
| | |
| | | |
| | | systemNoticeService.addSystemNotice(2, "您已成功抢得快车订单,请及时联系客户!", orderPrivateCar.getDriverId(), 1); |
| | | systemNoticeService.addSystemNotice(1, "您的订单已指派给" + driver.getName().substring(0, 1) + "师傅,请保持电话畅通!", orderPrivateCar.getUserId(), 1); |
| | | |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | if(pushMinistryOfTransport){ |
| | | |
| | | if(pushMinistryOfTransport){ |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | //上传数据 |
| | | pushMinistryOfTransportUtil.orderCreate(orderId); |
| | | pushMinistryOfTransportUtil.orderMatch(orderId); |
| | | } |
| | | } |
| | | }).start(); |
| | | |
| | | }).start(); |
| | | } |
| | | |
| | | |
| | | return ResultUtil.success(orderPrivateCar.getId()); |
| | | } |
| | | |
| | | |
| | | private Integer isPromotion(Integer userId){ |
| | | 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("state",1).eq("districtCode", registAreaCode).last(" and between now() startTime and endTime AND FIND_IN_SET(" + 1 + ", bizType) limit 1")); |
| | | if(tDriverPromotionActivity!=null){ |
| | | return userInfo.getBindDriverId(); |
| | | } |
| | | } |
| | | return null; |
| | | |
| | | } |
| | | /** |
| | | * 获取订单详情页(服务中的页面) |
| | | * @param orderId |
| | |
| | | if(order!=null){ |
| | | orders.addAll(order); |
| | | } |
| | | String value = (String) redisTemplate.opsForValue().get("DRIVER" + String.valueOf(orderPrivateCar.getDriverId())); |
| | | String value = (String) redisTemplate.opsForValue().get("dache:DRIVER" + String.valueOf(orderPrivateCar.getDriverId())); |
| | | order = this.baseMapper.queryOrderInfo(orderId,5,value.split(",")[0],value.split(",")[1]); |
| | | if(order!=null){ |
| | | orders.addAll(order); |
| | |
| | | if(order!=null){ |
| | | orders.addAll(order); |
| | | } |
| | | String value = (String) redisTemplate.opsForValue().get("DRIVER" + String.valueOf(orderPrivateCar.getDriverId())); |
| | | String value = (String) redisTemplate.opsForValue().get("dache:DRIVER" + String.valueOf(orderPrivateCar.getDriverId())); |
| | | order = this.baseMapper.queryOrderInfo(orderPrivateCar.getPid(),5,value.split(",")[0],value.split(",")[1]); |
| | | if(order!=null){ |
| | | orders.addAll(order); |
| | |
| | | orders.addAll(order); |
| | | } |
| | | OrderPrivateCar orderPrivateCar = this.baseMapper.selectById(orderId); |
| | | String value = redisUtil.getValue("DRIVER" + String.valueOf(orderPrivateCar.getDriverId())); |
| | | String value = redisUtil.getValue("dache:DRIVER" + String.valueOf(orderPrivateCar.getDriverId())); |
| | | order = this.baseMapper.queryOrderInfo(orderId,5,value.split(",")[0],value.split(",")[1]); |
| | | if(order!=null){ |
| | | orders.addAll(order); |
| | |
| | | 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){ |
| | |
| | | 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; |
| | |
| | | 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); |
| | | } |
| | |
| | | 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); |
| | | } |
| | |
| | | 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); |
| | | |
| | |
| | | } |
| | | |
| | | 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());//里程费 |
| | |
| | | * @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"))); |