员工提交

This commit is contained in:
磷叶 2024-11-27 18:06:07 +08:00
parent 41daefbda2
commit 6d94892d35
56 changed files with 799 additions and 201 deletions

View File

@ -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();

View File

@ -29,4 +29,7 @@ public class TodoListVO {
@ApiModelProperty("欠费设备数量")
private Integer arrearsDeviceCount;
@ApiModelProperty("风控待审核数量")
private Integer riskVerifyCount;
}

View File

@ -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;
}

View File

@ -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

View File

@ -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;
}

View File

@ -33,7 +33,7 @@ public interface DeviceMapper
* @param smDevice 设备
* @return 设备集合
*/
public List<DeviceVO> selectSmDeviceList(DeviceQuery smDevice);
public List<DeviceVO> 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<DeviceVO> selectSimpleList(DeviceQuery dto);
List<DeviceVO> selectSimpleList(@Param("query") DeviceQuery dto);
/**
* 设备绑定店铺
@ -123,7 +123,7 @@ public interface DeviceMapper
* 条件查询数量
* @param query 查询条件
*/
List<DeviceCountVO> selectCommonCount(DeviceQuery query);
List<DeviceCountVO> selectCommonCount(@Param("query") DeviceQuery query);
/**
* 根据设备编号查询
@ -168,12 +168,12 @@ public interface DeviceMapper
/**
* 获取所有MAC
*/
List<DeviceMacSnVO> selectMacSnList(DeviceQuery query);
List<DeviceMacSnVO> 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);
/**
* 绑定代理商

View File

@ -91,106 +91,125 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</sql>
<sql id="searchCondition">
<if test="storeName != null and storeName != ''"> and ss.name like concat('%', #{storeName}, '%')</if>
<if test="serviceType != null and serviceType != ''"> and sd.service_type = #{serviceType}</if>
<if test="deviceName != null and deviceName != ''"> and sd.device_name like concat('%', #{deviceName}, '%')</if>
<if test="model != null and model != ''"> and sm.model_name like concat('%', #{model}, '%')</if>
<if test="mac != null and mac != ''"> and sd.mac = #{mac}</if>
<if test="mac2 != null and mac2 != ''"> and sd.mac2 = #{mac2}</if>
<if test="anyMac != null and anyMac != ''">
<if test="query.storeName != null and query.storeName != ''"> and ss.name like concat('%', #{query.storeName}, '%')</if>
<if test="query.serviceType != null and query.serviceType != ''"> and sd.service_type = #{query.serviceType}</if>
<if test="query.deviceName != null and query.deviceName != ''"> and sd.device_name like concat('%', #{query.deviceName}, '%')</if>
<if test="query.model != null and query.model != ''"> and sm.model_name like concat('%', #{query.model}, '%')</if>
<if test="query.mac != null and query.mac != ''"> and sd.mac = #{query.mac}</if>
<if test="query.mac2 != null and query.mac2 != ''"> and sd.mac2 = #{query.mac2}</if>
<if test="query.anyMac != null and query.anyMac != ''">
and (
sd.mac = #{anyMac} or sd.mac2 = #{anyMac}
sd.mac = #{query.anyMac} or sd.mac2 = #{query.anyMac}
)
</if>
<if test="likeAnyMac != null and likeAnyMac != ''">
<if test="query.likeAnyMac != null and query.likeAnyMac != ''">
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}, '%')
)
</if>
<if test="onlineStatus != null and onlineStatus != ''"> and sd.online_status = #{onlineStatus}</if>
<if test="onlineStatus1 != null and onlineStatus1 != ''"> and sd.online_status1 = #{onlineStatus1}</if>
<if test="onlineStatus2 != null and onlineStatus2 != ''"> and sd.online_status2 = #{onlineStatus2}</if>
<if test="status != null and status != ''"> and sd.status = #{status}</if>
<if test="userName != null and userName != ''"> and if(su.is_real, su.real_name, su.user_name) like concat('%', #{userName}, '%')</if>
<if test="nickName != null and nickName != ''"> and sd.nick_name like concat('%', #{nickName}, '%')</if>
<if test="userId != null"> and sd.user_id = #{userId}</if>
<if test="storeId != null"> and sd.store_id = #{storeId}</if>
<if test="deviceId != null"> and sd.device_id = #{deviceId}</if>
<if test="startRentTime != null"> and sd.rent_time >= #{startRentTime}</if>
<if test="endRentTime != null"> and sd.device_id &lt;= #{endRentTime}</if>
<if test="deviceNo != null and deviceNo != ''"> and sd.device_no like concat('%', #{deviceNo}, '%')</if>
<if test="eqDeviceNo != null and eqDeviceNo != ''"> and sd.device_no = #{eqDeviceNo}</if>
<if test="lockUserId != null"> and sd.lock_user_id = #{lockUserId}</if>
<if test="agentId != null "> and agent_id = #{agentId}</if>
<if test="agentName != null and agentName != ''"> and if(sua.is_real, sua.real_name, sua.user_name) like concat('%', #{agentName}, '%')</if>
<if test="serviceMode != null and serviceMode != ''"> and sd.service_mode = #{serviceMode}</if>
<if test="version != null and version != ''"> and sd.version like concat('%', #{version}, '%')</if>
<if test="modelTag != null and modelTag != ''"> and find_in_set(#{modelTag}, sm.tags)</if>
<if test="excludeDeviceId != null"> and sd.device_id != #{excludeDeviceId}</if>
<if test="keyword != null and keyword != ''">
<if test="query.onlineStatus != null and query.onlineStatus != ''"> and sd.online_status = #{query.onlineStatus}</if>
<if test="query.onlineStatus1 != null and query.onlineStatus1 != ''"> and sd.online_status1 = #{query.onlineStatus1}</if>
<if test="query.onlineStatus2 != null and query.onlineStatus2 != ''"> and sd.online_status2 = #{query.onlineStatus2}</if>
<if test="query.status != null and query.status != ''"> and sd.status = #{query.status}</if>
<if test="query.userName != null and query.userName != ''"> and if(su.is_real, su.real_name, su.user_name) like concat('%', #{query.userName}, '%')</if>
<if test="query.nickName != null and query.nickName != ''"> and sd.nick_name like concat('%', #{query.nickName}, '%')</if>
<if test="query.userId != null"> and sd.user_id = #{query.userId}</if>
<if test="query.storeId != null"> and sd.store_id = #{query.storeId}</if>
<if test="query.deviceId != null"> and sd.device_id = #{query.deviceId}</if>
<if test="query.startRentTime != null"> and sd.rent_time >= #{query.startRentTime}</if>
<if test="query.endRentTime != null"> and sd.device_id &lt;= #{query.endRentTime}</if>
<if test="query.deviceNo != null and query.deviceNo != ''"> and sd.device_no like concat('%', #{query.deviceNo}, '%')</if>
<if test="query.eqDeviceNo != null and query.eqDeviceNo != ''"> and sd.device_no = #{query.eqDeviceNo}</if>
<if test="query.lockUserId != null"> and sd.lock_user_id = #{query.lockUserId}</if>
<if test="query.agentId != null "> and agent_id = #{query.agentId}</if>
<if test="query.agentName != null and query.agentName != ''"> and if(sua.is_real, sua.real_name, sua.user_name) like concat('%', #{query.agentName}, '%')</if>
<if test="query.serviceMode != null and query.serviceMode != ''"> and sd.service_mode = #{query.serviceMode}</if>
<if test="query.version != null and query.version != ''"> and sd.version like concat('%', #{query.version}, '%')</if>
<if test="query.modelTag != null and query.modelTag != ''"> and find_in_set(#{query.modelTag}, sm.tags)</if>
<if test="query.excludeDeviceId != null"> and sd.device_id != #{query.excludeDeviceId}</if>
<if test="query.inStaff != null">
and sd.store_id
<if test="!query.inStaff">not</if>
in (<include refid="selectStaffViewStoreIds"/>)
</if>
<if test="query.keyword != null and query.keyword != ''">
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}, '%')
)
</if>
<if test="isArrears != null">
<if test="isArrears">
<if test="query.isArrears != null">
<if test="query.isArrears">
and (sd.rent_time is null or sd.rent_time &lt;= now())
</if>
<if test="!isArrears">
<if test="!query.isArrears">
and (sd.rent_time is not null and sd.rent_time > now())
</if>
</if>
<if test="deviceIds != null and deviceIds.size() > 0">
<if test="query.deviceIds != null and query.deviceIds.size() > 0">
and sd.device_id in
<foreach collection="deviceIds" open="(" close=")" separator="," item="item">
<foreach collection="query.deviceIds" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
<if test="deviceNos != null and deviceNos.size() > 0">
<if test="query.deviceNos != null and query.deviceNos.size() > 0">
and sd.device_no in
<foreach collection="deviceNos" open="(" close=")" separator="," item="item">
<foreach collection="query.deviceNos" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
<if test="isBind != null">
<if test="isBind">
<if test="query.isBind != null">
<if test="query.isBind">
and sd.user_id is not null
</if>
<if test="!isBind">
<if test="!query.isBind">
and sd.user_id is null
</if>
</if>
<if test="storeIds != null and storeIds.size() > 0">
<if test="query.storeIds != null and query.storeIds.size() > 0">
and sd.store_id in
<foreach collection="storeIds" open="(" close=")" separator="," item="item">
<foreach collection="query.storeIds" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
<if test="userIds != null and userIds.size() > 0">
<if test="query.userIds != null and query.userIds.size() > 0">
and sd.user_id in
<foreach collection="userIds" open="(" close=")" separator="," item="item">
<foreach collection="query.userIds" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
<if test="modelIds != null and modelIds.size() > 0">
<if test="query.modelIds != null and query.modelIds.size() > 0">
and sd.model_id in
<foreach collection="modelIds" open="(" close=")" separator="," item="item">
<foreach collection="query.modelIds" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
<if test="macList != null and macList.size() > 0">
<if test="query.macList != null and query.macList.size() > 0">
and sd.mac in
<foreach collection="macList" open="(" close=")" separator="," item="item">
<foreach collection="query.macList" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
<if test="deleted == null">and sd.deleted = false</if>
<if test="deleted != null">and sd.deleted = #{deleted}</if>
<if test="query.deleted == null">and sd.deleted = false</if>
<if test="query.deleted != null">and sd.deleted = #{query.deleted}</if>
</sql>
<!--查询员工可查看的店铺ID列表-->
<sql id="selectStaffViewStoreIds">
select distinct sss.store_id
from ss_store_staff sss
<where>
<if test="query.staffUserId != null">and sss.user_id = #{query.staffUserId}</if>
<if test="query.staffPermission != null and query.staffPermission != ''">
and find_in_set(#{query.staffPermission}, sss.permissions)
</if>
</where>
</sql>
<select id="selectSmDeviceList" parameterType="DeviceQuery" resultMap="SmDeviceResult">
<include refid="selectVo"/>
<where>
@ -249,12 +268,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectCommonCount" resultMap="DeviceCount">
<trim prefix="select" suffixOverrides=",">
<if test="groupBy != null">
<if test="groupByTable == null">
sd.${groupBy},
<if test="query.groupBy != null">
<if test="query.groupByTable == null">
sd.${query.groupBy},
</if>
<if test="groupByTable != null">
${groupByTable}.${groupBy},
<if test="query.groupByTable != null">
${query.groupByTable}.${query.groupBy},
</if>
</if>
count(sd.device_id) as `count`
@ -265,12 +284,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<where>
<include refid="searchCondition"/>
</where>
<if test="groupBy != null">
<if test="groupByTable == null">
group by sd.${groupBy}
<if test="query.groupBy != null">
<if test="query.groupByTable == null">
group by sd.${query.groupBy}
</if>
<if test="groupByTable != null">
group by ${groupByTable}.${groupBy}
<if test="query.groupByTable != null">
group by ${query.groupByTable}.${query.groupBy}
</if>
</if>
</select>

View File

@ -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);
}

View File

@ -380,4 +380,8 @@ public interface DeviceService
*/
int setTime(DeviceVO device, long seconds, int tryCount);
/**
* 查询员工设备列表
*/
List<DeviceVO> selectStaffDeviceList(DeviceQuery query);
}

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -806,6 +806,12 @@ public class DeviceServiceImpl implements DeviceService
return this.setTime(device, LocalDateTime.now().plusSeconds(seconds), true, tryCount);
}
@Override
public List<DeviceVO> 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 -> {
// 尝试关闭该设备未结束的所有订单

View File

@ -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);
}
}

