新增月费功能
This commit is contained in:
parent
bb6edf05f3
commit
d42b3fff75
|
@ -1,11 +1,18 @@
|
|||
package com.ruoyi.common.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 登录用户类型
|
||||
* @author 辉
|
||||
* 2024/3/5
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum LoginType {
|
||||
ADMIN, // 后台登录
|
||||
FRONT; // 前台登录
|
||||
ADMIN("1"), // 后台登录
|
||||
FRONT("2"); // 前台登录
|
||||
|
||||
private final String type;
|
||||
}
|
||||
|
|
|
@ -9,4 +9,6 @@ public class DictTypeConstants {
|
|||
|
||||
// 套餐时长单位
|
||||
public static final String SUIT_TIME_UNIT = "suit_time_unit";
|
||||
// 设备服务费类型
|
||||
public static final String DEVICE_SERVICE_TYPE = "device_service_type";
|
||||
}
|
||||
|
|
|
@ -29,12 +29,8 @@ public class Abnormal extends BaseEntity
|
|||
@ApiModelProperty("用户id(提交人)")
|
||||
private Long userId;
|
||||
|
||||
/** 设备编号 */
|
||||
@ApiModelProperty("设备编号")
|
||||
@Excel(name = "设备编号")
|
||||
@NotNull(message = "设备编号不允许为空", groups = {ValidGroup.FrontCreate.class})
|
||||
@Size(max = 64, message = "设备编号长度不能超过64个字符")
|
||||
private String deviceNo;
|
||||
@ApiModelProperty("设备ID")
|
||||
private Long deviceId;
|
||||
|
||||
/** 故障描述 */
|
||||
@ApiModelProperty("故障描述")
|
||||
|
@ -62,7 +58,6 @@ public class Abnormal extends BaseEntity
|
|||
@Size(max = 200, message = "联系地址长度不能超过200个字符")
|
||||
private String address;
|
||||
|
||||
/** 状态(0:审核中,1:已证实,待处理,2:处理中,3:已处理,4:未证实) */
|
||||
@ApiModelProperty(" 状态(0:审核中,1:已证实,待处理,2:处理中,3:已处理,4:未证实)")
|
||||
@ApiModelProperty("状态:1-未读,2-已读")
|
||||
private String status;
|
||||
}
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
package com.ruoyi.ss.abnormal.domain;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2024/4/30
|
||||
*/
|
||||
public class AbnormalBO extends Abnormal {
|
||||
|
||||
/**
|
||||
* 过滤App端提交的数据
|
||||
* @return
|
||||
*/
|
||||
public AbnormalBO filterCreateByApp() {
|
||||
AbnormalBO bo = new AbnormalBO();
|
||||
bo.setUserId(getUserId());
|
||||
bo.setDeviceNo(getDeviceNo());
|
||||
bo.setContent(getContent());
|
||||
bo.setName(getName());
|
||||
bo.setMobile(getMobile());
|
||||
bo.setAddress(getAddress());
|
||||
return bo;
|
||||
}
|
||||
}
|
|
@ -13,4 +13,7 @@ public class AbnormalQuery extends Abnormal {
|
|||
@ApiModelProperty("关键词,可以是故障描述、故障编号")
|
||||
private String keyword;
|
||||
|
||||
@ApiModelProperty("设备编号")
|
||||
private String deviceNo;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
package com.ruoyi.ss.abnormal.domain;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.ValidGroup;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2024/4/30
|
||||
|
@ -10,6 +15,9 @@ import lombok.Data;
|
|||
@Data
|
||||
public class AbnormalVO extends Abnormal {
|
||||
|
||||
@ApiModelProperty("设备编号")
|
||||
private String deviceNo;
|
||||
|
||||
@ApiModelProperty("用户名称")
|
||||
private String userName;
|
||||
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package com.ruoyi.ss.abnormal.domain.dto;
|
||||
|
||||
import com.ruoyi.common.core.domain.ValidGroup;
|
||||
import com.ruoyi.ss.abnormal.domain.Abnormal;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2024/4/30
|
||||
*/
|
||||
@Data
|
||||
public class AbnormalSubmitDTO extends Abnormal {
|
||||
|
||||
/** 设备编号 */
|
||||
@ApiModelProperty("设备编号")
|
||||
@NotNull(message = "设备编号不允许为空", groups = {ValidGroup.FrontCreate.class})
|
||||
@Size(max = 64, message = "设备编号长度不能超过64个字符")
|
||||
private String deviceNo;
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.ruoyi.ss.abnormal.domain.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2024/7/23
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum AbnormalStatus {
|
||||
|
||||
UNREAD("1", "未读"),
|
||||
READ("2", "已读");
|
||||
|
||||
private final String status;
|
||||
private final String msg;
|
||||
|
||||
}
|
|
@ -69,4 +69,9 @@ public interface AbnormalMapper
|
|||
* @return
|
||||
*/
|
||||
int logicDel(@Param("abnormalIds") List<Long> abnormalIds);
|
||||
|
||||
/**
|
||||
* 查询数量
|
||||
*/
|
||||
int selectCount(AbnormalQuery query);
|
||||
}
|
||||
|
|
|
@ -4,13 +4,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.ss.abnormal.mapper.AbnormalMapper">
|
||||
|
||||
<resultMap type="AbnormalVO" id="AbnormalResult" autoMapping="true">
|
||||
</resultMap>
|
||||
<resultMap type="AbnormalVO" id="AbnormalResult" autoMapping="true"/>
|
||||
|
||||
<sql id="selectAbnormalVo">
|
||||
select
|
||||
sa.abnormal_id,
|
||||
sa.device_no,
|
||||
sa.device_id,
|
||||
sa.content,
|
||||
sa.name,
|
||||
sa.mobile,
|
||||
|
@ -22,16 +21,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
sa.update_by,
|
||||
sa.deleted,
|
||||
sa.user_id,
|
||||
su.user_name as user_name
|
||||
from ss_abnormal sa
|
||||
su.user_name as user_name,
|
||||
sd.device_no as device_no
|
||||
from <include refid="searchTables"/>
|
||||
</sql>
|
||||
|
||||
<sql id="searchTables">
|
||||
ss_abnormal sa
|
||||
left join sm_user su on su.user_id = sa.user_id
|
||||
left join sm_device sd on sd.device_id = sa.device_id
|
||||
</sql>
|
||||
|
||||
<select id="selectAbnormalList" parameterType="AbnormalQuery" resultMap="AbnormalResult">
|
||||
<include refid="selectAbnormalVo"/>
|
||||
<where>
|
||||
<if test="abnormalId != null "> and sa.abnormal_id = #{abnormalId}</if>
|
||||
<if test="deviceNo != null "> and sa.device_no = #{deviceNo}</if>
|
||||
<if test="deviceNo != null and deviceNo != ''"> and sd.device_no like concat('%', #{deviceNo}, '%')</if>
|
||||
<if test="deviceId != null "> and sd.device_id = #{deviceId}</if>
|
||||
<if test="content != null and content != ''"> and sa.content = #{content}</if>
|
||||
<if test="name != null and name != ''"> and sa.name like concat('%', #{name}, '%')</if>
|
||||
<if test="mobile != null and mobile != ''"> and sa.mobile = #{mobile}</if>
|
||||
|
@ -57,15 +63,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
where abnormal_id = #{abnormalId} and sa.deleted = false
|
||||
</select>
|
||||
|
||||
<select id="selectCount" resultType="java.lang.Integer">
|
||||
select count(sa.abnormal_id)
|
||||
from <include refid="searchTables"/>
|
||||
|
||||
</select>
|
||||
|
||||
<insert id="insertAbnormal" parameterType="Abnormal" useGeneratedKeys="true" keyProperty="abnormalId">
|
||||
insert into ss_abnormal
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="deviceNo != null">device_no,</if>
|
||||
<if test="deviceId != null">device_id,</if>
|
||||
<if test="content != null and content != ''">content,</if>
|
||||
<if test="name != null">`name`,</if>
|
||||
<if test="mobile != null">mobile,</if>
|
||||
<if test="address != null">address,</if>
|
||||
<if test="status != null and status != ''">status,</if>
|
||||
<if test="status != null and status != ''">`status`,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
|
@ -74,7 +86,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="userId != null">user_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="deviceNo != null">#{deviceNo},</if>
|
||||
<if test="deviceId != null">#{deviceId},</if>
|
||||
<if test="content != null and content != ''">#{content},</if>
|
||||
<if test="name != null">#{name},</if>
|
||||
<if test="mobile != null">#{mobile},</if>
|
||||
|
@ -92,7 +104,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<update id="updateAbnormal" parameterType="Abnormal">
|
||||
update ss_abnormal
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="deviceNo != null">device_no = #{deviceNo},</if>
|
||||
<if test="deviceId != null">device_no = #{deviceId},</if>
|
||||
<if test="content != null and content != ''">content = #{content},</if>
|
||||
<if test="name != null">`name` = #{name},</if>
|
||||
<if test="mobile != null">mobile = #{mobile},</if>
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package com.ruoyi.ss.abnormal.service;
|
||||
|
||||
import com.ruoyi.ss.abnormal.domain.Abnormal;
|
||||
import com.ruoyi.ss.abnormal.domain.dto.AbnormalSubmitDTO;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2024/7/23
|
||||
*/
|
||||
public interface AbnormalConverter {
|
||||
|
||||
/**
|
||||
* 提交异常 DTO -> PO
|
||||
*/
|
||||
Abnormal toPo(AbnormalSubmitDTO dto);
|
||||
}
|
|
@ -12,7 +12,7 @@ import java.util.List;
|
|||
* @author ruoyi
|
||||
* @date 2024-04-30
|
||||
*/
|
||||
public interface IAbnormalService
|
||||
public interface AbnormalService
|
||||
{
|
||||
/**
|
||||
* 查询设备故障
|
||||
|
@ -61,4 +61,9 @@ public interface IAbnormalService
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteAbnormalByAbnormalId(Long abnormalId);
|
||||
|
||||
/**
|
||||
* 查询数量
|
||||
*/
|
||||
int selectCount(AbnormalQuery query);
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package com.ruoyi.ss.abnormal.service;
|
||||
|
||||
import com.ruoyi.common.core.domain.ValidateResult;
|
||||
import com.ruoyi.ss.abnormal.domain.AbnormalBO;
|
||||
import com.ruoyi.ss.abnormal.domain.dto.AbnormalSubmitDTO;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
|
@ -9,9 +9,4 @@ import com.ruoyi.ss.abnormal.domain.AbnormalBO;
|
|||
*/
|
||||
public interface AbnormalValidator {
|
||||
|
||||
/**
|
||||
* App端插入前校验
|
||||
*/
|
||||
ValidateResult preCreateByApp(AbnormalBO data);
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
package com.ruoyi.ss.abnormal.service.impl;
|
||||
|
||||
import com.ruoyi.common.utils.ServiceUtil;
|
||||
import com.ruoyi.ss.abnormal.domain.Abnormal;
|
||||
import com.ruoyi.ss.abnormal.domain.dto.AbnormalSubmitDTO;
|
||||
import com.ruoyi.ss.abnormal.domain.enums.AbnormalStatus;
|
||||
import com.ruoyi.ss.abnormal.service.AbnormalConverter;
|
||||
import com.ruoyi.ss.abnormal.service.AbnormalService;
|
||||
import com.ruoyi.ss.device.domain.vo.DeviceVO;
|
||||
import com.ruoyi.ss.device.service.DeviceService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2024/7/23
|
||||
*/
|
||||
@Service
|
||||
public class AbnormalConverterImpl implements AbnormalConverter {
|
||||
|
||||
@Autowired
|
||||
private AbnormalService abnormalService;
|
||||
|
||||
@Autowired
|
||||
private DeviceService deviceService;
|
||||
|
||||
@Override
|
||||
public Abnormal toPo(AbnormalSubmitDTO dto) {
|
||||
if (dto == null) {
|
||||
return null;
|
||||
}
|
||||
DeviceVO device = deviceService.selectByDeviceNo(dto.getDeviceNo());
|
||||
ServiceUtil.assertion(device == null, "设备不存在");
|
||||
|
||||
Abnormal po = new Abnormal();
|
||||
po.setUserId(dto.getUserId());
|
||||
po.setDeviceId(device.getDeviceId());
|
||||
po.setContent(dto.getContent());
|
||||
po.setName(dto.getName());
|
||||
po.setMobile(dto.getMobile());
|
||||
po.setAddress(dto.getAddress());
|
||||
po.setStatus(AbnormalStatus.UNREAD.getStatus());
|
||||
po.setCreateBy(dto.getCreateBy());
|
||||
return po;
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@ import com.ruoyi.ss.abnormal.domain.Abnormal;
|
|||
import com.ruoyi.ss.abnormal.domain.AbnormalQuery;
|
||||
import com.ruoyi.ss.abnormal.domain.AbnormalVO;
|
||||
import com.ruoyi.ss.abnormal.mapper.AbnormalMapper;
|
||||
import com.ruoyi.ss.abnormal.service.IAbnormalService;
|
||||
import com.ruoyi.ss.abnormal.service.AbnormalService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -18,7 +18,7 @@ import java.util.List;
|
|||
* @date 2024-04-30
|
||||
*/
|
||||
@Service
|
||||
public class AbnormalServiceImpl implements IAbnormalService
|
||||
public class AbnormalServiceImpl implements AbnormalService
|
||||
{
|
||||
@Autowired
|
||||
private AbnormalMapper abnormalMapper;
|
||||
|
@ -96,4 +96,9 @@ public class AbnormalServiceImpl implements IAbnormalService
|
|||
{
|
||||
return abnormalMapper.deleteAbnormalByAbnormalId(abnormalId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int selectCount(AbnormalQuery query) {
|
||||
return abnormalMapper.selectCount(query);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.ruoyi.ss.abnormal.service.impl;
|
|||
|
||||
import com.ruoyi.common.core.domain.BaseValidator;
|
||||
import com.ruoyi.common.core.domain.ValidateResult;
|
||||
import com.ruoyi.ss.abnormal.domain.AbnormalBO;
|
||||
import com.ruoyi.ss.abnormal.domain.dto.AbnormalSubmitDTO;
|
||||
import com.ruoyi.ss.abnormal.service.AbnormalValidator;
|
||||
import com.ruoyi.ss.device.service.DeviceValidator;
|
||||
import com.ruoyi.ss.device.service.DeviceService;
|
||||
|
@ -23,23 +23,4 @@ public class AbnormalValidatorImpl extends BaseValidator implements AbnormalVali
|
|||
|
||||
@Autowired
|
||||
private DeviceValidator deviceValidator;
|
||||
|
||||
/**
|
||||
* App端插入前校验
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
@Override
|
||||
public ValidateResult preCreateByApp(AbnormalBO data) {
|
||||
if (data == null) {
|
||||
return error("数据不能为空");
|
||||
}
|
||||
|
||||
// 判断设备是否存在
|
||||
if (!deviceValidator.isExistNo(Collections.singletonList(data.getDeviceNo()))) {
|
||||
return error("设备不存在");
|
||||
}
|
||||
|
||||
return success();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,15 +3,18 @@ package com.ruoyi.ss.device.domain;
|
|||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.constants.DictTypeConstants;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import com.ruoyi.common.core.domain.JsonViewProfile;
|
||||
import com.ruoyi.common.core.domain.ValidGroup;
|
||||
import com.ruoyi.system.valid.DictValid;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Past;
|
||||
import java.math.BigDecimal;
|
||||
|
@ -143,10 +146,15 @@ public class Device extends BaseEntity
|
|||
@JsonView(JsonViewProfile.App.class)
|
||||
private String customPicture;
|
||||
|
||||
@ApiModelProperty("服务费费率")
|
||||
@Range(min = 0, max = 100, message = "服务费费率必须在0-100之间")
|
||||
@ApiModelProperty("服务费")
|
||||
@Range(min = 0, message = "服务费不允许小于0")
|
||||
private BigDecimal serviceRate;
|
||||
|
||||
@ApiModelProperty("服务费类型")
|
||||
@NotBlank(message = "服务费类型不允许为空", groups = {ValidGroup.Create.class})
|
||||
@DictValid(type = DictTypeConstants.DEVICE_SERVICE_TYPE, message = "非法的服务费类型")
|
||||
private String serviceType;
|
||||
|
||||
@ApiModelProperty("剩余时长(秒)")
|
||||
private BigDecimal remainTime;
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ public class DeviceBO extends Device {
|
|||
bo.setDeviceName(getDeviceName());
|
||||
bo.setServiceRate(getServiceRate());
|
||||
bo.setRemark(getRemark());
|
||||
bo.setServiceType(getServiceType());
|
||||
return bo;
|
||||
}
|
||||
|
||||
|
@ -36,6 +37,7 @@ public class DeviceBO extends Device {
|
|||
bo.setDeviceName(getDeviceName());
|
||||
bo.setServiceRate(getServiceRate());
|
||||
bo.setRemark(getRemark());
|
||||
bo.setServiceType(getServiceType());
|
||||
return bo;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package com.ruoyi.ss.device.domain.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 设备服务费类型
|
||||
* @author wjh
|
||||
* 2024/7/23
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum DeviceServiceType {
|
||||
|
||||
PERCENT("1", "按订单比例"),
|
||||
MONTH("2", "月费");
|
||||
|
||||
private final String type;
|
||||
private final String msg;
|
||||
|
||||
|
||||
}
|
|
@ -175,4 +175,9 @@ public interface DeviceMapper
|
|||
DeviceVO selectOne(DeviceQuery query);
|
||||
|
||||
int batchUpdateModel(DeviceBatchUpdateModelDTO dto);
|
||||
|
||||
/**
|
||||
* 更新服务费
|
||||
*/
|
||||
int updateServiceRate(DeviceVO data);
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
<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 like concat('%', #{mac}, '%')</if>
|
||||
|
@ -91,6 +92,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
sd.service_rate,
|
||||
sd.remain_time,
|
||||
sd.user_id,
|
||||
sd.service_type,
|
||||
sm.model_name as model,
|
||||
sm.picture as picture,
|
||||
sm.tags as model_tags,
|
||||
|
@ -244,6 +246,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="serviceRate != null">service_rate,</if>
|
||||
<if test="remainTime != null">remain_time,</if>
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="serviceType != null">service_type,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="storeId != null">#{storeId},</if>
|
||||
|
@ -274,6 +277,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="serviceRate != null">#{serviceRate},</if>
|
||||
<if test="remainTime != null">#{remainTime},</if>
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="serviceType != null">#{serviceType},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
@ -325,6 +329,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="serviceRate != null">service_rate = #{serviceRate},</if>
|
||||
<if test="remainTime != null">remain_time = #{remainTime},</if>
|
||||
<if test="userId != null">user_id = #{userId},</if>
|
||||
<if test="serviceType != null">service_type = #{serviceType},</if>
|
||||
</trim>
|
||||
where device_id = #{deviceId}
|
||||
</update>
|
||||
|
@ -377,6 +382,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="lastPullTime != null">last_pull_time = #{lastPullTime},</if>
|
||||
<if test="powerStatus != null">power_status = #{powerStatus},</if>
|
||||
<if test="remainTime != null">remain_time = #{remainTime},</if>
|
||||
<if test="serviceType != null">service_type = #{serviceType},</if>
|
||||
</trim>
|
||||
where mac = #{mac}
|
||||
</update>
|
||||
|
@ -420,6 +426,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</foreach>
|
||||
</update>
|
||||
|
||||
<update id="updateServiceRate">
|
||||
update sm_device
|
||||
set service_rate = #{serviceRate}
|
||||
where device_id = #{deviceId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteSmDeviceByDeviceId" parameterType="Long">
|
||||
delete from sm_device where device_id = #{deviceId}
|
||||
</delete>
|
||||
|
|
|
@ -246,4 +246,9 @@ public interface DeviceService
|
|||
* 批量更新设备型号
|
||||
*/
|
||||
int batchUpdateModel(DeviceBatchUpdateModelDTO dto);
|
||||
|
||||
/**
|
||||
* 更新服务费
|
||||
*/
|
||||
int updateServiceRate(DeviceVO data);
|
||||
}
|
||||
|
|
|
@ -336,6 +336,11 @@ public class DeviceServiceImpl implements DeviceService
|
|||
return deviceMapper.batchUpdateModel(dto);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateServiceRate(DeviceVO data) {
|
||||
return deviceMapper.updateServiceRate(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean addTime(Long deviceId, long seconds, boolean withIot) {
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.math.BigDecimal;
|
|||
import java.time.LocalDateTime;
|
||||
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;
|
||||
|
@ -28,6 +29,10 @@ public class ReceiveBill extends BaseEntity
|
|||
@Excel(name = "用户ID")
|
||||
private Long userId;
|
||||
|
||||
/** 设备ID */
|
||||
@Excel(name = "设备ID")
|
||||
private Long deviceId;
|
||||
|
||||
/** 账单类型 */
|
||||
@Excel(name = "账单类型")
|
||||
private String type;
|
||||
|
@ -47,4 +52,7 @@ public class ReceiveBill extends BaseEntity
|
|||
/** 账单描述 */
|
||||
@Excel(name = "账单描述")
|
||||
private String description;
|
||||
|
||||
@ApiModelProperty("已收金额")
|
||||
private BigDecimal receivedAmount;
|
||||
}
|
||||
|
|
|
@ -16,4 +16,13 @@ public class ReceiveBillQuery extends ReceiveBill{
|
|||
@ApiModelProperty("月份")
|
||||
private Integer billMonth;
|
||||
|
||||
@ApiModelProperty("用户名称")
|
||||
private String userName;
|
||||
|
||||
@ApiModelProperty("设备名称")
|
||||
private String deviceName;
|
||||
|
||||
@ApiModelProperty("设备SN")
|
||||
private String deviceNo;;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.ruoyi.ss.receiveBill.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
|
@ -8,4 +9,14 @@ import lombok.Data;
|
|||
*/
|
||||
@Data
|
||||
public class ReceiveBillVO extends ReceiveBill{
|
||||
|
||||
@ApiModelProperty("用户名称")
|
||||
private String userName;
|
||||
|
||||
@ApiModelProperty("设备名称")
|
||||
private String deviceName;
|
||||
|
||||
@ApiModelProperty("设备SN")
|
||||
private String deviceNo;
|
||||
|
||||
}
|
||||
|
|
|
@ -11,9 +11,8 @@ import lombok.Getter;
|
|||
@AllArgsConstructor
|
||||
public enum ReceiveBillStatus {
|
||||
|
||||
WAIT_PAY("1", "待支付"),
|
||||
PAYING("2", "支付中"),
|
||||
PAID("3", "已支付"),
|
||||
UNPAID("1", "未付完"),
|
||||
PAID("2", "已付完"),
|
||||
;
|
||||
|
||||
private final String status;
|
||||
|
|
|
@ -65,5 +65,5 @@ public interface ReceiveBillMapper
|
|||
/**
|
||||
* 查询数量
|
||||
*/
|
||||
int selectCount(ReceiveBillQuery query);
|
||||
int selectCount(@Param("query") ReceiveBillQuery query);
|
||||
}
|
||||
|
|
|
@ -10,26 +10,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
select
|
||||
srb.bill_id,
|
||||
srb.user_id,
|
||||
srb.device_id,
|
||||
srb.type,
|
||||
srb.status,
|
||||
srb.bill_time,
|
||||
srb.amount,
|
||||
srb.description,
|
||||
srb.create_time
|
||||
srb.create_time,
|
||||
srb.received_amount,
|
||||
su.user_name as user_name,
|
||||
sd.device_name as device_name,
|
||||
sd.device_no as device_no
|
||||
from <include refid="selectTables"/>
|
||||
</sql>
|
||||
|
||||
<sql id="selectTables">
|
||||
ss_receive_bill srb
|
||||
left join sm_user su on su.user_id = srb.user_id
|
||||
left join sm_device sd on sd.device_id = srb.device_id
|
||||
</sql>
|
||||
|
||||
<sql id="searchCondition">
|
||||
<if test="query.billId != null "> and srb.bill_id = #{query.billId}</if>
|
||||
<if test="query.userId != null "> and srb.user_id = #{query.userId}</if>
|
||||
<if test="query.deviceId != null "> and srb.device_id = #{query.deviceId}</if>
|
||||
<if test="query.billYear != null "> and year(srb.bill_time) = #{query.billYear}</if>
|
||||
<if test="query.billMonth != null "> and month(srb.bill_time) = #{query.billMonth}</if>
|
||||
<if test="query.type != null and query.type != ''"> and srb.type = #{query.type}</if>
|
||||
<if test="query.status != null and query.status != ''"> and srb.status = #{query.status}</if>
|
||||
<if test="query.userName != null and query.userName != ''"> and su.user_name like concat('%', #{query.userName}, '%')</if>
|
||||
<if test="query.deviceName != null and query.deviceName != ''"> and sd.device_name like concat('%', #{query.deviceName}, '%')</if>
|
||||
<if test="query.deviceNo != null and query.deviceNo != ''"> and sd.device_no like concat('%', #{query.deviceNo}, '%')</if>
|
||||
<if test="query.description != null and query.description != ''"> and srb.description like concat('%', #{query.description}, '%')</if>
|
||||
</sql>
|
||||
|
||||
|
@ -57,21 +68,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
insert into ss_receive_bill
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="deviceId != null">device_id,</if>
|
||||
<if test="type != null and type != ''">type,</if>
|
||||
<if test="status != null and status != ''">`status`,</if>
|
||||
<if test="billTime != null">bill_time,</if>
|
||||
<if test="amount != null">amount,</if>
|
||||
<if test="description != null and description != ''">`description`,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="receivedAmount != null">received_amount,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="deviceId != null">#{deviceId},</if>
|
||||
<if test="type != null and type != ''">#{type},</if>
|
||||
<if test="status != null and status != ''">#{status},</if>
|
||||
<if test="billTime != null">#{billTime},</if>
|
||||
<if test="amount != null">#{amount},</if>
|
||||
<if test="description != null and description != ''">#{description},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="receivedAmount != null">#{receivedAmount},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
@ -79,12 +94,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
update ss_receive_bill
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="data.userId != null">user_id = #{data.userId},</if>
|
||||
<if test="data.deviceId != null">device_id = #{data.deviceId},</if>
|
||||
<if test="data.type != null and data.type != ''">type = #{data.type},</if>
|
||||
<if test="data.status != null and data.status != ''">`status` = #{data.status},</if>
|
||||
<if test="data.billTime != null">bill_time = #{data.billTime},</if>
|
||||
<if test="data.amount != null">amount = #{data.amount},</if>
|
||||
<if test="data.description != null and data.description != ''">`description` = #{data.description},</if>
|
||||
<if test="data.createTime != null">create_time = #{data.createTime},</if>
|
||||
<if test="data.receivedAmount != null">received_amount = #{data.receivedAmount},</if>
|
||||
</trim>
|
||||
where bill_id = #{billId}
|
||||
</update>
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package com.ruoyi.ss.receiveBill.service;
|
||||
|
||||
import java.time.YearMonth;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.ss.device.domain.vo.DeviceVO;
|
||||
import com.ruoyi.ss.receiveBill.domain.ReceiveBill;
|
||||
import com.ruoyi.ss.receiveBill.domain.ReceiveBillVO;
|
||||
import com.ruoyi.ss.receiveBill.domain.ReceiveBillQuery;
|
||||
|
@ -66,10 +69,12 @@ public interface ReceiveBillService
|
|||
/**
|
||||
* 月费商户出账
|
||||
*
|
||||
* @param user 用户ID
|
||||
* @param billMonth 出账日期
|
||||
* @param user 用户ID
|
||||
* @param device
|
||||
* @param billTime 出账日期
|
||||
* @param amount
|
||||
*/
|
||||
int genBillByMonth(SmUserVo user, YearMonth billMonth);
|
||||
int genBillByMonthAndPay(SmUserVo user, DeviceVO device, LocalDateTime billTime, BigDecimal amount);
|
||||
|
||||
/**
|
||||
* 查询数量
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
package com.ruoyi.ss.receiveBill.service.impl;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.YearMonth;
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.ServiceUtil;
|
||||
import com.ruoyi.ss.device.domain.vo.DeviceVO;
|
||||
import com.ruoyi.ss.receiveBill.domain.enums.ReceiveBillStatus;
|
||||
import com.ruoyi.ss.receiveBill.domain.enums.ReceiveBillType;
|
||||
import com.ruoyi.ss.transactionBill.service.impl.TransactionBillServiceImpl;
|
||||
import com.ruoyi.ss.user.domain.SmUserVo;
|
||||
import com.ruoyi.ss.user.service.ISmUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -18,6 +19,7 @@ import com.ruoyi.ss.receiveBill.domain.ReceiveBill;
|
|||
import com.ruoyi.ss.receiveBill.domain.ReceiveBillVO;
|
||||
import com.ruoyi.ss.receiveBill.domain.ReceiveBillQuery;
|
||||
import com.ruoyi.ss.receiveBill.service.ReceiveBillService;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
/**
|
||||
* 应收账单Service业务层处理
|
||||
|
@ -33,6 +35,10 @@ public class ReceiveBillServiceImpl implements ReceiveBillService
|
|||
|
||||
@Autowired
|
||||
private ISmUserService userService;
|
||||
@Autowired
|
||||
private TransactionBillServiceImpl transactionBillService;
|
||||
@Autowired
|
||||
private TransactionTemplate transactionTemplate;
|
||||
|
||||
/**
|
||||
* 查询应收账单
|
||||
|
@ -108,16 +114,18 @@ public class ReceiveBillServiceImpl implements ReceiveBillService
|
|||
}
|
||||
|
||||
@Override
|
||||
public int genBillByMonth(SmUserVo user, YearMonth billMonth) {
|
||||
public int genBillByMonthAndPay(SmUserVo user, DeviceVO device, LocalDateTime billTime, BigDecimal amount) {
|
||||
ServiceUtil.assertion(user == null || user.getUserId() == null, "用户不存在");
|
||||
ServiceUtil.assertion(billMonth == null, "请指定一个月份");
|
||||
ServiceUtil.assertion(device == null || device.getDeviceId() == null, "设备不存在");
|
||||
ServiceUtil.assertion(billTime == null, "请指定一个月份");
|
||||
|
||||
// 查询指定月份是否已出账
|
||||
ReceiveBillQuery query = new ReceiveBillQuery();
|
||||
query.setBillYear(billMonth.getYear());
|
||||
query.setBillMonth(billMonth.getMonthValue());
|
||||
query.setBillYear(billTime.getYear());
|
||||
query.setBillMonth(billTime.getMonthValue());
|
||||
query.setType(ReceiveBillType.MONTH.getType());
|
||||
query.setUserId(user.getUserId());
|
||||
query.setDeviceId(device.getDeviceId());
|
||||
int count = this.selectCount(query);
|
||||
if ( count > 0) {
|
||||
return count;
|
||||
|
@ -126,16 +134,28 @@ public class ReceiveBillServiceImpl implements ReceiveBillService
|
|||
// 若未出账则生成账单
|
||||
ReceiveBill bill = new ReceiveBill();
|
||||
bill.setUserId(user.getUserId());
|
||||
bill.setDeviceId(device.getDeviceId());
|
||||
bill.setType(ReceiveBillType.MONTH.getType());
|
||||
bill.setStatus(ReceiveBillStatus.WAIT_PAY.getStatus());
|
||||
bill.setBillTime(LocalDateTime.of(LocalDate.of(billMonth.getYear(), billMonth.getMonthValue(), 1), LocalTime.MIN));
|
||||
bill.setAmount(user.getServiceRate());
|
||||
bill.setDescription(String.format("%s年%s月-月费", billMonth.getYear(), billMonth.getMonthValue()));
|
||||
return this.insertReceiveBill(bill);
|
||||
bill.setStatus(ReceiveBillStatus.PAID.getStatus());
|
||||
bill.setBillTime(billTime);
|
||||
bill.setAmount(amount);
|
||||
bill.setDescription(String.format("%s年%s月-设备%s月费", billTime.getYear(), billTime.getMonthValue(), device.getDeviceNo()));
|
||||
bill.setReceivedAmount(amount);
|
||||
Integer result = transactionTemplate.execute(status -> {
|
||||
// 用户余额扣减
|
||||
int subtract = userService.subtractBalance(user.getUserId(), amount, false, bill.getDescription());
|
||||
ServiceUtil.assertion(subtract != 1, "扣减商户余额失败");
|
||||
|
||||
// 插入账单
|
||||
return this.insertReceiveBill(bill);
|
||||
});
|
||||
|
||||
return result == null ? 0 : result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int selectCount(ReceiveBillQuery query) {
|
||||
return receiveBillMapper.selectCount(query);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -48,4 +48,13 @@ public class Refund extends BaseEntity
|
|||
|
||||
@ApiModelProperty("手续费退款金额")
|
||||
private BigDecimal serviceAmount;
|
||||
|
||||
@ApiModelProperty("操作人类型")
|
||||
private String userType;
|
||||
|
||||
@ApiModelProperty("操作人名称")
|
||||
private String userName;
|
||||
|
||||
@ApiModelProperty("操作人ID")
|
||||
private Long userId;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
sr.reason,
|
||||
sr.mch_amount,
|
||||
sr.service_amount,
|
||||
sr.user_type,
|
||||
sr.user_id,
|
||||
sr.user_name,
|
||||
smb.money as bill_amount,
|
||||
smb.bill_no as bill_no
|
||||
from ss_refund sr
|
||||
|
@ -28,6 +31,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="query.refundNo != null and query.refundNo != ''"> and sr.refund_no = #{query.refundNo}</if>
|
||||
<if test="query.billId != null "> and sr.bill_id = #{query.billId}</if>
|
||||
<if test="query.status != null and query.status != ''"> and sr.status = #{query.status}</if>
|
||||
<if test="query.userType != null and query.userType != ''"> and user_type = #{query.userType}</if>
|
||||
<if test="query.userId != null "> and user_id = #{query.userId}</if>
|
||||
<if test="query.userName != null and query.userName != ''"> and user_name like concat('%', #{query.userName}, '%')</if>
|
||||
</sql>
|
||||
|
||||
<select id="selectRefundList" parameterType="Refund" resultMap="RefundResult">
|
||||
|
@ -62,6 +68,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="reason != null and reason != ''">`reason`,</if>
|
||||
<if test="mchAmount != null">mch_amount,</if>
|
||||
<if test="serviceAmount != null">service_amount,</if>
|
||||
<if test="userType != null">user_type,</if>
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="userName != null">user_name,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="refundNo != null and refundNo != ''">#{refundNo},</if>
|
||||
|
@ -72,6 +81,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="reason != null and reason != ''">#{reason},</if>
|
||||
<if test="mchAmount != null">#{mchAmount},</if>
|
||||
<if test="serviceAmount != null">#{serviceAmount},</if>
|
||||
<if test="userType != null">#{userType},</if>
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="userName != null">#{userName},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
@ -92,6 +104,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="data.createTime != null">create_time = #{data.createTime},</if>
|
||||
<if test="data.status != null and data.status != ''">`status` = #{data.status},</if>
|
||||
<if test="data.reason != null and data.reason != ''">`reason` = #{data.reason},</if>
|
||||
<if test="data.userType != null">user_type = #{data.userType},</if>
|
||||
<if test="data.userId != null">user_id = #{data.userId},</if>
|
||||
<if test="data.userName != null">user_name = #{data.userName},</if>
|
||||
</sql>
|
||||
|
||||
<update id="updateByQuery">
|
||||
|
|
|
@ -46,6 +46,9 @@ public class RefundConverterImpl implements RefundConverter {
|
|||
refund.setReason(String.format("充值订单%s退款", bill.getBillNo()));
|
||||
refund.setMchAmount(refundMchAmount);
|
||||
refund.setServiceAmount(refundServiceAmount);
|
||||
refund.setUserType(dto.getUserType());
|
||||
refund.setUserName(dto.getUserName());
|
||||
refund.setUserId(dto.getUserId());
|
||||
return refund;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,10 +56,10 @@ public interface IStoreService
|
|||
|
||||
/**
|
||||
* 查询商户下的设备及其设备数量
|
||||
* @param store 查询条件
|
||||
* @param query 查询条件
|
||||
* @return 设备列表
|
||||
*/
|
||||
List<StoreVo> listCount(StoreQuery store);
|
||||
List<StoreVo> listCount(StoreQuery query);
|
||||
|
||||
/**
|
||||
* 查询用户的默认商户
|
||||
|
|
|
@ -141,7 +141,7 @@ public class StoreServiceImpl implements IStoreService
|
|||
|
||||
// 查询全部设备数据
|
||||
DeviceQuery deviceDto = new DeviceQuery();
|
||||
deviceDto.setStoreIds(storeList.stream().map(StoreVo::getStoreId).collect(Collectors.toList()));
|
||||
deviceDto.setUserId(query.getUserId());
|
||||
int count = smDeviceService.selectCount(deviceDto);
|
||||
StoreVo all = new StoreVo();
|
||||
all.setDeviceCount(count);
|
||||
|
|
|
@ -24,4 +24,12 @@ public class BillRefundDTO {
|
|||
@Min(value = 0, message = "退款金额不允许小于0")
|
||||
private BigDecimal refundAmount;
|
||||
|
||||
@ApiModelProperty("退款操作人类型")
|
||||
private String userType;
|
||||
|
||||
@ApiModelProperty("退款操作人名称")
|
||||
private String userName;
|
||||
|
||||
@ApiModelProperty("退款操作人ID")
|
||||
private Long userId;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.ruoyi.ss.account.service.ISmAccountService;
|
|||
import com.ruoyi.ss.channel.domain.SmChannel;
|
||||
import com.ruoyi.ss.channel.service.ISmChannelService;
|
||||
import com.ruoyi.ss.dashboard.BillCountVo;
|
||||
import com.ruoyi.ss.device.domain.enums.DeviceServiceType;
|
||||
import com.ruoyi.ss.device.domain.vo.DeviceVO;
|
||||
import com.ruoyi.ss.device.service.DeviceService;
|
||||
import com.ruoyi.ss.receiveBill.service.ReceiveBillService;
|
||||
|
@ -52,9 +53,7 @@ import org.springframework.transaction.support.TransactionTemplate;
|
|||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.YearMonth;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
@ -240,20 +239,45 @@ public class TransactionBillServiceImpl implements TransactionBillService {
|
|||
SmUserVo mch = userService.selectSmUserByUserId(order.getMchId());
|
||||
ServiceUtil.assertion(mch == null, "商户不存在,不允许下单");
|
||||
|
||||
BigDecimal serviceCharge = BigDecimal.ZERO; // 订单服务费
|
||||
BigDecimal arrivalAmount = order.getMoney();// 订单商户到账金额
|
||||
DeviceVO device = deviceService.selectSmDeviceByDeviceId(order.getDeviceId());
|
||||
ServiceUtil.assertion(device == null, "设备不存在,不允许下单");
|
||||
|
||||
// 月费商户才出账
|
||||
if (UserServiceType.MONTH.getType().equals(mch.getServiceType())) {
|
||||
int count = receiveBillService.genBillByMonth(mch, YearMonth.now());
|
||||
ServiceUtil.assertion(count == 0, "商户出账失败,请刷新后重试");
|
||||
BigDecimal serviceRate = BigDecimal.ZERO; // 服务费比例
|
||||
|
||||
// 优先级: 设备 > 商户 > 渠道
|
||||
if (device.getServiceRate() != null) {
|
||||
// 设备月费
|
||||
if (DeviceServiceType.MONTH.getType().equals(device.getServiceType())) {
|
||||
int count = receiveBillService.genBillByMonthAndPay(mch, device, LocalDateTime.now(), device.getServiceRate());
|
||||
ServiceUtil.assertion(count == 0, "商户出账失败,请刷新后重试");
|
||||
}
|
||||
// 设备订单比例
|
||||
else {
|
||||
serviceRate = device.getServiceRate();
|
||||
}
|
||||
}
|
||||
// 其他一律为收取服务费
|
||||
// 用户
|
||||
else if (mch.getServiceRate() != null) {
|
||||
// 用户月费
|
||||
if (UserServiceType.MONTH.getType().equals(mch.getServiceType())) {
|
||||
int count = receiveBillService.genBillByMonthAndPay(mch, device, LocalDateTime.now(), mch.getServiceRate());
|
||||
ServiceUtil.assertion(count == 0, "商户出账失败,请刷新后重试");
|
||||
|
||||
}
|
||||
// 用户服务费
|
||||
else {
|
||||
serviceRate = mch.getServiceRate();
|
||||
}
|
||||
}
|
||||
// 渠道
|
||||
else {
|
||||
BigDecimal serviceRate = this.getServiceRate(order.getDeviceId(), order.getChannelId());
|
||||
serviceCharge = serviceRate.multiply(order.getMoney()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP); // 服务费
|
||||
arrivalAmount = order.getMoney().subtract(serviceCharge); // 商户最终到账的金额 = 交易金额 - 服务费
|
||||
SmChannel channel = channelService.selectSmChannelByChannelId(order.getChannelId());
|
||||
ServiceUtil.assertion(channel == null, "支付渠道不存在");
|
||||
serviceRate = channel.getServiceRate();
|
||||
}
|
||||
|
||||
BigDecimal serviceCharge = serviceRate.multiply(order.getMoney()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP); // 服务费
|
||||
BigDecimal arrivalAmount = order.getMoney().subtract(serviceCharge); // 商户最终到账的金额 = 交易金额 - 服务费
|
||||
order.setArrivalAmount(arrivalAmount);
|
||||
order.setServiceCharge(serviceCharge);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import lombok.Getter;
|
|||
@AllArgsConstructor
|
||||
public enum UserServiceType {
|
||||
|
||||
PERCENT("1", "百分比抽成"),
|
||||
PERCENT("1", "按订单比例"),
|
||||
MONTH("2", "月费");
|
||||
|
||||
private final String type;
|
||||
|
|
|
@ -57,6 +57,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="userId != null"> and su.user_id = #{userId}</if>
|
||||
<if test="delFlag == null"> and su.del_flag = '0'</if>
|
||||
<if test="delFlag != null"> and su.del_flag = #{delFlag}</if>
|
||||
<if test="remark != null and remark != ''"> and su.remark like concat('%', #{remark}, '%')</if>
|
||||
<if test="tenantDeviceId != null">
|
||||
and su.user_id in (
|
||||
select sdt.tenant_id
|
||||
|
|
|
@ -126,8 +126,9 @@ public interface ISmUserService
|
|||
* @param amount 金额
|
||||
* @param check 是否校验余额是否充足
|
||||
* @param reason 原因
|
||||
* @return
|
||||
*/
|
||||
void subtractBalance(Long userId, BigDecimal amount, boolean check, String reason);
|
||||
int subtractBalance(Long userId, BigDecimal amount, boolean check, String reason);
|
||||
|
||||
/**
|
||||
* 修改微信OpenId
|
||||
|
|
|
@ -143,7 +143,7 @@ public class SmUserServiceImpl implements ISmUserService
|
|||
|
||||
@Override
|
||||
@Transactional
|
||||
public void subtractBalance(Long userId, BigDecimal amount, boolean check, String reason) {
|
||||
public int subtractBalance(Long userId, BigDecimal amount, boolean check, String reason) {
|
||||
ServiceUtil.assertion(BigDecimal.ZERO.compareTo(amount) > 0, "减少的金额需要大于0");
|
||||
|
||||
// 查询用户
|
||||
|
@ -156,6 +156,8 @@ public class SmUserServiceImpl implements ISmUserService
|
|||
// 余额变动记录
|
||||
int record = recordBalanceService.record(userId, user.getBalance(), amount, reason);
|
||||
ServiceUtil.assertion(record != 1, "用户余额变动记录失败");
|
||||
|
||||
return updateCount;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -5,10 +5,11 @@ import com.ruoyi.common.core.domain.AjaxResult;
|
|||
import com.ruoyi.common.core.domain.ValidGroup;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.utils.ServiceUtil;
|
||||
import com.ruoyi.ss.abnormal.domain.AbnormalBO;
|
||||
import com.ruoyi.ss.abnormal.domain.dto.AbnormalSubmitDTO;
|
||||
import com.ruoyi.ss.abnormal.domain.AbnormalQuery;
|
||||
import com.ruoyi.ss.abnormal.service.AbnormalConverter;
|
||||
import com.ruoyi.ss.abnormal.service.AbnormalValidator;
|
||||
import com.ruoyi.ss.abnormal.service.IAbnormalService;
|
||||
import com.ruoyi.ss.abnormal.service.AbnormalService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -25,18 +26,20 @@ import org.springframework.web.bind.annotation.*;
|
|||
public class AppAbnormalController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IAbnormalService abnormalService;
|
||||
private AbnormalService abnormalService;
|
||||
|
||||
@Autowired
|
||||
private AbnormalValidator abnormalValidator;
|
||||
|
||||
@Autowired
|
||||
private AbnormalConverter abnormalConverter;
|
||||
|
||||
@ApiOperation("提交设备故障反馈")
|
||||
@PostMapping("/submit")
|
||||
public AjaxResult submit(@RequestBody @Validated(ValidGroup.FrontCreate.class) AbnormalBO data) {
|
||||
public AjaxResult submit(@RequestBody @Validated(ValidGroup.FrontCreate.class) AbnormalSubmitDTO data) {
|
||||
data.setUserId(getUserId());
|
||||
data = data.filterCreateByApp();
|
||||
ServiceUtil.assertion(abnormalValidator.preCreateByApp(data));
|
||||
return success(abnormalService.insertAbnormal(data));
|
||||
data.setCreateBy(getUsername());
|
||||
return success(abnormalService.insertAbnormal(abnormalConverter.toPo(data)));
|
||||
}
|
||||
|
||||
@ApiOperation("获取本人提交的故障反馈列表")
|
||||
|
|
|
@ -109,9 +109,9 @@ public class AppStoreController extends BaseController {
|
|||
@GetMapping("/listCount")
|
||||
@JsonView(StoreView.ListCount.class)
|
||||
public AjaxResult listCount() {
|
||||
StoreQuery store = new StoreQuery();
|
||||
store.setUserId(getUserId());
|
||||
return AjaxResult.success(storeService.listCount(store));
|
||||
StoreQuery query = new StoreQuery();
|
||||
query.setUserId(getUserId());
|
||||
return AjaxResult.success(storeService.listCount(query));
|
||||
}
|
||||
|
||||
@ApiOperation("获取附近的店铺")
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.ruoyi.common.core.controller.BaseController;
|
|||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.JsonViewProfile;
|
||||
import com.ruoyi.common.core.domain.ValidGroup;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.ServiceUtil;
|
||||
|
@ -221,6 +222,10 @@ public class AppTransactionBillController extends BaseController
|
|||
if (!Objects.equals(bill.getMchId(), getUserId())) {
|
||||
return error("您无权操作退款");
|
||||
}
|
||||
LoginUser loginUser = getLoginUser();
|
||||
dto.setUserName(loginUser.getUsername());
|
||||
dto.setUserType(loginUser.getLoginType().getType());
|
||||
dto.setUserId(getUserId());
|
||||
return toAjax(smTransactionBillService.refund(dto));
|
||||
}
|
||||
|
||||
|
|
|
@ -5,22 +5,19 @@ import javax.servlet.http.HttpServletResponse;
|
|||
|
||||
import com.ruoyi.ss.abnormal.domain.AbnormalQuery;
|
||||
import com.ruoyi.ss.abnormal.domain.AbnormalVO;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
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.abnormal.domain.Abnormal;
|
||||
import com.ruoyi.ss.abnormal.service.IAbnormalService;
|
||||
import com.ruoyi.ss.abnormal.service.AbnormalService;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
|
@ -35,7 +32,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
|
|||
public class AbnormalController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IAbnormalService abnormalService;
|
||||
private AbnormalService abnormalService;
|
||||
|
||||
/**
|
||||
* 查询设备故障列表
|
||||
|
@ -71,4 +68,11 @@ public class AbnormalController extends BaseController
|
|||
{
|
||||
return success(abnormalService.selectAbnormalByAbnormalId(abnormalId));
|
||||
}
|
||||
|
||||
@ApiOperation("查询故障数量")
|
||||
@GetMapping("/count")
|
||||
public AjaxResult getCount(AbnormalQuery query) {
|
||||
return success(abnormalService.selectCount(query));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -82,9 +82,7 @@ public class SmDeviceController extends BaseController
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:device:query')")
|
||||
@GetMapping(value = "/{deviceId}")
|
||||
public AjaxResult getInfo(@PathVariable("deviceId") Long deviceId)
|
||||
{
|
||||
smDeviceService.pullDeviceInfo(Collections.singletonList(deviceId));
|
||||
public AjaxResult getInfo(@PathVariable("deviceId") Long deviceId) {
|
||||
DeviceVO device = smDeviceService.selectSmDeviceByDeviceId(deviceId);
|
||||
List<DeviceVO> list = Collections.singletonList(device);
|
||||
deviceAssembler.assembleIotDeviceInfo(list);
|
||||
|
@ -136,6 +134,7 @@ public class SmDeviceController extends BaseController
|
|||
}
|
||||
|
||||
@ApiOperation("刷新设备信息")
|
||||
@Log(title = "设备", businessType = BusinessType.UPDATE)
|
||||
@GetMapping("/{deviceId}/refreshIot")
|
||||
public AjaxResult syncIot(@PathVariable @ApiParam("设备id") Long deviceId) {
|
||||
smDeviceService.pullDeviceInfo(Collections.singletonList(deviceId));
|
||||
|
@ -144,6 +143,7 @@ public class SmDeviceController extends BaseController
|
|||
|
||||
@ApiOperation("绑定SN码")
|
||||
@PreAuthorize("@ss.hasPermi('system:device:bindSn')")
|
||||
@Log(title = "设备", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/{deviceId}/bindSn/{sn}")
|
||||
public AjaxResult bindSn(@PathVariable @ApiParam("设备ID") Long deviceId, @PathVariable @ApiParam("SN") String sn) {
|
||||
return success(smDeviceService.bindSn(deviceId, sn));
|
||||
|
@ -151,6 +151,7 @@ public class SmDeviceController extends BaseController
|
|||
|
||||
@ApiOperation("设备充值时长")
|
||||
@PreAuthorize("@ss.hasPermi('system:device:addTime')")
|
||||
@Log(title = "设备", businessType = BusinessType.OTHER)
|
||||
@PutMapping("/addTime/{deviceId}")
|
||||
public AjaxResult addTime(@PathVariable @ApiParam("设备id") Long deviceId, @ApiParam("时长(分)") Long amount) {
|
||||
return toAjax(smDeviceService.addTimeByUser(deviceId, amount * 60, true, "管理员手动充值"));
|
||||
|
@ -158,6 +159,7 @@ public class SmDeviceController extends BaseController
|
|||
|
||||
@ApiOperation("设备时长归零")
|
||||
@PreAuthorize("@ss.hasPermi('system:device:reset')")
|
||||
@Log(title = "设备", businessType = BusinessType.OTHER)
|
||||
@PutMapping("/{deviceId}/reset")
|
||||
public AjaxResult reset(@PathVariable @ApiParam("设备id") Long deviceId) {
|
||||
return success(smDeviceService.reset(deviceId));
|
||||
|
@ -165,6 +167,7 @@ public class SmDeviceController extends BaseController
|
|||
|
||||
@ApiOperation("设备开关")
|
||||
@PreAuthorize("@ss.hasPermi('system:device:switch')")
|
||||
@Log(title = "设备", businessType = BusinessType.OTHER)
|
||||
@PutMapping("/{deviceId}/switch")
|
||||
public AjaxResult switchDevice(@PathVariable Long deviceId, @RequestParam Boolean open) {
|
||||
return toAjax(smDeviceService.switchDevice(deviceId, open));
|
||||
|
@ -172,6 +175,7 @@ public class SmDeviceController extends BaseController
|
|||
|
||||
@ApiOperation("设备批量修改型号")
|
||||
@PreAuthorize("@ss.hasPermi('system:device:edit')")
|
||||
@Log(title = "设备", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/batchUpdateModel")
|
||||
public AjaxResult batchUpdateModel(@RequestBody @Validated DeviceBatchUpdateModelDTO dto) {
|
||||
return success(smDeviceService.batchUpdateModel(dto));
|
||||
|
@ -179,8 +183,17 @@ public class SmDeviceController extends BaseController
|
|||
|
||||
@ApiOperation("解除设备绑定")
|
||||
@PreAuthorize("@ss.hasPermi('system:device:unbind')")
|
||||
@Log(title = "设备", businessType = BusinessType.OTHER)
|
||||
@DeleteMapping("/{deviceId}/unbind")
|
||||
public AjaxResult unbind(@PathVariable @ApiParam("设备id") Long deviceId) {
|
||||
return toAjax(smDeviceService.unbind(deviceId));
|
||||
}
|
||||
|
||||
@ApiOperation("修改服务费")
|
||||
@PreAuthorize("@ss.hasPermi('system:device:edit')")
|
||||
@Log(title = "设备", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/updateServiceRate")
|
||||
public AjaxResult updateServiceRate(@RequestBody @Validated DeviceVO data) {
|
||||
return toAjax(smDeviceService.updateServiceRate(data));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
import java.util.Objects;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.ss.transactionBill.domain.bo.TransactionBillBO;
|
||||
import com.ruoyi.ss.transactionBill.domain.TransactionBillQuery;
|
||||
import com.ruoyi.ss.transactionBill.domain.TransactionBillVo;
|
||||
|
@ -167,6 +168,10 @@ public class SmTransactionBillController extends BaseController
|
|||
@PutMapping("/refund")
|
||||
@PreAuthorize("@ss.hasPermi('system:bill:refund')")
|
||||
public AjaxResult refund(@RequestBody @Validated BillRefundDTO dto) {
|
||||
LoginUser loginUser = getLoginUser();
|
||||
dto.setUserName(loginUser.getUsername());
|
||||
dto.setUserType(loginUser.getLoginType().getType());
|
||||
dto.setUserId(getUserId());
|
||||
return toAjax(smTransactionBillService.refund(dto));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user