xuhy
2025-04-03 980052523e461ba3745a6a0b73bd2b309e1eb879
开票
3个文件已修改
32 ■■■■■ 已修改文件
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TCheckAcceptRecordController.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/TBillController.java 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/FlowListenerService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TCheckAcceptRecordController.java
@@ -118,6 +118,7 @@
            tBill.setPayFeesStatus("1");
            tBill.setBillType("4");
            tBill.setSmsStatus(0);
            tBill.setBusinessDeptId(contract.getBusinessDeptId());
            billService.save(tBill);
        }
ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/TBillController.java
@@ -9,7 +9,6 @@
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;
@@ -22,12 +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>
@@ -129,17 +130,39 @@
    @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();
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/FlowListenerService.java
@@ -525,6 +525,8 @@
                    depositBill.setBillType("2");
                    contractService.updateById(contract);
                    rentBill.setBusinessDeptId(contract.getBusinessDeptId());
                    depositBill.setBusinessDeptId(contract.getBusinessDeptId());
                    billService.save(rentBill);
                    billService.save(depositBill);
                    // 生成后续账单
@@ -744,6 +746,7 @@
                                tBill.setContractNumber(contract.getContractNumber());
                                tBill.setPayFeesStatus("1");
                                tBill.setBillType("1");
                                tBill.setBusinessDeptId(contract.getBusinessDeptId());
                                billService.save(tBill);
                                beforeBill.setEndTime(beforeBill.getEndTime().plusMonths(contract.getPayType().equals("1") ? 1 : contract.getPayType().equals("2") ? 3 : 12).with(TemporalAdjusters.lastDayOfMonth()));
@@ -1014,6 +1017,7 @@
//                        } else {
                            tBill.setPayableFeesTime(tBill.getStartTime().withDayOfMonth(15).toLocalDate());
//                        }
                        tBill.setBusinessDeptId(contract.getBusinessDeptId());
                        billService.save(tBill);
                    }
                }