| | |
| | | package com.stylefeng.guns.modular.system.controller.specialTrain; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.stylefeng.guns.core.base.controller.BaseController; |
| | |
| | | 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.*; |
| | | import com.stylefeng.guns.modular.system.service.*; |
| | | import com.stylefeng.guns.modular.system.util.GoogleMap.FleetEngineUtil; |
| | | 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; |
| | |
| | | import java.io.FileInputStream; |
| | | import java.io.InputStreamReader; |
| | | import java.math.BigDecimal; |
| | | import java.math.MathContext; |
| | | import java.math.RoundingMode; |
| | | import java.util.*; |
| | | |
| | | /** |
| | |
| | | @Controller |
| | | @RequestMapping("/tOrderPrivateCar") |
| | | public class TOrderPrivateCarController extends BaseController { |
| | | |
| | | Logger log = LoggerFactory.getLogger(this.getClass()); |
| | | |
| | | private String PREFIX = "/system/tOrderPrivateCar/"; |
| | | |
| | |
| | | @Resource |
| | | private OrderCancelMapper orderCancelMapper; |
| | | |
| | | @Value("${pushMinistryOfTransport}") |
| | | private boolean pushMinistryOfTransport; |
| | | |
| | | @Value("${filePath}") |
| | | private String filePath; |
| | | |
| | | |
| | | |
| | | |
| | | @Autowired |
| | | private FleetEngineUtil fleetEngineUtil; |
| | | |
| | | @Resource |
| | | private ITUserService userService; |
| | | |
| | | @Resource |
| | | private ITCarService carService; |
| | | private ResultUtil resultUtil; |
| | | @Autowired |
| | | private ITCompanyService companyService; |
| | | @Autowired |
| | | private ITDriverService driverService; |
| | | @Autowired |
| | | private IIncomeService incomeService; |
| | | @Autowired |
| | | private PushUtil pushUtil; |
| | | @Autowired |
| | | private ITSystemNoticeService systemNoticeService; |
| | | @Resource |
| | | private TSystemPriceMapper systemPriceMapper; |
| | | |
| | | /** |
| | | * 跳转到专车订单首页 |
| | |
| | | model.addAttribute("item",item); |
| | | return PREFIX + "tOrderPrivateCar_orderDetail.html"; |
| | | } |
| | | |
| | | /** |
| | | * 跳转到修改专车订单 |
| | | */ |
| | |
| | | model.addAttribute("item",item); |
| | | return PREFIX + "toChangeMoney.html"; |
| | | } |
| | | |
| | | /** |
| | | * 跳转到出租车订单轨迹页面 |
| | | */ |
| | |
| | | page.setRecords(tOrderPrivateCarService.getPrivateCarOrderList(page,beginTime,endTime,ShiroKit.getUser().getRoleType(),ShiroKit.getUser().getObjectId(),orderNum,orderSource,userName,userPhone,passengers,passengersPhone,serverCarModelId,driver,state,smsNumber)); |
| | | return super.packForBT(page); |
| | | } |
| | | |
| | | private ResultUtil resultUtil; |
| | | |
| | | /** |
| | | * 获取订单轨迹 |
| | |
| | | return resultUtil; |
| | | } |
| | | |
| | | @Autowired |
| | | private ITCompanyService companyService; |
| | | |
| | | @Autowired |
| | | private ITDriverService driverService; |
| | | |
| | | @Autowired |
| | | private IIncomeService incomeService; |
| | | |
| | | |
| | | |
| | | /** |
| | | * 支付专车订单 |
| | | */ |
| | |
| | | TOrderPrivateCar orderPrivateCar = tOrderPrivateCarService.selectById(id); |
| | | orderPrivateCar.setAbnormalMoney(orderPrivateCar.getOrderMoney()); |
| | | orderPrivateCar.setOrderMoney(money); |
| | | orderPrivateCar.setPayMoney(money); |
| | | orderPrivateCar.setPayType(5); |
| | | orderPrivateCar.setState(7); |
| | | orderPrivateCar.setIsDispute(1); |
| | | orderPrivateCar.updateById(); |
| | | return SUCCESS_TIP; |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "/frozenOrder") |
| | | @ResponseBody |
| | | public Object frozenOrder(@RequestParam Integer tOrderPrivateCarId) { |
| | | public Object frozenOrder(@RequestParam Integer tOrderPrivateCarId) throws Exception { |
| | | TOrderPrivateCar orderPrivateCar = tOrderPrivateCarService.selectById(tOrderPrivateCarId); |
| | | |
| | | //添加已收入明细 |
| | | 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){ |
| | | 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, orderPrivateCar.getId(), 1); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip("COMPLETE", null, null, orderPrivateCar.getTripId(), null, null, null, null, orderPrivateCar.getId(), 1); |
| | | if(updateTrip){ |
| | | orderPrivateCar.setIsover(1); |
| | | tOrderPrivateCarService.updateById(orderPrivateCar); |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | }else{ |
| | | orderPrivateCar.setIsover(1); |
| | | tOrderPrivateCarService.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) { |
| | | 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).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)); |
| | | driver.setState(2); |
| | | driverService.updateById(driver); |
| | | }else{ |
| | | |
| | | 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)); |
| | | 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); |
| | | tOrderPrivateCarService.updateAllColumnById(orderPrivateCar); |
| | | orderPrivateCar.setIsDispute(1); |
| | | tOrderPrivateCarService.updateById(orderPrivateCar); |
| | | return SUCCESS_TIP; |
| | | } |
| | | |
| | | public TOrderPrivateCar setMoney(TOrderPrivateCar orderPrivateCar, Double parkingFee, Double crossingFee) throws Exception { |
| | | System.err.println("计算金额:"+orderPrivateCar); |
| | | Map<String, Object> query1 = systemPriceMapper.query(orderPrivateCar.getCompanyId(), 1, orderPrivateCar.getServerCarModelId()); |
| | | //开始根据不同的方式计算金额 |
| | | double amount = 0; |
| | | JSONObject jsonObject = JSON.parseObject(query1.get("content").toString()); |
| | | Double num1 = jsonObject.getDouble("num1");//起步价(元) |
| | | Double num2 = jsonObject.getDouble("num2");//起步公里(公里) |
| | | Double num3 = jsonObject.getDouble("num3");//起步时间(分钟) |
| | | Double num4 = jsonObject.getDouble("num4");//里程费(元) |
| | | Double num5 = jsonObject.getDouble("num5");//时长费(分钟) |
| | | Double num6 = jsonObject.getDouble("num6");//等待费(分钟) |
| | | Double num7 = jsonObject.getDouble("num7");//等待费(元) |
| | | Double num8 = jsonObject.getDouble("num8");//远途费(公里) |
| | | Double num9 = jsonObject.getDouble("num9");//远途费(公里) |
| | | Double num10 = jsonObject.getDouble("num10");//远途费(元) |
| | | Double num11 = jsonObject.getDouble("num11");//远途费(公里) |
| | | Double num12 = jsonObject.getDouble("num12");//远途费(公里) |
| | | Double num13 = jsonObject.getDouble("num13");//远途费(元) |
| | | Double num14 = jsonObject.getDouble("num14");//远途费(公里) |
| | | Double num15 = jsonObject.getDouble("num15");//远途费(元) |
| | | String num16 = jsonObject.getString("num16");//夜间费(开始时间) |
| | | Double num17 = jsonObject.getDouble("num17");//夜间费(元) |
| | | Double num18 = jsonObject.getDouble("num18");//夜间费(元) |
| | | Double num19 = jsonObject.getDouble("num19");//夜间费(元) |
| | | Double num20 = jsonObject.getDouble("num20");//夜间费(元) |
| | | Double num21 = jsonObject.getDouble("num21");//夜间费(元) |
| | | Double num22 = jsonObject.getDouble("num22");//夜间费(元) |
| | | String num23 = jsonObject.getString("num23");//高峰费(开始时间) |
| | | String num24 = jsonObject.getString("num24");//高峰费(开始时间) |
| | | Double num25 = jsonObject.getDouble("num25");//高峰费(元) |
| | | Double num26 = jsonObject.getDouble("num26");//高峰费(元) |
| | | Double num27 = jsonObject.getDouble("num27");//高峰费(元) |
| | | Double num28 = jsonObject.getDouble("num28");//高峰费(元) |
| | | Double num29 = jsonObject.getDouble("num29");//高峰费(元) |
| | | Double num30 = jsonObject.getDouble("num30");//高峰费(元) |
| | | |
| | | Date date = new Date(); |
| | | double d = (null == orderPrivateCar.getMileage() ? 0D : orderPrivateCar.getMileage()) / 1000;//实际公里 |
| | | if (orderPrivateCar.getEndServiceTime() == null){ |
| | | orderPrivateCar.setEndServiceTime(new Date()); |
| | | } |
| | | double t=1; |
| | | if (orderPrivateCar.getStartServiceTime() == null){ |
| | | t = 1;//实际时间(不满一分钟按一分钟算) |
| | | }else{ |
| | | t = ((orderPrivateCar.getEndServiceTime().getTime() - orderPrivateCar.getStartServiceTime().getTime()) / 60000) + 1;//实际时间(不满一分钟按一分钟算) |
| | | } |
| | | double w = ((orderPrivateCar.getStartServiceTime().getTime() - 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();//超出等待时间的时间 |
| | | double yt1 = 0;//远途1段 |
| | | double yt2 = 0;//远途2段 |
| | | double yt3 = 0;//远途3段 |
| | | |
| | | |
| | | //夜间服务处理逻辑 |
| | | 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])); |
| | | |
| | | 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(new BigDecimal(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));//里程费 |
| | | orderPrivateCar.setDuration(new BigDecimal(t1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | orderPrivateCar.setDurationMoney(new BigDecimal(t1 * num19).setScale(2, BigDecimal.ROUND_HALF_EVEN));//时长费 |
| | | 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));//远途费 |
| | | orderPrivateCar.setParkMoney(new BigDecimal(parkingFee));//停车费 |
| | | orderPrivateCar.setRoadTollMoney(new BigDecimal(crossingFee));//过路费 |
| | | orderPrivateCar.setRedPacketMoney(new BigDecimal("0"));//红包抵扣 |
| | | orderPrivateCar.setCouponMoney(new BigDecimal("0"));//优惠券抵扣 |
| | | orderPrivateCar.setDiscount(0D);//优惠抵扣 |
| | | orderPrivateCar.setPayMoney(new BigDecimal("0"));//支付金额 |
| | | orderPrivateCar.setOrderMoney(new BigDecimal(amount + parkingFee + crossingFee).setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | orderPrivateCar.setMoneyType(2); |
| | | orderPrivateCar.setMoneyTime(num16); |
| | | return orderPrivateCar; |
| | | } |
| | | } |
| | | |
| | | |
| | | //高峰时段处理逻辑 |
| | | Calendar s1 = Calendar.getInstance(); |
| | | s1.setTime(date); |
| | | s1.set(Calendar.HOUR_OF_DAY, Integer.valueOf(num23.split(" - ")[0].split(":")[0])); |
| | | s1.set(Calendar.MINUTE, Integer.valueOf(num23.split(" - ")[0].split(":")[1])); |
| | | |
| | | Calendar e1 = Calendar.getInstance(); |
| | | e1.setTime(date); |
| | | e1.set(Calendar.HOUR_OF_DAY, Integer.valueOf(num23.split(" - ")[1].split(":")[0])); |
| | | e1.set(Calendar.MINUTE, Integer.valueOf(num23.split(" - ")[1].split(":")[1])); |
| | | |
| | | Calendar s2 = Calendar.getInstance(); |
| | | s2.setTime(date); |
| | | s2.set(Calendar.HOUR_OF_DAY, Integer.valueOf(num24.split(" - ")[0].split(":")[0])); |
| | | s2.set(Calendar.MINUTE, Integer.valueOf(num24.split(" - ")[0].split(":")[1])); |
| | | |
| | | Calendar e2 = Calendar.getInstance(); |
| | | e2.setTime(date); |
| | | e2.set(Calendar.HOUR_OF_DAY, Integer.valueOf(num24.split(" - ")[1].split(":")[0])); |
| | | e2.set(Calendar.MINUTE, Integer.valueOf(num24.split(" - ")[1].split(":")[1])); |
| | | |
| | | if((date.getTime() > s1.getTimeInMillis() && date.getTime() < e1.getTimeInMillis()) || (date.getTime() > s2.getTimeInMillis() && date.getTime() < e2.getTimeInMillis())){ |
| | | if(d > num8.doubleValue() && d <= num9.doubleValue()){ |
| | | yt1 = num28 * (d - num8); |
| | | } |
| | | if(d > num9.doubleValue()){ |
| | | yt1 = num28 * (num9 - num8); |
| | | } |
| | | if(d > num11.doubleValue() && d <= num12.doubleValue()){ |
| | | yt2 = num29 * (d - num11); |
| | | } |
| | | if(d > num12.doubleValue()){ |
| | | yt2 = num29 * (num12 - num11); |
| | | } |
| | | if(d > num14.doubleValue()){ |
| | | yt3 = num30 * (d - num14); |
| | | } |
| | | amount = num25 + (d1 * num26) + (t1 * num27) + (w1 * num7) + yt1 + yt2 + yt3; |
| | | orderPrivateCar.setStartMileage(num2); |
| | | orderPrivateCar.setStartDuration((int)(num3.doubleValue())); |
| | | orderPrivateCar.setStartMoney(new BigDecimal(num25));//起步价 |
| | | orderPrivateCar.setMileageKilometers(new BigDecimal(d1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | orderPrivateCar.setMileageMoney(new BigDecimal(d1 * num26).setScale(2, BigDecimal.ROUND_HALF_EVEN));//里程费 |
| | | orderPrivateCar.setDuration(new BigDecimal(t1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | orderPrivateCar.setDurationMoney(new BigDecimal(t1 * num27).setScale(2, BigDecimal.ROUND_HALF_EVEN));//时长费 |
| | | 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));//远途费 |
| | | orderPrivateCar.setParkMoney(new BigDecimal(parkingFee));//停车费 |
| | | orderPrivateCar.setRoadTollMoney(new BigDecimal(crossingFee));//过路费 |
| | | orderPrivateCar.setRedPacketMoney(new BigDecimal("0"));//红包抵扣 |
| | | orderPrivateCar.setCouponMoney(new BigDecimal("0"));//优惠券抵扣 |
| | | orderPrivateCar.setDiscount(0D);//优惠抵扣 |
| | | orderPrivateCar.setPayMoney(new BigDecimal("0"));//支付金额 |
| | | orderPrivateCar.setOrderMoney(new BigDecimal(amount + parkingFee + crossingFee).setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | |
| | | orderPrivateCar.setMoneyType(3); |
| | | if((date.getTime() > s1.getTimeInMillis() && date.getTime() < e1.getTimeInMillis())){ |
| | | orderPrivateCar.setMoneyTime(num23); |
| | | }else{ |
| | | orderPrivateCar.setMoneyTime(num24); |
| | | } |
| | | |
| | | return orderPrivateCar; |
| | | } |
| | | |
| | | //其他时间段的计算 |
| | | if(d > num8.doubleValue() && d <= num9.doubleValue()){ |
| | | yt1 = num10 * (d - num8); |
| | | } |
| | | if(d > num9.doubleValue()){ |
| | | yt1 = num10 * (num9 - num8); |
| | | } |
| | | if(d > num11.doubleValue() && d <= num12.doubleValue()){ |
| | | yt2 = num13 * (d - num11); |
| | | } |
| | | if(d > num12.doubleValue()){ |
| | | yt2 = num13 * (num12 - num11); |
| | | } |
| | | if(d > num14.doubleValue()){ |
| | | yt3 = num15 * (d - num14); |
| | | } |
| | | amount = num1 + (d1 * num4) + (t1 * num5) + (w1 * num7) + yt1 + yt2 + yt3; |
| | | orderPrivateCar.setStartMileage(num2); |
| | | orderPrivateCar.setStartDuration((int)(num3.doubleValue())); |
| | | orderPrivateCar.setStartMoney(new BigDecimal(num1));//起步价 |
| | | orderPrivateCar.setMileageKilometers(new BigDecimal(d1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | orderPrivateCar.setMileageMoney(new BigDecimal(d1 * num4).setScale(2, BigDecimal.ROUND_HALF_EVEN));//里程费 |
| | | orderPrivateCar.setDuration(new BigDecimal(t1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | orderPrivateCar.setDurationMoney(new BigDecimal(t1 * num5).setScale(2, BigDecimal.ROUND_HALF_EVEN));//时长费 |
| | | 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));//远途费 |
| | | orderPrivateCar.setParkMoney(new BigDecimal(parkingFee));//停车费 |
| | | orderPrivateCar.setRoadTollMoney(new BigDecimal(crossingFee));//过路费 |
| | | orderPrivateCar.setRedPacketMoney(new BigDecimal("0"));//红包抵扣 |
| | | orderPrivateCar.setCouponMoney(new BigDecimal("0"));//优惠券抵扣 |
| | | orderPrivateCar.setDiscount(0D);//优惠抵扣 |
| | | orderPrivateCar.setPayMoney(new BigDecimal("0"));//支付金额 |
| | | orderPrivateCar.setOrderMoney(new BigDecimal(amount + parkingFee + crossingFee).setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | // |
| | | orderPrivateCar.setMoneyType(1); |
| | | return orderPrivateCar; |
| | | } |
| | | /** |
| | | * 支付专车订单 |
| | |
| | | if(orderPrivateCar.getIsplatPay()==2){ |
| | | return "error"; |
| | | } |
| | | //添加已收入明细 |
| | | //添加已收入明细 |
| | | TCompany company = companyService.selectById(orderPrivateCar.getCompanyId()); |
| | | Double taxi = company.getSpeMoney().doubleValue(); |
| | | BigDecimal d = null;//企业收入 |
| | |
| | | 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.setPayType(5); |
| | | orderPrivateCar.setPayMoney(orderPrivateCar.getOrderMoney()); |
| | | tOrderPrivateCarService.updateAllColumnById(orderPrivateCar); |
| | | return SUCCESS_TIP; |
| | | } |
| | |
| | | @ResponseBody |
| | | public Object cancel(@RequestParam Integer tOrderPrivateCarId) { |
| | | TOrderPrivateCar tOrderPrivateCar = tOrderPrivateCarService.selectById(tOrderPrivateCarId); |
| | | |
| | | if(Arrays.asList(6, 7, 8, 9, 10).contains(tOrderPrivateCar.getState())){ |
| | | return ERROR; |
| | | } |
| | | //修改之前司机状态 -- 空闲 |
| | | if(null != tOrderPrivateCar.getDriverId()){ |
| | | TDriver driver = tDriverService.selectById(tOrderPrivateCar.getDriverId()); |
| | |
| | | |
| | | 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("平台取消订单"); |
| | | orderCancel.setRemark("平台取消订单"); |
| | | 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); |
| | | |
| | | |
| | | //修改行程信息 |
| | | TCar car = carService.selectById(tOrderPrivateCar.getCarId()); |
| | | //修改行程信息 |
| | | boolean updateTrip = fleetEngineUtil.updateTrip("CANCELED", (null != car ? car.getVehicleId() : null), null, tOrderPrivateCar.getTripId(), null, null, null, null, tOrderPrivateCar.getId(), 1); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip("CANCELED", (null != car ? car.getVehicleId() : null), null, tOrderPrivateCar.getTripId(), null, null, null, null, tOrderPrivateCar.getId(), 1); |
| | | if(updateTrip){ |
| | | tOrderPrivateCar.setIsover(1); |
| | | tOrderPrivateCarService.updateById(tOrderPrivateCar); |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | }else{ |
| | | tOrderPrivateCar.setIsover(1); |
| | | tOrderPrivateCarService.updateById(tOrderPrivateCar); |
| | | } |
| | | |
| | | |
| | | //增加推送 |
| | | Map<String,String> map = new HashMap<>(); |
| | | map.put("id", tOrderPrivateCar.getId().toString()); |
| | | map.put("orderType", "1"); |
| | | map.put("from", "admin"); |
| | | String result = HttpRequestUtil.postRequest(PushURL.cancel_order_url, map); |
| | | System.out.println("专车取消:【orderId="+tOrderPrivateCar.getId().toString()+"】,调用接口:"+result); |
| | | return SUCCESS_TIP; |