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 7d4633c..246c520 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 @@ -833,12 +833,16 @@ public class AppVerifyController extends BaseController { logger.info("【根据token查询车辆列表(商家)】:keywords= {}", keywords); EUserVO userVO = userService.selectUserById(getUserId()); - String userType = userVO.getUserType(); - ServiceUtil.assertion(!(userType.equals(USER_TYPE_MERCHANT) || userType.equals(USER_TYPE_INDIVIDUAL)), "您没有权限访问"); +// String userType = userVO.getUserType(); +// ServiceUtil.assertion(!(userType.equals(USER_TYPE_MERCHANT) || userType.equals(USER_TYPE_INDIVIDUAL)), "您没有权限访问"); EDeviceQuery deviceQuery = new EDeviceQuery(); deviceQuery.setUserId(getUserId()); deviceQuery.setKeywords(keywords); List list = deviceService.selectEDeviceListWithIsolate(deviceQuery); + // list添加type等于1 + list.forEach(device -> { + device.setType("1"); + }); // 拼接分享的车辆 if(list.isEmpty()){ list = new ArrayList<>(); @@ -848,9 +852,15 @@ public class AppVerifyController extends BaseController } private void assembleShareDevice(List list,EUserVO userVO) { - List sns = shareKeyService.selectEShareSnListByShareUserId(userVO.getUserId()); + List sns = shareKeyService.selectEShareSnListByShareUserId(userVO.getUserId()); + ArrayList devices = new ArrayList<>(); if(!sns.isEmpty()){ - List devices = deviceService.selectBySns(sns); + sns.forEach(key -> { + EDeviceVO deviceVO = deviceService.selectEDeviceBySn(key.getSn()); + deviceVO.setType("2"); + deviceVO.setExpirationTime(key.getExpirationTime()); + devices.add(deviceVO); + }); list.addAll(devices); } } @@ -1087,21 +1097,20 @@ public class AppVerifyController extends BaseController public AjaxResult claimKey(Long keyId) { logger.info("扫码领取钥匙:keyId=【{}】", keyId); - EShareKey eShareKey = shareKeyService.selectEShareKeyByKeyId(keyId); - if(!ServiceConstants.KEY_STATUS_NEW.equals(eShareKey.getStatus())){ + EShareKey shareKey = shareKeyService.selectEShareKeyByKeyId(keyId); + if(!ServiceConstants.KEY_STATUS_NEW.equals(shareKey.getStatus())){ return AjaxResult.error("【扫码领取钥匙】失败,非待领取状态"); } + if(!shareKey.getShareId().equals(getUserId())){ + return AjaxResult.error("不是被分享人不能领取"); + } EShareKey bandKey = geteShareKey(keyId); return success(shareKeyService.updateEShareKey(bandKey)); } private @NotNull EShareKey geteShareKey(Long keyId) { - EUserVO userVO = userService.selectUserById(getUserId()); EShareKey bandKey = new EShareKey(); bandKey.setKeyId(keyId); - bandKey.setShareId(getUserId()); - bandKey.setShareUserName(userVO.getUserName()); - bandKey.setSharePhone(userVO.getPhonenumber()); bandKey.setStatus(ServiceConstants.KEY_STATUS_RECEIVED); return bandKey; } diff --git a/eride-admin/src/main/resources/application-druid.yml b/eride-admin/src/main/resources/application-druid.yml index c293e2a..06b3663 100644 --- a/eride-admin/src/main/resources/application-druid.yml +++ b/eride-admin/src/main/resources/application-druid.yml @@ -6,9 +6,9 @@ spring: druid: # 主库数据源 master: - url: jdbc:mysql://localhost:3306/eride?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + url: jdbc:mysql://47.120.68.19:3306/eride?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 username: root - password: 123456 + password: d0dbe100b71c1d09 # 从库数据源 slave: # 从数据源开关/默认关闭 diff --git a/eride-system/src/main/java/com/ruoyi/system/domain/device/EDeviceVO.java b/eride-system/src/main/java/com/ruoyi/system/domain/device/EDeviceVO.java index a828c90..3fad7e1 100644 --- a/eride-system/src/main/java/com/ruoyi/system/domain/device/EDeviceVO.java +++ b/eride-system/src/main/java/com/ruoyi/system/domain/device/EDeviceVO.java @@ -1,10 +1,12 @@ package com.ruoyi.system.domain.device; +import com.fasterxml.jackson.annotation.JsonFormat; import com.ruoyi.common.annotation.Excel; import com.ruoyi.system.domain.EFunction; import com.ruoyi.system.domain.accessory.EAccessoryVO; import lombok.Data; +import java.util.Date; import java.util.List; @Data @@ -39,4 +41,11 @@ public class EDeviceVO extends EDevice{ @Excel(name = "正在进行中的订单号") private String inProgressOrderNo; + @Excel(name = "车辆来源类型:1-自己的车;2-分享的车") + private String type; + + /** 有效时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date expirationTime; + } diff --git a/eride-system/src/main/java/com/ruoyi/system/mapper/EShareKeyMapper.java b/eride-system/src/main/java/com/ruoyi/system/mapper/EShareKeyMapper.java index 8f65e60..b8f1c56 100644 --- a/eride-system/src/main/java/com/ruoyi/system/mapper/EShareKeyMapper.java +++ b/eride-system/src/main/java/com/ruoyi/system/mapper/EShareKeyMapper.java @@ -89,7 +89,7 @@ public interface EShareKeyMapper /** * 根据分享用户id查询未过期车辆sn */ - List selectEShareSnListByShareUserId(Long shareUserId); + List selectEShareSnListByShareUserId(Long shareUserId); /** * 查询已过期但改变状态的共享钥匙列表 diff --git a/eride-system/src/main/java/com/ruoyi/system/service/IEShareKeyService.java b/eride-system/src/main/java/com/ruoyi/system/service/IEShareKeyService.java index c4d097d..bab888c 100644 --- a/eride-system/src/main/java/com/ruoyi/system/service/IEShareKeyService.java +++ b/eride-system/src/main/java/com/ruoyi/system/service/IEShareKeyService.java @@ -41,7 +41,7 @@ public interface IEShareKeyService * @param ownerId 归属用户id * @return 共享钥匙集合 */ - public List selectEShareSnListByShareUserId(Long ownerId); + public List selectEShareSnListByShareUserId(Long ownerId); /** * 根据归属用户id查询共享钥匙列表(已失效) diff --git a/eride-system/src/main/java/com/ruoyi/system/service/impl/EShareKeyServiceImpl.java b/eride-system/src/main/java/com/ruoyi/system/service/impl/EShareKeyServiceImpl.java index a5fe3e3..501d775 100644 --- a/eride-system/src/main/java/com/ruoyi/system/service/impl/EShareKeyServiceImpl.java +++ b/eride-system/src/main/java/com/ruoyi/system/service/impl/EShareKeyServiceImpl.java @@ -69,7 +69,7 @@ public class EShareKeyServiceImpl implements IEShareKeyService * @return 共享钥匙集合 */ @Override - public List selectEShareSnListByShareUserId(Long shareUserId){ + public List selectEShareSnListByShareUserId(Long shareUserId){ return eShareKeyMapper.selectEShareSnListByShareUserId(shareUserId); } diff --git a/eride-system/src/main/java/com/ruoyi/system/task/RlTask.java b/eride-system/src/main/java/com/ruoyi/system/task/RlTask.java index ea7d049..f2d07e7 100644 --- a/eride-system/src/main/java/com/ruoyi/system/task/RlTask.java +++ b/eride-system/src/main/java/com/ruoyi/system/task/RlTask.java @@ -133,7 +133,7 @@ public class RlTask { * 分享key过期状态处理 */ public void expiredKeyHandler(){ - log.info("-------------------【定时任务】分享key过期状态处理---开始----------------"); +// log.info("-------------------【定时任务】分享key过期状态处理---开始----------------"); List eShareKeys = shareKeyService.selectExpiredShareKeyList(); for (EShareKey eShareKey:eShareKeys) { EShareKey updateKey = new EShareKey(); @@ -141,7 +141,7 @@ public class RlTask { updateKey.setStatus(ServiceConstants.KEY_STATUS_EXPIRED); int i = shareKeyService.updateEShareKey(updateKey); } - log.info("-------------------【定时任务】分享key过期状态处理---结束----------------"); +// log.info("-------------------【定时任务】分享key过期状态处理---结束----------------"); } } diff --git a/eride-system/src/main/resources/mapper/system/EShareKeyMapper.xml b/eride-system/src/main/resources/mapper/system/EShareKeyMapper.xml index 98c6a8e..55a8613 100644 --- a/eride-system/src/main/resources/mapper/system/EShareKeyMapper.xml +++ b/eride-system/src/main/resources/mapper/system/EShareKeyMapper.xml @@ -61,9 +61,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where k.share_id = #{shareUserId} and k.del_flag = '0' - SELECT - k.sn + k.sn, + k.expiration_time FROM e_share_key k WHERE