diff --git a/smart-switch-service/src/main/java/com/ruoyi/dashboard/DashboardService.java b/smart-switch-service/src/main/java/com/ruoyi/dashboard/DashboardService.java index 614687d1..7dfaf976 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/dashboard/DashboardService.java +++ b/smart-switch-service/src/main/java/com/ruoyi/dashboard/DashboardService.java @@ -107,8 +107,13 @@ public class DashboardService { billQuery.setStartDate(query.getStartDate()); billQuery.setEndDate(query.getEndDate()); billQuery.setStatusList(TransactionBillStatus.serviceIncome()); + billQuery.setType(TransactionBillType.RECHARGE.getType()); List> amountList = transactionBillService.selectCommonSumOfMoney(billQuery, TransactionBillGroupBy.create_date.name()); + // 查询提现 + billQuery.setType(TransactionBillType.WITHDRAW.getType()); + List> withdrawList = transactionBillService.selectCommonSumOfMoney(billQuery, TransactionBillGroupBy.create_date.name()); + // 查询月费收入 ReceiveBillQuery receiveQuery = new ReceiveBillQuery(); receiveQuery.setStartDate(query.getStartDate()); @@ -134,6 +139,17 @@ public class DashboardService { vo.setChannelCost(BigDecimal.ZERO); } + // 提现服务费收入及成本 + TransactionAmountVO withdraw = withdrawList.stream() + .filter(item -> item.getKey().compareTo(DateUtils.toDate(date)) == 0) + .findFirst().orElse(null); + if (withdraw != null) { + vo.setWithdrawServiceAmount(withdraw.getServiceAmount()); + vo.setChannelCost(vo.getChannelCost().add(withdraw.getChannelCost())); + } else { + vo.setWithdrawServiceAmount(BigDecimal.ZERO); + } + // 月费收入 ReceiveAmountVO receive = receiveList.stream() .filter(item -> item.getKey().compareTo(DateUtils.toDate(date)) == 0) diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/account/domain/AccountVO.java b/smart-switch-service/src/main/java/com/ruoyi/ss/account/domain/AccountVO.java index 4ed90751..d26bacbf 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/account/domain/AccountVO.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/account/domain/AccountVO.java @@ -12,4 +12,7 @@ public class AccountVO extends Account { @ApiModelProperty("用户名称") private String userName; + + @ApiModelProperty("渠道是否启用") + private Boolean channelEnabled; } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/account/service/AccountAssembler.java b/smart-switch-service/src/main/java/com/ruoyi/ss/account/service/AccountAssembler.java new file mode 100644 index 00000000..a8ea8127 --- /dev/null +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/account/service/AccountAssembler.java @@ -0,0 +1,18 @@ +package com.ruoyi.ss.account.service; + +import com.ruoyi.ss.account.domain.AccountVO; + +import java.util.List; + +/** + * @author wjh + * 2024/9/18 + */ +public interface AccountAssembler { + + /** + * 拼接渠道是否启用 + */ + void assembleChannelEnabled(List list); + +} diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/account/service/impl/AccountAssemblerImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/account/service/impl/AccountAssemblerImpl.java new file mode 100644 index 00000000..bfc58638 --- /dev/null +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/account/service/impl/AccountAssemblerImpl.java @@ -0,0 +1,44 @@ +package com.ruoyi.ss.account.service.impl; + +import com.ruoyi.common.utils.collection.CollectionUtils; +import com.ruoyi.ss.account.domain.AccountVO; +import com.ruoyi.ss.account.service.AccountAssembler; +import com.ruoyi.ss.channelWithdraw.domain.ChannelWithdrawVO; +import com.ruoyi.ss.channelWithdraw.service.ChannelWithdrawService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @author wjh + * 2024/9/18 + */ +@Service +public class AccountAssemblerImpl implements AccountAssembler { + @Autowired + private ChannelWithdrawService channelWithdrawService; + + /** + * 拼接渠道是否启用 + * + * @param list + */ + @Override + public void assembleChannelEnabled(List list) { + if (CollectionUtils.isEmptyElement(list)) { + return; + } + + List channelList = channelWithdrawService.selectEnabledList(); + + for (AccountVO account : list) { + ChannelWithdrawVO channel = channelList.stream() + .filter(item -> item.getAccountType() != null && item.getAccountType().equals(account.getAccountType())) + .findFirst() + .orElse(null); + account.setChannelEnabled(channel != null); + } + + } +} diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/account/service/impl/AccountServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/account/service/impl/AccountServiceImpl.java index 42ddef08..d9bec165 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/account/service/impl/AccountServiceImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/account/service/impl/AccountServiceImpl.java @@ -9,7 +9,11 @@ import com.ruoyi.ss.account.domain.AccountQuery; import com.ruoyi.ss.account.domain.AccountVO; import com.ruoyi.ss.account.domain.enums.AccountType; import com.ruoyi.ss.account.mapper.AccountMapper; +import com.ruoyi.ss.account.service.AccountAssembler; import com.ruoyi.ss.account.service.AccountService; +import com.ruoyi.ss.channel.service.ChannelService; +import com.ruoyi.ss.channelWithdraw.domain.ChannelWithdrawVO; +import com.ruoyi.ss.channelWithdraw.service.ChannelWithdrawService; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -26,9 +30,16 @@ import java.util.stream.Collectors; */ @Service public class AccountServiceImpl implements AccountService { + @Autowired private AccountMapper accountMapper; + @Autowired + private AccountAssembler accountAssembler; + + @Autowired + private ChannelWithdrawService channelWithdrawService; + /** * 查询用户账户 * @@ -124,16 +135,29 @@ public class AccountServiceImpl implements AccountService { if (CollectionUtils.isEmpty(list)) { return Collections.emptyMap(); } + // 获取可用渠道,仅返回可用渠道 + Set enabledChannel = channelWithdrawService.selectEnabledList() + .stream().map(ChannelWithdrawVO::getAccountType).collect(Collectors.toSet()); + list.forEach(AccountVO::desensitization); Map> map = new HashMap<>(); - map.put(AccountType.BANK_CARD.name(), list.stream() - .filter(item -> Objects.equals(AccountType.BANK_CARD.getType(), item.getAccountType())).collect(Collectors.toList())); - map.put(AccountType.WECHAT.name(), list.stream() - .filter(item -> Objects.equals(AccountType.WECHAT.getType(), item.getAccountType())).collect(Collectors.toList())); - map.put(AccountType.ALIPAY.name(), list.stream() - .filter(item -> Objects.equals(AccountType.ALIPAY.getType(), item.getAccountType())).collect(Collectors.toList())); - map.put(AccountType.OFFLINE_IMAGE.name(), list.stream() - .filter(item -> Objects.equals(AccountType.OFFLINE_IMAGE.getType(), item.getAccountType())).collect(Collectors.toList())); + if (enabledChannel.contains(AccountType.BANK_CARD.getType())) { + map.put(AccountType.BANK_CARD.name(), list.stream() + .filter(item -> Objects.equals(AccountType.BANK_CARD.getType(), item.getAccountType())).collect(Collectors.toList())); + } + if (enabledChannel.contains(AccountType.WECHAT.getType())) { + map.put(AccountType.WECHAT.name(), list.stream() + .filter(item -> Objects.equals(AccountType.WECHAT.getType(), item.getAccountType())).collect(Collectors.toList())); + } + if (enabledChannel.contains(AccountType.ALIPAY.getType())) { + map.put(AccountType.ALIPAY.name(), list.stream() + .filter(item -> Objects.equals(AccountType.ALIPAY.getType(), item.getAccountType())).collect(Collectors.toList())); + } + if (enabledChannel.contains(AccountType.OFFLINE_IMAGE.getType())) { + map.put(AccountType.OFFLINE_IMAGE.name(), list.stream() + .filter(item -> Objects.equals(AccountType.OFFLINE_IMAGE.getType(), item.getAccountType())).collect(Collectors.toList())); + } + return map; } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/channelWithdraw/service/ChannelWithdrawService.java b/smart-switch-service/src/main/java/com/ruoyi/ss/channelWithdraw/service/ChannelWithdrawService.java index b6ebbf41..54db1c8d 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/channelWithdraw/service/ChannelWithdrawService.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/channelWithdraw/service/ChannelWithdrawService.java @@ -67,4 +67,10 @@ public interface ChannelWithdrawService * 查询用户可用的提现渠道 */ List selectEnabledList(Long userId); + + /** + * 查询启用渠道 + * @return + */ + List selectEnabledList(); } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/channelWithdraw/service/impl/ChannelWithdrawServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/channelWithdraw/service/impl/ChannelWithdrawServiceImpl.java index 9093f8ca..add489b0 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/channelWithdraw/service/impl/ChannelWithdrawServiceImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/channelWithdraw/service/impl/ChannelWithdrawServiceImpl.java @@ -118,4 +118,12 @@ public class ChannelWithdrawServiceImpl implements ChannelWithdrawService query.setEnabled(true); return this.selectChannelWithdrawList(query); } + + @Override + public List selectEnabledList() { + // 查询渠道列表 + ChannelWithdrawQuery query = new ChannelWithdrawQuery(); + query.setEnabled(true); + return this.selectChannelWithdrawList(query); + } } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/dashboard/vo/ServiceIncomeVO.java b/smart-switch-service/src/main/java/com/ruoyi/ss/dashboard/vo/ServiceIncomeVO.java index 4051aa83..dacb00d4 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/dashboard/vo/ServiceIncomeVO.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/dashboard/vo/ServiceIncomeVO.java @@ -19,10 +19,13 @@ public class ServiceIncomeVO { @ApiModelProperty("月费收入") private BigDecimal monthAmount; - @ApiModelProperty("服务费收入") + @ApiModelProperty("订单服务费收入") private BigDecimal serviceAmount; - @ApiModelProperty("成本") + @ApiModelProperty("提现服务费收入") + private BigDecimal withdrawServiceAmount; + + @ApiModelProperty("渠道成本") private BigDecimal channelCost; } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/DeviceService.java b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/DeviceService.java index 7860ce28..a469002a 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/DeviceService.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/DeviceService.java @@ -139,9 +139,10 @@ public interface DeviceService /** * 归零电表,并关闭订单 + * * @param deviceId 设备id */ - boolean resetTimeWithBill(Long deviceId); + int resetTimeWithBill(Long deviceId); /** * 设备是否已经被绑定 diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceServiceImpl.java index 599e7afd..ec724d23 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceServiceImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/device/service/impl/DeviceServiceImpl.java @@ -31,6 +31,7 @@ import com.ruoyi.ss.deviceSuit.service.DeviceSuitConverter; import com.ruoyi.ss.deviceSuit.service.DeviceSuitService; import com.ruoyi.ss.model.domain.SmModelVO; import com.ruoyi.ss.model.service.ModelService; +import com.ruoyi.ss.record.time.domain.enums.RecordTimeType; import com.ruoyi.ss.record.time.service.IRecordTimeService; import com.ruoyi.ss.record.time.service.RecordTimeConverter; import com.ruoyi.ss.store.domain.StoreVo; @@ -306,7 +307,7 @@ public class DeviceServiceImpl implements DeviceService LoginUser loginUser = SecurityUtils.getLoginUser(); scheduledExecutorService.schedule(() -> { DeviceVO device = deviceMapper.selectSmDeviceByDeviceId(deviceId); - recordTimeService.insertRecordTime(recordTimeConverter.toRecordTime(device, seconds, reason, loginUser)); + recordTimeService.insertRecordTime(recordTimeConverter.toRecordTime(device, seconds, reason, loginUser, RecordTimeType.TIME.getType())); }, 0, TimeUnit.SECONDS); } @@ -459,7 +460,7 @@ public class DeviceServiceImpl implements DeviceService // 设备剩余时长 Duration duration = Duration.between(now, device.getExpireTime()); long seconds = duration.getSeconds() > 0 ? duration.getSeconds() : 0; - recordTimeService.insertRecordTime(recordTimeConverter.toRecordTime(device, -seconds, "设备归零", loginUser)); + recordTimeService.insertRecordTime(recordTimeConverter.toRecordTime(device, -seconds, "设备归零", loginUser, RecordTimeType.TIME.getType())); }, 0, TimeUnit.SECONDS); return result == null ? 0 : result; @@ -495,7 +496,7 @@ public class DeviceServiceImpl implements DeviceService // 归零记录 LoginUser loginUser = SecurityUtils.getLoginUser(); scheduledExecutorService.schedule(() -> { - recordTimeService.insertRecordTime(recordTimeConverter.toRecordTime(device, device.getSurplusEle().negate().intValue(), "设备归零", loginUser)); + recordTimeService.insertRecordTime(recordTimeConverter.toRecordTime(device, device.getSurplusEle().negate().intValue(), "设备归零", loginUser, RecordTimeType.ELE.getType())); }, 0, TimeUnit.SECONDS); return result == null ? 0 : result; @@ -845,7 +846,7 @@ public class DeviceServiceImpl implements DeviceService } @Override - public boolean resetTimeWithBill(Long deviceId) { + public int resetTimeWithBill(Long deviceId) { ServiceUtil.assertion(deviceId == null, "设备id不能为空"); // 拉取最新设备信息 @@ -874,7 +875,7 @@ public class DeviceServiceImpl implements DeviceService int reset = this.resetTime(device, true); ServiceUtil.assertion(reset != 1, "归零失败"); - return true; + return reset; } /** diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/record/time/domain/RecordTime.java b/smart-switch-service/src/main/java/com/ruoyi/ss/record/time/domain/RecordTime.java index 9bf14da5..ab4ff58a 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/record/time/domain/RecordTime.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/record/time/domain/RecordTime.java @@ -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; @@ -52,4 +53,8 @@ public class RecordTime extends BaseEntity @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @Excel(name = "操作时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") private LocalDateTime operatorTime; + + @Excel(name = "变化类型:1-时长,2-电量") + @ApiModelProperty("变化类型:1-时长,2-电量") + private String type; } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/record/time/domain/enums/RecordTimeType.java b/smart-switch-service/src/main/java/com/ruoyi/ss/record/time/domain/enums/RecordTimeType.java new file mode 100644 index 00000000..b1b56875 --- /dev/null +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/record/time/domain/enums/RecordTimeType.java @@ -0,0 +1,20 @@ +package com.ruoyi.ss.record.time.domain.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author wjh + * 2024/9/18 + */ +@Getter +@AllArgsConstructor +public enum RecordTimeType { + + TIME("1", "时长"), + ELE("2", "电量"); + + private final String type; + private final String msg; + +} diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/record/time/mapper/RecordTimeMapper.xml b/smart-switch-service/src/main/java/com/ruoyi/ss/record/time/mapper/RecordTimeMapper.xml index a5c56d77..5e896e6d 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/record/time/mapper/RecordTimeMapper.xml +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/record/time/mapper/RecordTimeMapper.xml @@ -7,7 +7,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select id, device_id, amount, reason, operator_id, operator_name, operator_type, operator_time from ss_record_time + select + id, + device_id, + amount, + reason, + operator_id, + operator_name, + operator_type, + operator_time, + type + from ss_record_time @@ -40,6 +51,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" operator_name, operator_type, operator_time, + type, #{id}, @@ -50,6 +62,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{operatorName}, #{operatorType}, #{operatorTime}, + #{type}, @@ -63,6 +76,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" operator_name = #{operatorName}, operator_type = #{operatorType}, operator_time = #{operatorTime}, + type = #{type}, where id = #{id} diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/record/time/service/RecordTimeConverter.java b/smart-switch-service/src/main/java/com/ruoyi/ss/record/time/service/RecordTimeConverter.java index 8e642ed6..2663bae0 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/record/time/service/RecordTimeConverter.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/record/time/service/RecordTimeConverter.java @@ -12,7 +12,7 @@ import com.ruoyi.ss.user.domain.SmUserVo; */ public interface RecordTimeConverter { - RecordTime toRecordTime(Device device, long seconds, String reason, LoginUser loginUser); + RecordTime toRecordTime(Device device, long amount, String reason, LoginUser loginUser, String type); - RecordTime toRecordTime(DeviceVO device, long secondSuitTime, String reason, SmUserVo user); + RecordTime toRecordTime(DeviceVO device, long secondSuitTime, String reason, SmUserVo user, String type); } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/record/time/service/impl/RecordTimeConverterImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/record/time/service/impl/RecordTimeConverterImpl.java index 90bae07b..b68532d0 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/record/time/service/impl/RecordTimeConverterImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/record/time/service/impl/RecordTimeConverterImpl.java @@ -19,11 +19,12 @@ import java.time.LocalDateTime; @Service public class RecordTimeConverterImpl implements RecordTimeConverter { @Override - public RecordTime toRecordTime(Device device, long seconds, String reason, LoginUser loginUser) { + public RecordTime toRecordTime(Device device, long amount, String reason, LoginUser loginUser, String type) { RecordTime record = new RecordTime(); record.setDeviceId(device == null ? null : device.getDeviceId()); - record.setAmount(seconds); + record.setAmount(amount); record.setReason(reason); + record.setType(type); if (loginUser != null) { record.setOperatorId(loginUser.getUserId()); record.setOperatorName(loginUser.getUsername()); @@ -35,7 +36,7 @@ public class RecordTimeConverterImpl implements RecordTimeConverter { } @Override - public RecordTime toRecordTime(DeviceVO device, long seconds, String reason, SmUserVo user) { + public RecordTime toRecordTime(DeviceVO device, long seconds, String reason, SmUserVo user, String type) { RecordTime record = new RecordTime(); record.setDeviceId(device == null ? null : device.getDeviceId()); record.setAmount(seconds); diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/domain/TransactionBillQuery.java b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/domain/TransactionBillQuery.java index 4debcc45..cd914f55 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/domain/TransactionBillQuery.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/domain/TransactionBillQuery.java @@ -103,6 +103,9 @@ public class TransactionBillQuery extends TransactionBill { @ApiModelProperty("套餐收费类型列表") private List suitFeeTypes; + @ApiModelProperty("套餐收费模式列表") + private List suitFeeModes; + @ApiModelProperty("是否正在使用") private Boolean isUsing; @@ -114,4 +117,7 @@ public class TransactionBillQuery extends TransactionBill { @ApiModelProperty("是否已结束") private Boolean isFinished; + + @ApiModelProperty("渠道ID列表") + private List channelIds; } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/mapper/TransactionBillMapper.xml b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/mapper/TransactionBillMapper.xml index 0d3d7538..7b706382 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/mapper/TransactionBillMapper.xml +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/mapper/TransactionBillMapper.xml @@ -167,6 +167,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and stb.suit_end_ele <= #{query.endSuitEndEle} and stb.channel_id = #{query.channelId} and stb.withdraw_type = #{query.withdrawType} + and stb.money = #{query.money} and sd.device_no like concat('%', #{query.deviceNo}, '%') and su.phonenumber like concat('%', #{query.userMobile}, '%') and suit_fee_mode = #{query.suitFeeMode} @@ -201,6 +202,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{item} + + and stb.suit_fee_mode in + + #{item} + + and stb.bill_id in @@ -231,11 +238,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{item} + + and stb.channel_id in + + #{item} + + - and stb.create_time >= #{query.createDateRange[0]} and stb.create_time <= #{query.createDateRange[1]} + and date(stb.create_time) >= date(#{query.createDateRange[0]}) and date(stb.create_time) <= date(#{query.createDateRange[1]}) - and stb.pay_time >= #{query.payDateRange[0]} and stb.pay_time <= #{query.payDateRange[1]} + and date(stb.pay_time) >= date(#{query.payDateRange[0]}) and date(stb.pay_time) <= date(#{query.payDateRange[1]}) @@ -485,60 +498,61 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - update sm_transaction_bill + update sm_transaction_bill stb - where bill_id = #{data.billId} + where stb.bill_id = #{data.billId} + - user_id = #{data.userId}, - `type` = #{data.type}, - device_id = #{data.deviceId}, - mch_id = #{data.mchId}, - money = #{data.money}, - arrival_amount = #{data.arrivalAmount}, - service_charge = #{data.serviceCharge}, - create_time = #{data.createTime}, - remark = #{data.remark}, - `status` = #{data.status}, - channel_id = #{data.channelId}, - after_balance = #{data.afterBalance}, - pay_time = #{data.payTime}, - expire_time = #{data.expireTime}, - account_no = #{data.accountNo}, - payed_amount = #{data.payedAmount}, - transfer_ids = #{data.transferIds,typeHandler=com.ruoyi.system.mapper.typehandler.StringListTypeHandler}, - channel_cost = #{data.channelCost}, - suit_id = #{data.suitId}, - suit_time = #{data.suitTime}, - suit_time_unit = #{data.suitTimeUnit}, - suit_start_time = #{data.suitStartTime}, - suit_end_time = #{data.suitEndTime}, - suit_expire_time = #{data.suitExpireTime}, - suit_fee_mode = #{data.suitFeeMode}, - suit_fee_type = #{data.suitFeeType}, - suit_gear_amount = #{data.suitGearAmount,typeHandler=com.ruoyi.system.mapper.typehandler.DecimalSplitListTypeHandler}, - suit_gear_time = #{data.suitGearTime,typeHandler=com.ruoyi.system.mapper.typehandler.IntegerSplitListTypeHandler}, - suit_price = #{data.suitPrice}, - suit_start_ele = #{data.suitStartEle}, - suit_end_ele = #{data.suitEndEle}, - store_id = #{data.storeId}, - store_name = #{data.storeName}, - store_address = #{data.storeAddress}, - device_name = #{data.deviceName}, - device_no = #{data.deviceNo}, - suit_name = #{data.suitName}, - device_mac = #{data.deviceMac}, - refund_amount = #{data.refundAmount}, - refund_mch_amount = #{data.refundMchAmount}, - refund_service_amount = #{data.refundServiceAmount}, - pay_picture = #{data.payPicture}, - withdraw_type = #{data.withdrawType}, - offline_image = #{data.offlineImage}, - deposit_pay_id = #{data.depositPayId}, - pay_id = #{data.payId}, + stb.user_id = #{data.userId}, + stb.`type` = #{data.type}, + stb.device_id = #{data.deviceId}, + stb.mch_id = #{data.mchId}, + stb.money = #{data.money}, + stb.arrival_amount = #{data.arrivalAmount}, + stb.service_charge = #{data.serviceCharge}, + stb.create_time = #{data.createTime}, + stb.remark = #{data.remark}, + stb.`status` = #{data.status}, + stb.channel_id = #{data.channelId}, + stb.after_balance = #{data.afterBalance}, + stb.pay_time = #{data.payTime}, + stb.expire_time = #{data.expireTime}, + stb.account_no = #{data.accountNo}, + stb.payed_amount = #{data.payedAmount}, + stb.transfer_ids = #{data.transferIds,typeHandler=com.ruoyi.system.mapper.typehandler.StringListTypeHandler}, + stb.channel_cost = #{data.channelCost}, + stb.suit_id = #{data.suitId}, + stb.suit_time = #{data.suitTime}, + stb.suit_time_unit = #{data.suitTimeUnit}, + stb.suit_start_time = #{data.suitStartTime}, + stb.suit_end_time = #{data.suitEndTime}, + stb.suit_expire_time = #{data.suitExpireTime}, + stb.suit_fee_mode = #{data.suitFeeMode}, + stb.suit_fee_type = #{data.suitFeeType}, + stb.suit_gear_amount = #{data.suitGearAmount,typeHandler=com.ruoyi.system.mapper.typehandler.DecimalSplitListTypeHandler}, + stb.suit_gear_time = #{data.suitGearTime,typeHandler=com.ruoyi.system.mapper.typehandler.IntegerSplitListTypeHandler}, + stb.suit_price = #{data.suitPrice}, + stb.suit_start_ele = #{data.suitStartEle}, + stb.suit_end_ele = #{data.suitEndEle}, + stb.store_id = #{data.storeId}, + stb.store_name = #{data.storeName}, + stb.store_address = #{data.storeAddress}, + stb.device_name = #{data.deviceName}, + stb.device_no = #{data.deviceNo}, + stb.suit_name = #{data.suitName}, + stb.device_mac = #{data.deviceMac}, + stb.refund_amount = #{data.refundAmount}, + stb.refund_mch_amount = #{data.refundMchAmount}, + stb.refund_service_amount = #{data.refundServiceAmount}, + stb.pay_picture = #{data.payPicture}, + stb.withdraw_type = #{data.withdrawType}, + stb.offline_image = #{data.offlineImage}, + stb.deposit_pay_id = #{data.depositPayId}, + stb.pay_id = #{data.payId}, diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/TransactionBillServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/TransactionBillServiceImpl.java index 2f293e36..1ef36de0 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/TransactionBillServiceImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/TransactionBillServiceImpl.java @@ -26,6 +26,7 @@ import com.ruoyi.ss.payBill.domain.vo.DoPayVO; import com.ruoyi.ss.payBill.service.PayBillConverter; import com.ruoyi.ss.payBill.service.PayBillService; import com.ruoyi.ss.receiveBill.service.ReceiveBillService; +import com.ruoyi.ss.record.time.domain.enums.RecordTimeType; import com.ruoyi.ss.record.time.service.IRecordTimeService; import com.ruoyi.ss.record.time.service.RecordTimeConverter; import com.ruoyi.ss.recordBalance.domain.enums.RecordBalanceBstType; @@ -770,7 +771,7 @@ public class TransactionBillServiceImpl implements TransactionBillService, After if (success) { // 记录时长变化 - this.recordTime(bill, "用户充值"); + this.recordTime(bill, "用户充值订单:" + bill.getBillNo()); } else { // 修改设备充值状态为失败 transactionBillMapper.updateDeviceRechargeStatus(billId, TransactionBillDeviceRechargeStatus.FAIL.getStatus()); @@ -1409,7 +1410,7 @@ public class TransactionBillServiceImpl implements TransactionBillService, After // 成功后操作 if (success) { // 时长变化记录 - this.recordTime(bill, "蓝牙手动充值"); + this.recordTime(bill, "蓝牙手动充值订单:" + bill.getBillNo()); } return success; @@ -1423,7 +1424,12 @@ public class TransactionBillServiceImpl implements TransactionBillService, After return; } SmUserVo user = userService.selectSmUserByUserId(bill.getUserId()); - recordTimeService.insertRecordTime(recordTimeConverter.toRecordTime(device, bill.toSecondSuitTime(), reason, user)); + // 根据订单套餐类型记录 + if (SuitFeeType.TIME.getType().equals(bill.getSuitFeeType())) { + recordTimeService.insertRecordTime(recordTimeConverter.toRecordTime(device, bill.toSecondSuitTime(), reason, user, RecordTimeType.TIME.getType())); + } else if (SuitFeeType.COUNT.getType().equals(bill.getSuitFeeType())) { + recordTimeService.insertRecordTime(recordTimeConverter.toRecordTime(device, bill.toSecondSuitTime(), reason, user, RecordTimeType.ELE.getType())); + } }, 1L, TimeUnit.SECONDS); } diff --git a/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppAccountController.java b/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppAccountController.java index 5a9ed49a..0c68589e 100644 --- a/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppAccountController.java +++ b/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppAccountController.java @@ -13,12 +13,16 @@ import com.ruoyi.ss.account.domain.AccountVO; import com.ruoyi.ss.account.domain.enums.AccountType; import com.ruoyi.ss.account.service.AccountService; import com.ruoyi.ss.account.service.AccountValidator; +import com.ruoyi.ss.channelWithdraw.domain.ChannelWithdrawVO; +import com.ruoyi.ss.channelWithdraw.service.ChannelWithdrawService; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import java.util.stream.Collectors; + /** * @author wjh * 2024/3/26 @@ -36,6 +40,9 @@ public class AppAccountController extends BaseController { @Autowired private WxAuthService wxAuthService; + @Autowired + private ChannelWithdrawService channelWithdrawService; + @ApiOperation("添加收款账户") @PostMapping public AjaxResult addAccount(@RequestBody @Validated({ValidGroup.FrontCreate.class}) Account data) { diff --git a/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppDeviceController.java b/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppDeviceController.java index fa19a2d1..dc292745 100644 --- a/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppDeviceController.java +++ b/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppDeviceController.java @@ -125,11 +125,13 @@ public class AppDeviceController extends BaseController { return toAjax(smDeviceService.unbind(deviceId)); } - @Log(title = "设备电量归零", businessType = BusinessType.OTHER, operatorType = OperatorType.MOBILE) - @ApiOperation("设备电量归零") + @Log(title = "设备归零", businessType = BusinessType.OTHER, operatorType = OperatorType.MOBILE) + @ApiOperation("设备归零") @PutMapping("{deviceId}/reset") public AjaxResult reset(@PathVariable @ApiParam("设备id") Long deviceId) { - return success(smDeviceService.resetTimeWithBill(deviceId)); + int r1 = smDeviceService.resetTimeWithBill(deviceId); + int r2 = smDeviceService.resetEleWithBill(deviceId); + return toAjax(r1 >= 0 && r2 >= 0); } @ApiOperation("获取设备用电量分析") diff --git a/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SmDeviceController.java b/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SmDeviceController.java index 158f1c7d..13eb3eaa 100644 --- a/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SmDeviceController.java +++ b/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/SmDeviceController.java @@ -155,7 +155,7 @@ public class SmDeviceController extends BaseController @Log(title = "设备时长归零", businessType = BusinessType.OTHER) @PutMapping("/{deviceId}/reset") public AjaxResult reset(@PathVariable @ApiParam("设备id") Long deviceId) { - return success(deviceService.resetTimeWithBill(deviceId)); + return toAjax(deviceService.resetTimeWithBill(deviceId)); } @PreAuthorize("@ss.hasPermi('system:device:resetEle')")