feat:用户钱包安全删除判断
This commit is contained in:
1 parent
c5c400c807
commit
c481a2d261
14 files changed
+260
-69
No files matched your search
+11
-3
@@ -142,8 +142,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
BeanUtils.copyProperties(userDto, sysUser);
|
||||
// 判断是否为部门管理员
|
||||
PjcloudUser applyUser = SecurityUtils.getUser();
|
||||
boolean isDeptAdmin=false;
|
||||
if (null!=applyUser){
|
||||
boolean isDeptAdmin = false;
|
||||
if (null != applyUser) {
|
||||
isDeptAdmin = sysRoleService.isDeptAdmin(applyUser.getId());
|
||||
if (isDeptAdmin) {
|
||||
List<SysRole> defaultRoles = sysRoleService.findRolesByCodes(List.of(CommonRoleConstant.DEFAULT_USER, CommonRoleConstant.AUTO_CREATE_WALLET));
|
||||
@@ -323,8 +323,16 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean deleteUserByIds(Long[] ids) {
|
||||
// 删除 spring cache
|
||||
List<SysUser> userList = baseMapper.selectBatchIds(CollUtil.toList(ids));
|
||||
// 判断是否可以删除
|
||||
userList.forEach(v -> {
|
||||
String errorMsg = remoteWalletService.isDel(v.getUserId()).getData();
|
||||
if (ObjectUtil.isNotEmpty(errorMsg)) {
|
||||
throw new RuntimeException(errorMsg);
|
||||
}
|
||||
});
|
||||
|
||||
// 删除 spring cache
|
||||
Cache cache = cacheManager.getCache(CacheConstants.USER_DETAILS);
|
||||
for (SysUser sysUser : userList) {
|
||||
cache.evict(sysUser.getUsername());
|
||||
|
||||
+1
@@ -15,6 +15,7 @@ public enum WalletBizEnum {
|
||||
RECHARGE("3", "充值"),
|
||||
PAYMENT("4", "支付"),
|
||||
REFUND("5", "退款"),
|
||||
TRANSFER_ACCOUNTS("6", "转账"),
|
||||
;
|
||||
private final String code;
|
||||
|
||||
|
||||
+15
-1
@@ -1,6 +1,20 @@
|
||||
package com.bsd.pjcloud.wallet.api.dto.rule;
|
||||
|
||||
import com.bsd.pjcloud.admin.api.vo.base.BaseIsIncludeTreeInterface;
|
||||
import com.bsd.pjcloud.wallet.api.entity.rule.WalletRuleTransactionEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class WalletRuleTransactionDto extends WalletRuleTransactionEntity implements BaseIsIncludeTreeInterface {
|
||||
|
||||
/**
|
||||
* 树状结构搜索
|
||||
*/
|
||||
|
||||
private List<Long> deptIds;
|
||||
|
||||
private Boolean isInclude = false;
|
||||
|
||||
public class WalletRuleTransactionDto extends WalletRuleTransactionEntity {
|
||||
}
|
||||
+66
-65
@@ -6,6 +6,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import com.bsd.pjcloud.common.core.util.TenantTable;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
@@ -19,100 +20,100 @@ import java.time.LocalDateTime;
|
||||
public class WalletRuleTransactionEntity extends Model<WalletRuleTransactionEntity> {
|
||||
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@Schema(description="主键")
|
||||
@Schema(description = "主键")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 源钱包id
|
||||
*/
|
||||
@Schema(description="源钱包id")
|
||||
/**
|
||||
* 源钱包id
|
||||
*/
|
||||
@Schema(description = "源钱包id")
|
||||
private Long sourceWalletId;
|
||||
|
||||
/**
|
||||
* 目标钱包id
|
||||
*/
|
||||
@Schema(description="目标钱包id")
|
||||
/**
|
||||
* 目标钱包id
|
||||
*/
|
||||
@Schema(description = "目标钱包id")
|
||||
private Long targetWalletId;
|
||||
|
||||
/**
|
||||
* 源钱包余额
|
||||
*/
|
||||
@Schema(description="源钱包余额")
|
||||
/**
|
||||
* 源钱包余额
|
||||
*/
|
||||
@Schema(description = "源钱包余额")
|
||||
private Integer sourceWalletBalance;
|
||||
|
||||
/**
|
||||
* 目标钱包余额
|
||||
*/
|
||||
@Schema(description="目标钱包余额")
|
||||
/**
|
||||
* 目标钱包余额
|
||||
*/
|
||||
@Schema(description = "目标钱包余额")
|
||||
private Integer targetWalletBalance;
|
||||
|
||||
/**
|
||||
* 转换金额
|
||||
*/
|
||||
@Schema(description="转换金额")
|
||||
/**
|
||||
* 转换金额
|
||||
*/
|
||||
@Schema(description = "转换金额")
|
||||
private Integer balance;
|
||||
|
||||
/**
|
||||
* 转换后的金额
|
||||
*/
|
||||
@Schema(description="转换后的金额")
|
||||
/**
|
||||
* 转换后的金额
|
||||
*/
|
||||
@Schema(description = "转换后的金额")
|
||||
private Integer afterBalance;
|
||||
|
||||
/**
|
||||
* 钱包转换百分比
|
||||
*/
|
||||
@Schema(description="钱包转换百分比")
|
||||
/**
|
||||
* 钱包转换百分比
|
||||
*/
|
||||
@Schema(description = "钱包转换百分比")
|
||||
private Integer balanceMultiple;
|
||||
|
||||
/**
|
||||
* 是否退回
|
||||
*/
|
||||
@Schema(description="是否退回")
|
||||
/**
|
||||
* 是否退回
|
||||
*/
|
||||
@Schema(description = "是否退回")
|
||||
private String isRefund;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description="创建人")
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description = "创建人")
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description="创建时间")
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@Schema(description="修改人")
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@Schema(description = "修改人")
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@Schema(description="修改时间")
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@Schema(description = "修改时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 删除标记
|
||||
*/
|
||||
/**
|
||||
* 删除标记
|
||||
*/
|
||||
@TableLogic
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description="删除标记")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description = "删除标记")
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
@Schema(description="租户ID")
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
@Schema(description = "租户ID")
|
||||
private Long tenantId;
|
||||
}
|
||||
+3
@@ -49,4 +49,7 @@ public interface RemoteWalletService {
|
||||
|
||||
@GetMapping("/wallet-manage/dept-change")
|
||||
R<Boolean> deptChange(@RequestParam Long deptId, @RequestParam Boolean isDel);
|
||||
|
||||
@GetMapping("/wallet-manage/is-del")
|
||||
R<String> isDel(@RequestParam Long userId);
|
||||
}
|
||||
+24
@@ -1,6 +1,30 @@
|
||||
package com.bsd.pjcloud.wallet.api.vo.rule;
|
||||
|
||||
import com.bsd.pjcloud.wallet.api.entity.rule.WalletRuleTransactionEntity;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class WalletRuleTransactionVo extends WalletRuleTransactionEntity {
|
||||
|
||||
/**
|
||||
* 用户相关
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
* 源钱包相关
|
||||
*/
|
||||
private String sourceWalletTypeName;
|
||||
|
||||
private String sourceWalletTypeCode;
|
||||
|
||||
/**
|
||||
* 目标钱包相关
|
||||
*/
|
||||
private String targetWalletTypeName;
|
||||
|
||||
private String targetWalletTypeCode;
|
||||
|
||||
}
|
||||
+5
@@ -126,6 +126,11 @@ public class WalletManageController {
|
||||
return R.ok(true);
|
||||
}
|
||||
|
||||
@GetMapping("/is-del")
|
||||
public R<String> isDel(@RequestParam Long userId) {
|
||||
return R.ok(walletManageService.isDel(userId));
|
||||
}
|
||||
|
||||
/* ************************************* end 远程调用 end ************************************* */
|
||||
|
||||
|
||||
|
||||
+11
@@ -6,7 +6,10 @@ 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.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScopeFuncEnum;
|
||||
import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||
import com.bsd.pjcloud.wallet.api.dto.rule.WalletRuleTransactionDto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.rule.WalletRuleTransactionEntity;
|
||||
import com.bsd.pjcloud.wallet.service.WalletRuleTransactionService;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -42,6 +45,14 @@ public class WalletRuleTransactionController {
|
||||
return R.ok(walletRuleTransactionService.page(page, wrapper));
|
||||
}
|
||||
|
||||
@Operation(summary = "分页复杂查询", description = "分页复杂查询")
|
||||
@GetMapping("/page-join")
|
||||
@PreAuthorize("@pms.hasPermission('wallet_walletRuleTransaction_view')")
|
||||
public R pageJoin(@ParameterObject Page page, @ParameterObject WalletRuleTransactionDto dto) {
|
||||
DataScope dataScope = DataScope.of().func(DataScopeFuncEnum.ALL);
|
||||
return R.ok(walletRuleTransactionService.scopePageList(page, dto, dataScope));
|
||||
}
|
||||
|
||||
@Operation(summary = "通过id查询", description = "通过id查询")
|
||||
@GetMapping("/{id}")
|
||||
@PreAuthorize("@pms.hasPermission('wallet_walletRuleTransaction_view')")
|
||||
|
||||
+6
@@ -1,11 +1,17 @@
|
||||
package com.bsd.pjcloud.wallet.mapper.rule;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
|
||||
import com.bsd.pjcloud.wallet.api.dto.rule.WalletRuleTransactionDto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.rule.WalletRuleTransactionEntity;
|
||||
import com.bsd.pjcloud.wallet.api.vo.rule.WalletRuleTransactionVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@Mapper
|
||||
public interface WalletRuleTransactionMapper extends PjcloudBaseMapper<WalletRuleTransactionEntity> {
|
||||
|
||||
Page<WalletRuleTransactionVo> scopePageList(Page page, @Param("dto") WalletRuleTransactionDto dto, DataScope dataScope);
|
||||
|
||||
}
|
||||
+5
@@ -124,4 +124,9 @@ public interface WalletManageService extends IService<WalletManageEntity> {
|
||||
* 修改部门
|
||||
*/
|
||||
void deptChange(Long deptId, Boolean isDel);
|
||||
|
||||
/**
|
||||
* 是否可以删除该用户
|
||||
*/
|
||||
String isDel(Long userId);
|
||||
}
|
||||
+9
@@ -1,8 +1,17 @@
|
||||
package com.bsd.pjcloud.wallet.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.wallet.api.dto.rule.WalletRuleTransactionDto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.rule.WalletRuleTransactionEntity;
|
||||
import com.bsd.pjcloud.wallet.api.vo.rule.WalletRuleTransactionVo;
|
||||
|
||||
public interface WalletRuleTransactionService extends IService<WalletRuleTransactionEntity> {
|
||||
|
||||
/**
|
||||
* 分页复杂查询
|
||||
*/
|
||||
Page<WalletRuleTransactionVo> scopePageList(Page page, WalletRuleTransactionDto dto, DataScope dataScope);
|
||||
|
||||
}
|
||||
+29
@@ -39,6 +39,7 @@ import com.bsd.pjcloud.wallet.api.dto.WalletManageDto;
|
||||
import com.bsd.pjcloud.wallet.api.dto.WalletTypeDto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletActiveEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletTransactionEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity;
|
||||
import com.bsd.pjcloud.wallet.api.utils.WalletDataUtil;
|
||||
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
|
||||
@@ -46,6 +47,7 @@ import com.bsd.pjcloud.wallet.api.vo.WalletManageBalanceVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletManageVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletSettingVo;
|
||||
import com.bsd.pjcloud.wallet.mapper.WalletManageMapper;
|
||||
import com.bsd.pjcloud.wallet.mapper.WalletTransactionMapper;
|
||||
import com.bsd.pjcloud.wallet.mapper.WalletTypeMapper;
|
||||
import com.bsd.pjcloud.wallet.service.*;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
@@ -93,6 +95,7 @@ public class WalletManageServiceImpl extends ServiceImpl<WalletManageMapper, Wal
|
||||
private final RemoteDeptService deptService;
|
||||
|
||||
private final StringRedisTemplate redisTemplate;
|
||||
private final WalletTransactionMapper walletTransactionMapper;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -445,6 +448,32 @@ public class WalletManageServiceImpl extends ServiceImpl<WalletManageMapper, Wal
|
||||
// walletThirdZyService.syncAllDept(deptId, isDel);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否可以删除该用户
|
||||
* 返回空字符串就是可以删除
|
||||
*/
|
||||
@Override
|
||||
public String isDel(Long userId) {
|
||||
// 查询是否有钱包记录
|
||||
Long transactionCount = walletTransactionMapper.selectCount(new LambdaQueryWrapper<WalletTransactionEntity>()
|
||||
.eq(WalletTransactionEntity::getUserId, userId)
|
||||
);
|
||||
if (transactionCount > 0) {
|
||||
return "用户有消费记录,不能删除";
|
||||
}
|
||||
// 钱包类型
|
||||
List<WalletTypeEntity> walletList = walletTypeMapper.selectList(null);
|
||||
if (ObjectUtil.isEmpty(walletList)) return "";
|
||||
for (WalletTypeEntity v : walletList) {
|
||||
WalletManageEntity wallet = getWallet(userId, v.getId());
|
||||
if (ObjectUtil.isEmpty(wallet)) continue;
|
||||
if (wallet.getBalance() > 0) {
|
||||
return "用户" + v.getName() + ",还有" + wallet.getBalance() / 100 + "元,不能删除";
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private void disposeList(List<WalletManageVo> list, WalletManageDto dto) {
|
||||
if (ObjectUtil.isNotEmpty(list)) {
|
||||
// 用户
|
||||
|
||||
+12
@@ -1,7 +1,11 @@
|
||||
package com.bsd.pjcloud.wallet.service.impl.rule;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.wallet.api.dto.rule.WalletRuleTransactionDto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.rule.WalletRuleTransactionEntity;
|
||||
import com.bsd.pjcloud.wallet.api.vo.rule.WalletRuleTransactionVo;
|
||||
import com.bsd.pjcloud.wallet.mapper.rule.WalletRuleTransactionMapper;
|
||||
import com.bsd.pjcloud.wallet.service.WalletRuleTransactionService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -17,4 +21,12 @@ import org.springframework.validation.annotation.Validated;
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class WalletRuleTransactionServiceImpl extends ServiceImpl<WalletRuleTransactionMapper, WalletRuleTransactionEntity> implements WalletRuleTransactionService {
|
||||
|
||||
/**
|
||||
* 分页复杂查询
|
||||
*/
|
||||
@Override
|
||||
public Page<WalletRuleTransactionVo> scopePageList(Page page, WalletRuleTransactionDto dto, DataScope dataScope) {
|
||||
return baseMapper.scopePageList(page, dto, dataScope);
|
||||
}
|
||||
}
|
||||
+63
@@ -19,4 +19,67 @@
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
<result property="tenantId" column="tenant_id"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectA">
|
||||
select a.id,
|
||||
a.source_wallet_id,
|
||||
a.target_wallet_id,
|
||||
a.source_wallet_balance,
|
||||
a.target_wallet_balance,
|
||||
a.balance,
|
||||
a.after_balance,
|
||||
a.balance_multiple,
|
||||
a.is_refund,
|
||||
a.create_by,
|
||||
a.create_time,
|
||||
a.update_by,
|
||||
a.update_time,
|
||||
a.del_flag,
|
||||
a.tenant_id,
|
||||
</sql>
|
||||
|
||||
<sql id="whereA">
|
||||
a.del_flag = 0
|
||||
<if test="dto.sourceWalletId != null">
|
||||
and a.source_wallet_id = #{dto.sourceWalletId}
|
||||
</if>
|
||||
<if test="dto.targetWalletId != null">
|
||||
and a.target_wallet_id = #{dto.targetWalletId}
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="scopePageList" resultType="com.bsd.pjcloud.wallet.api.vo.rule.WalletRuleTransactionVo">
|
||||
<include refid="selectA"/>
|
||||
t.user_id,
|
||||
t.dept_id,
|
||||
sourceWalletType.name as sourceWalletTypeName,
|
||||
sourceWalletType.unique_code as sourceWalletTypeCode,
|
||||
targetWalletType.name as targetWalletTypeName,
|
||||
targetWalletType.unique_code as targetWalletTypeCode
|
||||
from wallet_rule_transaction a
|
||||
left join wallet_transaction t on t.biz_id = a.id and biz_type = '6'
|
||||
left join wallet_manage sourceWallet on sourceWallet.id = a.source_wallet_id
|
||||
left join wallet_type sourceWalletType on sourceWalletType.id = sourceWallet.wallet_type_id
|
||||
left join wallet_manage targetWallet on targetWallet.id = a.target_wallet_id
|
||||
left join wallet_type targetWalletType on targetWalletType.id = targetWallet.wallet_type_id
|
||||
<where>
|
||||
<include refid="whereA"/>
|
||||
<if test="dto.deptIds != null and dto.deptIds.size() != 0">
|
||||
<choose>
|
||||
<when test="dto.isInclude != null and dto.isInclude == true">
|
||||
and a.dept_id IN
|
||||
</when>
|
||||
<when test="dto.isInclude != null and dto.isInclude == false">
|
||||
and a.dept_id NOT IN
|
||||
</when>
|
||||
<otherwise>
|
||||
and a.dept_id IN
|
||||
</otherwise>
|
||||
</choose>
|
||||
<foreach collection="dto.deptIds" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in new issue
Block a user