1.风控(建表)
2.订单设备操作、设备使用中状态判断条件修改
This commit is contained in:
parent
f659bacc0e
commit
fb736ec07a
smart-switch-service/src/main/java/com/ruoyi/ss
device
domain/vo
mapper
service
risk
domain
mapper
service
transactionBill
smart-switch-web/src/main/java/com/ruoyi/web/controller/ss
|
@ -94,6 +94,9 @@ public class DeviceVO extends Device implements IotDevice {
|
|||
@JsonView(DeviceView.SuitList.class)
|
||||
private Boolean mchShowBillMobile;
|
||||
|
||||
@ApiModelProperty("正在使用中的订单数量")
|
||||
private Integer usingBillCount;
|
||||
|
||||
@Override
|
||||
public String iotMac1() {
|
||||
return getMac();
|
||||
|
|
|
@ -10,96 +10,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="modelTags" column="model_tags" typeHandler="com.ruoyi.system.mapper.typehandler.StringSplitListTypeHandler" />
|
||||
</resultMap>
|
||||
|
||||
<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 != ''">
|
||||
and (
|
||||
sd.mac = #{anyMac} or sd.mac2 = #{anyMac}
|
||||
)
|
||||
</if>
|
||||
<if test="likeAnyMac != null and likeAnyMac != ''">
|
||||
and (
|
||||
sd.mac like concat('%', #{likeAnyMac}, '%') or sd.mac2 like concat('%', #{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 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 <= #{endRentTime}</if>
|
||||
<if test="deviceNo != null"> and sd.device_no like concat('%', #{deviceNo}, '%')</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 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="isArrears != null">
|
||||
<if test="isArrears">
|
||||
and (sd.rent_time is null or sd.rent_time <= now())
|
||||
</if>
|
||||
<if test="!isArrears">
|
||||
and (sd.rent_time is not null and sd.rent_time > now())
|
||||
</if>
|
||||
</if>
|
||||
<if test="deviceIds != null and deviceIds.size() > 0">
|
||||
and sd.device_id in
|
||||
<foreach collection="deviceIds" open="(" close=")" separator="," item="item">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="deviceNos != null and deviceNos.size() > 0">
|
||||
and sd.device_no in
|
||||
<foreach collection="deviceNos" open="(" close=")" separator="," item="item">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="isBind != null">
|
||||
<if test="isBind">
|
||||
and sd.user_id is not null
|
||||
</if>
|
||||
<if test="!isBind">
|
||||
and sd.user_id is null
|
||||
</if>
|
||||
</if>
|
||||
<if test="storeIds != null and storeIds.size() > 0">
|
||||
and sd.store_id in
|
||||
<foreach collection="storeIds" open="(" close=")" separator="," item="item">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="userIds != null and userIds.size() > 0">
|
||||
and sd.user_id in
|
||||
<foreach collection="userIds" open="(" close=")" separator="," item="item">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="modelIds != null and modelIds.size() > 0">
|
||||
and sd.model_id in
|
||||
<foreach collection="modelIds" open="(" close=")" separator="," item="item">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="macList != null and macList.size() > 0">
|
||||
and sd.mac in
|
||||
<foreach collection="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>
|
||||
</sql>
|
||||
|
||||
<sql id="selectVo">
|
||||
select
|
||||
sd.device_id,
|
||||
|
@ -179,6 +89,96 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
left join sm_user sua on sua.user_id = sd.agent_id
|
||||
</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 != ''">
|
||||
and (
|
||||
sd.mac = #{anyMac} or sd.mac2 = #{anyMac}
|
||||
)
|
||||
</if>
|
||||
<if test="likeAnyMac != null and likeAnyMac != ''">
|
||||
and (
|
||||
sd.mac like concat('%', #{likeAnyMac}, '%') or sd.mac2 like concat('%', #{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 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 <= #{endRentTime}</if>
|
||||
<if test="deviceNo != null"> and sd.device_no like concat('%', #{deviceNo}, '%')</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 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="isArrears != null">
|
||||
<if test="isArrears">
|
||||
and (sd.rent_time is null or sd.rent_time <= now())
|
||||
</if>
|
||||
<if test="!isArrears">
|
||||
and (sd.rent_time is not null and sd.rent_time > now())
|
||||
</if>
|
||||
</if>
|
||||
<if test="deviceIds != null and deviceIds.size() > 0">
|
||||
and sd.device_id in
|
||||
<foreach collection="deviceIds" open="(" close=")" separator="," item="item">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="deviceNos != null and deviceNos.size() > 0">
|
||||
and sd.device_no in
|
||||
<foreach collection="deviceNos" open="(" close=")" separator="," item="item">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="isBind != null">
|
||||
<if test="isBind">
|
||||
and sd.user_id is not null
|
||||
</if>
|
||||
<if test="!isBind">
|
||||
and sd.user_id is null
|
||||
</if>
|
||||
</if>
|
||||
<if test="storeIds != null and storeIds.size() > 0">
|
||||
and sd.store_id in
|
||||
<foreach collection="storeIds" open="(" close=")" separator="," item="item">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="userIds != null and userIds.size() > 0">
|
||||
and sd.user_id in
|
||||
<foreach collection="userIds" open="(" close=")" separator="," item="item">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="modelIds != null and modelIds.size() > 0">
|
||||
and sd.model_id in
|
||||
<foreach collection="modelIds" open="(" close=")" separator="," item="item">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="macList != null and macList.size() > 0">
|
||||
and sd.mac in
|
||||
<foreach collection="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>
|
||||
</sql>
|
||||
|
||||
<select id="selectSmDeviceList" parameterType="DeviceQuery" resultMap="SmDeviceResult">
|
||||
<include refid="selectVo"/>
|
||||
<where>
|
||||
|
|
|
@ -36,4 +36,9 @@ public interface DeviceAssembler {
|
|||
* 拼接真实的服务费率
|
||||
*/
|
||||
void assembleRealServiceRate(List<DeviceVO> list);
|
||||
|
||||
/**
|
||||
* 拼接正在使用中的订单数量
|
||||
*/
|
||||
void assembleUsingBillCount(List<DeviceVO> list);
|
||||
}
|
||||
|
|
|
@ -368,4 +368,14 @@ public interface DeviceService
|
|||
* @param agentServiceRate 代理商设备服务费
|
||||
*/
|
||||
int bindAgent(Long deviceId, Long agentId, BigDecimal agentServiceRate);
|
||||
|
||||
/**
|
||||
* 设置电量
|
||||
*/
|
||||
int setEle(DeviceVO device, BigDecimal ele);
|
||||
|
||||
/**
|
||||
* 设置剩余时间
|
||||
*/
|
||||
int setTime(DeviceVO device, long seconds);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.ruoyi.ss.device.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.ruoyi.common.domain.vo.CommonCountVO;
|
||||
import com.ruoyi.common.utils.ServiceUtil;
|
||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||
import com.ruoyi.dashboard.domain.vo.BillCountVo;
|
||||
|
@ -157,4 +159,28 @@ public class DeviceAssemblerImpl implements DeviceAssembler {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void assembleUsingBillCount(List<DeviceVO> list) {
|
||||
if (CollectionUtils.isEmptyElement(list)) {
|
||||
return;
|
||||
}
|
||||
|
||||
TransactionBillQuery query = new TransactionBillQuery();
|
||||
query.setIsUsing(true);
|
||||
query.setType(TransactionBillType.RECHARGE.getType());
|
||||
query.setDeviceIds(CollectionUtils.map(list, DeviceVO::getDeviceId));
|
||||
List<JSONObject> counts = transactionBillService.selectCountGroupBy(query, "stb.device_id");
|
||||
|
||||
for (DeviceVO device : list) {
|
||||
JSONObject count = counts.stream()
|
||||
.filter(item -> Objects.equals(item.getLong("key"), device.getDeviceId()))
|
||||
.findFirst().orElse(null);
|
||||
if (count != null && count.getInteger("count") != null) {
|
||||
device.setUsingBillCount(count.getInteger("count"));
|
||||
} else {
|
||||
device.setUsingBillCount(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import com.ruoyi.common.enums.UserType;
|
|||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.*;
|
||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||
import com.ruoyi.dashboard.domain.vo.BillCountVo;
|
||||
import com.ruoyi.iot.domain.IotDeviceInfo;
|
||||
import com.ruoyi.iot.domain.response.CommandResponse;
|
||||
import com.ruoyi.iot.enums.IotHttpStatus;
|
||||
|
@ -669,10 +668,7 @@ public class DeviceServiceImpl implements DeviceService
|
|||
}
|
||||
|
||||
Integer result = transactionTemplate.execute(status -> {
|
||||
Device data = new Device();
|
||||
data.setDeviceId(device.getDeviceId());
|
||||
data.setExpireTime(expireTime);
|
||||
int update = deviceMapper.updateSmDevice(data);
|
||||
int update = this.updateExpireTime(device.getDeviceId(), expireTime);
|
||||
ServiceUtil.assertion(update != 1, "更新数据失败");
|
||||
|
||||
if (withIot) {
|
||||
|
@ -681,16 +677,23 @@ public class DeviceServiceImpl implements DeviceService
|
|||
if (seconds > 0) {
|
||||
CommandResponse res = iotService.trySetTime(device, seconds, tryCount);
|
||||
if (!res.isSuccess()) {
|
||||
log.error("操作设备失败:{}", res.getMsg());
|
||||
log.error("操作设备设置时长{}失败:{}", device.getDeviceId(), res.getMsg());
|
||||
throw new ServiceException(res.getMsg());
|
||||
}
|
||||
return res.isSuccess() ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
return update;
|
||||
});
|
||||
|
||||
return result == null ? 0 : 1;
|
||||
return result == null ? 0 : result;
|
||||
}
|
||||
|
||||
private int updateExpireTime(Long deviceId, LocalDateTime expireTime) {
|
||||
Device data = new Device();
|
||||
data.setDeviceId(deviceId);
|
||||
data.setExpireTime(expireTime);
|
||||
return deviceMapper.updateSmDevice(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -772,6 +775,40 @@ public class DeviceServiceImpl implements DeviceService
|
|||
return result == null ? 0 : result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int setEle(DeviceVO device, BigDecimal ele) {
|
||||
if (device == null || ele == null) {
|
||||
return 0;
|
||||
}
|
||||
Integer result = transactionTemplate.execute(status -> {
|
||||
int update = this.updateSurplusEle(device.getDeviceId(), ele);
|
||||
ServiceUtil.assertion(update != 1, "更新设备数据失败");
|
||||
|
||||
CommandResponse res = iotService.setEle(device, ele);
|
||||
ServiceUtil.assertion(res == null, "发送命令失败:返回值为空");
|
||||
ServiceUtil.assertion(!res.isSuccess(), res.getMsg());
|
||||
|
||||
return update;
|
||||
});
|
||||
|
||||
return result == null ? 0 : result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int setTime(DeviceVO device, long seconds) {
|
||||
return this.setTime(device, LocalDateTime.now().plusSeconds(seconds), true, 1);
|
||||
}
|
||||
|
||||
private int updateSurplusEle(Long deviceId, BigDecimal ele) {
|
||||
if (deviceId == null || ele == null) {
|
||||
return 0;
|
||||
}
|
||||
Device data = new Device();
|
||||
data.setSurplusEle(ele);
|
||||
data.setDeviceId(deviceId);
|
||||
return deviceMapper.updateSmDevice(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean addTime(Long deviceId, long seconds, boolean withIot) {
|
||||
|
@ -992,6 +1029,9 @@ public class DeviceServiceImpl implements DeviceService
|
|||
}
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
|
||||
// 拼接正在使用中的订单数量
|
||||
deviceAssembler.assembleUsingBillCount(list);
|
||||
|
||||
for (DeviceVO device : list) {
|
||||
try {
|
||||
if (StringUtils.isAnyBlank(device.getMac(), device.getModelProductId())) {
|
||||
|
@ -1040,12 +1080,14 @@ public class DeviceServiceImpl implements DeviceService
|
|||
|
||||
// 判断设备是否正在使用
|
||||
// 设备过期时间 > 当前时间,则正在使用
|
||||
boolean hasTime = device.getExpireTime() != null && device.getExpireTime().isAfter(now);
|
||||
// 若当前设备有电量,则正在使用
|
||||
boolean hasEle = device.getSurplusEle() != null && device.getSurplusEle().compareTo(BigDecimal.ZERO) > 0;
|
||||
// boolean hasTime = device.getExpireTime() != null && device.getExpireTime().isAfter(now);
|
||||
// // 若当前设备有电量,则正在使用
|
||||
// boolean hasEle = device.getSurplusEle() != null && device.getSurplusEle().compareTo(BigDecimal.ZERO) > 0;
|
||||
// 若开关开启,则正在使用
|
||||
boolean hasOpen = DevicePowerStatus.ON.getStatus().equals(device.getPowerStatus());
|
||||
if (hasTime || hasEle || hasOpen) {
|
||||
// 若设备有正在使用中的订单,则正在使用
|
||||
boolean hasUsingBill = device.getUsingBillCount() != null && device.getUsingBillCount() > 0;
|
||||
if (hasOpen || hasUsingBill) {
|
||||
device.setStatus(DeviceStatus.USING.getStatus());
|
||||
} else {
|
||||
device.setStatus(DeviceStatus.NORMAL.getStatus());
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
package com.ruoyi.ss.risk.domain;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 风控对象 ss_risk
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-10-18
|
||||
*/
|
||||
@Data
|
||||
public class Risk extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long riskId;
|
||||
|
||||
@Excel(name = "用户ID")
|
||||
@ApiModelProperty("用户ID")
|
||||
private Long userId;
|
||||
|
||||
@Excel(name = "类型")
|
||||
@ApiModelProperty("类型")
|
||||
private String type;
|
||||
|
||||
@Excel(name = "风控原因")
|
||||
@ApiModelProperty("风控原因")
|
||||
private String reason;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Excel(name = "结束时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty("结束时间")
|
||||
private Date endTime;
|
||||
|
||||
@Excel(name = "实名认证ID")
|
||||
@ApiModelProperty("实名认证ID")
|
||||
private Long realNameId;
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.ruoyi.ss.risk.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2024/10/18
|
||||
*/
|
||||
@Data
|
||||
public class RiskQuery extends RiskVO{
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.ruoyi.ss.risk.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2024/10/18
|
||||
*/
|
||||
@Data
|
||||
public class RiskVO extends Risk{
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package com.ruoyi.ss.risk.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.ss.risk.domain.Risk;
|
||||
import com.ruoyi.ss.risk.domain.RiskVO;
|
||||
import com.ruoyi.ss.risk.domain.RiskQuery;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 风控Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-10-18
|
||||
*/
|
||||
public interface RiskMapper
|
||||
{
|
||||
/**
|
||||
* 查询风控
|
||||
*
|
||||
* @param riskId 风控主键
|
||||
* @return 风控
|
||||
*/
|
||||
public RiskVO selectRiskByRiskId(Long riskId);
|
||||
|
||||
/**
|
||||
* 查询风控列表
|
||||
*
|
||||
* @param query 风控
|
||||
* @return 风控集合
|
||||
*/
|
||||
public List<RiskVO> selectRiskList(@Param("query")RiskQuery query);
|
||||
|
||||
/**
|
||||
* 新增风控
|
||||
*
|
||||
* @param risk 风控
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertRisk(Risk risk);
|
||||
|
||||
/**
|
||||
* 修改风控
|
||||
*
|
||||
* @param risk 风控
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateRisk(@Param("data") Risk risk);
|
||||
|
||||
/**
|
||||
* 删除风控
|
||||
*
|
||||
* @param riskId 风控主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteRiskByRiskId(Long riskId);
|
||||
|
||||
/**
|
||||
* 批量删除风控
|
||||
*
|
||||
* @param riskIds 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteRiskByRiskIds(Long[] riskIds);
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.ss.risk.mapper.RiskMapper">
|
||||
|
||||
<resultMap type="RiskVO" id="RiskResult" autoMapping="true"/>
|
||||
|
||||
<sql id="selectRiskVo">
|
||||
select
|
||||
sr.risk_id,
|
||||
sr.user_id,
|
||||
sr.type,
|
||||
sr.reason,
|
||||
sr.end_time,
|
||||
sr.create_time,
|
||||
sr.real_name_id
|
||||
from ss_risk sr
|
||||
</sql>
|
||||
|
||||
<sql id="searchCondition">
|
||||
<if test="query.riskId != null "> and sr.risk_id = #{query.riskId}</if>
|
||||
<if test="query.userId != null "> and sr.user_id = #{query.userId}</if>
|
||||
<if test="query.type != null and query.type != ''"> and sr.type = #{query.type}</if>
|
||||
<if test="query.reason != null and query.reason != ''"> and sr.reason like concat('%', #{query.reason}, '%')</if>
|
||||
<if test="query.realNameId != null "> and sr.real_name_id = #{query.realNameId}</if>
|
||||
</sql>
|
||||
|
||||
<select id="selectRiskList" parameterType="RiskQuery" resultMap="RiskResult">
|
||||
<include refid="selectRiskVo"/>
|
||||
<where>
|
||||
<include refid="searchCondition"/>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectRiskByRiskId" parameterType="Long" resultMap="RiskResult">
|
||||
<include refid="selectRiskVo"/>
|
||||
where risk_id = #{riskId}
|
||||
</select>
|
||||
|
||||
<insert id="insertRisk" parameterType="Risk" useGeneratedKeys="true" keyProperty="riskId">
|
||||
insert into ss_risk
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="type != null and type != ''">type,</if>
|
||||
<if test="reason != null">reason,</if>
|
||||
<if test="endTime != null">end_time,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="realNameId != null">real_name_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="type != null and type != ''">#{type},</if>
|
||||
<if test="reason != null">#{reason},</if>
|
||||
<if test="endTime != null">#{endTime},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="realNameId != null">#{realNameId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateRisk" parameterType="Risk">
|
||||
update ss_risk
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<include refid="updateColumns"/>
|
||||
</trim>
|
||||
where risk_id = #{data.riskId}
|
||||
</update>
|
||||
|
||||
<sql id="updateColumns">
|
||||
<if test="data.userId != null">user_id = #{data.userId},</if>
|
||||
<if test="data.type != null and data.type != ''">type = #{data.type},</if>
|
||||
<if test="data.reason != null">reason = #{data.reason},</if>
|
||||
<if test="data.endTime != null">end_time = #{data.endTime},</if>
|
||||
<if test="data.createTime != null">create_time = #{data.createTime},</if>
|
||||
<if test="data.realNameId != null">real_name_id = #{data.realNameId},</if>
|
||||
</sql>
|
||||
|
||||
<delete id="deleteRiskByRiskId" parameterType="Long">
|
||||
delete from ss_risk where risk_id = #{riskId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteRiskByRiskIds" parameterType="String">
|
||||
delete from ss_risk where risk_id in
|
||||
<foreach item="riskId" collection="array" open="(" separator="," close=")">
|
||||
#{riskId}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
|
@ -0,0 +1,63 @@
|
|||
package com.ruoyi.ss.risk.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.ss.risk.domain.Risk;
|
||||
import com.ruoyi.ss.risk.domain.RiskVO;
|
||||
import com.ruoyi.ss.risk.domain.RiskQuery;
|
||||
|
||||
/**
|
||||
* 风控Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-10-18
|
||||
*/
|
||||
public interface IRiskService
|
||||
{
|
||||
/**
|
||||
* 查询风控
|
||||
*
|
||||
* @param riskId 风控主键
|
||||
* @return 风控
|
||||
*/
|
||||
public RiskVO selectRiskByRiskId(Long riskId);
|
||||
|
||||
/**
|
||||
* 查询风控列表
|
||||
*
|
||||
* @param risk 风控
|
||||
* @return 风控集合
|
||||
*/
|
||||
public List<RiskVO> selectRiskList(RiskQuery risk);
|
||||
|
||||
/**
|
||||
* 新增风控
|
||||
*
|
||||
* @param risk 风控
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertRisk(Risk risk);
|
||||
|
||||
/**
|
||||
* 修改风控
|
||||
*
|
||||
* @param risk 风控
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateRisk(Risk risk);
|
||||
|
||||
/**
|
||||
* 批量删除风控
|
||||
*
|
||||
* @param riskIds 需要删除的风控主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteRiskByRiskIds(Long[] riskIds);
|
||||
|
||||
/**
|
||||
* 删除风控信息
|
||||
*
|
||||
* @param riskId 风控主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteRiskByRiskId(Long riskId);
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
package com.ruoyi.ss.risk.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.ss.risk.mapper.RiskMapper;
|
||||
import com.ruoyi.ss.risk.domain.Risk;
|
||||
import com.ruoyi.ss.risk.domain.RiskVO;
|
||||
import com.ruoyi.ss.risk.domain.RiskQuery;
|
||||
import com.ruoyi.ss.risk.service.IRiskService;
|
||||
|
||||
/**
|
||||
* 风控Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-10-18
|
||||
*/
|
||||
@Service
|
||||
public class RiskServiceImpl implements IRiskService
|
||||
{
|
||||
@Autowired
|
||||
private RiskMapper riskMapper;
|
||||
|
||||
/**
|
||||
* 查询风控
|
||||
*
|
||||
* @param riskId 风控主键
|
||||
* @return 风控
|
||||
*/
|
||||
@Override
|
||||
public RiskVO selectRiskByRiskId(Long riskId)
|
||||
{
|
||||
return riskMapper.selectRiskByRiskId(riskId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询风控列表
|
||||
*
|
||||
* @param risk 风控
|
||||
* @return 风控
|
||||
*/
|
||||
@Override
|
||||
public List<RiskVO> selectRiskList(RiskQuery risk)
|
||||
{
|
||||
return riskMapper.selectRiskList(risk);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增风控
|
||||
*
|
||||
* @param risk 风控
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertRisk(Risk risk)
|
||||
{
|
||||
risk.setCreateTime(DateUtils.getNowDate());
|
||||
return riskMapper.insertRisk(risk);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改风控
|
||||
*
|
||||
* @param risk 风控
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateRisk(Risk risk)
|
||||
{
|
||||
return riskMapper.updateRisk(risk);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除风控
|
||||
*
|
||||
* @param riskIds 需要删除的风控主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteRiskByRiskIds(Long[] riskIds)
|
||||
{
|
||||
return riskMapper.deleteRiskByRiskIds(riskIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除风控信息
|
||||
*
|
||||
* @param riskId 风控主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteRiskByRiskId(Long riskId)
|
||||
{
|
||||
return riskMapper.deleteRiskByRiskId(riskId);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
package com.ruoyi.ss.transactionBill.mapper;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.ruoyi.common.domain.vo.CommonCountVO;
|
||||
import com.ruoyi.dashboard.domain.vo.BillCountVo;
|
||||
import com.ruoyi.ss.transactionBill.domain.TransactionBill;
|
||||
import com.ruoyi.ss.transactionBill.domain.TransactionBillQuery;
|
||||
|
@ -197,4 +199,9 @@ public interface TransactionBillMapper
|
|||
* 查询金额统计
|
||||
*/
|
||||
<T> List<TransactionAmountVO<T>> selectCommonSumOfMoney(@Param("query") TransactionBillQuery query, @Param("groupBy") String groupBy);
|
||||
|
||||
/**
|
||||
* 查询统计数量
|
||||
*/
|
||||
List<JSONObject> selectCountGroupBy(@Param("query") TransactionBillQuery query, @Param("groupBy") String groupBy);
|
||||
}
|
||||
|
|
|
@ -421,6 +421,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectCountGroupBy" resultType="com.alibaba.fastjson2.JSONObject">
|
||||
select
|
||||
<if test="groupBy != null and groupBy != ''">
|
||||
${groupBy} as `key`,
|
||||
</if>
|
||||
count(stb.bill_id) as `count`
|
||||
from <include refid="rechargeTables"/>
|
||||
<where>
|
||||
<include refid="searchCondition"/>
|
||||
</where>
|
||||
<if test="groupBy != null and groupBy != ''">
|
||||
group by `key`
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<insert id="insertSmTransactionBill" parameterType="TransactionBill" useGeneratedKeys="true" keyProperty="billId">
|
||||
<selectKey resultType="Long" order="AFTER" keyProperty="billId">
|
||||
SELECT LAST_INSERT_ID();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.ruoyi.ss.transactionBill.service;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.ruoyi.dashboard.domain.vo.BillCountVo;
|
||||
import com.ruoyi.ss.device.domain.vo.DeviceVO;
|
||||
import com.ruoyi.ss.payBill.domain.vo.DoPayVO;
|
||||
|
@ -328,4 +329,6 @@ public interface TransactionBillService
|
|||
* @return
|
||||
*/
|
||||
int receiveMchShowMobileAmount(TransactionBillVO bill);
|
||||
|
||||
<T> List<JSONObject> selectCountGroupBy(TransactionBillQuery query, String groupBy);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.ruoyi.ss.transactionBill.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.core.redis.RedisLock;
|
||||
|
@ -21,7 +22,6 @@ import com.ruoyi.ss.bonus.service.BonusService;
|
|||
import com.ruoyi.ss.channelWithdraw.domain.ChannelWithdrawVO;
|
||||
import com.ruoyi.ss.channelWithdraw.service.ChannelWithdrawService;
|
||||
import com.ruoyi.dashboard.domain.vo.BillCountVo;
|
||||
import com.ruoyi.ss.device.domain.enums.DeviceOnlineStatus;
|
||||
import com.ruoyi.ss.device.domain.vo.DeviceVO;
|
||||
import com.ruoyi.ss.device.service.DeviceService;
|
||||
import com.ruoyi.ss.payBill.domain.PayBillQuery;
|
||||
|
@ -424,6 +424,11 @@ public class TransactionBillServiceImpl implements TransactionBillService, After
|
|||
return result == null ? 0 :result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JSONObject> selectCountGroupBy(TransactionBillQuery query, String groupBy) {
|
||||
return transactionBillMapper.selectCountGroupBy(query, groupBy);
|
||||
}
|
||||
|
||||
private int fix(TransactionBillVO bill) {
|
||||
if (bill == null || bill.getBillId() == null) {
|
||||
log.warn("修复订单数据失败:订单不存在或订单ID为空");
|
||||
|
@ -924,21 +929,18 @@ public class TransactionBillServiceImpl implements TransactionBillService, After
|
|||
);
|
||||
ServiceUtil.assertion(updateRecharge != 1, "设备充值状态发生变化,请稍后重试");
|
||||
|
||||
// 充值设备
|
||||
try {
|
||||
if (SuitFeeType.TIME.getType().equals(bill.getSuitFeeType())) {
|
||||
// 设备充值时长
|
||||
return deviceService.addTime(bill.getDeviceId(), transactionBillConverter.toRechargeSeconds(bill), true);
|
||||
// 设备设置时长
|
||||
long seconds = transactionBillConverter.toRechargeSeconds(bill);
|
||||
int setTime = deviceService.setTime(device, seconds);
|
||||
ServiceUtil.assertion(setTime != 1, "设备时长充值失败");
|
||||
} else if (SuitFeeType.COUNT.getType().equals(bill.getSuitFeeType())) {
|
||||
// 若设备剩余电量为负数,则补偿设备电量
|
||||
// 设备设置电量
|
||||
BigDecimal ele = transactionBillConverter.toRechargeEle(bill);
|
||||
if (device.getSurplusEle() != null && device.getSurplusEle().compareTo(BigDecimal.ZERO) < 0) {
|
||||
ele = ele.add(device.getSurplusEle().abs());
|
||||
}
|
||||
// 设备充值电量
|
||||
CommandResponse res = iotService.addEle(device, ele);
|
||||
ServiceUtil.assertion(res == null, "设备充值失败,返回数据为空");
|
||||
ServiceUtil.assertion(!res.isSuccess(), "设备充值失败:" + res.getMsg());
|
||||
return true;
|
||||
int setEle = deviceService.setEle(device, ele);
|
||||
ServiceUtil.assertion(setEle != 1, "设备时长充值失败");
|
||||
} else {
|
||||
throw new ServiceException("不支持的套餐类型");
|
||||
}
|
||||
|
@ -948,6 +950,8 @@ public class TransactionBillServiceImpl implements TransactionBillService, After
|
|||
openMsg.set(e.getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
// 是否成功
|
||||
|
@ -980,8 +984,7 @@ public class TransactionBillServiceImpl implements TransactionBillService, After
|
|||
return 0;
|
||||
}
|
||||
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime startTime = device.getExpireTime() == null || now.isAfter(device.getExpireTime()) ? now : device.getExpireTime();
|
||||
LocalDateTime startTime = LocalDateTime.now();
|
||||
|
||||
TransactionBill data = new TransactionBill();
|
||||
data.setBillId(bill.getBillId());
|
||||
|
@ -1913,7 +1916,6 @@ public class TransactionBillServiceImpl implements TransactionBillService, After
|
|||
@Override
|
||||
public List<TransactionBillVO> selectUsingBill(TransactionBillQuery query) {
|
||||
query.setIsUsing(true);
|
||||
query.setStatusList(TransactionBillStatus.asList(TransactionBillStatus.SUCCESS, TransactionBillStatus.SUCCESS_DEPOSIT));
|
||||
query.setType(TransactionBillType.RECHARGE.getType());
|
||||
return this.selectSmTransactionBillList(query);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,107 @@
|
|||
package com.ruoyi.web.controller.ss;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.ss.risk.domain.Risk;
|
||||
import com.ruoyi.ss.risk.domain.RiskVO;
|
||||
import com.ruoyi.ss.risk.domain.RiskQuery;
|
||||
import com.ruoyi.ss.risk.service.IRiskService;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 风控Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-10-18
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/ss/risk")
|
||||
public class RiskController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IRiskService riskService;
|
||||
|
||||
/**
|
||||
* 查询风控列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:risk:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(RiskQuery query)
|
||||
{
|
||||
startPage();
|
||||
startOrderBy();
|
||||
List<RiskVO> list = riskService.selectRiskList(query);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出风控列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:risk:export')")
|
||||
@Log(title = "风控", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, RiskQuery query)
|
||||
{
|
||||
List<RiskVO> list = riskService.selectRiskList(query);
|
||||
ExcelUtil<RiskVO> util = new ExcelUtil<RiskVO>(RiskVO.class);
|
||||
util.exportExcel(response, list, "风控数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取风控详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:risk:query')")
|
||||
@GetMapping(value = "/{riskId}")
|
||||
public AjaxResult getInfo(@PathVariable("riskId") Long riskId)
|
||||
{
|
||||
return success(riskService.selectRiskByRiskId(riskId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增风控
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:risk:add')")
|
||||
@Log(title = "风控", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody Risk risk)
|
||||
{
|
||||
return toAjax(riskService.insertRisk(risk));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改风控
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:risk:edit')")
|
||||
@Log(title = "风控", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody Risk risk)
|
||||
{
|
||||
return toAjax(riskService.updateRisk(risk));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除风控
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:risk:remove')")
|
||||
@Log(title = "风控", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{riskIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] riskIds)
|
||||
{
|
||||
return toAjax(riskService.deleteRiskByRiskIds(riskIds));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user