View File

@ -31,7 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="query.eqIdCard != null and query.eqIdCard != ''"> and srn.id_card = #{query.eqIdCard}</if>
<if test="query.mobile != null and query.mobile != ''"> and srn.mobile like concat('%', #{query.mobile}, '%')</if>
<if test="query.userName != null and query.userName != ''"> and su.user_name like concat('%', #{query.userName}, '%')</if>
<if test="query.type != null and query.type != ''"> and type = #{query.type}</if>
<if test="query.type != null and query.type != ''"> and srn.type = #{query.type}</if>
</sql>
<select id="selectRealNameList" parameterType="RealNameQuery" resultMap="RealNameResult">

View File

@ -6,6 +6,7 @@ import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.core.domain.ValidGroup;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
@ -14,6 +15,8 @@ import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotNull;
/**
* 风控对象 ss_risk
*
@ -29,10 +32,12 @@ public class Risk extends BaseEntity
@Excel(name = "用户ID")
@ApiModelProperty("用户ID")
@NotNull(message = "用户不允许为空", groups = {ValidGroup.Create.class})
private Long userId;
@Excel(name = "类型")
@ApiModelProperty("类型")
@NotNull(message = "类型不允许为空", groups = {ValidGroup.Create.class})
private List<String> type;
@Excel(name = "风控原因")

View File

@ -66,4 +66,9 @@ public interface RiskInfoMapper
* 根据查询条件更新数据
*/
int updateByQuery(@Param("data") RiskInfo data, @Param("query") RiskInfoQuery query);
/**
* 查询数量
*/
int selectCount(@Param("query") RiskInfoQuery query);
}

View File

@ -74,6 +74,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where sri.info_id = #{infoId}
</select>
<select id="selectCount" resultType="java.lang.Integer">
select count(sri.info_id)
from ss_risk_info sri
<where>
<include refid="searchCondition"/>
</where>
</select>
<insert id="insertRiskInfo" parameterType="RiskInfo" useGeneratedKeys="true" keyProperty="infoId">
insert into ss_risk_info
<trim prefix="(" suffix=")" suffixOverrides=",">

View File

@ -81,4 +81,9 @@ public interface RiskInfoService
* 审核
*/
int verify(RiskInfoVerifyDTO dto, LoginUser verifier);
/**
* 查询数量
*/
int selectCount(RiskInfoQuery query);
}

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -56,4 +56,9 @@ public interface StoreAssembler {
* @param list
*/
void assembleAvailableDeviceCount(List<StoreVo> list);
/**
* 拼接操作
*/
void assembleOperator(List<StoreVo> list, Long userId);
}

