From 48effdca685a209c19dd2a0ccd456470a895784b Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期五, 11 十月 2024 18:01:18 +0800 Subject: [PATCH] Merge branch '2.0' of http://120.76.84.145:10101/gitblit/r/java/IgoTravel into 2.0 --- UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java | 190 ++++++++++++++++++++++++++++++++++------------- 1 files changed, 138 insertions(+), 52 deletions(-) diff --git a/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java b/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java index 495ce14..443b590 100644 --- a/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java +++ b/UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java @@ -596,14 +596,21 @@ new Timer().schedule(new TimerTask() { @Override public void run() { - Process process = null; try { - process = Runtime.getRuntime().exec("sudo rm -rf /home/igotechgh/nginx/html/files/audio/" + fileName); - } catch (IOException e) { - throw new RuntimeException(e); - } - if (process != null) { - process.destroy(); + // 使用Runtime执行命令 + Process process = Runtime.getRuntime().exec("sudo rm -rf /home/igotechgh/nginx/html/files/audio/" + fileName); + // 读取命令的输出 + BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); + String line; + while ((line = reader.readLine()) != null) { + System.out.println(line); + } + // 等待命令执行完成 + process.waitFor(); + // 关闭流 + reader.close(); + } catch (IOException | InterruptedException e) { + e.printStackTrace(); } } }, 30000); @@ -817,14 +824,21 @@ new Timer().schedule(new TimerTask() { @Override public void run() { - Process process = null; try { - process = Runtime.getRuntime().exec("sudo rm -rf /home/igotechgh/nginx/html/files/audio/" + fileName); - } catch (IOException e) { - throw new RuntimeException(e); - } - if (process != null) { - process.destroy(); + // 使用Runtime执行命令 + Process process = Runtime.getRuntime().exec("sudo rm -rf /home/igotechgh/nginx/html/files/audio/" + fileName); + // 读取命令的输出 + BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); + String line; + while ((line = reader.readLine()) != null) { + System.out.println(line); + } + // 等待命令执行完成 + process.waitFor(); + // 关闭流 + reader.close(); + } catch (IOException | InterruptedException e) { + e.printStackTrace(); } } }, 30000); @@ -934,14 +948,21 @@ new Timer().schedule(new TimerTask() { @Override public void run() { - Process process = null; try { - process = Runtime.getRuntime().exec("sudo rm -rf /home/igotechgh/nginx/html/files/audio/" + fileName); - } catch (IOException e) { - throw new RuntimeException(e); - } - if (process != null) { - process.destroy(); + // 使用Runtime执行命令 + Process process = Runtime.getRuntime().exec("sudo rm -rf /home/igotechgh/nginx/html/files/audio/" + fileName); + // 读取命令的输出 + BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); + String line; + while ((line = reader.readLine()) != null) { + System.out.println(line); + } + // 等待命令执行完成 + process.waitFor(); + // 关闭流 + reader.close(); + } catch (IOException | InterruptedException e) { + e.printStackTrace(); } } }, 30000); @@ -1045,13 +1066,13 @@ } //计算红包 - if(null != redDeduction && 1 == redDeduction){ + if(null != redDeduction && 1 == redDeduction && null == orderLogistics.getRedPacketId()){ RedEnvelopePaymentSettings redEnvelopePaymentSettings = redEnvelopePaymentSettingsService.getRedEnvelopePaymentSettings(); if(null != redEnvelopePaymentSettings){ Double total = userRedPacketRecordService.queryRemainingAmount(uid); List<UserRedPacketRecord> userRedPacketRecords = userRedPacketRecordService.selectList(new EntityWrapper<UserRedPacketRecord>().eq("userId", uid) .eq("state", 1).eq("companyId", orderLogistics.getCompanyId()).gt("remainingAmount", 0).orderBy("insertTime", false)); - + BigDecimal deductionRatio = redEnvelopePaymentSettings.getDeductionRatio(); BigDecimal multiply1 = orderMoney.multiply(deductionRatio.divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_EVEN); if(total > 0 && multiply1.doubleValue() > 0 && total.compareTo(multiply1.doubleValue()) >= 0){ @@ -1061,12 +1082,12 @@ //获取红包id JSONArray jsonArray = new JSONArray(); for (UserRedPacketRecord userRedPacketRecord : userRedPacketRecords) { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("id", userRedPacketRecord.getId()); - BigDecimal remainingAmount = new BigDecimal(userRedPacketRecord.getRemainingAmount()); if(multiply1.compareTo(BigDecimal.ZERO) == 0){ break; } + JSONObject jsonObject = new JSONObject(); + jsonObject.put("id", userRedPacketRecord.getId()); + BigDecimal remainingAmount = new BigDecimal(userRedPacketRecord.getRemainingAmount()); if(multiply1.compareTo(remainingAmount) >= 0){ userRedPacketRecord.setRemainingAmount(0D); userRedPacketRecord.setEndTime(new Date()); @@ -1074,14 +1095,15 @@ multiply1 = multiply1.subtract(remainingAmount).setScale(2, RoundingMode.HALF_EVEN); jsonObject.put("money", remainingAmount); jsonArray.add(jsonObject); - userRedPacketRecordService.updateById(userRedPacketRecord); }else if(remainingAmount.compareTo(multiply1) > 0){ userRedPacketRecord.setRemainingAmount(remainingAmount.subtract(multiply1).setScale(2, RoundingMode.HALF_EVEN).doubleValue()); jsonObject.put("money", multiply1); jsonArray.add(jsonObject); - userRedPacketRecordService.updateById(userRedPacketRecord); multiply1 = BigDecimal.ZERO; } + } + if(userRedPacketRecords.size() > 0){ + userRedPacketRecordService.updateBatchById(userRedPacketRecords); } orderLogistics.setRedPacketId(jsonArray.toJSONString()); } @@ -1090,29 +1112,18 @@ orderMoney = orderMoney.subtract(new BigDecimal(total)).setScale(2, RoundingMode.HALF_EVEN); //获取红包id JSONArray jsonArray = new JSONArray(); - BigDecimal multiply = new BigDecimal(total); for (UserRedPacketRecord userRedPacketRecord : userRedPacketRecords) { JSONObject jsonObject = new JSONObject(); jsonObject.put("id", userRedPacketRecord.getId()); - BigDecimal remainingAmount = new BigDecimal(userRedPacketRecord.getRemainingAmount()); - if(multiply.compareTo(BigDecimal.ZERO) == 0){ - break; - } - if(multiply.compareTo(remainingAmount) >= 0){ - userRedPacketRecord.setRemainingAmount(0D); - userRedPacketRecord.setEndTime(new Date()); - userRedPacketRecord.setState(2); - multiply = multiply.subtract(remainingAmount).setScale(2, RoundingMode.HALF_EVEN); - jsonObject.put("money", remainingAmount); - jsonArray.add(jsonObject); - userRedPacketRecordService.updateById(userRedPacketRecord); - }else if(remainingAmount.compareTo(multiply) > 0){ - userRedPacketRecord.setRemainingAmount(remainingAmount.subtract(multiply).setScale(2, RoundingMode.HALF_EVEN).doubleValue()); - jsonObject.put("money", multiply); - jsonArray.add(jsonObject); - userRedPacketRecordService.updateById(userRedPacketRecord); - multiply = BigDecimal.ZERO; - } + jsonObject.put("money", userRedPacketRecord.getRemainingAmount()); + jsonArray.add(jsonObject); + + userRedPacketRecord.setRemainingAmount(0D); + userRedPacketRecord.setEndTime(new Date()); + userRedPacketRecord.setState(2); + } + if(userRedPacketRecords.size() > 0){ + userRedPacketRecordService.updateBatchById(userRedPacketRecords); } orderLogistics.setRedPacketId(jsonArray.toJSONString()); } @@ -1746,6 +1757,7 @@ 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')")); @@ -1756,12 +1768,12 @@ //日结算 if(maxPrice.compareTo(total.doubleValue()) <= 0){ SettlementRecord settlementRecord = settlementRecordService.selectOne(new EntityWrapper<SettlementRecord>().eq("driverId", orderLogistics.getDriverId()) - .eq("type", 1).eq("paymentStatus", 1).last(" and day = DATE_FORMAT(now(), '%Y-%m-%d')")); + .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(1); + settlementRecord.setType(type1); settlementRecord.setPaymentStatus(1); settlementRecord.setPayMoney(total.doubleValue()); settlementRecord.setInsertTime(new Date()); @@ -1773,6 +1785,37 @@ 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)){ + fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); + fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); + }else{ + fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); + } + }catch (Exception e){ + e.printStackTrace(); + } + }).start(); } } } @@ -1789,7 +1832,50 @@ public void run() { pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, ""); pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, ""); - pushUtil.pushOfflinePayment(2, orderLogistics.getDriverId(), orderLogistics.getId(), 4, orderLogistics.getPayMoney()); + Integer language1 = driver.getLanguage(); + String text = ""; + switch (language1){ + case 1: + text = "客户已选择支付现金,因此您必须收款。确定您已收到此订单费用:现金GHS " + orderLogistics.getPayMoney(); + break; + case 2: + text = "The client chose to pay in cash, so you must collect the payment.Confirm if you received the charge for this order: Cash GHS " + orderLogistics.getPayMoney(); + break; + case 3: + text = "Le client a choisi de payer en espèces, vous devez donc encaisser le paiement.Confirmez si vous avez reçu les frais pour cette commande : Espèces GHS " + orderLogistics.getPayMoney(); + break; + + } + String audioUrl = ""; + String fileName = "offlinePayment" + orderLogistics.getDriverId() + UUIDUtil.getRandomCode(5) + ".mp3"; + try { + audioUrl = TextToSpeechUtil.create(language1 == 1 ? "cmn-CN" : language1 == 2 ? "en-US" : "fr-FR", text, fileName); + } catch (Exception e) { + throw new RuntimeException(e); + } + //定时任务删除语音文件 + new Timer().schedule(new TimerTask() { + @Override + public void run() { + try { + // 使用Runtime执行命令 + Process process = Runtime.getRuntime().exec("sudo rm -rf /home/igotechgh/nginx/html/files/audio/" + fileName); + // 读取命令的输出 + BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); + String line; + while ((line = reader.readLine()) != null) { + System.out.println(line); + } + // 等待命令执行完成 + process.waitFor(); + // 关闭流 + reader.close(); + } catch (IOException | InterruptedException e) { + e.printStackTrace(); + } + } + }, 30000); + pushUtil.pushOfflinePayment(2, orderLogistics.getDriverId(), orderLogistics.getId(), 4, orderLogistics.getPayMoney(), audioUrl); } }).start(); @@ -3307,7 +3393,7 @@ BaseWarpper baseWarpper = new BaseWarpper(); double amount = 0; CancleOrder query = cancleOrderService.query(orderLogistics.getCompanyId()); - if(null == query || null == orderLogistics.getDriverId()){ + if(null == query || null == orderLogistics.getDriverId() || orderLogistics.getState() == 11){ baseWarpper.setAmount(amount); return ResultUtil.success(baseWarpper); } -- Gitblit v1.7.1