diff --git a/db/800pjcloudx_wallet.sql b/db/800pjcloudx_wallet.sql index 659672437..8322e62a9 100644 --- a/db/800pjcloudx_wallet.sql +++ b/db/800pjcloudx_wallet.sql @@ -391,23 +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 '状态', - 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-thirdparty/pjcloud-thirdparty-biz/src/main/resources/application.yml b/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/main/resources/application.yml index 33a15cab9..01e7c9341 100644 --- a/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/main/resources/application.yml +++ b/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/main/resources/application.yml @@ -89,12 +89,19 @@ zy: # callback-recognition-url: /third/third-ks/callback/recognition # callback-sku-url: /third/third-ks/callback/sku lb: - base-url: https://elss-sit.nbcb.com.cn - # base-url: https://elss-sit.nbcb.com.cn/h5/thirdApp - app-id: 7da62b1a9ade473c917f573c5748081e - app-secret: 8ffI6b+OKTmdVAt9Qo+2F/HQQMdt/d8GFia0zlJOt9I= + # 测试环境 + # base-url: https://elss-sit.nbcb.com.cn + # app-id: 7da62b1a9ade473c917f573c5748081e + # app-secret: 8ffI6b+OKTmdVAt9Qo+2F/HQQMdt/d8GFia0zlJOt9I= + # company-number: 202504673472 + # sm4-key: S67157e8aQs2tFSX + + # 正式环境 + base-url: https://elss.nbcb.com.cn + app-id: 528e3ca76ec34f5c9b3255ba18aee774 + app-secret: tIhDZDXWhtP6bvd0J9Q0zjIZxSkmyX+uUc87xnDTgfc= company-number: 202504673472 - sm4-key: S67157e8aQs2tFSX + sm4-key: 63P839eg0uxE5aoG sms: diff --git a/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/test/java/com/bsd/pjcloud/admin/PayTest.java b/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/test/java/com/bsd/pjcloud/admin/PayTest.java index 13a93d091..6a8fd2dd7 100644 --- a/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/test/java/com/bsd/pjcloud/admin/PayTest.java +++ b/pjcloud-thirdparty/pjcloud-thirdparty-biz/src/test/java/com/bsd/pjcloud/admin/PayTest.java @@ -29,7 +29,7 @@ import java.util.Map; @SpringBootTest(classes = ThirdPartyApp.class) public class PayTest { - // private final String baseUrl = "http://123.156.230.15:8089/api"; + // private final String baseUrl = "http://59.202.170.152:81/api"; // private final String baseUrl = "http://127.0.0.1:9999"; private final String baseUrl = "https://stgl.pj.gov.cn/api"; @@ -67,7 +67,7 @@ public class PayTest { Map paramsMap = new HashMap<>(); paramsMap.put("signPhone", LbRetailSignUtils.sm4Encrypt("17683843144", appM4KeyProd)); // paramsMap.put("signPhone", "8KKubCKESDN5TlUl3i0HaQ=="); - paramsMap.put("userId", 1875049673022279681L); + // paramsMap.put("userId", 1875049673022279681L); String body = JSONUtil.toJsonStr(paramsMap); // 发送请求 String res = HttpRequest.post(baseUrl + walletInfoUrl).contentType("application/json").header(apiCountersignProd(body)).body(body).execute().body(); diff --git a/pjcloud-upms/pjcloud-upms-biz/src/main/resources/mapper/SysUserMapper.xml b/pjcloud-upms/pjcloud-upms-biz/src/main/resources/mapper/SysUserMapper.xml index 49847405f..889ba6d9b 100644 --- a/pjcloud-upms/pjcloud-upms-biz/src/main/resources/mapper/SysUserMapper.xml +++ b/pjcloud-upms/pjcloud-upms-biz/src/main/resources/mapper/SysUserMapper.xml @@ -306,7 +306,7 @@ - + group by u.user_id ORDER BY u.create_time DESC diff --git a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/constant/WalletBizRechargeEnum.java b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/constant/WalletBizRechargeEnum.java index 6fdfe731b..907ac832d 100644 --- a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/constant/WalletBizRechargeEnum.java +++ b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/constant/WalletBizRechargeEnum.java @@ -10,7 +10,7 @@ import java.util.List; @Getter @AllArgsConstructor public enum WalletBizRechargeEnum { - ADD("1", "添加"), + ADD("1", "充值"), REDUCTION("2", "记账扣款"), RETURN_CANTEEN("3", "退还各自食堂"), ; diff --git a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/constant/WalletInvoiceStatusCheckEnum.java b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/constant/WalletInvoiceStatusCheckEnum.java new file mode 100644 index 000000000..d2db17c81 --- /dev/null +++ b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/constant/WalletInvoiceStatusCheckEnum.java @@ -0,0 +1,35 @@ +package com.bsd.pjcloud.wallet.api.constant; + +import cn.hutool.core.util.ObjectUtil; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Arrays; + +/** + * 发票审核状态 + */ +@Getter +@AllArgsConstructor +public enum WalletInvoiceStatusCheckEnum { + UNCHECK("1", "未审核"), + FOREIGN("2", "审核成功"), + REFUND("3", "撤回"), + ; + private final String code; + + private final String desc; + + + public static WalletInvoiceStatusCheckEnum descOf(String description) { + return Arrays.stream(WalletInvoiceStatusCheckEnum.values()) + .filter(v -> ObjectUtil.equal(v.getDesc(), description)) + .findFirst().get(); + } + + public static WalletInvoiceStatusCheckEnum codeOf(String code) { + return Arrays.stream(WalletInvoiceStatusCheckEnum.values()) + .filter(v -> ObjectUtil.equal(v.getCode(), code)) + .findFirst().get(); + } +} 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..943e10f07 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,18 @@ import lombok.Getter; import java.util.Arrays; -// cancellation +/** + * 充值/申请发票状态 + */ @Getter @AllArgsConstructor public enum WalletRechargeInvoiceStatusEnum { - DEFAULT("1", "默认"), - CANCELLATION("2", "作废"), + UNBIND("1", "未绑定充值"), + BINDED("2", "已绑定充值"), + UNCHECKED("3", "未审核"), + CHECKED("4", "审核成功"), + CANCELLATION("5", "作废"), ; private final String code; @@ -24,4 +29,10 @@ public enum WalletRechargeInvoiceStatusEnum { .findFirst().get(); } + public static WalletRechargeInvoiceStatusEnum codeOf(String code) { + return Arrays.stream(WalletRechargeInvoiceStatusEnum.values()) + .filter(v -> ObjectUtil.equal(v.getCode(), code)) + .findFirst().get(); + } + } 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 new file mode 100644 index 000000000..f2b35c5b9 --- /dev/null +++ b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/dto/recharge/WalletRechargeBindInvoiceDto.java @@ -0,0 +1,31 @@ +package com.bsd.pjcloud.wallet.api.dto.recharge; + +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 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/dto/recharge/WalletRechargeSaveTopupDto.java b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/dto/recharge/WalletRechargeSaveTopupDto.java new file mode 100644 index 000000000..30e26fe50 --- /dev/null +++ b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/dto/recharge/WalletRechargeSaveTopupDto.java @@ -0,0 +1,18 @@ +package com.bsd.pjcloud.wallet.api.dto.recharge; + +import lombok.Data; + +@Data +public class WalletRechargeSaveTopupDto { + + /** + * 充值类型 + */ + private String bizType; + + /** + * 发票id + */ + private Long invoiceId; + +} diff --git a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/entity/recharge/WalletRechargeApplyEntity.java b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/entity/recharge/WalletRechargeApplyEntity.java index 74718a078..b42e97e22 100644 --- a/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/entity/recharge/WalletRechargeApplyEntity.java +++ b/pjcloud-wallet/pjcloud-wallet-api/src/main/java/com/bsd/pjcloud/wallet/api/entity/recharge/WalletRechargeApplyEntity.java @@ -40,6 +40,12 @@ public class WalletRechargeApplyEntity extends Model @Schema(description = "流程id") private String processId; + /** + * 绑定发票id + */ + @Schema(description = "绑定发票id") + private Long invoiceId; + /** * 流程状态 */ 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.readExcel(excelVOList, bindingResult); + public R readExcel(@RequestExcel List excelVOList, BindingResult bindingResult, @RequestParam(required = false) String bizType) { + return walletRechargeApplyService.readExcel(excelVOList, bindingResult, bizType); + } + + @PostMapping("/read-topup-excel") + public R readTopupExcel(@RequestExcel List excelVOList, BindingResult bindingResult) { + return walletRechargeApplyService.readTopupExcel(excelVOList, bindingResult); } /* ************************************* start excel start ************************************* */ 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 655f5120f..48b0582f6 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,16 @@ 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.data.datascope.DataScope; 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; import com.bsd.pjcloud.common.excel.annotation.ResponseExcel; import io.swagger.v3.oas.annotations.security.SecurityRequirement; @@ -21,7 +23,6 @@ import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; import java.util.List; -import java.util.Objects; /** * 充值/扣款申请发票记录 @@ -37,23 +38,38 @@ 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)); } + @PostMapping("/bind-invoice") + @Operation(summary = "绑定发票") + public R bindInvoice(@Valid @RequestBody WalletRechargeBindInvoiceDto dto) { + walletRechargeInvoiceService.bindInvoice(dto); + return R.ok(); + } + + @Operation(summary = "下拉", description = "下拉") + @GetMapping("/select") + public R select(@ParameterObject Page page, @ParameterObject WalletRechargeBindInvoiceDto dto) { + DataScope dataScope = null; + return R.ok(walletRechargeInvoiceService.scopePageList(page, dto, dataScope)); + } + @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) { + DataScope dataScope = DataScope.of(); + dataScope.setScopeDeptName("apply_dept_id"); + return R.ok(walletRechargeInvoiceService.scopePageList(page, dto, dataScope)); } @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 = "新增充值/扣款申请发票记录") @@ -68,8 +84,8 @@ public class WalletRechargeInvoiceController { @SysLog("修改充值/扣款申请发票记录") @PutMapping @PreAuthorize("@pms.hasPermission('wallet_walletRechargeInvoice_edit')") - public R updateById(@RequestBody WalletRechargeInvoiceEntity walletRechargeInvoice) { - return R.ok(walletRechargeInvoiceService.updateById(walletRechargeInvoice)); + public R updateById(@RequestBody WalletRechargeInvoiceEntity dto) { + return R.ok(walletRechargeInvoiceService.edit(dto)); } @Operation(summary = "通过id删除充值/扣款申请发票记录", description = "通过id删除充值/扣款申请发票记录") @@ -77,7 +93,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/WalletForeignMapper.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletForeignMapper.java index 63ee374a7..36b41c650 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletForeignMapper.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletForeignMapper.java @@ -21,6 +21,7 @@ public interface WalletForeignMapper extends PjcloudBaseMapper wrapper = new MPJLambdaWrapper() .selectAll(WalletForeignEntity.class) .eqIfExists(WalletForeignEntity::getProcessStatus, dto.getProcessStatus()) + .eqIfExists(WalletForeignEntity::getUserId, dto.getUserId()) .in(ObjectUtil.isNotEmpty(dto.getDeptIds()), WalletForeignEntity::getDeptId, dto.getDeptIds()) .in(ObjectUtil.isNotEmpty(dto.getUserIds()), WalletForeignEntity::getUserId, dto.getUserIds()) .ne(!dto.getIsFindUsed(), WalletForeignEntity::getCount, WalletForeignEntity::getUseCount) diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletStrideMapper.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletStrideMapper.java index 097909fac..5697fed3d 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletStrideMapper.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/WalletStrideMapper.java @@ -22,6 +22,7 @@ public interface WalletStrideMapper extends PjcloudBaseMapper wrapper = new MPJLambdaWrapper() .selectAll(WalletStrideEntity.class) .eqIfExists(WalletStrideEntity::getProcessStatus, dto.getProcessStatus()) + .eqIfExists(WalletStrideEntity::getUserId, dto.getUserId()) .in(ObjectUtil.isNotEmpty(dto.getDeptIds()), WalletStrideEntity::getDeptId, dto.getDeptIds()) .in(ObjectUtil.isNotEmpty(dto.getUserIds()), WalletStrideEntity::getUserId, dto.getUserIds()) .ne(!dto.getIsFindUsed(), WalletForeignEntity::getCount, WalletForeignEntity::getUseCount) diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/recharge/WalletRechargeApplyMapper.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/recharge/WalletRechargeApplyMapper.java index 667bf45bf..555fe42d0 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/recharge/WalletRechargeApplyMapper.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/mapper/recharge/WalletRechargeApplyMapper.java @@ -16,37 +16,17 @@ import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeApplyVo; import com.github.yulichang.wrapper.MPJLambdaWrapper; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import java.util.List; @Mapper public interface WalletRechargeApplyMapper extends PjcloudBaseMapper { - default Page pageJoin(Page page, WalletRechargeApplyDto dto) { - MPJLambdaWrapper wrapper = new MPJLambdaWrapper() - .selectAll(WalletRechargeApplyEntity.class) - .selectAs(WalletTypeEntity::getName, WalletRechargeApplyVo::getWalletTypeName) - .selectAs(WalletTypeEntity::getUniqueCode, WalletRechargeApplyVo::getWalletTypeUniqueCode) - .leftJoin(WalletTypeEntity.class, WalletTypeEntity::getId, WalletRechargeApplyEntity::getWalletTypeId) - .eqIfExists(WalletRechargeApplyEntity::getWalletTypeId, dto.getWalletTypeId()) - .in(ObjectUtil.isNotEmpty(dto.getUserIds()), WalletManageEntity::getUserId, dto.getUserIds()) - .in(ObjectUtil.isNotEmpty(dto.getWalletTypeIds()), WalletManageEntity::getWalletTypeId, dto.getWalletTypeIds()) - .between( - ObjectUtil.isNotEmpty(dto.getCreateTimeList()), - WalletRechargeApplyEntity::getCreateTime, - ObjectUtil.isNotEmpty(dto.getCreateTimeList()) ? dto.getCreateTimeList()[0] : null, - ObjectUtil.isNotEmpty(dto.getCreateTimeList()) ? dto.getCreateTimeList()[1] : null - ) - .between( - ObjectUtil.isNotEmpty(dto.getProcessTimeList()), - WalletRechargeApplyEntity::getProcessTime, - ObjectUtil.isNotEmpty(dto.getProcessTimeList()) ? dto.getProcessTimeList()[0] : null, - ObjectUtil.isNotEmpty(dto.getProcessTimeList()) ? dto.getProcessTimeList()[1] : null - ) - .orderByDesc(WalletRechargeApplyEntity::getCreateTime) - .orderByDesc(WalletRechargeApplyEntity::getId); - return selectJoinPage(page, WalletRechargeApplyVo.class, wrapper); - } + + Page scopePageList(Page page, @Param("dto") WalletRechargeApplyDto dto, DataScope dataScope); + + Page pageJoin(Page page, @Param("dto") WalletRechargeApplyDto dto, DataScope dataScope); default Page scopePageList(Page page, WalletRechargeApplyDto dto) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper() @@ -71,8 +51,9 @@ public interface WalletRechargeApplyMapper extends PjcloudBaseMapper { @@ -11,4 +16,14 @@ public interface WalletRechargeInvoiceMapper extends PjcloudBaseMapper scopePageList(Page page, @Param("dto") WalletRechargeBindInvoiceDto dto, DataScope dataScope); + + /** + * 查询详情 + */ + 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/WalletRechargeApplyComposeService.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/WalletRechargeApplyComposeService.java index 22c1c1952..c25cc80e5 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/WalletRechargeApplyComposeService.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/service/WalletRechargeApplyComposeService.java @@ -2,6 +2,7 @@ package com.bsd.pjcloud.wallet.service; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeApplyDto; +import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeSaveTopupDto; import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeApplyCompareAceVo; public interface WalletRechargeApplyComposeService { 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..580910a24 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 @@ -3,9 +3,11 @@ 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.core.util.R; +import com.bsd.pjcloud.common.data.datascope.DataScope; import com.bsd.pjcloud.flow.task.dto.ProcessNodeRecordAssignUserParamDto; import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeApplyDto; import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeImportDto; +import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeSaveTopupDto; import com.bsd.pjcloud.wallet.api.dto.recharge.excel.WalletRechargeExcelDto; import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeApplyEntity; import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeApplyVo; @@ -17,6 +19,11 @@ import java.util.List; public interface WalletRechargeApplyService extends IService { + /** + * 新增充值 + */ + void saveTopup(WalletRechargeSaveTopupDto dto); + void create(WalletRechargeApplyEntity dto); Boolean edit(WalletRechargeApplyDto dto); @@ -26,9 +33,9 @@ public interface WalletRechargeApplyService extends IService list); - Page pageJoin(Page page, WalletRechargeApplyDto dto); + Page pageJoin(Page page, WalletRechargeApplyDto dto, DataScope dataScope); - Page scopePageList(Page page, WalletRechargeApplyDto dto); + Page scopePageList(Page page, WalletRechargeApplyDto dto, DataScope dataScope); /** * 提交申请 @@ -41,9 +48,14 @@ public interface WalletRechargeApplyService extends IService excelVOList, BindingResult bindingResult); + R readExcel(List excelVOList, BindingResult bindingResult, String bizType); + + /** + * 读取充值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 71f795fea..e8451e46d 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,18 +1,55 @@ 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.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, DataScope dataScope); + + /** + * 查询详情 + */ + WalletRechargeInvoiceVo joinById(Long id); + /** * 批量充值/扣款发票信息 */ - WalletRechargeInvoiceEntityVo getInvoice(Long id); + WalletRechargeInvoiceVo getInvoice(Long id); /** * 获取发票代码 */ String getInvoiceCode(); + + /** + * 绑定发票 + */ + void bindInvoice(@Valid WalletRechargeBindInvoiceDto dto); + + /** + * 创建基础发票 + */ + WalletRechargeInvoiceEntity createBaseInvoice(PjcloudUser loginUser, Integer totalPrice); + + /** + * 编辑发票 + */ + Long edit(WalletRechargeInvoiceEntity dto); + + /** + * 批量删除发票 + */ + void delByIds(ArrayList 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 2d08bada0..cd4140ef7 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 @@ -21,6 +21,7 @@ import com.bsd.pjcloud.common.core.constant.enums.YesNoEnum; import com.bsd.pjcloud.common.core.util.BeanUtils; import com.bsd.pjcloud.common.core.util.CollectionUtils; import com.bsd.pjcloud.common.core.util.R; +import com.bsd.pjcloud.common.data.datascope.DataScope; import com.bsd.pjcloud.common.data.tenant.TenantContextHolder; import com.bsd.pjcloud.common.excel.vo.ErrorMessage; import com.bsd.pjcloud.common.security.service.PjcloudUser; @@ -33,16 +34,19 @@ import com.bsd.pjcloud.flow.task.dto.TaskDto; import com.bsd.pjcloud.flow.task.dto.TaskParamDto; import com.bsd.pjcloud.wallet.api.constant.WalletBizEnum; import com.bsd.pjcloud.wallet.api.constant.WalletBizRechargeEnum; +import com.bsd.pjcloud.wallet.api.constant.WalletRechargeInvoiceStatusEnum; import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum; import com.bsd.pjcloud.wallet.api.dto.WalletManageDto; import com.bsd.pjcloud.wallet.api.dto.WalletTypeDto; import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeApplyDto; import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeImportDto; +import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeSaveTopupDto; import com.bsd.pjcloud.wallet.api.dto.recharge.excel.WalletRechargeExcelDto; 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 +56,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 +64,8 @@ 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.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.BindingResult; @@ -92,6 +99,7 @@ public class WalletRechargeApplyServiceImpl extends ServiceImpl list = rechargeImportService.list(new LambdaQueryWrapper().eq(WalletRechargeImportEntity::getInvoiceId, invoice.getId()).isNull(WalletRechargeImportEntity::getApplyId)); + if (ObjectUtil.isNotEmpty(list)) { + List updateObjList = list.stream().map(v -> { + WalletRechargeImportEntity item = new WalletRechargeImportEntity(); + item.setId(v.getId()); + item.setApplyId(apply.getId()); + return item; + }).toList(); + rechargeImportService.updateBatchById(updateObjList); + } + // 更新发票状态 + WalletRechargeInvoiceEntity updateObj = new WalletRechargeInvoiceEntity(); + updateObj.setId(invoice.getId()); + updateObj.setStatus(WalletRechargeInvoiceStatusEnum.BINDED.getCode()); + updateObj.setApplyId(apply.getId()); + walletRechargeInvoiceService.updateById(updateObj); + } + @Override public void create(WalletRechargeApplyEntity dto) { PjcloudUser loginUser = SecurityUtils.getUser(); @@ -145,6 +193,10 @@ public class WalletRechargeApplyServiceImpl extends ServiceImpl pageJoin(Page page, WalletRechargeApplyDto dto) { - Page list = baseMapper.pageJoin(page, dto); + public Page pageJoin(Page page, WalletRechargeApplyDto dto, DataScope dataScope) { + Page list = baseMapper.pageJoin(page, dto, dataScope); if (ObjectUtil.isNotEmpty(list.getRecords())) { // 用户 List userIds = list.getRecords().stream().map(WalletRechargeApplyVo::getUserId).distinct().toList(); @@ -178,8 +230,8 @@ public class WalletRechargeApplyServiceImpl extends ServiceImpl scopePageList(Page page, WalletRechargeApplyDto dto) { - Page list = baseMapper.scopePageList(page, dto); + public Page scopePageList(Page page, WalletRechargeApplyDto dto, DataScope dataScope) { + Page list = baseMapper.scopePageList(page, dto, dataScope); disposeList(list.getRecords(), dto); return list; } @@ -197,7 +249,7 @@ public class WalletRechargeApplyServiceImpl extends ServiceImpl list, BindingResult bindingResult) { + public R readExcel(List excelVOList, BindingResult bindingResult, String bizType) { + 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()); + insertObj.setBizType(bizType); + 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 +409,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 ************************************* */ @@ -346,6 +438,15 @@ public class WalletRechargeApplyServiceImpl extends ServiceImpl importList = rechargeImportService.list(new LambdaQueryWrapper().eq(WalletRechargeImportEntity::getApplyId, detail.getId())); if (ObjectUtil.isEmpty(importList)) { @@ -487,7 +588,7 @@ public class WalletRechargeApplyServiceImpl extends ServiceImpl().eq(WalletRechargeApplyEntity::getUserId, walletId).eq(WalletRechargeApplyEntity::getProcessStatus, NodeStatusEnum.JXZ.getCode())); - return count >= 3; + return count >= 10; } /** 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 9a09413b8..1bd6973c9 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,31 +1,40 @@ package com.bsd.pjcloud.wallet.service.impl.recharge; -import cn.hutool.core.date.DatePattern; -import cn.hutool.core.date.LocalDateTimeUtil; +import cn.hutool.core.bean.BeanUtil; 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.data.datascope.DataScope; +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; +import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeBindInvoiceDto; 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.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; import org.springframework.stereotype.Service; +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; /** @@ -36,21 +45,47 @@ import java.util.List; public class WalletRechargeInvoiceServiceImpl extends ServiceImpl implements WalletRechargeInvoiceService { private final WalletRechargeImportMapper importMapper; - - private final WalletRechargeApplyService applyService; + private final WalletRechargeApplyMapper applyMapper; private final RemoteUserService remoteUserService; private final RemoteWalletSettingService remoteWalletSettingService; + /** + * 分页查询 + */ + @Override + public Page scopePageList(Page page, WalletRechargeBindInvoiceDto dto, DataScope dataScope) { + return baseMapper.scopePageList(page, dto, dataScope); + } + + /** + * 查询详情 + */ + @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))); + // 生成款项 + WalletRechargeInvoiceItemVo item = new WalletRechargeInvoiceItemVo(); + item.setName("伙食费充值"); + item.setPrice(price); + detail.setItemJson(JSONUtil.toJsonStr(List.of(item))); + 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(" 批量充值/扣款申请不存在"); + throw new RuntimeException("批量充值/扣款申请不存在"); } // 查询申请记录有没有编辑过 if (!ObjectUtil.isAllNotEmpty(applyDetail.getImportTime(), applyDetail.getWalletTypeId())) { @@ -60,6 +95,20 @@ public class WalletRechargeInvoiceServiceImpl extends ServiceImpl() + .eq(WalletRechargeInvoiceEntity::getApplyId, id) + .eq(WalletRechargeInvoiceEntity::getStatus, WalletRechargeInvoiceStatusEnum.UNBIND.getCode()) + ); + if (ObjectUtil.isNotEmpty(InvoiceEntity)) { + 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; + } + // 获取配置 WalletSettingVo walletSetting = remoteWalletSettingService.get().getData(); // 查询申请人 @@ -79,13 +128,12 @@ public class WalletRechargeInvoiceServiceImpl extends ServiceImpl importList = importMapper.selectList(new LambdaQueryWrapper().eq(WalletRechargeImportEntity::getApplyId, id)); Integer totalPrice = importList.stream().map(WalletRechargeImportEntity::getPrice).reduce(Integer::sum).orElse(0); // 转换为元 - double price = BigDecimal.valueOf(totalPrice).divide(BigDecimal.valueOf(100)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + Double price = BigDecimal.valueOf(totalPrice).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP).doubleValue(); // 生成款项 - WalletRechargeInvoiceEntityItemVo item = new WalletRechargeInvoiceEntityItemVo(); - item.setName(LocalDateTimeUtil.format(applyDetail.getImportTime(), DatePattern.NORM_MONTH_PATTERN)); + WalletRechargeInvoiceItemVo item = new WalletRechargeInvoiceItemVo(); + item.setName("伙食费充值"); item.setPrice(price); - WalletRechargeInvoiceEntityVo result = new WalletRechargeInvoiceEntityVo(); result.setApplyId(applyDetail.getId()); result.setCode(getInvoiceCode()); result.setTime(applyDetail.getApplyTime()); @@ -94,10 +142,78 @@ public class WalletRechargeInvoiceServiceImpl extends ServiceImpl list) { + if (ObjectUtil.isEmpty(list)) return; + for (Long v : list) { + WalletRechargeInvoiceEntity detail = baseMapper.selectById(v); + if (ObjectUtil.isEmpty(detail) || ObjectUtil.isEmpty(detail.getApplyId())) continue; + if (ObjectUtil.isNotEmpty(detail.getStatus()) && ObjectUtil.notEqual(detail.getStatus(), WalletRechargeInvoiceStatusEnum.UNBIND.getCode())) { + UserInfo userInfo = remoteUserService.getByUserId(detail.getApplyUserId()).getData(); + throw new RuntimeException("用户<" + userInfo.getSysUser().getName() + ">创建的发票已经" + WalletRechargeInvoiceStatusEnum.codeOf(detail.getStatus()).getDesc() + "不能删除"); + } + // 删除申请记录 + baseMapper.deleteById(v); + // 删除申请记录条目 + importMapper.delete(new LambdaQueryWrapper().eq(WalletRechargeImportEntity::getApplyId, v)); + } } /** @@ -109,4 +225,19 @@ public class WalletRechargeInvoiceServiceImpl extends ServiceImpl updateWrapper = new LambdaUpdateWrapper() + .set(WalletRechargeApplyEntity::getInvoiceId, entity.getId()) + .eq(WalletRechargeApplyEntity::getId, entity.getApplyId()); + applyMapper.update(updateWrapper); + } } \ No newline at end of file diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/utils/ConvertCnPriceUtil.java b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/utils/ConvertCnPriceUtil.java index 50e58ada3..83bdfcc7a 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/utils/ConvertCnPriceUtil.java +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/java/com/bsd/pjcloud/wallet/utils/ConvertCnPriceUtil.java @@ -24,6 +24,13 @@ public class ConvertCnPriceUtil { // 去掉分隔符 amount = amount.replace(",", ""); + String[] split = amount.split("\\."); + if (split.length > 1) { + if (split[1].length() == 1) { + amount = amount + "0"; + } + } + // 验证金额正确性 if (amount.equals("0.00")) { throw new IllegalArgumentException("金额不能为零."); @@ -89,4 +96,8 @@ public class ConvertCnPriceUtil { } return buffer.reverse().toString(); } + + public static void main(String[] args) { + System.out.println(convert("55.00")); + } } diff --git a/pjcloud-wallet/pjcloud-wallet-biz/src/main/resources/mapper/recharge/WalletRechargeApplyMapper.xml b/pjcloud-wallet/pjcloud-wallet-biz/src/main/resources/mapper/recharge/WalletRechargeApplyMapper.xml index 87afb2acf..ecf85e886 100644 --- a/pjcloud-wallet/pjcloud-wallet-biz/src/main/resources/mapper/recharge/WalletRechargeApplyMapper.xml +++ b/pjcloud-wallet/pjcloud-wallet-biz/src/main/resources/mapper/recharge/WalletRechargeApplyMapper.xml @@ -3,19 +3,95 @@ - - - - - - - - - - - - - - - + + select a.id, + a.user_id, + a.invoice_id, + a.process_id, + a.process_status, + a.process_time, + a.biz_type, + a.wallet_type_id, + a.dept_id, + a.import_time, + a.remark, + a.create_by, + a.create_time, + a.update_by, + a.update_time, + a.del_flag, + a.tenant_id, + a.apply_time, + a.is_authorization, + + + + a.del_flag = '0' + + and a.process_status = #{dto.processStatus} + + + and a.user_id = #{dto.userId} + + + and a.biz_type = #{dto.bizType} + + + and a.user_id in + + #{v} + + + + and a.wallet_type_id in + + #{v} + + + + and a.create_time between #{dto.createTimeList[0]} and #{dto.createTimeList[1]} + + + and a.create_time between #{dto.processTimeList[0]} and #{dto.processTimeList[1]} + + + + + + t.name as walletTypeName, + t.unique_code as walletTypeUniqueCode, + t.icon as walletTypeIcon, + t.is_rule as isRule, + (select sum(i.price) + from wallet_recharge_import i + where i.del_flag = '0' + and i.apply_id = a.id) as totalPrice + from wallet_recharge_apply a + left join wallet_type t on a.wallet_type_id = t.id and t.del_flag = '0' + + + + group by a.id + + order by a.process_time desc , a.id desc + + + ORDER BY + CASE + WHEN a.apply_time IS NULL THEN 1 + ELSE 0 + END ASC, + a.apply_time DESC, + a.create_time DESC + + + + + + + \ No newline at end of file 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..0ca287a8e 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,64 @@ - - - - - - - - - - - - - - - - - - + + 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, + + + + a.del_flag = '0' + + 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