From fe846ceac8c8395477b0181d70f192d32be10894 Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期日, 27 四月 2025 15:02:05 +0800
Subject: [PATCH] bug修改
---
ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/TBillController.java | 77 ++++++++++++++++++++++++++++++++------
1 files changed, 65 insertions(+), 12 deletions(-)
diff --git a/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/TBillController.java b/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/TBillController.java
index 9212a3e..b9d8a9e 100644
--- a/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/TBillController.java
+++ b/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/TBillController.java
@@ -1,14 +1,16 @@
package com.ruoyi.web.controller.api;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.constant.DictConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.exception.ServiceException;
+import com.ruoyi.common.utils.CodeGenerateUtils;
import com.ruoyi.common.utils.DictUtils;
-import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.web.service.TokenService;
+import com.ruoyi.system.dto.BatchBillDTO;
import com.ruoyi.system.dto.TBillDto;
import com.ruoyi.system.dto.TInvoiceDTO;
import com.ruoyi.system.model.*;
@@ -19,10 +21,14 @@
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
+import java.time.LocalDateTime;
+import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.List;
+import java.util.Objects;
/**
* <p>
@@ -51,25 +57,44 @@
TInvoiceToBillService invoiceToBillService;
@Autowired
TokenService tokenService;
+ @Autowired
+ TTenantService tenantService;
@ApiOperation(value = "缴费账单查询分页列表")
@PostMapping("list")
public R<PageInfo<TBillDto>> list(@RequestBody TBillQuery query){
- if (StringUtils.isEmpty(query.getUserId())){
- throw new ServiceException("用户ID不能为空");
- }
- PageInfo<TBillDto> pageInfo = tBillService.queryPage(query);
+ String userId = tokenService.getLoginUserApplet().getUserId();
+ query.setUserId(userId);
+ PageInfo<TBillDto> pageInfo = tBillService.queryPageForApplet(query);
return R.ok(pageInfo);
+ }
+
+ public static void main(String[] args) {
+ LocalDateTime localDateTime1 = LocalDateTime.now().withYear(2025).withMonth(11).withDayOfMonth(1);
+ LocalDateTime localDateTime2 = LocalDateTime.now().withYear(2025).withMonth(11).withDayOfMonth(28);
+ long allDays = ChronoUnit.DAYS.between(localDateTime1, localDateTime2);
+ System.err.println(allDays);
}
@ApiOperation(value = "缴费账单查询列表")
@PostMapping("/getBillIds")
public R<List<String>> getBillIds(@RequestBody TBillQuery query){
- if (StringUtils.isEmpty(query.getUserId())){
- throw new ServiceException("用户ID不能为空");
- }
+ String userId = tokenService.getLoginUserApplet().getUserId();
+ query.setUserId(userId);
List<String> billIds = tBillService.getBillIds(query);
return R.ok(billIds);
+ }
+
+ @ApiOperation(value = "跳转批量缴费")
+ @PostMapping("/batchBill")
+ public R<String> batchBill(@RequestBody BatchBillDTO dto){
+ String userId = tokenService.getLoginUserApplet().getUserId();
+ List<String> billIds = dto.getBillIds();
+ Integer count = tBillService.batchBillCount(userId, billIds);
+ if(count>0){
+ return R.fail("请优先缴纳水电费");
+ }
+ return R.ok();
}
@ApiOperation(value = "查看缴费账单详情")
@@ -97,18 +122,47 @@
billVO.setConcatEndTime(contract.getEndTime());
});
billVO.setBillType(DictUtils.getDictLabel(DictConstants.DICT_TYPE_BILL_TYPE,billVO.getBillType()));
- billVO.setPayFeesStatus(DictUtils.getDictLabel(DictConstants.DICT_TYPE_PAY_FEES_STATUS,billVO.getPayFeesStatus()));
+// billVO.setPayFeesStatus(DictUtils.getDictLabel(DictConstants.DICT_TYPE_PAY_FEES_STATUS,billVO.getPayFeesStatus()));
return R.ok(billVO);
}
@ApiOperation(value = "缴费账单开票")
@PostMapping(value = "/invoice")
public R<String> invoice(@RequestBody TInvoiceDTO dto) {
+ String userId = tokenService.getLoginUserApplet().getUserId();
+ List<String> billIds = dto.getBillIds();
+ dto.setApplyName(tenantService.getById(userId).getResidentName());
+ String code;
+ do {
+ code = CodeGenerateUtils.generateVolumeSn();
+ } while (invoiceService.count(Wrappers.lambdaQuery(TInvoice.class).eq(TInvoice::getInvoiceNumber, code)) > 0);
+ dto.setInvoiceNumber(CodeGenerateUtils.generateVolumeSn());
+ String deptId = "";
+ List<TBill> list = tBillService.list(Wrappers.lambdaQuery(TBill.class).in(TBill::getId, billIds));
+ for (String billId : billIds) {
+ TBill tBill = list.stream().filter(bill -> bill.getId().equals(billId)).findFirst().orElse(null);
+ if(StringUtils.hasLength(deptId)){
+ if(Objects.nonNull(tBill)){
+ if(!deptId.equals(tBill.getBusinessDeptId())){
+ return R.fail("请选择同一运营部门账单开票");
+ }else {
+ deptId = tBill.getBusinessDeptId();
+ }
+ }
+ }else {
+ if(Objects.nonNull(tBill)){
+ deptId = tBill.getBusinessDeptId();
+ }else {
+ return R.fail("请选择同一运营部门账单开票");
+ }
+ }
+ }
+ dto.setBusinessDeptId(deptId);
+
// 添加开票信息
invoiceService.save(dto);
// 添加开票信息中间表信息
- List<String> billIds = dto.getBillIds();
List<TInvoiceToBill> sysInvoiceToBills = new ArrayList<>();
for (String billId : billIds) {
TInvoiceToBill tInvoiceToBill = new TInvoiceToBill();
@@ -124,8 +178,7 @@
@PostMapping(value = "/invoiceList")
public R<PageInfo<TBillDto>> invoiceList(@RequestBody TBillQuery query) {
-// Long userId = tokenService.getLoginUser().getUserId();
- String userId = "1881967035070177281";
+ String userId = tokenService.getLoginUserApplet().getUserId();
query.setUserId(userId);
PageInfo<TBillDto> pageInfo = tBillService.invoiceList(query);
return R.ok(pageInfo);
--
Gitblit v1.7.1