From 995e4fed95dc0625a2b3119838331823fa4558ac Mon Sep 17 00:00:00 2001
From: “mitao” <“2763622819@qq.com”>
Date: 星期四, 12 三月 2026 14:50:20 +0800
Subject: [PATCH] bugfix

---
 xp-robotaxi-order-boot/src/main/resources/i18n/messages_en_US.properties                                   |    7 +++
 xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/service/IXpOrderService.java                       |    8 ++++
 xp-robotaxi-order-boot/src/main/resources/i18n/messages.properties                                         |    7 +++
 xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/controller/XpOrderController.java                  |   16 ++++++--
 xp-robotaxi-order-boot/src/main/resources/i18n/messages_zh_CN.properties                                   |    7 +++
 xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/service/impl/XpClockInServiceImpl.java |    2 
 xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/constant/I18nKeyConstant.java                      |    6 ++
 xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/service/impl/XpOrderServiceImpl.java               |   36 ++++++++++++++++++
 8 files changed, 80 insertions(+), 9 deletions(-)

diff --git a/xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/service/impl/XpClockInServiceImpl.java b/xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/service/impl/XpClockInServiceImpl.java
index cd2127f..ed244f9 100644
--- a/xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/service/impl/XpClockInServiceImpl.java
+++ b/xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/service/impl/XpClockInServiceImpl.java
@@ -405,7 +405,7 @@
         dto.setList(pageInfo);
         XpOperationsUser xpOperationsUser = xpOperationUserClient.queryById(query.getAppUserId()).getData();
         List<Long> longList = fleetOperationsClient.getFleetIdsByUserId(xpOperationsUser.getId()).getData();
-        List<XpSchedulingDetail> list = xpSchedulingDetailService.list(new QueryWrapper<XpSchedulingDetail>().eq("fleetId", longList.get(0)).between(StringUtils.isNotEmpty(startTime), "plan_time", startTime, endTime));
+        List<XpSchedulingDetail> list = xpSchedulingDetailService.list(new QueryWrapper<XpSchedulingDetail>().eq("fleet_id", longList.get(0)).between(StringUtils.isNotEmpty(startTime), "plan_time", startTime, endTime));
         QueryWrapper<XpClockIn> last1 = new QueryWrapper<XpClockIn>().eq("app_user_id", query.getAppUserId()).last(" and (clock_in_result = 1 or clock_out_result = 1)"
                 + (StringUtils.isNotEmpty(startTime) ? " and (DATE_FORMAT(clock_in_time, '%Y-%m-%d') between '" + startTime + "' and '" + endTime + "' or DATE_FORMAT(clock_out_time, '%Y-%m-%d') between '" + startTime + "' and '" + endTime + "'))" : ""));
         QueryWrapper<XpClockIn> last2 = new QueryWrapper<XpClockIn>().eq("app_user_id", query.getAppUserId()).last(" and (clock_in_result = 2 or clock_out_result = 2)"
diff --git a/xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/constant/I18nKeyConstant.java b/xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/constant/I18nKeyConstant.java
index 80d0423..5c0e0d0 100644
--- a/xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/constant/I18nKeyConstant.java
+++ b/xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/constant/I18nKeyConstant.java
@@ -20,6 +20,10 @@
     String ORDER_REASSIGN_NEW_VEHICLE_NOT_START_ACCEPT = "order.reassign.new.vehicle.not.start.accept";
     String ORDER_REASSIGN_NEW_VEHICLE_NOT_FREE = "order.reassign.new.vehicle.not.free";
     String ORDER_STATUS_ERROR = "order.status.error";
+    String ORDER_CHANGE_AMOUNT_ID_REQUIRED = "order.change.amount.id.required";
+    String ORDER_CHANGE_AMOUNT_AMOUNT_REQUIRED = "order.change.amount.amount.required";
+    String ORDER_CHANGE_AMOUNT_AMOUNT_INVALID = "order.change.amount.amount.invalid";
+    String ORDER_CHANGE_AMOUNT_STATUS_INVALID = "order.change.amount.status.invalid";
+    String ORDER_CHANGE_AMOUNT_FAILED = "order.change.amount.failed";
     String VEHICLE_NOT_EXISTS = "vehicle.not.exists";
 }
