diff --git a/db/800pjcloudx_wallet.sql b/db/800pjcloudx_wallet.sql index 674c8cf96..6e84d7e81 100644 --- a/db/800pjcloudx_wallet.sql +++ b/db/800pjcloudx_wallet.sql @@ -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 ='饭卡冻结记录表'; diff --git a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/dto/WalletFreezeDto.java b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/dto/WalletFreezeDto.java index 151e1834d..bd14e0adc 100644 --- a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/dto/WalletFreezeDto.java +++ b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/dto/WalletFreezeDto.java @@ -8,8 +8,10 @@ import java.util.List; @Data public class WalletFreezeDto extends WalletFreezeEntity { - private List userIds; + private Long walletTypeId; private String cardNumber; + private List userIds; + } diff --git a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/entity/WalletFreezeEntity.java b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/entity/WalletFreezeEntity.java index 6071d5684..0a898e871 100644 --- a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/entity/WalletFreezeEntity.java +++ b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/entity/WalletFreezeEntity.java @@ -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 { @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 { @Schema(description="用户id") private Long userId; + /** + * 部门id + */ + @Schema(description="部门id") + private Long deptId; + /** * 冻结状态 */ diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/WalletFreezeController.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/WalletFreezeController.java index 6629aa1ac..4f44e368a 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/WalletFreezeController.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/WalletFreezeController.java @@ -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 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 export(WalletFreezeEntity walletFreeze,Long[] ids) { + @PreAuthorize("@pms.hasPermission('wallet_walletFreeze_export')") + public List export(WalletFreezeEntity walletFreeze, Long[] ids) { return walletFreezeService.list(Wrappers.lambdaQuery(walletFreeze).in(ArrayUtil.isNotEmpty(ids), WalletFreezeEntity::getId, ids)); } } \ No newline at end of file diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletFreezeMapper.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletFreezeMapper.java index 27ecf4321..c985867a3 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletFreezeMapper.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletFreezeMapper.java @@ -23,6 +23,6 @@ public interface WalletFreezeMapper extends PjcloudBaseMapper { Page pageJoin(Page page, WalletFreezeDto dto); + + Long create(WalletFreezeDto dto); + + void applyCallback(ProcessNodeRecordAssignUserParamDto dto); } \ No newline at end of file diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/WalletManageService.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/WalletManageService.java index ec0f40f33..ae225218e 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/WalletManageService.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/WalletManageService.java @@ -36,7 +36,7 @@ public interface WalletManageService extends IService { WalletManageEntity getOrCreateWallet(@NotNull Long userId, @NotNull WalletTypeCodeEnum walletTypeCode); /** - * 获取钱包(有缓存) + * 获取钱包(没有缓存) * * @param userId * @param walletTypeCode @@ -44,6 +44,16 @@ public interface WalletManageService extends IService { */ WalletManageEntity getWallet(@NotNull Long userId, @NotNull WalletTypeCodeEnum walletTypeCode); + + /** + * 获取钱包(没有缓存) + * + * @param userId + * @param walletTypeId + * @return + */ + WalletManageEntity getWallet(@NotNull Long userId, @NotNull Long walletTypeId); + /** * 获取钱包(有缓存) * diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/WalletForeignServiceImpl.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/WalletForeignServiceImpl.java index 0428afca7..67f22ba98 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/WalletForeignServiceImpl.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/WalletForeignServiceImpl.java @@ -69,7 +69,7 @@ public class WalletForeignServiceImpl extends ServiceImpl 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 pageJoin(Page page, WalletFreezeDto dto) { Page list = baseMapper.pageJoin(page, dto); @@ -60,4 +79,46 @@ public class WalletFreezeServiceImpl extends ServiceImpl 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() + .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()); + } + } } \ No newline at end of file diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/WalletManageServiceImpl.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/WalletManageServiceImpl.java index a20edf7f8..03aa5a581 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/WalletManageServiceImpl.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/WalletManageServiceImpl.java @@ -65,11 +65,16 @@ public class WalletManageServiceImpl extends ServiceImpl 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() + .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) {