wenhongquan преди 5 месеца
родител
ревизия
15bfc8decb

+ 4 - 0
ruoyi-admin/src/main/resources/application.yml

@@ -100,6 +100,10 @@ sa-token:
   is-share: false
   # jwt秘钥
   jwt-secret-key: abcdefghijklmnopqrstuvwxyz
+  # token有效期,单位s 默认30天, -1代表永不过期
+  timeout: 2592000
+  # token临时有效期 (指定时间内无操作就视为过期) 单位: 秒
+  activity-timeout: -1
 
 # security配置
 security:

+ 12 - 0
ruoyi-modules/ruoyi-dzbc/src/main/java/org/dromara/system/service/impl/TblDzbcCargoOrderServiceImpl.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.RequiredArgsConstructor;
+import org.dromara.common.core.exception.ServiceException;
 import org.dromara.common.core.service.UserService;
 import org.dromara.common.core.utils.MapstructUtils;
 import org.dromara.common.core.utils.StringUtils;
@@ -238,6 +239,17 @@ public class TblDzbcCargoOrderServiceImpl implements ITblDzbcCargoOrderService {
      */
     @Override
     public Boolean updateStatus(Long id, Integer status) {
+        // 如果是取货操作(status=1),需要校验是否已支付
+        if (status == 1) {
+            TblDzbcCargoOrder order = baseMapper.selectById(id);
+            if (order == null) {
+                throw new ServiceException("订单不存在");
+            }
+            // 如果价格大于0且未支付
+            if (order.getPrice() != null && order.getPrice() > 0 && (order.getPayStatus() == null || order.getPayStatus() != 1)) {
+                throw new ServiceException("订单未支付,无法取货");
+            }
+        }
         TblDzbcCargoOrder order = new TblDzbcCargoOrder();
         order.setId(id);
         order.setStatus(status);

+ 29 - 0
ruoyi-modules/ruoyi-dzbc/src/main/java/org/dromara/system/service/impl/TblDzbcDriverTripServiceImpl.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.RequiredArgsConstructor;
+import org.dromara.common.core.exception.ServiceException;
 import org.dromara.common.core.utils.MapstructUtils;
 import org.dromara.common.mybatis.core.page.PageQuery;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
@@ -86,6 +87,7 @@ public class TblDzbcDriverTripServiceImpl implements ITblDzbcDriverTripService {
         trip.setExt2(bo.getExt2());
         trip.setStatus(0);
 
+        validEntityBeforeSave(trip);
         baseMapper.insert(trip);
 
         TblDzbcDriverTripVo vo = queryById(trip.getId());
@@ -162,6 +164,33 @@ public class TblDzbcDriverTripServiceImpl implements ITblDzbcDriverTripService {
     }
 
     private void validEntityBeforeSave(TblDzbcDriverTrip entity) {
+        // 校验同一时间的同一辆车只能发车一次
+        if (entity.getCarId() != null || entity.getStartTime() != null) {
+            Long carId = entity.getCarId();
+            LocalDateTime startTime = entity.getStartTime();
+
+            // 如果是更新操作,且字段缺失,需要查询数据库补充
+            if (entity.getId() != null) {
+                TblDzbcDriverTrip old = baseMapper.selectById(entity.getId());
+                if (old != null) {
+                    if (carId == null) carId = old.getCarId();
+                    if (startTime == null) startTime = old.getStartTime();
+                }
+            }
+
+            if (carId != null && startTime != null) {
+                LambdaQueryWrapper<TblDzbcDriverTrip> lqw = Wrappers.lambdaQuery();
+                lqw.eq(TblDzbcDriverTrip::getCarId, carId);
+                lqw.eq(TblDzbcDriverTrip::getStartTime, startTime);
+                lqw.ne(TblDzbcDriverTrip::getStatus, 3); // 排除已取消
+                if (entity.getId() != null) {
+                    lqw.ne(TblDzbcDriverTrip::getId, entity.getId());
+                }
+                if (baseMapper.selectCount(lqw) > 0) {
+                    throw new ServiceException("该车辆在该时间段已有任务");
+                }
+            }
+        }
     }
 
     private void fillDetails(TblDzbcDriverTripVo vo) {