-
diff --git a/xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/controller/XpOrderController.java b/xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/controller/XpOrderController.java
index 445d1cc..3c1b1d1 100644
--- a/xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/controller/XpOrderController.java
+++ b/xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/controller/XpOrderController.java
@@ -37,9 +37,7 @@
 import com.xiaopeng.order.service.IXpOrderService;
 import com.xiaopeng.order.vo.OrderDetailVo;
 import com.xiaopeng.unifiedverification.interceptor.XpClientCheck;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.*;
 import lombok.RequiredArgsConstructor;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.springframework.beans.BeanUtils;
@@ -55,6 +53,7 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.math.BigDecimal;
 import java.net.URLEncoder;
 import java.util.Arrays;
 import java.util.List;
@@ -292,7 +291,16 @@
         );
         return R.ok();
     }
-
+    @ApiOperation(value = "订单改价", tags = {"管理后台-交易管理-订单管理"})
+    @PostMapping("/api/v1/order/changeAmount")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "订单ID", required = true, dataType = "Long"),
+            @ApiImplicitParam(name = "amount", value = "新的订单金额", required = true, dataType = "BigDecimal")
+    })
+    public R<?> changeAmount(@RequestParam("id") Long id ,@RequestParam("amount") BigDecimal amount) {
+        xpOrderService.changeAmount(id, amount);
+        return R.ok();
+    }
     /**
      * 获取用户快捷胶囊 历史 时段 终点高点
      */
diff --git a/xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/service/IXpOrderService.java b/xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/service/IXpOrderService.java
index c9ec795..88aaddc 100644
--- a/xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/service/IXpOrderService.java
+++ b/xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/service/IXpOrderService.java
@@ -25,6 +25,7 @@
 import com.xiaopeng.order.model.vo.XpOrderPageVO;
 import com.xiaopeng.order.vo.OrderDetailVo;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 /**
@@ -207,4 +208,11 @@
     OrderDetailVo orderDetail(Long orderId, String uid);
 
     R<String> feeDescription(Long orderId, String uid);
+
+    /**
+     * 订单改价
+     * @param id
+     * @param amount
+     */
+    void changeAmount(Long id, BigDecimal amount);
 }
diff --git a/xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/service/impl/XpOrderServiceImpl.java b/xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/service/impl/XpOrderServiceImpl.java
index c618ae7..d257b52 100644
--- a/xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/service/impl/XpOrderServiceImpl.java
+++ b/xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/service/impl/XpOrderServiceImpl.java
@@ -2504,4 +2504,40 @@
 
         return xpOrderDetailVO;
     }
+
+    @Override
+    public void changeAmount(Long id, BigDecimal amount) {
+        if (Objects.isNull(id)) {
+            throw new ServiceException("订单ID不能为空", I18nKeyConstant.ORDER_CHANGE_AMOUNT_ID_REQUIRED);
+        }
+        if (Objects.isNull(amount)) {
+            throw new ServiceException("订单金额不能为空", I18nKeyConstant.ORDER_CHANGE_AMOUNT_AMOUNT_REQUIRED);
+        }
+        if (amount.compareTo(BigDecimal.ZERO) < 0) {
+            throw new ServiceException("订单金额不能小于0", I18nKeyConstant.ORDER_CHANGE_AMOUNT_AMOUNT_INVALID);
+        }
+
+        XpOrder order = this.getById(id);
+        if (Objects.isNull(order)) {
+            throw new ServiceException("订单不存在", I18nKeyConstant.ORDER_NOT_EXISTS);
+        }
+
+        final Integer pendingPaymentStatus = 8;
+        if (!Objects.equals(order.getStatus(), pendingPaymentStatus)) {
+            throw new ServiceException("当前订单状态不允许改价,只有待付款状态的订单可以改价", I18nKeyConstant.ORDER_CHANGE_AMOUNT_STATUS_INVALID);
+        }
+
+        if (Objects.nonNull(order.getOrderMoney()) && order.getOrderMoney().compareTo(amount) == 0) {
+            return;
+        }
+
+        boolean updated = this.lambdaUpdate()
+                .set(XpOrder::getOrderMoney, amount)
+                .eq(XpOrder::getId, id)
+                .eq(XpOrder::getStatus, pendingPaymentStatus)
+                .update();
+        if (!updated) {
+            throw new ServiceException("订单改价失败,请稍后重试", I18nKeyConstant.ORDER_CHANGE_AMOUNT_FAILED);
+        }
+    }
 }
