商户订单统计
This commit is contained in:
parent
085050cbdc
commit
c35a60695c
|
@ -0,0 +1,39 @@
|
|||
package com.ruoyi.system.mapper.typehandler;
|
||||
|
||||
import org.apache.ibatis.type.BaseTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* 非空Integer类型处理器,为空时,返回0
|
||||
* @author wjh
|
||||
* 2024/4/12
|
||||
*/
|
||||
public class NonNullLongTyperHandler extends BaseTypeHandler<Long> {
|
||||
|
||||
@Override
|
||||
public void setNonNullParameter(PreparedStatement ps, int i, Long parameter, JdbcType jdbcType) throws SQLException {
|
||||
ps.setLong(i, parameter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getNullableResult(ResultSet rs, String columnName)
|
||||
throws SQLException {
|
||||
return rs.getLong(columnName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
|
||||
return rs.getLong(columnIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getNullableResult(CallableStatement cs, int columnIndex)
|
||||
throws SQLException {
|
||||
return cs.getLong(columnIndex);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package com.ruoyi.dashboard.domain.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2024/10/8
|
||||
*/
|
||||
@Data
|
||||
public class BusinessStatisticsQuery {
|
||||
|
||||
@ApiModelProperty("日期范围")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private List<LocalDate> dateRange;
|
||||
|
||||
@ApiModelProperty("商户ID")
|
||||
private Long mchId;
|
||||
|
||||
@ApiModelProperty("店铺ID")
|
||||
private Long storeId;
|
||||
|
||||
@ApiModelProperty("订单状态")
|
||||
private List<String> billStatusList;
|
||||
|
||||
@ApiModelProperty("订单类型")
|
||||
private String billType;
|
||||
|
||||
@ApiModelProperty("店铺名称")
|
||||
private String storeName;
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.ruoyi.ss.dashboard;
|
||||
package com.ruoyi.dashboard.domain.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
|
@ -1,4 +1,4 @@
|
|||
package com.ruoyi.ss.dashboard.vo;
|
||||
package com.ruoyi.dashboard.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
@ -1,4 +1,4 @@
|
|||
package com.ruoyi.ss.dashboard.vo;
|
||||
package com.ruoyi.dashboard.domain.vo;
|
||||
|
||||
import com.ruoyi.ss.businessRecord.domain.SmBusinessRecordVo;
|
||||
import lombok.Data;
|
|
@ -0,0 +1,39 @@
|
|||
package com.ruoyi.dashboard.domain.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2024/10/8
|
||||
*/
|
||||
@Data
|
||||
public class BusinessStatisticsVO {
|
||||
|
||||
@ApiModelProperty("店铺ID")
|
||||
private Long storeId;
|
||||
|
||||
@ApiModelProperty("店铺名称")
|
||||
private String storeName;
|
||||
|
||||
@ApiModelProperty("设备名称")
|
||||
private String deviceName;
|
||||
|
||||
@ApiModelProperty("设备数量")
|
||||
private Integer deviceCount;
|
||||
|
||||
@ApiModelProperty("订单数量")
|
||||
private Integer orderCount;
|
||||
|
||||
@ApiModelProperty("总时长(秒)")
|
||||
private BigDecimal seconds;
|
||||
|
||||
@ApiModelProperty("总电量(度)")
|
||||
private BigDecimal ele;
|
||||
|
||||
@ApiModelProperty("收入总金额")
|
||||
private BigDecimal arrivalAmount;
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.ruoyi.ss.dashboard.vo;
|
||||
package com.ruoyi.dashboard.domain.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
|
@ -1,4 +1,4 @@
|
|||
package com.ruoyi.ss.dashboard.vo;
|
||||
package com.ruoyi.dashboard.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.ruoyi.dashboard.vo;
|
||||
package com.ruoyi.dashboard.domain.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
|
@ -0,0 +1,19 @@
|
|||
package com.ruoyi.dashboard.mapper;
|
||||
|
||||
import com.ruoyi.dashboard.domain.dto.BusinessStatisticsQuery;
|
||||
import com.ruoyi.dashboard.domain.vo.BusinessStatisticsVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2024/10/8
|
||||
*/
|
||||
public interface DashboardMapper {
|
||||
|
||||
List<BusinessStatisticsVO> selectBusinessStatisticsByStore(BusinessStatisticsQuery query);
|
||||
|
||||
List<BusinessStatisticsVO> selectBusinessStatisticsByDevice(BusinessStatisticsQuery query);
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
<?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.dashboard.mapper.DashboardMapper">
|
||||
|
||||
<resultMap id="BusinessStatisticsStoreVO" type="BusinessStatisticsVO" autoMapping="true">
|
||||
<result property="deviceCount" column="device_count" typeHandler="com.ruoyi.system.mapper.typehandler.NonNullIntegerTyperHandler"/>
|
||||
<result property="orderCount" column="order_count" typeHandler="com.ruoyi.system.mapper.typehandler.NonNullIntegerTyperHandler"/>
|
||||
<result property="seconds" column="seconds" typeHandler="com.ruoyi.system.mapper.typehandler.NonNullDecimalTypeHandler"/>
|
||||
<result property="ele" column="ele" typeHandler="com.ruoyi.system.mapper.typehandler.NonNullDecimalTypeHandler"/>
|
||||
<result property="arrivalAmount" column="arrival_amount" typeHandler="com.ruoyi.system.mapper.typehandler.NonNullDecimalTypeHandler"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<sql id="selectBusinessStatisticsVO">
|
||||
select
|
||||
stb.store_id,
|
||||
if (stb.store_id is null, '未分配店铺', ss.name) as store_name,
|
||||
count(distinct stb.device_id) as device_count,
|
||||
sd.device_name as device_name,
|
||||
count(stb.bill_id) as order_count,
|
||||
sum(if(stb.suit_fee_type in ('1', '4'), timestampdiff(second, stb.suit_start_time, stb.suit_end_time), 0)) as `seconds`,
|
||||
sum(if(stb.suit_fee_type in ('2', '3'), stb.suit_end_ele - stb.suit_start_ele, 0)) as `ele`,
|
||||
sum(stb.arrival_amount) as arrival_amount
|
||||
from sm_transaction_bill stb
|
||||
left join sm_store ss on ss.store_id = stb.store_id
|
||||
left join sm_device sd on sd.device_id = stb.device_id
|
||||
<where>
|
||||
<if test="mchId != null">and stb.mch_id = #{mchId}</if>
|
||||
<if test="storeId != null">and stb.store_id = #{storeId}</if>
|
||||
<if test="billType != null">and stb.type = #{billType}</if>
|
||||
<if test="storeName != null and storeName != ''">and ss.name like concat('%', #{storeName}, '%')</if>
|
||||
<if test="dateRange != null and dateRange.size() == 2">
|
||||
and date(stb.create_time) >= #{dateRange[0]} and date(stb.create_time) <= #{dateRange[1]}
|
||||
</if>
|
||||
<if test="billStatusList != null and billStatusList.size() > 0">
|
||||
and stb.status in
|
||||
<foreach collection="billStatusList" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<select id="selectBusinessStatisticsByStore" resultMap="BusinessStatisticsStoreVO">
|
||||
<include refid="selectBusinessStatisticsVO"/>
|
||||
group by stb.store_id
|
||||
</select>
|
||||
|
||||
<select id="selectBusinessStatisticsByDevice" resultMap="BusinessStatisticsStoreVO">
|
||||
<include refid="selectBusinessStatisticsVO"/>
|
||||
group by stb.store_id, stb.device_id
|
||||
</select>
|
||||
</mapper>
|
|
@ -1,8 +1,11 @@
|
|||
package com.ruoyi.dashboard;
|
||||
package com.ruoyi.dashboard.service;
|
||||
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||
import com.ruoyi.dashboard.vo.TodoListVO;
|
||||
import com.ruoyi.dashboard.domain.dto.BusinessStatisticsQuery;
|
||||
import com.ruoyi.dashboard.domain.vo.BusinessStatisticsVO;
|
||||
import com.ruoyi.dashboard.domain.vo.TodoListVO;
|
||||
import com.ruoyi.dashboard.mapper.DashboardMapper;
|
||||
import com.ruoyi.ss.abnormal.domain.AbnormalQuery;
|
||||
import com.ruoyi.ss.abnormal.domain.enums.AbnormalStatus;
|
||||
import com.ruoyi.ss.abnormal.service.AbnormalService;
|
||||
|
@ -12,8 +15,8 @@ import com.ruoyi.ss.bonus.domain.vo.BonusDailyAmountVO;
|
|||
import com.ruoyi.ss.bonus.service.BonusService;
|
||||
import com.ruoyi.ss.complaint.domain.SmComplaintQuery;
|
||||
import com.ruoyi.ss.complaint.service.ISmComplaintService;
|
||||
import com.ruoyi.ss.dashboard.ServiceIncomeQuery;
|
||||
import com.ruoyi.ss.dashboard.vo.ServiceIncomeVO;
|
||||
import com.ruoyi.dashboard.domain.dto.ServiceIncomeQuery;
|
||||
import com.ruoyi.dashboard.domain.vo.ServiceIncomeVO;
|
||||
import com.ruoyi.ss.device.domain.DeviceQuery;
|
||||
import com.ruoyi.ss.device.service.DeviceService;
|
||||
import com.ruoyi.ss.mchApply.domain.MchApplyQuery;
|
||||
|
@ -48,6 +51,9 @@ import java.util.List;
|
|||
@Service
|
||||
public class DashboardService {
|
||||
|
||||
@Autowired
|
||||
private DashboardMapper dashboardMapper;
|
||||
|
||||
@Autowired
|
||||
private TransactionBillService transactionBillService;
|
||||
|
||||
|
@ -189,4 +195,17 @@ public class DashboardService {
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<BusinessStatisticsVO> businessStatisticsByStore(BusinessStatisticsQuery query) {
|
||||
query.setBillType(TransactionBillType.RECHARGE.getType());
|
||||
query.setBillStatusList(TransactionBillStatus.payedOrder());
|
||||
return dashboardMapper.selectBusinessStatisticsByStore(query);
|
||||
}
|
||||
|
||||
|
||||
public List<BusinessStatisticsVO> businessStatisticsByDevice(BusinessStatisticsQuery query) {
|
||||
query.setBillType(TransactionBillType.RECHARGE.getType());
|
||||
query.setBillStatusList(TransactionBillStatus.payedOrder());
|
||||
return dashboardMapper.selectBusinessStatisticsByDevice(query);
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@ import com.ruoyi.common.utils.DateUtils;
|
|||
import com.ruoyi.ss.balancePeriod.domain.SmBalancePeriod;
|
||||
import com.ruoyi.ss.balancePeriod.domain.SmBalancePeriodQuery;
|
||||
import com.ruoyi.ss.balancePeriod.mapper.SmBalancePeriodMapper;
|
||||
import com.ruoyi.ss.dashboard.vo.BillCountVo;
|
||||
import com.ruoyi.dashboard.domain.vo.BillCountVo;
|
||||
import com.ruoyi.ss.transactionBill.domain.TransactionBillQuery;
|
||||
import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillGroupBy;
|
||||
import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillStatus;
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.ruoyi.ss.businessRecord.service;
|
|||
import com.ruoyi.ss.businessRecord.domain.SmBusinessRecord;
|
||||
import com.ruoyi.ss.businessRecord.domain.SmBusinessRecordQuery;
|
||||
import com.ruoyi.ss.businessRecord.domain.SmBusinessRecordVo;
|
||||
import com.ruoyi.ss.dashboard.vo.BriefVo;
|
||||
import com.ruoyi.dashboard.domain.vo.BriefVo;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
|
|
@ -8,8 +8,8 @@ import com.ruoyi.ss.businessRecord.domain.SmBusinessRecord;
|
|||
import com.ruoyi.ss.businessRecord.domain.SmBusinessRecordQuery;
|
||||
import com.ruoyi.ss.businessRecord.domain.SmBusinessRecordVo;
|
||||
import com.ruoyi.ss.businessRecord.mapper.SmBusinessRecordMapper;
|
||||
import com.ruoyi.ss.dashboard.vo.BillCountVo;
|
||||
import com.ruoyi.ss.dashboard.vo.BriefVo;
|
||||
import com.ruoyi.dashboard.domain.vo.BillCountVo;
|
||||
import com.ruoyi.dashboard.domain.vo.BriefVo;
|
||||
import com.ruoyi.ss.device.domain.DeviceQuery;
|
||||
import com.ruoyi.ss.device.domain.enums.DeviceOnlineStatus;
|
||||
import com.ruoyi.ss.device.service.DeviceService;
|
||||
|
|
|
@ -29,7 +29,7 @@ public interface DeviceService
|
|||
* @param deviceId 设备主键
|
||||
* @return 设备
|
||||
*/
|
||||
public DeviceVO selectSmDeviceByDeviceId(Long deviceId);
|
||||
public DeviceVO selectById(Long deviceId);
|
||||
|
||||
/**
|
||||
* 查询设备列表
|
||||
|
|
|
@ -56,4 +56,11 @@ public interface DeviceValidator {
|
|||
* 后校验
|
||||
*/
|
||||
void afterCheck(DeviceVO vo);
|
||||
|
||||
/**
|
||||
* 判断用户是否设备的代理商
|
||||
* @param device 设备
|
||||
* @param userId 用户ID
|
||||
*/
|
||||
boolean isAgent(DeviceVO device, Long userId);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.ruoyi.ss.device.service.impl;
|
|||
|
||||
import com.ruoyi.common.utils.ServiceUtil;
|
||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||
import com.ruoyi.ss.dashboard.vo.BillCountVo;
|
||||
import com.ruoyi.dashboard.domain.vo.BillCountVo;
|
||||
import com.ruoyi.ss.device.domain.vo.DeviceVO;
|
||||
import com.ruoyi.ss.device.service.DeviceAssembler;
|
||||
import com.ruoyi.ss.deviceSuit.domain.DeviceSuitQuery;
|
||||
|
|
|
@ -138,7 +138,7 @@ public class DeviceServiceImpl implements DeviceService
|
|||
* @return 设备
|
||||
*/
|
||||
@Override
|
||||
public DeviceVO selectSmDeviceByDeviceId(Long deviceId)
|
||||
public DeviceVO selectById(Long deviceId)
|
||||
{
|
||||
return deviceMapper.selectSmDeviceByDeviceId(deviceId);
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ public class DeviceServiceImpl implements DeviceService
|
|||
ServiceUtil.assertion(insert != 1, "新增设备失败");
|
||||
|
||||
// 后校验
|
||||
DeviceVO vo = this.selectSmDeviceByDeviceId(data.getDeviceId());
|
||||
DeviceVO vo = this.selectById(data.getDeviceId());
|
||||
deviceValidator.afterCheck(vo);
|
||||
|
||||
// 创建OneNet设备1
|
||||
|
@ -220,7 +220,7 @@ public class DeviceServiceImpl implements DeviceService
|
|||
ServiceUtil.assertion(update != 1, "更新设备失败");
|
||||
|
||||
// 后校验
|
||||
DeviceVO vo = this.selectSmDeviceByDeviceId(data.getDeviceId());
|
||||
DeviceVO vo = this.selectById(data.getDeviceId());
|
||||
deviceValidator.afterCheck(vo);
|
||||
|
||||
// 更新套餐关联
|
||||
|
@ -408,7 +408,7 @@ public class DeviceServiceImpl implements DeviceService
|
|||
*/
|
||||
@Override
|
||||
public boolean switchDevice(Long deviceId, boolean open) {
|
||||
DeviceVO device = selectSmDeviceByDeviceId(deviceId);
|
||||
DeviceVO device = selectById(deviceId);
|
||||
ServiceUtil.assertion(device == null, "设备不存在");
|
||||
if (open) {
|
||||
return iotService.open(device);
|
||||
|
@ -539,7 +539,7 @@ public class DeviceServiceImpl implements DeviceService
|
|||
@Override
|
||||
public int resetEle(Long deviceId, boolean required) {
|
||||
// 获取设备信息
|
||||
DeviceVO device = selectSmDeviceByDeviceId(deviceId);
|
||||
DeviceVO device = selectById(deviceId);
|
||||
return resetEle(device, required);
|
||||
}
|
||||
|
||||
|
@ -551,7 +551,7 @@ public class DeviceServiceImpl implements DeviceService
|
|||
// 拉取设备信息
|
||||
pullDeviceInfo(deviceId);
|
||||
|
||||
DeviceVO device = selectSmDeviceByDeviceId(deviceId);
|
||||
DeviceVO device = selectById(deviceId);
|
||||
ServiceUtil.assertion(device == null, "设备不存在");
|
||||
|
||||
// 尝试关闭该设备未结束的所有订单
|
||||
|
@ -577,7 +577,7 @@ public class DeviceServiceImpl implements DeviceService
|
|||
|
||||
@Override
|
||||
public boolean addEle(Long deviceId, BigDecimal ele, boolean withIot, String reason) {
|
||||
DeviceVO device = selectSmDeviceByDeviceId(deviceId);
|
||||
DeviceVO device = selectById(deviceId);
|
||||
if (device == null) {
|
||||
return false;
|
||||
}
|
||||
|
@ -630,7 +630,7 @@ public class DeviceServiceImpl implements DeviceService
|
|||
|
||||
@Override
|
||||
public int setWifi(DeviceWifiDTO dto) {
|
||||
DeviceVO device = selectSmDeviceByDeviceId(dto.getDeviceId());
|
||||
DeviceVO device = selectById(dto.getDeviceId());
|
||||
if (device == null) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -672,7 +672,7 @@ public class DeviceServiceImpl implements DeviceService
|
|||
|
||||
// 物联网设备增加时长
|
||||
if (withIot) {
|
||||
DeviceVO newDevice = selectSmDeviceByDeviceId(deviceId);
|
||||
DeviceVO newDevice = selectById(deviceId);
|
||||
long betweenSeconds = Duration.between(LocalDateTime.now(), newDevice.getExpireTime()).getSeconds();
|
||||
if (betweenSeconds > 0) {
|
||||
CommandResponse rechargeResult = iotService.setTime(device, betweenSeconds);
|
||||
|
@ -1043,8 +1043,10 @@ public class DeviceServiceImpl implements DeviceService
|
|||
ServiceUtil.assertion(record != 1, "添加绑定记录失败");
|
||||
|
||||
// 用户设置为商户
|
||||
if (UserType.USER.getType().equals(user.getType())) {
|
||||
int changeType = userService.changeType(userId, UserType.MCH);
|
||||
ServiceUtil.assertion(changeType != 1, "修改用户类型失败");
|
||||
}
|
||||
|
||||
return updateCount;
|
||||
});
|
||||
|
|
|
@ -61,7 +61,7 @@ public class DeviceValidatorImpl extends BaseValidator implements DeviceValidato
|
|||
if (deviceId == null || userId == null) {
|
||||
return false;
|
||||
}
|
||||
DeviceVO device = deviceService.selectSmDeviceByDeviceId(deviceId);
|
||||
DeviceVO device = deviceService.selectById(deviceId);
|
||||
return device != null && Objects.equals(device.getUserId(), userId);
|
||||
}
|
||||
|
||||
|
@ -169,12 +169,20 @@ public class DeviceValidatorImpl extends BaseValidator implements DeviceValidato
|
|||
if (StringUtils.hasText(vo.getMac()) || StringUtils.hasText(vo.getMac2())) {
|
||||
ServiceUtil.assertion(Objects.equals(vo.getMac(), vo.getMac2()), "MAC-1和MAC-2不允许相同");
|
||||
}
|
||||
if (vo.getUserId() != null || vo.getAgentId() != null) {
|
||||
ServiceUtil.assertion(Objects.equals(vo.getUserId(), vo.getAgentId()), "代理商和商户不允许是同一个用户");
|
||||
}
|
||||
// if (vo.getUserId() != null || vo.getAgentId() != null) {
|
||||
// ServiceUtil.assertion(Objects.equals(vo.getUserId(), vo.getAgentId()), "代理商和商户不允许是同一个用户");
|
||||
// }
|
||||
ServiceUtil.assertion(this.isRepeatMac(vo.getDeviceId(), vo.getMac()), "MAC-1重复:" + vo.getMac());
|
||||
ServiceUtil.assertion(this.isRepeatMac(vo.getDeviceId(), vo.getMac2()), "MAC-2重复:" + vo.getMac2());
|
||||
ServiceUtil.assertion(this.isRepeatSn(vo.getDeviceId(), vo.getDeviceNo()), "SN重复");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAgent(DeviceVO device, Long userId) {
|
||||
if (device == null || userId == null) {
|
||||
return false;
|
||||
}
|
||||
return Objects.equals(device.getAgentId(), userId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.ruoyi.ss.store.service.impl;
|
|||
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||
import com.ruoyi.ss.dashboard.vo.BillCountVo;
|
||||
import com.ruoyi.dashboard.domain.vo.BillCountVo;
|
||||
import com.ruoyi.ss.device.domain.DeviceCountVO;
|
||||
import com.ruoyi.ss.device.domain.DeviceQuery;
|
||||
import com.ruoyi.ss.device.domain.enums.DeviceGroupBy;
|
||||
|
|
|
@ -157,7 +157,7 @@ public class TimeBillServiceImpl implements TimeBillService, AfterPay
|
|||
ServiceUtil.assertion(!redisLock.lock(RedisLockKey.ADD_TIME_BILL, lockKey), "当前使用该设备的人数过多,请稍后再试");
|
||||
try {
|
||||
// 查询设备
|
||||
DeviceVO device = deviceService.selectSmDeviceByDeviceId(dto.getDeviceId());
|
||||
DeviceVO device = deviceService.selectById(dto.getDeviceId());
|
||||
ServiceUtil.assertion(device == null, "设备不存在");
|
||||
dto.setDevice(device);
|
||||
|
||||
|
@ -217,7 +217,7 @@ public class TimeBillServiceImpl implements TimeBillService, AfterPay
|
|||
ServiceUtil.assertion(update != 1, "订单状态已发生变化,请刷新后重试");
|
||||
|
||||
// 关闭设备
|
||||
DeviceVO device = deviceService.selectSmDeviceByDeviceId(bill.getDeviceId());
|
||||
DeviceVO device = deviceService.selectById(bill.getDeviceId());
|
||||
ServiceUtil.assertion(device == null, "设备不存在");
|
||||
boolean close = iotService.close(device);
|
||||
ServiceUtil.assertion(!close, "关闭设备失败,请检查设备是否在线");
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.ruoyi.ss.transactionBill.mapper;
|
||||
|
||||
import com.ruoyi.ss.dashboard.vo.BillCountVo;
|
||||
import com.ruoyi.dashboard.domain.vo.BillCountVo;
|
||||
import com.ruoyi.ss.transactionBill.domain.TransactionBill;
|
||||
import com.ruoyi.ss.transactionBill.domain.TransactionBillQuery;
|
||||
import com.ruoyi.ss.transactionBill.domain.vo.TransactionAmountVO;
|
||||
|
|
|
@ -291,7 +291,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
where stb.bill_id = #{billId}
|
||||
</select>
|
||||
|
||||
<resultMap id="BillCountVo" type="com.ruoyi.ss.dashboard.vo.BillCountVo" autoMapping="true">
|
||||
<resultMap id="BillCountVo" type="com.ruoyi.dashboard.domain.vo.BillCountVo" autoMapping="true">
|
||||
<result property="createDate" column="create_date"/>
|
||||
<result property="createHour" column="create_hour"/>
|
||||
<result property="createYear" column="create_year"/>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.ruoyi.ss.transactionBill.service;
|
||||
|
||||
import com.ruoyi.ss.dashboard.vo.BillCountVo;
|
||||
import com.ruoyi.dashboard.domain.vo.BillCountVo;
|
||||
import com.ruoyi.ss.device.domain.vo.DeviceVO;
|
||||
import com.ruoyi.ss.payBill.domain.vo.DoPayVO;
|
||||
import com.ruoyi.ss.transactionBill.domain.TransactionBill;
|
||||
|
|
|
@ -47,7 +47,7 @@ public class RechargeDepositAfterPay implements AfterPay {
|
|||
|
||||
deviceService.pullDeviceInfo(bill.getDeviceId());
|
||||
|
||||
DeviceVO device = deviceService.selectSmDeviceByDeviceId(bill.getDeviceId());
|
||||
DeviceVO device = deviceService.selectById(bill.getDeviceId());
|
||||
ServiceUtil.assertion(device == null, "设备不存在");
|
||||
|
||||
Integer result = transactionTemplate.execute(status -> {
|
||||
|
|
|
@ -151,7 +151,7 @@ public class TransactionBillConverterImpl implements TransactionBillConverter {
|
|||
bo.setOrder(bill);
|
||||
bo.setUser(userService.selectSmUserByUserId(bill.getUserId()));
|
||||
bo.setMch(userService.selectSmUserByUserId(bill.getMchId()));
|
||||
bo.setDevice(deviceService.selectSmDeviceByDeviceId(bill.getDeviceId()));
|
||||
bo.setDevice(deviceService.selectById(bill.getDeviceId()));
|
||||
bo.setChannel(channelService.selectSmChannelByChannelId(channelId));
|
||||
bo.setPlatform(deptService.selectDeptById(Constants.ROOT_DEPT));
|
||||
return bo;
|
||||
|
@ -187,7 +187,7 @@ public class TransactionBillConverterImpl implements TransactionBillConverter {
|
|||
bo.setTotalEle(dto.getTotalEle());
|
||||
if (order != null) {
|
||||
deviceService.pullDeviceInfo(order.getDeviceId());
|
||||
bo.setDevice(deviceService.selectSmDeviceByDeviceId(order.getDeviceId()));
|
||||
bo.setDevice(deviceService.selectById(order.getDeviceId()));
|
||||
}
|
||||
return bo;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ import com.ruoyi.ss.bonus.service.BonusConverter;
|
|||
import com.ruoyi.ss.bonus.service.BonusService;
|
||||
import com.ruoyi.ss.channelWithdraw.domain.ChannelWithdrawVO;
|
||||
import com.ruoyi.ss.channelWithdraw.service.ChannelWithdrawService;
|
||||
import com.ruoyi.ss.dashboard.vo.BillCountVo;
|
||||
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;
|
||||
|
@ -842,7 +842,7 @@ public class TransactionBillServiceImpl implements TransactionBillService, After
|
|||
// 刷新设备数据
|
||||
deviceService.pullDeviceInfo(bill.getDeviceId());
|
||||
|
||||
DeviceVO device = deviceService.selectSmDeviceByDeviceId(bill.getDeviceId());
|
||||
DeviceVO device = deviceService.selectById(bill.getDeviceId());
|
||||
|
||||
// 如果设备离线,则直接返回失败
|
||||
if (DeviceOnlineStatus.OFFLINE.getStatus().equals(device.getOnlineStatus())) {
|
||||
|
@ -1244,7 +1244,7 @@ public class TransactionBillServiceImpl implements TransactionBillService, After
|
|||
ServiceUtil.assertion(bill == null, "计算金额出错,订单不存在");
|
||||
|
||||
if(SuitFeeType.COUNT.getType().equals(bill.getSuitFeeType()) || SuitFeeType.TIMING_COUNT.getType().equals(bill.getSuitFeeType())) {
|
||||
DeviceVO device = deviceService.selectSmDeviceByDeviceId(bill.getDeviceId());
|
||||
DeviceVO device = deviceService.selectById(bill.getDeviceId());
|
||||
totalEle = this.calcTotalEle(device, totalEle);
|
||||
}
|
||||
|
||||
|
@ -1649,7 +1649,7 @@ public class TransactionBillServiceImpl implements TransactionBillService, After
|
|||
ServiceUtil.assertion( result != 1, "蓝牙充值回调失败,设备状态已发生改变");
|
||||
|
||||
// 更新套餐使用信息
|
||||
DeviceVO device = deviceService.selectSmDeviceByDeviceId(bill.getDeviceId());
|
||||
DeviceVO device = deviceService.selectById(bill.getDeviceId());
|
||||
int updateInfo = this.updateSuitInfoBeforeDevice(bill, device);
|
||||
ServiceUtil.assertion(updateInfo != 1, "更新套餐使用信息失败");
|
||||
|
||||
|
@ -1674,7 +1674,7 @@ public class TransactionBillServiceImpl implements TransactionBillService, After
|
|||
// 记录时长变化记录
|
||||
private void recordTime(TransactionBillVO bill, String reason) {
|
||||
scheduledExecutorService.schedule(() -> {
|
||||
DeviceVO device = deviceService.selectSmDeviceByDeviceId(bill.getDeviceId());
|
||||
DeviceVO device = deviceService.selectById(bill.getDeviceId());
|
||||
if (device == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -1950,7 +1950,7 @@ public class TransactionBillServiceImpl implements TransactionBillService, After
|
|||
ServiceUtil.assertion(bill == null, "订单不存在");
|
||||
ServiceUtil.assertion(bill.getIsUsing() == null || !bill.getIsUsing(), "该订单不是正在使用中的订单,无法操作");
|
||||
|
||||
DeviceVO device = deviceService.selectSmDeviceByDeviceId(bill.getDeviceId());
|
||||
DeviceVO device = deviceService.selectById(bill.getDeviceId());
|
||||
ServiceUtil.assertion(device == null, "设备不存在");
|
||||
ServiceUtil.assertion(StringUtils.isBlank(device.getMac()), "设备MAC为空,请联系管理员处理");
|
||||
|
||||
|
|
|
@ -2,11 +2,9 @@ package com.ruoyi.ss.transactionBill.service.impl;
|
|||
|
||||
import com.ruoyi.common.core.domain.BaseValidator;
|
||||
import com.ruoyi.common.core.domain.ValidateResult;
|
||||
import com.ruoyi.common.utils.ServiceUtil;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||
import com.ruoyi.ss.channel.domain.ChannelVO;
|
||||
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.model.domain.enums.ModelTag;
|
||||
|
@ -31,11 +29,9 @@ import com.ruoyi.ss.user.service.UserValidator;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -242,7 +238,7 @@ public class TransactionBillValidatorImpl extends BaseValidator implements Trans
|
|||
*/
|
||||
@Override
|
||||
public boolean canRechargeOnline(Long deviceId) {
|
||||
DeviceVO device = deviceService.selectSmDeviceByDeviceId(deviceId);
|
||||
DeviceVO device = deviceService.selectById(deviceId);
|
||||
if (device == null) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
package com.ruoyi.web.controller.agent;
|
||||
|
||||
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.DeviceQuery;
|
||||
import com.ruoyi.ss.device.domain.vo.DeviceVO;
|
||||
import com.ruoyi.ss.device.service.DeviceService;
|
||||
import com.ruoyi.ss.device.service.DeviceValidator;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2024/10/8
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/agent/device")
|
||||
public class AgentDeviceController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private DeviceService deviceService;
|
||||
|
||||
@Autowired
|
||||
private DeviceValidator deviceValidator;
|
||||
|
||||
@ApiOperation("代理商获取设备列表")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(DeviceQuery query) {
|
||||
startPage();
|
||||
startOrderBy();
|
||||
query.setAgentId(getUserId());
|
||||
return getDataTable(deviceService.selectSmDeviceList(query));
|
||||
}
|
||||
|
||||
@ApiOperation("代理商解绑设备商户")
|
||||
@PutMapping("/unbindMch")
|
||||
public AjaxResult unbindMch(@RequestParam Long deviceId) {
|
||||
DeviceVO device = deviceService.selectById(deviceId);
|
||||
if (!deviceValidator.isAgent(device, getUserId())) {
|
||||
return error("您不是该设备的代理商,无权操作");
|
||||
}
|
||||
return toAjax(deviceService.unbind(deviceId));
|
||||
}
|
||||
|
||||
}
|
|
@ -25,7 +25,6 @@ import com.ruoyi.ss.device.service.DeviceValidator;
|
|||
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.SuitFeeType;
|
||||
import com.ruoyi.ss.suit.domain.enums.SuitTimeUnit;
|
||||
import com.ruoyi.web.core.annotation.DeviceAdminRequired;
|
||||
import io.swagger.annotations.Api;
|
||||
|
@ -81,6 +80,7 @@ public class AppDeviceController extends BaseController {
|
|||
smDevice.setUserId(getUserId());
|
||||
List<DeviceVO> list = smDeviceService.selectSmDeviceList(smDevice);
|
||||
smDeviceService.pullDeviceInfoList(list);
|
||||
deviceAssembler.assembleRealServiceRate(list);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ public class AppDeviceController extends BaseController {
|
|||
@GetMapping(value = "/{deviceId}")
|
||||
public AjaxResult getInfo(@PathVariable("deviceId") Long deviceId) {
|
||||
// smDeviceService.pullDeviceInfo(Collections.singletonList(deviceId));
|
||||
DeviceVO device = smDeviceService.selectSmDeviceByDeviceId(deviceId);
|
||||
DeviceVO device = smDeviceService.selectById(deviceId);
|
||||
List<DeviceVO> list = Collections.singletonList(device);
|
||||
deviceAssembler.assembleOrderCountInfo(list); // 订单统计信息
|
||||
return success(device);
|
||||
|
@ -161,7 +161,7 @@ public class AppDeviceController extends BaseController {
|
|||
@ApiParam("是否操作物联网设备") @RequestParam(required = false, defaultValue = "true") Boolean withIot
|
||||
) {
|
||||
ServiceUtil.assertion(!deviceValidator.isBelong(deviceId, getUserId()), "这不是您的设备");
|
||||
DeviceVO device = smDeviceService.selectSmDeviceByDeviceId(deviceId);
|
||||
DeviceVO device = smDeviceService.selectById(deviceId);
|
||||
ServiceUtil.assertion(device == null || !getUserId().equals(device.getUserId()), "设备不存在或您无权充值");
|
||||
|
||||
// 电量
|
||||
|
|
|
@ -10,7 +10,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
|
|||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.ServiceUtil;
|
||||
import com.ruoyi.ss.dashboard.vo.BillCountVo;
|
||||
import com.ruoyi.dashboard.domain.vo.BillCountVo;
|
||||
import com.ruoyi.ss.device.service.DeviceValidator;
|
||||
import com.ruoyi.ss.transactionBill.domain.TransactionBillQuery;
|
||||
import com.ruoyi.ss.transactionBill.domain.bo.EndUseBO;
|
||||
|
@ -37,7 +37,6 @@ import java.math.BigDecimal;
|
|||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
package com.ruoyi.web.controller.mch;
|
||||
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.dashboard.domain.dto.BusinessStatisticsQuery;
|
||||
import com.ruoyi.dashboard.service.DashboardService;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2024/10/8
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/mch/dashboard")
|
||||
public class MchDashboardController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private DashboardService dashboardService;
|
||||
|
||||
@ApiOperation("商户获取店铺维度的订单统计")
|
||||
@GetMapping("/businessStatisticsByStore")
|
||||
public AjaxResult businessStatisticsByStore(BusinessStatisticsQuery query) {
|
||||
query.setMchId(getUserId());
|
||||
return success(dashboardService.businessStatisticsByStore(query));
|
||||
}
|
||||
|
||||
@ApiOperation("商户获取指定店铺的订单统计")
|
||||
@GetMapping("/businessStatisticsByDevice")
|
||||
public AjaxResult businessStatisticsByDevice(BusinessStatisticsQuery query) {
|
||||
query.setMchId(getUserId());
|
||||
return success(dashboardService.businessStatisticsByDevice(query));
|
||||
}
|
||||
|
||||
}
|
|
@ -4,19 +4,19 @@ import com.ruoyi.common.core.controller.BaseController;
|
|||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.ValidGroup;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.dashboard.DashboardService;
|
||||
import com.ruoyi.dashboard.service.DashboardService;
|
||||
import com.ruoyi.ss.balancePeriod.domain.SmBalancePeriodQuery;
|
||||
import com.ruoyi.ss.balancePeriod.service.ISmBalancePeriodService;
|
||||
import com.ruoyi.ss.bonus.domain.BonusQuery;
|
||||
import com.ruoyi.ss.bonus.service.BonusService;
|
||||
import com.ruoyi.ss.businessRecord.service.ISmBusinessRecordService;
|
||||
import com.ruoyi.ss.dashboard.ServiceIncomeQuery;
|
||||
import com.ruoyi.dashboard.domain.dto.ServiceIncomeQuery;
|
||||
import com.ruoyi.ss.transactionBill.domain.TransactionBillQuery;
|
||||
import com.ruoyi.ss.transactionBill.service.TransactionBillService;
|
||||
import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillGroupBy;
|
||||
import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillStatus;
|
||||
import com.ruoyi.ss.businessRecord.domain.SmBusinessRecordVo;
|
||||
import com.ruoyi.ss.dashboard.vo.BriefVo;
|
||||
import com.ruoyi.dashboard.domain.vo.BriefVo;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
|
|
@ -85,7 +85,7 @@ public class SmDeviceController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('system:device:query')")
|
||||
@GetMapping(value = "/{deviceId}")
|
||||
public AjaxResult getInfo(@PathVariable("deviceId") Long deviceId) {
|
||||
DeviceVO device = deviceService.selectSmDeviceByDeviceId(deviceId);
|
||||
DeviceVO device = deviceService.selectById(deviceId);
|
||||
deviceAssembler.assembleRealServiceRate(device);
|
||||
return success(device);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user