diff --git a/eride-admin/src/main/java/com/ruoyi/web/controller/app/AppVerifyController.java b/eride-admin/src/main/java/com/ruoyi/web/controller/app/AppVerifyController.java index fccdee8..6b4e7b4 100644 --- a/eride-admin/src/main/java/com/ruoyi/web/controller/app/AppVerifyController.java +++ b/eride-admin/src/main/java/com/ruoyi/web/controller/app/AppVerifyController.java @@ -625,8 +625,11 @@ public class AppVerifyController extends BaseController if(StrUtil.isBlank(sn)){ throw new ServiceException("【根据sn查询正在进行中的订单】sn不能为空"); } - EOrderVO order = orderService.getInProgressOrder(sn); - return success(order); + List order = orderService.getInProgressOrder(getUserId(),sn); + if(ObjectUtil.isNull(order) || order.isEmpty()){ + return error("无正在进行中的订单"); + } + return success(order.get(0)); } /** @@ -829,10 +832,16 @@ public class AppVerifyController extends BaseController public AjaxResult getDeviceListByToken() { logger.info("【根据token查询车辆列表】"); - EDeviceQuery deviceQuery = new EDeviceQuery(); - deviceQuery.setUserId(getUserId()); - List list = deviceService.selectEDeviceListWithIsolate(deviceQuery); - return success(list); + // todo 如果是用户有订单,则返回所有订单中的车辆 获取到用户类型,如果是普通用户,则查询订单来判断 + if(ServiceConstants.USER_TYPE_NORMAL.equals(getUserType())){ + List devices = deviceService.getInProgressOrder(getUserId()); + return success(devices); + }else{ + EDeviceQuery deviceQuery = new EDeviceQuery(); + deviceQuery.setUserId(getUserId()); + List list = deviceService.selectEDeviceListWithIsolate(deviceQuery); + return success(list); + } } /** diff --git a/eride-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java b/eride-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java index a685e06..90d1b39 100644 --- a/eride-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java +++ b/eride-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java @@ -23,7 +23,7 @@ import com.ruoyi.common.utils.sql.SqlUtil; /** * web层通用数据处理 - * + * * @author ruoyi */ public class BaseController @@ -113,7 +113,7 @@ public class BaseController { return AjaxResult.success(message); } - + /** * 返回成功消息 */ @@ -140,7 +140,7 @@ public class BaseController /** * 响应返回结果 - * + * * @param rows 影响行数 * @return 操作结果 */ @@ -151,7 +151,7 @@ public class BaseController /** * 响应返回结果 - * + * * @param result 结果 * @return 操作结果 */ @@ -184,6 +184,14 @@ public class BaseController return getLoginUser().getUserId(); } + /** + * 获取登录用户id + */ + public String getUserType() + { + return getLoginUser().getUserType(); + } + /** * 获取登录部门id */ diff --git a/eride-common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java b/eride-common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java index 3462364..131630b 100644 --- a/eride-common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java +++ b/eride-common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java @@ -26,6 +26,11 @@ public class LoginUser implements UserDetails */ private Long deptId; + /** + * 用户类型 + */ + private String userType; + /** * 用户唯一标识 */ @@ -71,6 +76,10 @@ public class LoginUser implements UserDetails */ private EUserVO user; + public void setUserType(String userType) { + this.userType = userType; + } + public LoginUser() { } @@ -81,10 +90,11 @@ public class LoginUser implements UserDetails this.permissions = permissions; } - public LoginUser(Long userId, Long deptId, EUserVO user, Set permissions) + public LoginUser(Long userId, Long deptId, String userType, EUserVO user, Set permissions) { this.userId = userId; this.deptId = deptId; + this.userType = userType; this.user = user; this.permissions = permissions; } @@ -94,6 +104,11 @@ public class LoginUser implements UserDetails return userId; } + public String getUserType() + { + return userType; + } + public void setUserId(Long userId) { this.userId = userId; diff --git a/eride-framework/src/main/java/com/ruoyi/framework/web/service/UserDetailsServiceImpl.java b/eride-framework/src/main/java/com/ruoyi/framework/web/service/UserDetailsServiceImpl.java index 9333d66..6f7ef23 100644 --- a/eride-framework/src/main/java/com/ruoyi/framework/web/service/UserDetailsServiceImpl.java +++ b/eride-framework/src/main/java/com/ruoyi/framework/web/service/UserDetailsServiceImpl.java @@ -67,7 +67,7 @@ public class UserDetailsServiceImpl implements UserDetailsService passwordService.validate(user); } } - UserDetails loginUser = createLoginUser(user); + UserDetails loginUser = createLoginUser(user); return loginUser; } verifyUser(username, user); @@ -98,6 +98,6 @@ public class UserDetailsServiceImpl implements UserDetailsService public UserDetails createLoginUser(EUserVO user) { - return new LoginUser(user.getUserId(), user.getDeptId(), user, permissionService.getMenuPermission(user)); + return new LoginUser(user.getUserId(), user.getDeptId(), user.getUserType(),user, permissionService.getMenuPermission(user)); } } diff --git a/eride-system/src/main/java/com/ruoyi/system/mapper/EDeviceMapper.java b/eride-system/src/main/java/com/ruoyi/system/mapper/EDeviceMapper.java index 0d11a9a..7d70463 100644 --- a/eride-system/src/main/java/com/ruoyi/system/mapper/EDeviceMapper.java +++ b/eride-system/src/main/java/com/ruoyi/system/mapper/EDeviceMapper.java @@ -167,4 +167,12 @@ public interface EDeviceMapper extends BaseMapper * @return 结果 */ int cancelDefault(@Param("userId") Long userId, @Param("sn") String sn); + + /** + * 根据用户id查询正在进行的车辆列表 + * + * @param userId 用户id + * @return 结果 + */ + List getInProgressOrder(Long userId); } diff --git a/eride-system/src/main/java/com/ruoyi/system/mapper/EOrderMapper.java b/eride-system/src/main/java/com/ruoyi/system/mapper/EOrderMapper.java index 06fc007..8aaa3e9 100644 --- a/eride-system/src/main/java/com/ruoyi/system/mapper/EOrderMapper.java +++ b/eride-system/src/main/java/com/ruoyi/system/mapper/EOrderMapper.java @@ -100,7 +100,7 @@ public interface EOrderMapper /** * 根据sn查询正在进行中的订单 */ - List getInProgressOrder(String sn); + List getInProgressOrder(@Param("userId") Long userId,@Param("sn") String sn); /** * 订单金额 diff --git a/eride-system/src/main/java/com/ruoyi/system/service/IEDeviceService.java b/eride-system/src/main/java/com/ruoyi/system/service/IEDeviceService.java index 594589e..fe1bb22 100644 --- a/eride-system/src/main/java/com/ruoyi/system/service/IEDeviceService.java +++ b/eride-system/src/main/java/com/ruoyi/system/service/IEDeviceService.java @@ -397,4 +397,6 @@ public interface IEDeviceService extends IService /** 获取到该代理商下所有的车辆数 */ Integer getTatalDeviceCount(Long merchantId, String status,String[] statusList); + /** 根据用户id查询正在进行的车辆列表 */ + List getInProgressOrder(Long userId); } diff --git a/eride-system/src/main/java/com/ruoyi/system/service/IEOrderService.java b/eride-system/src/main/java/com/ruoyi/system/service/IEOrderService.java index 7a59e7a..c65f07d 100644 --- a/eride-system/src/main/java/com/ruoyi/system/service/IEOrderService.java +++ b/eride-system/src/main/java/com/ruoyi/system/service/IEOrderService.java @@ -193,7 +193,7 @@ public interface IEOrderService /** * 根据sn查询正在进行中的订单 */ - EOrderVO getInProgressOrder(String sn); + List getInProgressOrder(Long userId, String sn); void validate(EOrderQuery orderQuery); diff --git a/eride-system/src/main/java/com/ruoyi/system/service/impl/EDeviceServiceImpl.java b/eride-system/src/main/java/com/ruoyi/system/service/impl/EDeviceServiceImpl.java index 08492f2..e74d5ea 100644 --- a/eride-system/src/main/java/com/ruoyi/system/service/impl/EDeviceServiceImpl.java +++ b/eride-system/src/main/java/com/ruoyi/system/service/impl/EDeviceServiceImpl.java @@ -42,6 +42,7 @@ import org.springframework.transaction.support.TransactionTemplate; import javax.annotation.Resource; import java.math.BigDecimal; import java.math.RoundingMode; +import java.util.Collections; import java.util.Date; import java.util.List; import java.util.concurrent.ScheduledExecutorService; @@ -1354,6 +1355,11 @@ public class EDeviceServiceImpl extends ServiceImpl impl public Integer getTatalDeviceCount(Long merchantId,String status,String[] statusList) { return deviceMapper.getTatalDeviceCount(merchantId,status,statusList); } + + @Override + public List getInProgressOrder(Long userId) { + return deviceMapper.getInProgressOrder(userId); + } // // /** 押金抵扣 */ // private void depositDeduction(EtOrder order) { diff --git a/eride-system/src/main/java/com/ruoyi/system/service/impl/EOrderServiceImpl.java b/eride-system/src/main/java/com/ruoyi/system/service/impl/EOrderServiceImpl.java index 91f18af..904076d 100644 --- a/eride-system/src/main/java/com/ruoyi/system/service/impl/EOrderServiceImpl.java +++ b/eride-system/src/main/java/com/ruoyi/system/service/impl/EOrderServiceImpl.java @@ -493,8 +493,8 @@ public class EOrderServiceImpl implements IEOrderService if(StrUtil.isNotBlank(order.getSn())){ throw new RuntimeException("该订单已绑定车辆:"+order.getSn()); } - EOrderVO order1 = getInProgressOrder(sn); - if(ObjectUtil.isNotNull(order1)){ + List order1 = getInProgressOrder(null,sn); + if(!order1.isEmpty()){ throw new RuntimeException("该车辆【"+sn+"】有进行中的订单:"); } Boolean execute = transactionTemplate.execute(e -> { @@ -953,12 +953,8 @@ public class EOrderServiceImpl implements IEOrderService * 根据sn查询正在进行中的订单 */ @Override - public EOrderVO getInProgressOrder(String sn) { - List orders = orderMapper.getInProgressOrder(sn); - if(ObjectUtil.isNotNull(orders.size()) && orders.size() > 0){ - return orders.get(0); - } - return null; + public List getInProgressOrder(Long userId, String sn) { + return orderMapper.getInProgressOrder(userId,sn); } @Override diff --git a/eride-system/src/main/resources/mapper/system/EDeviceMapper.xml b/eride-system/src/main/resources/mapper/system/EDeviceMapper.xml index 09bce5d..e69a96d 100644 --- a/eride-system/src/main/resources/mapper/system/EDeviceMapper.xml +++ b/eride-system/src/main/resources/mapper/system/EDeviceMapper.xml @@ -356,4 +356,56 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" update e_device set is_default = '0' where user_id = #{userId} and sn != #{sn} + + + + + + diff --git a/eride-system/src/main/resources/mapper/system/EOrderMapper.xml b/eride-system/src/main/resources/mapper/system/EOrderMapper.xml index 9ecbfda..0d6aa30 100644 --- a/eride-system/src/main/resources/mapper/system/EOrderMapper.xml +++ b/eride-system/src/main/resources/mapper/system/EOrderMapper.xml @@ -207,7 +207,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"