diff --git a/xp-robotaxi-order-boot/src/main/resources/i18n/messages.properties b/xp-robotaxi-order-boot/src/main/resources/i18n/messages.properties
index 8e5d767..89e7749 100644
--- a/xp-robotaxi-order-boot/src/main/resources/i18n/messages.properties
+++ b/xp-robotaxi-order-boot/src/main/resources/i18n/messages.properties
@@ -12,4 +12,9 @@
 order.reassign.new.vehicle.not.free=新车辆已接单,请重新选择
 order.pricing.not.exists=当前城市未配置定价规则
 order.order.status.error=订单状态错误
-vehicle.not.exists=车辆不存在
\ No newline at end of file
+vehicle.not.exists=车辆不存在
+order.change.amount.id.required=订单ID不能为空
+order.change.amount.amount.required=订单金额不能为空
+order.change.amount.amount.invalid=订单金额不能小于0
+order.change.amount.status.invalid=当前订单状态不允许改价,只有待付款状态的订单可以改价
+order.change.amount.failed=订单改价失败,请稍后重试
diff --git a/xp-robotaxi-order-boot/src/main/resources/i18n/messages_en_US.properties b/xp-robotaxi-order-boot/src/main/resources/i18n/messages_en_US.properties
index fa19be3..a7242cb 100644
--- a/xp-robotaxi-order-boot/src/main/resources/i18n/messages_en_US.properties
+++ b/xp-robotaxi-order-boot/src/main/resources/i18n/messages_en_US.properties
@@ -13,4 +13,9 @@
 welcome.message=Welcome to our application!
 order.pricing.not.exists=The current city has not been configured with pricing rules
 order.order.status.error=Order status error
-vehicle.not.exists=The vehicle does not exist.
\ No newline at end of file
+vehicle.not.exists=The vehicle does not exist.
+order.change.amount.id.required=Order ID is required.
+order.change.amount.amount.required=Order amount is required.
+order.change.amount.amount.invalid=Order amount must be greater than or equal to 0.
+order.change.amount.status.invalid=The current order status does not allow price changes. Only pending payment orders can be changed.
+order.change.amount.failed=Failed to change order amount. Please try again later.
diff --git a/xp-robotaxi-order-boot/src/main/resources/i18n/messages_zh_CN.properties b/xp-robotaxi-order-boot/src/main/resources/i18n/messages_zh_CN.properties
index ee405de..137abaa 100644
--- a/xp-robotaxi-order-boot/src/main/resources/i18n/messages_zh_CN.properties
+++ b/xp-robotaxi-order-boot/src/main/resources/i18n/messages_zh_CN.properties
@@ -13,4 +13,9 @@
 welcome.message=欢迎来到我们的应用程序!
 order.pricing.not.exists=当前城市未配置定价规则
 order.order.status.error=订单状态错误
-vehicle.not.exists=车辆不存在
\ No newline at end of file
+vehicle.not.exists=车辆不存在
+order.change.amount.id.required=订单ID不能为空
+order.change.amount.amount.required=订单金额不能为空
+order.change.amount.amount.invalid=订单金额不能小于0
+order.change.amount.status.invalid=当前订单状态不允许改价,只有待付款状态的订单可以改价
+order.change.amount.failed=订单改价失败,请稍后重试

--
Gitblit v1.7.1