From 667d0211420d3e9280426407d64a327c75209a47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A2=A8=E5=A4=A7=E5=8F=94?= <494979559@qq.com> Date: Sun, 15 Sep 2024 17:04:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/core/domain/entity/SmUser.java | 4 +++ .../common/pay/syb/config/SybConfig.java | 3 +++ .../common/pay/syb/service/SybPayService.java | 2 +- .../system/domain/enums/config/ConfigKey.java | 3 ++- .../system/service/ISysConfigService.java | 7 +++++ .../service/impl/SysConfigServiceImpl.java | 13 +++++++++ .../bonus/service/impl/BonusServiceImpl.java | 27 +++++++++++++++++++ .../service/impl/DeviceServiceImpl.java | 5 ++++ .../ruoyi/ss/refund/mapper/RefundMapper.xml | 5 ++-- .../impl/TransactionBillServiceImpl.java | 4 --- .../com/ruoyi/ss/user/mapper/SmUserMapper.xml | 4 +++ .../ruoyi/ss/user/service/ISmUserService.java | 7 +++++ .../user/service/impl/SmUserServiceImpl.java | 7 +++++ .../mch/MchStoreApplyController.java | 1 + .../src/main/resources/application-dev.yml | 2 ++ .../src/main/resources/application-prod.yml | 2 ++ 16 files changed, 87 insertions(+), 9 deletions(-) diff --git a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/core/domain/entity/SmUser.java b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/core/domain/entity/SmUser.java index b833c9f4..9bdcdad5 100644 --- a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/core/domain/entity/SmUser.java +++ b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/core/domain/entity/SmUser.java @@ -185,4 +185,8 @@ public class SmUser extends BaseEntity @Excel(name = "代理商服务费比例") @ApiModelProperty("代理商服务费比例") private BigDecimal agentServiceRate; + + @Excel(name = "到账延迟时间", readConverterExp = "小=时") + @ApiModelProperty("到账延迟时间") + private Long arrivalDelay; } diff --git a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/pay/syb/config/SybConfig.java b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/pay/syb/config/SybConfig.java index a231b542..44aa2dbd 100644 --- a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/pay/syb/config/SybConfig.java +++ b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/pay/syb/config/SybConfig.java @@ -22,6 +22,9 @@ public class SybConfig { // 应用ID private String appId; + // 子应用ID + private String subAppId; + // MD5密钥 private String md5AppKey; diff --git a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/pay/syb/service/SybPayService.java b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/pay/syb/service/SybPayService.java index 298887b9..4223196d 100644 --- a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/pay/syb/service/SybPayService.java +++ b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/pay/syb/service/SybPayService.java @@ -47,7 +47,7 @@ public class SybPayService { "", "", "", - "", + sybConfig.getSubAppId(), "", "", "", diff --git a/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/domain/enums/config/ConfigKey.java b/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/domain/enums/config/ConfigKey.java index 6912caa2..0ecd7b6f 100644 --- a/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/domain/enums/config/ConfigKey.java +++ b/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/domain/enums/config/ConfigKey.java @@ -20,7 +20,8 @@ public enum ConfigKey { DAILY_WITHDRAW_AMOUNT("daily.withdraw.amount", "单日单用户提现限额(元)"), DAILY_WITHDRAW_COUNT("daily.withdraw.count", "单日单用户提现次数(次)"), NOVERIFY_WITHDRAW_SINGLE("noverify.withdraw.single", "提现单笔免审核额度(元)"), - RECHARGE_MIN_SERVICE("recharge.min.service","充值最低服务费(元)"); + RECHARGE_MIN_SERVICE("recharge.min.service","充值最低服务费(元)"), + ARRIVAL_DELAY("arrival.delay", "延迟到账时间(小时)"); private final String key; private final String msg; diff --git a/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/service/ISysConfigService.java b/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/service/ISysConfigService.java index 3f8c12f9..67f0bea6 100644 --- a/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/service/ISysConfigService.java +++ b/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/service/ISysConfigService.java @@ -107,4 +107,11 @@ public interface ISysConfigService List selectByIds(List configIds); int batchUpdateValue(List list); + + /** + * 获取int配置 + * @param key + * @return + */ + int getInt(ConfigKey key); } diff --git a/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java b/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java index cb7dbdcc..0909cf86 100644 --- a/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java +++ b/smart-switch-ruoyi/smart-switch-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java @@ -275,6 +275,19 @@ public class SysConfigServiceImpl implements ISysConfigService return result == null ? 0 : result; } + @Override + public int getInt(ConfigKey key) { + String s = this.selectConfigByKey(key.getKey()); + if (StringUtils.isBlank(s)) { + return 0; + } + try { + return Integer.parseInt(s); + } catch (Exception e) { + return 0; + } + } + /** * 设置cache key * diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/service/impl/BonusServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/service/impl/BonusServiceImpl.java index b1b2ffc2..d7a0b476 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/service/impl/BonusServiceImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/service/impl/BonusServiceImpl.java @@ -2,6 +2,7 @@ package com.ruoyi.ss.bonus.service.impl; import java.math.BigDecimal; import java.math.RoundingMode; +import java.time.LocalDateTime; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; @@ -22,7 +23,10 @@ import com.ruoyi.ss.bonus.domain.vo.BonusMonthAmountVO; import com.ruoyi.ss.bonus.domain.vo.ProvideBonusVO; import com.ruoyi.ss.recordBalance.domain.enums.RecordBalanceBstType; import com.ruoyi.ss.store.service.StoreService; +import com.ruoyi.ss.user.domain.SmUserVo; import com.ruoyi.ss.user.service.ISmUserService; +import com.ruoyi.system.domain.enums.config.ConfigKey; +import com.ruoyi.system.service.ISysConfigService; import com.ruoyi.system.service.ISysDeptService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -57,6 +61,9 @@ public class BonusServiceImpl implements BonusService @Autowired private StoreService storeService; + @Autowired + private ISysConfigService sysConfigService; + /** * 查询分成明细 * @@ -184,12 +191,32 @@ public class BonusServiceImpl implements BonusService BigDecimal decimal100 = new BigDecimal(100); BigDecimal dividedAmount = BigDecimal.ZERO; // 已分配金额 + // 获取用户列表 + List userList = userService.selectByUserIds(bonusList.stream() + .filter(item -> BonusArrivalType.userList().contains(item.getArrivalType())) + .map(BonusVO::getArrivalId) + .collect(Collectors.toList()) + ); + // 获取全局配置,默认延迟到账时间 + int defaultDelay = sysConfigService.getInt(ConfigKey.ARRIVAL_DELAY); + + LocalDateTime now = LocalDateTime.now(); + + LocalDateTime defaultPrePayTime = now.plusHours(defaultDelay); + + // 循环遍历,构造分成金额 for (BonusVO bonus : bonusList) { BigDecimal amount = money.multiply(bonus.getPoint()).divide(decimal100, 2, RoundingMode.HALF_UP); bonus.setAmount(amount); bonus.setStatus(BonusStatus.WAIT_DIVIDE.getStatus()); // TODO 预计分成时间 + if (BonusArrivalType.userList().contains(bonus.getArrivalType())) { + SmUserVo user = userList.stream().filter(item -> item.getUserId().equals(bonus.getArrivalId())).findFirst().orElse(null); + bonus.setPrePayTime(); + } else { + bonus.setPrePayTime(now); + } dividedAmount = dividedAmount.add(amount); } // 平台吃掉误差 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 7e0c1c64..ab83d75e 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 @@ -807,6 +807,11 @@ public class DeviceServiceImpl implements DeviceService } } + ServiceUtil.assertion(device.getLimitRechargeTime() != null + && device.getLimitRechargeTime().isAfter(LocalDateTime.now()), + "设备无法绑定:" + device.getLimitRechargeReason() + ); + // 查询用户 SmUserVo user = userService.selectSimpleById(userId); ServiceUtil.assertion(user == null, "用户不存在"); diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/refund/mapper/RefundMapper.xml b/smart-switch-service/src/main/java/com/ruoyi/ss/refund/mapper/RefundMapper.xml index 28763f2e..d4b3acbd 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/refund/mapper/RefundMapper.xml +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/refund/mapper/RefundMapper.xml @@ -36,9 +36,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and sr.user_type = #{query.userType} and sr.user_id = #{query.userId} and sr.user_name like concat('%', #{query.userName}, '%') - and smb.mch_id = #{query.billMchId} - and bst_type = #{query.bstType} - and channel_id = #{query.channelId} + and sr.bst_type = #{query.bstType} + and sr.channel_id = #{query.channelId}