From 2e366b939271b6ea338641f8a72d1bcd2182dbe7 Mon Sep 17 00:00:00 2001
From: zhibing.pu <393733352@qq.com>
Date: 星期五, 19 四月 2024 17:56:18 +0800
Subject: [PATCH] 新增加功能
---
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java | 872 +++++++++++++++++++++++++--------------------------------
1 files changed, 388 insertions(+), 484 deletions(-)
diff --git a/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java b/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java
index a361f5e..9c0cb83 100644
--- a/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java
+++ b/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java
@@ -13,16 +13,20 @@
import com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar;
import com.stylefeng.guns.modular.system.dao.CarMapper;
import com.stylefeng.guns.modular.system.dao.RegionMapper;
+import com.stylefeng.guns.modular.system.dao.SystemPriceMapper;
import com.stylefeng.guns.modular.system.dao.UserInfoMapper;
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.itextpdf.HtmlToPdfUtils;
+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 org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
+import org.quartz.JobDataMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@@ -105,6 +109,12 @@
@Autowired
private IOrderEvaluateService orderEvaluateService;
+
+ @Autowired
+ private IReminderRulesService reminderRulesService;
+
+ @Resource
+ private SystemPriceMapper systemPriceMapper;
@@ -152,58 +162,34 @@
orderLogistics.setState(2);
orderLogistics.setSnatchOrderTime(new Date());
- //调用高德创建轨迹
-// String s = gdFalconUtil.selectTerminal(driver.getPhone());
-// String track = gdFalconUtil.createTrack(s);
-// orderLogistics.setTrackId(track);
-
- //调用移动的小号接口
-// Map<String, String> geocode = gdMapGeocodingUtil.geocode(orderLogistics.getStartLon().toString(), orderLogistics.getStartLat().toString());
-// Region region = regionMapper.query(geocode.get("districtCode"));
-// Map<String, String> map = chinaMobileUtil.midAxbBindSend(orderLogistics.getRecipientPhone(), driver.getPhone(), Integer.valueOf(region.getCitycode().substring(1)));
-// if(String.valueOf(map.get("code")).equals("200")){
-// orderLogistics.setTelX(map.get("telX"));
-// orderLogistics.setBindId(map.get("bindId"));
-// }
-
this.updateById(orderLogistics);
-
- //添加已收入明细
- Company company = companyService.selectById(driver.getCompanyId());
- Double speMoney = orderLogistics.getType() == 4 ? company.getSameLogisticsMoney() : company.getCrossLogisticsMoney();
- BigDecimal d = null;//企业收入
- BigDecimal c = null;//司机收入
- if(company.getIsSpeFixedOrProportional() == 2){//固定
- d = new BigDecimal(speMoney);
- c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d);//只有出行金额参与抽成,其余归属司机
+
+
+ //todo 待翻译
+ //添加定时任务(普通任务)
+ ReminderRules reminderRules = reminderRulesService.selectOne(new EntityWrapper<ReminderRules>().eq("companyId", driver.getCompanyId()));
+ if(null != reminderRules){
+ JSONObject jsonObject = JSON.parseObject(reminderRules.getContent());
+ long packageTimeoutReminderInterval = jsonObject.getInteger("packageTimeoutReminderInterval") * 60000L;
+ long m = (System.currentTimeMillis() - orderLogistics.getSnatchOrderTime().getTime()) / 60000;
+ JobDataMap jobDataMap = new JobDataMap();
+ jobDataMap.put("driverId", uid);
+ jobDataMap.put("orderId", orderLogistics.getId());
+ jobDataMap.put("orderType", 4);
+ jobDataMap.put("describe", "您的打车订单已超时" + m + "分钟,请抓紧!");
+ QuartzUtil.addSimpleQuartzTask(
+ new OrderTimeOutJob().buildQuartzJob(UUIDUtil.getRandomCode(5) + "_" + orderLogistics.getId() + "_4", "ORDER_TIME_OUT", jobDataMap)
+ , new Date(packageTimeoutReminderInterval), packageTimeoutReminderInterval, -1);
}
- if(company.getIsSpeFixedOrProportional() == 1){//比例
- Double price = orderLogistics.getTravelMoney();
- d = new BigDecimal(price).multiply(new BigDecimal(speMoney).divide(new BigDecimal(100), new MathContext(2, RoundingMode.HALF_EVEN)));
- c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN);
- }
-// incomeService.saveData(1, orderLogistics.getCompanyId(), 2, orderLogistics.getId(), orderLogistics.getType(), d.doubleValue());
-// incomeService.saveData(2, orderLogistics.getDriverId(), 2, orderLogistics.getId(), orderLogistics.getType(), c.doubleValue());
- 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(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
- driverService.updateById(driver);
-
-
-
+
+
+
//推送相关代码------------------start----------------
new Thread(new Runnable() {
@Override
public void run() {
pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState());
pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState());
- }
- }).start();
-
- new Thread(new Runnable() {
- @Override
- public void run() {
- pushUtil.pushDriverPosition(orderId, orderLogistics.getType());
}
}).start();
@@ -275,6 +261,7 @@
orderLogistics.setState(3);
orderLogistics.setSetOutTime(new Date());
systemNoticeService.addSystemNotice(1, language == 1 ? "司机已出发,请耐心等待" : language == 2 ? "The driver is on the way, please wait." : "Le chauffeur est en route. Veuillez patienter.", orderLogistics.getUserId());
+ pushUtil.pushDriverPosition(orderId, 4);
break;
case 4://到达预约点,等待客户上车
orderLogistics.setState(4);
@@ -288,152 +275,18 @@
orderLogistics.setBoardingTime(new Date());
orderLogistics.setState(5);
orderLogistics.setStartServiceTime(new Date());
-
- pushUtil.pushDriverPosition(orderLogistics.getId(), orderLogistics.getType());//主动推送司机定位
break;
- case 6://结束服务(专车可以返回继续服务)不修改状态
+ case 6://结束服务
orderLogistics.setGetoffLon(lon);
orderLogistics.setGetoffLat(lat);
orderLogistics.setGetoffAddress(address);
orderLogistics.setGetoffTime(new Date());
orderLogistics.setEndServiceTime(new Date());
orderLogistics.setState(6);
-
- if(orderLogistics.getPayType() != 4){
- //添加已收入明细
- Company company = companyService.selectById(orderLogistics.getCompanyId());
- Double speMoney = company.getSameLogisticsMoney();
- BigDecimal d = null;//企业收入
- BigDecimal c = null;//司机收入
- if(company.getIsSameLogisticsFixedOrProportional() == 2){//固定
- d = new BigDecimal(speMoney);
- c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d);//只有出行金额参与抽成,其余归属司机
- }
- if(company.getIsSameLogisticsFixedOrProportional() == 1){//比例
- Double price = orderLogistics.getOrderMoney();
- d = new BigDecimal(price).multiply(new BigDecimal(speMoney).divide(new BigDecimal(100), new MathContext(2, RoundingMode.HALF_EVEN)));
- c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN);
- }
-
- incomeService.saveData(1, orderLogistics.getCompanyId(), 2, orderLogistics.getId(), 4, d.doubleValue());
- incomeService.saveData(2, orderLogistics.getDriverId(), 2, orderLogistics.getId(), 4, c.doubleValue());
- Driver driver = driverService.selectById(orderLogistics.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(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
- driverService.updateById(driver);
- }
-
- if (orderLogistics.getPayType()==4||!orderLogisticsId.isEmpty()){
- double sum = 0;
- if (orderLogistics.getPayType()==4){
- sum= orderLogistics.getOrderMoney();
- }
-
- if (!orderLogisticsId.isEmpty()){
- for (OrderLogisticsSpread orderLogisticsSpread : orderLogisticsId) {
- sum = sum +orderLogisticsSpread.getPrice();
- }
- }
-
- Driver driver = driverService.selectById(orderLogistics.getDriverId());
- if(null != orderLogistics.getCouponMoney() && 0 < orderLogistics.getCouponMoney()){
- Double money = orderLogistics.getCouponMoney();
- incomeService.saveData(2, orderLogistics.getDriverId(), 5, orderLogistics.getId(), orderLogistics.getType(), money);
- driver.setBusinessMoney(new BigDecimal(null != driver.getBusinessMoney() ? driver.getBusinessMoney() : 0).add(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
- driver.setLaveBusinessMoney(new BigDecimal(null != driver.getLaveBusinessMoney() ? driver.getLaveBusinessMoney() : 0).add(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
- driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
- driverService.updateById(driver);
- }
- if(null != orderLogistics.getDiscountMoney() && 0 < orderLogistics.getDiscountMoney()){
- Double money = orderLogistics.getDiscountMoney();
- incomeService.saveData(2, orderLogistics.getDriverId(), 6, orderLogistics.getId(), orderLogistics.getType(), money);
- driver.setBusinessMoney(new BigDecimal(null != driver.getBusinessMoney() ? driver.getBusinessMoney() : 0).add(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
- driver.setLaveBusinessMoney(new BigDecimal(null != driver.getLaveBusinessMoney() ? driver.getLaveBusinessMoney() : 0).add(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
- driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
- driverService.updateById(driver);
- }
- if(null != orderLogistics.getRedPacketMoney() && 0 < orderLogistics.getRedPacketMoney()){
- Double money = orderLogistics.getRedPacketMoney();
- incomeService.saveData(2, orderLogistics.getDriverId(), 7, orderLogistics.getId(), orderLogistics.getType(), money);
- driver.setBusinessMoney(new BigDecimal(null != driver.getBusinessMoney() ? driver.getBusinessMoney() : 0).add(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
- driver.setLaveBusinessMoney(new BigDecimal(null != driver.getLaveBusinessMoney() ? driver.getLaveBusinessMoney() : 0).add(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
- driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
- driverService.updateById(driver);
- }
-
-
-
- Company company = companyService.selectById(orderLogistics.getCompanyId());
- Double speMoney = company.getSameLogisticsMoney();
- BigDecimal d = null;//企业收入
- BigDecimal c = null;//司机收入
- if(company.getIsSameLogisticsFixedOrProportional() == 2){//固定
- d = new BigDecimal(speMoney);
- c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d);//只有出行金额参与抽成,其余归属司机
- }
- if(company.getIsSameLogisticsFixedOrProportional() == 1){//比例
- Double price = orderLogistics.getOrderMoney();
- d = new BigDecimal(price).multiply(new BigDecimal(speMoney).divide(new BigDecimal(100), new MathContext(2, RoundingMode.HALF_EVEN)));
- c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN);
- }
- //记录司机待结算金额
- if(d.compareTo(new BigDecimal(0)) > 0){
- SettlementDetail settlementDetail = new SettlementDetail();
- settlementDetail.setOrderId(orderId);
- settlementDetail.setOrderType(4);
- settlementDetail.setDriverId(orderLogistics.getDriverId());
- settlementDetail.setOrderMoney(sum);
- settlementDetail.setPrice(d.doubleValue());
- settlementDetail.setCreateTime(new Date());
- settlementDetailService.insert(settlementDetail);
-
- SettlementAllocation settlementAllocation = settlementAllocationService.selectOne(null);
- if(null != settlementAllocation){
- JSONObject jsonObject = JSON.parseObject(settlementAllocation.getContent());
- Double maxPrice = jsonObject.getDouble("maxPrice");
- Integer type = jsonObject.getInteger("type");
- if(type == 1){
- List<SettlementDetail> settlementDetailList = settlementDetailService.selectList(new EntityWrapper<SettlementDetail>().eq("driverId", orderLogistics.getDriverId()).isNull("settlementRecordId").last(" and DATE_FORMAT(now(), '%Y-%m-%d') = DATE_FORMAT(createTime, '%Y-%m-%d')"));
- BigDecimal total = new BigDecimal(0);
- for (SettlementDetail detail : settlementDetailList) {
- total = total.add(new BigDecimal(detail.getPrice()));
- }
- if(maxPrice.compareTo(total.doubleValue()) <= 0){
- SettlementRecord settlementRecord = settlementRecordService.selectOne(new EntityWrapper<SettlementRecord>().eq("driverId", orderLogistics.getDriverId())
- .eq("type", type).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(type);
- settlementRecord.setPaymentStatus(1);
- settlementRecord.setPayMoney(total.doubleValue());
- settlementRecord.setInsertTime(new Date());
- settlementRecordService.insert(settlementRecord);
- }else{
- settlementRecord.setPayMoney(total.doubleValue());
- settlementRecordService.updateById(settlementRecord);
- }
- for (SettlementDetail detail : settlementDetailList) {
- detail.setSettlementRecordId(settlementRecord.getId());
- settlementDetailService.updateById(detail);
- }
- }
- }
- }
- }
- }
-
break;
}
this.updateById(orderLogistics);
-
- if(6 == state && ToolUtil.isNotEmpty(pickUpCode)){
- fillInPickUpCode(orderId, pickUpCode, language);
- }
-
-
+
// TODO: 2020/6/5 推送状态
new Thread(new Runnable() {
@Override
@@ -442,283 +295,7 @@
pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState());
}
}).start();
-
-
- if(state == 6){
- UserInfo userInfo = userInfoMapper.selectById(orderLogistics.getUserId());
- language = userInfo.getLanguage();
- String payTypeChinese = "";
- String payTypeEnglish = "";
- String payTypeFrench = "";
- if(orderLogistics.getPayType() == 1){
- payTypeChinese = "手机支付";
- payTypeEnglish = "Mobile money";
- payTypeFrench = "Argent mobile";
- }
- if(orderLogistics.getPayType() == 2){
- payTypeChinese = "银行卡支付";
- payTypeEnglish = "Bank card";
- payTypeFrench = "Carte bancaire";
- }
- if(orderLogistics.getPayType() == 3){
- payTypeChinese = "余额支付";
- payTypeEnglish = "I-GO Wallet";
- payTypeFrench = "Portefeuille I-GO";
- }
- if(orderLogistics.getPayType() == 3){
- payTypeChinese = "现金";
- payTypeEnglish = "Cash";
- payTypeFrench = "En espèces";
- }
-
- if(ToolUtil.isNotEmpty(userInfo.getEmail())){
- String path = templatePath + "user/receiptLogistics.html";
- Document document = Jsoup.parse(new File(path), "UTF-8");
- SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd");
- SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
- Driver driver = driverService.selectById(orderLogistics.getDriverId());
- Car car = carMapper.selectById(orderLogistics.getCarId());
- Double aDouble = 0D;
- if(null != orderLogistics.getDriverId()){
- aDouble = orderEvaluateService.queryDriverScore(orderLogistics.getDriverId());
- }
- if(1 == language){
- document.getElementById("english").remove();
- document.getElementById("french").remove();
- document.getElementsByTag("title").get(0).text("I-GO电子收据");
- Element title_chinese = document.getElementById("title_chinese");
- title_chinese.text(DateUtil.conversionFormat(language, sdf2.format(orderLogistics.getTravelTime())) + ",您在I-GO此订单消费GHS " + orderLogistics.getPayMoney());
- Element xcf_chinese = document.getElementById("xcf_chinese");
- xcf_chinese.text("GHS " + new BigDecimal(orderLogistics.getOrderMoney()).setScale(2, RoundingMode.HALF_EVEN));
- if(null != orderLogistics.getCouponMoney() && orderLogistics.getCouponMoney() > 0){
- Element yhq_chinese = document.getElementById("yhq_chinese");
- yhq_chinese.text("GHS -" + new BigDecimal(orderLogistics.getCouponMoney()).setScale(2, RoundingMode.HALF_EVEN));
- }else{
- Element yhq_chinese_div = document.getElementById("yhq_chinese_div");
- yhq_chinese_div.remove();
- }
- if(null != orderLogistics.getDiscountMoney() && orderLogistics.getDiscountMoney() > 0){
- Element zk_chinese = document.getElementById("zk_chinese");
- zk_chinese.text("GHS -" + new BigDecimal(orderLogistics.getDiscountMoney()).setScale(2, RoundingMode.HALF_EVEN));
- }else{
- Element zk_chinese_div = document.getElementById("zk_chinese_div");
- zk_chinese_div.remove();
- }
- if(null != orderLogistics.getRedPacketMoney() && orderLogistics.getRedPacketMoney() > 0){
- Element hb_chinese = document.getElementById("hb_chinese");
- hb_chinese.text("GHS -" + new BigDecimal(orderLogistics.getRedPacketMoney()).setScale(2, RoundingMode.HALF_EVEN));
- }else{
- Element hb_chinese_div = document.getElementById("hb_chinese_div");
- hb_chinese_div.remove();
- }
- Element xj_chinese = document.getElementById("xj_chinese");
- xj_chinese.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN));
- Element pay_type_chinese = document.getElementById("pay_type_chinese");
- pay_type_chinese.text(payTypeChinese);
- Element pay_money_chinese = document.getElementById("pay_money_chinese");
- pay_money_chinese.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN));
- Element pdf_chinese = document.getElementById("pdf_chinese");
- pdf_chinese.attr("href", "http://182.160.16.251:80/user/base/order/uploadReceiptPdf?orderId=" + orderId + "&orderType=4");
- Element lost_item_chinese = document.getElementById("lost_item_chinese");
- lost_item_chinese.attr("href", "http://182.160.16.251:81/mailbox/user/lossGoods.html?language=" + language + "&orderId=" + orderId + "&orderType=4");
-// Element track_chinese = document.getElementById("track_chinese");
-// track_chinese.attr("href", "http://182.160.16.251:81/mailbox/user/location.html");
- Element pay_time_chinese = document.getElementById("pay_time_chinese");
- pay_time_chinese.text(DateUtil.conversionFormat(language, sdf1.format(orderLogistics.getTravelTime())));
- Elements driver_chinese = document.getElementsByClass("driver_chinese");
- for (int i = 0; i < driver_chinese.size(); i++) {
- Element element = driver_chinese.get(i);
- element.text(" " + driver.getFirstName() + "." + driver.getLastName());
- }
- Element cp_chinese = document.getElementById("cp_chinese");
- cp_chinese.text("车牌:" + car.getCarLicensePlate());
- Element pf_chinese = document.getElementById("pf_chinese");
- pf_chinese.text("司机评分:" + aDouble);
- Element start_address_chinese = document.getElementById("start_address_chinese");
- start_address_chinese.text(orderLogistics.getStartAddress());
- Element end_address_chinese = document.getElementById("end_address_chinese");
- end_address_chinese.text(orderLogistics.getEndAddress());
- Phone phone = phoneService.selectOne(new EntityWrapper<Phone>().eq("type", 2).eq("companyId", driver.getCompanyId()));
- Element server_tel_chinese = document.getElementById("server_tel_chinese");
- server_tel_chinese.attr("href", "tel:" + (null != phone ? phone.getPhone() : ""));
- }
- if(2 == language){
- document.getElementById("chinese").remove();
- document.getElementById("french").remove();
- document.getElementsByTag("title").get(0).text("Receipt");
- Element title_english = document.getElementById("title_english");
- title_english.text(DateUtil.conversionFormat(language, sdf2.format(orderLogistics.getTravelTime())) + ",You spent GHS " + orderLogistics.getPayMoney() + " on the trip ");
- Element xcf_english = document.getElementById("xcf_english");
- xcf_english.text("GHS " + new BigDecimal(orderLogistics.getOrderMoney()).setScale(2, RoundingMode.HALF_EVEN));
- if(null != orderLogistics.getCouponMoney() && orderLogistics.getCouponMoney() > 0){
- Element yhq_english = document.getElementById("yhq_english");
- yhq_english.text("GHS -" + new BigDecimal(orderLogistics.getCouponMoney()).setScale(2, RoundingMode.HALF_EVEN));
- }else{
- Element yhq_english_div = document.getElementById("yhq_english_div");
- yhq_english_div.remove();
- }
- if(null != orderLogistics.getDiscountMoney() && orderLogistics.getDiscountMoney() > 0){
- Element zk_english = document.getElementById("zk_english");
- zk_english.text("GHS -" + new BigDecimal(orderLogistics.getDiscountMoney()).setScale(2, RoundingMode.HALF_EVEN));
- }else{
- Element zk_english_div = document.getElementById("zk_english_div");
- zk_english_div.remove();
- }
- if(null != orderLogistics.getRedPacketMoney() && orderLogistics.getRedPacketMoney() > 0){
- Element hb_english = document.getElementById("hb_english");
- hb_english.text("GHS -" + new BigDecimal(orderLogistics.getRedPacketMoney()).setScale(2, RoundingMode.HALF_EVEN));
- }else{
- Element hb_english_div = document.getElementById("hb_english_div");
- hb_english_div.remove();
- }
- Element xj_english = document.getElementById("xj_english");
- xj_english.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN));
- Element pay_type_english = document.getElementById("pay_type_english");
- pay_type_english.text(payTypeEnglish);
- Element pay_money_english = document.getElementById("pay_money_english");
- pay_money_english.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN));
- Element pdf_english = document.getElementById("pdf_english");
- pdf_english.attr("href", "http://182.160.16.251:80/user/base/order/uploadReceiptPdf?orderId=" + orderId + "&orderType=4");
- Element lost_item_english = document.getElementById("lost_item_english");
- lost_item_english.attr("href", "http://182.160.16.251:81/mailbox/user/lossGoods.html?language=" + language + "&orderId=" + orderId + "&orderType=4");
-// Element track_english = document.getElementById("track_english");
-// track_english.attr("href", "http://182.160.16.251:81/mailbox/user/location.html");
- Element pay_time_english = document.getElementById("pay_time_english");
- pay_time_english.text(DateUtil.conversionFormat(language, sdf1.format(orderLogistics.getTravelTime())));
- Elements driver_english = document.getElementsByClass("driver_english");
- for (int i = 0; i < driver_english.size(); i++) {
- Element element = driver_english.get(i);
- element.text(" " + driver.getFirstName() + "." + driver.getLastName());
- }
- Element cp_english = document.getElementById("cp_english");
- cp_english.text("Number Plate:" + car.getCarLicensePlate());
- Element pf_english = document.getElementById("pf_english");
- pf_english.text("Driver Rating:" + aDouble);
- Element start_address_english = document.getElementById("start_address_english");
- start_address_english.text(orderLogistics.getStartAddress());
- Element end_address_english = document.getElementById("end_address_english");
- end_address_english.text(orderLogistics.getEndAddress());
- Phone phone = phoneService.selectOne(new EntityWrapper<Phone>().eq("type", 2).eq("companyId", driver.getCompanyId()));
- Element server_tel_english = document.getElementById("server_tel_english");
- server_tel_english.attr("href", "tel:" + (null != phone ? phone.getPhone() : ""));
- }
- if(3 == language){
- document.getElementById("chinese").remove();
- document.getElementById("english").remove();
- document.getElementsByTag("title").get(0).text("Reçu");
- Element title_french = document.getElementById("title_french");
- title_french.text(DateUtil.conversionFormat(language, sdf2.format(orderLogistics.getTravelTime())) + ",Vous consommez GHS " + orderLogistics.getPayMoney() + " sur votre commande i-go1 le ");
- Element xcf_french = document.getElementById("xcf_french");
- xcf_french.text("GHS " + new BigDecimal(orderLogistics.getOrderMoney()).setScale(2, RoundingMode.HALF_EVEN));
- if(null != orderLogistics.getCouponMoney() && orderLogistics.getCouponMoney() > 0){
- Element yhq_french = document.getElementById("yhq_french");
- yhq_french.text("GHS -" + new BigDecimal(orderLogistics.getCouponMoney()).setScale(2, RoundingMode.HALF_EVEN));
- }else{
- Element yhq_french_div = document.getElementById("yhq_french_div");
- yhq_french_div.remove();
- }
- if(null != orderLogistics.getDiscountMoney() && orderLogistics.getDiscountMoney() > 0){
- Element zk_french = document.getElementById("zk_french");
- zk_french.text("GHS -" + new BigDecimal(orderLogistics.getDiscountMoney()).setScale(2, RoundingMode.HALF_EVEN));
- }else{
- Element zk_french_div = document.getElementById("zk_french_div");
- zk_french_div.remove();
- }
- if(null != orderLogistics.getRedPacketMoney() && orderLogistics.getRedPacketMoney() > 0){
- Element hb_french = document.getElementById("hb_french");
- hb_french.text("GHS -" + new BigDecimal(orderLogistics.getRedPacketMoney()).setScale(2, RoundingMode.HALF_EVEN));
- }else{
- Element hb_french_div = document.getElementById("hb_french_div");
- hb_french_div.remove();
- }
- Element xj_french = document.getElementById("xj_french");
- xj_french.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN));
- Element pay_type_french = document.getElementById("pay_type_french");
- pay_type_french.text(payTypeFrench);
- Element pay_money_french = document.getElementById("pay_money_french");
- pay_money_french.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN));
- Element pdf_french = document.getElementById("pdf_french");
- pdf_french.attr("href", "http://182.160.16.251:80/user/base/order/uploadReceiptPdf?orderId=" + orderId + "&orderType=4");
- Element lost_item_french = document.getElementById("lost_item_french");
- lost_item_french.attr("href", "http://182.160.16.251:81/mailbox/user/lossGoods.html?language=" + language + "&orderId=" + orderId + "&orderType=4");
-// Element track_french = document.getElementById("track_french");
-// track_french.attr("href", "http://182.160.16.251:81/mailbox/user/location.html");
- Element pay_time_french = document.getElementById("pay_time_french");
- pay_time_french.text(DateUtil.conversionFormat(language, sdf1.format(orderLogistics.getTravelTime())));
- Elements driver_french = document.getElementsByClass("driver_french");
- for (int i = 0; i < driver_french.size(); i++) {
- Element element = driver_french.get(i);
- element.text(" " + driver.getFirstName() + "." + driver.getLastName());
- }
- Element cp_french = document.getElementById("cp_french");
- cp_french.text("Plaque: GS " + car.getCarLicensePlate());
- Element pf_french = document.getElementById("pf_french");
- pf_french.text("Note du chauffeur: " + aDouble);
- Element start_address_french = document.getElementById("start_address_french");
- start_address_french.text(orderLogistics.getStartAddress());
- Element end_address_french = document.getElementById("end_address_french");
- end_address_french.text(orderLogistics.getEndAddress());
- Phone phone = phoneService.selectOne(new EntityWrapper<Phone>().eq("type", 2).eq("companyId", driver.getCompanyId()));
- Element server_tel_french = document.getElementById("server_tel_french");
- server_tel_french.attr("href", "tel:" + (null != phone ? phone.getPhone() : ""));
- }
-
- EmailUtil.send(userInfo.getEmail(), language == 1 ? "I-GO电子收据" : language == 2 ? "Receipt" : "Reçu", document.html());
-
- //开始生成pdf收据和html收据
- File file = new File("/usr/local/nginx/html/files/html/");
- if(!file.exists()){
- file.mkdirs();
- }
- file = new File("/usr/local/nginx/html/files/html/parcel_receipt_" + orderId + ".html");
- if(!file.exists()){
- file.createNewFile();
- }
- FileWriter fileWriter = new FileWriter(file);
- fileWriter.write(document.html());
- fileWriter.flush();
- fileWriter.close();
-
- File file1 = new File("/usr/local/nginx/html/files/pdf/");
- if(!file1.exists()){
- file1.mkdirs();
- }
- file1 = new File("/usr/local/nginx/html/files/pdf/parcel_receipt_" + orderId + ".pdf");
- if(!file1.exists()){
- file1.createNewFile();
- }
- try{
- FileOutputStream fileOutputStream = new FileOutputStream(file1);
- HtmlToPdfUtils.convertToPdf("/usr/local/nginx/html/files/html/parcel_receipt_" + orderId + ".html", "I-GO", fileOutputStream);
- }catch (Exception e){
- e.printStackTrace();
- System.out.println("html转pdf异常");
- }
-
- String link ="http://182.160.16.251:81/files/html/parcel_receipt_" + orderId + ".html";
- TEmail tEmail = new TEmail();
- tEmail.setLink(link);
- tEmail.setUserId(userInfo.getId());
- tEmail.setType(1);
- tEmail.setName(language == 1 ? "I-GO电子收据" : language == 2 ? "Receipt" : "Reçu");
- tEmail.setOrderId(orderId);
- tEmail.setCreateTime(new Date());
- int i = cn.hutool.core.date.DateUtil.dayOfWeek(new Date())-1;
- String week = EmailUtil.getWeek(language, i);
- tEmail.setWeek(week);
- boolean am = cn.hutool.core.date.DateUtil.isAM(new Date());
- if(am){
- tEmail.setAmOrPm(language==1?"上午":language==2?"morning":"matin");
- }else {
- tEmail.setAmOrPm(language==1?"下午":language==2?"afternoon":"après-midi");
- }
- emailService.insert(tEmail);
- }
-
-
-
- }
-
+
return ResultUtil.success();
}
@@ -751,29 +328,12 @@
*/
@Override
public ResultUtil makeUpTheDifference(Integer orderId, Double difference, Integer language) throws Exception {
- OrderLogisticsSpread query = orderLogisticsSpreadService.query(orderId);
OrderLogistics orderLogistics = this.selectById(orderId);
- if(orderLogistics.getState() != 4 && orderLogistics.getState() != 8){
+ if(orderLogistics.getState() != 4){
return ResultUtil.error(language == 1 ? "不允许设置差价" : language == 2 ? "To set price difference is not allowed." : "Il n’est pas permis de définir une différence de prix.");
}
- if(query != null){
- query.setPrice(difference);
- orderLogisticsSpreadService.updateById(query);
- return ResultUtil.success();
- }
- OrderLogisticsSpread orderLogisticsSpread = new OrderLogisticsSpread();
- orderLogisticsSpread.setOrderLogisticsId(orderId);
- orderLogisticsSpread.setPrice(difference);
- orderLogisticsSpreadService.insert(orderLogisticsSpread);
- orderLogistics.setState(8);
- this.updateById(orderLogistics);
-
- new Thread(new Runnable() {
- @Override
- public void run() {
- pushUtil.pushPayDifference(1, orderLogistics.getUserId(), orderId, orderLogistics.getType(), difference);
- }
- }).start();
+ //推送给乘客,需要乘客确认后再加
+ pushUtil.pushPayDifference(1, orderLogistics.getUserId(), orderId, orderLogistics.getType(), difference, 1);
return ResultUtil.success();
}
@@ -869,13 +429,6 @@
public void run() {
pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState());
pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState());
- }
- }).start();
-
- new Thread(new Runnable() {
- @Override
- public void run() {
- pushUtil.pushDriverPosition(orderId, orderLogistics.getType());
}
}).start();
@@ -1047,4 +600,355 @@
this.updateById(orderLogistics);
pushUtil.pushModifyAddress(1, orderLogistics.getUserId(), orderId, 4, status);
}
+
+
+ /**
+ * 获取费用明细
+ * @param orderId
+ * @return
+ * @throws Exception
+ */
+ @Override
+ public Map<String, Object> queryMoneyInfo(Integer orderId) throws Exception {
+ OrderLogistics orderLogistics = this.selectById(orderId);
+ if(orderLogistics.getState() == 5){//服务中的时候获取实时费用数据
+ this.setMoney(orderLogistics, 0D, 0D);
+ }
+
+ Map<String, Object> map = new HashMap<>();
+ map.put("orderMoney", orderLogistics.getOrderMoney());//订单金额
+ map.put("startMileage", orderLogistics.getStartMileage());//起步价
+ map.put("startMoney", orderLogistics.getStartMoney());//起步价
+ map.put("mileageKilometers", orderLogistics.getMileageKilometers());//里程费
+ map.put("mileageMoney", orderLogistics.getMileageMoney());//里程费
+ map.put("duration", orderLogistics.getDuration());//时长费
+ map.put("durationMoney", orderLogistics.getDurationMoney());//时长费
+ map.put("wait", orderLogistics.getWait());//等待费
+ map.put("waitMoney", orderLogistics.getWaitMoney());//等待费
+ map.put("longDistance", orderLogistics.getLongDistance());//远途费
+ map.put("longDistanceMoney", orderLogistics.getLongDistanceMoney());//远途费
+ map.put("parkMoney", orderLogistics.getParkMoney());//停车费
+ map.put("roadTollMoney", orderLogistics.getRoadTollMoney());//过路费
+ map.put("redPacketMoney", orderLogistics.getRedPacketMoney());//红包抵扣金额
+ map.put("couponMoney", orderLogistics.getCouponMoney());//优惠券抵扣金额
+ map.put("discountMoney", orderLogistics.getDiscountMoney());//折扣抵扣金额
+ map.put("discount", orderLogistics.getDiscount());//折扣
+ map.put("priceDifference", orderLogistics.getPriceDifference());//补差价
+ return map;
+ }
+
+
+
+ /**
+ * 计算价格
+ * @param orderLogistics
+ * @param parkingFee
+ * @param crossingFee
+ * @return
+ * @throws Exception
+ */
+ public OrderLogistics setMoney(OrderLogistics orderLogistics, Double parkingFee, Double crossingFee) throws Exception {
+ Map<String, Object> query1 = systemPriceMapper.query(orderLogistics.getCompanyId(), 4, orderLogistics.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 == orderLogistics.getMileage() ? 0D : orderLogistics.getMileage()) / 1000;//实际公里
+ double t = ((orderLogistics.getEndServiceTime().getTime() - orderLogistics.getStartServiceTime().getTime()) / 60000) + 1;//实际时间(不满一分钟按一分钟算)
+ double w = ((orderLogistics.getStartServiceTime().getTime() - orderLogistics.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;
+// orderLogistics.setStartMileage(num2);
+// orderLogistics.setStartMoney(num17);//起步价
+// orderLogistics.setStartDuration((int)(num3.doubleValue()));
+// orderLogistics.setMileageKilometers(new BigDecimal(d1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
+// orderLogistics.setMileageMoney(new BigDecimal(d1 * num18).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());//里程费
+// orderLogistics.setDuration(new BigDecimal(t1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
+// orderLogistics.setDurationMoney(new BigDecimal(t1 * num19).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());//时长费
+// orderLogistics.setWait(new BigDecimal(w1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
+// orderLogistics.setWaitMoney(new BigDecimal(w1 * num7).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());//等待费
+// orderLogistics.setLongDistance(new BigDecimal((d > num8) ? d - num8 : 0).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
+// orderLogistics.setLongDistanceMoney(new BigDecimal(yt1 + yt2 + yt3).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());//远途费
+// orderLogistics.setParkMoney(parkingFee);//停车费
+// orderLogistics.setRoadTollMoney(crossingFee);//过路费
+// orderLogistics.setRedPacketMoney(0D);//红包抵扣
+// orderLogistics.setCouponMoney(0D);//优惠券抵扣
+// orderLogistics.setDiscount(0D);//优惠抵扣
+// orderLogistics.setPayMoney(0D);//支付金额
+// orderLogistics.setOrderMoney(new BigDecimal(amount + parkingFee + crossingFee).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
+// orderLogistics.setMoneyType(2);
+// orderLogistics.setMoneyTime(num16);
+// return orderLogistics;
+// }
+// }
+
+
+ //高峰时段处理逻辑
+ 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;
+ orderLogistics.setStartMileage(num2);
+ orderLogistics.setStartDuration((int)(num3.doubleValue()));
+ orderLogistics.setStartMoney(num25);//起步价
+ orderLogistics.setMileageKilometers(new BigDecimal(d1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
+ orderLogistics.setMileageMoney(new BigDecimal(d1 * num26).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());//里程费
+ orderLogistics.setDuration(new BigDecimal(t1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
+ orderLogistics.setDurationMoney(new BigDecimal(t1 * num27).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());//时长费
+ orderLogistics.setWait(new BigDecimal(w1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
+ orderLogistics.setWaitMoney(new BigDecimal(w1 * num7).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());//等待费
+ orderLogistics.setLongDistance(new BigDecimal((d > num8) ? d - num8 : 0).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
+ orderLogistics.setLongDistanceMoney(new BigDecimal(yt1 + yt2 + yt3).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());//远途费
+ orderLogistics.setParkMoney(parkingFee);//停车费
+ orderLogistics.setRoadTollMoney(crossingFee);//过路费
+ orderLogistics.setRedPacketMoney(0D);//红包抵扣
+ orderLogistics.setCouponMoney(0D);//优惠券抵扣
+ orderLogistics.setDiscount(0D);//优惠抵扣
+ orderLogistics.setPayMoney(0D);//支付金额
+ orderLogistics.setOrderMoney(new BigDecimal(amount + parkingFee + crossingFee).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
+
+ orderLogistics.setMoneyType(3);
+ if((date.getTime() > s1.getTimeInMillis() && date.getTime() < e1.getTimeInMillis())){
+ orderLogistics.setMoneyTime(num23);
+ }else{
+ orderLogistics.setMoneyTime(num24);
+ }
+
+ return orderLogistics;
+ }
+
+ //其他时间段的计算
+ 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;
+ orderLogistics.setStartMileage(num2);
+ orderLogistics.setStartDuration((int)(num3.doubleValue()));
+ orderLogistics.setStartMoney(num1);//起步价
+ orderLogistics.setMileageKilometers(new BigDecimal(d1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
+ orderLogistics.setMileageMoney(new BigDecimal(d1 * num4).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());//里程费
+ orderLogistics.setDuration(new BigDecimal(t1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
+ orderLogistics.setDurationMoney(new BigDecimal(t1 * num5).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());//时长费
+ orderLogistics.setWait(new BigDecimal(w1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
+ orderLogistics.setWaitMoney(new BigDecimal(w1 * num7).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());//等待费
+ orderLogistics.setLongDistance(new BigDecimal((d > num8) ? d - num8 : 0).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
+ orderLogistics.setLongDistanceMoney(new BigDecimal(yt1 + yt2 + yt3).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());//远途费
+ orderLogistics.setParkMoney(parkingFee);//停车费
+ orderLogistics.setRoadTollMoney(crossingFee);//过路费
+ orderLogistics.setRedPacketMoney(0D);//红包抵扣
+ orderLogistics.setCouponMoney(0D);//优惠券抵扣
+ orderLogistics.setDiscount(0D);//优惠抵扣
+ orderLogistics.setPayMoney(0D);//支付金额
+ orderLogistics.setOrderMoney(new BigDecimal(amount + parkingFee + crossingFee).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
+
+ orderLogistics.setMoneyType(1);
+ return orderLogistics;
+ }
+
+
+
+ /**
+ * 确认费用操作
+ * @param orderId
+ * @param type
+ * @param parkingFee
+ * @param crossingFee
+ * @return
+ * @throws Exception
+ */
+ @Override
+ public ResultUtil confirmFees(Integer language, Integer orderId, Integer type, Double parkingFee, Double crossingFee) throws Exception {
+ OrderLogistics orderLogistics = this.selectById(orderId);
+ if(orderLogistics.getArriveTime()==null){
+ orderLogistics.setArriveTime(orderLogistics.getStartServiceTime());
+ }
+ orderLogistics = this.setMoney(orderLogistics, 0D, 0D);//计算费用
+ orderLogistics.setPayManner(type);
+ orderLogistics.setParkMoney(null == parkingFee ? 0D : parkingFee);
+ orderLogistics.setRoadTollMoney(null == crossingFee ? 0D : crossingFee);
+ orderLogistics.setOrderMoney(orderLogistics.getOrderMoney() + orderLogistics.getParkMoney() + orderLogistics.getRoadTollMoney() + orderLogistics.getPriceDifference());
+ //判断是否首单免费-免费直接完成
+ Integer orderNumber = this.selectCount(new EntityWrapper<OrderLogistics>().eq("userId",orderLogistics.getUserId()).last("and (state=8 or state=9)"));
+
+ if(orderNumber<=0){//判断是否是首单
+ //判断是否免单
+ UserInfo userInfo = userInfoMapper.selectById(orderLogistics.getUserId());
+ if(userInfo.getFreeMoney().doubleValue()>0d){
+ if(orderLogistics.getOrderMoney()<=userInfo.getFreeMoney().doubleValue()){
+ orderLogistics.setState(8);
+ orderLogistics.setIsFree(2);
+ //添加已收入明细
+ Company company = companyService.selectById(orderLogistics.getCompanyId());
+ Double speMoney = company.getSpeMoney();
+ BigDecimal d = null;//企业收入
+ BigDecimal c = null;//司机收入
+ if(company.getIsSpeFixedOrProportional() == 2){//固定
+ d = new BigDecimal(speMoney);
+ c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d);//只有出行金额参与抽成,其余归属司机
+ }
+ if(company.getIsSpeFixedOrProportional() == 1){//比例
+ Double price = orderLogistics.getStartMoney() + orderLogistics.getMileageMoney() + orderLogistics.getWaitMoney() + orderLogistics.getDurationMoney() + orderLogistics.getLongDistanceMoney();
+ d = new BigDecimal(price).multiply(new BigDecimal(speMoney).divide(new BigDecimal(100), new MathContext(2, RoundingMode.HALF_EVEN)));
+ c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN);
+ }
+ incomeService.saveData(1, orderLogistics.getCompanyId(), 2, orderLogistics.getId(), 4, d.doubleValue());
+ incomeService.saveData(2, orderLogistics.getDriverId(), 2, orderLogistics.getId(), 4, c.doubleValue());
+ Driver driver = driverService.selectById(orderLogistics.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(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
+ driverService.updateById(driver);
+ }else{
+ orderLogistics.setState(7);
+ orderLogistics.setOrderMoney(orderLogistics.getOrderMoney()-userInfo.getFreeMoney().doubleValue());
+ orderLogistics.setFreeMoney(userInfo.getFreeMoney());
+
+ }
+
+ }else{
+ orderLogistics.setState(7);
+ }
+
+ }else{
+ orderLogistics.setState(7);
+ }
+
+ Map<String, String> map = chinaMobileUtil.midAxbUnBindSend(orderLogistics.getBindId(),orderLogistics.getTelX());
+ if(String.valueOf(map.get("code")).equals("200")){
+ orderLogistics.setTelX("");
+ orderLogistics.setBindId("");
+ }
+ this.updateById(orderLogistics);
+
+
+ pushUtil.removeTask(orderId, 4);//删除定时任务,结束推送数据
+ 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", orderLogistics.getUserId());
+
+ //回滚司机状态为空闲
+ Driver driver = driverService.selectById(orderLogistics.getDriverId());
+ driver.setState(2);
+ driverService.updateById(driver);
+
+ OrderLogistics finalOrderTaxi = orderLogistics;
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ pushUtil.pushOrderState(1, finalOrderTaxi.getUserId(), finalOrderTaxi.getId(), 4, finalOrderTaxi.getState());
+ pushUtil.pushOrderState(2, finalOrderTaxi.getDriverId(), finalOrderTaxi.getId(), 4, finalOrderTaxi.getState());
+ }
+ }).start();
+ return ResultUtil.success();
+ }
}
--
Gitblit v1.7.1