| | |
| | | import com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar; |
| | | import com.stylefeng.guns.modular.specialTrain.server.IOrderPrivateCarService; |
| | | import com.stylefeng.guns.modular.specialTrain.server.impl.OrderPrivateCarServiceImpl; |
| | | import com.stylefeng.guns.modular.system.dao.RegionMapper; |
| | | import com.stylefeng.guns.modular.system.dao.SensitiveWordsMapper; |
| | | import com.stylefeng.guns.modular.system.dao.SysIntegralMapper; |
| | | import com.stylefeng.guns.modular.system.dao.UserActivityDiscount1Mapper; |
| | | import com.stylefeng.guns.modular.system.dao.*; |
| | | import com.stylefeng.guns.modular.system.model.*; |
| | | import com.stylefeng.guns.modular.system.model.vo.UnPayOrderVO; |
| | | import com.stylefeng.guns.modular.system.service.*; |
| | |
| | | @Resource |
| | | private OrderTaxiMapper orderTaxiMapper; |
| | | |
| | | @Resource |
| | | private RegionMapper regionMapper; |
| | | |
| | | |
| | | @Resource |
| | | private SensitiveWordsMapper sensitiveWordsMapper; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private IOrderPrivateCarService orderPrivateCarService; |
| | | |
| | | @Autowired |
| | | private ILineService lineService; |
| | | |
| | | |
| | | @Autowired |
| | | private IIncomeService incomeService; |
| | | |
| | |
| | | @Autowired |
| | | private ChinaMobileUtil chinaMobileUtil; |
| | | |
| | | @Autowired |
| | | private GDFalconUtil gdFalconUtil; |
| | | |
| | | |
| | | @Resource |
| | | private RedisTemplate<String, Object> redisTemplate; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private PayMoneyUtil payMoneyUtil; |
| | | |
| | | @Autowired |
| | | private IOrderLogisticsService orderLogisticsService; |
| | | |
| | | @Autowired |
| | | private ITaxiCardPaymentService taxiCardPaymentService; |
| | | |
| | | |
| | | @Autowired |
| | | private ICompanyService companyService; |
| | | |
| | |
| | | @Autowired |
| | | private IRegionService regionService; |
| | | |
| | | @Autowired |
| | | private TAbnormalPayOrderMapper abnormalPayOrderMapper; |
| | | |
| | | @Resource |
| | | private CarMapper carMapper; |
| | | |
| | | @Resource |
| | | private CarModelMapper carModelMapper; |
| | | |
| | | @Autowired |
| | | private TDriverPromotionActivityService driverPromotionActivityService; |
| | |
| | | |
| | | // 是否推广订单 |
| | | Integer promotion = isPromotion(uid); |
| | | orderCrossCity.setPromotion(promotion); |
| | | if(promotion!=null){ |
| | | orderCrossCity.setPromotion(2); |
| | | Driver driver1 = driverService.selectById(promotion); |
| | | orderCrossCity.setPromotionUser(driver1.getName()); |
| | | orderCrossCity.setPromotionPhone(driver1.getPhone()); |
| | | orderCrossCity.setPromotionDriverId(promotion); |
| | | }else{ |
| | | orderCrossCity.setPromotion(1); |
| | | } |
| | | |
| | | this.insert(orderCrossCity); |
| | | |
| | |
| | | return ResultUtil.success(baseWarpper); |
| | | } |
| | | |
| | | |
| | | private Integer isPromotion(Integer userId){ |
| | | UserInfo userInfo = userInfoService.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(" + 3 + ", bizType) limit 1")); |
| | | TDriverPromotionActivity tDriverPromotionActivity = driverPromotionActivityService.selectOne(new EntityWrapper<TDriverPromotionActivity>().eq("state",1).eq("districtCode", registAreaCode).le("startTime", new Date()).ge("endTime", new Date()).last("AND FIND_IN_SET(" + 3 + ", bizType) limit 1")); |
| | | if(tDriverPromotionActivity!=null){ |
| | | return 2; |
| | | return userInfo.getBindDriverId(); |
| | | } |
| | | } |
| | | return null; |
| | | |
| | | } |
| | | /** |
| | | * 获取订单 |
| | |
| | | } |
| | | }).start(); |
| | | } |
| | | Driver driver = driverService.selectById(orderCrossCity.getDriverId()); |
| | | |
| | | //修改司机座位 |
| | | LineShiftDriver lineShiftDriver = lineShiftDriverMapper.selectById(orderCrossCity.getLineShiftDriverId()); |
| | | lineShiftDriver.setLaveSeat(lineShiftDriver.getLaveSeat() + orderCrossCity.getPeopleNumber()); |
| | | lineShiftDriver.setLaveSeatNumber(lineShiftDriver.getLaveSeatNumber() + (orderCrossCity.getTravelMode() == 1 ? "," : "") + orderCrossCity.getSeatNumber()); |
| | | lineShiftDriverMapper.updateById(lineShiftDriver); |
| | | if(1 == orderCrossCity.getTravelMode()){ |
| | | LineShiftDriver lineShiftDriver = lineShiftDriverMapper.selectById(orderCrossCity.getLineShiftDriverId()); |
| | | lineShiftDriver.setLaveSeat(lineShiftDriver.getLaveSeat() + orderCrossCity.getPeopleNumber()); |
| | | lineShiftDriver.setLaveSeatNumber(lineShiftDriver.getLaveSeatNumber() + (orderCrossCity.getTravelMode() == 1 ? "," : "") + orderCrossCity.getSeatNumber()); |
| | | lineShiftDriverMapper.updateById(lineShiftDriver); |
| | | }else{ |
| | | Car car = carMapper.selectById(driver.getCarId()); |
| | | CarModel carModel = carModelMapper.selectById(car.getCarModelId()); |
| | | LineShiftDriver lineShiftDriver = lineShiftDriverMapper.selectById(orderCrossCity.getLineShiftDriverId()); |
| | | lineShiftDriver.setLaveSeat(carModel.getSeat() - 1); |
| | | String seatNumber = ""; |
| | | for(int i = 1; i < carModel.getSeat(); i++){ |
| | | seatNumber += i + ","; |
| | | } |
| | | lineShiftDriver.setLaveSeatNumber(seatNumber.substring(0, seatNumber.length() - 1)); |
| | | lineShiftDriverMapper.updateById(lineShiftDriver); |
| | | } |
| | | |
| | | //修改司机为空闲 |
| | | List<OrderCrossCity> orderCrossCities = orderCrossCityMapper.queryByDriverId(orderCrossCity.getDriverId(), 2, 3, 4, 5, 11); |
| | | if (orderCrossCities.size() == 0) { |
| | | Driver driver = driverService.selectById(orderCrossCity.getDriverId()); |
| | | driver.setState(2); |
| | | driverService.updateById(driver); |
| | | } |
| | |
| | | @Override |
| | | public OrderServerWarpper queryOrderServer(Integer orderId, Integer uid) throws Exception { |
| | | OrderCrossCity orderCrossCity = this.selectById(orderId); |
| | | //计算预计距离和剩余时间 |
| | | String value = (String) redisTemplate.opsForValue().get("DRIVER" + String.valueOf(orderCrossCity.getDriverId())); |
| | | if (null == value || "".equals(value)) { |
| | | System.err.println("司机没有上传位置信息"); |
| | | if(null != orderCrossCity){ |
| | | //计算预计距离和剩余时间 |
| | | String value = (String) redisTemplate.opsForValue().get("dache:DRIVER" + String.valueOf(orderCrossCity.getDriverId())); |
| | | if (null == value || "".equals(value)) { |
| | | System.err.println("司机没有上传位置信息"); |
| | | |
| | | //调用获取轨迹中的数据 |
| | | List<Map<String, Object>> list = orderPositionService.queryTrack(orderId, 3); |
| | | if (list.size() > 0) { |
| | | Map<String, Object> map = list.get(list.size() - 1); |
| | | value = map.get("lon") + "," + map.get("lat"); |
| | | } |
| | | } |
| | | |
| | | //调用获取轨迹中的数据 |
| | | List<Map<String, Object>> list = orderPositionService.queryTrack(orderId, 3); |
| | | if (list.size() > 0) { |
| | | Map<String, Object> map = list.get(list.size() - 1); |
| | | value = map.get("lon") + "," + map.get("lat"); |
| | | OrderServerWarpper orderServerWarpper = new OrderServerWarpper(); |
| | | orderServerWarpper.setOrderId(orderCrossCity.getId()); |
| | | orderServerWarpper.setOrderType(3); |
| | | orderServerWarpper.setState(orderCrossCity.getState()); |
| | | orderServerWarpper.setLon(null != value ? value.split(",")[0] : "0.0"); |
| | | orderServerWarpper.setLat(null != value ? value.split(",")[1] : "0.0"); |
| | | orderServerWarpper.setReassignNotice(orderCrossCity.getReassignNotice()); |
| | | if (orderCrossCity.getState() == 2 || orderCrossCity.getState() == 3) {//前往预约地 |
| | | // TODO: 2023/11/4 无法修改 |
| | | Map<String, String> distance = gdMapElectricFenceUtil.getDistance(value, orderCrossCity.getStartLon() + "," + orderCrossCity.getStartLat(), 1); |
| | | String d = "0"; |
| | | String t = "0"; |
| | | if (null == distance) { |
| | | System.err.println("查询距离出错了"); |
| | | } else { |
| | | d = new BigDecimal(distance.get("distance")).divide(new BigDecimal(1000), new MathContext(2, RoundingMode.HALF_EVEN)).toString(); |
| | | t = new BigDecimal(distance.get("duration")).divide(new BigDecimal(60), new MathContext(2, RoundingMode.HALF_EVEN)).intValue() + ""; |
| | | } |
| | | orderServerWarpper.setReservationMileage(d); |
| | | orderServerWarpper.setReservationTime(t); |
| | | orderServerWarpper.setServedMileage("0"); |
| | | orderServerWarpper.setServedTime("0"); |
| | | orderServerWarpper.setLaveMileage("0"); |
| | | orderServerWarpper.setLaveTime("0"); |
| | | } |
| | | } |
| | | |
| | | OrderServerWarpper orderServerWarpper = new OrderServerWarpper(); |
| | | orderServerWarpper.setOrderId(orderCrossCity.getId()); |
| | | orderServerWarpper.setOrderType(3); |
| | | orderServerWarpper.setState(orderCrossCity.getState()); |
| | | orderServerWarpper.setLon(null != value ? value.split(",")[0] : "0.0"); |
| | | orderServerWarpper.setLat(null != value ? value.split(",")[1] : "0.0"); |
| | | orderServerWarpper.setReassignNotice(orderCrossCity.getReassignNotice()); |
| | | if (orderCrossCity.getState() == 2 || orderCrossCity.getState() == 3) {//前往预约地 |
| | | // TODO: 2023/11/4 无法修改 |
| | | Map<String, String> distance = gdMapElectricFenceUtil.getDistance(value, orderCrossCity.getStartLon() + "," + orderCrossCity.getStartLat(), 1); |
| | | String d = "0"; |
| | | String t = "0"; |
| | | if (null == distance) { |
| | | System.err.println("查询距离出错了"); |
| | | } else { |
| | | d = new BigDecimal(distance.get("distance")).divide(new BigDecimal(1000), new MathContext(2, RoundingMode.HALF_EVEN)).toString(); |
| | | t = new BigDecimal(distance.get("duration")).divide(new BigDecimal(60), new MathContext(2, RoundingMode.HALF_EVEN)).intValue() + ""; |
| | | if (orderCrossCity.getState() == 5 || orderCrossCity.getState() == 6) {//服务中 |
| | | // TODO: 2023/11/4 无法修改 |
| | | Map<String, String> distance = gdMapElectricFenceUtil.getDistance(value, orderCrossCity.getEndLon() + "," + orderCrossCity.getEndLat(), 1); |
| | | String d = "0"; |
| | | String t = "0"; |
| | | if (null == distance) { |
| | | System.err.println("查询距离出错了"); |
| | | } else { |
| | | d = new BigDecimal(distance.get("distance")).divide(new BigDecimal(1000), new MathContext(2, RoundingMode.HALF_EVEN)).toString(); |
| | | t = new BigDecimal(distance.get("duration")).divide(new BigDecimal(60), new MathContext(2, RoundingMode.HALF_EVEN)).intValue() + ""; |
| | | } |
| | | orderServerWarpper.setReservationMileage("0"); |
| | | orderServerWarpper.setReservationTime("0"); |
| | | orderServerWarpper.setServedMileage(String.valueOf(orderCrossCity.getMileage() / 1000)); |
| | | orderServerWarpper.setServedTime(Long.valueOf((new Date().getTime() - orderCrossCity.getStartServiceTime().getTime()) / 60000).intValue() + ""); |
| | | orderServerWarpper.setLaveMileage(d); |
| | | orderServerWarpper.setLaveTime(t); |
| | | } |
| | | orderServerWarpper.setReservationMileage(d); |
| | | orderServerWarpper.setReservationTime(t); |
| | | orderServerWarpper.setServedMileage("0"); |
| | | orderServerWarpper.setServedTime("0"); |
| | | orderServerWarpper.setLaveMileage("0"); |
| | | orderServerWarpper.setLaveTime("0"); |
| | | |
| | | return orderServerWarpper; |
| | | } |
| | | if (orderCrossCity.getState() == 5 || orderCrossCity.getState() == 6) {//服务中 |
| | | // TODO: 2023/11/4 无法修改 |
| | | Map<String, String> distance = gdMapElectricFenceUtil.getDistance(value, orderCrossCity.getEndLon() + "," + orderCrossCity.getEndLat(), 1); |
| | | String d = "0"; |
| | | String t = "0"; |
| | | if (null == distance) { |
| | | System.err.println("查询距离出错了"); |
| | | } else { |
| | | d = new BigDecimal(distance.get("distance")).divide(new BigDecimal(1000), new MathContext(2, RoundingMode.HALF_EVEN)).toString(); |
| | | t = new BigDecimal(distance.get("duration")).divide(new BigDecimal(60), new MathContext(2, RoundingMode.HALF_EVEN)).intValue() + ""; |
| | | } |
| | | orderServerWarpper.setReservationMileage("0"); |
| | | orderServerWarpper.setReservationTime("0"); |
| | | orderServerWarpper.setServedMileage(String.valueOf(orderCrossCity.getMileage() / 1000)); |
| | | orderServerWarpper.setServedTime(Long.valueOf((new Date().getTime() - orderCrossCity.getStartServiceTime().getTime()) / 60000).intValue() + ""); |
| | | orderServerWarpper.setLaveMileage(d); |
| | | orderServerWarpper.setLaveTime(t); |
| | | } |
| | | |
| | | return orderServerWarpper; |
| | | return new OrderServerWarpper(); |
| | | } |
| | | |
| | | |
| | |
| | | OrderPrivateCarServiceImpl.orderIds.add(orderPrivateCar.getId());//添加记录,防止调用接口重复提醒无人接单 |
| | | OpenCity openCity = openCityService.openCity1(orderPrivateCar.getStartLon().toString(), orderPrivateCar.getStartLat().toString()); |
| | | List<PushOrder> querys = pushOrderService.querys(null, 1, openCity.getId());//获取需要推送的次数 |
| | | for (int i = 1; i <= querys.size() + 5; i++) { |
| | | for (int i = 1; i <= querys.size() + 15; i++) { |
| | | //订单被抢后的处理 |
| | | Integer state = orderPrivateCarMapper.selectById(orderId).getState(); |
| | | if (state != 1) { |
| | |
| | | |
| | | //所有推送完后的处理 |
| | | Boolean b = pushEndMap.get(orderPrivateCar.getCrossCityOrderId()); |
| | | if (i == querys.size() + 5 && state == 1 && (null != b && !b.booleanValue())) { |
| | | if (i == querys.size() + 15 && state == 1 && (null != b && !b.booleanValue())) { |
| | | pushUtil.pushEndPush(1, orderPrivateCar.getUserId(), orderPrivateCar.getId(), 1); |
| | | OrderPrivateCarServiceImpl.orderIds.remove(orderPrivateCar.getId()); |
| | | pushEndMap.put(orderPrivateCar.getCrossCityOrderId(), Boolean.TRUE);//推送后添加标识 |
| | |
| | | OrderTaxiServiceImpl.orderIds.add(orderTaxi.getId());//添加记录,防止调用接口重复提醒无人接单 |
| | | OpenCity openCity = openCityService.openCity1(orderTaxi.getStartLon().toString(), orderTaxi.getStartLat().toString()); |
| | | List<PushOrder> querys = pushOrderService.querys(null, 2, openCity.getId());//获取需要推送的次数 |
| | | for (int i = 1; i <= querys.size() + 5; i++) { |
| | | for (int i = 1; i <= querys.size() + 15; i++) { |
| | | //处理订单被抢 |
| | | Integer state = orderTaxiMapper.selectById(orderId).getState(); |
| | | if (state != 1) { |
| | |
| | | |
| | | //所有推送完后的处理 |
| | | Boolean b = pushEndMap.get(orderTaxi.getCrossCityOrderId()); |
| | | if (i == querys.size() + 5 && state == 1 && (null != b && !b.booleanValue())) { |
| | | if (i == querys.size() + 15 && state == 1 && (null != b && !b.booleanValue())) { |
| | | pushUtil.pushEndPush(1, orderTaxi.getUserId(), orderTaxi.getId(), 2); |
| | | OrderTaxiServiceImpl.orderIds.remove(orderTaxi.getId()); |
| | | pushEndMap.put(orderTaxi.getCrossCityOrderId(), Boolean.TRUE);//推送后添加标识 |
| | |
| | | } |
| | | orderCrossCity.setAbnormalIntro(abnormalIntro); |
| | | orderCrossCity.setAbnormalImg(abnormalImg); |
| | | orderCrossCity.setAbnormal(1); |
| | | orderCrossCity.setAbnormal(2); |
| | | this.baseMapper.updateById(orderCrossCity); |
| | | } |
| | | |
| | |
| | | BigDecimal bigDecimal = tDriverPromotionActivity.getCommissionRatio().divide(new BigDecimal(100), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(payMoney)).setScale(2, RoundingMode.HALF_UP); |
| | | orderCrossCity.setPromotionDriverId(userInfo.getBindDriverId()); |
| | | orderCrossCity.setPromotionMoney(bigDecimal); |
| | | orderCrossCity.setPromotionActivityId(tDriverPromotionActivity.getId()); |
| | | this.baseMapper.updateById(orderCrossCity); |
| | | } |
| | | } |
| | | |
| | | // 是否异常订单 |
| | | if (orderCrossCity.getResponsibilityType() !=null && orderCrossCity.getResponsibilityType() >2) { |
| | | TAbnormalPayOrder tAbnormalPayOrder = abnormalPayOrderMapper.selectList(new EntityWrapper<TAbnormalPayOrder>().eq("type", 3).eq("orderNum", orderCrossCity.getOrderNum())).stream().findFirst().orElse(null); |
| | | if (tAbnormalPayOrder != null) { |
| | | tAbnormalPayOrder.setPayStatus(2); |
| | | tAbnormalPayOrder.setPayTime(new Date()); |
| | | abnormalPayOrderMapper.updateById(tAbnormalPayOrder); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> queryMyTripList(Integer uid, Integer pageNum, Integer size) throws Exception { |
| | | pageNum = (pageNum - 1) * size; |
| | | List<Map<String, Object>> maps = orderCrossCityMapper.queryMyTripList(uid, pageNum, size); |
| | | for (Map<String, Object> map : maps) { |
| | | if (Integer.valueOf(String.valueOf(map.get("state"))) == 11) { |
| | | map.put("state", map.get("oldState")); |
| | | } |
| | | } |
| | | return maps; |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> queryMyTripListAll(Integer uid) throws Exception { |
| | | |
| | | List<Map<String, Object>> maps = orderCrossCityMapper.queryMyTripListAll(uid); |
| | | for (Map<String, Object> map : maps) { |
| | | if (Integer.valueOf(String.valueOf(map.get("state"))) == 11) { |
| | | map.put("state", map.get("oldState")); |
| | | } |
| | | } |
| | | return maps; |
| | | } |
| | | } |