From 6ac12d8d4477869d11be35222159345fb4309371 Mon Sep 17 00:00:00 2001 From: dzc <2388224167@qq.com> Date: Wed, 25 Jun 2025 16:43:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=8F=91=E7=A5=A8=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/800pjcloudx_wallet.sql | 38 ++++--- .../WalletRechargeInvoiceStatusEnum.java | 9 +- .../WalletRechargeBindInvoiceDto.java | 18 ++- .../recharge/WalletRechargeImportEntity.java | 6 + .../recharge/WalletRechargeInvoiceEntity.java | 16 ++- ....java => WalletRechargeInvoiceItemVo.java} | 2 +- ...tyVo.java => WalletRechargeInvoiceVo.java} | 2 +- .../WalletRechargeApplyController.java | 5 + .../WalletRechargeInvoiceController.java | 21 ++-- .../recharge/WalletRechargeInvoiceMapper.java | 14 +++ .../service/WalletRechargeApplyService.java | 7 +- .../service/WalletRechargeInvoiceService.java | 28 ++++- .../WalletRechargeApplyServiceImpl.java | 68 +++++++++--- .../WalletRechargeInvoiceServiceImpl.java | 104 +++++++++++++++--- .../recharge/WalletRechargeInvoiceMapper.xml | 72 ++++++++---- 15 files changed, 320 insertions(+), 90 deletions(-) rename pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/vo/recharge/{WalletRechargeInvoiceEntityItemVo.java => WalletRechargeInvoiceItemVo.java} (83%) rename pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/vo/recharge/{WalletRechargeInvoiceEntityVo.java => WalletRechargeInvoiceVo.java} (70%) diff --git a/db/800pjcloudx_wallet.sql b/db/800pjcloudx_wallet.sql index 82cb4e569..8322e62a9 100644 --- a/db/800pjcloudx_wallet.sql +++ b/db/800pjcloudx_wallet.sql @@ -391,24 +391,26 @@ CREATE INDEX idx_dept_id ON wallet_recharge_apply (user_id); DROP TABLE IF EXISTS wallet_recharge_invoice; CREATE TABLE wallet_recharge_invoice ( - id bigint NOT NULL COMMENT '主键ID', - apply_id bigint NOT NULL COMMENT '申请id', - code varchar(32) NOT NULL COMMENT '发票代码(七位数)', - time datetime DEFAULT NULL COMMENT '发票日期', - dept_or_user varchar(64) DEFAULT NULL COMMENT '交款单位或个人', - total_price int DEFAULT NULL COMMENT '合计人民币', - payee_dept varchar(64) DEFAULT NULL COMMENT '收款单位', - payee_user varchar(64) DEFAULT NULL COMMENT '收款人', - item_json varchar(2048) DEFAULT NULL COMMENT '备注', - remark varchar(1024) DEFAULT NULL COMMENT '备注', - status varchar(32) DEFAULT NULL COMMENT '状态', - pic_url varchar(1024) DEFAULT 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 '修改人', - 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 '主键ID', + apply_user_id bigint DEFAULT NULL COMMENT '申请用户id', + apply_dept_id bigint DEFAULT NULL COMMENT '申请用户部门id', + apply_id bigint DEFAULT NULL COMMENT '申请id', + code varchar(32) NOT NULL COMMENT '发票代码(七位数)', + time datetime DEFAULT NULL COMMENT '发票日期', + dept_or_user varchar(64) DEFAULT NULL COMMENT '交款单位或个人', + total_price int DEFAULT NULL COMMENT '合计人民币', + payee_dept varchar(64) DEFAULT NULL COMMENT '收款单位', + payee_user varchar(64) DEFAULT NULL COMMENT '收款人', + item_json varchar(2048) DEFAULT NULL COMMENT '备注', + remark varchar(1024) DEFAULT NULL COMMENT '备注', + status varchar(32) DEFAULT NULL COMMENT '状态', + pic_url varchar(1024) DEFAULT 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 '修改人', + 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 diff --git a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/constant/WalletRechargeInvoiceStatusEnum.java b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/constant/WalletRechargeInvoiceStatusEnum.java index 9f8322276..a16dc6739 100644 --- a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/constant/WalletRechargeInvoiceStatusEnum.java +++ b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/constant/WalletRechargeInvoiceStatusEnum.java @@ -6,13 +6,16 @@ import lombok.Getter; import java.util.Arrays; -// cancellation +/** + * 充值/申请发票状态 + */ @Getter @AllArgsConstructor public enum WalletRechargeInvoiceStatusEnum { - DEFAULT("1", "默认"), - CANCELLATION("2", "作废"), + UNCHECKED("1", "未审核"), + CHECKED("2", "审核通过"), + CANCELLATION("3", "作废"), ; private final String code; diff --git a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/dto/recharge/WalletRechargeBindInvoiceDto.java b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/dto/recharge/WalletRechargeBindInvoiceDto.java index e7903a352..f2b35c5b9 100644 --- a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/dto/recharge/WalletRechargeBindInvoiceDto.java +++ b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/dto/recharge/WalletRechargeBindInvoiceDto.java @@ -1,17 +1,31 @@ package com.bsd.pjcloud.wallet.api.dto.recharge; -import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeInvoiceEntityVo; +import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeInvoiceVo; import lombok.Data; +import org.apache.commons.math3.optim.nonlinear.scalar.LineSearch; + +import java.time.LocalDateTime; +import java.util.List; /** * 充值记录绑定发票 */ @Data -public class WalletRechargeBindInvoiceDto extends WalletRechargeInvoiceEntityVo { +public class WalletRechargeBindInvoiceDto extends WalletRechargeInvoiceVo { /** * 充值/扣款申请id */ private Long applyId; + /** + * 申请人 + */ + private List userIds; + + /** + * 创建时间 + */ + private LocalDateTime[] createTimeList; + } diff --git a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/entity/recharge/WalletRechargeImportEntity.java b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/entity/recharge/WalletRechargeImportEntity.java index 74c8715a5..fc35e52fc 100644 --- a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/entity/recharge/WalletRechargeImportEntity.java +++ b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/entity/recharge/WalletRechargeImportEntity.java @@ -49,6 +49,12 @@ public class WalletRechargeImportEntity extends Model excelVOList, BindingResult bindingResult) { + return walletRechargeApplyService.readTopupExcel(excelVOList, bindingResult); + } + /* ************************************* start excel start ************************************* */ } \ No newline at end of file diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/recharge/WalletRechargeInvoiceController.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/recharge/WalletRechargeInvoiceController.java index e3324d934..444d45f9c 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/recharge/WalletRechargeInvoiceController.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/controller/recharge/WalletRechargeInvoiceController.java @@ -2,14 +2,13 @@ package com.bsd.pjcloud.wallet.controller.recharge; 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.dto.recharge.WalletRechargeBindInvoiceDto; import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeInvoiceEntity; -import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeInvoiceEntityVo; +import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeInvoiceVo; import com.bsd.pjcloud.wallet.service.WalletRechargeInvoiceService; import jakarta.validation.Valid; import org.springframework.security.access.prepost.PreAuthorize; @@ -38,7 +37,7 @@ public class WalletRechargeInvoiceController { @GetMapping("/get-invoice") @Operation(summary = "批量充值/扣款发票信息") - public R getInvoice(@RequestParam Long id) { + public R getInvoice(@RequestParam Long id) { return R.ok(walletRechargeInvoiceService.getInvoice(id)); } @@ -49,19 +48,24 @@ public class WalletRechargeInvoiceController { return R.ok(); } + @Operation(summary = "下拉", description = "下拉") + @GetMapping("/select") + public R select(@ParameterObject Page page, @ParameterObject WalletRechargeBindInvoiceDto dto) { + return R.ok(walletRechargeInvoiceService.scopePageList(page, dto)); + } + @Operation(summary = "分页查询", description = "分页查询") @GetMapping("/page") @PreAuthorize("@pms.hasPermission('wallet_walletRechargeInvoice_view')") - public R getWalletRechargeInvoicePage(@ParameterObject Page page, @ParameterObject WalletRechargeInvoiceEntity walletRechargeInvoice) { - LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); - return R.ok(walletRechargeInvoiceService.page(page, wrapper)); + public R getWalletRechargeInvoicePage(@ParameterObject Page page, @ParameterObject WalletRechargeBindInvoiceDto dto) { + return R.ok(walletRechargeInvoiceService.scopePageList(page, dto)); } @Operation(summary = "通过id查询", description = "通过id查询") @GetMapping("/{id}") @PreAuthorize("@pms.hasPermission('wallet_walletRechargeInvoice_view')") public R getById(@PathVariable("id") Long id) { - return R.ok(walletRechargeInvoiceService.getById(id)); + return R.ok(walletRechargeInvoiceService.joinById(id)); } @Operation(summary = "新增充值/扣款申请发票记录", description = "新增充值/扣款申请发票记录") @@ -85,7 +89,8 @@ public class WalletRechargeInvoiceController { @DeleteMapping @PreAuthorize("@pms.hasPermission('wallet_walletRechargeInvoice_del')") public R removeById(@RequestBody Long[] ids) { - return R.ok(walletRechargeInvoiceService.removeBatchByIds(CollUtil.toList(ids))); + walletRechargeInvoiceService.delByIds(CollUtil.toList(ids)); + return R.ok(); } @ResponseExcel diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/recharge/WalletRechargeInvoiceMapper.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/recharge/WalletRechargeInvoiceMapper.java index 2f7b3440d..dc1fe3f60 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/recharge/WalletRechargeInvoiceMapper.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/recharge/WalletRechargeInvoiceMapper.java @@ -1,8 +1,12 @@ package com.bsd.pjcloud.wallet.mapper.recharge; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper; +import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeBindInvoiceDto; import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeInvoiceEntity; +import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeInvoiceVo; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; @Mapper public interface WalletRechargeInvoiceMapper extends PjcloudBaseMapper { @@ -11,4 +15,14 @@ public interface WalletRechargeInvoiceMapper extends PjcloudBaseMapper scopePageList(Page page, @Param("dto") WalletRechargeBindInvoiceDto dto); + + /** + * 查询详情 + */ + WalletRechargeInvoiceVo joinById(@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/service/WalletRechargeApplyService.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/WalletRechargeApplyService.java index b4628cfb2..6e806a8cf 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/WalletRechargeApplyService.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/WalletRechargeApplyService.java @@ -41,10 +41,15 @@ public interface WalletRechargeApplyService extends IService excelVOList, BindingResult bindingResult); + /** + * 读取充值excel内容 + */ + R readTopupExcel(List excelVOList, BindingResult bindingResult); + /** * 审批回调 */ diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/WalletRechargeInvoiceService.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/WalletRechargeInvoiceService.java index 0ec849280..5f694272a 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/WalletRechargeInvoiceService.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/WalletRechargeInvoiceService.java @@ -1,17 +1,31 @@ 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.security.service.PjcloudUser; import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeBindInvoiceDto; import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeInvoiceEntity; -import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeInvoiceEntityVo; +import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeInvoiceVo; import jakarta.validation.Valid; +import java.util.ArrayList; + public interface WalletRechargeInvoiceService extends IService { + /** + * 分页查询 + */ + Page scopePageList(Page page, WalletRechargeBindInvoiceDto dto); + + /** + * 查询详情 + */ + WalletRechargeInvoiceVo joinById(Long id); + /** * 批量充值/扣款发票信息 */ - WalletRechargeInvoiceEntityVo getInvoice(Long id); + WalletRechargeInvoiceVo getInvoice(Long id); /** * 获取发票代码 @@ -22,4 +36,14 @@ public interface WalletRechargeInvoiceService extends IService list); } \ No newline at end of file diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/recharge/WalletRechargeApplyServiceImpl.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/recharge/WalletRechargeApplyServiceImpl.java index 71c3d72f3..b8ffffa64 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/recharge/WalletRechargeApplyServiceImpl.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/recharge/WalletRechargeApplyServiceImpl.java @@ -43,6 +43,7 @@ import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity; import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity; import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeApplyEntity; import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeImportEntity; +import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeInvoiceEntity; import com.bsd.pjcloud.wallet.api.utils.WalletDataUtil; import com.bsd.pjcloud.wallet.api.vo.WalletManageVo; import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeApplyVo; @@ -52,6 +53,7 @@ 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.mapper.recharge.WalletRechargeApplyMapper; +import com.bsd.pjcloud.wallet.mapper.recharge.WalletRechargeInvoiceMapper; import com.bsd.pjcloud.wallet.service.*; import com.bsd.pjcloud.wallet.utils.flow.FlowUtil; import com.bsd.pjcloud.wallet.utils.flow.dto.WalletRechargeApplyFlowDto; @@ -59,6 +61,7 @@ import com.bsd.pjcloud.wallet.utils.flow.dto.WalletRechargeApplyFlowDto; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.tuple.ImmutablePair; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.BindingResult; @@ -92,6 +95,7 @@ public class WalletRechargeApplyServiceImpl extends ServiceImpl list, BindingResult bindingResult) { + public R readExcel(List excelVOList, BindingResult bindingResult) { + ImmutablePair, List> pair = validateExcelData(excelVOList, bindingResult); + List errorMessages = pair.getLeft(); + List list = pair.getRight(); + if (ObjectUtil.isNotEmpty(errorMessages)) return R.failed(errorMessages); + PjcloudUser loginUser = SecurityUtils.getUser(); + WalletRechargeApplyEntity insertObj = new WalletRechargeApplyEntity(); + insertObj.setDeptId(loginUser.getDeptId()); + insertObj.setUserId(loginUser.getId()); + int i = baseMapper.insert(insertObj); + if (i <= 0) { + throw new RuntimeException("导入失败"); + } + List batchSaveList = list.stream().map(v -> WalletRechargeImportEntity.builder().price(v.getPriceNumber()).userId(v.getUserId()).userDeptId(v.getUserDeptId()).build()).toList(); + batchSaveList.forEach(v -> v.setApplyId(insertObj.getId())); + rechargeImportService.saveBatch(batchSaveList); + return R.ok(null, "导入成功"); + } + + /** + * 读取充值excel内容 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public R readTopupExcel(List excelVOList, BindingResult bindingResult) { + ImmutablePair, List> pair = validateExcelData(excelVOList, bindingResult); + List errorMessages = pair.getLeft(); + List list = pair.getRight(); + if (ObjectUtil.isNotEmpty(errorMessages)) return R.failed(errorMessages); + PjcloudUser loginUser = SecurityUtils.getUser(); + // 先创建发票 + Integer totalPrice = list.stream().map(WalletRechargeExcelDto::getPriceNumber).reduce(Integer::sum).orElse(0); + WalletRechargeInvoiceEntity invoice = walletRechargeInvoiceService.createBaseInvoice(loginUser, totalPrice); + if (ObjectUtil.isEmpty(invoice)) throw new RuntimeException("导入失败"); + // 导入数据 + List batchSaveList = list.stream().map(v -> WalletRechargeImportEntity.builder().price(v.getPriceNumber()).userId(v.getUserId()).userDeptId(v.getUserDeptId()).invoiceId(invoice.getId()).build()).toList(); + rechargeImportService.saveBatch(batchSaveList); + return R.ok(null, "导入成功"); + } + + /** + * 校验充值/扣款excel的数据 + */ + public ImmutablePair, List> validateExcelData(List list, BindingResult bindingResult) { if (ObjectUtil.isEmpty(list)) { - return R.failed(); + throw new RuntimeException("读取excel数据错误"); } list = list.stream().filter(v -> !ObjectUtil.isAllEmpty(v.getUsername(), v.getUserMobile(), v.getPrice())).toList(); if (ObjectUtil.isEmpty(list)) { - return R.failed(); + throw new RuntimeException("读取excel数据错误"); } List errorMessageList = (List) bindingResult.getTarget(); List usernameList = list.stream().map(WalletRechargeExcelDto::getUsername).toList(); @@ -306,20 +353,9 @@ public class WalletRechargeApplyServiceImpl extends ServiceImpl batchSaveList = list.stream().map(v -> WalletRechargeImportEntity.builder().price(v.getPriceNumber()).userId(v.getUserId()).userDeptId(v.getUserDeptId()).build()).toList(); - batchSaveList.forEach(v -> v.setApplyId(insertObj.getId())); - rechargeImportService.saveBatch(batchSaveList); - return R.ok(null, "导入成功"); + return ImmutablePair.of(null, list); } /* ************************************* end excel end ************************************* */ diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/recharge/WalletRechargeInvoiceServiceImpl.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/recharge/WalletRechargeInvoiceServiceImpl.java index 2a374da7d..7d61ad10e 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/recharge/WalletRechargeInvoiceServiceImpl.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/impl/recharge/WalletRechargeInvoiceServiceImpl.java @@ -1,15 +1,15 @@ package com.bsd.pjcloud.wallet.service.impl.recharge; import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.date.DatePattern; -import cn.hutool.core.date.LocalDateTimeUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +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.feign.RemoteUserService; +import com.bsd.pjcloud.common.security.service.PjcloudUser; import com.bsd.pjcloud.flow.task.constant.TaskCheckStatusEnum; import com.bsd.pjcloud.wallet.api.constant.WalletBizRechargeEnum; import com.bsd.pjcloud.wallet.api.constant.WalletRechargeInvoiceStatusEnum; @@ -19,12 +19,11 @@ import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeImportEntity; import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeInvoiceEntity; import com.bsd.pjcloud.wallet.api.feign.RemoteWalletSettingService; import com.bsd.pjcloud.wallet.api.vo.WalletSettingVo; -import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeInvoiceEntityItemVo; -import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeInvoiceEntityVo; +import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeInvoiceItemVo; +import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeInvoiceVo; import com.bsd.pjcloud.wallet.mapper.recharge.WalletRechargeApplyMapper; import com.bsd.pjcloud.wallet.mapper.recharge.WalletRechargeImportMapper; import com.bsd.pjcloud.wallet.mapper.recharge.WalletRechargeInvoiceMapper; -import com.bsd.pjcloud.wallet.service.WalletRechargeApplyService; import com.bsd.pjcloud.wallet.service.WalletRechargeInvoiceService; import com.bsd.pjcloud.wallet.utils.ConvertCnPriceUtil; import lombok.AllArgsConstructor; @@ -33,6 +32,8 @@ import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; import java.math.RoundingMode; +import java.time.LocalDateTime; +import java.util.ArrayList; import java.util.List; /** @@ -45,18 +46,37 @@ public class WalletRechargeInvoiceServiceImpl extends ServiceImpl scopePageList(Page page, WalletRechargeBindInvoiceDto dto) { + return baseMapper.scopePageList(page, dto); + } + + /** + * 查询详情 + */ + @Override + public WalletRechargeInvoiceVo joinById(Long id) { + WalletRechargeInvoiceVo detail = baseMapper.joinById(id); + if (ObjectUtil.isEmpty(detail)) return detail; + // 转换为元 + Double price = BigDecimal.valueOf(detail.getTotalPrice()).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP).doubleValue(); + detail.setTotalPriceCnStr(ConvertCnPriceUtil.convert(String.valueOf(price))); + return detail; + } + /** * 批量充值/扣款发票信息 */ @Override - public WalletRechargeInvoiceEntityVo getInvoice(Long id) { + public WalletRechargeInvoiceVo getInvoice(Long id) { // 查询申请记录 - WalletRechargeApplyEntity applyDetail = applyService.getById(id); + WalletRechargeApplyEntity applyDetail = applyMapper.selectById(id); WalletBizRechargeEnum bizEnum = WalletBizRechargeEnum.valueOfByType(applyDetail.getBizType()); if (ObjectUtil.isEmpty(applyDetail)) { throw new RuntimeException("批量充值/扣款申请不存在"); @@ -71,13 +91,13 @@ public class WalletRechargeInvoiceServiceImpl extends ServiceImpl() .eq(WalletRechargeInvoiceEntity::getApplyId, id) - .eq(WalletRechargeInvoiceEntity::getStatus, WalletRechargeInvoiceStatusEnum.DEFAULT.getCode()) + .eq(WalletRechargeInvoiceEntity::getStatus, WalletRechargeInvoiceStatusEnum.UNCHECKED.getCode()) ); if (ObjectUtil.isNotEmpty(InvoiceEntity)) { - result = BeanUtil.copyProperties(InvoiceEntity, WalletRechargeInvoiceEntityVo.class); + result = BeanUtil.copyProperties(InvoiceEntity, WalletRechargeInvoiceVo.class); Double price = BigDecimal.valueOf(result.getTotalPrice()).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP).doubleValue(); result.setTotalPriceCnStr(ConvertCnPriceUtil.convert(String.valueOf(price))); return result; @@ -104,9 +124,8 @@ public class WalletRechargeInvoiceServiceImpl extends ServiceImpl list) { + if (ObjectUtil.isEmpty(list)) return; + for (Long v : list) { + WalletRechargeInvoiceEntity detail = baseMapper.selectById(v); + if (ObjectUtil.isEmpty(detail)) continue; + if (ObjectUtil.isNotEmpty(detail.getStatus()) && ObjectUtil.notEqual(detail.getStatus(), WalletRechargeInvoiceStatusEnum.UNCHECKED.getCode())) { + UserInfo userInfo = remoteUserService.getByUserId(detail.getApplyId()).getData(); + throw new RuntimeException("用户<" + userInfo.getSysUser().getName() + ">发起的审批不能删除"); + } + } + } + /** * 获取发票代码 */ @@ -139,7 +209,7 @@ public class WalletRechargeInvoiceServiceImpl extends ServiceImpl updateWrapper = new LambdaUpdateWrapper() .set(WalletRechargeApplyEntity::getInvoiceId, entity.getId()) diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/resources/mapper/recharge/WalletRechargeInvoiceMapper.xml b/pjcloud-wallet/pjcloud-wallet-biz/src/main/resources/mapper/recharge/WalletRechargeInvoiceMapper.xml index 3efcf8530..de44b763f 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/resources/mapper/recharge/WalletRechargeInvoiceMapper.xml +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/resources/mapper/recharge/WalletRechargeInvoiceMapper.xml @@ -2,29 +2,63 @@ - - - - - - - - - - - - - - - - - - + + select a.id, + a.apply_user_id, + a.apply_dept_id, + a.apply_id, + a.code, + a.time, + a.dept_or_user, + a.total_price, + a.payee_dept, + a.payee_user, + a.item_json, + a.remark, + a.status, + a.pic_url, + a.create_by, + a.create_time, + a.update_by, + a.update_time, + a.del_flag, + a.tenant_id, + + + + + and a.status = #{dto.status} + + + and a.apply_user_id in + + #{v} + + + + and a.create_time between #{dto.createTimeList[0]} and #{dto.createTimeList[1]} + + + + + \ No newline at end of file