creaet:饭卡冻结记录

This commit is contained in:
dzc committed 2025-01-03 18:12:58 +08:00
1 parent 51465b7e5b
commit 85f27c56c3
10 files changed
+186 -87

No files matched your search

+14 -11
View File
@@ -113,17 +113,20 @@ CREATE INDEX idx_dept_id ON wallet_active (user_id);
DROP TABLE IF EXISTS wallet_freeze;
CREATE TABLE wallet_freeze
(
id bigint NOT NULL COMMENT '编号',
wallet_id bigint NOT NULL COMMENT '钱包id',
user_id bigint NOT NULL COMMENT '用户id',
free_status tinytext NOT NULL COMMENT '冻结状态',
remark varchar(1024) COMMENT '备注',
create_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
create_time datetime DEFAULT NULL COMMENT '创建时间',
update_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '修改人',
update_time datetime DEFAULT NULL COMMENT '修改时间',
del_flag char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标记',
tenant_id bigint DEFAULT NULL COMMENT '租户ID',
id bigint NOT NULL COMMENT '编号',
process_id varchar(256) COMMENT '流程id',
process_status varchar(10) NOT NULL COMMENT '审核状体',
wallet_id bigint NOT NULL COMMENT '钱包id',
user_id bigint NOT NULL COMMENT '用户id',
dept_id bigint NOT NULL COMMENT '部门id',
free_status tinytext NOT NULL COMMENT '冻结状态',
remark varchar(1024) COMMENT '备注',
create_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
create_time datetime DEFAULT NULL COMMENT '创建时间',
update_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '修改人',
update_time datetime DEFAULT NULL COMMENT '修改时间',
del_flag char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标记',
tenant_id bigint DEFAULT NULL COMMENT '租户ID',
PRIMARY KEY (id)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4 COMMENT ='饭卡冻结记录表';
@@ -8,8 +8,10 @@ import java.util.List;
@Data
public class WalletFreezeDto extends WalletFreezeEntity {
private List<Long> userIds;
private Long walletTypeId;
private String cardNumber;
private List<Long> userIds;
}
@@ -3,8 +3,7 @@ package com.bsd.pjcloud.wallet.api.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.*;
import com.bsd.pjcloud.common.core.util.TenantTable;
import java.time.LocalDateTime;
@@ -14,6 +13,9 @@ import java.time.LocalDateTime;
* @author dzc
* @date 2024-12-31 18:54:43
*/
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Data
@TenantTable
@TableName("wallet_freeze")
@@ -29,6 +31,18 @@ public class WalletFreezeEntity extends Model<WalletFreezeEntity> {
@Schema(description="编号")
private Long id;
/**
* 流程id
*/
@Schema(description = "流程id")
private String processId;
/**
* 流程状态
*/
@Schema(description = "流程状态")
private String processStatus;
/**
* 钱包id
*/
@@ -41,6 +55,12 @@ public class WalletFreezeEntity extends Model<WalletFreezeEntity> {
@Schema(description="用户id")
private Long userId;
/**
* 部门id
*/
@Schema(description="部门id")
private Long deptId;
/**
* 冻结状态
*/
@@ -7,6 +7,10 @@ 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.common.security.annotation.Inner;
import com.bsd.pjcloud.common.security.service.PjcloudUser;
import com.bsd.pjcloud.common.security.util.SecurityUtils;
import com.bsd.pjcloud.flow.task.dto.ProcessNodeRecordAssignUserParamDto;
import com.bsd.pjcloud.wallet.api.dto.WalletFreezeDto;
import com.bsd.pjcloud.wallet.api.entity.WalletFreezeEntity;
import com.bsd.pjcloud.wallet.service.WalletFreezeService;
@@ -30,103 +34,84 @@ import java.util.List;
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/wallet-freeze" )
@Tag(description = "wallet-freeze" , name = "饭卡冻结记录表管理" )
@RequestMapping("/wallet-freeze")
@Tag(description = "wallet-freeze", name = "饭卡冻结记录表管理")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class WalletFreezeController {
private final WalletFreezeService walletFreezeService;
private final WalletFreezeService walletFreezeService;
/**
* 分页查询
* @param page 分页对象
* @param walletFreeze 饭卡冻结记录表
* @return
*/
@Operation(summary = "分页查询" , description = "分页查询" )
@GetMapping("/page" )
@PreAuthorize("@pms.hasPermission('wallet_walletFreeze_view')" )
/* ************************************* start flow callback start ************************************* */
@Inner(value = false)
@PostMapping("/apply-callback")
public void applyCallback(@RequestBody ProcessNodeRecordAssignUserParamDto dto) {
walletFreezeService.applyCallback(dto);
}
/* ************************************* start flow callback start ************************************* */
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('wallet_walletFreeze_view')")
public R getWalletFreezePage(@ParameterObject Page page, @ParameterObject WalletFreezeEntity walletFreeze) {
LambdaQueryWrapper<WalletFreezeEntity> wrapper = Wrappers.lambdaQuery();
return R.ok(walletFreezeService.page(page, wrapper));
}
/**
* 分页复杂查询
* @param page 分页复杂查询
* @param dto 分页复杂查询
* @return
*/
@Operation(summary = "分页复杂查询" , description = "分页复杂查询" )
@GetMapping("/page-join" )
@PreAuthorize("@pms.hasPermission('wallet_walletFreeze_view')" )
@Operation(summary = "分页复杂查询", description = "分页复杂查询")
@GetMapping("/page-join")
@PreAuthorize("@pms.hasPermission('wallet_walletFreeze_view')")
public R getWalletFreezePage(@ParameterObject Page page, @ParameterObject WalletFreezeDto dto) {
return R.ok(walletFreezeService.pageJoin(page, dto));
}
/**
* 通过id查询饭卡冻结记录表
* @param id id
* @return R
*/
@Operation(summary = "通过id查询" , description = "通过id查询" )
@GetMapping("/{id}" )
@PreAuthorize("@pms.hasPermission('wallet_walletFreeze_view')" )
public R getById(@PathVariable("id" ) Long id) {
@Operation(summary = "通过id查询", description = "通过id查询")
@GetMapping("/{id}")
@PreAuthorize("@pms.hasPermission('wallet_walletFreeze_view')")
public R getById(@PathVariable("id") Long id) {
return R.ok(walletFreezeService.getById(id));
}
/**
* 新增饭卡冻结记录表
* @param walletFreeze 饭卡冻结记录表
* @return R
*/
@Operation(summary = "新增饭卡冻结记录表" , description = "新增饭卡冻结记录表" )
@SysLog("新增饭卡冻结记录表" )
@Operation(summary = "新增饭卡冻结记录表", description = "新增饭卡冻结记录表")
@SysLog("新增饭卡冻结记录表")
@PostMapping
@PreAuthorize("@pms.hasPermission('wallet_walletFreeze_add')" )
public R save(@RequestBody WalletFreezeEntity walletFreeze) {
return R.ok(walletFreezeService.save(walletFreeze));
@PreAuthorize("@pms.hasPermission('wallet_walletFreeze_add')")
public R save(@RequestBody WalletFreezeDto dto) {
return R.ok(walletFreezeService.create(dto));
}
/**
* 修改饭卡冻结记录表
* @param walletFreeze 饭卡冻结记录表
* @return R
*/
@Operation(summary = "修改饭卡冻结记录表" , description = "修改饭卡冻结记录表" )
@SysLog("修改饭卡冻结记录表" )
@Operation(summary = "新增饭卡冻结记录表", description = "新增饭卡冻结记录表")
@SysLog("新增饭卡冻结记录表")
@PostMapping("/app")
@PreAuthorize("@pms.hasPermission('wallet_walletFreeze_add')")
public R appSave(@RequestBody WalletFreezeDto dto) {
PjcloudUser loginUser = SecurityUtils.getUser();
dto.setUserId(loginUser.getId());
return R.ok(walletFreezeService.create(dto));
}
@Operation(summary = "修改饭卡冻结记录表", description = "修改饭卡冻结记录表")
@SysLog("修改饭卡冻结记录表")
@PutMapping
@PreAuthorize("@pms.hasPermission('wallet_walletFreeze_edit')" )
@PreAuthorize("@pms.hasPermission('wallet_walletFreeze_edit')")
public R updateById(@RequestBody WalletFreezeEntity walletFreeze) {
return R.ok(walletFreezeService.updateById(walletFreeze));
}
/**
* 通过id删除饭卡冻结记录表
* @param ids id列表
* @return R
*/
@Operation(summary = "通过id删除饭卡冻结记录表" , description = "通过id删除饭卡冻结记录表" )
@SysLog("通过id删除饭卡冻结记录表" )
@Operation(summary = "通过id删除饭卡冻结记录表", description = "通过id删除饭卡冻结记录表")
@SysLog("通过id删除饭卡冻结记录表")
@DeleteMapping
@PreAuthorize("@pms.hasPermission('wallet_walletFreeze_del')" )
@PreAuthorize("@pms.hasPermission('wallet_walletFreeze_del')")
public R removeById(@RequestBody Long[] ids) {
return R.ok(walletFreezeService.removeBatchByIds(CollUtil.toList(ids)));
}
/**
* 导出excel 表格
* @param walletFreeze 查询条件
* @param ids 导出指定ID
* @return excel 文件流
*/
@ResponseExcel
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('wallet_walletFreeze_export')" )
public List<WalletFreezeEntity> export(WalletFreezeEntity walletFreeze,Long[] ids) {
@PreAuthorize("@pms.hasPermission('wallet_walletFreeze_export')")
public List<WalletFreezeEntity> export(WalletFreezeEntity walletFreeze, Long[] ids) {
return walletFreezeService.list(Wrappers.lambdaQuery(walletFreeze).in(ArrayUtil.isNotEmpty(ids), WalletFreezeEntity::getId, ids));
}
}
@@ -23,6 +23,6 @@ public interface WalletFreezeMapper extends PjcloudBaseMapper<WalletFreezeEntity
.leftJoin(WalletManageEntity.class, WalletManageEntity::getId, WalletFreezeEntity::getWalletId)
.eqIfExists(WalletManageEntity::getCardNumber, dto.getCardNumber())
.in(ObjectUtil.isNotEmpty(dto.getUserIds()), WalletFreezeEntity::getId, dto.getUserIds());
return selectJoinPage(page, WalletActiveVo.class, wrapper);
return selectJoinPage(page, WalletFreezeVo.class, wrapper);
}
}
@@ -2,6 +2,7 @@ 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.flow.task.dto.ProcessNodeRecordAssignUserParamDto;
import com.bsd.pjcloud.wallet.api.dto.WalletFreezeDto;
import com.bsd.pjcloud.wallet.api.entity.WalletFreezeEntity;
import com.bsd.pjcloud.wallet.api.vo.WalletFreezeVo;
@@ -9,4 +10,8 @@ import com.bsd.pjcloud.wallet.api.vo.WalletFreezeVo;
public interface WalletFreezeService extends IService<WalletFreezeEntity> {
Page<WalletFreezeVo> pageJoin(Page page, WalletFreezeDto dto);
Long create(WalletFreezeDto dto);
void applyCallback(ProcessNodeRecordAssignUserParamDto dto);
}
@@ -36,7 +36,7 @@ public interface WalletManageService extends IService<WalletManageEntity> {
WalletManageEntity getOrCreateWallet(@NotNull Long userId, @NotNull WalletTypeCodeEnum walletTypeCode);
/**
* 获取钱包(有缓存)
* 获取钱包(没有缓存)
*
* @param userId
* @param walletTypeCode
@@ -44,6 +44,16 @@ public interface WalletManageService extends IService<WalletManageEntity> {
*/
WalletManageEntity getWallet(@NotNull Long userId, @NotNull WalletTypeCodeEnum walletTypeCode);
/**
* 获取钱包(没有缓存)
*
* @param userId
* @param walletTypeId
* @return
*/
WalletManageEntity getWallet(@NotNull Long userId, @NotNull Long walletTypeId);
/**
* 获取钱包(有缓存)
*
@@ -69,7 +69,7 @@ public class WalletForeignServiceImpl extends ServiceImpl<WalletForeignMapper, W
dto.setProcessStatus(TaskCheckStatusEnum.PADDING.getCode());
baseMapper.insert(dto);
// 发起审批
String processId = flowUtil.startFlow("TASK_STRIDE_FLOW", userData.getData().getSysUser(), dto.getId());
String processId = flowUtil.startFlow("TASK_FOREIGN_FLOW", userData.getData().getSysUser(), dto.getId());
baseMapper.updateById(WalletForeignEntity.builder().id(dto.getId()).processId(processId).build());
return dto.getId();
}
@@ -115,8 +115,6 @@ public class WalletForeignServiceImpl extends ServiceImpl<WalletForeignMapper, W
e.printStackTrace();
log.error("|{}|审批回调意外的错误,dto:|{}|error:|{}|", TAG, JSON.toJSONString(dto), e.getMessage());
}
// 创建券
walletCodeUseService.generate(detail.getId(), detail.getUserId(), WalletCodeBizEnum.FOREIGN, detail.getCount());
}
private boolean isCheckData(Long walletId) {
@@ -1,24 +1,37 @@
package com.bsd.pjcloud.wallet.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
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.entity.SysUser;
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.constant.enums.YesNoEnum;
import com.bsd.pjcloud.common.core.util.CollectionUtils;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.flow.task.constant.TaskCheckStatusEnum;
import com.bsd.pjcloud.flow.task.dto.ProcessNodeRecordAssignUserParamDto;
import com.bsd.pjcloud.wallet.api.constant.WalletCodeBizEnum;
import com.bsd.pjcloud.wallet.api.dto.WalletFreezeDto;
import com.bsd.pjcloud.wallet.api.entity.WalletForeignEntity;
import com.bsd.pjcloud.wallet.api.entity.WalletFreezeEntity;
import com.bsd.pjcloud.wallet.api.vo.WalletActiveVo;
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
import com.bsd.pjcloud.wallet.api.entity.WalletStrideEntity;
import com.bsd.pjcloud.wallet.api.vo.WalletFreezeVo;
import com.bsd.pjcloud.wallet.mapper.WalletFreezeMapper;
import com.bsd.pjcloud.wallet.service.WalletFreezeService;
import com.bsd.pjcloud.wallet.service.WalletManageService;
import com.bsd.pjcloud.wallet.service.WalletTypeService;
import com.bsd.pjcloud.wallet.utils.FlowUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import java.util.ArrayList;
@@ -37,9 +50,15 @@ import java.util.Map;
@Service
public class WalletFreezeServiceImpl extends ServiceImpl<WalletFreezeMapper, WalletFreezeEntity> implements WalletFreezeService {
static private final String TAG = "饭卡冻结记录表";
private final RemoteUserService userService;
private final RemoteDeptService deptService;
private final FlowUtil flowUtil;
private final WalletManageService walletManageService;
@Override
public Page<WalletFreezeVo> pageJoin(Page page, WalletFreezeDto dto) {
Page<WalletFreezeVo> list = baseMapper.pageJoin(page, dto);
@@ -60,4 +79,46 @@ public class WalletFreezeServiceImpl extends ServiceImpl<WalletFreezeMapper, Wal
return list;
}
@Override
@Transactional(rollbackFor = Exception.class)
public Long create(WalletFreezeDto dto) {
// 查询发起人
R<UserInfo> userData = userService.getByUserId(dto.getUserId());
if (ObjectUtil.isEmpty(userData.getData())) {
throw new RuntimeException("发起人不存在");
}
// 查询钱包
WalletManageEntity wallet = walletManageService.getWallet(dto.getUserId(), dto.getWalletTypeId());
if (ObjectUtil.isEmpty(wallet)) {
throw new RuntimeException("用户钱包不存在");
}
dto.setDeptId(userData.getData().getSysUser().getDeptId());
dto.setFreeStatus(YesNoEnum.NO.getCode());
dto.setWalletId(wallet.getId());
dto.setProcessStatus(TaskCheckStatusEnum.PADDING.getCode());
baseMapper.insert(dto);
// 发起审批
String processId = flowUtil.startFlow("TASK_FREEZE_FLOW", userData.getData().getSysUser(), dto.getId());
baseMapper.updateById(WalletFreezeEntity.builder().id(dto.getId()).processId(processId).build());
return dto.getId();
}
@Override
@Transactional(rollbackFor = Exception.class)
public void applyCallback(ProcessNodeRecordAssignUserParamDto dto) {
if (!flowUtil.checkCallback(dto)) return;
String processId = dto.getProcessInstanceId();
WalletFreezeEntity detail = baseMapper.selectOne(new LambdaQueryWrapper<WalletFreezeEntity>()
.eq(WalletFreezeEntity::getProcessId, processId)
);
if (ObjectUtil.isEmpty(detail)) return;
try {
Boolean isConsent = flowUtil.isConsent(dto);
String processStatus = isConsent ? TaskCheckStatusEnum.RESULT.getCode() : TaskCheckStatusEnum.REJECT.getCode();
baseMapper.updateById(WalletFreezeEntity.builder().id(detail.getId()).freeStatus(YesNoEnum.YES.getCode()).processStatus(processStatus).build());
} catch (Exception e) {
e.printStackTrace();
log.error("|{}|审批回调意外的错误,dto:|{}|error:|{}|", TAG, JSON.toJSONString(dto), e.getMessage());
}
}
}
@@ -65,11 +65,16 @@ public class WalletManageServiceImpl extends ServiceImpl<WalletManageMapper, Wal
UserInfo user = null;
if (checkPermission) {
user = userService.getByUserId(userId).getData();
String autoWalletRoleCode = ParamResolver.getStr("WALLET_AUTO_CREATE");
if (ObjectUtil.isEmpty(autoWalletRoleCode)) {
log.info("|{}|创建用户电子钱包失败,userId:{},WALLET_AUTO_CREATE参数未配置", TAG, userId);
return;
}
if (ObjectUtil.isEmpty(user)) {
log.info("|{}|创建用户电子钱包失败,userId:{},用户id不存在", TAG, userId);
return;
}
String role = Arrays.stream(user.getRoleCodes()).filter(v -> ObjectUtil.equals(v, ParamResolver.getStr("WALLET_AUTO_CREATE"))).findFirst().get();
String role = Arrays.stream(user.getRoleCodes()).filter(v -> ObjectUtil.equals(v, autoWalletRoleCode)).findFirst().get();
if (ObjectUtil.isEmpty(role)) {
log.info("|{}|创建用户电子钱包失败,userId:{},没有{}权限", TAG, userId, "WALLET_AUTO_CREATE");
return;
@@ -117,6 +122,16 @@ public class WalletManageServiceImpl extends ServiceImpl<WalletManageMapper, Wal
);
}
@Override
public WalletManageEntity getWallet(Long userId, Long walletTypeId) {
WalletTypeEntity walletType = walletTypeService.getById(walletTypeId);
if (ObjectUtil.isEmpty(walletType)) return null;
return baseMapper.selectOne(new LambdaQueryWrapper<WalletManageEntity>()
.eq(WalletManageEntity::getUserId, userId)
.eq(WalletManageEntity::getWalletTypeId, walletType.getId())
);
}
@Override
@Cacheable(value = CacheConstants.WALLET_DETAIL, key = "#walletId", condition = "#walletId != null", unless = "#result == null")
public WalletManageEntity getWallet(Long walletId) {