View File

@ -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<Long> storeId, Long userId);
boolean isMch(List<Long> 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);
}

View File

@ -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<StoreVo> 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);
}
}
}

View File

@ -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<Long> storeIds, Long userId) {
public boolean isMch(List<Long> storeIds, Long userId) {
List<StoreVo> 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);
}
/**
* 校验时间是符合规则

View File

@ -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;

View File

@ -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;
}

View File

@ -72,4 +72,7 @@ public interface StoreStaffMapper
* 查询数量
*/
int selectCount(@Param("query") StoreStaffQuery query);
int bindUser(@Param("employId") Long employId,@Param("userId") Long userId);
}

View File

@ -119,6 +119,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where employ_id = #{data.employId}
</update>
<update id="bindUser">
update ss_store_staff
set user_id = #{userId}
where employ_id = #{employId} and user_id is null
</update>
<sql id="updateColumns">
<if test="data.storeId != null">store_id = #{data.storeId},</if>
<if test="data.userId != null">user_id = #{data.userId},</if>

View File

@ -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);
}

View File

@ -77,4 +77,8 @@ public interface StoreStaffService
*/
StoreStaffVO selectOne(StoreStaffQuery query);
/**
* 绑定用户为店铺员工
*/
int bindUser(Long employId, Long userId);
}

