From 4d4eb6e9addc4ce148e05f470beb016e507975ba Mon Sep 17 00:00:00 2001
From: longz <longzhaoz@qq.com>
Date: 星期一, 27 四月 2026 17:21:06 +0800
Subject: [PATCH] 小程序二维码 支持改价 自主行程查询
---
DriverYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/crossCity/server/impl/LineShiftDriverServiceImpl.java | 144 ++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 133 insertions(+), 11 deletions(-)
diff --git a/DriverYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/crossCity/server/impl/LineShiftDriverServiceImpl.java b/DriverYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/crossCity/server/impl/LineShiftDriverServiceImpl.java
index a2f8aef..1aa349d 100644
--- a/DriverYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/crossCity/server/impl/LineShiftDriverServiceImpl.java
+++ b/DriverYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/crossCity/server/impl/LineShiftDriverServiceImpl.java
@@ -1,7 +1,5 @@
package com.stylefeng.guns.modular.crossCity.server.impl;
-import cn.hutool.core.date.DateUnit;
-import cn.hutool.cron.CronUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
@@ -18,16 +16,11 @@
import com.stylefeng.guns.modular.crossCity.model.OrderCrossCity;
import com.stylefeng.guns.modular.crossCity.server.ILineService;
import com.stylefeng.guns.modular.crossCity.server.ILineShiftDriverService;
-import com.stylefeng.guns.modular.crossCity.server.ILineSiteService;
import com.stylefeng.guns.modular.crossCity.server.IOrderCrossCityService;
-import com.stylefeng.guns.modular.crossCity.warpper.AddSelfTripWarpper;
-import com.stylefeng.guns.modular.crossCity.warpper.DriverShiftListWarpper;
-import com.stylefeng.guns.modular.crossCity.warpper.LineShiftItemWarpper;
-import com.stylefeng.guns.modular.crossCity.warpper.OtherDriverShiftWarpper;
-import com.stylefeng.guns.modular.crossCity.warpper.ScanOrderDetailWarpper;
+import com.stylefeng.guns.modular.crossCity.warpper.*;
import com.stylefeng.guns.modular.system.dao.CarModelMapper;
import com.stylefeng.guns.modular.system.dao.CarServiceMapper;
-import com.stylefeng.guns.modular.system.dao.ServerCarModelMapper;
+import com.stylefeng.guns.modular.system.dao.OrderEvaluateMapper;
import com.stylefeng.guns.modular.system.model.Car;
import com.stylefeng.guns.modular.system.model.CarModel;
import com.stylefeng.guns.modular.system.model.CarService;
@@ -46,7 +39,6 @@
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.*;
-import java.util.stream.Collectors;
@Service
@@ -78,6 +70,9 @@
@Resource
private DriverSelfTripMapper driverSelfTripMapper;
+
+ @Resource
+ private OrderEvaluateMapper orderEvaluateMapper;
@Autowired
private IOrderCrossCityService orderCrossCityService;
@@ -521,6 +516,8 @@
trip.setSeat(warpper.getSeat());
trip.setStartCityCode(warpper.getStartCityCode());
trip.setStartCityName(warpper.getStartCityName());
+ trip.setEndCityCode(warpper.getEndCityCode());
+ trip.setEndCityName(warpper.getEndCityName());
trip.setStartAddress(warpper.getStartAddress());
trip.setStartLon(warpper.getStartLon());
trip.setStartLat(warpper.getStartLat());
@@ -582,7 +579,11 @@
Double endLon = item.getDouble("endLon");
Double endLat = item.getDouble("endLat");
Double price = item.getDouble("price");
- if (ToolUtil.isEmpty(endAddress) || endLon == null || endLat == null || price == null || price < 0) {
+ if (ToolUtil.isEmpty(endAddress)
+ || endLon == null
+ || endLat == null
+ || price == null
+ || price < 0) {
return null;
}
}
@@ -605,6 +606,14 @@
@Override
public ResultUtil<ScanOrderDetailWarpper> getDetail(Integer lineShiftDriverId) {
+ LineShiftDriver lineShiftDriver = lineShiftDriverMapper.selectById(lineShiftDriverId);
+ if (lineShiftDriver == null) {
+ return ResultUtil.error("班次信息不存在");
+ }
+ if (lineShiftDriver.getLineShiftId() != null && lineShiftDriver.getLineShiftId() == -1) {
+ return buildSelfTripDetail(lineShiftDriver);
+ }
+
// 1. 查询基础数据
Map<String, Object> data = lineShiftDriverMapper.getDetail(lineShiftDriverId);
if (data == null || data.isEmpty()) {
@@ -617,6 +626,7 @@
// 司机信息
result.setHeadImgUrl(data.get("headImgUrl") != null ? data.get("headImgUrl").toString() : null);
result.setDriverName(data.get("driverName") != null ? data.get("driverName").toString() : null);
+ result.setSex(data.get("sex") != null ? Integer.parseInt(data.get("sex").toString()) : null);
result.setCarLicensePlate(data.get("carLicensePlate") != null ? data.get("carLicensePlate").toString() : null);
result.setCarBrand(data.get("carBrand") != null ? data.get("carBrand").toString() : null);
result.setCarColor(data.get("carColor") != null ? data.get("carColor").toString() : null);
@@ -671,4 +681,116 @@
return ResultUtil.success(result);
}
+
+ private ResultUtil<ScanOrderDetailWarpper> buildSelfTripDetail(LineShiftDriver lineShiftDriver) {
+ if (lineShiftDriver.getCustomerId() == null) {
+ return ResultUtil.error("自主行程信息不存在");
+ }
+ DriverSelfTrip trip = driverSelfTripMapper.selectById(lineShiftDriver.getCustomerId());
+ if (trip == null || trip.getState() == null || trip.getState() != 1) {
+ return ResultUtil.error("自主行程信息不存在");
+ }
+ Driver driver = driverService.selectById(lineShiftDriver.getDriverId());
+ if (driver == null) {
+ return ResultUtil.error("司机信息不存在");
+ }
+ Car car = null;
+ CarModel carModel = null;
+ CarService carServiceData = null;
+ if (driver.getCarId() != null) {
+ car = carService.selectById(driver.getCarId());
+ if (car != null && car.getCarModelId() != null) {
+ carModel = carModelMapper.selectById(car.getCarModelId());
+ }
+ carServiceData = carServiceMapper.query(3, driver.getCarId());
+ }
+
+ ScanOrderDetailWarpper result = new ScanOrderDetailWarpper();
+ result.setHeadImgUrl(driver.getHeadImgUrl());
+ String name = driver.getName();
+ result.setDriverName(ToolUtil.isEmpty(name) ? "" : name.substring(0, 1) + "师傅");
+ result.setSex(driver.getSex());
+ result.setCarLicensePlate(car == null ? null : car.getCarLicensePlate());
+ result.setCarBrand(carModel == null ? null : carModel.getName());
+ result.setCarColor(car == null ? null : car.getCarColor());
+ Double score = orderEvaluateMapper.queryCount(driver.getId());
+ result.setScore(score == null ? 0D : score);
+ int orderCount = orderCrossCityService.selectCount(
+ new EntityWrapper<OrderCrossCity>()
+ .eq("driverId", driver.getId())
+ .eq("state", 9)
+ );
+ result.setOrderCount(orderCount);
+
+ result.setLineId(-1);
+ result.setLineName(trip.getStartCityName() + "-" + trip.getEndCityName());
+ result.setUnitPrice(null);
+ if (lineShiftDriver.getDay() != null) {
+ result.setDay(new SimpleDateFormat("yyyy-MM-dd").format(lineShiftDriver.getDay()));
+ }
+ result.setStartTime(trip.getStartTime());
+ result.setEndTime(trip.getStartTime());
+ result.setTotalSeat(lineShiftDriver.getTotalSeat());
+ result.setLaveSeat(lineShiftDriver.getLaveSeat());
+ result.setLaveSeatNumber(lineShiftDriver.getLaveSeatNumber());
+
+ result.setStartSiteId(null);
+ result.setStartSiteName(trip.getStartAddress());
+ result.setEndSiteId(null);
+ result.setEndSiteName(null);
+ result.setStartCityName(trip.getStartCityName());
+ result.setEndCityName(null);
+ result.setStartLonLat(trip.getStartLon() == null || trip.getStartLat() == null ? null : trip.getStartLon() + "," + trip.getStartLat());
+ result.setEndLonLat(null);
+
+
+ if (ToolUtil.isNotEmpty(trip.getDestJson())) {
+ try {
+ JSONArray array = JSON.parseArray(trip.getDestJson());
+ if (array != null && !array.isEmpty()) {
+ JSONObject first = array.getJSONObject(0);
+ if (first != null) {
+ result.setEndSiteName(first.getString("endAddress"));
+ result.setEndCityName(first.getString("endCityName"));
+ Double endLon = first.getDouble("endLon");
+ Double endLat = first.getDouble("endLat");
+ if (endLon != null && endLat != null) {
+ result.setEndLonLat(endLon + "," + endLat);
+ }
+ Double price = first.getDouble("price");
+ if (price != null) {
+ result.setUnitPrice(price);
+ }
+ }
+ for (int i = 0; i < array.size(); i++) {
+ JSONObject jsonObject = array.getJSONObject(i);
+ jsonObject.put("range",3000D);
+ }
+ result.setEndDetailList(array);
+ }
+ } catch (Exception ignored) {
+ }
+ }
+
+ result.setOtherFee(null);
+ result.setServerCarModelId(carServiceData == null ? null : carServiceData.getServerCarModelId());
+ result.setDriverId(driver.getId());
+ result.setLineShiftDriverId(lineShiftDriver.getId());
+
+ result.setStartDefaultPointAddress(trip.getStartAddress());
+ result.setStartDefaultPointLon(trip.getStartLon());
+ result.setStartDefaultPointLat(trip.getStartLat());
+ result.setEndDefaultPointAddress(result.getEndSiteName());
+ if (ToolUtil.isNotEmpty(result.getEndLonLat()) && result.getEndLonLat().contains(",")) {
+ String[] split = result.getEndLonLat().split(",");
+ if (split.length == 2) {
+ try {
+ result.setEndDefaultPointLon(Double.valueOf(split[0]));
+ result.setEndDefaultPointLat(Double.valueOf(split[1]));
+ } catch (Exception ignored) {
+ }
+ }
+ }
+ return ResultUtil.success(result);
+ }
}
--
Gitblit v1.7.1