diff --git a/db/800pjcloudx_wallet.sql b/db/800pjcloudx_wallet.sql index bb6bf0f6d..ef2fa0e2f 100644 --- a/db/800pjcloudx_wallet.sql +++ b/db/800pjcloudx_wallet.sql @@ -209,7 +209,7 @@ CREATE TABLE wallet_rule_transaction balance int DEFAULT 0 NOT NULL COMMENT '转换金额', after_balance int DEFAULT 0 NOT NULL COMMENT '转换后的金额', balance_multiple int DEFAULT 0 NOT NULL COMMENT '钱包转换百分比', - status VARCHAR(64) default '0' not null comment '是否启用', + is_refund VARCHAR(64) default '0' not null 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 '修改人', diff --git a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/dto/rule/WalletRuleJoinDto.java b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/dto/rule/WalletRuleJoinDto.java index cf20316f0..5d9f6f7b2 100644 --- a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/dto/rule/WalletRuleJoinDto.java +++ b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/dto/rule/WalletRuleJoinDto.java @@ -7,8 +7,8 @@ import lombok.Data; import lombok.NoArgsConstructor; @Data -@Builder -@AllArgsConstructor -@NoArgsConstructor +//@Builder +//@AllArgsConstructor +//@NoArgsConstructor public class WalletRuleJoinDto extends WalletRuleJoinEntity { } diff --git a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/dto/rule/WalletRuleTransactionDto.java b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/dto/rule/WalletRuleTransactionDto.java new file mode 100644 index 000000000..80f9be574 --- /dev/null +++ b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/dto/rule/WalletRuleTransactionDto.java @@ -0,0 +1,6 @@ +package com.bsd.pjcloud.wallet.api.dto.rule; + +import com.bsd.pjcloud.wallet.api.entity.rule.WalletRuleTransactionEntity; + +public class WalletRuleTransactionDto extends WalletRuleTransactionEntity { +} diff --git a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/entity/rule/WalletRuleTransactionEntity.java b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/entity/rule/WalletRuleTransactionEntity.java new file mode 100644 index 000000000..35dfaae66 --- /dev/null +++ b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/entity/rule/WalletRuleTransactionEntity.java @@ -0,0 +1,118 @@ +package com.bsd.pjcloud.wallet.api.entity.rule; + +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 com.bsd.pjcloud.common.core.util.TenantTable; +import java.time.LocalDateTime; + +/** + * 钱包转账记录 + */ +@Data +@TenantTable +@TableName("wallet_rule_transaction") +@EqualsAndHashCode(callSuper = true) +@Schema(description = "钱包转账记录") +public class WalletRuleTransactionEntity extends Model { + + + /** + * 主键 + */ + @TableId(type = IdType.ASSIGN_ID) + @Schema(description="主键") + private Long id; + + /** + * 源钱包id + */ + @Schema(description="源钱包id") + private Long sourceWalletId; + + /** + * 目标钱包id + */ + @Schema(description="目标钱包id") + private Long targetWalletId; + + /** + * 源钱包余额 + */ + @Schema(description="源钱包余额") + private Integer sourceWalletBalance; + + /** + * 目标钱包余额 + */ + @Schema(description="目标钱包余额") + private Integer targetWalletBalance; + + /** + * 转换金额 + */ + @Schema(description="转换金额") + private Integer balance; + + /** + * 转换后的金额 + */ + @Schema(description="转换后的金额") + private Integer afterBalance; + + /** + * 钱包转换百分比 + */ + @Schema(description="钱包转换百分比") + private Integer balanceMultiple; + + /** + * 是否退回 + */ + @Schema(description="是否退回") + private String isRefund; + + /** + * 创建人 + */ + @TableField(fill = FieldFill.INSERT) + @Schema(description="创建人") + private String createBy; + + /** + * 创建时间 + */ + @TableField(fill = FieldFill.INSERT) + @Schema(description="创建时间") + private LocalDateTime createTime; + + /** + * 修改人 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + @Schema(description="修改人") + private String updateBy; + + /** + * 修改时间 + */ + @TableField(fill = FieldFill.INSERT_UPDATE) + @Schema(description="修改时间") + private LocalDateTime updateTime; + + /** + * 删除标记 + */ + @TableLogic + @TableField(fill = FieldFill.INSERT) + @Schema(description="删除标记") + private String delFlag; + + /** + * 租户ID + */ + @Schema(description="租户ID") + private Long tenantId; +} \ No newline at end of file diff --git a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/vo/rule/WalletRuleJoinVo.java b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/vo/rule/WalletRuleJoinVo.java index fd709165d..04d489bdb 100644 --- a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/vo/rule/WalletRuleJoinVo.java +++ b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/vo/rule/WalletRuleJoinVo.java @@ -12,4 +12,22 @@ import lombok.NoArgsConstructor; @AllArgsConstructor @NoArgsConstructor public class WalletRuleJoinVo extends WalletRuleJoinEntity { + + /** + * 源钱包类型 + */ + private String sourceName; + + private String sourceUniqueCode; + + private String sourceIcon; + + /** + * 目标钱包类型 + */ + private String targetName; + + private String targetUniqueCode; + + private String targetIcon; } diff --git a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/vo/rule/WalletRuleTransactionVo.java b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/vo/rule/WalletRuleTransactionVo.java new file mode 100644 index 000000000..806aae3af --- /dev/null +++ b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/vo/rule/WalletRuleTransactionVo.java @@ -0,0 +1,6 @@ +package com.bsd.pjcloud.wallet.api.vo.rule; + +import com.bsd.pjcloud.wallet.api.entity.rule.WalletRuleTransactionEntity; + +public class WalletRuleTransactionVo extends WalletRuleTransactionEntity { +} diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/rule/WalletRuleJoinController.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/rule/WalletRuleJoinController.java index c45463c86..f1869c4ee 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/rule/WalletRuleJoinController.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/rule/WalletRuleJoinController.java @@ -6,10 +6,11 @@ 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.log.annotation.SysLog; +import com.bsd.pjcloud.wallet.api.dto.rule.WalletRuleJoinDto; import com.bsd.pjcloud.wallet.api.entity.rule.WalletRuleJoinEntity; import com.bsd.pjcloud.wallet.service.WalletRuleJoinService; -import org.springframework.security.access.prepost.PreAuthorize; import com.bsd.pjcloud.common.excel.annotation.ResponseExcel; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import org.springdoc.core.annotations.ParameterObject; @@ -17,10 +18,10 @@ import org.springframework.http.HttpHeaders; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.Operation; import lombok.RequiredArgsConstructor; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import java.util.List; -import java.util.Objects; /** * 钱包规则配置 @@ -36,46 +37,62 @@ public class WalletRuleJoinController { @Operation(summary = "分页查询", description = "分页查询") @GetMapping("/page") - @PreAuthorize("@pms.hasPermission('wallet_walletRuleJoin_view')") + // @PreAuthorize("@pms.hasPermission('wallet_walletRuleJoin_view')") public R getWalletRuleJoinPage(@ParameterObject Page page, @ParameterObject WalletRuleJoinEntity walletRuleJoin) { LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); return R.ok(walletRuleJoinService.page(page, wrapper)); } + @Operation(summary = "分页复杂查询", description = "分页复杂查询") + @GetMapping("/page-join") + // @PreAuthorize("@pms.hasPermission('wallet_walletRuleJoin_view')") + public R pageJoin(@ParameterObject Page page, @ParameterObject WalletRuleJoinDto dto) { + DataScope dataScope = null; + return R.ok(walletRuleJoinService.scopeJoinPage(page, dto, dataScope)); + } + @Operation(summary = "通过id查询", description = "通过id查询") @GetMapping("/{id}") - @PreAuthorize("@pms.hasPermission('wallet_walletRuleJoin_view')") + // @PreAuthorize("@pms.hasPermission('wallet_walletRuleJoin_view')") public R getById(@PathVariable("id") Long id) { return R.ok(walletRuleJoinService.getById(id)); } + @Operation(summary = "通过id查询", description = "通过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 = "新增钱包规则配置") @SysLog("新增钱包规则配置") @PostMapping - @PreAuthorize("@pms.hasPermission('wallet_walletRuleJoin_add')") + // @PreAuthorize("@pms.hasPermission('wallet_walletRuleJoin_add')") public R save(@RequestBody WalletRuleJoinEntity walletRuleJoin) { - return R.ok(walletRuleJoinService.save(walletRuleJoin)); + return R.ok(walletRuleJoinService.create(walletRuleJoin)); } @Operation(summary = "修改钱包规则配置", description = "修改钱包规则配置") @SysLog("修改钱包规则配置") @PutMapping - @PreAuthorize("@pms.hasPermission('wallet_walletRuleJoin_edit')") + // @PreAuthorize("@pms.hasPermission('wallet_walletRuleJoin_edit')") public R updateById(@RequestBody WalletRuleJoinEntity walletRuleJoin) { - return R.ok(walletRuleJoinService.updateById(walletRuleJoin)); + return R.ok(walletRuleJoinService.edit(walletRuleJoin)); } @Operation(summary = "通过id删除钱包规则配置", description = "通过id删除钱包规则配置") @SysLog("通过id删除钱包规则配置") @DeleteMapping - @PreAuthorize("@pms.hasPermission('wallet_walletRuleJoin_del')") + // @PreAuthorize("@pms.hasPermission('wallet_walletRuleJoin_del')") public R removeById(@RequestBody Long[] ids) { - return R.ok(walletRuleJoinService.removeBatchByIds(CollUtil.toList(ids))); + walletRuleJoinService.delByIds(CollUtil.toList(ids)); + return R.ok(); } @ResponseExcel @GetMapping("/export") - @PreAuthorize("@pms.hasPermission('wallet_walletRuleJoin_export')") + // @PreAuthorize("@pms.hasPermission('wallet_walletRuleJoin_export')") public List export(WalletRuleJoinEntity walletRuleJoin, Long[] ids) { return walletRuleJoinService.list(Wrappers.lambdaQuery(walletRuleJoin).in(ArrayUtil.isNotEmpty(ids), WalletRuleJoinEntity::getId, ids)); } diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/rule/WalletRuleTransactionController.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/rule/WalletRuleTransactionController.java new file mode 100644 index 000000000..a65653f4a --- /dev/null +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/rule/WalletRuleTransactionController.java @@ -0,0 +1,82 @@ +package com.bsd.pjcloud.wallet.controller.rule; + +import cn.hutool.core.util.ArrayUtil; +import cn.hutool.core.collection.CollUtil; +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.entity.rule.WalletRuleTransactionEntity; +import com.bsd.pjcloud.wallet.service.WalletRuleTransactionService; +import org.springframework.security.access.prepost.PreAuthorize; +import com.bsd.pjcloud.common.excel.annotation.ResponseExcel; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import org.springdoc.core.annotations.ParameterObject; +import org.springframework.http.HttpHeaders; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Operation; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Objects; + +/** + * 钱包转账记录 + */ +@RestController +@RequiredArgsConstructor +@RequestMapping("/wallet-rule-transaction") +@Tag(description = "wallet-rule-transaction", name = "钱包转账记录管理") +@SecurityRequirement(name = HttpHeaders.AUTHORIZATION) +public class WalletRuleTransactionController { + + private final WalletRuleTransactionService walletRuleTransactionService; + + @Operation(summary = "分页查询", description = "分页查询") + @GetMapping("/page") + @PreAuthorize("@pms.hasPermission('wallet_walletRuleTransaction_view')") + public R getWalletRuleTransactionPage(@ParameterObject Page page, @ParameterObject WalletRuleTransactionEntity walletRuleTransaction) { + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + return R.ok(walletRuleTransactionService.page(page, wrapper)); + } + + @Operation(summary = "通过id查询", description = "通过id查询") + @GetMapping("/{id}") + @PreAuthorize("@pms.hasPermission('wallet_walletRuleTransaction_view')") + public R getById(@PathVariable("id") Long id) { + return R.ok(walletRuleTransactionService.getById(id)); + } + + @Operation(summary = "新增钱包转账记录", description = "新增钱包转账记录") + @SysLog("新增钱包转账记录") + @PostMapping + @PreAuthorize("@pms.hasPermission('wallet_walletRuleTransaction_add')") + public R save(@RequestBody WalletRuleTransactionEntity walletRuleTransaction) { + return R.ok(walletRuleTransactionService.save(walletRuleTransaction)); + } + + @Operation(summary = "修改钱包转账记录", description = "修改钱包转账记录") + @SysLog("修改钱包转账记录") + @PutMapping + @PreAuthorize("@pms.hasPermission('wallet_walletRuleTransaction_edit')") + public R updateById(@RequestBody WalletRuleTransactionEntity walletRuleTransaction) { + return R.ok(walletRuleTransactionService.updateById(walletRuleTransaction)); + } + + @Operation(summary = "通过id删除钱包转账记录", description = "通过id删除钱包转账记录") + @SysLog("通过id删除钱包转账记录") + @DeleteMapping + @PreAuthorize("@pms.hasPermission('wallet_walletRuleTransaction_del')") + public R removeById(@RequestBody Long[] ids) { + return R.ok(walletRuleTransactionService.removeBatchByIds(CollUtil.toList(ids))); + } + + @ResponseExcel + @GetMapping("/export") + @PreAuthorize("@pms.hasPermission('wallet_walletRuleTransaction_export')") + public List export(WalletRuleTransactionEntity walletRuleTransaction, Long[] ids) { + return walletRuleTransactionService.list(Wrappers.lambdaQuery(walletRuleTransaction).in(ArrayUtil.isNotEmpty(ids), WalletRuleTransactionEntity::getId, ids)); + } +} \ No newline at end of file diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/rule/WalletRuleJoinMapper.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/rule/WalletRuleJoinMapper.java index acbfbd060..e60cdba0b 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/rule/WalletRuleJoinMapper.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/rule/WalletRuleJoinMapper.java @@ -1,11 +1,18 @@ 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.WalletRuleJoinDto; import com.bsd.pjcloud.wallet.api.entity.rule.WalletRuleJoinEntity; +import com.bsd.pjcloud.wallet.api.vo.rule.WalletRuleJoinVo; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; @Mapper public interface WalletRuleJoinMapper extends PjcloudBaseMapper { + Page scopeJoinPage(Page page, @Param("dto") WalletRuleJoinDto dto, DataScope dataScope); + WalletRuleJoinVo joinDetail(@Param("id") Long id); } \ No newline at end of file diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/rule/WalletRuleTransactionMapper.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/rule/WalletRuleTransactionMapper.java new file mode 100644 index 000000000..fb1496256 --- /dev/null +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/rule/WalletRuleTransactionMapper.java @@ -0,0 +1,11 @@ +package com.bsd.pjcloud.wallet.mapper.rule; + +import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper; +import com.bsd.pjcloud.wallet.api.entity.rule.WalletRuleTransactionEntity; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface WalletRuleTransactionMapper extends PjcloudBaseMapper { + + +} \ No newline at end of file diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/WalletRuleJoinService.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/WalletRuleJoinService.java index 4f9673f55..0a4660b7e 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/WalletRuleJoinService.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/WalletRuleJoinService.java @@ -1,8 +1,40 @@ 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.WalletRuleJoinDto; +import com.bsd.pjcloud.wallet.api.entity.mch.MchRuleJoinDtoEntity; import com.bsd.pjcloud.wallet.api.entity.rule.WalletRuleJoinEntity; +import com.bsd.pjcloud.wallet.api.vo.mch.MchRuleJoinDtoVo; +import com.bsd.pjcloud.wallet.api.vo.rule.WalletRuleJoinVo; + +import java.util.ArrayList; public interface WalletRuleJoinService extends IService { + /** + * 权限分页查询 + */ + Page scopeJoinPage(Page page, WalletRuleJoinDto dto, DataScope dataScope); + + /** + * 新增 + */ + Long create(WalletRuleJoinEntity dto); + + /** + * 修改 + */ + Long edit(WalletRuleJoinEntity dto); + + /** + * 删除 + */ + void delByIds(ArrayList list); + + /** + * 复杂详情 + */ + WalletRuleJoinVo joinDetail(Long id); } \ No newline at end of file diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/WalletRuleTransactionService.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/WalletRuleTransactionService.java new file mode 100644 index 000000000..44fbb582c --- /dev/null +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/WalletRuleTransactionService.java @@ -0,0 +1,8 @@ +package com.bsd.pjcloud.wallet.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.bsd.pjcloud.wallet.api.entity.rule.WalletRuleTransactionEntity; + +public interface WalletRuleTransactionService extends IService { + +} \ No newline at end of file diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/rule/WalletRuleJoinServiceImpl.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/rule/WalletRuleJoinServiceImpl.java index 82a77bac0..c45fa1a4e 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/rule/WalletRuleJoinServiceImpl.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/rule/WalletRuleJoinServiceImpl.java @@ -1,13 +1,120 @@ package com.bsd.pjcloud.wallet.service.impl.rule; +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.common.data.datascope.DataScope; +import com.bsd.pjcloud.wallet.api.dto.rule.WalletRuleJoinDto; +import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity; import com.bsd.pjcloud.wallet.api.entity.rule.WalletRuleJoinEntity; +import com.bsd.pjcloud.wallet.api.vo.rule.WalletRuleJoinVo; import com.bsd.pjcloud.wallet.mapper.rule.WalletRuleJoinMapper; import com.bsd.pjcloud.wallet.service.WalletRuleJoinService; +import com.bsd.pjcloud.wallet.service.WalletTypeService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import java.util.ArrayList; + /** * 钱包规则配置 */ +@Validated +@Slf4j +@RequiredArgsConstructor @Service public class WalletRuleJoinServiceImpl extends ServiceImpl implements WalletRuleJoinService { + + private final WalletTypeService walletTypeService; + + /** + * 权限分页查询 + */ + @Override + public Page scopeJoinPage(Page page, WalletRuleJoinDto dto, DataScope dataScope) { + return baseMapper.scopeJoinPage(page, dto, dataScope); + } + + /** + * 新增 + */ + @Override + public Long create(WalletRuleJoinEntity dto) { + if (existWalletRuleJoin(dto)) { + throw new RuntimeException("绑定类型不能重复"); + } + if (areWalletIdsDistinct(dto)) { + throw new RuntimeException("源钱包类型与目标钱包类型不能重复"); + } + WalletTypeEntity targetMch = walletTypeService.getById(dto.getTargetWalletTypeId()); + if (ObjectUtil.isEmpty(targetMch)) { + throw new RuntimeException("目标钱包类型不存在"); + } + baseMapper.insert(dto); + return dto.getId(); + } + + /** + * 修改 + */ + @Override + public Long edit(WalletRuleJoinEntity dto) { + if (existWalletRuleJoin(dto)) { + throw new RuntimeException("绑定类型不能重复"); + } + if (areWalletIdsDistinct(dto)) { + throw new RuntimeException("源钱包类型与目标钱包类型不能重复"); + } + WalletTypeEntity targetMch = walletTypeService.getById(dto.getTargetWalletTypeId()); + if (ObjectUtil.isEmpty(targetMch)) { + throw new RuntimeException("目标钱包类型不存在"); + } + baseMapper.updateById(dto); + return dto.getId(); + } + + /** + * 删除 + */ + @Override + public void delByIds(ArrayList list) { + if (ObjectUtil.isEmpty(list)) return; + baseMapper.deleteByIds(list); + } + + /** + * 复杂详情 + */ + @Override + public WalletRuleJoinVo joinDetail(Long id) { + return baseMapper.joinDetail(id); + } + + /** + * 是否重复 + */ + private boolean existWalletRuleJoin(WalletRuleJoinEntity dto) { + Long count = baseMapper.selectCount(new LambdaQueryWrapper() + .eq(ObjectUtil.isNotEmpty(dto.getSourceWalletTypeId()), WalletRuleJoinEntity::getSourceWalletTypeId, dto.getSourceWalletTypeId()) + .eq(ObjectUtil.isNotEmpty(dto.getTargetWalletTypeId()), WalletRuleJoinEntity::getTargetWalletTypeId, dto.getTargetWalletTypeId()) + .ne(ObjectUtil.isNotEmpty(dto.getId()), WalletRuleJoinEntity::getId, dto.getId()) + ); + if (ObjectUtil.isNotEmpty(dto.getId())) { + return count >= 1; + } + return count > 0; + } + + /** + * sourceWalletTypeId和targetWalletTypeId是否重复 + */ + private boolean areWalletIdsDistinct(WalletRuleJoinEntity dto) { + if (!ObjectUtil.isAllNotEmpty(dto.getSourceWalletTypeId(), dto.getTargetWalletTypeId())) { + return false; + } + return ObjectUtil.equals(dto.getSourceWalletTypeId(), dto.getTargetWalletTypeId()); + } } \ No newline at end of file diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/rule/WalletRuleTransactionServiceImpl.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/rule/WalletRuleTransactionServiceImpl.java new file mode 100644 index 000000000..d12b54765 --- /dev/null +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/rule/WalletRuleTransactionServiceImpl.java @@ -0,0 +1,20 @@ +package com.bsd.pjcloud.wallet.service.impl.rule; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.bsd.pjcloud.wallet.api.entity.rule.WalletRuleTransactionEntity; +import com.bsd.pjcloud.wallet.mapper.rule.WalletRuleTransactionMapper; +import com.bsd.pjcloud.wallet.service.WalletRuleTransactionService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +/** + * 钱包转账记录 + */ +@Validated +@Slf4j +@RequiredArgsConstructor +@Service +public class WalletRuleTransactionServiceImpl extends ServiceImpl implements WalletRuleTransactionService { +} \ No newline at end of file diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/resources/mapper/rule/WalletRuleJoinMapper.xml b/pjcloud-wallet/pjcloud-wallet-biz/src/main/resources/mapper/rule/WalletRuleJoinMapper.xml index 43eb3f1ca..0fe82158c 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/resources/mapper/rule/WalletRuleJoinMapper.xml +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/resources/mapper/rule/WalletRuleJoinMapper.xml @@ -2,8 +2,7 @@ - - + @@ -15,5 +14,61 @@ - + + + + select a.id, + a.source_wallet_type_id, + a.target_wallet_type_id, + a.balance_multiple, + a.status, + a.create_by, + a.create_time, + a.update_by, + a.update_time, + a.del_flag, + a.tenant_id, + + + + a.del_flag = 0 + + and a.source_wallet_type_id = #{dto.sourceWalletTypeId} + + + and a.target_wallet_type_id = #{dto.targetWalletTypeId} + + + + + + \ No newline at end of file diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/resources/mapper/rule/WalletRuleTransactionMapper.xml b/pjcloud-wallet/pjcloud-wallet-biz/src/main/resources/mapper/rule/WalletRuleTransactionMapper.xml new file mode 100644 index 000000000..54da92661 --- /dev/null +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/resources/mapper/rule/WalletRuleTransactionMapper.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file