feat:默认选中

This commit is contained in:
dzc committed 2025-04-01 12:56:18 +08:00
1 parent 75814f3876
commit 8712745fbd
14 files changed
+186 -76

No files matched your search

@@ -18,6 +18,8 @@ public class MchManageDto extends MchManageEntity {
private List<Long> ids;
private List<Long> notIds;
private String type;
private Boolean parentIsNull = true;
@@ -10,4 +10,6 @@ public class WalletTypeDto extends WalletTypeEntity {
private List<Long> walletTypeIds;
private List<Long> notWalletTypeIds;
}
@@ -0,0 +1,9 @@
package com.bsd.pjcloud.wallet.api.vo;
import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity;
import lombok.Data;
@Data
public class WalletTypeVo extends WalletTypeEntity {
}
@@ -10,23 +10,47 @@ public class WalletRuleJoinUserConfigVo {
*/
private Long userId;
private Long userDpetId;
private String username;
/**
* 钱包相关
*/
private Long walletId;
private String userMobile;
private Long walletTypeId;
/**
* 源钱包相关
*/
private Long sourceWalletId;
private Integer sourceWalletBalance = 0;
private Long sourceWalletTypeId;
private String sourceWalletTypeName;
/**
* 目标钱包相关
*/
private Long targetWalletId;
private Integer targetWalletBalance = 0;
private Long targetWalletTypeId;
private String targetWalletTypeName;
/**
* 可以转账的余额
*/
private Integer changeTransferBalance = 0;
/**
* 总充值余额
*/
private Long totalTopUpBalance;
private Long totalTopUpBalance = 0L;
/**
* 总的转账余额
*/
private Long totalTransferBalance;
private Long totalTransferBalance = 0L;
}
@@ -150,7 +150,7 @@ public class WalletManageController {
@GetMapping("/app/detail")
public R appGetAll(@RequestParam Long walletId) {
PjcloudUser user = SecurityUtils.getUser();
return R.ok(walletManageService.join(user.getId(), walletId));
return R.ok(walletManageService.join(walletId));
}
@GetMapping("/app/get-qr-code")
@@ -194,7 +194,7 @@ public class WalletManageController {
@GetMapping("/join/{id}")
@PreAuthorize("@pms.hasPermission('wallet_walletManage_view')")
public R<WalletManageVo> joinDetail(@PathVariable("id") Long id) {
return R.ok(walletManageService.join(null, id));
return R.ok(walletManageService.join(id));
}
@Operation(summary = "新增钱包管理", description = "新增钱包管理")
@@ -2,11 +2,13 @@ package com.bsd.pjcloud.wallet.controller;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.wallet.api.dto.WalletTypeDto;
import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity;
import com.bsd.pjcloud.wallet.service.WalletTypeService;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -37,40 +39,24 @@ public class WalletTypeController {
private final WalletTypeService walletTypeService;
/**
* 分页查询
*
* @param page 分页对象
* @param walletType 钱包类型
* @return
*/
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('wallet_walletType_view')")
public R getWalletTypePage(@ParameterObject Page page, @ParameterObject WalletTypeEntity walletType) {
public R getWalletTypePage(@ParameterObject Page page, @ParameterObject WalletTypeDto dto) {
LambdaQueryWrapper<WalletTypeEntity> wrapper = Wrappers.lambdaQuery();
wrapper.orderByDesc(WalletTypeEntity::getCreateTime);
return R.ok(walletTypeService.page(page, wrapper));
}
/**
* 查询下拉
*/
@Operation(summary = "查询下拉", description = "查询下拉")
@GetMapping("/select")
public R<Page<WalletTypeEntity>> walletList(@ParameterObject Page page) {
public R<Page<WalletTypeEntity>> walletList(@ParameterObject Page page, @ParameterObject WalletTypeDto dto) {
LambdaQueryWrapper<WalletTypeEntity> wrapper = Wrappers.lambdaQuery();
wrapper.orderByDesc(WalletTypeEntity::getCreateTime);
wrapper.notIn(ObjectUtil.isNotEmpty(dto.getNotWalletTypeIds()), WalletTypeEntity::getId, dto.getNotWalletTypeIds());
return R.ok(walletTypeService.page(page, wrapper));
}
/**
* 通过id查询钱包类型
*
* @param id id
* @return R
*/
@Operation(summary = "通过id查询", description = "通过id查询")
@GetMapping("/{id}")
@PreAuthorize("@pms.hasPermission('wallet_walletType_view')")
@@ -78,12 +64,6 @@ public class WalletTypeController {
return R.ok(walletTypeService.getById(id));
}
/**
* 新增钱包类型
*
* @param dto 钱包类型
* @return R
*/
@Operation(summary = "新增钱包类型", description = "新增钱包类型")
@SysLog("新增钱包类型")
@PostMapping
@@ -93,12 +73,6 @@ public class WalletTypeController {
return R.ok(true);
}
/**
* 修改钱包类型
*
* @param dto 钱包类型
* @return R
*/
@Operation(summary = "修改钱包类型", description = "修改钱包类型")
@SysLog("修改钱包类型")
@PutMapping
@@ -108,12 +82,6 @@ public class WalletTypeController {
return R.ok(true);
}
/**
* 通过id删除钱包类型
*
* @param ids id列表
* @return R
*/
@Operation(summary = "通过id删除钱包类型", description = "通过id删除钱包类型")
@SysLog("通过id删除钱包类型")
@DeleteMapping
@@ -122,14 +90,6 @@ public class WalletTypeController {
return R.ok(walletTypeService.removeBatchByIds(CollUtil.toList(ids)));
}
/**
* 导出excel 表格
*
* @param walletType 查询条件
* @param ids 导出指定ID
* @return excel 文件流
*/
@ResponseExcel
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('wallet_walletType_export')")
@@ -59,17 +59,17 @@ public class WalletRuleJoinController {
}
@Operation(summary = "通过id查询", description = "通过id查询")
@GetMapping("join-detail/{id}")
@GetMapping("/join-detail/{id}")
// @PreAuthorize("@pms.hasPermission('dzc_walletRuleMchConfig_view')")
public R joinDetail(@PathVariable("id") Long id) {
return R.ok(walletRuleJoinService.joinDetail(id));
}
@Operation(summary = "查询用户转账配置", description = "查询用户转账配置")
@GetMapping("user-config/{walletId}")
@GetMapping("/user-config")
// @PreAuthorize("@pms.hasPermission('dzc_walletRuleMchConfig_view')")
public R userConfig(@PathVariable("walletId") Long walletId) {
return R.ok(walletRuleJoinService.userConfig(walletId));
public R userConfig(@RequestParam Long userId, @RequestParam Long sourceWalletTypeId, @RequestParam Long targetWalletTypeId) {
return R.ok(walletRuleJoinService.userConfig(userId, sourceWalletTypeId, targetWalletTypeId));
}
@Operation(summary = "新增钱包规则配置", description = "新增钱包规则配置")
@@ -71,6 +71,7 @@ public interface MchManageMapper extends PjcloudBaseMapper<MchManageEntity> {
.like(ObjectUtil.isNotEmpty(dto.getName()), MchManageEntity::getName, dto.getName())
.in(ObjectUtil.isNotEmpty(dto.getDeptIds()), MchManageEntity::getDeptId, dto.getDeptIds())
.in(ObjectUtil.isNotEmpty(dto.getIds()), MchManageEntity::getId, dto.getIds())
.in(ObjectUtil.isNotEmpty(dto.getNotIds()), MchManageEntity::getId, dto.getNotIds())
.orderByDesc(MchManageEntity::getSort)
.orderByDesc(MchManageEntity::getDeptId)
.orderByDesc(MchManageEntity::getCreateTime);
@@ -106,5 +106,7 @@ public interface WalletTransactionMapper extends PjcloudBaseMapper<WalletTransac
@Param("dateTime") String monthTimeStr,
@Param("userIdList") List<Long> userIdList);
WalletTransactionSumAndCountVo sumAndCountUser(@Param("dto") WalletTransactionSumAndCountDto dto);
List<WalletTransactionSumAndCountVo> sumAndCount(@Param("dto") WalletTransactionSumAndCountDto dto);
}
@@ -64,29 +64,22 @@ public interface WalletManageService extends IService<WalletManageEntity> {
List<WalletManageVo> scopeQbList(WalletManageBalanceDto dto, DataScope dataScope);
WalletManageVo join(Long user, Long walletId);
WalletManageVo join(Long walletId);
WalletManageVo join(Long user, Long walletTypeId);
/**
* 生成钱包二维码参数
*
* @param walletId 钱包id
*/
String getQrCode(Long walletId);
/**
* 导出
*
* @param response
* @param dto
*/
void export(HttpServletResponse response, Page page, WalletManageDto dto);
/**
* 钱包记录导出
*
* @param response
* @param page
* @param dto
*/
void exportQb(HttpServletResponse response, Page page, WalletManageBalanceDto dto);
@@ -40,5 +40,5 @@ public interface WalletRuleJoinService extends IService<WalletRuleJoinEntity> {
/**
* 用户配置
*/
WalletRuleJoinUserConfigVo userConfig(Long walletId);
WalletRuleJoinUserConfigVo userConfig(Long userId, Long sourceWalletTypeId, Long targetWalletTypeId);
}
@@ -250,7 +250,7 @@ public class WalletManageServiceImpl extends ServiceImpl<WalletManageMapper, Wal
}
@Override
public WalletManageVo join(Long userId, Long walletId) {
public WalletManageVo join(Long walletId) {
WalletManageVo detail = baseMapper.join(walletId);
if (ObjectUtil.isNotEmpty(detail)) {
// 用户
@@ -262,6 +262,27 @@ public class WalletManageServiceImpl extends ServiceImpl<WalletManageMapper, Wal
return detail;
}
@Override
public WalletManageVo join(Long userId, Long walletTypeId) {
WalletManageEntity detail = getWallet(userId, walletTypeId);
if (ObjectUtil.isEmpty(detail)) return null;
WalletManageVo result = BeanUtils.toBean(detail, WalletManageVo.class);
if (ObjectUtil.isNotEmpty(detail)) {
// 用户
UserInfo userInfo = userService.getByUserId(detail.getUserId()).getData();
if (ObjectUtil.isNotEmpty(userInfo)) {
DataUtil.convertUser(result, userInfo.getSysUser());
}
// 钱包类型
WalletTypeEntity walletType = walletTypeService.getById(detail.getWalletTypeId());
if (ObjectUtil.isNotEmpty(walletType)) {
WalletDataUtil.convertWalletType(result, walletType);
}
detail.getWalletTypeId();
}
return result;
}
@Override
public Page<WalletManageVo> scopeQbPage(Page page, WalletManageBalanceDto dto, DataScope dataScope) {
WalletManageDto walletDto = BeanUtils.toBean(dto, WalletManageDto.class);
@@ -4,8 +4,10 @@ import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.admin.api.dto.UserInfo;
import com.bsd.pjcloud.admin.api.entity.SysDept;
import com.bsd.pjcloud.admin.api.feign.RemoteDeptService;
import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
import com.bsd.pjcloud.admin.api.utils.DataUtil;
import com.bsd.pjcloud.common.core.util.BeanUtils;
import com.bsd.pjcloud.common.core.util.R;
@@ -13,6 +15,7 @@ import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.wallet.api.constant.WalletBizEnum;
import com.bsd.pjcloud.wallet.api.dto.WalletTransactionSumAndCountDto;
import com.bsd.pjcloud.wallet.api.dto.rule.WalletRuleJoinDto;
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity;
import com.bsd.pjcloud.wallet.api.entity.rule.WalletRuleJoinEntity;
import com.bsd.pjcloud.wallet.api.vo.WalletManageVo;
@@ -21,6 +24,7 @@ import com.bsd.pjcloud.wallet.api.vo.rule.WalletRuleJoinUserConfigVo;
import com.bsd.pjcloud.wallet.api.vo.rule.WalletRuleJoinVo;
import com.bsd.pjcloud.wallet.mapper.WalletTransactionMapper;
import com.bsd.pjcloud.wallet.mapper.rule.WalletRuleJoinMapper;
import com.bsd.pjcloud.wallet.service.WalletManageService;
import com.bsd.pjcloud.wallet.service.WalletRuleJoinService;
import com.bsd.pjcloud.wallet.service.WalletTypeService;
import lombok.RequiredArgsConstructor;
@@ -44,8 +48,10 @@ public class WalletRuleJoinServiceImpl extends ServiceImpl<WalletRuleJoinMapper,
private final WalletTransactionMapper walletTransactionMapper;
private final WalletTypeService walletTypeService;
private final WalletManageService walletManageService;
private final RemoteDeptService remoteDeptService;
private final RemoteUserService remoteUserService;
/**
* 权限分页查询
@@ -117,15 +123,65 @@ public class WalletRuleJoinServiceImpl extends ServiceImpl<WalletRuleJoinMapper,
}
@Override
public WalletRuleJoinUserConfigVo userConfig(Long walletId) {
public WalletRuleJoinUserConfigVo userConfig(Long userId, Long sourceWalletTypeId, Long targetWalletTypeId) {
WalletRuleJoinUserConfigVo configVo = new WalletRuleJoinUserConfigVo();
// 查询用户充值的总余额
// 源钱包信息
WalletManageVo sourceWallet = walletManageService.join(userId, sourceWalletTypeId);
if (ObjectUtil.isEmpty(sourceWallet)) {
throw new RuntimeException("源钱包不存在");
}
configVo.setSourceWalletId(sourceWallet.getId());
configVo.setTargetWalletBalance(sourceWallet.getBalance());
configVo.setSourceWalletTypeId(sourceWallet.getWalletTypeId());
configVo.setSourceWalletTypeName(sourceWallet.getWalletTypeName());
// 目标钱包信息
WalletManageVo targetWallet = walletManageService.join(userId, targetWalletTypeId);
if (ObjectUtil.isEmpty(targetWallet)) {
throw new RuntimeException("目标钱包不存在");
}
configVo.setTargetWalletId(targetWallet.getId());
configVo.setTargetWalletBalance(targetWallet.getBalance());
configVo.setTargetWalletTypeId(targetWallet.getWalletTypeId());
configVo.setTargetWalletTypeName(targetWallet.getWalletTypeName());
// 查询用户充值的总充值余额
WalletTransactionSumAndCountDto totalTopupDto = new WalletTransactionSumAndCountDto();
totalTopupDto.setBizTypes(WalletBizEnum.getTopUpCodes());
totalTopupDto.setType(WalletTransactionSumAndCountDto.TYPE_INCOME);
totalTopupDto.setWalletId(walletId);
List<WalletTransactionSumAndCountVo> totalTopupVo = walletTransactionMapper.sumAndCount(totalTopupDto);
return null;
totalTopupDto.setWalletTypeId(sourceWalletTypeId);
WalletTransactionSumAndCountVo totalTopupVo = walletTransactionMapper.sumAndCountUser(totalTopupDto);
if (ObjectUtil.isNotEmpty(totalTopupVo) && ObjectUtil.isNotEmpty(totalTopupVo.getSum())) {
configVo.setTotalTopUpBalance(totalTopupVo.getSum());
}
// 查询总的转账余额
WalletTransactionSumAndCountDto transferBalanceDto = new WalletTransactionSumAndCountDto();
totalTopupDto.setBizTypes(List.of(WalletBizEnum.TRANSFER_ACCOUNTS.getCode()));
totalTopupDto.setType(WalletTransactionSumAndCountDto.TYPE_INCOME);
totalTopupDto.setWalletTypeId(targetWalletTypeId);
WalletTransactionSumAndCountVo transferBalanceVo = walletTransactionMapper.sumAndCountUser(transferBalanceDto);
if (ObjectUtil.isNotEmpty(transferBalanceVo)) {
configVo.setTotalTransferBalance(transferBalanceVo.getSum());
}
// 转账百分比配置
// 查询用户
UserInfo userInfo = remoteUserService.getByUserId(sourceWallet.getUserId()).getData();
if (ObjectUtil.isEmpty(userInfo)) {
throw new RuntimeException("用户不存在");
}
configVo.setUserId(userInfo.getSysUser().getUserId());
configVo.setUserDpetId(userInfo.getSysUser().getDeptId());
configVo.setUsername(userInfo.getSysUser().getName());
configVo.setUserMobile(userInfo.getSysUser().getPhone());
WalletRuleJoinEntity walletRuleJoin = baseMapper.selectOne(new LambdaQueryWrapper<WalletRuleJoinEntity>()
.eq(WalletRuleJoinEntity::getSourceWalletTypeId, sourceWallet.getWalletTypeId())
.eq(WalletRuleJoinEntity::getTargetWalletTypeId, targetWallet.getWalletTypeId())
.eq(WalletRuleJoinEntity::getTargetDeptId, userInfo.getSysUser().getDeptId())
);
if (ObjectUtil.isEmpty(walletRuleJoin)) {
// 查询部门
SysDept sysDept = remoteDeptService.getDeptByDeptId(userInfo.getSysUser().getDeptId()).getData();
throw new RuntimeException("该用户所属的部门<" + sysDept.getName() + ">未配置钱包规则");
}
return configVo;
}
/**
@@ -16,7 +16,6 @@
</sql>
<sql id="whereA">
</sql>
<select id="getTransactionPriceCount" resultType="java.lang.Integer">
@@ -89,4 +88,45 @@
</where>
group by a.dept_id
</select>
<select id="sumAndCountUser" resultType="com.bsd.pjcloud.wallet.api.vo.WalletTransactionSumAndCountVo">
select a.dept_id,
sum(a.price) as sum,
count(0) as count
from wallet_transaction a
left join wallet_manage m on a.wallet_id = m.id
left join wallet_type t on t.id = m.wallet_type_id
<where>
a.del_flag = 0 and a.dept_id is not null
<if test="dto.walletId != null">
and a.wallet_id = ${dto.walletId}
</if>
<if test="dto.walletTypeId != null">
and m.wallet_type_id = ${dto.walletTypeId}
</if>
<if test="dto.type != null">
<if test="dto.type == 1">
and a.price &gt; 0
</if>
<if test="dto.type == 2">
and a.price &lt; 0
</if>
</if>
<if test="dto.bizTypes != null and dto.bizTypes.size() != 0">
and a.biz_type in
<foreach collection="dto.bizTypes" item="v" open="(" close=")" separator=",">
#{v}
</foreach>
</if>
<if test="dto.deptIds != null and dto.deptIds.size() != 0">
and a.dept_id in
<foreach collection="dto.deptIds" item="v" open="(" close=")" separator=",">
#{v}
</foreach>
</if>
<if test="dto.createTimeList != null and dto.createTimeList.length == 2">
and a.create_time between #{dto.createTimeList[0]} and #{dto.createTimeList[1]}
</if>
</where>
</select>
</mapper>