| | |
| | | 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.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.quartz.JobDataMap; |
| | | 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.*; |
| | | |
| | | |
| | |
| | | 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 IReminderRulesService reminderRulesService; |
| | | |
| | | |
| | | |
| | |
| | | * @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); |
| | | //处理摆渡车的情况 |
| | | 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("订单已取消"); |
| | | 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); |
| | | this.updateById(orderPrivateCar); |
| | | |
| | | //如果是预约单,则不修改司机为服务中 |
| | |
| | | driver.setState(3); |
| | | driverService.updateById(driver); |
| | | } |
| | | |
| | | |
| | | |
| | | //todo 待翻译 |
| | | //添加定时任务(普通任务) |
| | | ReminderRules reminderRules = reminderRulesService.selectOne(new EntityWrapper<ReminderRules>().eq("companyId", driver.getCompanyId())); |
| | | if(null != reminderRules){ |
| | | JSONObject jsonObject = JSON.parseObject(reminderRules.getContent()); |
| | | //预约单 |
| | | if(orderPrivateCar.getOrderType() == 1){ |
| | | long specialCarTimeoutReminderInterval = jsonObject.getInteger("specialCarTimeoutReminderInterval") * 60000L; |
| | | long m = (System.currentTimeMillis() - orderPrivateCar.getSnatchOrderTime().getTime()) / 60000; |
| | | JobDataMap jobDataMap = new JobDataMap(); |
| | | jobDataMap.put("driverId", uid); |
| | | jobDataMap.put("orderId", orderPrivateCar.getId()); |
| | | jobDataMap.put("orderType", 1); |
| | | jobDataMap.put("describe", "您的打车订单已超时" + m + "分钟,请抓紧!"); |
| | | QuartzUtil.addSimpleQuartzTask( |
| | | new OrderTimeOutJob().buildQuartzJob(UUIDUtil.getRandomCode(5) + "_" + orderPrivateCar.getId() + "_1", "ORDER_TIME_OUT", jobDataMap) |
| | | , new Date(specialCarTimeoutReminderInterval), specialCarTimeoutReminderInterval, -1); |
| | | }else{ |
| | | UserInfo userInfo = userInfoMapper.selectById(orderPrivateCar.getUserId()); |
| | | JSONObject reservationOrder = jsonObject.getJSONObject("reservationOrder"); |
| | | long appointmentReminder = reservationOrder.getInteger("appointmentReminder") * 60000L; |
| | | long appointmentTimeoutReminderInterval = reservationOrder.getInteger("appointmentTimeoutReminderInterval") * 60000L; |
| | | SimpleDateFormat sdf = new SimpleDateFormat(""); |
| | | JobDataMap jobDataMap = new JobDataMap(); |
| | | jobDataMap.put("driverId", uid); |
| | | jobDataMap.put("orderId", orderPrivateCar.getId()); |
| | | jobDataMap.put("orderType", 1); |
| | | jobDataMap.put("describe", "您将于" + sdf.format(orderPrivateCar.getTravelTime()) + "去接" + userInfo.getFirstName() + " " + userInfo.getLastName() + ",请准时!"); |
| | | QuartzUtil.addSimpleQuartzTask( |
| | | new OrderTimeOutJob().buildQuartzJob(UUIDUtil.getRandomCode(5) + "_" + orderPrivateCar.getId() + "_1", "ORDER_TIME_OUT", jobDataMap) |
| | | , new Date(appointmentReminder), appointmentReminder, 0); |
| | | |
| | | |
| | | jobDataMap = new JobDataMap(); |
| | | jobDataMap.put("driverId", uid); |
| | | jobDataMap.put("orderId", orderPrivateCar.getId()); |
| | | jobDataMap.put("orderType", 1); |
| | | jobDataMap.put("describe", "您将于" + sdf.format(orderPrivateCar.getTravelTime()) + "去接" + userInfo.getFirstName() + " " + userInfo.getLastName() + ",请准时!"); |
| | | QuartzUtil.addSimpleQuartzTask( |
| | | new OrderTimeOutJob().buildQuartzJob(UUIDUtil.getRandomCode(5) + "_" + orderPrivateCar.getId() + "_1", "ORDER_TIME_OUT", jobDataMap) |
| | | , new Date(appointmentReminder + appointmentTimeoutReminderInterval), appointmentTimeoutReminderInterval, -1); |
| | | } |
| | | } |
| | | |
| | | //推送相关代码------------------start---------------- |
| | | new Thread(new Runnable() { |
| | | @Override |
| | |
| | | } |
| | | }).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(); |
| | | |
| | | 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, language == 1 ? "您的订单已指派给" + driver.getFirstName() + "师傅,请保持电话畅通!" : |
| | | language == 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); |
| | | if(null != map.get("travelTime_")){ |
| | | String travelTime_ = map.get("travelTime_").toString(); |
| | | map.put("travelTime_", DateUtil.conversionFormat1(language, travelTime_)); |
| | | } |
| | | map.put("cancelUser", language == 1 ? "用户" : language == 2 ? "The client" : "Le client"); |
| | | 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 address,String phone, Integer language) 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("手机号错误"); |
| | | } |
| | | 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("当前订单不能开始服务"); |
| | | }*/ |
| | | switch (state){ |
| | | case 3://出发前往预约点 |
| | | orderPrivateCar.setState(3); |
| | | orderPrivateCar.setSetOutTime(new Date()); |
| | | systemNoticeService.addSystemNotice(1, "司机已出发,请耐心等待", orderPrivateCar.getUserId()); |
| | | systemNoticeService.addSystemNotice(1, language == 1 ? "司机已出发,请耐心等待" : language == 2 ? "The driver is on the way, please wait." : "Le chauffeur est en route. Veuillez patienter.", orderPrivateCar.getUserId()); |
| | | pushUtil.pushDriverPosition(orderPrivateCar.getId(), 1);//主动推送司机定位 |
| | | break; |
| | | case 4://到达预约点,等待客户上车 |
| | | orderPrivateCar.setState(4); |
| | | orderPrivateCar.setArriveTime(new Date()); |
| | | systemNoticeService.addSystemNotice(1, "司机已到达您设置的预约地点,请及时上车", orderPrivateCar.getUserId()); |
| | | systemNoticeService.addSystemNotice(1, language == 1 ? "司机已到达您设置的预约地点,请及时上车" : language == 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()); |
| | | 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.close(); |
| | | break; |
| | | case 6://结束服务(专车可以返回继续服务)不修改状态 |
| | | orderPrivateCar.setState(6); |
| | | orderPrivateCar.setGetoffLon(lon); |
| | | orderPrivateCar.setGetoffLat(lat); |
| | | orderPrivateCar.setGetoffAddress(address); |
| | |
| | | * @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) throws Exception { |
| | | OrderPrivateCar orderPrivateCar = this.selectById(orderId); |
| | | if(orderPrivateCar.getArriveTime()==null){ |
| | | orderPrivateCar.setArriveTime(orderPrivateCar.getStartServiceTime()); |
| | |
| | | } |
| | | 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()); |
| | |
| | | |
| | | |
| | | pushUtil.removeTask(orderId, 1);//删除定时任务,结束推送数据 |
| | | systemNoticeService.addSystemNotice(1, "司机已结束本次行程,谢谢使用", orderPrivateCar.getUserId()); |
| | | systemNoticeService.addSystemNotice(1, language == 1 ? "司机已结束本次行程,谢谢使用" : language == 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()); |
| | |
| | | pushUtil.pushOrderState(2, finalOrderTaxi.getDriverId(), finalOrderTaxi.getId(), 1, finalOrderTaxi.getState()); |
| | | } |
| | | }).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(); |
| | | } |
| | | |
| | |
| | | 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(2 == status){ |
| | | orderPrivateCar.setEndLon(Double.valueOf(orderPrivateCar.getDestinationLon())); |
| | | orderPrivateCar.setEndLat(Double.valueOf(orderPrivateCar.getDestinationLat())); |
| | | orderPrivateCar.setEndAddress(orderPrivateCar.getDestination()); |
| | | } |
| | | orderPrivateCar.setDestinationLon(""); |
| | | orderPrivateCar.setDestination(""); |
| | | orderPrivateCar.setDestinationLat(""); |
| | | this.updateById(orderPrivateCar); |
| | | pushUtil.pushModifyAddress(1, orderPrivateCar.getUserId(), orderId, 1, status); |
| | | } |
| | | } |