From 6d94892d35cb91fbe5ea9fd6a67c45b91ae4dff0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A3=B7=E5=8F=B6?= <14103883+leaf-phos@user.noreply.gitee.com> Date: Wed, 27 Nov 2024 18:06:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=91=98=E5=B7=A5=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/service/SysLoginService.java | 2 +- .../ruoyi/dashboard/domain/vo/TodoListVO.java | 3 + .../dashboard/service/DashboardService.java | 11 ++ .../com/ruoyi/ss/device/domain/DeviceBO.java | 20 --- .../ruoyi/ss/device/domain/DeviceQuery.java | 9 ++ .../ruoyi/ss/device/mapper/DeviceMapper.java | 14 +- .../ruoyi/ss/device/mapper/DeviceMapper.xml | 149 ++++++++++-------- .../ss/device/service/DeviceConverter.java | 10 ++ .../ss/device/service/DeviceService.java | 4 + .../ss/device/service/DeviceValidator.java | 14 ++ .../service/impl/DeviceAssemblerImpl.java | 4 +- .../service/impl/DeviceConverterImpl.java | 29 ++++ .../service/impl/DeviceServiceImpl.java | 7 +- .../service/impl/DeviceValidatorImpl.java | 36 +++-- .../ss/realName/mapper/RealNameMapper.xml | 2 +- .../java/com/ruoyi/ss/risk/domain/Risk.java | 5 + .../ss/riskInfo/mapper/RiskInfoMapper.java | 5 + .../ss/riskInfo/mapper/RiskInfoMapper.xml | 8 + .../ss/riskInfo/service/RiskInfoService.java | 5 + .../service/impl/RiskInfoServiceImpl.java | 5 + .../com/ruoyi/ss/store/domain/StoreVo.java | 3 + .../ss/store/domain/vo/StoreOperatorVO.java | 35 ++++ .../ss/store/service/StoreAssembler.java | 5 + .../ss/store/service/StoreValidator.java | 29 +++- .../service/impl/StoreAssemblerImpl.java | 27 ++++ .../service/impl/StoreValidatorImpl.java | 56 +++++-- .../ss/storeStaff/domain/StoreStaff.java | 3 +- .../ss/storeStaff/domain/StoreStaffVO.java | 10 ++ .../storeStaff/mapper/StoreStaffMapper.java | 3 + .../ss/storeStaff/mapper/StoreStaffMapper.xml | 6 + .../service/StoreStaffConverter.java | 15 ++ .../storeStaff/service/StoreStaffService.java | 4 + .../service/StoreStaffValidator.java | 17 +- .../service/impl/StoreStaffConverterImpl.java | 34 ++++ .../service/impl/StoreStaffServiceImpl.java | 31 ++++ .../service/impl/StoreStaffValidatorImpl.java | 11 +- .../domain/TransactionBillQuery.java | 10 ++ .../domain/vo/TransactionBillOperatorVO.java | 24 +++ .../domain/vo/TransactionBillVO.java | 4 + .../mapper/TransactionBillMapper.xml | 17 ++ .../service/TransactionAssembler.java | 4 + .../service/TransactionBillService.java | 5 + .../service/TransactionBillValidator.java | 5 + .../impl/TransactionAssemblerImpl.java | 22 ++- .../impl/TransactionBillServiceImpl.java | 6 + .../impl/TransactionBillValidatorImpl.java | 14 ++ .../controller/app/AppDeviceController.java | 38 +++-- .../controller/app/AppStoreController.java | 16 +- .../app/AppStoreStaffController.java | 30 ++++ .../app/AppTransactionBillController.java | 8 +- .../mch/MchStoreApplyController.java | 4 +- .../mch/MchStoreStaffController.java | 28 ++-- .../web/controller/ss/RiskController.java | 7 +- .../staff/StaffDeviceController.java | 44 ++++++ .../staff/StaffStoreController.java | 37 ++--- .../staff/StaffTransactionBillController.java | 46 ++++++ 56 files changed, 799 insertions(+), 201 deletions(-) create mode 100644 smart-switch-service/src/main/java/com/ruoyi/ss/store/domain/vo/StoreOperatorVO.java create mode 100644 smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/service/StoreStaffConverter.java create mode 100644 smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/service/impl/StoreStaffConverterImpl.java create mode 100644 smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/domain/vo/TransactionBillOperatorVO.java create mode 100644 smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppStoreStaffController.java create mode 100644 smart-switch-web/src/main/java/com/ruoyi/web/controller/staff/StaffDeviceController.java create mode 100644 smart-switch-web/src/main/java/com/ruoyi/web/controller/staff/StaffTransactionBillController.java diff --git a/smart-switch-ruoyi/smart-switch-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java b/smart-switch-ruoyi/smart-switch-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java index 8904c23e..3970c519 100644 --- a/smart-switch-ruoyi/smart-switch-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java +++ b/smart-switch-ruoyi/smart-switch-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java @@ -312,7 +312,7 @@ public class SysLoginService return null; } - String name = "微信用户" + openId.substring(openId.length() - 4); + String name = "微信" + openId.substring(openId.length() - 4); // 添加用户 SmUser newUser = new SmUser(); diff --git a/smart-switch-service/src/main/java/com/ruoyi/dashboard/domain/vo/TodoListVO.java b/smart-switch-service/src/main/java/com/ruoyi/dashboard/domain/vo/TodoListVO.java index d7041616..827a93e6 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/dashboard/domain/vo/TodoListVO.java +++ b/smart-switch-service/src/main/java/com/ruoyi/dashboard/domain/vo/TodoListVO.java @@ -29,4 +29,7 @@ public class TodoListVO { @ApiModelProperty("欠费设备数量") private Integer arrearsDeviceCount; + @ApiModelProperty("风控待审核数量") + private Integer riskVerifyCount; + } diff --git a/smart-switch-service/src/main/java/com/ruoyi/dashboard/service/DashboardService.java b/smart-switch-service/src/main/java/com/ruoyi/dashboard/service/DashboardService.java index 3f804d12..0e8c3dfe 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/dashboard/service/DashboardService.java +++ b/smart-switch-service/src/main/java/com/ruoyi/dashboard/service/DashboardService.java @@ -27,6 +27,9 @@ import com.ruoyi.ss.receiveBill.domain.enums.ReceiveBillGroupBy; import com.ruoyi.ss.receiveBill.domain.enums.ReceiveBillType; import com.ruoyi.ss.receiveBill.domain.vo.ReceiveAmountVO; import com.ruoyi.ss.receiveBill.service.ReceiveBillService; +import com.ruoyi.ss.riskInfo.domain.RiskInfoQuery; +import com.ruoyi.ss.riskInfo.domain.enums.RiskInfoStatus; +import com.ruoyi.ss.riskInfo.service.RiskInfoService; import com.ruoyi.ss.storeApply.domain.StoreApplyQuery; import com.ruoyi.ss.storeApply.domain.enums.StoreApplyStatus; import com.ruoyi.ss.storeApply.service.StoreApplyService; @@ -78,6 +81,9 @@ public class DashboardService { @Autowired private BonusService bonusService; + @Autowired + private RiskInfoService riskInfoService; + public TodoListVO getTodoList() { TodoListVO vo = new TodoListVO(); @@ -110,6 +116,11 @@ public class DashboardService { deviceQuery.setIsArrears(true); vo.setArrearsDeviceCount(deviceService.selectCount(deviceQuery)); + // 风控审核 + RiskInfoQuery riskInfoQuery = new RiskInfoQuery(); + riskInfoQuery.setStatus(RiskInfoStatus.WAIT_VERIFY.getStatus()); + vo.setRiskVerifyCount(riskInfoService.selectCount(riskInfoQuery)); + return vo; } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/DeviceBO.java b/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/DeviceBO.java index d15f87f4..0314e935 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/DeviceBO.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/DeviceBO.java @@ -73,26 +73,6 @@ public class DeviceBO extends Device { return bo; } - /** - * 过滤APP更新字段 - */ - public DeviceBO filterUpdateByApp() { - DeviceBO bo = new DeviceBO(); - bo.setDeviceId(getDeviceId()); - bo.setStoreId(getStoreId()); - bo.setRemark(getRemark()); - bo.setDeviceName(getDeviceName()); - bo.setCustomPicture(getCustomPicture()); - bo.setStartTime(getStartTime()); - bo.setStartPrice(getStartPrice()); - bo.setStartUnit(getStartUnit()); - bo.setOverTime(getOverTime()); - bo.setOverPrice(getOverPrice()); - bo.setOverUnit(getOverUnit()); - bo.setSuitIds(getSuitIds()); - return bo; - } - /** * 过滤代理商更新字段 * @return diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/DeviceQuery.java b/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/DeviceQuery.java index a922ff89..718eb25c 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/DeviceQuery.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/domain/DeviceQuery.java @@ -97,4 +97,13 @@ public class DeviceQuery extends Device { @ApiModelProperty("关键词") private String keyword; + + @ApiModelProperty("是否在员工信息中(根据员工信息筛选时使用)") + private Boolean inStaff; + + @ApiModelProperty("员工用户ID") + private Long staffUserId; + + @ApiModelProperty("员工权限") + private String staffPermission; } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/mapper/DeviceMapper.java b/smart-switch-service/src/main/java/com/ruoyi/ss/device/mapper/DeviceMapper.java index 5d89c4fa..292c5d4a 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/mapper/DeviceMapper.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/mapper/DeviceMapper.java @@ -33,7 +33,7 @@ public interface DeviceMapper * @param smDevice 设备 * @return 设备集合 */ - public List selectSmDeviceList(DeviceQuery smDevice); + public List selectSmDeviceList(@Param("query") DeviceQuery smDevice); /** * 新增设备 @@ -71,7 +71,7 @@ public interface DeviceMapper * 条件查询数量 * @param dto 条件 */ - int selectCount(DeviceQuery dto); + int selectCount(@Param("query") DeviceQuery dto); /** * 增加设备时长 @@ -91,7 +91,7 @@ public interface DeviceMapper * @param dto * @return */ - List selectSimpleList(DeviceQuery dto); + List selectSimpleList(@Param("query") DeviceQuery dto); /** * 设备绑定店铺 @@ -123,7 +123,7 @@ public interface DeviceMapper * 条件查询数量 * @param query 查询条件 */ - List selectCommonCount(DeviceQuery query); + List selectCommonCount(@Param("query") DeviceQuery query); /** * 根据设备编号查询 @@ -168,12 +168,12 @@ public interface DeviceMapper /** * 获取所有MAC */ - List selectMacSnList(DeviceQuery query); + List selectMacSnList(@Param("query") DeviceQuery query); /** * 查询一个 */ - DeviceVO selectOne(DeviceQuery query); + DeviceVO selectOne(@Param("query") DeviceQuery query); int batchUpdateModel(DeviceBatchUpdateModelDTO dto); @@ -200,7 +200,7 @@ public interface DeviceMapper /** * 查询设备最大的代理商服务费 */ - BigDecimal selectMaxAgentServiceRate(DeviceQuery query); + BigDecimal selectMaxAgentServiceRate(@Param("query") DeviceQuery query); /** * 绑定代理商 diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/mapper/DeviceMapper.xml b/smart-switch-service/src/main/java/com/ruoyi/ss/device/mapper/DeviceMapper.xml index 1fd046ef..85a40294 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/mapper/DeviceMapper.xml +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/mapper/DeviceMapper.xml @@ -91,106 +91,125 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - and ss.name like concat('%', #{storeName}, '%') - and sd.service_type = #{serviceType} - and sd.device_name like concat('%', #{deviceName}, '%') - and sm.model_name like concat('%', #{model}, '%') - and sd.mac = #{mac} - and sd.mac2 = #{mac2} - + and ss.name like concat('%', #{query.storeName}, '%') + and sd.service_type = #{query.serviceType} + and sd.device_name like concat('%', #{query.deviceName}, '%') + and sm.model_name like concat('%', #{query.model}, '%') + and sd.mac = #{query.mac} + and sd.mac2 = #{query.mac2} + and ( - sd.mac = #{anyMac} or sd.mac2 = #{anyMac} + sd.mac = #{query.anyMac} or sd.mac2 = #{query.anyMac} ) - + and ( - sd.mac like concat('%', #{likeAnyMac}, '%') or sd.mac2 like concat('%', #{likeAnyMac}, '%') + sd.mac like concat('%', #{query.likeAnyMac}, '%') or sd.mac2 like concat('%', #{query.likeAnyMac}, '%') ) - and sd.online_status = #{onlineStatus} - and sd.online_status1 = #{onlineStatus1} - and sd.online_status2 = #{onlineStatus2} - and sd.status = #{status} - and if(su.is_real, su.real_name, su.user_name) like concat('%', #{userName}, '%') - and sd.nick_name like concat('%', #{nickName}, '%') - and sd.user_id = #{userId} - and sd.store_id = #{storeId} - and sd.device_id = #{deviceId} - and sd.rent_time >= #{startRentTime} - and sd.device_id <= #{endRentTime} - and sd.device_no like concat('%', #{deviceNo}, '%') - and sd.device_no = #{eqDeviceNo} - and sd.lock_user_id = #{lockUserId} - and agent_id = #{agentId} - and if(sua.is_real, sua.real_name, sua.user_name) like concat('%', #{agentName}, '%') - and sd.service_mode = #{serviceMode} - and sd.version like concat('%', #{version}, '%') - and find_in_set(#{modelTag}, sm.tags) - and sd.device_id != #{excludeDeviceId} - + and sd.online_status = #{query.onlineStatus} + and sd.online_status1 = #{query.onlineStatus1} + and sd.online_status2 = #{query.onlineStatus2} + and sd.status = #{query.status} + and if(su.is_real, su.real_name, su.user_name) like concat('%', #{query.userName}, '%') + and sd.nick_name like concat('%', #{query.nickName}, '%') + and sd.user_id = #{query.userId} + and sd.store_id = #{query.storeId} + and sd.device_id = #{query.deviceId} + and sd.rent_time >= #{query.startRentTime} + and sd.device_id <= #{query.endRentTime} + and sd.device_no like concat('%', #{query.deviceNo}, '%') + and sd.device_no = #{query.eqDeviceNo} + and sd.lock_user_id = #{query.lockUserId} + and agent_id = #{query.agentId} + and if(sua.is_real, sua.real_name, sua.user_name) like concat('%', #{query.agentName}, '%') + and sd.service_mode = #{query.serviceMode} + and sd.version like concat('%', #{query.version}, '%') + and find_in_set(#{query.modelTag}, sm.tags) + and sd.device_id != #{query.excludeDeviceId} + + and sd.store_id + not + in () + + and ( - sd.device_name like concat('%', #{keyword}, '%') or - sd.device_no like concat('%', #{keyword}, '%') or - su.phonenumber like concat('%', #{keyword}, '%') or - su.user_name like concat('%', #{keyword}, '%') + sd.device_name like concat('%', #{query.keyword}, '%') or + sd.device_no like concat('%', #{query.keyword}, '%') or + su.phonenumber like concat('%', #{query.keyword}, '%') or + su.user_name like concat('%', #{query.keyword}, '%') ) - - + + and (sd.rent_time is null or sd.rent_time <= now()) - + and (sd.rent_time is not null and sd.rent_time > now()) - + and sd.device_id in - + #{item} - + and sd.device_no in - + #{item} - - + + and sd.user_id is not null - + and sd.user_id is null - + and sd.store_id in - + #{item} - + and sd.user_id in - + #{item} - + and sd.model_id in - + #{item} - + and sd.mac in - + #{item} - and sd.deleted = false - and sd.deleted = #{deleted} + and sd.deleted = false + and sd.deleted = #{query.deleted} + + + + select distinct sss.store_id + from ss_store_staff sss + + and sss.user_id = #{query.staffUserId} + + and find_in_set(#{query.staffPermission}, sss.permissions) + + + + + - - - sd.${groupBy}, + + + sd.${query.groupBy}, - - ${groupByTable}.${groupBy}, + + ${query.groupByTable}.${query.groupBy}, count(sd.device_id) as `count` @@ -265,12 +284,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - - - group by sd.${groupBy} + + + group by sd.${query.groupBy} - - group by ${groupByTable}.${groupBy} + + group by ${query.groupByTable}.${query.groupBy} diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/DeviceConverter.java b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/DeviceConverter.java index 376c887e..f5997f0c 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/DeviceConverter.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/DeviceConverter.java @@ -1,8 +1,18 @@ package com.ruoyi.ss.device.service; +import com.ruoyi.ss.device.domain.DeviceBO; + /** * @author wjh * 2024/7/15 */ public interface DeviceConverter { + + /** + * APP修改设备转BO + * @param data + * @param userId + * @return + */ + DeviceBO toBOByAppUpdate(DeviceBO data, Long userId); } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/DeviceService.java b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/DeviceService.java index e2c9d0d4..77478d66 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/DeviceService.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/DeviceService.java @@ -380,4 +380,8 @@ public interface DeviceService */ int setTime(DeviceVO device, long seconds, int tryCount); + /** + * 查询员工设备列表 + */ + List selectStaffDeviceList(DeviceQuery query); } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/DeviceValidator.java b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/DeviceValidator.java index f53747fc..e1bff48f 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/DeviceValidator.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/DeviceValidator.java @@ -108,4 +108,18 @@ public interface DeviceValidator { * 校验分成 */ void checkBonus(Long deviceId); + + /** + * 判断是否允许操作设备 + * @param deviceId 设备ID + * @param userId 用户ID + */ + boolean canOpera(Long deviceId, Long userId); + + /** + * 判断是否允许操作设备 + * @param device 设备 + * @param userId 用户ID + */ + boolean canOpera(DeviceVO device, Long userId); } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceAssemblerImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceAssemblerImpl.java index ac0b86c6..a575f60f 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceAssemblerImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceAssemblerImpl.java @@ -214,7 +214,7 @@ public class DeviceAssemblerImpl implements DeviceAssembler { // 直营模式 if (DeviceServiceMode.DIRECT.getMode().equals(device.getServiceMode())) { // 是商户 - if (deviceValidator.isMch(device, userId)) { + if (deviceValidator.canOpera(device, userId)) { device.setAllowSwitch(true); continue; } @@ -227,7 +227,7 @@ public class DeviceAssemblerImpl implements DeviceAssembler { continue; } // 是商户,并且代理允许 - if (deviceValidator.isMch(device, userId) && device.getAgentAllowMchSwitch()) { + if (deviceValidator.canOpera(device, userId) && device.getAgentAllowMchSwitch()) { device.setAllowSwitch(true); continue; } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceConverterImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceConverterImpl.java index 402e79c4..97721713 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceConverterImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceConverterImpl.java @@ -1,6 +1,11 @@ package com.ruoyi.ss.device.service.impl; +import com.ruoyi.ss.device.domain.DeviceBO; +import com.ruoyi.ss.device.domain.vo.DeviceVO; import com.ruoyi.ss.device.service.DeviceConverter; +import com.ruoyi.ss.device.service.DeviceService; +import com.ruoyi.ss.device.service.DeviceValidator; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; /** @@ -10,6 +15,30 @@ import org.springframework.stereotype.Service; @Service public class DeviceConverterImpl implements DeviceConverter { + @Autowired + private DeviceService deviceService; + + @Autowired + private DeviceValidator deviceValidator; + @Override + public DeviceBO toBOByAppUpdate(DeviceBO data, Long userId) { + if (data == null) { + return null; + } + + DeviceBO bo = new DeviceBO(); + bo.setDeviceId(data.getDeviceId()); + bo.setRemark(data.getRemark()); + bo.setDeviceName(data.getDeviceName()); + bo.setCustomPicture(data.getCustomPicture()); + + // 仅允许商户修改的字段 + if (deviceValidator.isMch(data.getDeviceId(), userId)) { + bo.setSuitIds(data.getSuitIds()); + bo.setStoreId(data.getStoreId()); + } + return bo; + } } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceServiceImpl.java index 36ec3326..de8a4224 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceServiceImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceServiceImpl.java @@ -806,6 +806,12 @@ public class DeviceServiceImpl implements DeviceService return this.setTime(device, LocalDateTime.now().plusSeconds(seconds), true, tryCount); } + @Override + public List selectStaffDeviceList(DeviceQuery query) { + query.setInStaff(true); + return deviceMapper.selectSmDeviceList(query); + } + private int updateSurplusEle(Long deviceId, BigDecimal ele) { if (deviceId == null || ele == null) { return 0; @@ -1258,7 +1264,6 @@ public class DeviceServiceImpl implements DeviceService // 获取设备信息 DeviceVO device = deviceMapper.selectSmDeviceByDeviceId(deviceId); ServiceUtil.assertion(device == null || device.getDeleted(), "设备不存在"); - ServiceUtil.assertion(!UserUtil.hasFrontUser(device.getUserId()), "您不是该设备的商户,无法进行该操作"); Integer result = transactionTemplate.execute(status -> { // 尝试关闭该设备未结束的所有订单 diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceValidatorImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceValidatorImpl.java index e160526e..339c6833 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceValidatorImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceValidatorImpl.java @@ -16,14 +16,16 @@ import com.ruoyi.ss.device.service.DeviceAssembler; import com.ruoyi.ss.device.service.DeviceService; import com.ruoyi.ss.device.service.DeviceValidator; import com.ruoyi.ss.store.service.StoreValidator; +import com.ruoyi.ss.storeStaff.domain.enums.StoreStaffPermissions; +import com.ruoyi.ss.storeStaff.service.StoreStaffValidator; import com.ruoyi.ss.suit.service.SuitValidator; import com.ruoyi.ss.transactionBill.domain.TransactionBillQuery; import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillType; import com.ruoyi.ss.transactionBill.service.TransactionBillService; import com.ruoyi.ss.user.domain.SmUserVO; import com.ruoyi.ss.user.service.ISmUserService; -import com.ruoyi.ss.user.service.impl.SmUserServiceImpl; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.core.parameters.P; import org.springframework.stereotype.Service; import java.math.BigDecimal; @@ -54,6 +56,9 @@ public class DeviceValidatorImpl extends BaseValidator implements DeviceValidato @Autowired private DeviceAssembler deviceAssembler; + @Autowired + private StoreStaffValidator storeStaffValidator; + /** * 设备编号是否存在 * @@ -148,17 +153,6 @@ public class DeviceValidatorImpl extends BaseValidator implements DeviceValidato return error("店铺不存在"); } - Long userId = SecurityUtils.getUserId(); - - // 判断是否有权限更改 - if (!isMch(data.getDeviceId(), userId)) { - return error("这不是您的设备,您无权更改"); - } - // 判断套餐 - if (CollectionUtils.isNotEmptyElement(data.getSuitIds()) && !suitValidator.isBelong(data.getSuitIds(), userId)) { - return error("有套餐不属于您,无权修改"); - } - return success(); } @@ -293,4 +287,22 @@ public class DeviceValidatorImpl extends BaseValidator implements DeviceValidato deviceAssembler.assembleBonusList(device); this.checkBonus(device); } + + @Override + public boolean canOpera(Long deviceId, Long userId) { + if (deviceId == null || userId == null) { + return false; + } + DeviceVO device = deviceService.selectById(deviceId); + return isMch(device, userId); + } + + @Override + public boolean canOpera(DeviceVO device, Long userId) { + if (device == null) { + return false; + } + return this.isMch(device, userId) + || storeStaffValidator.hasStorePermission(device.getStoreId(), userId, StoreStaffPermissions.DEVICE_OPERA); + } } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/realName/mapper/RealNameMapper.xml b/smart-switch-service/src/main/java/com/ruoyi/ss/realName/mapper/RealNameMapper.xml index 15e10382..f7c00ad6 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/realName/mapper/RealNameMapper.xml +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/realName/mapper/RealNameMapper.xml @@ -31,7 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and srn.id_card = #{query.eqIdCard} and srn.mobile like concat('%', #{query.mobile}, '%') and su.user_name like concat('%', #{query.userName}, '%') - and type = #{query.type} + and srn.type = #{query.type} + + insert into ss_risk_info diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/riskInfo/service/RiskInfoService.java b/smart-switch-service/src/main/java/com/ruoyi/ss/riskInfo/service/RiskInfoService.java index 96306b14..951f1299 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/riskInfo/service/RiskInfoService.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/riskInfo/service/RiskInfoService.java @@ -81,4 +81,9 @@ public interface RiskInfoService * 审核 */ int verify(RiskInfoVerifyDTO dto, LoginUser verifier); + + /** + * 查询数量 + */ + int selectCount(RiskInfoQuery query); } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/riskInfo/service/impl/RiskInfoServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/riskInfo/service/impl/RiskInfoServiceImpl.java index f4f84b5a..12b70f4a 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/riskInfo/service/impl/RiskInfoServiceImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/riskInfo/service/impl/RiskInfoServiceImpl.java @@ -194,6 +194,11 @@ public class RiskInfoServiceImpl implements RiskInfoService return result == null ? 0 : result; } + @Override + public int selectCount(RiskInfoQuery query) { + return riskInfoMapper.selectCount(query); + } + private int updateByQuery(RiskInfo data, RiskInfoQuery query) { return riskInfoMapper.updateByQuery(data, query); } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/store/domain/StoreVo.java b/smart-switch-service/src/main/java/com/ruoyi/ss/store/domain/StoreVo.java index 1690a5d2..1413fdb1 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/store/domain/StoreVo.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/store/domain/StoreVo.java @@ -2,6 +2,7 @@ package com.ruoyi.ss.store.domain; import com.fasterxml.jackson.annotation.JsonView; import com.ruoyi.common.core.domain.JsonViewProfile; +import com.ruoyi.ss.store.domain.vo.StoreOperatorVO; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; @@ -42,4 +43,6 @@ public class StoreVo extends Store { @JsonView(JsonViewProfile.App.class) private Integer availableDeviceCount; + @ApiModelProperty("操作") + private StoreOperatorVO operator; } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/store/domain/vo/StoreOperatorVO.java b/smart-switch-service/src/main/java/com/ruoyi/ss/store/domain/vo/StoreOperatorVO.java new file mode 100644 index 00000000..ba6179b0 --- /dev/null +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/store/domain/vo/StoreOperatorVO.java @@ -0,0 +1,35 @@ +package com.ruoyi.ss.store.domain.vo; + +import io.swagger.annotations.ApiModelProperty; +import io.swagger.annotations.ApiOperation; +import lombok.Data; + +/** + * @author wjh + * 2024/11/27 + */ +@Data +public class StoreOperatorVO { + + @ApiModelProperty("查看设备列表") + private Boolean viewDevice; + + @ApiModelProperty("修改店铺信息") + private Boolean update; + + @ApiModelProperty("配置店铺信息") + private Boolean config; + + @ApiModelProperty("注销店铺") + private Boolean del; + + public static StoreOperatorVO defaultInstance() { + StoreOperatorVO vo = new StoreOperatorVO(); + vo.setViewDevice(false); + vo.setUpdate(false); + vo.setConfig(false); + vo.setDel(false); + return vo; + } + +} diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/store/service/StoreAssembler.java b/smart-switch-service/src/main/java/com/ruoyi/ss/store/service/StoreAssembler.java index 1296df04..676a6066 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/store/service/StoreAssembler.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/store/service/StoreAssembler.java @@ -56,4 +56,9 @@ public interface StoreAssembler { * @param list */ void assembleAvailableDeviceCount(List list); + + /** + * 拼接操作 + */ + void assembleOperator(List list, Long userId); } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/store/service/StoreValidator.java b/smart-switch-service/src/main/java/com/ruoyi/ss/store/service/StoreValidator.java index 6319cb28..58cb43c8 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/store/service/StoreValidator.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/store/service/StoreValidator.java @@ -2,7 +2,6 @@ package com.ruoyi.ss.store.service; import com.ruoyi.common.core.domain.ValidateResult; import com.ruoyi.ss.store.domain.Store; -import com.ruoyi.ss.store.domain.StoreBO; import com.ruoyi.ss.store.domain.StoreVo; import java.time.LocalTime; @@ -68,16 +67,16 @@ public interface StoreValidator { /** * 判断店铺是否属于用户 */ - boolean isStoreBelongUser(List storeId, Long userId); + boolean isMch(List storeId, Long userId); default boolean isStoreBelongUser(Long storeId, Long userId) { - return isStoreBelongUser(Collections.singletonList(storeId), userId); + return isMch(Collections.singletonList(storeId), userId); } /** * 判断店铺是否属于用户 */ - boolean isStoreBelongUser(Store store, Long userId); + boolean isMch(Store store, Long userId); /** * 判断店铺是否存在 @@ -109,4 +108,26 @@ public interface StoreValidator { * 后校验 */ void afterCheck(StoreVo vo); + + /** + * 允许操作店铺 + * @param store 店铺 + * @param userId 用户 + */ + boolean canOperaStore(StoreVo store, Long userId); + + /** + * 允许操作店铺 + */ + boolean canOperaStore(Long storeId, Long userId); + + /** + * 允许查看店铺 + */ + boolean canViewStore(Long storeId, Long userId); + + /** + * 允许查看店铺 + */ + boolean canViewStore(StoreVo store, Long userId); } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/store/service/impl/StoreAssemblerImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/store/service/impl/StoreAssemblerImpl.java index 5790da16..793d2793 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/store/service/impl/StoreAssemblerImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/store/service/impl/StoreAssemblerImpl.java @@ -10,7 +10,9 @@ import com.ruoyi.ss.device.domain.enums.DeviceOnlineStatus; import com.ruoyi.ss.device.domain.enums.DeviceStatus; import com.ruoyi.ss.device.service.DeviceService; import com.ruoyi.ss.store.domain.StoreVo; +import com.ruoyi.ss.store.domain.vo.StoreOperatorVO; import com.ruoyi.ss.store.service.StoreAssembler; +import com.ruoyi.ss.store.service.StoreValidator; import com.ruoyi.ss.transactionBill.domain.TransactionBillQuery; import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillGroupBy; import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillStatus; @@ -39,6 +41,9 @@ public class StoreAssemblerImpl implements StoreAssembler { @Autowired private TransactionBillService transactionBillService; + @Autowired + private StoreValidator storeValidator; + /** * 拼接设备数量 * @@ -235,4 +240,26 @@ public class StoreAssemblerImpl implements StoreAssembler { store.setAvailableDeviceCount(count == null ? 0 :count); } } + + @Override + public void assembleOperator(List list, Long userId) { + if (CollectionUtils.isEmptyElement(list)) { + return; + } + + for (StoreVo store : list) { + StoreOperatorVO vo = StoreOperatorVO.defaultInstance(); + // 有操作权限,可修改、配置 + if (storeValidator.canOperaStore(store, userId)) { + vo.setConfig(true); + vo.setUpdate(true); + } + // 是商户,可删除、查看设备列表 + if (storeValidator.isMch(store, userId)) { + vo.setDel(true); + vo.setViewDevice(true); + } + store.setOperator(vo); + } + } } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/store/service/impl/StoreValidatorImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/store/service/impl/StoreValidatorImpl.java index de29415e..83ba3578 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/store/service/impl/StoreValidatorImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/store/service/impl/StoreValidatorImpl.java @@ -13,6 +13,8 @@ import com.ruoyi.ss.store.domain.StoreVo; import com.ruoyi.ss.store.domain.enums.StoreStatus; import com.ruoyi.ss.store.service.StoreService; import com.ruoyi.ss.store.service.StoreValidator; +import com.ruoyi.ss.storeStaff.domain.enums.StoreStaffPermissions; +import com.ruoyi.ss.storeStaff.service.StoreStaffValidator; import com.ruoyi.ss.user.service.UserValidator; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -40,6 +42,9 @@ public class StoreValidatorImpl extends BaseValidator implements StoreValidator @Autowired private UserValidator userValidator; + @Autowired + private StoreStaffValidator storeStaffValidator; + /** * 逻辑删除前校验 * @param ids 店铺id列表 @@ -76,10 +81,6 @@ public class StoreValidatorImpl extends BaseValidator implements StoreValidator return result; } - if (!this.isStoreBelongUser(storeIds, SecurityUtils.getUserId())) { - return error("当前店铺不属于当前用户"); - } - return success(); } @@ -169,12 +170,6 @@ public class StoreValidatorImpl extends BaseValidator implements StoreValidator return error("待修改的店铺不存在"); } - // 前台用户更新校验 - // 判断是否是当前用户的店铺 - if (!this.isStoreBelongUser(old, SecurityUtils.getUserId())) { - return error("当前店铺不属于当前用户"); - } - // 判断店铺是否正在变更中 if (this.isApproving(old)) { return error("当前店铺正在变更中,请稍后重试"); @@ -199,7 +194,7 @@ public class StoreValidatorImpl extends BaseValidator implements StoreValidator return error("店铺不存在,请刷新后重试"); } - if (!this.isStoreBelongUser(storeIds, SecurityUtils.getUserId())) { + if (!this.isMch(storeIds, SecurityUtils.getUserId())) { return error("存在店铺不属于当前用户"); } @@ -224,10 +219,10 @@ public class StoreValidatorImpl extends BaseValidator implements StoreValidator * 判断店铺是否属于用户 */ @Override - public boolean isStoreBelongUser(List storeIds, Long userId) { + public boolean isMch(List storeIds, Long userId) { List stores = storeService.selectStoreByIds(storeIds); for (StoreVo item : stores) { - if (!this.isStoreBelongUser(item, userId)) { + if (!this.isMch(item, userId)) { return false; } } @@ -239,7 +234,7 @@ public class StoreValidatorImpl extends BaseValidator implements StoreValidator * */ @Override - public boolean isStoreBelongUser(Store store, Long userId) { + public boolean isMch(Store store, Long userId) { return store != null && store.getUserId() != null && store.getUserId().equals(userId); } @@ -271,9 +266,6 @@ public class StoreValidatorImpl extends BaseValidator implements StoreValidator if (userId == null || storeId == null) { return error("参数错误:userId 与 storeId 不允许为空"); } - if (!this.isStoreBelongUser(Collections.singletonList(storeId), userId)) { - return error("当前店铺不属于当前用户"); - } return success(); } @@ -339,6 +331,36 @@ public class StoreValidatorImpl extends BaseValidator implements StoreValidator } + @Override + public boolean canOperaStore(StoreVo store, Long userId) { + if (store == null || userId == null) { + return false; + } + return this.isMch(store, userId) + || storeStaffValidator.hasStorePermission(store.getStoreId(), userId, StoreStaffPermissions.STORE_OPERA); + } + + @Override + public boolean canOperaStore(Long storeId, Long userId) { + StoreVo store = storeService.selectSmStoreById(storeId); + return this.canOperaStore(store, userId); + } + + @Override + public boolean canViewStore(Long storeId, Long userId) { + StoreVo store = storeService.selectSmStoreById(storeId); + return this.canViewStore(store, userId); + } + + @Override + public boolean canViewStore(StoreVo store, Long userId) { + if (store == null || userId == null) { + return false; + } + return isMch(store, userId) + || storeStaffValidator.hasStorePermission(store.getStoreId(), userId, StoreStaffPermissions.STORE_VIEW); + } + /** * 校验时间是符合规则 diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/domain/StoreStaff.java b/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/domain/StoreStaff.java index 7989eaf3..2774e623 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/domain/StoreStaff.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/domain/StoreStaff.java @@ -35,10 +35,9 @@ public class StoreStaff extends BaseEntity @Excel(name = "用户ID") @ApiModelProperty("用户ID") - @NotNull(message = "用户不能为空", groups = {ValidGroup.Create.class}) private Long userId; - @Excel(name = "角色", readConverterExp = "1=店铺所有人,2=员工") + @Excel(name = "角色", readConverterExp = "1=合伙人") @ApiModelProperty("角色") @NotNull(message = "角色不能为空", groups = {ValidGroup.Create.class}) private String role; diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/domain/StoreStaffVO.java b/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/domain/StoreStaffVO.java index 370a0fc7..2781cf42 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/domain/StoreStaffVO.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/domain/StoreStaffVO.java @@ -5,6 +5,8 @@ import com.ruoyi.common.enums.DesensitizedType; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.math.BigDecimal; + /** * @author wjh * 2024/11/13 @@ -22,4 +24,12 @@ public class StoreStaffVO extends StoreStaff{ @ApiModelProperty("商户ID") private Long mchId; + // TODO 月收入 + @ApiModelProperty("月收入") + private BigDecimal monthIncome; + + // TODO + @ApiModelProperty("设备数") + private Long deviceCount; + } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/mapper/StoreStaffMapper.java b/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/mapper/StoreStaffMapper.java index b71dbb86..f003b782 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/mapper/StoreStaffMapper.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/mapper/StoreStaffMapper.java @@ -72,4 +72,7 @@ public interface StoreStaffMapper * 查询数量 */ int selectCount(@Param("query") StoreStaffQuery query); + + int bindUser(@Param("employId") Long employId,@Param("userId") Long userId); + } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/mapper/StoreStaffMapper.xml b/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/mapper/StoreStaffMapper.xml index b66b8bd1..4d98ce4c 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/mapper/StoreStaffMapper.xml +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/mapper/StoreStaffMapper.xml @@ -119,6 +119,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where employ_id = #{data.employId} + + update ss_store_staff + set user_id = #{userId} + where employ_id = #{employId} and user_id is null + + store_id = #{data.storeId}, user_id = #{data.userId}, diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/service/StoreStaffConverter.java b/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/service/StoreStaffConverter.java new file mode 100644 index 00000000..204b05e0 --- /dev/null +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/service/StoreStaffConverter.java @@ -0,0 +1,15 @@ +package com.ruoyi.ss.storeStaff.service; + +import com.ruoyi.ss.storeStaff.domain.StoreStaff; + +/** + * @author wjh + * 2024/11/27 + */ +public interface StoreStaffConverter { + + /** + * app转换为PO + */ + StoreStaff toPoByApp(StoreStaff data); +} diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/service/StoreStaffService.java b/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/service/StoreStaffService.java index 7fb8c484..1582d916 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/service/StoreStaffService.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/service/StoreStaffService.java @@ -77,4 +77,8 @@ public interface StoreStaffService */ StoreStaffVO selectOne(StoreStaffQuery query); + /** + * 绑定用户为店铺员工 + */ + int bindUser(Long employId, Long userId); } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/service/StoreStaffValidator.java b/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/service/StoreStaffValidator.java index e24f88fe..d2184455 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/service/StoreStaffValidator.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/service/StoreStaffValidator.java @@ -2,6 +2,7 @@ package com.ruoyi.ss.storeStaff.service; import com.ruoyi.ss.storeStaff.domain.StoreStaff; import com.ruoyi.ss.storeStaff.domain.StoreStaffVO; +import com.ruoyi.ss.storeStaff.domain.enums.StoreStaffPermissions; import java.util.List; @@ -28,8 +29,18 @@ public interface StoreStaffValidator { /** * 判断用户能否操作店铺 - * @param storeId 店铺ID - * @param userId 员工ID + * + * @param storeId 店铺ID + * @param userId 员工ID + * @param permission */ - boolean canOperaStore(Long storeId, Long userId); + boolean hasStorePermission(Long storeId, Long userId, StoreStaffPermissions permission); + + /** + * 校验是否重复成为店铺员工 + * @param storeId 店铺ID + * @param userId 用户ID + * @param employId 员工ID + */ + void checkRepeatUser(Long storeId, Long userId, Long employId); } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/service/impl/StoreStaffConverterImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/service/impl/StoreStaffConverterImpl.java new file mode 100644 index 00000000..e362db2d --- /dev/null +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/service/impl/StoreStaffConverterImpl.java @@ -0,0 +1,34 @@ +package com.ruoyi.ss.storeStaff.service.impl; + +import com.ruoyi.ss.storeStaff.domain.StoreStaff; +import com.ruoyi.ss.storeStaff.service.StoreStaffConverter; +import com.ruoyi.ss.user.service.ISmUserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * @author wjh + * 2024/11/27 + */ +@Service +public class StoreStaffConverterImpl implements StoreStaffConverter { + + @Autowired + private ISmUserService userService; + + @Override + public StoreStaff toPoByApp(StoreStaff data) { + if (data == null) { + return null; + } + StoreStaff po = new StoreStaff(); + po.setEmployId(data.getEmployId()); + po.setStoreId(data.getStoreId()); + po.setRole(data.getRole()); + po.setPoint(data.getPoint()); + po.setEnabled(data.getEnabled()); + po.setPermissions(data.getPermissions()); + po.setRemark(data.getRemark()); + return po; + } +} diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/service/impl/StoreStaffServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/service/impl/StoreStaffServiceImpl.java index 3629c1d7..3a404975 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/service/impl/StoreStaffServiceImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/service/impl/StoreStaffServiceImpl.java @@ -6,6 +6,8 @@ import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.ServiceUtil; import com.ruoyi.common.utils.collection.CollectionUtils; import com.ruoyi.ss.storeStaff.service.StoreStaffValidator; +import com.ruoyi.ss.user.domain.SmUserVO; +import com.ruoyi.ss.user.service.ISmUserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.ss.storeStaff.mapper.StoreStaffMapper; @@ -33,6 +35,9 @@ public class StoreStaffServiceImpl implements StoreStaffService @Autowired private StoreStaffValidator storeStaffValidator; + @Autowired + private ISmUserService userService; + /** * 查询店铺员工 * @@ -143,4 +148,30 @@ public class StoreStaffServiceImpl implements StoreStaffService } return list.get(0); } + + @Override + public int bindUser(Long employId, Long userId) { + if (employId == null || userId == null) { + return 0; + } + StoreStaffVO old = selectStoreStaffByEmployId(employId); + ServiceUtil.assertion(old == null, "员工信息不存在"); + ServiceUtil.assertion(old.getUserId() != null, "当前员工信息已被其他用户绑定,无法重复绑定"); + + SmUserVO user = userService.selectSmUserByUserId(userId); + ServiceUtil.assertion(user == null, "用户不存在"); + + Integer result = transactionTemplate.execute(status -> { + int bind = storeStaffMapper.bindUser(employId, userId); + ServiceUtil.assertion(bind != 1, "绑定失败,当前员工信息已发生变化"); + + // 后校验 + StoreStaffVO vo = selectStoreStaffByEmployId(employId); + storeStaffValidator.checkRepeatUser(vo.getStoreId(), vo.getUserId(), vo.getEmployId()); + + return bind; + }); + + return result == null ? 0 : result; + } } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/service/impl/StoreStaffValidatorImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/service/impl/StoreStaffValidatorImpl.java index c8ae5b0e..3899107a 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/service/impl/StoreStaffValidatorImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/storeStaff/service/impl/StoreStaffValidatorImpl.java @@ -95,19 +95,20 @@ public class StoreStaffValidatorImpl implements StoreStaffValidator { } @Override - public boolean canOperaStore(Long storeId, Long userId) { - if (storeId == null || userId == null) { + public boolean hasStorePermission(Long storeId, Long userId, StoreStaffPermissions permission) { + if (storeId == null || userId == null || permission == null) { return false; } StoreStaffQuery query = new StoreStaffQuery(); query.setStoreId(storeId); query.setUserId(userId); query.setEnabled(true); - query.setPermission(StoreStaffPermissions.STORE_OPERA.getCode()); + query.setPermission(permission.getCode()); return storeStaffService.selectCount(query) > 0; } - private void checkRepeatUser(Long storeId, Long userId, Long employId) { + @Override + public void checkRepeatUser(Long storeId, Long userId, Long employId) { if (storeId == null || userId == null) { return; } @@ -115,6 +116,6 @@ public class StoreStaffValidatorImpl implements StoreStaffValidator { query.setStoreId(storeId); query.setUserId(userId); query.setExcludeEmployId(employId); - ServiceUtil.assertion(storeStaffService.selectCount(query) > 0, "当前用户已成为店铺员工,请勿重复操作"); ; + ServiceUtil.assertion(storeStaffService.selectCount(query) > 0, "当前用户已成为店铺员工,请勿重复操作"); } } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/domain/TransactionBillQuery.java b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/domain/TransactionBillQuery.java index 9c897bfe..0653b7b5 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/domain/TransactionBillQuery.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/domain/TransactionBillQuery.java @@ -131,4 +131,14 @@ public class TransactionBillQuery extends TransactionBill { @ApiModelProperty("收入人ID") private Long incomeUserId; + + @ApiModelProperty("开启员工条件筛选") + private Boolean inStaff; + + @ApiModelProperty("员工用户ID") + private Long staffUserId; + + @ApiModelProperty("员工权限") + private String staffPermission; + } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/domain/vo/TransactionBillOperatorVO.java b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/domain/vo/TransactionBillOperatorVO.java new file mode 100644 index 00000000..6300ba74 --- /dev/null +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/domain/vo/TransactionBillOperatorVO.java @@ -0,0 +1,24 @@ +package com.ruoyi.ss.transactionBill.domain.vo; + +import com.fasterxml.jackson.annotation.JsonView; +import com.ruoyi.common.core.domain.JsonViewProfile; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author wjh + * 2024/11/27 + */ +@Data +public class TransactionBillOperatorVO { + + @ApiModelProperty("是否允许退款") + @JsonView(JsonViewProfile.App.class) + private Boolean refund; + + public static TransactionBillOperatorVO defaultInstance() { + TransactionBillOperatorVO vo = new TransactionBillOperatorVO(); + vo.setRefund(false); + return vo; + } +} diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/domain/vo/TransactionBillVO.java b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/domain/vo/TransactionBillVO.java index 17785c62..60e08953 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/domain/vo/TransactionBillVO.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/domain/vo/TransactionBillVO.java @@ -66,6 +66,10 @@ public class TransactionBillVO extends TransactionBill implements IotDevice { @ApiModelProperty("总用电量(度)/时长(秒)") private BigDecimal totalUse; + @ApiModelProperty("操作权限") + @JsonView(JsonViewProfile.App.class) + private TransactionBillOperatorVO operator; + @Override public String iotMac1() { return getDeviceMac(); diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/mapper/TransactionBillMapper.xml b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/mapper/TransactionBillMapper.xml index fe53a604..59509da8 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/mapper/TransactionBillMapper.xml +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/mapper/TransactionBillMapper.xml @@ -286,6 +286,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and date(stb.pay_time) >= date(#{query.payDateRange[0]}) and date(stb.pay_time) <= date(#{query.payDateRange[1]}) + + and stb.store_id + not + in () + + + + + + select distinct sss.store_id + from ss_store_staff sss + + and sss.user_id = #{query.staffUserId} + + and find_in_set(#{query.staffPermission}, sss.permissions) + +