From 8db5d3eafb1cc5352b1bdf2c281c54c7fa80db93 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期五, 14 二月 2025 18:07:04 +0800
Subject: [PATCH] 补充
---
UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/service/impl/OrderTaxiServiceImpl.java | 165 ++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 115 insertions(+), 50 deletions(-)
diff --git a/UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/service/impl/OrderTaxiServiceImpl.java b/UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/service/impl/OrderTaxiServiceImpl.java
index 7041973..e0dd55c 100644
--- a/UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/service/impl/OrderTaxiServiceImpl.java
+++ b/UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/service/impl/OrderTaxiServiceImpl.java
@@ -5,6 +5,7 @@
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
+import com.stylefeng.guns.core.util.GpsCoordinateUtils;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.crossCity.server.IOrderCrossCityService;
import com.stylefeng.guns.modular.crossCity.server.impl.OrderCrossCityServiceImpl;
@@ -20,9 +21,11 @@
import com.stylefeng.guns.modular.system.warpper.OrderServerWarpper;
import com.stylefeng.guns.modular.taxi.dao.OrderTaxiMapper;
import com.stylefeng.guns.modular.taxi.dao.TPhoneMapper;
+import com.stylefeng.guns.modular.taxi.dao.TransactionDetailsMapper;
import com.stylefeng.guns.modular.taxi.model.OrderTaxi;
import com.stylefeng.guns.modular.taxi.model.PaymentRecord;
import com.stylefeng.guns.modular.taxi.model.TPhone;
+import com.stylefeng.guns.modular.taxi.model.TransactionDetails;
import com.stylefeng.guns.modular.taxi.service.IOrderTaxiService;
import com.stylefeng.guns.modular.taxi.service.IPaymentRecordService;
import com.stylefeng.guns.modular.taxi.service.ITransactionDetailsService;
@@ -164,7 +167,6 @@
-
@Resource
private TPhoneMapper tPhoneMapper;
@@ -177,7 +179,8 @@
* @throws Exception
*/
@Override
- public synchronized ResultUtil<BaseWarpper> taxiOrder(OrderTaxi orderTaxi, Integer uid) throws Exception {
+ public synchronized ResultUtil<BaseWarpper> taxiOrder(OrderTaxi orderTaxi, Integer uid,String areaCode) throws Exception {
+ System.out.println("出租车==========================================="+orderTaxi);
//定义用户所属公司
UserInfo userInfo1 = userInfoService.selectById(uid);
if (userInfo1.getIsBlack()==1){
@@ -577,8 +580,9 @@
placeOrderWay = 3;
break;
}
+ Company company = companyService.selectById(orderTaxi.getCompanyId());
//添加交易明细
- transactionDetailsService.saveDataTaxi(uid, "取消订单", query.getMoney(), 2, 1, 1, 2, id,placeOrderWay);
+ transactionDetailsService.saveDataTaxi(uid, "取消订单", query.getMoney(), 2, 1, 1, 2, id,placeOrderWay,company.getId());
userInfoService.updateById(userInfo);
//解除小号绑定
@@ -778,7 +782,7 @@
userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(orderMoney)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
SysIntegral query1 = sysIntegralMapper.query(orderTaxi.getCompanyId());
- userInfo.setIntegral(userInfo.getIntegral() + (orderMoney.intValue() * query1.getIntegral()));//积分
+// userInfo.setIntegral(userInfo.getIntegral() + (orderMoney.intValue() * query1.getIntegral()));//积分
Integer placeOrderWay = null;
switch (orderTaxi.getOrderSource()){
case 2:
@@ -798,7 +802,7 @@
break;
}
//添加交易明细
- transactionDetailsService.saveDataTaxi(uid, "完成订单", orderMoney, 2, 1, 1, 2, orderId,placeOrderWay);
+// transactionDetailsService.saveDataTaxi(uid, "完成订单", orderMoney, 2, 1, 1, 2, orderId,placeOrderWay);
userInfoService.updateById(userInfo);
orderTaxi.setState(8);
@@ -818,24 +822,46 @@
}
//添加已收入明细
- Company company = companyService.selectById(orderTaxi.getCompanyId());
- Double taxi = company.getTaxiMoney();
- BigDecimal d = null;//企业收入
- BigDecimal c = null;//司机收入
- if(company.getIsTaxiFixedOrProportional() == 2){//固定
- d = new BigDecimal(taxi);
- c = new BigDecimal(orderTaxi.getOrderMoney()).subtract(d);//只有出行金额参与抽成,其余归属司机
- }
- if(company.getIsTaxiFixedOrProportional() == 1){//比例
- d = new BigDecimal(orderTaxi.getTravelMoney()).multiply(new BigDecimal(taxi).divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_HALF_EVEN);
- c = new BigDecimal(orderTaxi.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN);
- }
- incomeService.saveData(1, orderTaxi.getCompanyId(), 2, orderTaxi.getId(), 2, d.doubleValue());
- incomeService.saveData(2, orderTaxi.getDriverId(), 2, orderTaxi.getId(), 2, c.doubleValue());
+// Company company = companyService.selectById(orderTaxi.getCompanyId());
+// Double taxi = company.getTaxiMoney();
+// BigDecimal d = null;//企业收入
+// BigDecimal c = null;//司机收入
+// if(company.getIsTaxiFixedOrProportional() == 2){//固定
+// d = new BigDecimal(taxi);
+// c = new BigDecimal(orderTaxi.getOrderMoney()).subtract(d);//只有出行金额参与抽成,其余归属司机
+// }
+// if(company.getIsTaxiFixedOrProportional() == 1){//比例
+// d = new BigDecimal(orderTaxi.getTravelMoney()).multiply(new BigDecimal(taxi).divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_HALF_EVEN);
+// c = new BigDecimal(orderTaxi.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN);
+// }
+// incomeService.saveData(1, orderTaxi.getCompanyId(), 2, orderTaxi.getId(), 2, d.doubleValue());
+// incomeService.saveData(2, orderTaxi.getDriverId(), 2, orderTaxi.getId(), 2, c.doubleValue());
Driver driver = driverService.selectById(orderTaxi.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());
+// 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());
+ Company company = companyService.selectById(driver.getFranchiseeId());
+ if(Objects.isNull(company)){
+ company = companyService.selectById(driver.getCompanyId());
+ }
+ // 司机收入
+ double moneyTwo;
+ // 平台收入
+ double money;
+ if(orderTaxi.getOrderSource() == 2 || orderTaxi.getOrderSource() == 3){
+ double v = company.getPercentageDeduction() / 100;
+ money = v * orderTaxi.getOrderMoney();
+ moneyTwo = orderTaxi.getOrderMoney()-money;
+ }else {
+ money = company.getFixedDeduction();
+ moneyTwo = orderTaxi.getOrderMoney()-money;
+ }
+ driver.setBalance(driver.getBalance() + moneyTwo);
+ // 新增扣除使用费记录
+ transactionDetailsService.saveDataTaxi(driver.getId(), "软件使用费", money, 2, 1, 2, 6, orderTaxi.getId(),placeOrderWay,company.getId());
+ // 司机订单收入
+ transactionDetailsService.saveDataTaxi(driver.getId(), "完成订单", moneyTwo, 1, 1, 2, 2, orderTaxi.getId(),placeOrderWay,company.getId());
+
driverService.updateById(driver);
// TODO: 2020/5/24 这里需要给司机和用户推送订单状态
@@ -1047,7 +1073,10 @@
value = map.get("lon") + "," + map.get("lat");
}
}
- Map<String, String> distance = gdMapElectricFenceUtil.getDistance(value, orderTaxi.getStartLon() + "," + orderTaxi.getStartLat(), 1);
+ // todo 注意 因更换地图为百度 两者lon和lat位置互换了
+ String[] split = value.split(",");
+ value = split[1] + "," + split[0];
+ Map<String, String> distance = gdMapElectricFenceUtil.getDistance(value, orderTaxi.getStartLat() + "," + orderTaxi.getStartLon(), 1);
String d = "0";
String t = "0";
if(null == distance){
@@ -1062,6 +1091,18 @@
orderServerWarpper.setState(orderTaxi.getState());
orderServerWarpper.setLon(null != value ? value.split(",")[0] : "0.0");
orderServerWarpper.setLat(null != value ? value.split(",")[1] : "0.0");
+ value = value == null ? "0.0,0.0" : value;
+ double[] doubles = GpsCoordinateUtils.calBD09toGCJ02(Double.parseDouble(value.split(",")[1]), Double.parseDouble(value.split(",")[0]));
+ orderServerWarpper.setNextLongitude(String.valueOf(doubles[0]));
+ orderServerWarpper.setNextLatitude(String.valueOf(doubles[1]));
+ // 起点地址转换
+ doubles = GpsCoordinateUtils.calBD09toGCJ02(orderTaxi.getStartLat(), orderTaxi.getStartLon());
+ orderServerWarpper.setStartLat(String.valueOf(doubles[0]));
+ orderServerWarpper.setStartLon(String.valueOf(doubles[1]));
+ // 终点地址转换
+ doubles = GpsCoordinateUtils.calBD09toGCJ02(orderTaxi.getEndLat(), orderTaxi.getEndLon());
+ orderServerWarpper.setEndLat(String.valueOf(doubles[0]));
+ orderServerWarpper.setEndLon(String.valueOf(doubles[1]));
orderServerWarpper.setReassignNotice(orderTaxi.getReassignNotice());
if(orderTaxi.getState() == 2 || orderTaxi.getState() == 3){//前往预约地
orderServerWarpper.setReservationMileage(d);
@@ -1072,12 +1113,12 @@
orderServerWarpper.setLaveTime("0");
}
if(orderTaxi.getState() == 5 || orderTaxi.getState() == 6){//服务中
- distance = gdMapElectricFenceUtil.getDistance(value, orderTaxi.getEndLon() + "," + orderTaxi.getEndLat(), 1);
+ distance = gdMapElectricFenceUtil.getDistance(value, orderTaxi.getEndLat() + "," + orderTaxi.getEndLon(), 1);
if(null == distance){
System.err.println("查询距离出错了");
}else{
- d = new BigDecimal(distance.get("distance")).divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_EVEN).toString();
- t = new BigDecimal(distance.get("duration")).divide(new BigDecimal(60)).setScale(2, BigDecimal.ROUND_HALF_EVEN).intValue() + "";
+ d = new BigDecimal(distance.get("distance")).divide(new BigDecimal(1000),2, RoundingMode.HALF_UP).toString();
+ t = new BigDecimal(distance.get("duration")).divide(new BigDecimal(60),2, RoundingMode.HALF_UP) + "";
}
orderServerWarpper.setReservationMileage("0");
orderServerWarpper.setReservationTime("0");
@@ -1226,17 +1267,18 @@
placeOrderWay = 3;
break;
}
- //添加交易明细
- transactionDetailsService.saveDataTaxi(orderTaxi.getUserId(), "完成订单", query.getAmount(), 2, 1, 1, 2, query.getOrderId(),placeOrderWay);
+// Company company = companyService.selectById(orderTaxi.getCompanyId());
+// //添加交易明细
+// transactionDetailsService.saveDataTaxi(orderTaxi.getUserId(), "完成订单", query.getAmount(), 2, 1, 1, 2, query.getOrderId(),placeOrderWay,company.getId());
orderTaxi.setState(8);
orderTaxi.setPayType(type);
orderTaxi.setPayMoney(query.getAmount());
this.updateById(orderTaxi);
- UserInfo userInfo = userInfoService.selectById(orderTaxi.getUserId());
- SysIntegral query1 = sysIntegralMapper.query(orderTaxi.getCompanyId());
- userInfo.setIntegral(userInfo.getIntegral() + (query.getAmount().intValue() * query1.getIntegral()));//积分
- userInfoService.updateById(userInfo);
+// UserInfo userInfo = userInfoService.selectById(orderTaxi.getUserId());
+// SysIntegral query1 = sysIntegralMapper.query(orderTaxi.getCompanyId());
+// userInfo.setIntegral(userInfo.getIntegral() + (query.getAmount().intValue() * query1.getIntegral()));//积分
+// userInfoService.updateById(userInfo);
//处理优惠券和红包
if(null != orderTaxi.getCouponId()){
@@ -1258,24 +1300,46 @@
paymentRecordService.updateById(query);
//添加已收入明细
- Company company = companyService.selectById(orderTaxi.getCompanyId());
- Double taxi = company.getTaxiMoney();
- BigDecimal d = null;//企业收入
- BigDecimal c = null;//司机收入
- if(company.getIsTaxiFixedOrProportional() == 2){//固定
- d = new BigDecimal(taxi);
- c = new BigDecimal(orderTaxi.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN);
- }
- if(company.getIsTaxiFixedOrProportional() == 1){//比例
- d = new BigDecimal(orderTaxi.getTravelMoney()).multiply(new BigDecimal(taxi).divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_HALF_EVEN);
- c = new BigDecimal(orderTaxi.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN);
- }
- incomeService.saveData(1, orderTaxi.getCompanyId(), 2, orderTaxi.getId(), 2, d.doubleValue());
- incomeService.saveData(2, orderTaxi.getDriverId(), 2, orderTaxi.getId(), 2, c.doubleValue());
+// Company company = companyService.selectById(orderTaxi.getCompanyId());
+// Double taxi = company.getTaxiMoney();
+// BigDecimal d = null;//企业收入
+// BigDecimal c = null;//司机收入
+// if(company.getIsTaxiFixedOrProportional() == 2){//固定
+// d = new BigDecimal(taxi);
+// c = new BigDecimal(orderTaxi.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN);
+// }
+// if(company.getIsTaxiFixedOrProportional() == 1){//比例
+// d = new BigDecimal(orderTaxi.getTravelMoney()).multiply(new BigDecimal(taxi).divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_HALF_EVEN);
+// c = new BigDecimal(orderTaxi.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN);
+// }
+// incomeService.saveData(1, orderTaxi.getCompanyId(), 2, orderTaxi.getId(), 2, d.doubleValue());
+// incomeService.saveData(2, orderTaxi.getDriverId(), 2, orderTaxi.getId(), 2, c.doubleValue());
Driver driver = driverService.selectById(orderTaxi.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());
+// 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());
+ Company company = companyService.selectById(driver.getFranchiseeId());
+ if(Objects.isNull(company)){
+ company = companyService.selectById(driver.getCompanyId());
+ }
+ // 司机收入
+ double moneyTwo;
+ // 平台收入
+ double money;
+ if(orderTaxi.getOrderSource() == 2 || orderTaxi.getOrderSource() == 3){
+ double v = company.getPercentageDeduction() / 100;
+ money = v * orderTaxi.getOrderMoney();
+ moneyTwo = orderTaxi.getOrderMoney()-money;
+ }else {
+ money = company.getFixedDeduction();
+ moneyTwo = orderTaxi.getOrderMoney()-money;
+ }
+ driver.setBalance(driver.getBalance() + moneyTwo);
+ // 新增扣除使用费记录
+ transactionDetailsService.saveDataTaxi(driver.getId(), "软件使用费", money, 2, 1, 2, 6, orderTaxi.getId(),placeOrderWay,company.getId());
+ // 司机订单收入
+ transactionDetailsService.saveDataTaxi(driver.getId(), "完成订单", moneyTwo, 1, 1, 2, 2, orderTaxi.getId(),placeOrderWay,company.getId());
+
driverService.updateById(driver);
// TODO: 2020/5/24 这里需要给司机和用户推送订单状态
@@ -1338,8 +1402,9 @@
placeOrderWay = 3;
break;
}
+ Company company = companyService.selectById(orderTaxi.getCompanyId());
//添加交易明细
- transactionDetailsService.saveDataTaxi(orderTaxi.getUserId(), "取消订单", query.getAmount(), 2, 1, 1, 2, query.getOrderId(),placeOrderWay);
+ transactionDetailsService.saveDataTaxi(orderTaxi.getUserId(), "取消订单", query.getAmount(), 2, 1, 1, 2, query.getOrderId(),placeOrderWay,company.getId());
orderTaxi.setState(10);
//解除小号绑定
if(orderTaxi.getBindId() != null){
--
Gitblit v1.7.1