View File

@ -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);
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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, "当前用户已成为店铺员工,请勿重复操作");
}
}

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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();

View File

@ -286,6 +286,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="query.payDateRange != null and query.payDateRange.size() > 1">
and date(stb.pay_time) >= date(#{query.payDateRange[0]}) and date(stb.pay_time) &lt;= date(#{query.payDateRange[1]})
</if>
<if test="query.inStaff != null">
and stb.store_id
<if test="!query.inStaff">not</if>
in (<include refid="selectStaffViewStoreIds"/>)
</if>
</sql>
<!--查询员工可查看的店铺ID列表-->
<sql id="selectStaffViewStoreIds">
select distinct sss.store_id
from ss_store_staff sss
<where>
<if test="query.staffUserId != null">and sss.user_id = #{query.staffUserId}</if>
<if test="query.staffPermission != null and query.staffPermission != ''">
and find_in_set(#{query.staffPermission}, sss.permissions)
</if>
</where>
</sql>
<select id="selectSmTransactionBillList" parameterType="TransactionBillQuery" resultMap="SmTransactionBillResult">

View File

@ -44,4 +44,8 @@ public interface TransactionAssembler {
*/
void handleMchUserMobile(List<TransactionBillVO> list);
/**
* 拼接操作权限
*/
void assembleOperator(List<TransactionBillVO> list, Long userId);
}

View File

@ -332,4 +332,9 @@ public interface TransactionBillService
int receiveMchShowMobileAmount(TransactionBillVO bill);
<T> List<JSONObject> selectCountGroupBy(TransactionBillQuery query, String groupBy);
/**
* 查询员工可见列表
*/
List<TransactionBillVO> selectStaffDeviceList(TransactionBillQuery query);
}

View File

@ -66,4 +66,9 @@ public interface TransactionBillValidator {
* @param user 用户
*/
void checkRefundRisk(SmUserVO user);
/**
* 是否允许操作订单
*/
boolean canOperaOrder(TransactionBillVO bill, Long userId);
}

View File

@ -11,12 +11,12 @@ import com.ruoyi.ss.channel.domain.Channel;
import com.ruoyi.ss.channel.domain.ChannelQuery;
import com.ruoyi.ss.channel.domain.ChannelVO;
import com.ruoyi.ss.channel.service.ChannelService;
import com.ruoyi.ss.channelWithdraw.service.ChannelWithdrawService;
import com.ruoyi.ss.suit.domain.enums.SuitFeeMode;
import com.ruoyi.ss.suit.domain.enums.SuitFeeType;
import com.ruoyi.ss.transactionBill.domain.enums.RechargeBillShowMobileStatus;
import com.ruoyi.ss.transactionBill.domain.vo.TransactionBillOperatorVO;
import com.ruoyi.ss.transactionBill.domain.vo.TransactionBillVO;
import com.ruoyi.ss.transactionBill.service.TransactionAssembler;
import com.ruoyi.ss.transactionBill.service.TransactionBillValidator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -42,6 +42,9 @@ public class TransactionAssemblerImpl implements TransactionAssembler {
@Autowired
private BonusService bonusService;
@Autowired
private TransactionBillValidator transactionBillValidator;
/**
* 拼接渠道名称
*
@ -164,4 +167,19 @@ public class TransactionAssemblerImpl implements TransactionAssembler {
}
}
@Override
public void assembleOperator(List<TransactionBillVO> list, Long userId) {
if (CollectionUtils.isEmptyElement(list)) {
return;
}
for (TransactionBillVO bill : list) {
TransactionBillOperatorVO vo = TransactionBillOperatorVO.defaultInstance();
if (transactionBillValidator.canOperaOrder(bill, userId)) {
vo.setRefund(true);
}
bill.setOperator(vo);
}
}
}

View File

@ -426,6 +426,12 @@ public class TransactionBillServiceImpl implements TransactionBillService, After
return result == null ? 0 :result;
}
@Override
public List<TransactionBillVO> selectStaffDeviceList(TransactionBillQuery query) {
query.setInStaff(true);
return this.selectSmTransactionBillList(query);
}
@Override
public List<JSONObject> selectCountGroupBy(TransactionBillQuery query, String groupBy) {
return transactionBillMapper.selectCountGroupBy(query, groupBy);

View File

@ -18,6 +18,8 @@ import com.ruoyi.ss.risk.domain.enums.RiskType;
import com.ruoyi.ss.risk.service.RiskService;
import com.ruoyi.ss.store.domain.StoreVo;
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.domain.SuitVO;
import com.ruoyi.ss.suit.domain.enums.SuitFeeMode;
import com.ruoyi.ss.suit.domain.enums.SuitFeeType;
@ -65,6 +67,9 @@ public class TransactionBillValidatorImpl extends BaseValidator implements Trans
@Autowired
private RiskService riskService;
@Autowired
private StoreStaffValidator storeStaffValidator;
@Override
public ValidateResult preAddOrder(RechargeBO bo) {
if (bo == null) {
@ -356,4 +361,13 @@ public class TransactionBillValidatorImpl extends BaseValidator implements Trans
}
}
}
@Override
public boolean canOperaOrder(TransactionBillVO bill, Long userId) {
if (bill == null || userId == null) {
return false;
}
return this.isMch(bill, userId)
|| storeStaffValidator.hasStorePermission(bill.getStoreId(), userId, StoreStaffPermissions.ORDER_OPERA);
}
}

View File

@ -11,7 +11,7 @@ import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.enums.OperatorType;
import com.ruoyi.common.utils.ServiceUtil;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.iot.service.IotService;
import com.ruoyi.common.utils.collection.CollectionUtils;
import com.ruoyi.ss.device.domain.DeviceView;
import com.ruoyi.ss.device.domain.Device;
import com.ruoyi.ss.device.domain.DeviceBO;
@ -27,6 +27,7 @@ import com.ruoyi.ss.device.service.DeviceService;
import com.ruoyi.ss.meterReadingRecord.domain.SmMeterReadingRecordQuery;
import com.ruoyi.ss.meterReadingRecord.service.ISmMeterReadingRecordService;
import com.ruoyi.ss.suit.domain.enums.SuitTimeUnit;
import com.ruoyi.ss.suit.service.SuitValidator;
import com.ruoyi.web.core.annotation.DeviceAdminRequired;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -38,7 +39,6 @@ import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ScheduledExecutorService;
/**
* 设备Controller
@ -62,21 +62,29 @@ public class AppDeviceController extends BaseController {
@Autowired
private DeviceValidator deviceValidator;
@Autowired
private IotService iotService;
@Autowired
private ScheduledExecutorService scheduledExecutorService;
@Autowired
private DeviceConverter deviceConverter;
@Autowired
private SuitValidator suitValidator;
@Log(title = "商户修改设备信息", businessType = BusinessType.UPDATE, operatorType = OperatorType.MOBILE)
@ApiOperation("商户修改设备信息")
@PutMapping
public AjaxResult edit(@RequestBody @Validated({ValidGroup.FrontUpdate.class}) DeviceBO data) {
data = data.filterUpdateByApp();
Long userId = getUserId();
// 转换
data = deviceConverter.toBOByAppUpdate(data, userId);
// 判断是否有权限更改
if (!deviceValidator.canOpera(data.getDeviceId(), userId) ) {
return error("您无权修改该设备");
}
// 判断套餐
if (CollectionUtils.isNotEmptyElement(data.getSuitIds()) && !suitValidator.isBelong(data.getSuitIds(), userId)) {
return error("有套餐不属于您,无权修改");
}
ServiceUtil.assertion(deviceValidator.preUpdateByApp(data));
return toAjax(smDeviceService.updateSmDevice(data));
}
@ -120,6 +128,10 @@ public class AppDeviceController extends BaseController {
@ApiOperation("设备通断电")
@PutMapping("/{deviceId}/changePower")
public AjaxResult close(@PathVariable @ApiParam("设备id") Long deviceId, String status) {
// 判断是否有权限更改
if (!deviceValidator.canOpera(deviceId, getUserId()) ) {
return error("您无权操作此设备");
}
DeviceVO device = smDeviceService.selectById(deviceId);
ServiceUtil.assertion(device == null, "设备不存在");
deviceAssembler.assembleAllowSwitch(device, getUserId());
@ -155,6 +167,9 @@ public class AppDeviceController extends BaseController {
@ApiOperation("设备归零")
@PutMapping("{deviceId}/reset")
public AjaxResult reset(@PathVariable @ApiParam("设备id") Long deviceId) {
if (!deviceValidator.canOpera(deviceId, getUserId()) ) {
return error("您无权操作此设备");
}
return toAjax(smDeviceService.resetWithBill(deviceId));
}
@ -173,6 +188,9 @@ public class AppDeviceController extends BaseController {
@ApiParam("单位") @RequestParam(required = false, defaultValue = "3") String timeUnit,
@ApiParam("是否操作物联网设备") @RequestParam(required = false, defaultValue = "true") Boolean withIot
) {
if (!deviceValidator.canOpera(deviceId, getUserId()) ) {
return error("您无权操作此设备");
}
DeviceVO device = smDeviceService.selectById(deviceId);
ServiceUtil.assertion(device == null, "设备不存在");
deviceAssembler.assembleAllowSwitch(device, getUserId());

View File

@ -69,8 +69,8 @@ public class AppStoreController extends BaseController {
@PutMapping
public AjaxResult edit(@RequestBody @Validated(ValidGroup.FrontUpdate.class) StoreBO data) {
StoreVo store = storeService.selectSmStoreById(data.getStoreId());
if (!storeValidator.isStoreBelongUser(store, getUserId())) {
return error("这不是您的店铺,无法修改");
if (!storeValidator.canOperaStore(store, getUserId())) {
return error("您无权修改该店铺");
}
data = data.filterUpdateByApp();
ServiceUtil.assertion(storeValidator.preUpdateByApp(data));
@ -81,7 +81,7 @@ public class AppStoreController extends BaseController {
@PutMapping("/config")
public AjaxResult configStore(@RequestBody @Validated(ValidGroup.FrontUpdate.class) StoreBO data) {
StoreVo store = storeService.selectSmStoreById(data.getStoreId());
if (!storeValidator.isStoreBelongUser(store, getUserId())) {
if (!storeValidator.canOperaStore(store, getUserId())) {
return error("这不是您的店铺,无法修改");
}
data = data.filterConfigByApp();
@ -97,6 +97,10 @@ public class AppStoreController extends BaseController {
@ApiOperation("删除店铺信息")
@DeleteMapping("/{storeId}")
public AjaxResult delete(@PathVariable Long storeId) {
if (storeValidator.canOperaStore(storeId, getUserId())) {
return error("您无权删除该店铺");
}
List<Long> storeIds = Collections.singletonList(storeId);
ServiceUtil.assertion(storeValidator.preLogicDelByApp(storeIds));
return AjaxResult.success(storeService.logicDel(storeIds));
@ -158,11 +162,12 @@ public class AppStoreController extends BaseController {
@ApiOperation("商户获取店铺信息")
@GetMapping("/mch/{storeId}")
public AjaxResult getMchDetail(@PathVariable @ApiParam("店铺ID") Long storeId) {
ServiceUtil.assertion(!storeValidator.isStoreBelongUser(Collections.singletonList(storeId), getUserId()), "这不是您的店铺,无法查看");
ServiceUtil.assertion(!storeValidator.canViewStore(storeId, getUserId()), "您无权查看该店铺");
StoreVo store = storeService.selectSmStoreById(storeId);
List<StoreVo> storeList = Collections.singletonList(store);
storeAssembler.assembleDeviceCount(storeList); // 总设备数量
storeAssembler.assembleRevenue(storeList); // 经营信息
storeAssembler.assembleOperator(storeList, getUserId());
return success(store);
}
@ -171,6 +176,9 @@ public class AppStoreController extends BaseController {
@PutMapping("/{storeId}/setDefault")
public AjaxResult setDefaultStore(@PathVariable Long storeId) {
Long userId = getUserId();
if (!storeValidator.canOperaStore(storeId, userId)) {
return error("您无权操作该店铺");
}
ServiceUtil.assertion(storeValidator.preSetDefaultByApp(userId, storeId));
return success(storeService.setDefault(userId, storeId));
}

View File

@ -0,0 +1,30 @@
package com.ruoyi.web.controller.app;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.ss.storeStaff.service.StoreStaffService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* @author wjh
* 2024/11/27
*/
@RestController
@RequestMapping("/app/storeStaff")
public class AppStoreStaffController extends BaseController {
@Autowired
private StoreStaffService storeStaffService;
@ApiOperation("绑定当前用户为店铺员工")
@PutMapping("/bindUser")
public AjaxResult bindUser(@RequestParam Long employId) {
return toAjax(storeStaffService.bindUser(employId, getUserId()));
}
}

View File

@ -128,6 +128,7 @@ public class AppTransactionBillController extends BaseController
List<TransactionBillVO> list = transactionBillService.selectSmTransactionBillList(query);
transactionAssembler.assembleChannelName(list);
transactionAssembler.handleMchUserMobile(list);
transactionAssembler.assembleOperator(list, getUserId());
return getDataTable(list);
}
@ -140,6 +141,7 @@ public class AppTransactionBillController extends BaseController
List<TransactionBillVO> list = Collections.singletonList(bill);
transactionAssembler.assembleChannelName(Collections.singletonList(bill));
transactionAssembler.handleMchUserMobile(list);
transactionAssembler.assembleOperator(list, getUserId());
return AjaxResult.success(bill);
}
@ -203,7 +205,7 @@ public class AppTransactionBillController extends BaseController
public AjaxResult cancelRecharge(@PathVariable @ApiParam("订单编号") String billNo) {
TransactionBillVO bill = transactionBillService.selectSmTransactionBillByBillNo(billNo);
if (!transactionBillValidator.isMch(bill, getUserId())) {
return error("这不是您的订单,无法取消");
return error("您不是该订单的商户,无法取消");
}
return AjaxResult.success(transactionBillService.cancelRecharge(billNo, TransactionBillStatus.CANCELED));
}
@ -258,8 +260,8 @@ public class AppTransactionBillController extends BaseController
return error("订单不存在");
}
Long userId = getUserId();
if (!Objects.equals(bill.getMchId(), userId )) {
return error("您无权操作退款");
if (!transactionBillValidator.canOperaOrder(bill, userId)) {
return error("您无权操作该订单的退款");
}
// 判断是否限制退款

View File

@ -41,8 +41,8 @@ public class MchStoreApplyController extends BaseController {
@JsonView(JsonViewProfile.AppMch.class)
@GetMapping("/getLastByStore/{storeId}")
public AjaxResult getLastByStore(@PathVariable Long storeId) {
if (!storeValidator.isStoreBelongUser(Collections.singletonList(storeId), getUserId())) {
return error("这不是您的店铺");
if (!storeValidator.canViewStore(storeId, getUserId())) {
return error("您无权查看该店铺信息");
}
PageHelper.orderBy(" create_time desc ");
PageHelper.startPage(1, 1);

View File

@ -10,6 +10,7 @@ import com.ruoyi.ss.store.service.StoreValidator;
import com.ruoyi.ss.storeStaff.domain.StoreStaff;
import com.ruoyi.ss.storeStaff.domain.StoreStaffQuery;
import com.ruoyi.ss.storeStaff.domain.StoreStaffVO;
import com.ruoyi.ss.storeStaff.service.StoreStaffConverter;
import com.ruoyi.ss.storeStaff.service.StoreStaffService;
import com.ruoyi.ss.storeStaff.service.StoreStaffValidator;
import io.swagger.annotations.ApiOperation;
@ -36,6 +37,9 @@ public class MchStoreStaffController extends BaseController {
@Autowired
private StoreStaffValidator storeStaffValidator;
@Autowired
private StoreStaffConverter storeStaffConverter;
@ApiOperation("商户查询店铺员工列表")
@GetMapping("/list")
public TableDataInfo list(StoreStaffQuery query) {
@ -59,28 +63,29 @@ public class MchStoreStaffController extends BaseController {
@ApiOperation("商户新增店铺员工")
@Log(title = "店铺员工", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody @Validated(ValidGroup.Create.class) StoreStaff storeStaff) {
public AjaxResult add(@RequestBody @Validated(ValidGroup.FrontCreate.class) StoreStaff data) {
// 校验店铺是否为本人的
if (!storeValidator.isStoreBelongUser(storeStaff.getStoreId(), getUserId())) {
if (!storeValidator.isStoreBelongUser(data.getStoreId(), getUserId())) {
return error("您只能操作自己的店铺");
}
storeStaff.setCreateBy(getUsername());
storeStaff.setCreateId(getUserId());
return toAjax(storeStaffService.insertStoreStaff(storeStaff));
StoreStaff po = storeStaffConverter.toPoByApp(data);
po.setCreateBy(getUsername());
po.setCreateId(getUserId());
return toAjax(storeStaffService.insertStoreStaff(po));
}
@ApiOperation("商户修改店铺员工")
@Log(title = "店铺员工", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody @Validated(ValidGroup.Update.class) StoreStaff storeStaff) {
if (storeStaff.getStoreId() != null) {
public AjaxResult edit(@RequestBody @Validated(ValidGroup.FrontUpdate.class) StoreStaff data) {
if (data.getStoreId() != null) {
// 校验店铺是否为本人的
if (!storeValidator.isStoreBelongUser(storeStaff.getStoreId(), getUserId())) {
if (!storeValidator.isStoreBelongUser(data.getStoreId(), getUserId())) {
return error("您只能操作自己的店铺");
}
}
return toAjax(storeStaffService.updateStoreStaff(storeStaff));
StoreStaff po = storeStaffConverter.toPoByApp(data);
return toAjax(storeStaffService.updateStoreStaff(po));
}
@ApiOperation("商户删除店铺员工")
@ -88,9 +93,8 @@ public class MchStoreStaffController extends BaseController {
@DeleteMapping("/{employIds}")
public AjaxResult remove(@PathVariable List<Long> employIds) {
if (!storeStaffValidator.isMch(employIds, getUserId())) {
return error("您只能操作自己店铺");
return error("您只能操作自己店铺的员工");
}
return toAjax(storeStaffService.deleteStoreStaffByEmployIds(employIds));
}

View File

@ -2,8 +2,11 @@ package com.ruoyi.web.controller.ss;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.core.domain.ValidGroup;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
@ -78,7 +81,7 @@ public class RiskController extends BaseController
@PreAuthorize("@ss.hasPermi('ss:risk:add')")
@Log(title = "风控", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody Risk risk)
public AjaxResult add(@RequestBody @Validated(ValidGroup.Create.class) Risk risk)
{
return toAjax(riskService.insertRisk(risk));
}
@ -89,7 +92,7 @@ public class RiskController extends BaseController
@PreAuthorize("@ss.hasPermi('ss:risk:edit')")
@Log(title = "风控", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody Risk risk)
public AjaxResult edit(@RequestBody @Validated(ValidGroup.Update.class) Risk risk)
{
return toAjax(riskService.updateRisk(risk));
}

View File

@ -0,0 +1,44 @@
package com.ruoyi.web.controller.staff;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.ss.device.domain.DeviceQuery;
import com.ruoyi.ss.device.domain.vo.DeviceVO;
import com.ruoyi.ss.device.service.DeviceAssembler;
import com.ruoyi.ss.device.service.DeviceService;
import com.ruoyi.ss.storeStaff.domain.enums.StoreStaffPermissions;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author wjh
* 2024/11/27
*/
@RestController
@RequestMapping("/staff/device")
public class StaffDeviceController extends BaseController {
@Autowired
private DeviceService deviceService;
@Autowired
private DeviceAssembler deviceAssembler;
@ApiOperation("员工查询设备列表")
@GetMapping("/list")
public TableDataInfo list(DeviceQuery query) {
startPage();
startOrderBy();
query.setStaffUserId(getUserId());
query.setStaffPermission(StoreStaffPermissions.DEVICE_VIEW.getCode());
List<DeviceVO> list = deviceService.selectStaffDeviceList(query);
deviceService.pullDeviceInfoList(list);
return getDataTable(list);
}
}

View File

@ -7,6 +7,8 @@ import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.ServiceUtil;
import com.ruoyi.ss.store.domain.StoreBO;
import com.ruoyi.ss.store.domain.StoreQuery;
import com.ruoyi.ss.store.domain.StoreVo;
import com.ruoyi.ss.store.service.StoreAssembler;
import com.ruoyi.ss.store.service.StoreService;
import com.ruoyi.ss.store.service.StoreValidator;
import com.ruoyi.ss.storeStaff.domain.enums.StoreStaffPermissions;
@ -16,6 +18,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 员工 店铺Controller
* @author wjh
@ -29,10 +33,7 @@ public class StaffStoreController extends BaseController {
private StoreService storeService;
@Autowired
private StoreStaffValidator storeStaffValidator;
@Autowired
private StoreValidator storeValidator;
private StoreAssembler storeAssembler;
@ApiOperation("员工获取管理的店铺列表")
@GetMapping("/list")
@ -40,29 +41,13 @@ public class StaffStoreController extends BaseController {
startPage();
query.setStaffUserId(getUserId());
query.setStaffPermission(StoreStaffPermissions.STORE_VIEW.getCode());
return getDataTable(storeService.selectStaffStoreList(query));
List<StoreVo> list = storeService.selectStaffStoreList(query);
// 拼接设备数量
storeAssembler.assembleDeviceCount(list);
// 拼接营收数据
storeAssembler.assembleRevenue(list);
return getDataTable(list);
}
@ApiOperation("员工获取店铺详情")
@GetMapping("/{storeId}")
public AjaxResult getDetail(@PathVariable Long storeId) {
StoreQuery query = new StoreQuery();
query.setStaffUserId(getUserId());
query.setStaffPermission(StoreStaffPermissions.STORE_VIEW.getCode());
query.setStoreId(storeId);
return success(storeService.selectStaffStoreOne(query));
}
// TODO 建议还是合在商户的接口中使用
@ApiOperation("员工申请修改店铺信息")
@PutMapping
public AjaxResult update(@RequestBody @Validated(ValidGroup.FrontUpdate.class) StoreBO data) {
if (!storeStaffValidator.canOperaStore(data.getStoreId(), getUserId())) {
return error("您无权修改该店铺");
}
data = data.filterUpdateByAppStaff();
ServiceUtil.assertion(storeValidator.preUpdateByApp(data));
return toAjax(storeService.updateApply(data));
}
}

View File

@ -0,0 +1,46 @@
package com.ruoyi.web.controller.staff;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.ss.device.domain.vo.DeviceVO;
import com.ruoyi.ss.storeStaff.domain.enums.StoreStaffPermissions;
import com.ruoyi.ss.transactionBill.domain.TransactionBillQuery;
import com.ruoyi.ss.transactionBill.domain.vo.TransactionBillVO;
import com.ruoyi.ss.transactionBill.service.TransactionAssembler;
import com.ruoyi.ss.transactionBill.service.TransactionBillService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author wjh
* 2024/11/27
*/
@RestController
@RequestMapping("/staff/bill")
public class StaffTransactionBillController extends BaseController {
@Autowired
private TransactionBillService transactionBillService;
@Autowired
private TransactionAssembler transactionAssembler;
@ApiOperation("员工获取订单列表")
@GetMapping("/list")
public TableDataInfo list(TransactionBillQuery query) {
startPage();
startOrderBy();
query.setStaffUserId(getUserId());
query.setStaffPermission(StoreStaffPermissions.ORDER_VIEW.getCode());
List<TransactionBillVO> list = transactionBillService.selectStaffDeviceList(query);
transactionAssembler.assembleOperator(list, getUserId());
return getDataTable(list);
}
}