From cb7e84fe6e40f3ce3ed1fe3fb3b4c0da8c847793 Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期三, 27 八月 2025 23:51:22 +0800 Subject: [PATCH] 修改bug --- DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/service/impl/OrderTaxiServiceImpl.java | 144 +++++++++++++++++++++++++++--------------------- 1 files changed, 81 insertions(+), 63 deletions(-) diff --git a/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/service/impl/OrderTaxiServiceImpl.java b/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/service/impl/OrderTaxiServiceImpl.java index d1075d1..bc3a9eb 100644 --- a/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/service/impl/OrderTaxiServiceImpl.java +++ b/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/service/impl/OrderTaxiServiceImpl.java @@ -75,6 +75,9 @@ @Autowired private TDriverPromotionActivityService driverPromotionActivityService; + + @Resource + private IOpenCityService openCityService; @@ -141,23 +144,27 @@ */ @Override public ResultUtil grabOrder(Integer orderId, Integer uid) throws Exception { - OrderPrivateCar orderPrivateCar1 = orderPrivateCarService.selectById(orderId); - if(null != orderPrivateCar1 && orderPrivateCar1.getType() == 3 && orderPrivateCar1.getState() != 1&& orderPrivateCar1.getState() != 11){ - return ResultUtil.error("订单已被抢了"); - } - OrderTaxi orderTaxi = null; - if(null != orderPrivateCar1 && orderPrivateCar1.getType() == 3 && orderPrivateCar1.getState() == 1&& orderPrivateCar1.getState() == 11){ - orderPrivateCarService.deleteById(orderId); - OrderTaxi orderTaxi1 = setOrderTaxi(orderPrivateCar1); - this.insert(orderTaxi1); - orderTaxi = orderTaxi1; + OrderTaxi orderTaxi = this.selectById(orderId); + if(null != orderTaxi && orderTaxi.getType() == 2){ + if(orderTaxi.getState() != 1){ + return ResultUtil.error("订单已被抢了"); + } }else{ - orderTaxi = this.selectById(orderId); + OrderPrivateCar orderPrivateCar1 = orderPrivateCarService.selectById(orderId); + if(null != orderPrivateCar1 && orderPrivateCar1.getType() == 3 && orderPrivateCar1.getState() != 1&& orderPrivateCar1.getState() != 11){ + return ResultUtil.error("订单已被抢了"); + } + orderTaxi = null; + if(null != orderPrivateCar1 && orderPrivateCar1.getType() == 3 && (orderPrivateCar1.getState() == 1|| orderPrivateCar1.getState() == 11)){ + orderPrivateCarService.deleteById(orderId); + OrderTaxi orderTaxi1 = setOrderTaxi(orderPrivateCar1); + this.insert(orderTaxi1); + orderTaxi = orderTaxi1; + } } if(null == orderTaxi){ return ResultUtil.error("订单已被抢了"); } - //处理摆渡车的情况 if(orderTaxi.getType() == 2){ @@ -215,7 +222,7 @@ // } // 是否推广订单 - Integer promotion = isPromotion(orderTaxi.getUserId()); + Integer promotion = isPromotion(orderTaxi.getUserId(), driver.getPlaceOfEmployment()); if(promotion!=null){ orderTaxi.setPromotion(2); Driver driver1 = driverService.selectById(promotion); @@ -244,18 +251,20 @@ orderTaxi.setTravelId(travelItinerary); }else{ //改派抢单 - Company company1 = companyService.selectById(driver.getCompanyId()); - //中台修改订单状态 - ModifyTravelItineraryRequest request1 = new ModifyTravelItineraryRequest(); - request1.setOrderId(orderTaxi.getTravelId()); - request1.setStatus(orderTaxi.getState()); - request1.setDriverId(driver.getEmpId().toString()); - if(2 == orderTaxi.getPromotion()){ - Driver driver1 = driverService.selectById(orderTaxi.getPromotionDriverId()); - request1.setPromoterId(driver1.getEmpId().toString()); + if(ToolUtil.isNotEmpty(orderTaxi.getTravelId())){ + Company company1 = companyService.selectById(driver.getCompanyId()); + //中台修改订单状态 + ModifyTravelItineraryRequest request1 = new ModifyTravelItineraryRequest(); + request1.setOrderId(orderTaxi.getTravelId()); + request1.setStatus(orderTaxi.getState()); + request1.setDriverId(driver.getEmpId().toString()); + if(2 == orderTaxi.getPromotion()){ + Driver driver1 = driverService.selectById(orderTaxi.getPromotionDriverId()); + request1.setPromoterId(driver1.getEmpId().toString()); + } + request1.setSupplierShopId(company1.getEnterCode()); + OrderUtil.modifyTravelItinerary(request1); } - request1.setSupplierShopId(company1.getEnterCode()); - OrderUtil.modifyTravelItinerary(request1); } this.updateById(orderTaxi); @@ -329,11 +338,11 @@ return ResultUtil.success(orderTaxi.getId()); } - private Integer isPromotion(Integer userId){ + private Integer isPromotion(Integer userId, String code){ 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).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", code).le("startTime", new Date()).ge("endTime", new Date()).last("AND FIND_IN_SET(" + 2 + ", bizType) limit 1")); if(tDriverPromotionActivity!=null){ return userInfo.getBindDriverId(); } @@ -372,6 +381,7 @@ orderTaxi.setOrderType(orderPrivateCar.getOrderType()); orderTaxi.setOrderSource(orderPrivateCar.getOrderSource()); orderTaxi.setIsDelete(1); + orderTaxi.setIsReassign(1); return orderTaxi; } @@ -407,7 +417,7 @@ orderTaxi.setStartServiceTime(date); orderTaxi.setBoardingTime(date); - String value = (String) redisTemplate.opsForValue().get("DRIVER" + uid); + String value = (String) redisTemplate.opsForValue().get("dache:DRIVER" + uid); if (ToolUtil.isNotEmpty(value)) { String[] split = value.split(","); Map<String, String> geocode1 = gdMapGeocodingUtil.geocode(split[0], split[1]); @@ -473,7 +483,9 @@ */ @Override public Map<String, Object> queryOrderInfo(Integer orderId) throws Exception { - return orderTaxiMapper.queryOrderInfo(orderId); + OrderTaxi orderTaxi = this.selectById(orderId); + OpenCity openCity = openCityService.openCity1(orderTaxi.getStartLon().toString(), orderTaxi.getStartLat().toString()); + return orderTaxiMapper.queryOrderInfo(orderId, openCity.getId()); } @@ -522,19 +534,21 @@ } this.updateById(orderTaxi); - Driver driver = driverService.selectById(orderTaxi.getDriverId()); - Company company = companyService.selectById(driver.getCompanyId()); - //中台修改订单状态 - ModifyTravelItineraryRequest request = new ModifyTravelItineraryRequest(); - request.setOrderId(orderTaxi.getTravelId()); - request.setStatus(orderTaxi.getState()); - request.setDriverId(driver.getEmpId().toString()); - if(2 == orderTaxi.getPromotion()){ - Driver driver1 = driverService.selectById(orderTaxi.getPromotionDriverId()); - request.setPromoterId(driver1.getEmpId().toString()); + if(ToolUtil.isNotEmpty(orderTaxi.getTravelId())){ + Driver driver = driverService.selectById(orderTaxi.getDriverId()); + Company company = companyService.selectById(driver.getCompanyId()); + //中台修改订单状态 + ModifyTravelItineraryRequest request = new ModifyTravelItineraryRequest(); + request.setOrderId(orderTaxi.getTravelId()); + request.setStatus(orderTaxi.getState()); + request.setDriverId(driver.getEmpId().toString()); + if(2 == orderTaxi.getPromotion()){ + Driver driver1 = driverService.selectById(orderTaxi.getPromotionDriverId()); + request.setPromoterId(driver1.getEmpId().toString()); + } + request.setSupplierShopId(company.getEnterCode()); + OrderUtil.modifyTravelItinerary(request); } - request.setSupplierShopId(company.getEnterCode()); - OrderUtil.modifyTravelItinerary(request); // TODO: 2020/6/5 推送状态 new Thread(new Runnable() { @@ -580,18 +594,20 @@ this.updateById(orderTaxi); Driver driver = driverService.selectById(orderTaxi.getDriverId()); - Company company = companyService.selectById(driver.getCompanyId()); - //中台修改订单状态 - ModifyTravelItineraryRequest request = new ModifyTravelItineraryRequest(); - request.setOrderId(orderTaxi.getTravelId()); - request.setStatus(orderTaxi.getState()); - request.setDriverId(driver.getEmpId().toString()); - if(2 == orderTaxi.getPromotion()){ - Driver driver1 = driverService.selectById(orderTaxi.getPromotionDriverId()); - request.setPromoterId(driver1.getEmpId().toString()); + if(ToolUtil.isNotEmpty(orderTaxi.getTravelId())){ + Company company = companyService.selectById(driver.getCompanyId()); + //中台修改订单状态 + ModifyTravelItineraryRequest request = new ModifyTravelItineraryRequest(); + request.setOrderId(orderTaxi.getTravelId()); + request.setStatus(orderTaxi.getState()); + request.setDriverId(driver.getEmpId().toString()); + if(2 == orderTaxi.getPromotion()){ + Driver driver1 = driverService.selectById(orderTaxi.getPromotionDriverId()); + request.setPromoterId(driver1.getEmpId().toString()); + } + request.setSupplierShopId(company.getEnterCode()); + OrderUtil.modifyTravelItinerary(request); } - request.setSupplierShopId(company.getEnterCode()); - OrderUtil.modifyTravelItinerary(request); //回滚司机状态为空闲 driver.setState(2); @@ -633,18 +649,20 @@ this.updateById(orderTaxi); Driver driver = driverService.selectById(orderTaxi.getDriverId()); - Company company1 = companyService.selectById(driver.getCompanyId()); - //中台修改订单状态 - ModifyTravelItineraryRequest request1 = new ModifyTravelItineraryRequest(); - request1.setOrderId(orderTaxi.getTravelId()); - request1.setStatus(orderTaxi.getState()); - request1.setDriverId(driver.getEmpId().toString()); - if(2 == orderTaxi.getPromotion()){ - Driver driver1 = driverService.selectById(orderTaxi.getPromotionDriverId()); - request1.setPromoterId(driver1.getEmpId().toString()); + if(ToolUtil.isNotEmpty(orderTaxi.getTravelId())){ + Company company1 = companyService.selectById(driver.getCompanyId()); + //中台修改订单状态 + ModifyTravelItineraryRequest request1 = new ModifyTravelItineraryRequest(); + request1.setOrderId(orderTaxi.getTravelId()); + request1.setStatus(orderTaxi.getState()); + request1.setDriverId(driver.getEmpId().toString()); + if(2 == orderTaxi.getPromotion()){ + Driver driver1 = driverService.selectById(orderTaxi.getPromotionDriverId()); + request1.setPromoterId(driver1.getEmpId().toString()); + } + request1.setSupplierShopId(company1.getEnterCode()); + OrderUtil.modifyTravelItinerary(request1); } - request1.setSupplierShopId(company1.getEnterCode()); - OrderUtil.modifyTravelItinerary(request1); //回滚司机状态为空闲 driver.setState(2); -- Gitblit v1.7.1