| | |
| | | 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 java.io.FileWriter; |
| | | import java.io.PrintWriter; |
| | | import java.math.BigDecimal; |
| | | import java.math.MathContext; |
| | | import java.math.RoundingMode; |
| | | 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}") |
| | |
| | | * @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) { |
| | | 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) { |
| | | 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); |
| | | 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); |
| | |
| | | } |
| | | }).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 successfully grabbed a taxi order, please contact the customer in time!" |
| | | : "Vous avez saisi avec succès une commande de taxi, veuillez contacter le client à temps!", orderPrivateCar.getDriverId()); |
| | | systemNoticeService.addSystemNotice(1, language == 1 ? "您的订单已指派给" + driver.getFirstName() + "师傅,请保持电话畅通!" : |
| | | language == 2 ? "Your order has been assigned to " + driver.getFirstName() + " master, please keep the phone open!" |
| | | : "Votre commande a été attribuée à " + driver.getFirstName() + " master, veuillez garder le téléphone ouvert!", 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); |
| | | String travelTime_ = map.get("travelTime_").toString(); |
| | | map.put("travelTime_", DateUtil.conversionFormat1(language, travelTime_)); |
| | | 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(state==5){ |
| | | // UserInfo userInfo = userInfoMapper.selectById(orderPrivateCar.getUserId()); |
| | | // if(!userInfo.getPhone().substring(7, userInfo.getPhone().length()).equals(phone)){ |
| | | // return ResultUtil.error("手机号错误"); |
| | | // } |
| | | // } |
| | | 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("当前订单不能开始服务"); |
| | |
| | | case 3://出发前往预约点 |
| | | orderPrivateCar.setState(3); |
| | | orderPrivateCar.setSetOutTime(new Date()); |
| | | systemNoticeService.addSystemNotice(1, "司机已出发,请耐心等待", orderPrivateCar.getUserId()); |
| | | systemNoticeService.addSystemNotice(1, language == 1 ? "司机已出发,请耐心等待" : language == 2 ? "he driver has left, please wait patiently" : "Le chauffeur est parti, soyez patient", orderPrivateCar.getUserId()); |
| | | 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 reservation place you set, please get on the bus in time" : "Le chauffeur est arrivé au lieu de rendez-vous que vous avez fixé, s’il vous plaît embarquez à temps", orderPrivateCar.getUserId()); |
| | | break; |
| | | case 5://开始服务 |
| | | orderPrivateCar.setBoardingLon(lon); |
| | |
| | | |
| | | 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); |
| | |
| | | } |
| | | 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.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(); |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | //夜间服务处理逻辑 |
| | | 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 + ")"); |
| | | } |
| | | } |
| | | } |