From 64b4be369b925296fd0bb70166fe5fb2d6da5807 Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期一, 13 一月 2025 19:38:59 +0800
Subject: [PATCH] 订单编辑修改

---
 ruoyi-service/ruoyi-admin/src/main/java/com/ruoyi/admin/controller/OrderController.java |   31 ++++++++++++++++++++++++++++---
 1 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/ruoyi-service/ruoyi-admin/src/main/java/com/ruoyi/admin/controller/OrderController.java b/ruoyi-service/ruoyi-admin/src/main/java/com/ruoyi/admin/controller/OrderController.java
index f468f8b..90cc8ab 100644
--- a/ruoyi-service/ruoyi-admin/src/main/java/com/ruoyi/admin/controller/OrderController.java
+++ b/ruoyi-service/ruoyi-admin/src/main/java/com/ruoyi/admin/controller/OrderController.java
@@ -21,6 +21,7 @@
 import com.ruoyi.common.core.constant.Constants;
 import com.ruoyi.common.core.domain.BaseEntity;
 import com.ruoyi.common.core.domain.R;
+import com.ruoyi.common.core.exception.ServiceException;
 import com.ruoyi.common.core.utils.DateUtils;
 import com.ruoyi.common.core.utils.GaoDeMapUtil;
 import com.ruoyi.common.core.utils.SnowflakeIdWorker;
@@ -52,6 +53,7 @@
 import java.net.URLEncoder;
 import java.nio.file.Files;
 import java.nio.file.Paths;
+import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -97,6 +99,8 @@
     private ExchangeDispatchClient dispatchClient;
     @Resource
     private TokenService tokenService;
+    @Resource
+    private ChangeDispatchService changeDispatchService;
 
     /**
      * 雪花算法类
@@ -375,6 +379,18 @@
                 .eq(Site::getIsDelete, 0).one();
         if (null != site) {
             order.setSiteName(site.getSiteName());
+        }
+
+        if(StringUtils.hasLength(order.getTime()) || Objects.nonNull(order.getServerId())){
+            // 修改sys_change_dispatch 为已改派
+            ChangeDispatch changeDispatch = changeDispatchService.lambdaQuery()
+                    .eq(ChangeDispatch::getOrderId, order.getOrderId())
+                    .eq(ChangeDispatch::getIsDelete, 0)
+                    .last("limit 1").one();
+            if(Objects.nonNull(changeDispatch)){
+                changeDispatch.setState(Constants.ONE);
+                changeDispatchService.updateById(changeDispatch);
+            }
         }
 
         // 师傅信息
@@ -769,9 +785,7 @@
     public R<String> importTemplate(HttpServletResponse response) throws Exception {
         List<FrozenBuckleImportDTO> list = new ArrayList<>();
         FrozenBuckleImportDTO bean = new FrozenBuckleImportDTO();
-
         list.add(bean);
-
         // 这里URLEncoder.encode可以防止中文乱码
         String fileName = URLEncoder.encode("订单导入模板", "UTF-8");
         response.setContentType("application/vnd.ms-excel");
@@ -841,8 +855,19 @@
             String area = frozenBuckleImportDTO.getArea();
             String address = frozenBuckleImportDTO.getReservationAddress();
 
+            String time = frozenBuckleImportDTO.getTime();
+            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+            try{
+                format.parse(time);
+            }catch (Exception e){
+                throw new ServiceException("上门时间格式错误");
+            }
+
             // 解析地址经纬度
             CityInfoVO cityInfoVO = GaoDeMapUtil.getAddressInfo(province + city + area + address).getDatas();
+            if(Objects.isNull(cityInfoVO.getLongitude()) || Objects.isNull(cityInfoVO.getLatitude())){
+                return R.fail("地址输入不正确");
+            }
             String areaCode = cityInfoVO.getCode();
             String provinceCode = areaCode.substring(0, 2) + "0000";
             String cityCode = areaCode.substring(0, 4) + "00";
@@ -885,7 +910,7 @@
                 order.setServeId(recoveryServe.getId());
                 order.setServePrice(recoveryServe.getDefaultPrice());
             }else {
-                return R.fail("回收服务不存在");
+                return R.fail("服务信息不存在");
             }
             RecoveryServePrice one = recoveryServePriceService.lambdaQuery().eq(RecoveryServePrice::getCity, order.getCityCode()).eq(RecoveryServePrice::getRecoveryServeId, order.getServeId()).eq(BaseEntity::getIsDelete, 0).one();
             if (one==null) {

--
Gitblit v1.7.1