From f85ea638d98b302c590e65f00e6912d91601613c Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期六, 09 十一月 2024 15:53:53 +0800 Subject: [PATCH] 修改bug --- ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/specialTrain/TOrderPrivateCarController.java | 191 +++++++++++++++++++++++++++++++++++++---------- 1 files changed, 148 insertions(+), 43 deletions(-) diff --git a/ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/specialTrain/TOrderPrivateCarController.java b/ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/specialTrain/TOrderPrivateCarController.java index 0fba0af..6ecc3c0 100644 --- a/ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/specialTrain/TOrderPrivateCarController.java +++ b/ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/specialTrain/TOrderPrivateCarController.java @@ -14,6 +14,7 @@ import com.stylefeng.guns.core.util.ExcelExportUtil; import com.stylefeng.guns.core.util.SinataUtil; import com.stylefeng.guns.core.util.ToolUtil; +import com.stylefeng.guns.modular.system.controller.util.PushUtil; import com.stylefeng.guns.modular.system.dao.OrderCancelMapper; import com.stylefeng.guns.modular.system.dao.TSystemPriceMapper; import com.stylefeng.guns.modular.system.model.*; @@ -22,6 +23,8 @@ import com.stylefeng.guns.modular.system.util.HttpRequestUtil; import com.stylefeng.guns.modular.system.util.PushURL; import com.stylefeng.guns.modular.system.util.ResultUtil; +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.Controller; @@ -31,10 +34,7 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.InputStreamReader; +import java.io.*; import java.math.BigDecimal; import java.math.MathContext; import java.math.RoundingMode; @@ -49,6 +49,8 @@ @Controller @RequestMapping("/tOrderPrivateCar") public class TOrderPrivateCarController extends BaseController { + + Logger log = LoggerFactory.getLogger(this.getClass()); private String PREFIX = "/system/tOrderPrivateCar/"; @@ -72,6 +74,9 @@ @Autowired private FleetEngineUtil fleetEngineUtil; + + @Resource + private ITUserService userService; @@ -203,6 +208,9 @@ TOrderPrivateCar orderPrivateCar = tOrderPrivateCarService.selectById(id); orderPrivateCar.setAbnormalMoney(orderPrivateCar.getOrderMoney()); orderPrivateCar.setOrderMoney(money); + orderPrivateCar.setPayMoney(money); + orderPrivateCar.setState(7); + orderPrivateCar.setIsDispute(1); orderPrivateCar.updateById(); return SUCCESS_TIP; } @@ -212,44 +220,127 @@ @ResponseBody public Object frozenOrder(@RequestParam Integer tOrderPrivateCarId) throws Exception { TOrderPrivateCar orderPrivateCar = tOrderPrivateCarService.selectById(tOrderPrivateCarId); - orderPrivateCar = this.setMoney(orderPrivateCar, 0D, 0D);//计算费用 - //添加已收入明细 - TCompany company = companyService.selectById(orderPrivateCar.getCompanyId()); - Double taxi = company.getSpeMoney().doubleValue(); - BigDecimal d = null;//企业收入 - BigDecimal c = null;//司机收入 - if(company.getIsSpeFixedOrProportional() == 2){//固定 - d = new BigDecimal(taxi); - c = orderPrivateCar.getOrderMoney().subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN); - } - if(company.getIsSpeFixedOrProportional() == 1){//比例 - Double price = orderPrivateCar.getStartMoney().doubleValue() + orderPrivateCar.getMileageMoney().doubleValue() + orderPrivateCar.getWaitMoney().doubleValue()+ orderPrivateCar.getDurationMoney().doubleValue() + orderPrivateCar.getLongDistanceMoney().doubleValue(); - d = new BigDecimal(price).multiply(new BigDecimal(taxi).divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_HALF_EVEN); - c = orderPrivateCar.getOrderMoney().subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN); - } - if(orderPrivateCar.getIsFrozen()==1){ - TDriver driver = driverService.selectById(orderPrivateCar.getDriverId()); - driver.setBusinessMoney(new BigDecimal(null != driver.getBusinessMoney() ? driver.getBusinessMoney() : 0).subtract(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); - driver.setLaveBusinessMoney(new BigDecimal(null != driver.getLaveBusinessMoney() ? driver.getLaveBusinessMoney() : 0).subtract(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); - driver.setBalance((null != driver.getBalance() ? driver.getBalance() : BigDecimal.ZERO).subtract(c).setScale(2, BigDecimal.ROUND_HALF_EVEN)); - driver.setFrozenMoney(driver.getFrozenMoney().add(c)); - driverService.updateById(driver); - }else{ + if(orderPrivateCar.getIsFrozen() == 1 && orderPrivateCar.getState() < 7){ + if(orderPrivateCar.getArriveTime()==null){ + orderPrivateCar.setArriveTime(orderPrivateCar.getStartServiceTime()); + } + orderPrivateCar = this.setMoney(orderPrivateCar, 0D, 0D);//计算费用 + orderPrivateCar.setPayManner(1); + orderPrivateCar.setParkMoney(new BigDecimal(0)); + orderPrivateCar.setRoadTollMoney(new BigDecimal(0)); + //判断是否首单免费-免费直接完成 + Integer orderNumber = tOrderPrivateCarService.selectCount(new EntityWrapper<TOrderPrivateCar>().eq("userId",orderPrivateCar.getUserId()).last("and (state=8 or state=9)")); + + if(orderNumber<=0){//判断是否是首单 + //判断是否免单 + TUser userInfo = userService.selectById(orderPrivateCar.getUserId()); + if(userInfo.getFreeMoney().doubleValue()>0d){ + if(orderPrivateCar.getOrderMoney().compareTo(userInfo.getFreeMoney())<=0){ + orderPrivateCar.setState(8); + orderPrivateCar.setIsFree(2); + //添加已收入明细 + TCompany company = companyService.selectById(orderPrivateCar.getCompanyId()); + Double speMoney = company.getSpeMoney().doubleValue(); + BigDecimal d = null;//企业收入 + BigDecimal c = null;//司机收入 + if(company.getIsSpeFixedOrProportional() == 2){//固定 + d = new BigDecimal(speMoney); + c = orderPrivateCar.getOrderMoney().subtract(d);//只有出行金额参与抽成,其余归属司机 + } + if(company.getIsSpeFixedOrProportional() == 1){//比例 + Double price = orderPrivateCar.getStartMoney().add(orderPrivateCar.getMileageMoney()).add(new BigDecimal(orderPrivateCar.getWaitMoney())).add(orderPrivateCar.getDurationMoney()).add(orderPrivateCar.getLongDistanceMoney()).doubleValue(); + d = new BigDecimal(price).multiply(new BigDecimal(speMoney).divide(new BigDecimal(100), new MathContext(2, RoundingMode.HALF_EVEN))); + c = orderPrivateCar.getOrderMoney().subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN); + } + incomeService.saveData(1, orderPrivateCar.getCompanyId(), 2, orderPrivateCar.getId(), 1, d.doubleValue()); + incomeService.saveData(2, orderPrivateCar.getDriverId(), 2, orderPrivateCar.getId(), 1, c.doubleValue()); + TDriver driver = driverService.selectById(orderPrivateCar.getDriverId()); + driver.setBusinessMoney(new BigDecimal(null != driver.getBusinessMoney() ? driver.getBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); + driver.setLaveBusinessMoney(new BigDecimal(null != driver.getLaveBusinessMoney() ? driver.getLaveBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); + driver.setBalance((null != driver.getBalance() ? driver.getBalance() : new BigDecimal("0")).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN)); + driverService.updateById(driver); + }else{ + orderPrivateCar.setState(7); + orderPrivateCar.setOrderMoney(orderPrivateCar.getOrderMoney().subtract(userInfo.getFreeMoney())); + orderPrivateCar.setFreeMoney(userInfo.getFreeMoney()); + + } + + }else{ + orderPrivateCar.setState(7); + } + + }else{ + orderPrivateCar.setState(7); + } + + tOrderPrivateCarService.updateById(orderPrivateCar); + + //修改行程数据 + boolean updateTrip = fleetEngineUtil.updateTrip("COMPLETE", null, null, orderPrivateCar.getTripId(), null, null, null, null); + if(!updateTrip){ + for (int i = 0; i < 5; i++) { + updateTrip = fleetEngineUtil.updateTrip("COMPLETE", null, null, orderPrivateCar.getTripId(), null, null, null, null); + if(updateTrip){ + break; + } + try { + Thread.sleep(3000L); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + } + //上报行程 + boolean reportBillableEvent = fleetEngineUtil.reportBillableEvent(orderPrivateCar.getTripId()); + if(!reportBillableEvent){ + for (int i = 0; i < 5; i++) { + reportBillableEvent = fleetEngineUtil.reportBillableEvent(orderPrivateCar.getTripId()); + if(reportBillableEvent){ + break; + } + try { + Thread.sleep(3000L); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + } + + + + TUser userInfo = userService.selectById(orderPrivateCar.getUserId()); + Integer language1 = userInfo.getLanguage(); + 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()); + + //回滚司机状态为空闲 TDriver driver = driverService.selectById(orderPrivateCar.getDriverId()); - driver.setBusinessMoney(new BigDecimal(null != driver.getBusinessMoney() ? driver.getBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); - driver.setLaveBusinessMoney(new BigDecimal(null != driver.getLaveBusinessMoney() ? driver.getLaveBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); - driver.setBalance((null != driver.getBalance() ? driver.getBalance() : BigDecimal.ZERO).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN)); - driver.setFrozenMoney(driver.getFrozenMoney().subtract(c)); + driver.setState(2); driverService.updateById(driver); + + TOrderPrivateCar finalOrderTaxi = orderPrivateCar; + new Thread(new Runnable() { + @Override + public void run() { + pushUtil.pushOrderState(1, finalOrderTaxi.getUserId(), finalOrderTaxi.getId(), 1, finalOrderTaxi.getState(), 0, ""); + pushUtil.pushOrderState(2, finalOrderTaxi.getDriverId(), finalOrderTaxi.getId(), 1, finalOrderTaxi.getState(), 0, ""); + } + }).start(); + + pushUtil.frozenOrder(orderPrivateCar.getDriverId(), 2); } - + orderPrivateCar.setIsFrozen(orderPrivateCar.getIsFrozen()==1?2:1); - orderPrivateCar.setState(7); - tOrderPrivateCarService.updateAllColumnById(orderPrivateCar); - + orderPrivateCar.setIsDispute(1); + tOrderPrivateCarService.updateById(orderPrivateCar); return SUCCESS_TIP; } + @Autowired + private PushUtil pushUtil; + @Autowired + private ITSystemNoticeService systemNoticeService; @Resource private TSystemPriceMapper systemPriceMapper; public TOrderPrivateCar setMoney(TOrderPrivateCar orderPrivateCar, Double parkingFee, Double crossingFee) throws Exception { @@ -480,7 +571,7 @@ if(orderPrivateCar.getIsplatPay()==2){ return "error"; } - //添加已收入明细 + //添加已收入明细 TCompany company = companyService.selectById(orderPrivateCar.getCompanyId()); Double taxi = company.getSpeMoney().doubleValue(); BigDecimal d = null;//企业收入 @@ -502,6 +593,9 @@ driver.setBalance((null != driver.getBalance() ? driver.getBalance() : BigDecimal.ZERO).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN)); driverService.updateById(driver); orderPrivateCar.setIsplatPay(2); + orderPrivateCar.setPayManner(1); + orderPrivateCar.setState(8); + orderPrivateCar.setPayMoney(orderPrivateCar.getOrderMoney()); tOrderPrivateCarService.updateAllColumnById(orderPrivateCar); return SUCCESS_TIP; } @@ -523,22 +617,33 @@ tOrderPrivateCar.setState(10); tOrderPrivateCarService.updateById(tOrderPrivateCar); - + + TUser tUser = userService.selectById(tOrderPrivateCar.getUserId()); + Integer language = tUser.getLanguage(); OrderCancel orderCancel = new OrderCancel(); orderCancel.setOrderId(tOrderPrivateCarId); orderCancel.setOrderType(1); - orderCancel.setReason("The platform cancels the order"); - orderCancel.setRemark("The platform cancels the order"); + orderCancel.setReason(language == 1 ? "平台取消订单" : language == 2 ? "The platform cancelled the order" : "La plateforme a annulé la commande"); + orderCancel.setRemark(language == 1 ? "平台取消订单" : language == 2 ? "The platform cancelled the order" : "La plateforme a annulé la commande"); orderCancel.setUserType(2); orderCancel.setState(2); orderCancel.setInsertTime(new Date()); orderCancelMapper.insert(orderCancel); //修改行程信息 - try { - fleetEngineUtil.updateTrip("CANCELED", null, null, tOrderPrivateCar.getTripId(), null, null, null, null); - } catch (Exception e) { - throw new RuntimeException(e); + boolean updateTrip = fleetEngineUtil.updateTrip("CANCELED", null, null, tOrderPrivateCar.getTripId(), null, null, null, null); + if(!updateTrip){ + for (int i = 0; i < 5; i++) { + updateTrip = fleetEngineUtil.updateTrip("CANCELED", null, null, tOrderPrivateCar.getTripId(), null, null, null, null); + if(updateTrip){ + break; + } + try { + Thread.sleep(3000L); + }catch (Exception e){ + e.printStackTrace(); + } + } } -- Gitblit v1.7.1