| | |
| | | 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; |
| | | import com.stylefeng.guns.modular.specialTrain.dao.OrderPrivateCarMapper; |
| | | import com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar; |
| | | import com.stylefeng.guns.modular.specialTrain.server.IOrderPrivateCarService; |
| | | import com.stylefeng.guns.modular.system.dao.CarModelMapper; |
| | | import com.stylefeng.guns.modular.system.dao.RegionMapper; |
| | | import com.stylefeng.guns.modular.system.dao.SystemPriceMapper; |
| | | import com.stylefeng.guns.modular.system.dao.UserInfoMapper; |
| | | import com.stylefeng.guns.modular.system.model.*; |
| | | import com.stylefeng.guns.modular.system.service.*; |
| | | import com.stylefeng.guns.modular.system.util.*; |
| | | import com.stylefeng.guns.modular.system.util.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.quartz.QuartzUtil; |
| | | import com.stylefeng.guns.modular.system.util.quartz.jobs.OrderTimeOutJob; |
| | | import com.stylefeng.guns.modular.taxi.model.OrderTaxi; |
| | | import com.stylefeng.guns.modular.taxi.service.IOrderTaxiService; |
| | | import org.apache.shiro.util.StringUtils; |
| | | import org.quartz.JobDataMap; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | import java.io.FileWriter; |
| | | import java.io.PrintWriter; |
| | | import java.math.BigDecimal; |
| | | import java.math.MathContext; |
| | | import java.math.RoundingMode; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | |
| | | @Service |
| | | public class OrderPrivateCarServiceImpl extends ServiceImpl<OrderPrivateCarMapper, OrderPrivateCar> implements IOrderPrivateCarService { |
| | | |
| | | Logger log = LoggerFactory.getLogger(this.getClass()); |
| | | |
| | | @Resource |
| | | private OrderPrivateCarMapper orderPrivateCarMapper; |
| | |
| | | private GDMapElectricFenceUtil gdMapElectricFenceUtil; |
| | | |
| | | @Autowired |
| | | private PushMinistryOfTransportUtil pushMinistryOfTransportUtil; |
| | | |
| | | @Autowired |
| | | private IOrderTaxiService orderTaxiService; |
| | | |
| | | @Value("${pushMinistryOfTransport}") |
| | | private boolean pushMinistryOfTransport; |
| | | |
| | | |
| | | @Resource |
| | |
| | | @Autowired |
| | | private IIncomeService incomeService; |
| | | |
| | | @Autowired |
| | | private IPaymentRecordService paymentRecordService; |
| | | |
| | | @Autowired |
| | | private ITransactionDetailsService transactionDetailsService; |
| | | |
| | | |
| | | @Value("${filePath}") |
| | | private String filePath; |
| | | |
| | | @Autowired |
| | | private ISysOvertimeService sysOvertimeService; |
| | | |
| | | @Autowired |
| | | private FleetEngineUtil fleetEngineUtil; |
| | | |
| | | @Resource |
| | | private CarModelMapper carModelMapper; |
| | | |
| | | @Autowired |
| | | private ICarService carService; |
| | | |
| | | @Resource |
| | | private ICancleOrderService cancleOrderService; |
| | | |
| | | @Resource |
| | | private RedisUtil redisUtil; |
| | | |
| | | @Resource |
| | | private IOrderCancelService orderCancelService; |
| | | |
| | | @Resource |
| | | private QuartzUtil quartzUtil; |
| | | |
| | | |
| | | |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public List<Map<String, Object>> queryOrderList(Integer state, Integer driverId) throws Exception { |
| | | return orderPrivateCarMapper.queryOrderList(state, driverId); |
| | | public List<Map<String, Object>> queryOrderList(Integer state, Integer driverId, Integer language) throws Exception { |
| | | List<Map<String, Object>> list = orderPrivateCarMapper.queryOrderList(state, driverId, language); |
| | | for (Map<String, Object> map : list) { |
| | | if(null != map.get("time")){ |
| | | String time = map.get("time").toString(); |
| | | map.put("time", DateUtil.conversionFormat(language, time)); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public List<Map<String, Object>> queryMyAllOrder(Integer state, Integer uid) throws Exception { |
| | | return orderPrivateCarMapper.queryMyAllOrder(state, uid); |
| | | public List<Map<String, Object>> queryMyAllOrder(Integer state, Integer uid, Integer language) throws Exception { |
| | | List<Map<String, Object>> list = orderPrivateCarMapper.queryMyAllOrder(state, uid, language); |
| | | for (Map<String, Object> map : list) { |
| | | if(null != map.get("time")){ |
| | | String time = map.get("time").toString(); |
| | | map.put("time", DateUtil.conversionFormat(language, time)); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public Map<String, Object> queryPushOrder(Integer orderId) throws Exception { |
| | | return orderPrivateCarMapper.queryPushOrder(orderId); |
| | | public Map<String, Object> queryPushOrder(Integer orderId, Integer language) throws Exception { |
| | | Map<String, Object> map = orderPrivateCarMapper.queryPushOrder(orderId, language); |
| | | if(null != map.get("travelTime")){ |
| | | String travelTime = map.get("travelTime").toString(); |
| | | map.put("travelTime", DateUtil.conversionFormat1(language, travelTime)); |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public synchronized ResultUtil grabOrder(Integer orderId, Integer uid) throws Exception { |
| | | public synchronized ResultUtil grabOrder(Integer orderId, Integer uid, Integer language) throws Exception { |
| | | OrderPrivateCar orderPrivateCar = this.selectById(orderId); |
| | | String tripId = redisUtil.getValue("trip" + orderPrivateCar.getUserId()); |
| | | //处理摆渡车的情况 |
| | | if(orderPrivateCar.getType() == 2){ |
| | | //查看用户下的摆渡车是否已被人抢了 |
| | |
| | | .eq("place", orderPrivateCar.getPlace()) |
| | | ); |
| | | if(list.size() > 0 || list1.size() > 0){ |
| | | return ResultUtil.error("手速有点慢哦,订单已被抢啦!"); |
| | | return ResultUtil.error(language == 1 ? "手速有点慢哦,订单已被抢啦" : language == 2 ? "Too slow, order was snatched!" : "Trop lent, l’ordre a été arraché!"); |
| | | } |
| | | } |
| | | |
| | | if(orderPrivateCar.getState() == 9){ |
| | | return ResultUtil.error("订单已取消"); |
| | | if(orderPrivateCar.getState() == 10){ |
| | | return ResultUtil.error(language == 1 ? "订单已取消" : language == 2 ? "Order cancelled" : "Commande annulée"); |
| | | } |
| | | if(orderPrivateCar.getState() != 1){ |
| | | return ResultUtil.error("手速有点慢哦,订单已被抢啦!"); |
| | | return ResultUtil.error(language == 1 ? "手速有点慢哦,订单已被抢啦" : language == 2 ? "Too slow, order was snatched!" : "Trop lent, l’ordre a été arraché!"); |
| | | } |
| | | Driver driver = driverService.selectById(uid); |
| | | orderPrivateCar.setDriverId(uid); |
| | |
| | | driver.getCompanyId() != null && driver.getCompanyId() != 0 ? driver.getCompanyId() : 1)); |
| | | orderPrivateCar.setState(2); |
| | | orderPrivateCar.setSnatchOrderTime(new Date()); |
| | | |
| | | //调用高德创建轨迹 |
| | | // String s = gdFalconUtil.selectTerminal(driver.getPhone()); |
| | | // String track = gdFalconUtil.createTrack(s); |
| | | // orderPrivateCar.setTrackId(track); |
| | | |
| | | //调用移动的小号接口 |
| | | /*Map<String, String> geocode = gdMapGeocodingUtil.geocode(orderPrivateCar.getStartLon().toString(), orderPrivateCar.getStartLat().toString()); |
| | | Region region = regionMapper.query(geocode.get("districtCode"));*/ |
| | | // Map<String, String> map = chinaMobileUtil.midAxbBindSend(orderPrivateCar.getPassengersPhone(), driver.getPhone(), null); |
| | | // if(String.valueOf(map.get("code")).equals("200")){ |
| | | // orderPrivateCar.setTelX(map.get("telX")); |
| | | // orderPrivateCar.setBindId(map.get("bindId")); |
| | | // } |
| | | // System.out.println(map); |
| | | if(!StringUtils.hasLength(orderPrivateCar.getTripId())){ |
| | | orderPrivateCar.setTripId(UUIDUtil.getRandomCode()); |
| | | } |
| | | |
| | | if(orderPrivateCar.getOrderType() == 1){ |
| | | String value = redisUtil.getValue("DRIVER" + driver.getId()); |
| | | if(ToolUtil.isNotEmpty(value)) { |
| | | String[] split = value.split(","); |
| | | DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(orderPrivateCar.getStartLat(), orderPrivateCar.getStartLon(), Double.valueOf(split[1]), Double.valueOf(split[0]), tripId); |
| | | //超时时间 |
| | | long timeOut = System.currentTimeMillis() + (distancematrix.getDuration() * 1000); |
| | | orderPrivateCar.setEstimateArriveTime(new Date(timeOut)); |
| | | orderPrivateCar.setEstimateArriveMileage(distancematrix.getDistance()); |
| | | } |
| | | } |
| | | this.updateById(orderPrivateCar); |
| | | |
| | | //如果是预约单,则不修改司机为服务中 |
| | |
| | | driver.setState(3); |
| | | 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, orderPrivateCar.getId(), 1); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null, orderPrivateCar.getId(), 1); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 超时用户取消不收费的提醒 |
| | | * 预约单:行程时间 + 配置不收费的时间 > 当前时间 (只弹一次) |
| | | * 即时单:预估到达预约点时间 + 配置不收费的时间 > 当前时间 (只弹一次) |
| | | * |
| | | * 超时用户取消订单后需要弹给司机提醒弹框,超时时间 = 当前时间 - 行程时间 - 配置不收费的时间 |
| | | * |
| | | * 定时提醒弹框 |
| | | * 司机只要开始超时且还未到达预约点,则需要定时提醒 |
| | | * |
| | | * 预约单需要提前xx分钟提醒司机需要接乘客,过后每隔xx分钟提醒一次。超时后停止提醒 |
| | | */ |
| | | |
| | | //添加定时任务(普通任务) |
| | | SysOvertime reminderRules = sysOvertimeService.selectOne(new EntityWrapper<SysOvertime>().eq("companyId", driver.getCompanyId())); |
| | | if(null != reminderRules){ |
| | | CancleOrder cancleOrder = cancleOrderService.selectOne(new EntityWrapper<CancleOrder>().eq("companyId", driver.getCompanyId())); |
| | | Integer driverTimeout = JSON.parseObject(cancleOrder.getContent()).getInteger("driverTimeout"); |
| | | |
| | | //即时单 |
| | | if(orderPrivateCar.getOrderType() == 1){ |
| | | //超时时间 |
| | | long timeOut = orderPrivateCar.getEstimateArriveTime().getTime() + (driverTimeout * 60 * 1000); |
| | | //乘客取消不收费提醒 |
| | | JobDataMap jobDataMap = new JobDataMap(); |
| | | jobDataMap.put("driverId", uid); |
| | | jobDataMap.put("timeOutType", 1); |
| | | jobDataMap.put("orderId", orderPrivateCar.getId()); |
| | | jobDataMap.put("orderType", 1); |
| | | jobDataMap.put("language", language); |
| | | jobDataMap.put("timeOut", timeOut); |
| | | jobDataMap.put("driverTimeout", driverTimeout); |
| | | jobDataMap.put("describe", language == 1 ? "您已超时" + driverTimeout + "分钟,用户可免费取消订单" : language == 2 ? "Reminder You are overdue for " + driverTimeout + " minutes The subscriber could cancel the order for free Confirm" : "Rappel Vous êtes en retard de " + driverTimeout + " minutes L’abonné peut annuler la commande gratuitement Confirmer"); |
| | | quartzUtil.addSimpleQuartzTask(OrderTimeOutJob.class,"1_" + orderPrivateCar.getId() + "_1", "ORDER_TIME_OUT", jobDataMap |
| | | , new Date(timeOut), timeOut, 0); |
| | | |
| | | //超时循环提醒 |
| | | jobDataMap = new JobDataMap(); |
| | | jobDataMap.put("driverId", uid); |
| | | jobDataMap.put("timeOutType", 3); |
| | | jobDataMap.put("orderId", orderPrivateCar.getId()); |
| | | jobDataMap.put("orderType", 1); |
| | | jobDataMap.put("language", language); |
| | | jobDataMap.put("timeOut", orderPrivateCar.getEstimateArriveTime().getTime()); |
| | | jobDataMap.put("driverTimeout", 0); |
| | | jobDataMap.put("describe", ""); |
| | | quartzUtil.addSimpleQuartzTask(OrderTimeOutJob.class,"3_" + orderPrivateCar.getId() + "_1", "ORDER_TIME_OUT", jobDataMap |
| | | , orderPrivateCar.getEstimateArriveTime(), reminderRules.getCar() * 60000, -1); |
| | | }else{ |
| | | //超时时间 |
| | | long timeOut = orderPrivateCar.getTravelTime().getTime() + (driverTimeout * 60000); |
| | | //乘客取消不收费提醒 |
| | | JobDataMap jobDataMap = new JobDataMap(); |
| | | jobDataMap.put("driverId", uid); |
| | | jobDataMap.put("timeOutType", 1); |
| | | jobDataMap.put("orderId", orderPrivateCar.getId()); |
| | | jobDataMap.put("orderType", 1); |
| | | jobDataMap.put("language", language); |
| | | jobDataMap.put("timeOut", timeOut); |
| | | jobDataMap.put("driverTimeout", driverTimeout); |
| | | jobDataMap.put("describe", language == 1 ? "您已超时" + driverTimeout + "分钟,用户可免费取消订单" : language == 2 ? "Reminder You are overdue for " + driverTimeout + " minutes The subscriber could cancel the order for free Confirm" : "Rappel Vous êtes en retard de " + driverTimeout + " minutes L’abonné peut annuler la commande gratuitement Confirmer"); |
| | | quartzUtil.addSimpleQuartzTask(OrderTimeOutJob.class,"1_" + orderPrivateCar.getId() + "_1", "ORDER_TIME_OUT", jobDataMap |
| | | , new Date(timeOut), timeOut, 0); |
| | | |
| | | UserInfo userInfo = userInfoMapper.selectById(orderPrivateCar.getUserId()); |
| | | |
| | | //预约单出发首次提醒 |
| | | long travelTime = orderPrivateCar.getTravelTime().getTime() - reminderRules.getReserveTime() * 60000; |
| | | SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); |
| | | jobDataMap = new JobDataMap(); |
| | | jobDataMap.put("driverId", uid); |
| | | jobDataMap.put("timeOutType", 2); |
| | | jobDataMap.put("orderId", orderPrivateCar.getId()); |
| | | jobDataMap.put("orderType", 1); |
| | | jobDataMap.put("language", language); |
| | | jobDataMap.put("timeOut", timeOut); |
| | | jobDataMap.put("driverTimeout", 0); |
| | | jobDataMap.put("describe", language == 1 ? "您将于" + sdf.format(orderPrivateCar.getTravelTime()) + "去接" + (ToolUtil.isEmpty(userInfo.getFirstName()) ? userInfo.getNickName() : userInfo.getFirstName() + " " + userInfo.getLastName()) + ",请准时!" : |
| | | language == 2 ? "You are going to pick up " + (ToolUtil.isEmpty(userInfo.getFirstName()) ? userInfo.getNickName() : userInfo.getFirstName() + " " + userInfo.getLastName()) + " at " + sdf.format(orderPrivateCar.getTravelTime()) + ", please be on time. " : |
| | | "Vous allez chercher " + (ToolUtil.isEmpty(userInfo.getFirstName()) ? userInfo.getNickName() : userInfo.getFirstName() + " " + userInfo.getLastName()) + " à " + sdf.format(orderPrivateCar.getTravelTime()) + ", s’il vous plaît soyez à l’heure."); |
| | | quartzUtil.addSimpleQuartzTask(OrderTimeOutJob.class,"2_1_" + orderPrivateCar.getId() + "_1", "ORDER_TIME_OUT", jobDataMap |
| | | , new Date(travelTime), travelTime, 0); |
| | | |
| | | //预约单出发循环提醒 |
| | | jobDataMap = new JobDataMap(); |
| | | jobDataMap.put("driverId", uid); |
| | | jobDataMap.put("timeOutType", 2); |
| | | jobDataMap.put("orderId", orderPrivateCar.getId()); |
| | | jobDataMap.put("orderType", 1); |
| | | jobDataMap.put("language", language); |
| | | jobDataMap.put("timeOut", orderPrivateCar.getTravelTime().getTime()); |
| | | jobDataMap.put("driverTimeout", 0); |
| | | jobDataMap.put("describe", language == 1 ? "您将于" + sdf.format(orderPrivateCar.getTravelTime()) + "去接" + (ToolUtil.isEmpty(userInfo.getFirstName()) ? userInfo.getNickName() : userInfo.getFirstName() + " " + userInfo.getLastName()) + ",请准时!" : |
| | | language == 2 ? "You are going to pick up " + (ToolUtil.isEmpty(userInfo.getFirstName()) ? userInfo.getNickName() : userInfo.getFirstName() + " " + userInfo.getLastName()) + " at " + sdf.format(orderPrivateCar.getTravelTime()) + ", please be on time. " : |
| | | "Vous allez chercher " + (ToolUtil.isEmpty(userInfo.getFirstName()) ? userInfo.getNickName() : userInfo.getFirstName() + " " + userInfo.getLastName()) + " à " + sdf.format(orderPrivateCar.getTravelTime()) + ", s’il vous plaît soyez à l’heure."); |
| | | quartzUtil.addSimpleQuartzTask(OrderTimeOutJob.class,"2_2_" + orderPrivateCar.getId() + "_1", "ORDER_TIME_OUT", jobDataMap |
| | | , new Date(travelTime + reminderRules.getReserveNext() * 60000), reminderRules.getReserveNext() * 60000, -1); |
| | | |
| | | //超时循环提醒 |
| | | jobDataMap = new JobDataMap(); |
| | | jobDataMap.put("driverId", uid); |
| | | jobDataMap.put("timeOutType", 3); |
| | | jobDataMap.put("orderId", orderPrivateCar.getId()); |
| | | jobDataMap.put("orderType", 1); |
| | | jobDataMap.put("language", language); |
| | | jobDataMap.put("timeOut", orderPrivateCar.getTravelTime().getTime()); |
| | | jobDataMap.put("driverTimeout", 0); |
| | | jobDataMap.put("describe", ""); |
| | | quartzUtil.addSimpleQuartzTask(OrderTimeOutJob.class,"3_" + orderPrivateCar.getId() + "_1", "ORDER_TIME_OUT", jobDataMap |
| | | , orderPrivateCar.getTravelTime(), reminderRules.getCar() * 60000, -1); |
| | | } |
| | | } |
| | | |
| | | |
| | | //推送相关代码------------------start---------------- |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | pushUtil.pushOrderState(1, orderPrivateCar.getUserId(), orderPrivateCar.getId(), 1, orderPrivateCar.getState()); |
| | | pushUtil.pushOrderState(2, orderPrivateCar.getDriverId(), orderPrivateCar.getId(), 1, orderPrivateCar.getState()); |
| | | pushUtil.pushOrderState(1, orderPrivateCar.getUserId(), orderPrivateCar.getId(), 1, orderPrivateCar.getState(), 0, "", "driver"); |
| | | pushUtil.pushOrderState(2, orderPrivateCar.getDriverId(), orderPrivateCar.getId(), 1, orderPrivateCar.getState(), 0, "", "driver"); |
| | | if(orderPrivateCar.getType() == 2){ |
| | | pushUtil.pushFerryOrderState(1, orderPrivateCar.getUserId(), orderPrivateCar.getId(), 1, 2); |
| | | } |
| | | } |
| | | }).start(); |
| | | |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | pushUtil.pushDriverPosition(orderId, 1); |
| | | } |
| | | }).start(); |
| | | |
| | | systemNoticeService.addSystemNotice(2, "您已成功抢得专车订单,请及时联系客户!", orderPrivateCar.getDriverId()); |
| | | systemNoticeService.addSystemNotice(1, "您的订单已指派给" + driver.getName().substring(0, 1) + "师傅,请保持电话畅通!", orderPrivateCar.getUserId()); |
| | | |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | if(pushMinistryOfTransport){ |
| | | //上传数据 |
| | | pushMinistryOfTransportUtil.orderCreate(orderId); |
| | | pushMinistryOfTransportUtil.orderMatch(orderId); |
| | | } |
| | | } |
| | | }).start(); |
| | | |
| | | |
| | | Integer language1 = userInfoMapper.selectById(orderPrivateCar.getUserId()).getLanguage(); |
| | | systemNoticeService.addSystemNotice(2, language == 1 ? "您已成功抢得打车订单,请及时联系客户!" : |
| | | language == 2 ? "You have grabbed the ride order, please contact the client timely." |
| | | : "Vous avez saisi la commande de course, veuillez contacter le client en temps opportun.", orderPrivateCar.getDriverId()); |
| | | systemNoticeService.addSystemNotice(1, language1 == 1 ? "您的订单已指派给" + driver.getFirstName() + "师傅,请保持电话畅通!" : |
| | | language1 == 2 ? "Your order has been assigned to the driver- " + driver.getFirstName() + ", please keep your line on." |
| | | : "Votre commande a été attribuée au chauffeur- " + driver.getFirstName() + ", S'il vous plaît, restez en ligne.", orderPrivateCar.getUserId()); |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public Map<String, Object> queryOrderInfo(Integer orderId) throws Exception { |
| | | return orderPrivateCarMapper.queryOrderInfo(orderId); |
| | | public Map<String, Object> queryOrderInfo(Integer language, Integer orderId) throws Exception { |
| | | Map<String, Object> map = orderPrivateCarMapper.queryOrderInfo(orderId); |
| | | OrderPrivateCar orderPrivateCar = this.selectById(orderId); |
| | | if(null != map.get("travelTime_")){ |
| | | String travelTime_ = map.get("travelTime_").toString(); |
| | | map.put("travelTime_", DateUtil.conversionFormat1(language, travelTime_)); |
| | | } |
| | | Integer orderState = Integer.valueOf(map.get("orderState").toString()); |
| | | if(orderState == 12){ |
| | | OrderCancel orderCancel = orderCancelService.selectOne(new EntityWrapper<OrderCancel>().eq("orderId", orderId) |
| | | .eq("orderType", 1).eq("state", 1).orderBy("insertTime desc limit 0, 1")); |
| | | if(null != orderCancel){ |
| | | map.put("cancelPayMoney", orderCancel.getMoney()); |
| | | } |
| | | } |
| | | map.put("cancelUser", language == 1 ? "用户" : language == 2 ? "The client" : "Le client"); |
| | | long timeOutCancel = 0L; |
| | | // CancleOrder cancleOrder = cancleOrderService.selectOne(new EntityWrapper<CancleOrder>().eq("companyId", orderPrivateCar.getCompanyId())); |
| | | // JSONObject jsonObject = JSON.parseObject(cancleOrder.getContent()); |
| | | // int driverTimeout = jsonObject.getIntValue("driverTimeout") * 60000; |
| | | if(orderPrivateCar.getOrderType() == 1 && null != orderPrivateCar.getEstimateArriveTime()){ |
| | | timeOutCancel = orderPrivateCar.getEstimateArriveTime().getTime(); |
| | | }else{ |
| | | timeOutCancel = orderPrivateCar.getTravelTime().getTime(); |
| | | } |
| | | map.put("timeOutCancel", timeOutCancel); |
| | | map.put("isDispute", orderPrivateCar.getIsDispute()); |
| | | return map; |
| | | } |
| | | |
| | | |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil process(Integer orderId, Integer state, Double lon, Double lat, String address,String phone) throws Exception { |
| | | public ResultUtil process(Integer orderId, Integer state, Double lon, Double lat,String phone, Integer language, Integer uid) throws Exception { |
| | | OrderPrivateCar orderPrivateCar = this.selectById(orderId); |
| | | if(state==5){ |
| | | UserInfo userInfo = userInfoMapper.selectById(orderPrivateCar.getUserId()); |
| | | if(!userInfo.getPhone().substring(7, userInfo.getPhone().length()).equals(phone)){ |
| | | return ResultUtil.error("手机号错误"); |
| | | } |
| | | String tripId = redisUtil.getValue("trip" + orderPrivateCar.getUserId()); |
| | | ReverseGeocodeVo reverseGeocode = GoogleMapUtil.getReverseGeocode(lat, lon, tripId); |
| | | if(null == reverseGeocode){ |
| | | return ResultUtil.error(language == 1 ? "无效的经纬度" : language == 2 ? "Invalid longitude and latitude" : "Longitude et latitude non valides"); |
| | | } |
| | | String address = reverseGeocode.getAddress(); |
| | | if(!uid.equals(orderPrivateCar.getDriverId())){ |
| | | return ResultUtil.error(language == 1 ? "操作失败,请刷新订单" : language == 2 ? "Operation failed, please refresh the order" : "L’opération a échoué, veuillez actualiser la commande"); |
| | | } |
| | | if(orderPrivateCar.getState().compareTo(state) == 0){ |
| | | return ResultUtil.error(language == 1 ? "不能重复操作" : language == 2 ? "Unable to recur operate" : "Impossible de récurrence des opérer"); |
| | | } |
| | | if(state==3 && orderPrivateCar.getState()!=2){ |
| | | return ResultUtil.error("当前订单不能触发前往预约地点"); |
| | | return ResultUtil.error(language == 1 ? "当前订单不能触发前往预约地点" : language == 2 ? "The current order cannot trigger travel to the reservation" : "La commande en cours ne peut pas déclencher une visite au lieu de rendez-vous"); |
| | | } |
| | | if(state==4 && orderPrivateCar.getState()!=3){ |
| | | return ResultUtil.error("当前订单不能到达预约地点"); |
| | | return ResultUtil.error(language == 1 ? "当前订单不能到达预约地点" : language == 2 ? "The current order cannot arrive at the reservation" : "La commande en cours ne peut pas atteindre le rendez-vous"); |
| | | } |
| | | /*if(state==5 && orderPrivateCar.getState()!=4){ |
| | | return ResultUtil.error("当前订单不能开始服务"); |
| | | }*/ |
| | | Integer language1 = userInfoMapper.selectById(orderPrivateCar.getUserId()).getLanguage(); |
| | | |
| | | String tripStatus = "UNKNOWN_TRIP_STATUS"; |
| | | String audioUrl = ""; |
| | | switch (state){ |
| | | case 3://出发前往预约点 |
| | | orderPrivateCar.setState(3); |
| | | orderPrivateCar.setSetOutTime(new Date()); |
| | | systemNoticeService.addSystemNotice(1, "司机已出发,请耐心等待", orderPrivateCar.getUserId()); |
| | | systemNoticeService.addSystemNotice(1, language1 == 1 ? "司机已出发,请耐心等待" : language1 == 2 ? "The driver is on the way, please wait." : "Le chauffeur est en route. Veuillez patienter.", orderPrivateCar.getUserId()); |
| | | pushUtil.pushDriverPosition(orderPrivateCar.getId(), 1);//主动推送司机定位 |
| | | tripStatus = "ENROUTE_TO_PICKUP"; |
| | | break; |
| | | case 4://到达预约点,等待客户上车 |
| | | orderPrivateCar.setState(4); |
| | | orderPrivateCar.setArriveTime(new Date()); |
| | | systemNoticeService.addSystemNotice(1, "司机已到达您设置的预约地点,请及时上车", orderPrivateCar.getUserId()); |
| | | systemNoticeService.addSystemNotice(1, language1 == 1 ? "司机已到达您设置的预约地点,请及时上车" : language1 == 2 ? |
| | | "The driver has arrived at the reserved location, please get in timely." : |
| | | "Le chauffeur est arrivé à l'endroit prévu, veuillez monter dans la voiture à temps.", orderPrivateCar.getUserId()); |
| | | tripStatus = "ARRIVED_AT_PICKUP"; |
| | | break; |
| | | case 5://开始服务 |
| | | orderPrivateCar.setBoardingLon(lon); |
| | |
| | | orderPrivateCar.setState(5); |
| | | orderPrivateCar.setStartServiceTime(new Date()); |
| | | |
| | | pushUtil.pushDriverPosition(orderPrivateCar.getId(), 1);//主动推送司机定位 |
| | | |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | if(pushMinistryOfTransport){//上传数据 |
| | | pushMinistryOfTransportUtil.operateDepart(orderId); |
| | | } |
| | | } |
| | | }).start(); |
| | | OrderPosition orderPosition = new OrderPosition(); |
| | | orderPosition.setOrderId(orderId); |
| | | orderPosition.setOrderType(1); |
| | |
| | | out.write(JSON.toJSONString(orderPositions)); |
| | | out.flush(); |
| | | out.close(); |
| | | tripStatus = "ENROUTE_TO_DROPOFF"; |
| | | switch (language){ |
| | | case 1: |
| | | audioUrl = "https://igo.i-go.group/files/audio/system/OnboardReminder-CN.mp3"; |
| | | break; |
| | | case 2: |
| | | audioUrl = "https://igo.i-go.group/files/audio/system/OnboardReminder-EN.mp3"; |
| | | break; |
| | | case 3: |
| | | audioUrl = "https://igo.i-go.group/files/audio/system/OnboardReminder-FR.mp3"; |
| | | break; |
| | | } |
| | | break; |
| | | case 6://结束服务(专车可以返回继续服务)不修改状态 |
| | | orderPrivateCar.setState(6); |
| | | orderPrivateCar.setGetoffLon(lon); |
| | | orderPrivateCar.setGetoffLat(lat); |
| | | orderPrivateCar.setGetoffAddress(address); |
| | | orderPrivateCar.setGetoffTime(new Date()); |
| | | orderPrivateCar.setEndServiceTime(new Date()); |
| | | tripStatus = ""; |
| | | switch (language){ |
| | | case 1: |
| | | audioUrl = "https://igo.i-go.group/files/audio/system/ReachDestination-CN.mp3"; |
| | | break; |
| | | case 2: |
| | | audioUrl = "https://igo.i-go.group/files/audio/system/ReachDestination-EN.mp3"; |
| | | break; |
| | | case 3: |
| | | audioUrl = "https://igo.i-go.group/files/audio/system/ReachDestination-FR.mp3"; |
| | | break; |
| | | } |
| | | break; |
| | | } |
| | | this.updateById(orderPrivateCar); |
| | | |
| | | //修改行程数据 |
| | | if(ToolUtil.isNotEmpty(tripStatus)){ |
| | | Car car = carService.selectById(orderPrivateCar.getCarId()); |
| | | boolean updateTrip = fleetEngineUtil.updateTrip(tripStatus, car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null, orderPrivateCar.getId(), 1); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip(tripStatus, car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null, orderPrivateCar.getId(), 1); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | // TODO: 2020/6/5 推送状态 |
| | | OrderPrivateCar finalOrderPrivateCar = orderPrivateCar; |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | pushUtil.pushOrderState(1, finalOrderPrivateCar.getUserId(), finalOrderPrivateCar.getId(), 1, finalOrderPrivateCar.getState()); |
| | | pushUtil.pushOrderState(2, finalOrderPrivateCar.getDriverId(), finalOrderPrivateCar.getId(), 1, finalOrderPrivateCar.getState()); |
| | | pushUtil.pushOrderState(1, finalOrderPrivateCar.getUserId(), finalOrderPrivateCar.getId(), 1, finalOrderPrivateCar.getState(), 0, "", "driver"); |
| | | pushUtil.pushOrderState(2, finalOrderPrivateCar.getDriverId(), finalOrderPrivateCar.getId(), 1, finalOrderPrivateCar.getState(), 0, "", "driver"); |
| | | } |
| | | }).start(); |
| | | return ResultUtil.success(); |
| | | return ResultUtil.success(audioUrl); |
| | | } |
| | | |
| | | |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil confirmFees(Integer orderId, Integer type, Double parkingFee, Double crossingFee) throws Exception { |
| | | public ResultUtil confirmFees(Integer language, Integer orderId, Integer type, Double parkingFee, Double crossingFee, Integer uid) throws Exception { |
| | | OrderPrivateCar orderPrivateCar = this.selectById(orderId); |
| | | if(!uid.equals(orderPrivateCar.getDriverId())){ |
| | | return ResultUtil.error(language == 1 ? "操作失败,请刷新订单" : language == 2 ? "Operation failed, please refresh the order" : "L’opération a échoué, veuillez actualiser la commande"); |
| | | } |
| | | if(6 != orderPrivateCar.getState()){ |
| | | return ResultUtil.error(language == 1 ? "操作失败,请刷新订单" : language == 2 ? "Operation failed, please refresh the order" : "L’opération a échoué, veuillez actualiser la commande"); |
| | | } |
| | | if(orderPrivateCar.getArriveTime()==null){ |
| | | orderPrivateCar.setArriveTime(orderPrivateCar.getStartServiceTime()); |
| | | } |
| | | |
| | | orderPrivateCar = this.setMoney(orderPrivateCar, 0D, 0D);//计算费用 |
| | | orderPrivateCar.setPayManner(type); |
| | | orderPrivateCar.setParkMoney(null == parkingFee ? 0D : parkingFee); |
| | |
| | | } |
| | | 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))).setScale(2, BigDecimal.ROUND_HALF_EVEN); |
| | | 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()); |
| | |
| | | orderPrivateCar.setState(7); |
| | | } |
| | | |
| | | Map<String, String> map = chinaMobileUtil.midAxbUnBindSend(orderPrivateCar.getBindId(),orderPrivateCar.getTelX()); |
| | | if(String.valueOf(map.get("code")).equals("200")){ |
| | | orderPrivateCar.setTelX(""); |
| | | orderPrivateCar.setBindId(""); |
| | | } |
| | | // Map<String, String> map = chinaMobileUtil.midAxbUnBindSend(orderPrivateCar.getBindId(),orderPrivateCar.getTelX()); |
| | | // if(String.valueOf(map.get("code")).equals("200")){ |
| | | // orderPrivateCar.setTelX(""); |
| | | // orderPrivateCar.setBindId(""); |
| | | // } |
| | | this.updateById(orderPrivateCar); |
| | | |
| | | |
| | | |
| | | //修改行程数据 |
| | | Car car = carService.selectById(orderPrivateCar.getCarId()); |
| | | boolean updateTrip = fleetEngineUtil.updateTrip("COMPLETE", car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null, orderPrivateCar.getId(), 1); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip("COMPLETE", car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null, orderPrivateCar.getId(), 1); |
| | | if(updateTrip){ |
| | | orderPrivateCar.setIsover(1); |
| | | this.updateById(orderPrivateCar); |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }else{ |
| | | orderPrivateCar.setIsover(1); |
| | | this.updateById(orderPrivateCar); |
| | | } |
| | | |
| | | //上报行程 |
| | | 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) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | pushUtil.removeTask(orderId, 1);//删除定时任务,结束推送数据 |
| | | systemNoticeService.addSystemNotice(1, "司机已结束本次行程,谢谢使用", orderPrivateCar.getUserId()); |
| | | UserInfo userInfo = userInfoMapper.selectById(orderPrivateCar.getUserId()); |
| | | Integer language1 = userInfo.getLanguage(); |
| | | systemNoticeService.addSystemNotice(1, language1 == 1 ? "司机已结束本次行程,谢谢使用" : language1 == 2 ? |
| | | "The driver has finished the trip,thank you for using I-GO" : "Le chauffeur a terminé le trajet, merci d'utiliser I-GO", orderPrivateCar.getUserId()); |
| | | |
| | | //回滚司机状态为空闲 |
| | | Driver driver = driverService.selectById(orderPrivateCar.getDriverId()); |
| | |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | pushUtil.pushOrderState(1, finalOrderTaxi.getUserId(), finalOrderTaxi.getId(), 1, finalOrderTaxi.getState()); |
| | | pushUtil.pushOrderState(2, finalOrderTaxi.getDriverId(), finalOrderTaxi.getId(), 1, finalOrderTaxi.getState()); |
| | | pushUtil.pushOrderState(1, finalOrderTaxi.getUserId(), finalOrderTaxi.getId(), 1, finalOrderTaxi.getState(), 0, "", "driver"); |
| | | pushUtil.pushOrderState(2, finalOrderTaxi.getDriverId(), finalOrderTaxi.getId(), 1, finalOrderTaxi.getState(), 0, "", "driver"); |
| | | } |
| | | }).start(); |
| | | |
| | | OrderPrivateCar finalOrderPrivateCar = orderPrivateCar; |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | if(pushMinistryOfTransport){//上传交通数据 |
| | | pushMinistryOfTransportUtil.baseInfoVehicleTotalMile(finalOrderPrivateCar.getCarId()); |
| | | pushMinistryOfTransportUtil.operateArrive(orderId); |
| | | } |
| | | } |
| | | }).start(); |
| | | |
| | | |
| | | |
| | | |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | |
| | | @Override |
| | | public Map<String, Object> queryMoneyInfo(Integer orderId) throws Exception { |
| | | OrderPrivateCar orderPrivateCar = this.selectById(orderId); |
| | | if(orderPrivateCar.getState() == 5){//服务中的时候获取实时费用数据 |
| | | if(orderPrivateCar.getState() == 6){//服务中的时候获取实时费用数据 |
| | | this.setMoney(orderPrivateCar, 0D, 0D); |
| | | } |
| | | |
| | |
| | | map.put("couponMoney", orderPrivateCar.getCouponMoney());//优惠券抵扣金额 |
| | | map.put("discountMoney", orderPrivateCar.getDiscountMoney());//折扣抵扣金额 |
| | | map.put("discount", orderPrivateCar.getDiscount());//折扣 |
| | | map.put("isDispute", orderPrivateCar.getIsDispute()); |
| | | return map; |
| | | } |
| | | |
| | |
| | | @Override |
| | | public boolean calculateMileage(Integer orderId, String lon, String lat) throws Exception { |
| | | OrderPrivateCar orderPrivateCar = this.selectById(orderId); |
| | | if(orderPrivateCar.getState() == 2){ |
| | | return false; |
| | | } |
| | | OrderPosition orderPosition = orderPositionService.queryNew(orderId, 1); |
| | | String now = lon + "," + lat; |
| | | String old = null; |
| | | if(null != orderPosition){ |
| | | old = orderPosition.getLon() + "," + orderPosition.getLat(); |
| | | }else{ |
| | | orderPrivateCar.setToStartPointMileage(0D); |
| | | orderPrivateCar.setMileage(0D); |
| | | this.updateById(orderPrivateCar); |
| | | return true;//第一条数据不作处理,直接存储 |
| | |
| | | Map<String, Double> distance = GeodesyUtil.getDistance(now, old); |
| | | if(null != distance){ |
| | | Double distance1 = distance.get("WGS84"); |
| | | if(distance1 > 50 && orderPrivateCar.getState()==5/* && orderPosition.getInsertTime().getTime()>=orderPrivateCar.getBoardingTime().getTime()*/){//大于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 > 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; |
| | |
| | | */ |
| | | public OrderPrivateCar setMoney(OrderPrivateCar orderPrivateCar, Double parkingFee, Double crossingFee) throws Exception { |
| | | Map<String, Object> query1 = systemPriceMapper.query(orderPrivateCar.getCompanyId(), 1, orderPrivateCar.getServerCarModelId()); |
| | | if(null == query1){ |
| | | throw new RuntimeException("请先添加计费规则"); |
| | | } |
| | | //开始根据不同的方式计算金额 |
| | | double amount = 0; |
| | | JSONObject jsonObject = JSON.parseObject(query1.get("content").toString()); |
| | |
| | | Date date = new Date(); |
| | | double d = (null == orderPrivateCar.getMileage() ? 0D : orderPrivateCar.getMileage()) / 1000;//实际公里 |
| | | double t = ((orderPrivateCar.getEndServiceTime().getTime() - orderPrivateCar.getStartServiceTime().getTime()) / 60000) + 1;//实际时间(不满一分钟按一分钟算) |
| | | double w = ((orderPrivateCar.getStartServiceTime().getTime() - orderPrivateCar.getArriveTime().getTime()) / 60000) + 1;//等待分钟(不满一分钟按一分钟算) |
| | | double w = ((orderPrivateCar.getStartServiceTime().getTime() - (null == orderPrivateCar.getArriveTime() ? orderPrivateCar.getStartServiceTime() : orderPrivateCar.getArriveTime()).getTime()) / 60000) + 1;//等待分钟(不满一分钟按一分钟算) |
| | | double d1 = (d - num2) < 0 ? 0 : d - num2;//超出起步里程的公里 |
| | | double t1 = (t - num3) < 0 ? 0 : new BigDecimal(t - num3).setScale(0, BigDecimal.ROUND_UP).doubleValue();//超过起步分钟数的时间 |
| | | double w1 = (w - num6) < 0 ? 0 : new BigDecimal(w - num6).setScale(0, BigDecimal.ROUND_UP).doubleValue();//超出等待时间的时间 |
| | |
| | | |
| | | |
| | | //夜间服务处理逻辑 |
| | | Calendar s = Calendar.getInstance(); |
| | | s.setTime(date); |
| | | s.set(Calendar.HOUR_OF_DAY, Integer.valueOf(num16.split(" - ")[0].split(":")[0])); |
| | | s.set(Calendar.MINUTE, Integer.valueOf(num16.split(" - ")[0].split(":")[1])); |
| | | if(ToolUtil.isNotEmpty(num16)){ |
| | | Calendar s = Calendar.getInstance(); |
| | | s.setTime(date); |
| | | s.set(Calendar.HOUR_OF_DAY, Integer.valueOf(num16.split(" - ")[0].split(":")[0])); |
| | | s.set(Calendar.MINUTE, Integer.valueOf(num16.split(" - ")[0].split(":")[1])); |
| | | |
| | | Calendar e = Calendar.getInstance(); |
| | | e.setTime(date); |
| | | e.set(Calendar.HOUR_OF_DAY, Integer.valueOf(num16.split(" - ")[1].split(":")[0])); |
| | | e.set(Calendar.MINUTE, Integer.valueOf(num16.split(" - ")[1].split(":")[1])); |
| | | Calendar e = Calendar.getInstance(); |
| | | e.setTime(date); |
| | | e.set(Calendar.HOUR_OF_DAY, Integer.valueOf(num16.split(" - ")[1].split(":")[0])); |
| | | e.set(Calendar.MINUTE, Integer.valueOf(num16.split(" - ")[1].split(":")[1])); |
| | | |
| | | if(date.getTime() > s.getTimeInMillis() && date.getTime() < e.getTimeInMillis()){ |
| | | if(d > num8.doubleValue() && d <= num9.doubleValue()){ |
| | | yt1 = num20 * (d - num8); |
| | | if(date.getTime() > s.getTimeInMillis() && date.getTime() < e.getTimeInMillis()){ |
| | | if(d > num8.doubleValue() && d <= num9.doubleValue()){ |
| | | yt1 = num20 * (d - num8); |
| | | } |
| | | if(d > num9.doubleValue()){ |
| | | yt1 = num20 * (num9 - num8); |
| | | } |
| | | if(d > num11.doubleValue() && d <= num12.doubleValue()){ |
| | | yt2 = num21 * (d - num11); |
| | | } |
| | | if(d > num12.doubleValue()){ |
| | | yt2 = num21 * (num12 - num11); |
| | | } |
| | | if(d > num14.doubleValue()){ |
| | | yt3 = num22 * (d - num14); |
| | | } |
| | | amount = num17 + (d1 * num18) + (t1 * num19) + (w1 * num7) + yt1 + yt2 + yt3; |
| | | orderPrivateCar.setStartMileage(num2); |
| | | orderPrivateCar.setStartMoney(num17);//起步价 |
| | | orderPrivateCar.setStartDuration((int)(num3.doubleValue())); |
| | | orderPrivateCar.setMileageKilometers(new BigDecimal(d1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | orderPrivateCar.setMileageMoney(new BigDecimal(d1 * num18).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());//里程费 |
| | | orderPrivateCar.setDuration(new BigDecimal(t1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | orderPrivateCar.setDurationMoney(new BigDecimal(t1 * num19).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());//时长费 |
| | | orderPrivateCar.setWait(new BigDecimal(w1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | orderPrivateCar.setWaitMoney(new BigDecimal(w1 * num7).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());//等待费 |
| | | orderPrivateCar.setLongDistance(new BigDecimal((d > num8) ? d - num8 : 0).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | orderPrivateCar.setLongDistanceMoney(new BigDecimal(yt1 + yt2 + yt3).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());//远途费 |
| | | orderPrivateCar.setParkMoney(parkingFee);//停车费 |
| | | orderPrivateCar.setRoadTollMoney(crossingFee);//过路费 |
| | | orderPrivateCar.setRedPacketMoney(0D);//红包抵扣 |
| | | orderPrivateCar.setCouponMoney(0D);//优惠券抵扣 |
| | | orderPrivateCar.setDiscount(0D);//优惠抵扣 |
| | | orderPrivateCar.setPayMoney(0D);//支付金额 |
| | | orderPrivateCar.setOrderMoney(new BigDecimal(amount + parkingFee + crossingFee).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | orderPrivateCar.setMoneyType(2); |
| | | orderPrivateCar.setMoneyTime(num16); |
| | | return orderPrivateCar; |
| | | } |
| | | if(d > num9.doubleValue()){ |
| | | yt1 = num20 * (num9 - num8); |
| | | } |
| | | if(d > num11.doubleValue() && d <= num12.doubleValue()){ |
| | | yt2 = num21 * (d - num11); |
| | | } |
| | | if(d > num12.doubleValue()){ |
| | | yt2 = num21 * (num12 - num11); |
| | | } |
| | | if(d > num14.doubleValue()){ |
| | | yt3 = num22 * (d - num14); |
| | | } |
| | | amount = num17 + (d1 * num18) + (t1 * num19) + (w1 * num7) + yt1 + yt2 + yt3; |
| | | orderPrivateCar.setStartMileage(num2); |
| | | orderPrivateCar.setStartMoney(num17);//起步价 |
| | | orderPrivateCar.setStartDuration((int)(num3.doubleValue())); |
| | | orderPrivateCar.setMileageKilometers(new BigDecimal(d1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | orderPrivateCar.setMileageMoney(new BigDecimal(d1 * num18).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());//里程费 |
| | | orderPrivateCar.setDuration(new BigDecimal(t1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | orderPrivateCar.setDurationMoney(new BigDecimal(t1 * num19).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());//时长费 |
| | | orderPrivateCar.setWait(new BigDecimal(w1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | orderPrivateCar.setWaitMoney(new BigDecimal(w1 * num7).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());//等待费 |
| | | orderPrivateCar.setLongDistance(new BigDecimal((d > num8) ? d - num8 : 0).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | orderPrivateCar.setLongDistanceMoney(new BigDecimal(yt1 + yt2 + yt3).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());//远途费 |
| | | orderPrivateCar.setParkMoney(parkingFee);//停车费 |
| | | orderPrivateCar.setRoadTollMoney(crossingFee);//过路费 |
| | | orderPrivateCar.setRedPacketMoney(0D);//红包抵扣 |
| | | orderPrivateCar.setCouponMoney(0D);//优惠券抵扣 |
| | | orderPrivateCar.setDiscount(0D);//优惠抵扣 |
| | | orderPrivateCar.setPayMoney(0D);//支付金额 |
| | | orderPrivateCar.setOrderMoney(new BigDecimal(amount + parkingFee + crossingFee).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | orderPrivateCar.setMoneyType(2); |
| | | orderPrivateCar.setMoneyTime(num16); |
| | | return orderPrivateCar; |
| | | } |
| | | |
| | | |
| | |
| | | public List<OrderPrivateCar> getSmsOrderList() { |
| | | return this.baseMapper.getSmsOrderList(); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void payOrderPrivateCarCallback(Integer id, String order_id, Integer language) throws Exception { |
| | | OrderPrivateCar orderPrivateCar = this.selectById(id); |
| | | PaymentRecord query = paymentRecordService.query(1, orderPrivateCar.getDriverId(), 2, id, 1, null, 1); |
| | | if(null != query){ |
| | | //添加交易明细 |
| | | transactionDetailsService.saveData(orderPrivateCar.getDriverId(), language == 1 ? "现金收款代付" : language == 2 ? "Cash collection on behalf of payment" : "Paiement en espèces", query.getAmount(), 2, 1, 2, 1, id); |
| | | orderPrivateCar.setDriverPay(2); |
| | | this.updateById(orderPrivateCar); |
| | | |
| | | query.setState(2); |
| | | query.setCode(order_id); |
| | | paymentRecordService.updateById(query); |
| | | }else{ |
| | | System.err.println("预支付数据异常(orderId = " + id + ")"); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 处理乘客修改终点 |
| | | * @param orderId |
| | | * @param status |
| | | */ |
| | | @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())); |
| | | orderPrivateCar.setEndAddress(orderPrivateCar.getDestination()); |
| | | //修改google地图行程终点 |
| | | Car car = carService.selectById(orderPrivateCar.getCarId()); |
| | | boolean updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderPrivateCar.getTripId(), |
| | | null, null, orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString(), orderPrivateCar.getId(), 1); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderPrivateCar.getTripId(), |
| | | null, null, orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString(), orderPrivateCar.getId(), 1); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | this.updateById(orderPrivateCar); |
| | | pushUtil.pushModifyAddress(1, orderPrivateCar.getUserId(), orderId, 1, status); |
| | | } |
| | | } |