Merge branch '2.0' of http://120.76.84.145:10101/gitblit/r/java/IgoTravel into 2.0
| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.mchange.util.FailSuppressedMessageLogger; |
| | | import com.stylefeng.guns.core.util.MD5Util; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.crossCity.model.OrderCrossCity; |
| | | import com.stylefeng.guns.modular.crossCity.server.IOrderCrossCityService; |
| | |
| | | |
| | | @Autowired |
| | | private IOrderCancelService orderCancelService; |
| | | |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | |
| | | |
| | |
| | | if(null == uid){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | String format = String.format("uid=%s&type=%s", uid, type); |
| | | String key = MD5Util.encrypt(format); |
| | | String value = redisUtil.getValue(key); |
| | | if(ToolUtil.isNotEmpty(value) && (System.currentTimeMillis() - Long.valueOf(value)) <= 1000){ |
| | | return ResultUtil.error(language == 1 ? "请勿重复操作" : language == 2 ? "Don't repeat the operation" : "Ne répétez pas l’opération"); |
| | | } |
| | | redisUtil.setStrValue(key, System.currentTimeMillis() + "", 5); |
| | | return driverService.work(uid, type, language); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.stylefeng.guns.core.util.MD5Util; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.smallLogistics.model.OrderLogistics; |
| | | import com.stylefeng.guns.modular.smallLogistics.model.OrderLogisticsSpread; |
| | |
| | | import com.stylefeng.guns.modular.system.model.OrderPosition; |
| | | import com.stylefeng.guns.modular.system.model.Reassign; |
| | | import com.stylefeng.guns.modular.system.service.IDriverService; |
| | | import com.stylefeng.guns.modular.system.service.IOrderPositionService; |
| | | import com.stylefeng.guns.modular.system.service.IOrderService; |
| | | import com.stylefeng.guns.modular.system.service.IReassignService; |
| | | import com.stylefeng.guns.modular.system.util.*; |
| | |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.InputStreamReader; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 订单相关控制器 |
| | |
| | | |
| | | @Resource |
| | | private FleetEngineUtil fleetEngineUtil; |
| | | |
| | | @Autowired |
| | | private IOrderPositionService orderPositionService; |
| | | |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | |
| | | |
| | |
| | | if(null == uid){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | String format = String.format("uid=%s&orderId=%s&orderType=%s&state=%s", uid, orderId, orderType, state); |
| | | String key = MD5Util.encrypt(format); |
| | | String value = redisUtil.getValue(key); |
| | | if(ToolUtil.isNotEmpty(value) && (System.currentTimeMillis() - Long.valueOf(value)) <= 1000){ |
| | | return ResultUtil.error(language == 1 ? "请勿重复操作" : language == 2 ? "Don't repeat the operation" : "Ne répétez pas l’opération"); |
| | | } |
| | | redisUtil.setStrValue(key, System.currentTimeMillis() + "", 5); |
| | | return orderService.process(orderId, orderType, state, uid, lon, lat, phone, pickUpCode, language); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/taxi/getTripInfo") |
| | | public ResultUtil getTripInfo(String tripId){ |
| | | return ResultUtil.success(fleetEngineUtil.getTrip(tripId)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 更新google订单状态 |
| | | * @param tripStatus |
| | | * @param tripId |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/taxi/editTripStatus") |
| | | public ResultUtil editTripStatus(String tripStatus, String tripId){ |
| | | boolean b = fleetEngineUtil.updateTrip(tripStatus, null, null, tripId, null, null, null, null); |
| | | if(b){ |
| | | return ResultUtil.success(); |
| | | } |
| | | return ResultUtil.error("更新失败"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 上传订单经纬度 |
| | | * @param orderPosition |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/api/order/saveOrderPosition") |
| | | public ResultUtil saveOrderPosition(OrderPosition orderPosition, HttpServletRequest request){ |
| | | try { |
| | | Integer uid = driverService.getUserIdFormRedis(request); |
| | | if(null == uid){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | if(null != orderPosition.getOrderId()){ |
| | | orderPosition.setDriverId(uid); |
| | | orderPosition.setInsertTime(new Date()); |
| | | orderPositionService.saveData(orderPosition); |
| | | } |
| | | redisUtil.setStrValue("DRIVER" + uid, orderPosition.getLon() + "," + orderPosition.getLat(), 300);//实时位置存入redis中 |
| | | return ResultUtil.success(); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/taxi/editGoogleTripStatus") |
| | | public ResultUtil editGoogleTripStatus(){ |
| | | List<OrderPrivateCar> privateCars = orderPrivateCarService.selectList(new EntityWrapper<OrderPrivateCar>().isNotNull("tripId")); |
| | | for (OrderPrivateCar privateCar : privateCars) { |
| | | Integer state = privateCar.getState(); |
| | | String tripId = privateCar.getTripId(); |
| | | String trip = fleetEngineUtil.getTrip(tripId); |
| | | if(ToolUtil.isNotEmpty(trip)){ |
| | | JSONObject jsonObject = JSON.parseObject(trip); |
| | | String tripStatus = jsonObject.getString("tripStatus"); |
| | | if(Arrays.asList(10, 12).contains(state) && !"CANCELED".equals(tripStatus)){ |
| | | //修改行程信息 |
| | | boolean updateTrip = fleetEngineUtil.updateTrip("CANCELED", null, null, tripId, null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip("CANCELED", null, null, tripId, null, null, null, null); |
| | | if(updateTrip){ |
| | | continue; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if(Arrays.asList(6, 7, 8, 9).contains(state) && !"COMPLETE".equals(tripStatus)){ |
| | | //修改行程信息 |
| | | boolean updateTrip = fleetEngineUtil.updateTrip("COMPLETE", null, null, tripId, null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip("COMPLETE", null, null, tripId, null, null, null, null); |
| | | if(updateTrip){ |
| | | continue; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | List<OrderLogistics> orderLogisticsList = orderLogisticsService.selectList(new EntityWrapper<OrderLogistics>().isNotNull("tripId")); |
| | | for (OrderLogistics orderLogistics : orderLogisticsList) { |
| | | Integer state = orderLogistics.getState(); |
| | | String tripId = orderLogistics.getTripId(); |
| | | String trip = fleetEngineUtil.getTrip(tripId); |
| | | if(ToolUtil.isNotEmpty(trip)){ |
| | | JSONObject jsonObject = JSON.parseObject(trip); |
| | | String tripStatus = jsonObject.getString("tripStatus"); |
| | | if(Arrays.asList(10, 12).contains(state) && !"CANCELED".equals(tripStatus)){ |
| | | //修改行程信息 |
| | | boolean updateTrip = fleetEngineUtil.updateTrip("CANCELED", null, null, tripId, null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip("CANCELED", null, null, tripId, null, null, null, null); |
| | | if(updateTrip){ |
| | | continue; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if(Arrays.asList(6, 7, 8, 9).contains(state) && !"COMPLETE".equals(tripStatus)){ |
| | | //修改行程信息 |
| | | boolean updateTrip = fleetEngineUtil.updateTrip("COMPLETE", null, null, tripId, null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip("COMPLETE", null, null, tripId, null, null, null, null); |
| | | if(updateTrip){ |
| | | continue; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return ResultUtil.success(); |
| | | } |
| | | } |
| | |
| | | package com.stylefeng.guns.modular.api; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.stylefeng.guns.core.util.MD5Util; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.system.model.SettlementRecord; |
| | | import com.stylefeng.guns.modular.system.service.IDriverService; |
| | | import com.stylefeng.guns.modular.system.service.ISettlementRecordService; |
| | | import com.stylefeng.guns.modular.system.util.RedisUtil; |
| | | import com.stylefeng.guns.modular.system.util.ResultUtil; |
| | | import com.stylefeng.guns.modular.system.util.Tingg.model.CallbackRequest; |
| | | import com.stylefeng.guns.modular.system.util.Tingg.model.CallbackResponse; |
| | |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | * @author zhibing.pu |
| | | * @Date 2023/8/17 9:39 |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("") |
| | | public class SettlementRecordController { |
| | |
| | | |
| | | @Autowired |
| | | private IDriverService driverService; |
| | | |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | |
| | | if(null == uid){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | String format = String.format("uid=%s&payType=%s&language=%s", uid, payType, language); |
| | | String key = MD5Util.encrypt(format); |
| | | String value = redisUtil.getValue(key); |
| | | if(ToolUtil.isNotEmpty(value) && (System.currentTimeMillis() - Long.valueOf(value)) <= 1000){ |
| | | return ResultUtil.error(language == 1 ? "请勿重复操作" : language == 2 ? "Don't repeat the operation" : "Ne répétez pas l’opération"); |
| | | } |
| | | redisUtil.setStrValue(key, System.currentTimeMillis() + "", 5); |
| | | return settlementRecordService.paymentSettlementAmount(uid, payType, bankCardId, language); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | @ResponseBody |
| | | @PostMapping("/base/settlementRecord/paymentSettlementAmountCallback") |
| | | public CallbackResponse paymentSettlementAmountCallback(@RequestBody CallbackRequest callbackRequest){ |
| | | log.info("结算支付回调结果:{}", JSON.toJSONString(callbackRequest)); |
| | | CallbackResponse callbackResponse = new CallbackResponse(); |
| | | try { |
| | | /** |
| | |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | log.info("结算支付回调结果处理结束:{}", JSON.toJSONString(callbackResponse)); |
| | | return callbackResponse; |
| | | } |
| | | } |
| | |
| | | if(ToolUtil.isNotEmpty(value) && (System.currentTimeMillis() - Long.valueOf(value)) <= 1000){ |
| | | return ResultUtil.error(language == 1 ? "请勿重复操作" : language == 2 ? "Don't repeat the operation" : "Ne répétez pas l’opération"); |
| | | } |
| | | redisUtil.setStrValue(key, System.currentTimeMillis() + "", 5); |
| | | return withdrawalService.withdrawal(money, uid, type, remark, language); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | driver.setState(3); |
| | | driverService.updateById(driver); |
| | | |
| | | //检查google车辆信息或者添加新的车辆信息 |
| | | Car car = carService.selectById(orderLogistics.getCarId()); |
| | | if(ToolUtil.isEmpty(car.getVehicleId())){ |
| | | car.setVehicleId(UUIDUtil.getRandomCode()); |
| | | carService.updateById(car); |
| | | } |
| | | String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId()); |
| | | if(ToolUtil.isEmpty(vehicles)){ |
| | | CarModel carModel = carModelMapper.selectById(car.getCarModelId()); |
| | | boolean createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!createVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(createVehicles){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | //修改google订单信息或者创建新的行程 |
| | | String trip = fleetEngineUtil.getTrip(orderLogistics.getTripId()); |
| | | if(ToolUtil.isEmpty(trip)){ |
| | | JSONObject createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderLogistics.getTripId(), |
| | | orderLogistics.getStartLat().toString(), orderLogistics.getStartLon().toString(), orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString()); |
| | | JSONObject error = createTrip.getJSONObject("error"); |
| | | if(null != error){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderLogistics.getTripId(), |
| | | orderLogistics.getStartLat().toString(), orderLogistics.getStartLon().toString(), orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString()); |
| | | error = createTrip.getJSONObject("error"); |
| | | String tripStatus = createTrip.getString("tripStatus"); |
| | | if(null == error && "NEW".equals(tripStatus)){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | }else{ |
| | | //开始修改行程数据 |
| | | boolean updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 超时用户取消不收费的提醒 |
| | | * 即时单:预估到达预约点时间 + 配置不收费的时间 > 当前时间 (只弹一次) |
| | |
| | | new OrderTimeOutJob().buildQuartzJob("3_" + orderLogistics.getId() + "_4", "ORDER_TIME_OUT", jobDataMap) |
| | | , orderLogistics.getEstimateArriveTime(), reminderRules.getCar() * 60000, -1); |
| | | } |
| | | |
| | | new Thread(()->{ |
| | | Car car = carService.selectById(orderLogistics.getCarId()); |
| | | if(!StringUtils.hasLength(car.getVehicleId())){ |
| | | car.setVehicleId(UUIDUtil.getRandomCode()); |
| | | carService.updateById(car); |
| | | } |
| | | String trip = fleetEngineUtil.getTrip(orderLogistics.getTripId()); |
| | | if(ToolUtil.isEmpty(trip)){ |
| | | String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId()); |
| | | if(ToolUtil.isEmpty(vehicles)){ |
| | | CarModel carModel = carModelMapper.selectById(car.getCarModelId()); |
| | | boolean createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!createVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(createVehicles){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | boolean createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderLogistics.getTripId(), |
| | | orderLogistics.getStartLat().toString(), orderLogistics.getStartLon().toString(), orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString()); |
| | | if(!createTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderLogistics.getTripId(), |
| | | orderLogistics.getStartLat().toString(), orderLogistics.getStartLon().toString(), orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString()); |
| | | if(createTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | }else{ |
| | | //开始修改行程数据 |
| | | boolean updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }).start(); |
| | | |
| | | |
| | | //推送相关代码------------------start---------------- |
| | | new Thread(new Runnable() { |
| | |
| | | orderLogistics.setGetoffTime(new Date()); |
| | | orderLogistics.setEndServiceTime(new Date()); |
| | | orderLogistics.setState(6); |
| | | tripStatus = "COMPLETE"; |
| | | tripStatus = ""; |
| | | break; |
| | | } |
| | | this.updateById(orderLogistics); |
| | | |
| | | Driver driver = driverService.selectById(orderLogistics.getDriverId()); |
| | | String finalTripStatus = tripStatus; |
| | | new Thread(()->{ |
| | | Car car = carMapper.selectById(driver.getCarId()); |
| | | //修改行程数据 |
| | | boolean updateTrip = fleetEngineUtil.updateTrip(finalTripStatus, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null); |
| | | //修改行程数据 |
| | | if(ToolUtil.isNotEmpty(tripStatus)){ |
| | | boolean updateTrip = fleetEngineUtil.updateTrip(tripStatus, null, null, orderLogistics.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip(finalTripStatus, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null); |
| | | updateTrip = fleetEngineUtil.updateTrip(tripStatus, null, null, orderLogistics.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | }).start(); |
| | | } |
| | | |
| | | // TODO: 2020/6/5 推送状态 |
| | | new Thread(new Runnable() { |
| | |
| | | @Override |
| | | public void updateEndAddress(Integer orderId, Integer status) { |
| | | OrderLogistics orderLogistics = this.selectById(orderId); |
| | | if(ToolUtil.isEmpty(orderLogistics.getDestinationLon())){ |
| | | return; |
| | | } |
| | | if(2 == status){ |
| | | orderLogistics.setEndLon(Double.valueOf(orderLogistics.getDestinationLon())); |
| | | orderLogistics.setEndLat(Double.valueOf(orderLogistics.getDestinationLat())); |
| | |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | orderLogistics.setDestinationLon(""); |
| | | orderLogistics.setDestination(""); |
| | | orderLogistics.setDestinationLat(""); |
| | | this.updateById(orderLogistics); |
| | | pushUtil.pushModifyAddress(1, orderLogistics.getUserId(), orderId, 4, status); |
| | | } |
| | |
| | | orderLogistics.setBindId(""); |
| | | } |
| | | this.updateById(orderLogistics); |
| | | //修改行程数据 |
| | | boolean updateTrip = fleetEngineUtil.updateTrip("COMPLETE", null, null, orderLogistics.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip("COMPLETE", null, null, orderLogistics.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | //上报行程 |
| | | boolean reportBillableEvent = fleetEngineUtil.reportBillableEvent(orderLogistics.getTripId()); |
| | | if(!reportBillableEvent){ |
| | | for (int i = 0; i < 5; i++) { |
| | | reportBillableEvent = fleetEngineUtil.reportBillableEvent(orderLogistics.getTripId()); |
| | | if(reportBillableEvent){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | pushUtil.removeTask(orderId, 4);//删除定时任务,结束推送数据 |
| | |
| | | public void run() { |
| | | pushUtil.pushOrderState(1, finalOrderTaxi.getUserId(), finalOrderTaxi.getId(), 4, finalOrderTaxi.getState(), 0, ""); |
| | | pushUtil.pushOrderState(2, finalOrderTaxi.getDriverId(), finalOrderTaxi.getId(), 4, finalOrderTaxi.getState(), 0, ""); |
| | | } |
| | | }).start(); |
| | | |
| | | //上报google |
| | | OrderLogistics finalOrderLogistics = orderLogistics; |
| | | new Thread(()->{ |
| | | log.warn("行程结束:{} {}", System.currentTimeMillis(), finalOrderLogistics.getTripId()); |
| | | boolean reportBillableEvent = fleetEngineUtil.reportBillableEvent(finalOrderLogistics.getTripId()); |
| | | if(!reportBillableEvent){ |
| | | for (int i = 0; i < 5; i++) { |
| | | reportBillableEvent = fleetEngineUtil.reportBillableEvent(finalOrderLogistics.getTripId()); |
| | | if(reportBillableEvent){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | }).start(); |
| | | return ResultUtil.success(); |
| | |
| | | Map<String, Double> distance = GeodesyUtil.getDistance(now, old); |
| | | if(null != distance){ |
| | | Double distance1 = distance.get("WGS84"); |
| | | if(distance1 > 50 && Arrays.asList(3, 4).contains(orderLogistics.getState())){//大于50米表示在移动 |
| | | if(distance1 > 30 && Arrays.asList(3, 4).contains(orderLogistics.getState())){//大于50米表示在移动 |
| | | orderLogistics.setToStartPointMileage(new BigDecimal(orderLogistics.getToStartPointMileage()).add(new BigDecimal(distance1)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | this.updateById(orderLogistics); |
| | | return true; |
| | | } |
| | | if(distance1 > 50 && orderLogistics.getState()==5){//大于50米表示在移动 |
| | | if(distance1 > 30 && orderLogistics.getState()==5){//大于50米表示在移动 |
| | | orderLogistics.setMileage(new BigDecimal(orderLogistics.getMileage()).add(new BigDecimal(distance1)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | this.updateById(orderLogistics); |
| | | return true; |
| | |
| | | driverService.updateById(driver); |
| | | } |
| | | |
| | | //检查google车辆信息或者添加新的车辆信息 |
| | | Car car = carService.selectById(orderPrivateCar.getCarId()); |
| | | if(ToolUtil.isEmpty(car.getVehicleId())){ |
| | | car.setVehicleId(UUIDUtil.getRandomCode()); |
| | | carService.updateById(car); |
| | | } |
| | | String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId()); |
| | | if(ToolUtil.isEmpty(vehicles)){ |
| | | CarModel carModel = carModelMapper.selectById(car.getCarModelId()); |
| | | boolean createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!createVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(createVehicles){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | //修改google订单信息或者创建新的行程 |
| | | String trip = fleetEngineUtil.getTrip(orderPrivateCar.getTripId()); |
| | | if(ToolUtil.isEmpty(trip)){ |
| | | JSONObject createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderPrivateCar.getTripId(), |
| | | orderPrivateCar.getStartLat().toString(), orderPrivateCar.getStartLon().toString(), orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString()); |
| | | JSONObject error = createTrip.getJSONObject("error"); |
| | | if(null != error){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderPrivateCar.getTripId(), |
| | | orderPrivateCar.getStartLat().toString(), orderPrivateCar.getStartLon().toString(), orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString()); |
| | | error = createTrip.getJSONObject("error"); |
| | | String tripStatus = createTrip.getString("tripStatus"); |
| | | if(null == error && "NEW".equals(tripStatus)){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | }else{ |
| | | //开始修改行程数据 |
| | | boolean updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 超时用户取消不收费的提醒 |
| | |
| | | , orderPrivateCar.getTravelTime(), reminderRules.getCar() * 60000, -1); |
| | | } |
| | | } |
| | | |
| | | new Thread(()->{ |
| | | try { |
| | | Car car = carService.selectById(orderPrivateCar.getCarId()); |
| | | if(!StringUtils.hasLength(car.getVehicleId())){ |
| | | car.setVehicleId(UUIDUtil.getRandomCode()); |
| | | carService.updateById(car); |
| | | } |
| | | String trip = fleetEngineUtil.getTrip(orderPrivateCar.getTripId()); |
| | | if(ToolUtil.isEmpty(trip)){ |
| | | String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId()); |
| | | if(ToolUtil.isEmpty(vehicles)){ |
| | | CarModel carModel = carModelMapper.selectById(car.getCarModelId()); |
| | | boolean createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!createVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(createVehicles){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | boolean createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderPrivateCar.getTripId(), |
| | | orderPrivateCar.getStartLat().toString(), orderPrivateCar.getStartLon().toString(), orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString()); |
| | | if(!createTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderPrivateCar.getTripId(), |
| | | orderPrivateCar.getStartLat().toString(), orderPrivateCar.getStartLon().toString(), orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString()); |
| | | if(createTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //开始修改行程数据 |
| | | boolean updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | }).start(); |
| | | |
| | | |
| | | //推送相关代码------------------start---------------- |
| | | new Thread(new Runnable() { |
| | |
| | | orderPrivateCar.setGetoffAddress(address); |
| | | orderPrivateCar.setGetoffTime(new Date()); |
| | | orderPrivateCar.setEndServiceTime(new Date()); |
| | | tripStatus = "COMPLETE"; |
| | | tripStatus = ""; |
| | | switch (language){ |
| | | case 1: |
| | | audioUrl = "https://igo.i-go.group/files/audio/system/ReachDestination-CN.mp3"; |
| | |
| | | } |
| | | this.updateById(orderPrivateCar); |
| | | |
| | | Driver driver = driverService.selectById(orderPrivateCar.getDriverId()); |
| | | String finalTripStatus = tripStatus; |
| | | new Thread(()->{ |
| | | //修改行程数据 |
| | | boolean updateTrip = fleetEngineUtil.updateTrip(finalTripStatus, null, 1, orderPrivateCar.getTripId(), null, null, null, null); |
| | | //修改行程数据 |
| | | if(ToolUtil.isNotEmpty(tripStatus)){ |
| | | boolean updateTrip = fleetEngineUtil.updateTrip(tripStatus, null, null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip(finalTripStatus, null, 1, orderPrivateCar.getTripId(), null, null, null, null); |
| | | updateTrip = fleetEngineUtil.updateTrip(tripStatus, null, null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | }).start(); |
| | | } |
| | | |
| | | |
| | | // TODO: 2020/6/5 推送状态 |
| | | OrderPrivateCar finalOrderPrivateCar = orderPrivateCar; |
| | |
| | | if(orderPrivateCar.getArriveTime()==null){ |
| | | orderPrivateCar.setArriveTime(orderPrivateCar.getStartServiceTime()); |
| | | } |
| | | |
| | | //获取google trip_info获取轨迹线路,重新存储轨迹和计算行驶距离和时间 |
| | | |
| | | |
| | | orderPrivateCar = this.setMoney(orderPrivateCar, 0D, 0D);//计算费用 |
| | | orderPrivateCar.setPayManner(type); |
| | |
| | | orderPrivateCar.setBindId(""); |
| | | } |
| | | this.updateById(orderPrivateCar); |
| | | |
| | | |
| | | |
| | | //修改行程数据 |
| | | boolean updateTrip = fleetEngineUtil.updateTrip("COMPLETE", null, null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip("COMPLETE", null, null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //上报行程 |
| | | boolean reportBillableEvent = fleetEngineUtil.reportBillableEvent(orderPrivateCar.getTripId()); |
| | | if(!reportBillableEvent){ |
| | | for (int i = 0; i < 5; i++) { |
| | | reportBillableEvent = fleetEngineUtil.reportBillableEvent(orderPrivateCar.getTripId()); |
| | | if(reportBillableEvent){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | pushUtil.removeTask(orderId, 1);//删除定时任务,结束推送数据 |
| | | UserInfo userInfo = userInfoMapper.selectById(orderPrivateCar.getUserId()); |
| | | Integer language1 = userInfo.getLanguage(); |
| | |
| | | } |
| | | }).start(); |
| | | |
| | | OrderPrivateCar finalOrderPrivateCar = orderPrivateCar; |
| | | new Thread(()->{ |
| | | //上报google |
| | | log.warn("行程结束:{} {}", System.currentTimeMillis(), finalOrderPrivateCar.getTripId()); |
| | | boolean reportBillableEvent = fleetEngineUtil.reportBillableEvent(finalOrderPrivateCar.getTripId()); |
| | | if(!reportBillableEvent){ |
| | | for (int i = 0; i < 5; i++) { |
| | | reportBillableEvent = fleetEngineUtil.reportBillableEvent(finalOrderPrivateCar.getTripId()); |
| | | if(reportBillableEvent){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | }).start(); |
| | | |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | |
| | | Map<String, Double> distance = GeodesyUtil.getDistance(now, old); |
| | | if(null != distance){ |
| | | Double distance1 = distance.get("WGS84"); |
| | | if(distance1 > 50 && Arrays.asList(3, 4).contains(orderPrivateCar.getState())){//大于50米表示在移动 |
| | | if(distance1 > 30 && Arrays.asList(3, 4).contains(orderPrivateCar.getState())){//大于50米表示在移动 |
| | | orderPrivateCar.setToStartPointMileage(new BigDecimal(orderPrivateCar.getToStartPointMileage()).add(new BigDecimal(distance1)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | this.updateById(orderPrivateCar); |
| | | return true; |
| | | } |
| | | if(distance1 > 50 && orderPrivateCar.getState()==5){//大于50米表示在移动 |
| | | if(distance1 > 30 && orderPrivateCar.getState()==5){//大于50米表示在移动 |
| | | orderPrivateCar.setMileage(new BigDecimal(orderPrivateCar.getMileage()).add(new BigDecimal(distance1)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | this.updateById(orderPrivateCar); |
| | | return true; |
| | |
| | | @Override |
| | | public void updateEndAddress(Integer orderId, Integer status) { |
| | | OrderPrivateCar orderPrivateCar = this.selectById(orderId); |
| | | if(ToolUtil.isEmpty(orderPrivateCar.getDestinationLon())){ |
| | | return; |
| | | } |
| | | if(2 == status){ |
| | | orderPrivateCar.setEndLon(Double.valueOf(orderPrivateCar.getDestinationLon())); |
| | | orderPrivateCar.setEndLat(Double.valueOf(orderPrivateCar.getDestinationLat())); |
| | |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | orderPrivateCar.setDestinationLon(""); |
| | | orderPrivateCar.setDestination(""); |
| | | orderPrivateCar.setDestinationLat(""); |
| | | this.updateById(orderPrivateCar); |
| | | pushUtil.pushModifyAddress(1, orderPrivateCar.getUserId(), orderId, 1, status); |
| | | } |
| | |
| | | Company query1(@Param("cityIds") List<Integer> cityIds); |
| | | |
| | | |
| | | List<Company> queryList(@Param("city") String[] city, @Param("type") Integer type); |
| | | List<Company> queryList(@Param("ids") List<Integer> ids, @Param("type") Integer type); |
| | | |
| | | |
| | | |
| | |
| | | upload as upload, |
| | | insertTime as insertTime |
| | | from t_company where flag != 3 and state = 0 and id in ( |
| | | select companyId from t_company_city where state = 1 |
| | | <if test="null != city"> |
| | | and cityId in (select id from t_city where englishName in |
| | | <foreach collection="city" item="item" index="index" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> |
| | | ) |
| | | </if> |
| | | <foreach collection="ids" item="item" index="index" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> |
| | | ) |
| | | <if test="null != type"> |
| | | and type = #{type} |
| | |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | |
| | | import java.util.Date; |
| | | |
| | |
| | | * 订单类型(1=专车,2=出租车,3=城际,4=小件物流-同城,5=小件物流-跨城,6=包车) |
| | | */ |
| | | @TableField("orderType") |
| | | @ApiModelProperty(value = "订单类型(1=专车,2=出租车,3=城际,4=小件物流-同城,5=小件物流-跨城,6=包车)", required = true) |
| | | private Integer orderType; |
| | | /** |
| | | * 订单id |
| | | */ |
| | | @TableField("orderId") |
| | | @ApiModelProperty(value = "订单id", required = true) |
| | | private Integer orderId; |
| | | /** |
| | | * 司机id |
| | |
| | | * 经度 |
| | | */ |
| | | @TableField("lon") |
| | | @ApiModelProperty(value = "经度", required = true) |
| | | private String lon; |
| | | /** |
| | | * 纬度 |
| | | */ |
| | | @TableField("lat") |
| | | @ApiModelProperty(value = "纬度", required = true) |
| | | private String lat; |
| | | /** |
| | | * 方向角 |
| | | */ |
| | | @TableField("directionAngle") |
| | | @ApiModelProperty(value = "方向角", required = false) |
| | | private String directionAngle; |
| | | /** |
| | | * 海拔 |
| | | */ |
| | | @TableField("altitude") |
| | | @ApiModelProperty(value = "海拔", required = false) |
| | | private String altitude; |
| | | /** |
| | | * 添加时间 |
| | |
| | | * @throws Exception |
| | | */ |
| | | ResultUtil payOrder(Integer uid, Integer orderId, Integer orderType, Integer payType, Integer bankCardId, Integer language) throws Exception; |
| | | |
| | | |
| | | /** |
| | | * 使用google获取司机的最新位置信息 |
| | | */ |
| | | void getDriverNowPosition(); |
| | | } |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | |
| | | @Override |
| | | public Company query(String[] city) throws Exception { |
| | | List<Company> query = companyMapper.queryList(city, 3); |
| | | List<City> cities1 = cityService.selectList(null); |
| | | List<Integer> collect = new ArrayList<>(); |
| | | for (City city1 : cities1) { |
| | | String chineseName = city1.getChineseName(); |
| | | String englishName = city1.getEnglishName(); |
| | | String frenchName = city1.getFrenchName(); |
| | | for (String s : city) { |
| | | if(s.indexOf(chineseName) != -1 || s.indexOf(englishName) != -1 || s.indexOf(frenchName) != -1){ |
| | | collect.add(city1.getId()); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | List<Company> query = companyMapper.queryList(collect, 3); |
| | | if(query.size() == 0){ |
| | | query = companyMapper.queryList(city, 2); |
| | | query = companyMapper.queryList(collect, 2); |
| | | } |
| | | if(query.size() == 0){ |
| | | query = companyMapper.queryList(city, 1); |
| | | query = companyMapper.queryList(collect, 1); |
| | | } |
| | | if(query.size() > 0){ |
| | | return query.get(0); |
| | |
| | | |
| | | |
| | | public Company query1(String[] city) throws Exception { |
| | | List<City> cities = cityService.selectList(new EntityWrapper<City>().in("chineseName", Arrays.asList(city)).or() |
| | | .in("englishName", Arrays.asList(city)).or().in("frenchName", Arrays.asList(city))); |
| | | List<Integer> collect = cities.stream().map(City::getId).collect(Collectors.toList()); |
| | | List<City> cities1 = cityService.selectList(null); |
| | | List<Integer> collect = new ArrayList<>(); |
| | | for (City city1 : cities1) { |
| | | String chineseName = city1.getChineseName(); |
| | | String englishName = city1.getEnglishName(); |
| | | String frenchName = city1.getFrenchName(); |
| | | for (String s : city) { |
| | | if(s.indexOf(chineseName) != -1 || s.indexOf(englishName) != -1 || s.indexOf(frenchName) != -1){ |
| | | collect.add(city1.getId()); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | if(collect.size() == 0){ |
| | | return null; |
| | | } |
| | |
| | | if(!file.exists()){ |
| | | file.getParentFile().mkdirs(); |
| | | file.createNewFile(); |
| | | file.setReadable(true, false);//设置读取权限 |
| | | file.setWritable(true, false);//设置写入权限 |
| | | } |
| | | //写入相应的文件 |
| | | orderPositions.add(orderPosition); |
| | | System.err.println("存储新数据:" + JSON.toJSONString(orderPositions)); |
| | | // System.err.println("存储新数据:" + JSON.toJSONString(orderPositions)); |
| | | FileUtil.writeUtf8String(JSON.toJSONString(orderPositions), file); |
| | | } |
| | | } |
| | |
| | | import com.stylefeng.guns.modular.system.service.*; |
| | | import com.stylefeng.guns.modular.system.util.*; |
| | | import com.stylefeng.guns.modular.system.util.GoogleMap.DistancematrixVo; |
| | | import com.stylefeng.guns.modular.system.util.GoogleMap.FleetEngineUtil; |
| | | 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.Tingg.TinggPayUtil; |
| | |
| | | |
| | | @Resource |
| | | private IBalanceUsageRecordService balanceUsageRecordService; |
| | | |
| | | @Resource |
| | | private FleetEngineUtil fleetEngineUtil; |
| | | |
| | | @Autowired |
| | | private IOrderPositionService orderPositionService; |
| | | |
| | | |
| | | |
| | |
| | | } |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void getDriverNowPosition() { |
| | | for (OrderPrivateCar orderPrivateCar : orderPrivateCarService.selectList(new EntityWrapper<OrderPrivateCar>().eq("state", 5))) { |
| | | String trackId = orderPrivateCar.getTrackId(); |
| | | if(ToolUtil.isNotEmpty(trackId)){ |
| | | String trip = fleetEngineUtil.getTrip(trackId); |
| | | JSONObject lastLocation = JSON.parseObject(trip).getJSONObject("lastLocation"); |
| | | JSONObject location = lastLocation.getJSONObject("location"); |
| | | Double latitude = location.getDouble("latitude"); |
| | | Double longitude = location.getDouble("longitude"); |
| | | OrderPosition orderPosition = new OrderPosition(); |
| | | orderPosition.setOrderId(orderPrivateCar.getId()); |
| | | orderPosition.setOrderType(1); |
| | | orderPosition.setDriverId(orderPrivateCar.getDriverId()); |
| | | orderPosition.setLat(latitude.toString()); |
| | | orderPosition.setLon(longitude.toString()); |
| | | orderPosition.setInsertTime(new Date()); |
| | | try { |
| | | orderPositionService.saveData(orderPosition); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | List<OrderLogistics> orderLogisticsList = orderLogisticsService.selectList(new EntityWrapper<OrderLogistics>().eq("state", 5)); |
| | | for (OrderLogistics orderLogistics : orderLogisticsList) { |
| | | String trackId = orderLogistics.getTrackId(); |
| | | if(ToolUtil.isNotEmpty(trackId)){ |
| | | String trip = fleetEngineUtil.getTrip(trackId); |
| | | JSONObject lastLocation = JSON.parseObject(trip).getJSONObject("lastLocation"); |
| | | JSONObject location = lastLocation.getJSONObject("location"); |
| | | Double latitude = location.getDouble("latitude"); |
| | | Double longitude = location.getDouble("longitude"); |
| | | OrderPosition orderPosition = new OrderPosition(); |
| | | orderPosition.setOrderId(orderLogistics.getId()); |
| | | orderPosition.setOrderType(1); |
| | | orderPosition.setDriverId(orderLogistics.getDriverId()); |
| | | orderPosition.setLat(latitude.toString()); |
| | | orderPosition.setLon(longitude.toString()); |
| | | orderPosition.setInsertTime(new Date()); |
| | | try { |
| | | orderPositionService.saveData(orderPosition); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | import com.stylefeng.guns.modular.system.dao.PhoneMapper; |
| | | import com.stylefeng.guns.modular.system.model.Company; |
| | | import com.stylefeng.guns.modular.system.model.Phone; |
| | | import com.stylefeng.guns.modular.system.service.ICompanyCityService; |
| | | import com.stylefeng.guns.modular.system.service.ICompanyService; |
| | | import com.stylefeng.guns.modular.system.service.IPhoneService; |
| | | import com.stylefeng.guns.modular.system.util.GoogleMap.AddressComponentsVo; |
| | |
| | | |
| | | @Resource |
| | | private PhoneMapper phoneMapper; |
| | | |
| | | @Resource |
| | | private CompanyMapper companyMapper; |
| | | |
| | | @Autowired |
| | | private ICompanyCityService companyCityService; |
| | | |
| | | /** |
| | | * 获取所有系统电话 |
| | |
| | | //平台电话 |
| | | Phone query = phoneMapper.query(2, 1, null, null, null); |
| | | map.put("platform", null != query ? query.getPhone() : ""); |
| | | |
| | | List<Company> companies = companyMapper.queryList(city, null); |
| | | if(companies.size() > 0){ |
| | | Integer id = companies.get(0).getId(); |
| | | |
| | | Company companies = companyCityService.query(city); |
| | | if(null != companies){ |
| | | Integer id = companies.getId(); |
| | | Phone phone = this.selectOne(new EntityWrapper<Phone>().eq("type", 2).eq("companyId", id)); |
| | | map.put("company", phone.getPhone()); |
| | | phone = this.selectOne(new EntityWrapper<Phone>().eq("type", 3).eq("companyId", id)); |
| | |
| | | package com.stylefeng.guns.modular.system.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | |
| | | |
| | | driver.setState(2); |
| | | driverService.updateById(driver); |
| | | |
| | | //检查google车辆信息或者添加新的车辆信息 |
| | | Car car = carService.selectById(orderPrivateCar.getCarId()); |
| | | if(ToolUtil.isEmpty(car.getVehicleId())){ |
| | | car.setVehicleId(UUIDUtil.getRandomCode()); |
| | | carService.updateById(car); |
| | | } |
| | | String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId()); |
| | | if(ToolUtil.isEmpty(vehicles)){ |
| | | CarModel carModel = carModelMapper.selectById(car.getCarModelId()); |
| | | boolean createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!createVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(createVehicles){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | //修改google订单信息或者创建新的行程 |
| | | String trip = fleetEngineUtil.getTrip(orderPrivateCar.getTripId()); |
| | | if(ToolUtil.isEmpty(trip)){ |
| | | JSONObject createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderPrivateCar.getTripId(), |
| | | orderPrivateCar.getStartLat().toString(), orderPrivateCar.getStartLon().toString(), orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString()); |
| | | JSONObject error = createTrip.getJSONObject("error"); |
| | | if(null != error){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderPrivateCar.getTripId(), |
| | | orderPrivateCar.getStartLat().toString(), orderPrivateCar.getStartLon().toString(), orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString()); |
| | | error = createTrip.getJSONObject("error"); |
| | | String tripStatus = createTrip.getString("tripStatus"); |
| | | if(null == error && "NEW".equals(tripStatus)){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | }else{ |
| | | //开始修改行程数据 |
| | | boolean updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | //删除定时任务 |
| | | QuartzUtil.deleteQuartzTask("1_" + orderPrivateCar.getId() + "_1","ORDER_TIME_OUT"); |
| | |
| | | } |
| | | } |
| | | |
| | | new Thread(()->{ |
| | | try { |
| | | Car car = carService.selectById(orderPrivateCar.getCarId()); |
| | | if(!StringUtils.hasLength(car.getVehicleId())){ |
| | | car.setVehicleId(UUIDUtil.getRandomCode()); |
| | | carService.updateById(car); |
| | | } |
| | | String trip = fleetEngineUtil.getTrip(orderPrivateCar.getTripId()); |
| | | if(ToolUtil.isEmpty(trip)){ |
| | | String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId()); |
| | | if(ToolUtil.isEmpty(vehicles)){ |
| | | CarModel carModel = carModelMapper.selectById(car.getCarModelId()); |
| | | boolean createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!createVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(createVehicles){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | boolean createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderPrivateCar.getTripId(), |
| | | orderPrivateCar.getStartLat().toString(), orderPrivateCar.getStartLon().toString(), orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString()); |
| | | if(!createTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderPrivateCar.getTripId(), |
| | | orderPrivateCar.getStartLat().toString(), orderPrivateCar.getStartLon().toString(), orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString()); |
| | | if(createTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //开始修改行程数据 |
| | | boolean updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | }).start(); |
| | | |
| | | //推送相关代码------------------start---------------- |
| | | String finalAudioUrl = audioUrl; |
| | | new Thread(new Runnable() { |
| | |
| | | |
| | | driver.setState(2); |
| | | driverService.updateById(driver); |
| | | |
| | | //检查google车辆信息或者添加新的车辆信息 |
| | | Car car = carService.selectById(orderLogistics.getCarId()); |
| | | if(ToolUtil.isEmpty(car.getVehicleId())){ |
| | | car.setVehicleId(UUIDUtil.getRandomCode()); |
| | | carService.updateById(car); |
| | | } |
| | | String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId()); |
| | | if(ToolUtil.isEmpty(vehicles)){ |
| | | CarModel carModel = carModelMapper.selectById(car.getCarModelId()); |
| | | boolean createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!createVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(createVehicles){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | //修改google订单信息或者创建新的行程 |
| | | String trip = fleetEngineUtil.getTrip(orderLogistics.getTripId()); |
| | | if(ToolUtil.isEmpty(trip)){ |
| | | JSONObject createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderLogistics.getTripId(), |
| | | orderLogistics.getStartLat().toString(), orderLogistics.getStartLon().toString(), orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString()); |
| | | JSONObject error = createTrip.getJSONObject("error"); |
| | | if(null != error){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderLogistics.getTripId(), |
| | | orderLogistics.getStartLat().toString(), orderLogistics.getStartLon().toString(), orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString()); |
| | | error = createTrip.getJSONObject("error"); |
| | | String tripStatus = createTrip.getString("tripStatus"); |
| | | if(null == error && "NEW".equals(tripStatus)){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | }else{ |
| | | //开始修改行程数据 |
| | | boolean updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | //删除定时任务 |
| | | QuartzUtil.deleteQuartzTask("1_" + orderLogistics.getId() + "_4","ORDER_TIME_OUT"); |
| | |
| | | new OrderTimeOutJob().buildQuartzJob("3_" + orderLogistics.getId() + "_4", "ORDER_TIME_OUT", jobDataMap) |
| | | , orderLogistics.getEstimateArriveTime(), reminderRules.getCar() * 60000, -1); |
| | | } |
| | | |
| | | new Thread(()->{ |
| | | try { |
| | | Car car = carService.selectById(orderLogistics.getCarId()); |
| | | if(!StringUtils.hasLength(car.getVehicleId())){ |
| | | car.setVehicleId(UUIDUtil.getRandomCode()); |
| | | carService.updateById(car); |
| | | } |
| | | String trip = fleetEngineUtil.getTrip(orderLogistics.getTripId()); |
| | | if(ToolUtil.isEmpty(trip)){ |
| | | String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId()); |
| | | if(ToolUtil.isEmpty(vehicles)){ |
| | | CarModel carModel = carModelMapper.selectById(car.getCarModelId()); |
| | | boolean createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!createVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(createVehicles){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | boolean createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderLogistics.getTripId(), |
| | | orderLogistics.getStartLat().toString(), orderLogistics.getStartLon().toString(), orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString()); |
| | | if(!createTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderLogistics.getTripId(), |
| | | orderLogistics.getStartLat().toString(), orderLogistics.getStartLon().toString(), orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString()); |
| | | if(createTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | }else{ |
| | | //开始修改行程数据 |
| | | boolean updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | }).start(); |
| | | |
| | | |
| | | //推送相关代码------------------start---------------- |
| | | String finalAudioUrl = audioUrl; |
| | |
| | | |
| | | public static void main(String[] ages){ |
| | | GeodesyUtil geodesyUtil = new GeodesyUtil(); |
| | | geodesyUtil.getDistance("115.481028,39.989643", "114.465302,40.004717"); |
| | | geodesyUtil.getDistance("-0.2621451,5.6025811", "-0.2592737227678299,5.6036623712816533"); |
| | | } |
| | | } |
| | |
| | | * @param end_lng 终点经度 |
| | | * @return |
| | | */ |
| | | public boolean createTrip(String vehicleId, Integer numberOfPassengers, String tripId, String start_lat, String start_lng, String end_lat, String end_lng) { |
| | | public JSONObject createTrip(String vehicleId, Integer numberOfPassengers, String tripId, String start_lat, String start_lng, String end_lat, String end_lng) { |
| | | String url = "https://fleetengine.googleapis.com/v1/providers/" + provider + "/trips?tripId=" + tripId; |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | | Map<String, String> headers = new HashMap<>(); |
| | |
| | | end_point.put("longitude", end_lng); |
| | | dropoffPoint.put("point", end_point); |
| | | body.put("dropoffPoint", dropoffPoint); |
| | | logger.info("创建行程请求:{}", body.toJSONString()); |
| | | logger.info("创建行程请求:{} {}", tripId, body.toJSONString()); |
| | | HttpRequest request = post.body(body.toJSONString()); |
| | | HttpResponse response = request.execute(); |
| | | logger.info("创建行程结果:{}", response.body()); |
| | |
| | | } |
| | | } |
| | | logger.error("创建行程异常: tripId={} body={}", tripId, response.body()); |
| | | return false; |
| | | } |
| | | /** |
| | | * 返回结果 |
| | |
| | | * "currentRouteSegmentTrafficVersion": "2024-05-27T02:05:37.941167Z" |
| | | * } |
| | | */ |
| | | return true; |
| | | return jsonObject; |
| | | } |
| | | |
| | | |
| | |
| | | dropoffPoint.put("point", end_point); |
| | | body.put("dropoffPoint", dropoffPoint); |
| | | } |
| | | logger.info("修改行程请求:{}", body.toJSONString()); |
| | | logger.info("修改行程请求:{} {}", tripId, body.toJSONString()); |
| | | HttpRequest request = put.body(body.toJSONString()); |
| | | HttpResponse response = request.execute(); |
| | | logger.info("修改行程结果:{}", response.body()); |
| | |
| | | headers.put("Content-Type", "application/json"); |
| | | get.addHeaders(headers); |
| | | |
| | | logger.info("查询行程请求:{} {}", tripId, url); |
| | | HttpResponse response = get.execute(); |
| | | logger.info("查询行程结果:{}", response.body()); |
| | | JSONObject jsonObject = JSON.parseObject(response.body().replaceAll("@type", "type")); |
| | |
| | | if(null != error){ |
| | | Integer code = error.getInteger("code"); |
| | | if(code == 404){ |
| | | return ""; |
| | | return null; |
| | | } |
| | | if(code == 401){ |
| | | String status = error.getString("status"); |
| | |
| | | * @return |
| | | */ |
| | | public boolean reportBillableEvent(String tripId) { |
| | | log.info("行程上报:{}", tripId); |
| | | String billableEventId = UUIDUtil.getRandomCode(); |
| | | String url = "https://mobilitybilling.googleapis.com/v1:reportBillableEvent?regionCode=GH&key=" + key + "&billableEventId=" + billableEventId; |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | |
| | | if((state == 2 || state == 3 || state == 4) || (oldState != null && (oldState == 2 || oldState == 3 || oldState == 4))){//前往预约地 |
| | | String d = "0"; |
| | | String t = "0"; |
| | | if(ToolUtil.isNotEmpty(value) && ToolUtil.isNotEmpty(startLonLat)){ |
| | | String[] split = value.split(","); |
| | | String[] split1 = startLonLat.split(","); |
| | | DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(Double.valueOf(split[1]), Double.valueOf(split[0]), Double.valueOf(split1[1]), Double.valueOf(split1[0]), tripId); |
| | | if(null == distancematrix){ |
| | | System.err.println("地图获取距离出错"); |
| | | }else{ |
| | | d = distancematrix.getDistance().toString();//距离m |
| | | t = distancematrix.getDuration().toString();//时间s |
| | | } |
| | | } |
| | | d = new BigDecimal(d).divide(new BigDecimal(1000), new MathContext(2, RoundingMode.HALF_EVEN)).toString(); |
| | | t = new BigDecimal(t).divide(new BigDecimal(60), new MathContext(2, RoundingMode.HALF_EVEN)).intValue() + ""; |
| | | // if(ToolUtil.isNotEmpty(value) && ToolUtil.isNotEmpty(startLonLat)){ |
| | | // String[] split = value.split(","); |
| | | // String[] split1 = startLonLat.split(","); |
| | | // DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(Double.valueOf(split[1]), Double.valueOf(split[0]), Double.valueOf(split1[1]), Double.valueOf(split1[0]), tripId); |
| | | // if(null == distancematrix){ |
| | | // System.err.println("地图获取距离出错"); |
| | | // }else{ |
| | | // d = distancematrix.getDistance().toString();//距离m |
| | | // t = distancematrix.getDuration().toString();//时间s |
| | | // } |
| | | // } |
| | | // d = new BigDecimal(d).divide(new BigDecimal(1000), new MathContext(2, RoundingMode.HALF_EVEN)).toString(); |
| | | // t = new BigDecimal(t).divide(new BigDecimal(60), new MathContext(2, RoundingMode.HALF_EVEN)).intValue() + ""; |
| | | map.put("reservationMileage", d);//当前位置距离预约点的剩余里程 |
| | | map.put("reservationTime", t);//当前位置距离预约点的剩余分钟 |
| | | map.put("servedMileage", "0");//距离起点已经服务的里程 |
| | |
| | | |
| | | String d = "0"; |
| | | String t = "0"; |
| | | if(ToolUtil.isNotEmpty(value) && ToolUtil.isNotEmpty(endLonLat)){ |
| | | String[] split = value.split(","); |
| | | String[] split1 = endLonLat.split(","); |
| | | DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(Double.valueOf(split[1]), Double.valueOf(split[0]), Double.valueOf(split1[1]), Double.valueOf(split1[0]), tripId); |
| | | if(null == distancematrix){ |
| | | System.err.println("地图获取距离出错"); |
| | | }else{ |
| | | d = distancematrix.getDistance().toString();//距离m |
| | | t = distancematrix.getDuration().toString();//时间s |
| | | } |
| | | } |
| | | |
| | | d = new BigDecimal(d).divide(new BigDecimal(1000), new MathContext(2, RoundingMode.HALF_EVEN)).toString(); |
| | | t = new BigDecimal(t).divide(new BigDecimal(60), new MathContext(2, RoundingMode.HALF_EVEN)).intValue() + ""; |
| | | // if(ToolUtil.isNotEmpty(value) && ToolUtil.isNotEmpty(endLonLat)){ |
| | | // String[] split = value.split(","); |
| | | // String[] split1 = endLonLat.split(","); |
| | | // DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(Double.valueOf(split[1]), Double.valueOf(split[0]), Double.valueOf(split1[1]), Double.valueOf(split1[0]), tripId); |
| | | // if(null == distancematrix){ |
| | | // System.err.println("地图获取距离出错"); |
| | | // }else{ |
| | | // d = distancematrix.getDistance().toString();//距离m |
| | | // t = distancematrix.getDuration().toString();//时间s |
| | | // } |
| | | // } |
| | | // |
| | | // d = new BigDecimal(d).divide(new BigDecimal(1000), new MathContext(2, RoundingMode.HALF_EVEN)).toString(); |
| | | // t = new BigDecimal(t).divide(new BigDecimal(60), new MathContext(2, RoundingMode.HALF_EVEN)).intValue() + ""; |
| | | map.put("laveMileage", d);//距离终点剩余未服务的里程数 |
| | | map.put("laveTime", t);//距离终端剩余未服务的预计时间 |
| | | } |
| | |
| | | |
| | | @Autowired |
| | | private IDriverOnlineService driverOnlineService; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 5秒钟处理的任务 |
| | | */ |
| | | @Scheduled(fixedRate = 5000) |
| | | public void task5Second(){ |
| | | try { |
| | | // orderService.getDriverNowPosition(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | |
| | | //package com.stylefeng.guns; |
| | | // |
| | | //import cn.hutool.http.HttpUtil; |
| | | //import com.alibaba.fastjson.JSON; |
| | | //import com.alibaba.fastjson.JSONObject; |
| | | //import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | //import com.stylefeng.guns.core.util.ToolUtil; |
| | | //import com.stylefeng.guns.modular.smallLogistics.server.IOrderLogisticsService; |
| | | //import com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar; |
| | | //import com.stylefeng.guns.modular.specialTrain.server.IOrderPrivateCarService; |
| | | //import com.stylefeng.guns.modular.system.service.IDriverService; |
| | | //import com.stylefeng.guns.modular.system.service.IOrderEvaluateService; |
| | | //import com.stylefeng.guns.modular.system.service.IOrderPositionService; |
| | | //import com.stylefeng.guns.modular.system.util.GoogleMap.FleetEngineUtil; |
| | | //import com.stylefeng.guns.modular.system.warpper.ActivityWarpper; |
| | | //import org.junit.Test; |
| | | //import org.junit.runner.RunWith; |
| | |
| | | //import org.springframework.test.context.junit4.SpringRunner; |
| | | // |
| | | //import java.text.SimpleDateFormat; |
| | | //import java.util.Arrays; |
| | | //import java.util.List; |
| | | //import java.util.Map; |
| | | // |
| | |
| | | // @Autowired |
| | | // private IDriverService driverService; |
| | | // |
| | | // @Autowired |
| | | // IOrderPrivateCarService orderPrivateCarService; |
| | | // |
| | | // @Autowired |
| | | // private FleetEngineUtil fleetEngineUtil; |
| | | // |
| | | // @Test |
| | | // public void test(){ |
| | | // try { |
| | | // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | // List<ActivityWarpper> activityWarppers = driverService.queryMyActivity(2508, sdf.parse("2024-01-31"), 1); |
| | | // }catch (Exception e){ |
| | | // e.printStackTrace(); |
| | | // } |
| | | // |
| | | // |
| | | // |
| | | // } |
| | | //} |
| | |
| | | orderCancelMapper.insert(orderCancel); |
| | | |
| | | //修改行程信息 |
| | | try { |
| | | boolean updateTrip = fleetEngineUtil.updateTrip("CANCELED", null, null, tOrderLogistics.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip("CANCELED", null, null, tOrderLogistics.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | boolean updateTrip = fleetEngineUtil.updateTrip("CANCELED", null, null, tOrderLogistics.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip("CANCELED", null, null, tOrderLogistics.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | tOrderPrivateCarService.updateById(orderPrivateCar); |
| | | |
| | | //修改行程数据 |
| | | boolean updateTrip = fleetEngineUtil.updateTrip("COMPLETE", null, null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip("COMPLETE", null, null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | //上报行程 |
| | | boolean reportBillableEvent = fleetEngineUtil.reportBillableEvent(orderPrivateCar.getTripId()); |
| | | if(!reportBillableEvent){ |
| | | for (int i = 0; i < 5; i++) { |
| | | reportBillableEvent = fleetEngineUtil.reportBillableEvent(orderPrivateCar.getTripId()); |
| | | if(reportBillableEvent){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | TUser userInfo = userService.selectById(orderPrivateCar.getUserId()); |
| | | Integer language1 = userInfo.getLanguage(); |
| | |
| | | public void run() { |
| | | pushUtil.pushOrderState(1, finalOrderTaxi.getUserId(), finalOrderTaxi.getId(), 1, finalOrderTaxi.getState(), 0, ""); |
| | | pushUtil.pushOrderState(2, finalOrderTaxi.getDriverId(), finalOrderTaxi.getId(), 1, finalOrderTaxi.getState(), 0, ""); |
| | | } |
| | | }).start(); |
| | | |
| | | TOrderPrivateCar finalOrderPrivateCar = orderPrivateCar; |
| | | new Thread(()->{ |
| | | try { |
| | | //上报google |
| | | fleetEngineUtil.reportBillableEvent(finalOrderPrivateCar.getTripId()); |
| | | log.warn("上报时间:{},tripid:{},created_at:{},completed_at:{}", System.currentTimeMillis(), finalOrderPrivateCar.getTripId(), |
| | | finalOrderPrivateCar.getInsertTime().getTime(), finalOrderPrivateCar.getEndServiceTime().getTime()); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | }).start(); |
| | | |
| | |
| | | orderCancelMapper.insert(orderCancel); |
| | | |
| | | //修改行程信息 |
| | | try { |
| | | boolean updateTrip = fleetEngineUtil.updateTrip("CANCELED", null, null, tOrderPrivateCar.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip("CANCELED", null, null, tOrderPrivateCar.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | boolean updateTrip = fleetEngineUtil.updateTrip("CANCELED", null, null, tOrderPrivateCar.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip("CANCELED", null, null, tOrderPrivateCar.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | |
| | | |
| | |
| | | <!--根据条件查询小件物流订单列表--> |
| | | <select id="getLogisticsOrderList" resultType="map" parameterType="com.baomidou.mybatisplus.plugins.Page"> |
| | | SELECT * FROM (SELECT ui.nickName as userName,ui.phone as userPhone,CONCAT(di.firstName, " ", di.lastName,'-',di.phone) as driver,CONCAT(cb.`name`,'-',ci.carLicensePlate) as car, |
| | | ot.* FROM t_order_logistics as ot |
| | | ot.*,oc.money as cancel_money FROM t_order_logistics as ot |
| | | LEFT JOIN t_user as ui on ui.id = ot.userId |
| | | LEFT JOIN t_driver as di on di.id = ot.driverId |
| | | LEFT JOIN t_car as ci on ci.id= ot.carId |
| | | LEFT JOIN t_car_brand as cb on cb.id = ci.carBrandId) as o |
| | | LEFT JOIN t_car_brand as cb on cb.id = ci.carBrandId |
| | | left join t_order_cancel as oc on (ot.id = oc.orderId and oc.orderType = 4 and oc.state = 2) |
| | | ) as o |
| | | <where> |
| | | o.isDelete = 1 |
| | | <if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''"> |
| | |
| | | <!--根据条件查询专车订单列表--> |
| | | <select id="getPrivateCarOrderList" resultType="map" parameterType="com.baomidou.mybatisplus.plugins.Page"> |
| | | SELECT * FROM (SELECT ui.nickName as userName,ui.phone as userPhone,CONCAT(di.firstName, " ", di.lastName,'-',di.phone) as driver,CONCAT(cb.`name`,'-',ci.carLicensePlate) as car, |
| | | sc.chineseName as serverCarModel,ot.* FROM t_order_private_car as ot |
| | | sc.chineseName as serverCarModel,oc.money as cancel_money,ot.* FROM t_order_private_car as ot |
| | | LEFT JOIN t_user as ui on ui.id = ot.userId |
| | | LEFT JOIN t_driver as di on di.id = ot.driverId |
| | | LEFT JOIN t_car as ci on ci.id= ot.carId |
| | | LEFT JOIN t_car_brand as cb on cb.id = ci.carBrandId |
| | | LEFT JOIN t_server_carmodel as sc on sc.id = ot.serverCarModelId |
| | | left join t_order_cancel as oc on (ot.id = oc.orderId and oc.orderType = 1 and oc.state = 2) |
| | | ) as o |
| | | <where> |
| | | o.isDelete = 1 and o.type = 1 |
| | |
| | | select |
| | | aa.time, |
| | | aa.userId, |
| | | aa.userName, |
| | | aa.phone, |
| | | any_value(aa.userName) as userName, |
| | | any_value(aa.phone) as phone, |
| | | sum(aa.amount) as amount, |
| | | sum(aa.tyNum) as tyNum, |
| | | sum(aa.tyUseNum) as tyUseNum, |
| | |
| | | <resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.UserRedPacketRecord"> |
| | | <id column="id" property="id"/> |
| | | <result column="money" property="money"/> |
| | | <result column="expirationTime" property="expirationTime"/> |
| | | <result column="insertTime" property="insertTime"/> |
| | | <result column="companyId" property="companyId"/> |
| | | <result column="state" property="state"/> |
| | |
| | | d.nickName as `name`, |
| | | d.phone as phone, |
| | | a.money as money, |
| | | DATE_FORMAT(a.expirationTime, '%Y-%m-%d %H:%i:%s') as expirationTime, |
| | | if(a.state = 1, '未使用', if(a.state = 2, '已使用', '已过期')) as state, |
| | | DATE_FORMAT(a.endTime, '%Y-%m-%d %H:%i:%s') as endTime |
| | | from t_user_red_packet_record a |
| | |
| | | end_point.put("longitude", end_lng); |
| | | dropoffPoint.put("point", end_point); |
| | | body.put("dropoffPoint", dropoffPoint); |
| | | logger.info("创建行程请求:{}", body.toJSONString()); |
| | | logger.info("创建行程请求:{} {}", tripId, body.toJSONString()); |
| | | HttpRequest request = post.body(body.toJSONString()); |
| | | HttpResponse response = request.execute(); |
| | | logger.info("创建行程结果:{}", response.body()); |
| | |
| | | dropoffPoint.put("point", end_point); |
| | | body.put("dropoffPoint", dropoffPoint); |
| | | } |
| | | logger.info("修改行程请求:{}", body.toJSONString()); |
| | | logger.info("修改行程请求:{} {}", tripId, body.toJSONString()); |
| | | HttpRequest request = put.body(body.toJSONString()); |
| | | HttpResponse response = request.execute(); |
| | | logger.info("修改行程结果:{}", response.body()); |
| | |
| | | * @return |
| | | */ |
| | | public boolean reportBillableEvent(String tripId) { |
| | | log.info("上报行程:{}", tripId); |
| | | String billableEventId = UUIDUtil.getRandomCode(); |
| | | String url = "https://mobilitybilling.googleapis.com/v1:reportBillableEvent?regionCode=GH&key=" + key + "&billableEventId=" + billableEventId; |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | |
| | | <#button name="修改" icon="fa-edit" clickFun="SettlementAllocation.setSettlementAllocation()"/> |
| | | <div class="form-group"> |
| | | <input type="radio" name="type" value="1" ${null != item && item.type == '1' ? 'checked' : ''}> |
| | | 每天 超过 <input type="number" class="date" value="${null != item && item.type == '1' ? item.maxPrice : ''}" style="background-color: #FFFFFF;background-image: none;border: 1px solid #e5e6e7;border-radius: 1px;color: inherit;padding: 6px 12px;"/> 必须结算 |
| | | 每天 超过 <input type="number" min="1" class="day" value="${null != item && item.type == '1' ? item.maxPrice : ''}" style="background-color: #FFFFFF;background-image: none;border: 1px solid #e5e6e7;border-radius: 1px;color: inherit;padding: 6px 12px;"/> 必须结算 |
| | | </div> |
| | | <div class="form-group"> |
| | | <input type="radio" name="type" value="2" ${null != item && item.type == '2' ? 'checked' : ''}> 每周 |
| | | 每周 每周<input type="number" min="1" max="7" class="date" value="${null != item && item.type == '2' ? item.day : ''}" style="background-color: #FFFFFF;background-image: none;border: 1px solid #e5e6e7;border-radius: 1px;color: inherit;padding: 6px 12px;"/> (几)可结算 |
| | | </div> |
| | | <div class="form-group"> |
| | | <input type="radio" name="type" value="3" ${null != item && item.type == '3' ? 'checked' : ''}> 每月 |
| | | 每月 每月<input type="number" min="1" max="31" class="date" value="${null != item && item.type == '3' ? item.day : ''}" style="background-color: #FFFFFF;background-image: none;border: 1px solid #e5e6e7;border-radius: 1px;color: inherit;padding: 6px 12px;"/> 号可结算 |
| | | </div> |
| | | <div class="form-group"> |
| | | <input type="radio" name="type" value="2" ${null != item && item.type == '2' ? 'checked' : ''}> 每周 |
| | | 每周 每周<input type="number" min="1" max="7" class="date" value="${null != item && item.type == '2' ? item.day : ''}" style="background-color: #FFFFFF;background-image: none;border: 1px solid #e5e6e7;border-radius: 1px;color: inherit;padding: 6px 12px;"/> (几)可结算 |
| | | </div> |
| | | <div class="form-group"> |
| | | 周/月 日上限超过 <input type="number" id="maxPrice" value="${null != item && item.type != '1' ? item.maxPrice : ''}" style="background-color: #FFFFFF;background-image: none;border: 1px solid #e5e6e7;border-radius: 1px;color: inherit;padding: 6px 12px;"/> 必须结算 |
| | | 周/月 日上限超过 <input type="number" min="0" id="maxPrice" value="${null != item && item.type != '1' ? item.maxPrice : ''}" style="background-color: #FFFFFF;background-image: none;border: 1px solid #e5e6e7;border-radius: 1px;color: inherit;padding: 6px 12px;"/> 必须结算 |
| | | </div> |
| | | </div> |
| | | <div class="row"> |
| | |
| | | * 删除司机单单返活动 |
| | | */ |
| | | SettlementAllocation.setSettlementAllocation = function () { |
| | | let type = $('input[name="type"]:checked')[0]; |
| | | var type = $($('input[name="type"]:checked')[0]); |
| | | if(typeof type == "undefined"){ |
| | | Feng.error("请选择结算周期"); |
| | | return |
| | | } |
| | | let day = $($(type).siblings('.date')[0]).val(); |
| | | if('' == day || null == day){ |
| | | Feng.error("请输入有效的结算日期") |
| | | return |
| | | if(type.val() == '1'){ |
| | | var day = $(type.siblings('.day')[0]).val(); |
| | | if('' == day || null == day){ |
| | | Feng.error("请输入金额上限") |
| | | return |
| | | } |
| | | }else{ |
| | | var day = $(type.siblings('.date')[0]).val(); |
| | | if('' == day || null == day){ |
| | | Feng.error("请输入有效的结算日期") |
| | | return |
| | | } |
| | | } |
| | | let maxPrice = $('#maxPrice').val(); |
| | | if(1 == $(type).val()){ |
| | | var maxPrice = $('#maxPrice').val(); |
| | | if('1' == type.val()){ |
| | | maxPrice = day; |
| | | } |
| | | // if('' == maxPrice || null == maxPrice){ |
| | | // Feng.error("请输入每日结算金额") |
| | | // return |
| | | // } |
| | | if('' == maxPrice || null == maxPrice){ |
| | | Feng.error("请输入金额上限") |
| | | return |
| | | } |
| | | if(maxPrice < 0){ |
| | | Feng.error("金额上限不能小于0") |
| | | return |
| | | } |
| | | let json = { |
| | | type: $(type).val(), |
| | | type: type.val(), |
| | | day: day, |
| | | maxPrice: maxPrice |
| | | } |
| | |
| | | if(row.orderMoney != '' && row.orderMoney != null) { |
| | | btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.orderMoney + '" onfocus="TUser.tooltip()">' + row.orderMoney + '</p>'] |
| | | } |
| | | if(row.state == 10){ |
| | | btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.cancel_money + '" onfocus="TUser.tooltip()">' + row.cancel_money + '</p>'] |
| | | } |
| | | return btn; |
| | | } |
| | | }, |
| | |
| | | if(row.orderMoney != '' && row.orderMoney != null) { |
| | | btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.orderMoney + '" onfocus="TUser.tooltip()">' + row.orderMoney + '</p>'] |
| | | } |
| | | if(row.state == 10){ |
| | | btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.cancel_money + '" onfocus="TUser.tooltip()">' + row.cancel_money + '</p>'] |
| | | } |
| | | return btn; |
| | | } |
| | | }, |
| | |
| | | if(null == uid){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | String format = String.format("uid=%s&id=%s&orderType=%s&payType=%s&type=%s", uid, id, orderType, payType, type); |
| | | String key = MD5Util.encrypt(format); |
| | | String value = redisUtil.getValue(key); |
| | | if(ToolUtil.isNotEmpty(value) && (System.currentTimeMillis() - Long.valueOf(value)) <= 1000){ |
| | | return ResultUtil.error(language == 1 ? "请勿重复操作" : language == 2 ? "Don't repeat the operation" : "Ne répétez pas l’opération"); |
| | | } |
| | | redisUtil.setStrValue(key, System.currentTimeMillis() + "", 5); |
| | | switch (orderType){ |
| | | case 1: |
| | | return orderPrivateCarService.cancleOrderPrivateCar(id, payType, bankCardId, cancleId, type, language); |
| | |
| | | @ResponseBody |
| | | @PostMapping("/base/wxCancelOrderTaxi") |
| | | public CallbackResponse wxCancelOrderTaxi(@RequestBody CallbackRequest callbackRequest){ |
| | | log.info("取消订单支付回调结果:{}", JSON.toJSONString(callbackRequest)); |
| | | CallbackResponse callbackResponse = new CallbackResponse(); |
| | | try { |
| | | /** |
| | |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | log.info("取消订单支付回调处理结束:{}", JSON.toJSONString(callbackResponse)); |
| | | return callbackResponse; |
| | | } |
| | | |
| | |
| | | @ResponseBody |
| | | @PostMapping("/base/wxPayOrderTaxi") |
| | | public CallbackResponse wxPayOrderTaxi(@RequestBody CallbackRequest callbackRequest){ |
| | | log.info("订单完成支付回调结果:{}", JSON.toJSONString(callbackRequest)); |
| | | CallbackResponse callbackResponse = new CallbackResponse(); |
| | | try { |
| | | /** |
| | |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | log.info("订单完成支付回调处理结束:{}", JSON.toJSONString(callbackResponse)); |
| | | return callbackResponse; |
| | | } |
| | | |
| | |
| | | UserInfo userInfo = userInfoService.selectById(uid); |
| | | userInfo.setLanguage(language); |
| | | userInfoService.updateById(userInfo); |
| | | |
| | | new Thread(() -> { |
| | | try { |
| | | String vehicleId = null; |
| | | if(null != orderLogistics.getDriverId()){ |
| | | Driver driver = driverService.selectById(orderLogistics.getDriverId()); |
| | | Car car = carMapper.selectById(driver.getCarId()); |
| | | if(!StringUtils.hasLength(car.getVehicleId())){ |
| | | car.setVehicleId(UUIDUtil.getRandomCode()); |
| | | carMapper.updateById(car); |
| | | } |
| | | //查询车辆信息,没有则创建信息 |
| | | String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId()); |
| | | if(ToolUtil.isEmpty(vehicles)){ |
| | | CarModel carModel = carModelMapper.selectById(car.getCarModelId()); |
| | | boolean createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!createVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(createVehicles){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | } |
| | | boolean updateVehicles = fleetEngineUtil.updateVehicles("ONLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!updateVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateVehicles = fleetEngineUtil.updateVehicles("ONLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(updateVehicles){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | //创建行程数据 |
| | | boolean createTrip = fleetEngineUtil.createTrip(vehicleId, 1, orderLogistics.getTripId(), |
| | | orderLogistics.getStartLat().toString(), orderLogistics.getStartLon().toString(), orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString()); |
| | | if(!createTrip){ |
| | | |
| | | //google创建车辆信息 |
| | | String vehicleId = null; |
| | | if(null != orderLogistics.getDriverId()){ |
| | | Driver driver = driverService.selectById(orderLogistics.getDriverId()); |
| | | Car car = carMapper.selectById(driver.getCarId()); |
| | | if(!StringUtils.hasLength(car.getVehicleId())){ |
| | | car.setVehicleId(UUIDUtil.getRandomCode()); |
| | | carMapper.updateById(car); |
| | | } |
| | | //查询车辆信息,没有则创建信息 |
| | | String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId()); |
| | | if(ToolUtil.isEmpty(vehicles)){ |
| | | CarModel carModel = carModelMapper.selectById(car.getCarModelId()); |
| | | boolean createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!createVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createTrip = fleetEngineUtil.createTrip(vehicleId, 1, orderLogistics.getTripId(), |
| | | orderLogistics.getStartLat().toString(), orderLogistics.getStartLon().toString(), orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString()); |
| | | if(createTrip){ |
| | | createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(createVehicles){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | } |
| | | |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | boolean updateVehicles = fleetEngineUtil.updateVehicles("ONLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!updateVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateVehicles = fleetEngineUtil.updateVehicles("ONLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(updateVehicles){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | } |
| | | } |
| | | }).start(); |
| | | } |
| | | |
| | | //创建行程数据 |
| | | String trip = fleetEngineUtil.getTrip(orderLogistics.getTripId()); |
| | | int count = this.selectCount(new EntityWrapper<OrderLogistics>().eq("tripId", orderLogistics.getTripId())); |
| | | int count1 = orderPrivateCarService.selectCount(new EntityWrapper<OrderPrivateCar>().eq("tripId", orderLogistics.getTripId())); |
| | | if(ToolUtil.isNotEmpty(trip) || (count + count1) > 0){ |
| | | String randomCode = UUIDUtil.getRandomCode(); |
| | | redisUtil.setStrValue("trip" + orderLogistics.getUserId(), randomCode); |
| | | OrderLogistics orderLogistics1 = new OrderLogistics(); |
| | | orderLogistics1.setId(orderLogistics.getId()); |
| | | orderLogistics1.setTripId(randomCode); |
| | | this.updateById(orderLogistics1); |
| | | orderLogistics.setTripId(randomCode); |
| | | } |
| | | JSONObject createTrip = fleetEngineUtil.createTrip(vehicleId, 1, orderLogistics.getTripId(), |
| | | orderLogistics.getStartLat().toString(), orderLogistics.getStartLon().toString(), orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString()); |
| | | JSONObject error = createTrip.getJSONObject("error"); |
| | | if(null != error){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createTrip = fleetEngineUtil.createTrip(vehicleId, 1, orderLogistics.getTripId(), |
| | | orderLogistics.getStartLat().toString(), orderLogistics.getStartLon().toString(), orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString()); |
| | | error = createTrip.getJSONObject("error"); |
| | | String tripStatus = createTrip.getString("tripStatus"); |
| | | if(null == error && "NEW".equals(tripStatus)){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if(orderSource == 2){//扫码下单 |
| | | Driver driver = driverService.selectById(orderLogistics.getDriverId()); |
| | |
| | | userRedPacketRecord.setEndTime(new Date()); |
| | | userRedPacketRecord.setState(2); |
| | | multiply1 = multiply1.subtract(remainingAmount).setScale(2, RoundingMode.HALF_EVEN); |
| | | jsonObject.put("money", remainingAmount); |
| | | jsonObject.put("money", remainingAmount.setScale(2, RoundingMode.HALF_EVEN)); |
| | | jsonArray.add(jsonObject); |
| | | }else if(remainingAmount.compareTo(multiply1) > 0){ |
| | | userRedPacketRecord.setRemainingAmount(remainingAmount.subtract(multiply1).setScale(2, RoundingMode.HALF_EVEN).doubleValue()); |
| | | jsonObject.put("money", multiply1); |
| | | jsonObject.put("money", multiply1.setScale(2, RoundingMode.HALF_EVEN)); |
| | | jsonArray.add(jsonObject); |
| | | multiply1 = BigDecimal.ZERO; |
| | | } |
| | |
| | | }else{ |
| | | resultUtil = ResultUtil.error(language == 1 ? "支付失败" : language == 2 ? "Payment failure" : "Paiement échoué", ""); |
| | | } |
| | | return resultUtil; |
| | | } |
| | | |
| | | if(payType == 2) {//银行卡支付 |
| | |
| | | resultUtil = TinggPayUtil.checkoutRequest(checkoutRequest); |
| | | |
| | | if(resultUtil.getCode()==200){ |
| | | this.updateById(orderLogistics); |
| | | paymentRecordService.saveData(1, null, null, orderId, 4, 2, |
| | | orderMoney.setScale(2, RoundingMode.HALF_EVEN).doubleValue(), null, 1);//添加预支付数据 |
| | | }else{ |
| | | resultUtil = ResultUtil.error(language == 1 ? "支付失败" : language == 2 ? "Payment failure" : "Paiement échoué", ""); |
| | | } |
| | | return resultUtil; |
| | | } |
| | | |
| | | if(payType == 3){//余额支付 |
| | |
| | | } |
| | | } |
| | | |
| | | if(orderLogistics.getIsplatPay()==1){ |
| | | //添加已收入明细 |
| | | Company company = companyService.selectById(orderLogistics.getCompanyId()); |
| | | Double speMoney = company.getSpeMoney(); |
| | | BigDecimal d = null;//企业收入 |
| | | BigDecimal c = null;//司机收入 |
| | | if(company.getIsSpeFixedOrProportional() == 2){//固定 |
| | | d = new BigDecimal(speMoney); |
| | | c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d);//只有出行金额参与抽成,其余归属司机 |
| | | } |
| | | if(company.getIsSpeFixedOrProportional() == 1){//比例 |
| | | Double price = orderLogistics.getStartMoney() + orderLogistics.getMileageMoney() + orderLogistics.getWaitMoney() + orderLogistics.getDurationMoney() + orderLogistics.getLongDistanceMoney(); |
| | | d = new BigDecimal(price).multiply(new BigDecimal(speMoney).divide(new BigDecimal(100), new MathContext(2, RoundingMode.HALF_EVEN))); |
| | | c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN); |
| | | } |
| | | incomeService.saveData(1, orderLogistics.getCompanyId(), 2, orderLogistics.getId(), 4, d.doubleValue()); |
| | | incomeService.saveData(2, orderLogistics.getDriverId(), 2, orderLogistics.getId(), 4, c.doubleValue()); |
| | | Driver driver = driverService.selectById(orderLogistics.getDriverId()); |
| | | driver.setBusinessMoney(new BigDecimal(null != driver.getBusinessMoney() ? driver.getBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driver.setLaveBusinessMoney(new BigDecimal(null != driver.getLaveBusinessMoney() ? driver.getLaveBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driverService.updateById(driver); |
| | | //添加已收入明细 |
| | | Company company = companyService.selectById(orderLogistics.getCompanyId()); |
| | | Double speMoney = company.getSpeMoney(); |
| | | BigDecimal d = null;//企业收入 |
| | | BigDecimal c = null;//司机收入 |
| | | if(company.getIsSpeFixedOrProportional() == 2){//固定 |
| | | d = new BigDecimal(speMoney); |
| | | c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d);//只有出行金额参与抽成,其余归属司机 |
| | | } |
| | | if(company.getIsSpeFixedOrProportional() == 1){//比例 |
| | | Double price = orderLogistics.getStartMoney() + orderLogistics.getMileageMoney() + orderLogistics.getWaitMoney() + orderLogistics.getDurationMoney() + orderLogistics.getLongDistanceMoney(); |
| | | d = new BigDecimal(price).multiply(new BigDecimal(speMoney).divide(new BigDecimal(100), new MathContext(2, RoundingMode.HALF_EVEN))); |
| | | c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN); |
| | | } |
| | | incomeService.saveData(1, orderLogistics.getCompanyId(), 2, orderLogistics.getId(), 4, d.doubleValue()); |
| | | incomeService.saveData(2, orderLogistics.getDriverId(), 2, orderLogistics.getId(), 4, c.doubleValue()); |
| | | Driver driver = driverService.selectById(orderLogistics.getDriverId()); |
| | | driver.setBusinessMoney(new BigDecimal(null != driver.getBusinessMoney() ? driver.getBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driver.setLaveBusinessMoney(new BigDecimal(null != driver.getLaveBusinessMoney() ? driver.getLaveBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driverService.updateById(driver); |
| | | |
| | | // TODO: 2020/5/24 这里需要给司机和用户推送订单状态 |
| | | new Thread(new Runnable() { |
| | |
| | | Document document = Jsoup.parse(new File(path), "UTF-8"); |
| | | SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd"); |
| | | SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| | | Driver driver = driverService.selectById(orderLogistics.getDriverId()); |
| | | driver = driverService.selectById(orderLogistics.getDriverId()); |
| | | Car car = carMapper.selectById(orderLogistics.getCarId()); |
| | | Double aDouble = 0D; |
| | | if(null != orderLogistics.getDriverId()){ |
| | |
| | | } |
| | | |
| | | |
| | | if(orderLogistics.getIsplatPay()==1){ |
| | | //添加已收入明细 |
| | | Company company = companyService.selectById(orderLogistics.getCompanyId()); |
| | | Double speMoney = company.getSpeMoney(); |
| | | BigDecimal d = null;//企业收入 |
| | | BigDecimal c = null;//司机收入 |
| | | if(company.getIsSpeFixedOrProportional() == 2){//固定 |
| | | d = new BigDecimal(speMoney); |
| | | c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d);//只有出行金额参与抽成,其余归属司机 |
| | | } |
| | | if(company.getIsSpeFixedOrProportional() == 1){//比例 |
| | | Double price = orderLogistics.getStartMoney() + orderLogistics.getMileageMoney() + orderLogistics.getWaitMoney() + orderLogistics.getDurationMoney() + orderLogistics.getLongDistanceMoney(); |
| | | d = new BigDecimal(price).multiply(new BigDecimal(speMoney).divide(new BigDecimal(100), new MathContext(2, RoundingMode.HALF_EVEN))); |
| | | c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN); |
| | | } |
| | | //添加已收入明细 |
| | | Company company = companyService.selectById(orderLogistics.getCompanyId()); |
| | | Double speMoney = company.getSpeMoney(); |
| | | BigDecimal d = null;//企业收入 |
| | | BigDecimal c = null;//司机收入 |
| | | if(company.getIsSpeFixedOrProportional() == 2){//固定 |
| | | d = new BigDecimal(speMoney); |
| | | c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d);//只有出行金额参与抽成,其余归属司机 |
| | | } |
| | | if(company.getIsSpeFixedOrProportional() == 1){//比例 |
| | | Double price = orderLogistics.getStartMoney() + orderLogistics.getMileageMoney() + orderLogistics.getWaitMoney() + orderLogistics.getDurationMoney() + orderLogistics.getLongDistanceMoney(); |
| | | d = new BigDecimal(price).multiply(new BigDecimal(speMoney).divide(new BigDecimal(100), new MathContext(2, RoundingMode.HALF_EVEN))); |
| | | c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN); |
| | | } |
| | | // incomeService.saveData(1, orderPrivateCar.getCompanyId(), 2, orderPrivateCar.getId(), 1, d.doubleValue()); |
| | | // incomeService.saveData(2, orderPrivateCar.getDriverId(), 2, orderPrivateCar.getId(), 1, c.doubleValue()); |
| | | |
| | |
| | | // driver.setLaveBusinessMoney(new BigDecimal(null != driver.getLaveBusinessMoney() ? driver.getLaveBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | // driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | // driverService.updateById(driver); |
| | | |
| | | |
| | | //记录司机待结算金额 |
| | | if(d.compareTo(new BigDecimal(0)) > 0){ |
| | | SettlementDetail settlementDetail = new SettlementDetail(); |
| | | settlementDetail.setOrderId(orderId); |
| | | settlementDetail.setOrderType(4); |
| | | settlementDetail.setDriverId(driver.getId()); |
| | | settlementDetail.setOrderMoney(orderLogistics.getOrderMoney()); |
| | | settlementDetail.setPrice(d.doubleValue()); |
| | | settlementDetail.setCreateTime(new Date()); |
| | | settlementDetailService.insert(settlementDetail); |
| | | |
| | | SettlementAllocation settlementAllocation = settlementAllocationService.selectOne(null); |
| | | if(null != settlementAllocation){ |
| | | JSONObject jsonObject = JSON.parseObject(settlementAllocation.getContent()); |
| | | Double maxPrice = jsonObject.getDouble("maxPrice"); |
| | | Integer type1 = jsonObject.getInteger("type"); |
| | | if(null != maxPrice){ |
| | | List<SettlementDetail> settlementDetailList = settlementDetailService.selectList(new EntityWrapper<SettlementDetail>().eq("driverId", driver.getId()) |
| | | .isNull("settlementRecordId").last(" and DATE_FORMAT(now(), '%Y-%m-%d') = DATE_FORMAT(createTime, '%Y-%m-%d')")); |
| | | BigDecimal total = new BigDecimal(0); |
| | | for (SettlementDetail detail : settlementDetailList) { |
| | | total = total.add(new BigDecimal(detail.getPrice())); |
| | | } |
| | | //日结算 |
| | | if(maxPrice.compareTo(total.doubleValue()) <= 0){ |
| | | SettlementRecord settlementRecord = settlementRecordService.selectOne(new EntityWrapper<SettlementRecord>().eq("driverId", orderLogistics.getDriverId()) |
| | | .eq("type", type1).eq("paymentStatus", 1).last(" and day = DATE_FORMAT(now(), '%Y-%m-%d')")); |
| | | if(null == settlementRecord){ |
| | | settlementRecord = new SettlementRecord(); |
| | | settlementRecord.setDay(new Date()); |
| | | settlementRecord.setDriverId(orderLogistics.getDriverId()); |
| | | settlementRecord.setType(type1); |
| | | settlementRecord.setPaymentStatus(1); |
| | | settlementRecord.setPayMoney(total.doubleValue()); |
| | | settlementRecord.setInsertTime(new Date()); |
| | | settlementRecordService.insert(settlementRecord); |
| | | }else{ |
| | | settlementRecord.setPayMoney(settlementRecord.getPayMoney() + total.doubleValue()); |
| | | settlementRecordService.updateById(settlementRecord); |
| | | } |
| | | for (SettlementDetail detail : settlementDetailList) { |
| | | detail.setSettlementRecordId(settlementRecord.getId()); |
| | | settlementDetailService.updateById(detail); |
| | | } |
| | | //强制司机下班 |
| | | DriverWork driverWork = driverWorkService.selectOne(new EntityWrapper<DriverWork>() |
| | | .eq("driverId", orderLogistics.getDriverId()).eq("state", 1)); |
| | | if(null != driverWork){ |
| | | driverWork.setEndTime(new Date()); |
| | | driverWork.setState(2); |
| | | driverWorkService.updateById(driverWork); |
| | | driver.setState(1); |
| | | driverService.updateById(driver); |
| | | Car car = carService.selectById(driver.getCarId()); |
| | | if(!org.apache.shiro.util.StringUtils.hasLength(car.getVehicleId())){ |
| | | car.setVehicleId(UUIDUtil.getRandomCode()); |
| | | carService.updateById(car); |
| | | } |
| | | |
| | | //司机下班,修改谷歌上的车辆信息 |
| | | new Thread(()->{ |
| | | try { |
| | | CarModel carModel = carModelMapper.selectById(car.getCarModelId()); |
| | | String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId()); |
| | | if(ToolUtil.isEmpty(vehicles)){ |
| | | boolean createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!createVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(createVehicles){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | |
| | | //记录司机待结算金额 |
| | | if(d.compareTo(new BigDecimal(0)) > 0){ |
| | | SettlementDetail settlementDetail = new SettlementDetail(); |
| | | settlementDetail.setOrderId(orderId); |
| | | settlementDetail.setOrderType(4); |
| | | settlementDetail.setDriverId(driver.getId()); |
| | | settlementDetail.setOrderMoney(orderLogistics.getOrderMoney()); |
| | | settlementDetail.setPrice(d.doubleValue()); |
| | | settlementDetail.setCreateTime(new Date()); |
| | | settlementDetailService.insert(settlementDetail); |
| | | |
| | | SettlementAllocation settlementAllocation = settlementAllocationService.selectOne(null); |
| | | if(null != settlementAllocation){ |
| | | JSONObject jsonObject = JSON.parseObject(settlementAllocation.getContent()); |
| | | Double maxPrice = jsonObject.getDouble("maxPrice"); |
| | | Integer type1 = jsonObject.getInteger("type"); |
| | | if(null != maxPrice){ |
| | | List<SettlementDetail> settlementDetailList = settlementDetailService.selectList(new EntityWrapper<SettlementDetail>().eq("driverId", driver.getId()) |
| | | .isNull("settlementRecordId").last(" and DATE_FORMAT(now(), '%Y-%m-%d') = DATE_FORMAT(createTime, '%Y-%m-%d')")); |
| | | BigDecimal total = new BigDecimal(0); |
| | | for (SettlementDetail detail : settlementDetailList) { |
| | | total = total.add(new BigDecimal(detail.getPrice())); |
| | | } |
| | | //日结算 |
| | | if(maxPrice.compareTo(total.doubleValue()) <= 0){ |
| | | SettlementRecord settlementRecord = settlementRecordService.selectOne(new EntityWrapper<SettlementRecord>().eq("driverId", orderLogistics.getDriverId()) |
| | | .eq("type", type1).eq("paymentStatus", 1).last(" and day = DATE_FORMAT(now(), '%Y-%m-%d')")); |
| | | if(null == settlementRecord){ |
| | | settlementRecord = new SettlementRecord(); |
| | | settlementRecord.setDay(new Date()); |
| | | settlementRecord.setDriverId(orderLogistics.getDriverId()); |
| | | settlementRecord.setType(type1); |
| | | settlementRecord.setPaymentStatus(1); |
| | | settlementRecord.setPayMoney(total.doubleValue()); |
| | | settlementRecord.setInsertTime(new Date()); |
| | | settlementRecordService.insert(settlementRecord); |
| | | }else{ |
| | | settlementRecord.setPayMoney(settlementRecord.getPayMoney() + total.doubleValue()); |
| | | settlementRecordService.updateById(settlementRecord); |
| | | } |
| | | for (SettlementDetail detail : settlementDetailList) { |
| | | detail.setSettlementRecordId(settlementRecord.getId()); |
| | | settlementDetailService.updateById(detail); |
| | | } |
| | | //强制司机下班 |
| | | DriverWork driverWork = driverWorkService.selectOne(new EntityWrapper<DriverWork>() |
| | | .eq("driverId", orderLogistics.getDriverId()).eq("state", 1)); |
| | | if(null != driverWork){ |
| | | driverWork.setEndTime(new Date()); |
| | | driverWork.setState(2); |
| | | driverWorkService.updateById(driverWork); |
| | | driver.setState(1); |
| | | driverService.updateById(driver); |
| | | Car car = carService.selectById(driver.getCarId()); |
| | | if(!org.apache.shiro.util.StringUtils.hasLength(car.getVehicleId())){ |
| | | car.setVehicleId(UUIDUtil.getRandomCode()); |
| | | carService.updateById(car); |
| | | } |
| | | |
| | | //司机下班,修改谷歌上的车辆信息 |
| | | new Thread(()->{ |
| | | try { |
| | | CarModel carModel = carModelMapper.selectById(car.getCarModelId()); |
| | | String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId()); |
| | | if(ToolUtil.isEmpty(vehicles)){ |
| | | boolean createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!createVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(createVehicles){ |
| | | break; |
| | | } |
| | | } |
| | | boolean updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!updateVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(updateVehicles){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | } |
| | | }else{ |
| | | boolean updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!updateVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(updateVehicles){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | boolean updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!updateVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(updateVehicles){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | } |
| | | }else{ |
| | | boolean updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!updateVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(updateVehicles){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | } |
| | | } |
| | | }).start(); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | }).start(); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | this.updateById(orderLogistics); |
| | | this.updateAllColumnById(orderLogistics); |
| | | return resultUtil; |
| | | } |
| | | |
| | |
| | | query.setState(2); |
| | | query.setCode(order_id); |
| | | paymentRecordService.updateById(query); |
| | | if(orderLogistics.getIsplatPay()==1){ |
| | | //添加已收入明细 |
| | | Company company = companyService.selectById(orderLogistics.getCompanyId()); |
| | | Double speMoney = company.getSpeMoney(); |
| | | BigDecimal d = null;//企业收入 |
| | | BigDecimal c = null;//司机收入 |
| | | if(company.getIsSpeFixedOrProportional() == 2){//固定 |
| | | d = new BigDecimal(speMoney); |
| | | c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d);//只有出行金额参与抽成,其余归属司机 |
| | | } |
| | | if(company.getIsSpeFixedOrProportional() == 1){//比例 |
| | | Double price = orderLogistics.getStartMoney() + orderLogistics.getMileageMoney() + orderLogistics.getWaitMoney() + orderLogistics.getDurationMoney() + orderLogistics.getLongDistanceMoney(); |
| | | d = new BigDecimal(price).multiply(new BigDecimal(speMoney).divide(new BigDecimal(100), new MathContext(2, RoundingMode.HALF_EVEN))); |
| | | c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN); |
| | | } |
| | | incomeService.saveData(1, orderLogistics.getCompanyId(), 2, orderLogistics.getId(), 4, d.doubleValue()); |
| | | incomeService.saveData(2, orderLogistics.getDriverId(), 2, orderLogistics.getId(), 4, c.doubleValue()); |
| | | Driver driver = driverService.selectById(orderLogistics.getDriverId()); |
| | | driver.setBusinessMoney(new BigDecimal(null != driver.getBusinessMoney() ? driver.getBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driver.setLaveBusinessMoney(new BigDecimal(null != driver.getLaveBusinessMoney() ? driver.getLaveBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driverService.updateById(driver); |
| | | |
| | | //添加已收入明细 |
| | | Company company = companyService.selectById(orderLogistics.getCompanyId()); |
| | | Double speMoney = company.getSpeMoney(); |
| | | BigDecimal d = null;//企业收入 |
| | | BigDecimal c = null;//司机收入 |
| | | if(company.getIsSpeFixedOrProportional() == 2){//固定 |
| | | d = new BigDecimal(speMoney); |
| | | c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d);//只有出行金额参与抽成,其余归属司机 |
| | | } |
| | | if(company.getIsSpeFixedOrProportional() == 1){//比例 |
| | | Double price = orderLogistics.getStartMoney() + orderLogistics.getMileageMoney() + orderLogistics.getWaitMoney() + orderLogistics.getDurationMoney() + orderLogistics.getLongDistanceMoney(); |
| | | d = new BigDecimal(price).multiply(new BigDecimal(speMoney).divide(new BigDecimal(100), new MathContext(2, RoundingMode.HALF_EVEN))); |
| | | c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN); |
| | | } |
| | | incomeService.saveData(1, orderLogistics.getCompanyId(), 2, orderLogistics.getId(), 4, d.doubleValue()); |
| | | incomeService.saveData(2, orderLogistics.getDriverId(), 2, orderLogistics.getId(), 4, c.doubleValue()); |
| | | Driver driver = driverService.selectById(orderLogistics.getDriverId()); |
| | | driver.setBusinessMoney(new BigDecimal(null != driver.getBusinessMoney() ? driver.getBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driver.setLaveBusinessMoney(new BigDecimal(null != driver.getLaveBusinessMoney() ? driver.getLaveBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driverService.updateById(driver); |
| | | |
| | | // TODO: 2020/5/24 这里需要给司机和用户推送订单状态 |
| | | new Thread(new Runnable() { |
| | |
| | | Document document = Jsoup.parse(new File(path), "UTF-8"); |
| | | SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd"); |
| | | SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| | | Driver driver = driverService.selectById(orderLogistics.getDriverId()); |
| | | driver = driverService.selectById(orderLogistics.getDriverId()); |
| | | Car car = carMapper.selectById(orderLogistics.getCarId()); |
| | | Double aDouble = 0D; |
| | | if(null != orderLogistics.getDriverId()){ |
| | |
| | | driverService.updateById(driver); |
| | | } |
| | | |
| | | if((orderLogistics.getState() == 10 || orderLogistics.getState() == 12) && null != orderLogistics.getDriverId()){ |
| | | if(orderLogistics.getState() == 10 || orderLogistics.getState() == 12){ |
| | | //修改行程信息 |
| | | boolean updateTrip = fleetEngineUtil.updateTrip("CANCELED", null, null, orderLogistics.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | Thread.sleep(3000L); |
| | | } |
| | | } |
| | | } |
| | | log.warn("取消订单:{} {}", System.currentTimeMillis(), orderLogistics.getTripId()); |
| | | //添加消息 |
| | | systemNoticeService.addSystemNotice(1, language == 1 ? "您已成功取消包裹订单,谢谢使用!" : language == 2 ? "You've cancelled the delivery order successfully, thank you for using I-GO " |
| | | : "Vous avez annulé la commande de livraison avec succès, merci d’utiliser I-GO", orderLogistics.getUserId(), 1); |
| | |
| | | userInfo.setLanguage(language); |
| | | userInfoService.updateById(userInfo); |
| | | |
| | | new Thread(() -> { |
| | | try { |
| | | if(null != orderPrivateCar.getDriverId()){ |
| | | Driver driver = driverService.selectById(orderPrivateCar.getDriverId()); |
| | | Car car = carMapper.selectById(driver.getCarId()); |
| | | if(!StringUtils.hasLength(car.getVehicleId())){ |
| | | car.setVehicleId(UUIDUtil.getRandomCode()); |
| | | carMapper.updateById(car); |
| | | } |
| | | String vehicleId = car.getVehicleId(); |
| | | //查询车辆信息,没有则创建信息 |
| | | String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId()); |
| | | if(ToolUtil.isEmpty(vehicles)){ |
| | | CarModel carModel = carModelMapper.selectById(car.getCarModelId()); |
| | | boolean createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!createVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(createVehicles){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | //google创建车辆信息 |
| | | String vehicleId = null; |
| | | if(null != orderPrivateCar.getDriverId()) { |
| | | Driver driver = driverService.selectById(orderPrivateCar.getDriverId()); |
| | | Car car = carMapper.selectById(driver.getCarId()); |
| | | if (!StringUtils.hasLength(car.getVehicleId())) { |
| | | car.setVehicleId(UUIDUtil.getRandomCode()); |
| | | carMapper.updateById(car); |
| | | } |
| | | vehicleId = car.getVehicleId(); |
| | | //查询车辆信息,没有则创建信息 |
| | | String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId()); |
| | | if (ToolUtil.isEmpty(vehicles)) { |
| | | CarModel carModel = carModelMapper.selectById(car.getCarModelId()); |
| | | boolean createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if (!createVehicles) { |
| | | for (int i = 0; i < 5; i++) { |
| | | createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if (createVehicles) { |
| | | break; |
| | | } |
| | | boolean updateVehicles = fleetEngineUtil.updateVehicles("ONLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!updateVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateVehicles = fleetEngineUtil.updateVehicles("ONLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(updateVehicles){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //创建行程数据 |
| | | boolean createTrip = fleetEngineUtil.createTrip(vehicleId, 1, orderPrivateCar.getTripId(), |
| | | orderPrivateCar.getStartLat().toString(), orderPrivateCar.getStartLon().toString(), orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString()); |
| | | if(!createTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createTrip = fleetEngineUtil.createTrip(vehicleId, 1, orderPrivateCar.getTripId(), |
| | | orderPrivateCar.getStartLat().toString(), orderPrivateCar.getStartLon().toString(), orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString()); |
| | | if(createTrip){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | } |
| | | |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | boolean updateVehicles = fleetEngineUtil.updateVehicles("ONLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if (!updateVehicles) { |
| | | for (int i = 0; i < 5; i++) { |
| | | updateVehicles = fleetEngineUtil.updateVehicles("ONLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if (updateVehicles) { |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | } |
| | | } |
| | | }).start(); |
| | | } |
| | | //创建行程数据 |
| | | String trip = fleetEngineUtil.getTrip(orderPrivateCar.getTripId()); |
| | | int count = orderLogisticsService.selectCount(new EntityWrapper<OrderLogistics>().eq("tripId", orderPrivateCar.getTripId())); |
| | | int count1 = this.selectCount(new EntityWrapper<OrderPrivateCar>().eq("tripId", orderPrivateCar.getTripId())); |
| | | if(ToolUtil.isNotEmpty(trip) || (count + count1) > 0){ |
| | | String randomCode = UUIDUtil.getRandomCode(); |
| | | redisUtil.setStrValue("trip" + orderPrivateCar.getUserId(), randomCode); |
| | | OrderPrivateCar orderPrivateCar1 = new OrderPrivateCar(); |
| | | orderPrivateCar1.setId(orderPrivateCar.getId()); |
| | | orderPrivateCar1.setTripId(randomCode); |
| | | this.updateById(orderPrivateCar1); |
| | | orderPrivateCar.setTripId(randomCode); |
| | | } |
| | | JSONObject createTrip = fleetEngineUtil.createTrip(vehicleId, 1, orderPrivateCar.getTripId(), |
| | | orderPrivateCar.getStartLat().toString(), orderPrivateCar.getStartLon().toString(), orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString()); |
| | | JSONObject error = createTrip.getJSONObject("error"); |
| | | if(null != error){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createTrip = fleetEngineUtil.createTrip(vehicleId, 1, orderPrivateCar.getTripId(), |
| | | orderPrivateCar.getStartLat().toString(), orderPrivateCar.getStartLon().toString(), orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString()); |
| | | error = createTrip.getJSONObject("error"); |
| | | String tripStatus = createTrip.getString("tripStatus"); |
| | | if(null == error && "NEW".equals(tripStatus)){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | if(orderSource == 2){//扫码下单 |
| | |
| | | } |
| | | |
| | | //修改行程信息 |
| | | if((orderPrivateCar.getState() == 10 || orderPrivateCar.getState() == 12) && null != orderPrivateCar.getDriverId()){ |
| | | if(orderPrivateCar.getState() == 10 || orderPrivateCar.getState() == 12){ |
| | | boolean updateTrip = fleetEngineUtil.updateTrip("CANCELED", null, null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | Thread.sleep(3000L); |
| | | } |
| | | } |
| | | } |
| | | log.warn("取消订单:{} {}", System.currentTimeMillis(), orderPrivateCar.getTripId()); |
| | | //添加消息 |
| | | systemNoticeService.addSystemNotice(1, language == 1 ? "您已成功取消出行订单,谢谢使用!" : language == 2 ? "You've cancelled the ride order successfully, thank you for using I-GO " : "Vous avez annulé la commande de course avec succès, merci d’utiliser I-GO", orderPrivateCar.getUserId(), 1); |
| | | Map<String, Object> map = new HashMap<>(); |
| | |
| | | userCouponRecord.setEndTime(new Date()); |
| | | userCouponRecordService.updateById(userCouponRecord); |
| | | } |
| | | |
| | | if(orderPrivateCar.getIsplatPay()==1){ |
| | | //添加已收入明细 |
| | | Company company = companyService.selectById(orderPrivateCar.getCompanyId()); |
| | | Double speMoney = company.getSpeMoney(); |
| | | BigDecimal d = null;//企业收入 |
| | | BigDecimal c = null;//司机收入 |
| | | if(company.getIsSpeFixedOrProportional() == 2){//固定 |
| | | d = new BigDecimal(speMoney); |
| | | c = new BigDecimal(orderPrivateCar.getOrderMoney()).subtract(d);//只有出行金额参与抽成,其余归属司机 |
| | | } |
| | | if(company.getIsSpeFixedOrProportional() == 1){//比例 |
| | | Double price = orderPrivateCar.getStartMoney() + orderPrivateCar.getMileageMoney() + orderPrivateCar.getWaitMoney() + orderPrivateCar.getDurationMoney() + orderPrivateCar.getLongDistanceMoney(); |
| | | d = new BigDecimal(price).multiply(new BigDecimal(speMoney).divide(new BigDecimal(100), new MathContext(2, RoundingMode.HALF_EVEN))); |
| | | c = new BigDecimal(orderPrivateCar.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN); |
| | | } |
| | | incomeService.saveData(1, orderPrivateCar.getCompanyId(), 2, orderPrivateCar.getId(), 1, d.doubleValue()); |
| | | incomeService.saveData(2, orderPrivateCar.getDriverId(), 2, orderPrivateCar.getId(), 1, c.doubleValue()); |
| | | Driver driver = driverService.selectById(orderPrivateCar.getDriverId()); |
| | | driver.setBusinessMoney(new BigDecimal(null != driver.getBusinessMoney() ? driver.getBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driver.setLaveBusinessMoney(new BigDecimal(null != driver.getLaveBusinessMoney() ? driver.getLaveBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driverService.updateById(driver); |
| | | |
| | | //添加已收入明细 |
| | | Company company = companyService.selectById(orderPrivateCar.getCompanyId()); |
| | | Double speMoney = company.getSpeMoney(); |
| | | BigDecimal d = null;//企业收入 |
| | | BigDecimal c = null;//司机收入 |
| | | if(company.getIsSpeFixedOrProportional() == 2){//固定 |
| | | d = new BigDecimal(speMoney); |
| | | c = new BigDecimal(orderPrivateCar.getOrderMoney()).subtract(d);//只有出行金额参与抽成,其余归属司机 |
| | | } |
| | | if(company.getIsSpeFixedOrProportional() == 1){//比例 |
| | | Double price = orderPrivateCar.getStartMoney() + orderPrivateCar.getMileageMoney() + orderPrivateCar.getWaitMoney() + orderPrivateCar.getDurationMoney() + orderPrivateCar.getLongDistanceMoney(); |
| | | d = new BigDecimal(price).multiply(new BigDecimal(speMoney).divide(new BigDecimal(100), new MathContext(2, RoundingMode.HALF_EVEN))); |
| | | c = new BigDecimal(orderPrivateCar.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN); |
| | | } |
| | | incomeService.saveData(1, orderPrivateCar.getCompanyId(), 2, orderPrivateCar.getId(), 1, d.doubleValue()); |
| | | incomeService.saveData(2, orderPrivateCar.getDriverId(), 2, orderPrivateCar.getId(), 1, c.doubleValue()); |
| | | Driver driver = driverService.selectById(orderPrivateCar.getDriverId()); |
| | | driver.setBusinessMoney(new BigDecimal(null != driver.getBusinessMoney() ? driver.getBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driver.setLaveBusinessMoney(new BigDecimal(null != driver.getLaveBusinessMoney() ? driver.getLaveBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driverService.updateById(driver); |
| | | |
| | | if(ToolUtil.isNotEmpty(userInfo.getEmail())){ |
| | | new Thread(new Runnable() { |
| | |
| | | driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driverService.updateById(driver); |
| | | } |
| | | |
| | | |
| | | if(orderPrivateCar.getIsplatPay()==1){ |
| | | //添加已收入明细 |
| | | Company company = companyService.selectById(orderPrivateCar.getCompanyId()); |
| | | Double speMoney = company.getSpeMoney(); |
| | | BigDecimal d = null;//企业收入 |
| | | BigDecimal c = null;//司机收入 |
| | | if(company.getIsSpeFixedOrProportional() == 2){//固定 |
| | | d = new BigDecimal(speMoney); |
| | | c = new BigDecimal(orderPrivateCar.getOrderMoney()).subtract(d);//只有出行金额参与抽成,其余归属司机 |
| | | } |
| | | if(company.getIsSpeFixedOrProportional() == 1){//比例 |
| | | Double price = orderPrivateCar.getStartMoney() + orderPrivateCar.getMileageMoney() + orderPrivateCar.getWaitMoney() + orderPrivateCar.getDurationMoney() + orderPrivateCar.getLongDistanceMoney(); |
| | | d = new BigDecimal(price).multiply(new BigDecimal(speMoney).divide(new BigDecimal(100), new MathContext(2, RoundingMode.HALF_EVEN))); |
| | | c = new BigDecimal(orderPrivateCar.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN); |
| | | } |
| | | |
| | | |
| | | //添加已收入明细 |
| | | Company company = companyService.selectById(orderPrivateCar.getCompanyId()); |
| | | Double speMoney = company.getSpeMoney(); |
| | | BigDecimal d = null;//企业收入 |
| | | BigDecimal c = null;//司机收入 |
| | | if(company.getIsSpeFixedOrProportional() == 2){//固定 |
| | | d = new BigDecimal(speMoney); |
| | | c = new BigDecimal(orderPrivateCar.getOrderMoney()).subtract(d);//只有出行金额参与抽成,其余归属司机 |
| | | } |
| | | if(company.getIsSpeFixedOrProportional() == 1){//比例 |
| | | Double price = orderPrivateCar.getStartMoney() + orderPrivateCar.getMileageMoney() + orderPrivateCar.getWaitMoney() + orderPrivateCar.getDurationMoney() + orderPrivateCar.getLongDistanceMoney(); |
| | | d = new BigDecimal(price).multiply(new BigDecimal(speMoney).divide(new BigDecimal(100), new MathContext(2, RoundingMode.HALF_EVEN))); |
| | | c = new BigDecimal(orderPrivateCar.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN); |
| | | } |
| | | // incomeService.saveData(1, orderPrivateCar.getCompanyId(), 2, orderPrivateCar.getId(), 1, d.doubleValue()); |
| | | // incomeService.saveData(2, orderPrivateCar.getDriverId(), 2, orderPrivateCar.getId(), 1, c.doubleValue()); |
| | | |
| | |
| | | // driver.setLaveBusinessMoney(new BigDecimal(null != driver.getLaveBusinessMoney() ? driver.getLaveBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | // driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | // driverService.updateById(driver); |
| | | |
| | | |
| | | //记录司机待结算金额 |
| | | if(d.compareTo(new BigDecimal(0)) > 0){ |
| | | SettlementDetail settlementDetail = new SettlementDetail(); |
| | | settlementDetail.setOrderId(orderId); |
| | | settlementDetail.setOrderType(1); |
| | | settlementDetail.setDriverId(driver.getId()); |
| | | settlementDetail.setOrderMoney(orderPrivateCar.getOrderMoney()); |
| | | settlementDetail.setPrice(d.doubleValue()); |
| | | settlementDetail.setCreateTime(new Date()); |
| | | settlementDetailService.insert(settlementDetail); |
| | | |
| | | SettlementAllocation settlementAllocation = settlementAllocationService.selectOne(null); |
| | | if(null != settlementAllocation){ |
| | | JSONObject jsonObject = JSON.parseObject(settlementAllocation.getContent()); |
| | | Double maxPrice = jsonObject.getDouble("maxPrice"); |
| | | Integer type1 = jsonObject.getInteger("type"); |
| | | if(null != maxPrice){ |
| | | List<SettlementDetail> settlementDetailList = settlementDetailService.selectList(new EntityWrapper<SettlementDetail>().eq("driverId", driver.getId()) |
| | | .isNull("settlementRecordId").last(" and DATE_FORMAT(now(), '%Y-%m-%d') = DATE_FORMAT(createTime, '%Y-%m-%d')")); |
| | | BigDecimal total = new BigDecimal(0); |
| | | for (SettlementDetail detail : settlementDetailList) { |
| | | total = total.add(new BigDecimal(detail.getPrice())); |
| | | } |
| | | //日结算 |
| | | if(maxPrice.compareTo(total.doubleValue()) <= 0){ |
| | | SettlementRecord settlementRecord = settlementRecordService.selectOne(new EntityWrapper<SettlementRecord>().eq("driverId", orderPrivateCar.getDriverId()) |
| | | .eq("type", type1).eq("paymentStatus", 1).last(" and day = DATE_FORMAT(now(), '%Y-%m-%d')")); |
| | | if(null == settlementRecord){ |
| | | settlementRecord = new SettlementRecord(); |
| | | settlementRecord.setDay(new Date()); |
| | | settlementRecord.setDriverId(orderPrivateCar.getDriverId()); |
| | | settlementRecord.setType(type1); |
| | | settlementRecord.setPaymentStatus(1); |
| | | settlementRecord.setPayMoney(total.doubleValue()); |
| | | settlementRecord.setInsertTime(new Date()); |
| | | settlementRecordService.insert(settlementRecord); |
| | | }else{ |
| | | settlementRecord.setPayMoney(settlementRecord.getPayMoney() + total.doubleValue()); |
| | | settlementRecordService.updateById(settlementRecord); |
| | | } |
| | | for (SettlementDetail detail : settlementDetailList) { |
| | | detail.setSettlementRecordId(settlementRecord.getId()); |
| | | settlementDetailService.updateById(detail); |
| | | } |
| | | //强制司机下班 |
| | | DriverWork driverWork = driverWorkService.selectOne(new EntityWrapper<DriverWork>() |
| | | .eq("driverId", orderPrivateCar.getDriverId()).eq("state", 1)); |
| | | if(null != driverWork){ |
| | | driverWork.setEndTime(new Date()); |
| | | driverWork.setState(2); |
| | | driverWorkService.updateById(driverWork); |
| | | driver.setState(1); |
| | | driverService.updateById(driver); |
| | | Car car = carService.selectById(driver.getCarId()); |
| | | if(!org.apache.shiro.util.StringUtils.hasLength(car.getVehicleId())){ |
| | | car.setVehicleId(UUIDUtil.getRandomCode()); |
| | | carService.updateById(car); |
| | | } |
| | | |
| | | //司机下班,修改谷歌上的车辆信息 |
| | | new Thread(()->{ |
| | | try { |
| | | CarModel carModel = carModelMapper.selectById(car.getCarModelId()); |
| | | String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId()); |
| | | if(ToolUtil.isEmpty(vehicles)){ |
| | | boolean createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!createVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(createVehicles){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | |
| | | //记录司机待结算金额 |
| | | if(d.compareTo(new BigDecimal(0)) > 0){ |
| | | SettlementDetail settlementDetail = new SettlementDetail(); |
| | | settlementDetail.setOrderId(orderId); |
| | | settlementDetail.setOrderType(1); |
| | | settlementDetail.setDriverId(driver.getId()); |
| | | settlementDetail.setOrderMoney(orderPrivateCar.getOrderMoney()); |
| | | settlementDetail.setPrice(d.doubleValue()); |
| | | settlementDetail.setCreateTime(new Date()); |
| | | settlementDetailService.insert(settlementDetail); |
| | | |
| | | SettlementAllocation settlementAllocation = settlementAllocationService.selectOne(null); |
| | | if(null != settlementAllocation){ |
| | | JSONObject jsonObject = JSON.parseObject(settlementAllocation.getContent()); |
| | | Double maxPrice = jsonObject.getDouble("maxPrice"); |
| | | Integer type1 = jsonObject.getInteger("type"); |
| | | if(null != maxPrice){ |
| | | List<SettlementDetail> settlementDetailList = settlementDetailService.selectList(new EntityWrapper<SettlementDetail>().eq("driverId", driver.getId()) |
| | | .isNull("settlementRecordId").last(" and DATE_FORMAT(now(), '%Y-%m-%d') = DATE_FORMAT(createTime, '%Y-%m-%d')")); |
| | | BigDecimal total = new BigDecimal(0); |
| | | for (SettlementDetail detail : settlementDetailList) { |
| | | total = total.add(new BigDecimal(detail.getPrice())); |
| | | } |
| | | //日结算 |
| | | if(maxPrice.compareTo(total.doubleValue()) <= 0){ |
| | | SettlementRecord settlementRecord = settlementRecordService.selectOne(new EntityWrapper<SettlementRecord>().eq("driverId", orderPrivateCar.getDriverId()) |
| | | .eq("type", type1).eq("paymentStatus", 1).last(" and day = DATE_FORMAT(now(), '%Y-%m-%d')")); |
| | | if(null == settlementRecord){ |
| | | settlementRecord = new SettlementRecord(); |
| | | settlementRecord.setDay(new Date()); |
| | | settlementRecord.setDriverId(orderPrivateCar.getDriverId()); |
| | | settlementRecord.setType(type1); |
| | | settlementRecord.setPaymentStatus(1); |
| | | settlementRecord.setPayMoney(total.doubleValue()); |
| | | settlementRecord.setInsertTime(new Date()); |
| | | settlementRecordService.insert(settlementRecord); |
| | | }else{ |
| | | settlementRecord.setPayMoney(settlementRecord.getPayMoney() + total.doubleValue()); |
| | | settlementRecordService.updateById(settlementRecord); |
| | | } |
| | | for (SettlementDetail detail : settlementDetailList) { |
| | | detail.setSettlementRecordId(settlementRecord.getId()); |
| | | settlementDetailService.updateById(detail); |
| | | } |
| | | //强制司机下班 |
| | | DriverWork driverWork = driverWorkService.selectOne(new EntityWrapper<DriverWork>() |
| | | .eq("driverId", orderPrivateCar.getDriverId()).eq("state", 1)); |
| | | if(null != driverWork){ |
| | | driverWork.setEndTime(new Date()); |
| | | driverWork.setState(2); |
| | | driverWorkService.updateById(driverWork); |
| | | driver.setState(1); |
| | | driverService.updateById(driver); |
| | | Car car = carService.selectById(driver.getCarId()); |
| | | if(!org.apache.shiro.util.StringUtils.hasLength(car.getVehicleId())){ |
| | | car.setVehicleId(UUIDUtil.getRandomCode()); |
| | | carService.updateById(car); |
| | | } |
| | | |
| | | //司机下班,修改谷歌上的车辆信息 |
| | | new Thread(()->{ |
| | | try { |
| | | CarModel carModel = carModelMapper.selectById(car.getCarModelId()); |
| | | String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId()); |
| | | if(ToolUtil.isEmpty(vehicles)){ |
| | | boolean createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!createVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(createVehicles){ |
| | | break; |
| | | } |
| | | } |
| | | boolean updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!updateVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(updateVehicles){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | } |
| | | }else{ |
| | | boolean updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!updateVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(updateVehicles){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | boolean updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!updateVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(updateVehicles){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | } |
| | | }else{ |
| | | boolean updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(!updateVehicles){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); |
| | | if(updateVehicles){ |
| | | break; |
| | | } |
| | | Thread.sleep(5000L); |
| | | } |
| | | } |
| | | } |
| | | }).start(); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | }).start(); |
| | | } |
| | | } |
| | | } |
| | |
| | | query.setState(2); |
| | | query.setCode(order_id); |
| | | paymentRecordService.updateById(query); |
| | | if(orderPrivateCar.getIsplatPay()==1){ |
| | | //添加已收入明细 |
| | | Company company = companyService.selectById(orderPrivateCar.getCompanyId()); |
| | | Double taxi = company.getSpeMoney(); |
| | | BigDecimal d = null;//企业收入 |
| | | BigDecimal c = null;//司机收入 |
| | | if(company.getIsSpeFixedOrProportional() == 2){//固定 |
| | | d = new BigDecimal(taxi); |
| | | c = new BigDecimal(orderPrivateCar.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN); |
| | | } |
| | | if(company.getIsSpeFixedOrProportional() == 1){//比例 |
| | | Double price = orderPrivateCar.getStartMoney() + orderPrivateCar.getMileageMoney() + orderPrivateCar.getWaitMoney() + orderPrivateCar.getDurationMoney() + orderPrivateCar.getLongDistanceMoney(); |
| | | d = new BigDecimal(price).multiply(new BigDecimal(taxi).divide(new BigDecimal(100), new MathContext(2, RoundingMode.HALF_EVEN))); |
| | | c = new BigDecimal(orderPrivateCar.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN); |
| | | } |
| | | incomeService.saveData(1, orderPrivateCar.getCompanyId(), 2, orderPrivateCar.getId(), 1, d.doubleValue()); |
| | | incomeService.saveData(2, orderPrivateCar.getDriverId(), 2, orderPrivateCar.getId(), 1, c.doubleValue()); |
| | | Driver driver = driverService.selectById(orderPrivateCar.getDriverId()); |
| | | driver.setBusinessMoney(new BigDecimal(null != driver.getBusinessMoney() ? driver.getBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driver.setLaveBusinessMoney(new BigDecimal(null != driver.getLaveBusinessMoney() ? driver.getLaveBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driverService.updateById(driver); |
| | | //添加已收入明细 |
| | | Company company = companyService.selectById(orderPrivateCar.getCompanyId()); |
| | | Double taxi = company.getSpeMoney(); |
| | | BigDecimal d = null;//企业收入 |
| | | BigDecimal c = null;//司机收入 |
| | | if(company.getIsSpeFixedOrProportional() == 2){//固定 |
| | | d = new BigDecimal(taxi); |
| | | c = new BigDecimal(orderPrivateCar.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN); |
| | | } |
| | | if(company.getIsSpeFixedOrProportional() == 1){//比例 |
| | | Double price = orderPrivateCar.getStartMoney() + orderPrivateCar.getMileageMoney() + orderPrivateCar.getWaitMoney() + orderPrivateCar.getDurationMoney() + orderPrivateCar.getLongDistanceMoney(); |
| | | d = new BigDecimal(price).multiply(new BigDecimal(taxi).divide(new BigDecimal(100), new MathContext(2, RoundingMode.HALF_EVEN))); |
| | | c = new BigDecimal(orderPrivateCar.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN); |
| | | } |
| | | incomeService.saveData(1, orderPrivateCar.getCompanyId(), 2, orderPrivateCar.getId(), 1, d.doubleValue()); |
| | | incomeService.saveData(2, orderPrivateCar.getDriverId(), 2, orderPrivateCar.getId(), 1, c.doubleValue()); |
| | | Driver driver = driverService.selectById(orderPrivateCar.getDriverId()); |
| | | driver.setBusinessMoney(new BigDecimal(null != driver.getBusinessMoney() ? driver.getBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driver.setLaveBusinessMoney(new BigDecimal(null != driver.getLaveBusinessMoney() ? driver.getLaveBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driverService.updateById(driver); |
| | | |
| | | |
| | | if(ToolUtil.isNotEmpty(userInfo.getEmail())){ |
| | |
| | | |
| | | |
| | | List<Company> queryList(@Param("city") String[] city, @Param("type") Integer type); |
| | | |
| | | |
| | | List<Company> queryList1(@Param("collect") List<Integer> collect, @Param("type") Integer type); |
| | | } |
| | |
| | | * 根据行政区域获取设置的电话 |
| | | * @return |
| | | */ |
| | | List<Phone> queryPhones(@Param("city") String[] city); |
| | | List<Phone> queryPhones(@Param("companyIds") List<Integer> companyIds); |
| | | |
| | | |
| | | /** |
| | |
| | | * @return |
| | | */ |
| | | Phone query(@Param("type") Integer type, @Param("platform") Integer platform, |
| | | @Param("city") String[] city); |
| | | @Param("companyId") Integer companyId); |
| | | } |
| | |
| | | and type = #{type} |
| | | </if> |
| | | </select> |
| | | |
| | | |
| | | |
| | | <select id="queryList1" resultType="Company"> |
| | | select |
| | | id as id, |
| | | isSpe as isSpe, |
| | | isTaxi as isTaxi, |
| | | isCross as isCross, |
| | | isCrossLogistics as isCrossLogistics, |
| | | isSameLogistics as isSameLogistics, |
| | | isCharter as isCharter, |
| | | isSpeFixedOrProportional as isSpeFixedOrProportional, |
| | | isTaxiFixedOrProportional as isTaxiFixedOrProportional, |
| | | isCrossLogisticsFixedOrProportional as isCrossLogisticsFixedOrProportional, |
| | | isSameLogisticsFixedOrProportional as isSameLogisticsFixedOrProportional, |
| | | speMoney as speMoney, |
| | | taxiMoney as taxiMoney, |
| | | crossLogisticsMoney as crossLogisticsMoney, |
| | | sameLogisticsMoney as sameLogisticsMoney, |
| | | isNeedFerry as isNeedFerry, |
| | | name as name, |
| | | type as type, |
| | | superiorId as superiorId, |
| | | principalName as principalName, |
| | | principalPhone as principalPhone, |
| | | adminName as adminName, |
| | | adminPhone as adminPhone, |
| | | urgentPhoen as urgentPhoen, |
| | | setupTime as setupTime, |
| | | identifier as identifier, |
| | | addressCode as addressCode, |
| | | businessScope as businessScope, |
| | | contactAddress as contactAddress, |
| | | documentAddress as documentAddress, |
| | | economicType as economicType, |
| | | regCapital as regCapital, |
| | | legalName as legalName, |
| | | legalId as legalId, |
| | | legalPhone as legalPhone, |
| | | legalPhotoUrl as legalPhotoUrl, |
| | | licensingAgency as licensingAgency, |
| | | licenseTime as licenseTime, |
| | | licenseStartTime as licenseStartTime, |
| | | licenseEndTime as licenseEndTime, |
| | | licenseNumber as licenseNumber, |
| | | carNum as carNum, |
| | | driverNum as driverNum, |
| | | mac as mac, |
| | | state as state, |
| | | flag as flag, |
| | | upload as upload, |
| | | insertTime as insertTime |
| | | from t_company where flag != 3 and state = 0 and id in ( |
| | | select companyId from t_company_city where state = 1 |
| | | <if test="null != city"> |
| | | and cityId in |
| | | <foreach collection="collect" item="item" index="index" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> |
| | | </if> |
| | | ) |
| | | <if test="null != type"> |
| | | and type = #{type} |
| | | </if> |
| | | </select> |
| | | </mapper> |
| | |
| | | platform as platform, |
| | | phone as phone, |
| | | companyId as companyId |
| | | from t_phone where companyId in ( |
| | | select companyId from t_company_city where state = 1 |
| | | <if test="null != city"> |
| | | and cityId in (select id from t_city where englishName in |
| | | <foreach collection="city" item="item" index="index" separator="," open="(" close=")"> |
| | | #{item} |
| | | </foreach> |
| | | ) |
| | | </if> |
| | | from t_phone where companyId in |
| | | <foreach collection="companyIds" item="item" index="index" separator="," open="(" close=")"> |
| | | #{item} |
| | | </foreach> |
| | | ) |
| | | </select> |
| | | |
| | |
| | | and platform = #{platform} |
| | | </if> |
| | | <if test="platform != 1"> |
| | | and companyId in ( |
| | | select companyId from t_company_city where state = 1 |
| | | <if test="null != city"> |
| | | and cityId in (select id from t_city where englishName in |
| | | <foreach collection="city" item="item" index="index" separator="," open="(" close=")"> |
| | | #{item} |
| | | </foreach> |
| | | ) |
| | | </if> |
| | | ) |
| | | and companyId = #{companyId} |
| | | </if> |
| | | </select> |
| | | |
| | |
| | | import com.stylefeng.guns.modular.system.model.Company; |
| | | import com.stylefeng.guns.modular.system.model.CompanyCity; |
| | | |
| | | import java.util.List; |
| | | |
| | | public interface ICompanyCityService extends IService<CompanyCity> { |
| | | |
| | | |
| | |
| | | * @throws Exception |
| | | */ |
| | | Company query(String[] city) throws Exception; |
| | | |
| | | |
| | | /** |
| | | * 根据城市名称获取匹配的企业 |
| | | * @param city |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | Company query1(String[] city) throws Exception; |
| | | |
| | | |
| | | /** |
| | | * 根据城市名称获取匹配的企业 |
| | | * @param city |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | List<Company> query2(String[] city) throws Exception; |
| | | } |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | |
| | | @Override |
| | | public Company query(String[] city) throws Exception { |
| | | List<City> cities = cityService.selectList(new EntityWrapper<City>().in("chineseName", Arrays.asList(city)).or() |
| | | .in("englishName", Arrays.asList(city)).or().in("frenchName", Arrays.asList(city))); |
| | | List<Integer> collect = cities.stream().map(City::getId).collect(Collectors.toList()); |
| | | List<City> cities1 = cityService.selectList(null); |
| | | List<Integer> collect = new ArrayList<>(); |
| | | for (City city1 : cities1) { |
| | | String chineseName = city1.getChineseName(); |
| | | String englishName = city1.getEnglishName(); |
| | | String frenchName = city1.getFrenchName(); |
| | | for (String s : city) { |
| | | if(s.indexOf(chineseName) != -1 || s.indexOf(englishName) != -1 || s.indexOf(frenchName) != -1){ |
| | | collect.add(city1.getId()); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | if(collect.size() == 0){ |
| | | return null; |
| | | } |
| | | return companyMapper.query(collect); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Company query1(String[] city) throws Exception { |
| | | List<City> cities1 = cityService.selectList(null); |
| | | List<Integer> collect = new ArrayList<>(); |
| | | for (City city1 : cities1) { |
| | | String chineseName = city1.getChineseName(); |
| | | String englishName = city1.getEnglishName(); |
| | | String frenchName = city1.getFrenchName(); |
| | | for (String s : city) { |
| | | if(s.indexOf(chineseName) != -1 || s.indexOf(englishName) != -1 || s.indexOf(frenchName) != -1){ |
| | | collect.add(city1.getId()); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | List<Company> query = companyMapper.queryList1(collect, 3); |
| | | if(query.size() == 0){ |
| | | query = companyMapper.queryList1(collect, 2); |
| | | } |
| | | if(query.size() == 0){ |
| | | query = companyMapper.queryList1(collect, 1); |
| | | } |
| | | if(query.size() > 0){ |
| | | return query.get(0); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public List<Company> query2(String[] city) throws Exception { |
| | | List<City> cities1 = cityService.selectList(null); |
| | | List<Integer> collect = new ArrayList<>(); |
| | | for (City city1 : cities1) { |
| | | String chineseName = city1.getChineseName(); |
| | | String englishName = city1.getEnglishName(); |
| | | String frenchName = city1.getFrenchName(); |
| | | for (String s : city) { |
| | | if(s.indexOf(chineseName) != -1 || s.indexOf(englishName) != -1 || s.indexOf(frenchName) != -1){ |
| | | collect.add(city1.getId()); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | List<Company> query = companyMapper.queryList1(collect, 3); |
| | | if(query.size() == 0){ |
| | | query = companyMapper.queryList1(collect, 2); |
| | | } |
| | | if(query.size() == 0){ |
| | | query = companyMapper.queryList1(collect, 1); |
| | | } |
| | | return query; |
| | | } |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.stylefeng.guns.modular.system.dao.PhoneMapper; |
| | | import com.stylefeng.guns.modular.system.model.Company; |
| | | import com.stylefeng.guns.modular.system.model.Phone; |
| | | import com.stylefeng.guns.modular.system.service.ICompanyCityService; |
| | | import com.stylefeng.guns.modular.system.service.IPhoneService; |
| | | import com.stylefeng.guns.modular.system.util.GoogleMap.AddressComponentsVo; |
| | | import com.stylefeng.guns.modular.system.util.GoogleMap.GoogleMapUtil; |
| | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | |
| | | @Service |
| | |
| | | |
| | | @Resource |
| | | private RedisUtil redisUtil; |
| | | |
| | | @Resource |
| | | private ICompanyCityService companyCityService; |
| | | |
| | | |
| | | |
| | |
| | | for (int i = 0; i < addressComponentsVos.length; i++) { |
| | | city[i] = addressComponentsVos[i].getLongName(); |
| | | } |
| | | List<Phone> list = phoneMapper.queryPhones(city); |
| | | List<Company> companies = companyCityService.query2(city); |
| | | List<Integer> collect = companies.stream().map(Company::getId).collect(Collectors.toList()); |
| | | List<Phone> list = phoneMapper.queryPhones(collect); |
| | | return list; |
| | | } |
| | | |
| | |
| | | } |
| | | Map<String, Object> map = new HashMap<>(); |
| | | //平台电话 |
| | | Phone query = phoneMapper.query(2, 1, city); |
| | | Phone query = phoneMapper.query(2, 1, null); |
| | | map.put("platform", null != query ? query.getPhone() : ""); |
| | | |
| | | |
| | | Company company = companyCityService.query1(city); |
| | | //公司 |
| | | query = phoneMapper.query(2, 2, city); |
| | | query = phoneMapper.query(2, 2, company.getId()); |
| | | map.put("company", null != query ? query.getPhone() : ""); |
| | | return map; |
| | | } |
| | |
| | | * @param end_lng 终点经度 |
| | | * @return |
| | | */ |
| | | public boolean createTrip(String vehicleId, Integer numberOfPassengers, String tripId, String start_lat, String start_lng, String end_lat, String end_lng) { |
| | | public JSONObject createTrip(String vehicleId, Integer numberOfPassengers, String tripId, String start_lat, String start_lng, String end_lat, String end_lng) { |
| | | String url = "https://fleetengine.googleapis.com/v1/providers/" + provider + "/trips?tripId=" + tripId; |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | | Map<String, String> headers = new HashMap<>(); |
| | |
| | | end_point.put("longitude", end_lng); |
| | | dropoffPoint.put("point", end_point); |
| | | body.put("dropoffPoint", dropoffPoint); |
| | | logger.info("创建行程请求:{}", body.toJSONString()); |
| | | logger.info("创建行程请求:{} {}", tripId, body.toJSONString()); |
| | | HttpRequest request = post.body(body.toJSONString()); |
| | | HttpResponse response = request.execute(); |
| | | logger.info("创建行程结果:{}", response.body()); |
| | |
| | | } |
| | | } |
| | | logger.error("创建行程异常: tripId={} body={}", tripId, response.body()); |
| | | return false; |
| | | } |
| | | /** |
| | | * 返回结果 |
| | |
| | | * "currentRouteSegmentTrafficVersion": "2024-05-27T02:05:37.941167Z" |
| | | * } |
| | | */ |
| | | return true; |
| | | return jsonObject; |
| | | } |
| | | |
| | | |
| | |
| | | dropoffPoint.put("point", end_point); |
| | | body.put("dropoffPoint", dropoffPoint); |
| | | } |
| | | logger.info("修改行程请求:{}", body.toJSONString()); |
| | | logger.info("修改行程请求:{} {}", tripId, body.toJSONString()); |
| | | HttpRequest request = put.body(body.toJSONString()); |
| | | HttpResponse response = request.execute(); |
| | | logger.info("修改行程结果:{}", response.body()); |
| | |
| | | headers.put("Content-Type", "application/json"); |
| | | get.addHeaders(headers); |
| | | |
| | | logger.info("查询行程请求:{} {}", tripId, url); |
| | | HttpResponse response = get.execute(); |
| | | logger.info("查询行程结果:{}", response.body()); |
| | | JSONObject jsonObject = JSON.parseObject(response.body().replaceAll("@type", "type")); |
| | |
| | | if(null != error){ |
| | | Integer code = error.getInteger("code"); |
| | | if(code == 404){ |
| | | return ""; |
| | | return null; |
| | | } |
| | | if(code == 401){ |
| | | String status = error.getString("status"); |
| | |
| | | import com.stylefeng.guns.modular.system.util.Tingg.model.CheckoutRequest; |
| | | import io.cellulant.model.Payload; |
| | | import io.cellulant.service.CheckoutEncryption; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.BufferedReader; |
| | |
| | | /** |
| | | * Tingg支付工具类 |
| | | */ |
| | | @Slf4j |
| | | public class TinggPayUtil { |
| | | |
| | | private static String accessKey = "8rc1gTV9n91Tc1Sy9oVWry99fgrgrVV8concf9onWooWSg9TVW8nSgo98g88"; |
| | |
| | | CheckoutEncryption checkoutEncrption = new CheckoutEncryption(ivKey, secretKey); |
| | | Payload payload = getPayload(checkoutRequest); |
| | | String param = checkoutEncrption.encrypt(payload); |
| | | System.out.println("Encrpted payload=" + param); |
| | | log.error("调起支付:" + checkoutRequest.getMerchantTransactionId() + "\nEncrpted payload=" + param); |
| | | String url = "https://checkout.tingg.africa/express/checkout?encrypted_payload=" + param + "&access_key=" + accessKey; |
| | | return ResultUtil.success(url); |
| | | }catch (Exception e){ |