wujianwei
2026-01-07 5c3154277d1f6d94d511cb7fd70e7b88ab318a99
新增开票接口
5个文件已修改
70 ■■■■ 已修改文件
service/src/main/java/com/ruoyi/cwgl/controller/InvoiceManageController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/src/main/java/com/ruoyi/cwgl/domain/InvoiceManage.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/src/main/java/com/ruoyi/cwgl/service/IInvoiceManageService.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/src/main/java/com/ruoyi/cwgl/service/impl/InvoiceManageServiceImpl.java 30 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/src/main/resources/mapper/cwgl/InvoiceManageMapper.xml 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/src/main/java/com/ruoyi/cwgl/controller/InvoiceManageController.java
@@ -102,11 +102,11 @@
    @PreAuthorize("@ss.hasPermi('cwgl:invoiceManage:apply')")
    @Log(title = "申请开票", businessType = BusinessType.UPDATE)
    @PostMapping("/apply/{id}")
    public AjaxResult applyInvoice(@PathVariable("id") Integer id, @RequestBody List<InvoiceBillDetail> invoiceBillDetails)
    public AjaxResult applyInvoice(@PathVariable("id") Integer id)
    {
       return invoiceManageService.applyInvoice(id,invoiceBillDetails);
       return invoiceManageService.applyInvoice(id);
            
service/src/main/java/com/ruoyi/cwgl/domain/InvoiceManage.java
@@ -197,4 +197,9 @@
    @TableField(exist = false)
    private List<InvoiceDetail> invoiceDetailList;
        @TableField(exist = false)
    private List<InvoiceBillDetail> invoiceBillDetails;
}
service/src/main/java/com/ruoyi/cwgl/service/IInvoiceManageService.java
@@ -3,7 +3,6 @@
import java.util.List;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.cwgl.domain.InvoiceBillDetail;
import com.ruoyi.cwgl.domain.InvoiceManage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.cwgl.domain.dto.CallbackReceiptDto;
@@ -115,10 +114,9 @@
    /**
     * 申请开票
     * @param id
     * @param invoiceBillDetails
     * @return
     */
    AjaxResult applyInvoice(Integer id, List<InvoiceBillDetail> invoiceBillDetails);
    AjaxResult applyInvoice(Integer id);
    /**
     * 开票回调接口
service/src/main/java/com/ruoyi/cwgl/service/impl/InvoiceManageServiceImpl.java
@@ -1,8 +1,6 @@
package com.ruoyi.cwgl.service.impl;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.http.HttpUtil;
@@ -33,6 +31,7 @@
import com.ruoyi.common.core.service.BaseService;
import com.ruoyi.cwgl.mapper.InvoiceManageMapper;
import com.ruoyi.cwgl.mapper.InvoiceBillDetailMapper;
import com.ruoyi.cwgl.service.IInvoiceManageService;
import com.ruoyi.cwgl.service.IInvoiceManageLogService;
import com.ruoyi.common.core.text.Convert;
@@ -49,6 +48,9 @@
    protected final Logger logger = LoggerFactory.getLogger(getClass());
    @Resource
    private InvoiceManageMapper invoiceManageMapper;
    @Resource
    private InvoiceBillDetailMapper invoiceBillDetailMapper;
    @Resource
    private IInvoiceManageLogService invoiceManageLogService;
@@ -263,6 +265,20 @@
                invoiceManageMapper.batchInvoiceDetail(list);
            }
        }
        // 新增发票业务商品明细信息
        List<InvoiceBillDetail> invoiceBillDetails = invoiceManage.getInvoiceBillDetails();
        if (StringUtils.isNotNull(invoiceBillDetails)) {
            List<InvoiceBillDetail> billDetailList = new ArrayList<InvoiceBillDetail>();
            for (InvoiceBillDetail invoiceBillDetail : invoiceBillDetails) {
                invoiceBillDetail.setInvoiceManageId(id);
                invoiceBillDetail.setCreateTime(new Date());
                billDetailList.add(invoiceBillDetail);
            }
            if (billDetailList.size() > 0) {
                invoiceBillDetailMapper.insertInvoiceBillDetailBatch(billDetailList);
            }
        }
    }
    /**
@@ -310,7 +326,7 @@
    }
    @Override
    public AjaxResult applyInvoice(Integer id, List<InvoiceBillDetail> invoiceBillDetails) {
    public AjaxResult applyInvoice(Integer id) {
        InvoiceManage invoiceManage = selectInvoiceManageById(id);
        if (invoiceManage == null) {
            throw new ServiceException("发票记录不存在");
@@ -319,9 +335,9 @@
            throw new ServiceException("请勿重复开票");
        }
        List<InvoiceDetail> invoiceDetailList = invoiceManage.getInvoiceDetailList();
        if (CollectionUtil.isEmpty(invoiceDetailList)) {
            throw new ServiceException("收费明细无数据");
        List<InvoiceBillDetail> invoiceBillDetails = invoiceManage.getInvoiceBillDetails();
        if (CollectionUtil.isEmpty(invoiceBillDetails)) {
            throw new ServiceException("商品明细无数据无法开发票");
        }
@@ -474,3 +490,5 @@
    }
}
service/src/main/resources/mapper/cwgl/InvoiceManageMapper.xml
@@ -39,6 +39,15 @@
        <collection property="invoiceDetailList" notNullColumn="sub_id" javaType="java.util.List" resultMap="InvoiceDetailResult" />
    </resultMap>
    <resultMap id="InvoiceManageInvoiceBillDetailResult" type="com.ruoyi.cwgl.domain.InvoiceManage" extends="InvoiceManageResult">
        <collection property="invoiceBillDetails" notNullColumn="bill_detail_id" javaType="java.util.List" resultMap="InvoiceBillDetailResult" />
    </resultMap>
    <resultMap id="InvoiceManageFullResult" type="com.ruoyi.cwgl.domain.InvoiceManage" extends="InvoiceManageResult">
        <collection property="invoiceDetailList" notNullColumn="sub_id" javaType="java.util.List" resultMap="InvoiceDetailResult" />
        <collection property="invoiceBillDetails" notNullColumn="bill_detail_id" javaType="java.util.List" resultMap="InvoiceBillDetailResult" />
    </resultMap>
    <resultMap type="com.ruoyi.cwgl.domain.InvoiceDetail" id="InvoiceDetailResult">
        <result property="id"    column="sub_id"    />
        <result property="invoiceManageId"    column="sub_invoice_manage_id"    />
@@ -51,6 +60,17 @@
        <result property="createTime"    column="sub_create_time"    />
        <result property="updateTime"    column="sub_update_time"    />
        <result property="deleted"    column="sub_deleted"    />
    </resultMap>
    <resultMap type="com.ruoyi.cwgl.domain.InvoiceBillDetail" id="InvoiceBillDetailResult">
        <result property="id"    column="bill_detail_id"    />
        <result property="invoiceManageId"    column="bill_detail_invoice_manage_id"    />
        <result property="goodsName"    column="bill_detail_goods_name"    />
        <result property="price"    column="bill_detail_price"    />
        <result property="status"    column="bill_detail_status"    />
        <result property="createTime"    column="bill_detail_create_time"    />
        <result property="updateTime"    column="bill_detail_update_time"    />
        <result property="withTaxFlag"    column="bill_detail_with_tax_flag"    />
    </resultMap>
    <sql id="selectInvoiceManageVo">
@@ -86,10 +106,13 @@
    </sql>
    <!--查询-->
    <select id="selectInvoiceManageById" parameterType="Integer" resultMap="InvoiceManageInvoiceDetailResult">
    <select id="selectInvoiceManageById" parameterType="Integer" resultMap="InvoiceManageFullResult">
        select a.id, a.order_no, a.invoice_info_id, a.invoice_seller_id, a.customer_name, a.invoice_seller_name, a.invoice_company_name, a.invoice_credit_code, a.invoice_seller_credit_code, a.invoice_bank_name, a.invoice_bank_no, a.invoice_operating_license_address, a.invoice_operating_license_phone, a.invoice_seller_address, a.invoice_seller_phone, a.invoice_operating_license_email, a.status, a.invoice_no, a.invoice_date, a.invoice_amount, a.related_bill_billed_amount, a.create_by, a.update_by, a.create_time, a.update_time, a.deleted, a.invoice_type, a.enterprise_type,
             b.id as sub_id, b.invoice_manage_id as sub_invoice_manage_id, b.receivable_bill_no as sub_receivable_bill_no, b.receivable_bill_amount as sub_receivable_bill_amount, b.receivable_bill_currency as sub_receivable_bill_currency, b.billed_amount as sub_billed_amount, b.unbilled_amount as sub_unbilled_amount, b.current_billed_amount as sub_current_billed_amount, b.create_time as sub_create_time, b.update_time as sub_update_time, b.deleted as sub_deleted        from invoice_manage a
             b.id as sub_id, b.invoice_manage_id as sub_invoice_manage_id, b.receivable_bill_no as sub_receivable_bill_no, b.receivable_bill_amount as sub_receivable_bill_amount, b.receivable_bill_currency as sub_receivable_bill_currency, b.billed_amount as sub_billed_amount, b.unbilled_amount as sub_unbilled_amount, b.current_billed_amount as sub_current_billed_amount, b.create_time as sub_create_time, b.update_time as sub_update_time, b.deleted as sub_deleted,
             c.id as bill_detail_id, c.invoice_manage_id as bill_detail_invoice_manage_id, c.goods_name as bill_detail_goods_name, c.price as bill_detail_price, c.status as bill_detail_status, c.create_time as bill_detail_create_time, c.update_time as bill_detail_update_time, c.with_tax_flag as bill_detail_with_tax_flag
        from invoice_manage a
        left join invoice_detail b on b.invoice_manage_id = a.id
        left join invoice_bill_detail c on c.invoice_manage_id = a.id
        where a.id = #{id}
    </select>