1
dd
2025-10-21 8dcc757d17dd3bed804167a0aa640a978f10022c
1
4 files modified
5 files added
230 ■■■■■ changed files
ruoyi-admin/src/main/java/com/ruoyi/im/service/impl/UserPolicyServiceImpl.java 6 ●●●●● patch | view | raw | blame | history
ruoyi-admin/src/main/java/com/ruoyi/web/controller/product/UserKycController.java 5 ●●●● patch | view | raw | blame | history
ruoyi-admin/src/main/java/com/ruoyi/web/controller/product/UserPolicyController.java 25 ●●●●● patch | view | raw | blame | history
ruoyi-admin/src/main/java/com/ruoyi/web/controller/product/UserWalletControlkler.java 8 ●●●●● patch | view | raw | blame | history
ruoyi-system/src/main/java/com/ruoyi/system/domain/FundsLog.java 53 ●●●●● patch | view | raw | blame | history
ruoyi-system/src/main/java/com/ruoyi/system/domain/OperationType.java 72 ●●●●● patch | view | raw | blame | history
ruoyi-system/src/main/java/com/ruoyi/system/mapper/FundsLogMapper.java 9 ●●●●● patch | view | raw | blame | history
ruoyi-system/src/main/java/com/ruoyi/system/service/FundsLogService.java 23 ●●●●● patch | view | raw | blame | history
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/FundsLogServiceImpl.java 29 ●●●●● patch | view | raw | blame | history
ruoyi-admin/src/main/java/com/ruoyi/im/service/impl/UserPolicyServiceImpl.java
@@ -17,6 +17,7 @@
import com.ruoyi.system.domain.*;
import com.ruoyi.system.domain.dto.UserPolicyDto;
import com.ruoyi.system.mapper.UserPolicyMapper;
import com.ruoyi.system.service.FundsLogService;
import com.ruoyi.system.service.GroupWelcomeConfigService;
import com.ruoyi.system.service.PaymentRecordService;
import com.ruoyi.system.service.UserAccountService;
@@ -50,6 +51,8 @@
    private UserKycService userKycService;
    @Autowired
    private GroupWelcomeConfigService groupWelcomeConfigService;
    @Autowired
    private FundsLogService fundsLogService;
    @Override
@@ -226,6 +229,9 @@
            paymentRecord.setProductName(insuranceProduct.getProductName());
            paymentRecord.setModePayment(3);
            paymentRecordService.save(paymentRecord);
            fundsLogService.addLog(userAccount.getId(), userAccount.getAccount(), insuranceProduct.getPremium(), OperationType.USER_ORDER);
            // 生成资金日志
            return Result.success();
        }
    }
ruoyi-admin/src/main/java/com/ruoyi/web/controller/product/UserKycController.java
@@ -228,7 +228,10 @@
     */
    @GetMapping("/getAccountPassword")
    @Transactional
    public AjaxResult getAccountPassword(@RequestParam(value = "account") String account) {
    public AjaxResult getAccountPassword(@RequestParam(value = "account",required = false) String account) {
        if(ObjectUtil.isEmpty(account)){
            return AjaxResult.error("请输入查询账号!");
        }
        UserAccount userAccount = userAccountService.getOne(new LambdaQueryWrapper<>(UserAccount.class)
                .eq(UserAccount::getAccount, account)
        );
ruoyi-admin/src/main/java/com/ruoyi/web/controller/product/UserPolicyController.java
@@ -22,6 +22,7 @@
import com.ruoyi.system.domain.dto.UserPolicyDto;
import com.ruoyi.im.service.UserPolicyService;
import com.ruoyi.system.domain.out.UserTeamAndPositionOut;
import com.ruoyi.system.service.FundsLogService;
import com.ruoyi.system.service.PaymentRecordService;
import com.ruoyi.system.service.UserAccountService;
import lombok.extern.slf4j.Slf4j;
@@ -69,6 +70,9 @@
    @Autowired
    PaymentRecordService paymentRecordService;
    @Autowired
    FundsLogService fundsLogService;
    @Value("${pay.key}")
    private String key;
@@ -243,6 +247,8 @@
                userAccount.setBalance(userAccount.getBalance().add(userPolicy.getPremium()));
                userAccountService.updateById(userAccount);
                fundsLogService.addLog(userAccount.getId(), userAccount.getAccount(), userPolicy.getPremium(), OperationType.REFUND);
                return AjaxResult.success("审批成功");
            }
@@ -569,4 +575,23 @@
        return AjaxResult.success("删除成功");
    }
    /**
     * 保单列表
     */
    @GetMapping("/getFundsLogList")
    public TableDataInfo getFundsLogList(@RequestParam(value = "account",required = false)  String account,@RequestParam(value = "operationType",required = false)  Integer operationType) {
        startPage();
        LambdaQueryWrapper<FundsLog> wrapper = new LambdaQueryWrapper<>();
       if(StringUtils.isNotEmpty(account)){
           wrapper.eq(FundsLog::getAccount,account);
       }
       if (ObjectUtil.isNotEmpty(operationType)){
           wrapper.eq(FundsLog::getOperationType,operationType);
       }
        wrapper.orderByDesc(FundsLog::getCreateTime);
        List<FundsLog> list = fundsLogService.list(wrapper);
        return getDataTable(list);
    }
}
ruoyi-admin/src/main/java/com/ruoyi/web/controller/product/UserWalletControlkler.java
@@ -3,8 +3,10 @@
import cn.hutool.core.util.ObjectUtil;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.OperationType;
import com.ruoyi.system.domain.UserAccount;
import com.ruoyi.system.domain.UserKyc;
import com.ruoyi.system.service.FundsLogService;
import com.ruoyi.system.service.UserAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
@@ -23,6 +25,9 @@
    @Autowired
    UserAccountService userAccountService;
    @Autowired
    FundsLogService fundsLogService;
    /**
     * 用户资金操作
@@ -56,6 +61,9 @@
                return AjaxResult.success("充值类型错误");
            }
            userAccountService.updateById(userAccount);
            fundsLogService.addLog(userAccount.getId(), userAccount.getAccount(), money, type == 1 ? OperationType.ADMIN_RECHARGE : OperationType.ADMIN_DEDUCTION);
            return AjaxResult.success("充值成功");
        }catch (Exception e){
            e.printStackTrace();
ruoyi-system/src/main/java/com/ruoyi/system/domain/FundsLog.java
New file
@@ -0,0 +1,53 @@
package com.ruoyi.system.domain;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Data
public class FundsLog {
    /**
     * 主键ID
     */
    private Long id;
    /**
     * 用户ID
     */
    private Integer userId;
    /**
     * 账号
     */
    private String account;
    /**
     * 操作类型
     * 1-后台充值 2-后台扣款 3-用户下单 4-退款
     */
    private Integer operationType;
    /**
     * 操作金额
     */
    private BigDecimal amount;
    /**
     * 创建时间
     */
    private LocalDateTime createTime;
    /**
     * 更新时间
     */
    private LocalDateTime updateTime;
    // 构造方法
    public FundsLog() {
        this.createTime = LocalDateTime.now();
        this.updateTime = LocalDateTime.now();
    }
}
ruoyi-system/src/main/java/com/ruoyi/system/domain/OperationType.java
New file
@@ -0,0 +1,72 @@
package com.ruoyi.system.domain;
/**
 * 资金操作类型枚举
 */
public enum OperationType {
    /**
     * 后台充值 - 1
     */
    ADMIN_RECHARGE(1, "后台充值"),
    /**
     * 后台扣款 - 2
     */
    ADMIN_DEDUCTION(2, "后台扣款"),
    /**
     * 用户下单 - 3
     */
    USER_ORDER(3, "用户下单"),
    /**
     * 退款 - 4
     */
    REFUND(4, "退款");
    private final int code;
    private final String description;
    OperationType(int code, String description) {
        this.code = code;
        this.description = description;
    }
    public int getCode() {
        return code;
    }
    public String getDescription() {
        return description;
    }
    /**
     * 根据代码获取操作类型枚举
     * @param code 操作类型代码
     * @return 对应的枚举值,如果不存在返回null
     */
    public static OperationType getByCode(int code) {
        for (OperationType type : values()) {
            if (type.getCode() == code) {
                return type;
            }
        }
        return null;
    }
    /**
     * 根据描述获取操作类型枚举
     * @param description 操作类型描述
     * @return 对应的枚举值,如果不存在返回null
     */
    public static OperationType getByDescription(String description) {
        for (OperationType type : values()) {
            if (type.getDescription().equals(description)) {
                return type;
            }
        }
        return null;
    }
}
ruoyi-system/src/main/java/com/ruoyi/system/mapper/FundsLogMapper.java
New file
@@ -0,0 +1,9 @@
package com.ruoyi.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.system.domain.FundsLog;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface FundsLogMapper extends BaseMapper<FundsLog> {
}
ruoyi-system/src/main/java/com/ruoyi/system/service/FundsLogService.java
New file
@@ -0,0 +1,23 @@
package com.ruoyi.system.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.system.domain.FundsLog;
import com.ruoyi.system.domain.InvitationBlacklist;
import com.ruoyi.system.domain.OperationType;
import java.math.BigDecimal;
import java.util.List;
public interface FundsLogService extends IService<FundsLog> {
    /**
     * 后台充值
     * @param userId 用户ID
     * @param account 账户标识
     * @param amount 充值金额
     * @return 记录成功的资金日志ID
     */
    void addLog(Integer userId, String account, BigDecimal amount,OperationType operationType);
}
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/FundsLogServiceImpl.java
New file
@@ -0,0 +1,29 @@
package com.ruoyi.system.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.system.domain.FundsLog;
import com.ruoyi.system.domain.OperationType;
import com.ruoyi.system.mapper.FundsLogMapper;
import com.ruoyi.system.service.FundsLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.List;
@Service
public class FundsLogServiceImpl extends ServiceImpl<FundsLogMapper, FundsLog> implements FundsLogService {
    @Override
    public void addLog(Integer userId, String account, BigDecimal amount, OperationType operationType) {
        // 创建资金日志记录
        FundsLog fundsLog = new FundsLog();
        fundsLog.setUserId(userId);
        fundsLog.setAccount(account);
        fundsLog.setOperationType(operationType.getCode());
        fundsLog.setAmount(amount);
        save(fundsLog);
    }
}