123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.dayou.mapper.FinanceInvoiceMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.dayou.entity.FinanceInvoice">
- <result column="id" property="id" />
- <result column="deleted" property="deleted" />
- <result column="modified" property="modified" />
- <result column="created" property="created" />
- <result column="production_fund_id" property="productionFundId" />
- <result column="title" property="title" />
- <result column="type" property="type" />
- <result column="tax_no" property="taxNo" />
- <result column="plan_amount" property="planAmount" />
- <result column="real_amount" property="realAmount" />
- <result column="plan_make_date" property="planMakeDate" />
- <result column="real_make_date" property="realMakeDate" />
- <result column="state" property="state" />
- <result column="reason" property="reason" />
- <result column="apply_id" property="applyId" />
- <result column="checker_id" property="checkerId" />
- <result column="maker_id" property="makerId" />
- <result column="bank_name" property="bankName" />
- <result column="bank_account" property="bankAccount" />
- <result column="bank_address" property="bankAddress" />
- <result column="bank_tel" property="bankTel" />
- <result column="make_item" property="makeItem" />
- <result column="item_quantity" property="itemQuantity" />
- <result column="item_unit" property="itemUnit" />
- <result column="tax_rate" property="taxRate" />
- <result column="tax_amount" property="taxAmount" />
- <result column="remark" property="remark" />
- </resultMap>
- <!-- 通用查询结果列 -->
- <sql id="Base_Column_List">
- id,
- deleted,
- modified,
- created,
- production_fund_id, title, type, tax_no, plan_amount, real_amount, plan_make_date, real_make_date, state, reason, apply_id, checker_id, maker_id, bank_name, bank_account, bank_address, bank_tel, make_item, item_quantity, item_unit, tax_rate, tax_amount, remark
- </sql>
- <!--开票列表查询Sql-->
- <sql id="getPageSql">
- SELECT
- fi.*,
- fi.created AS createTime,
- (case orf.business_type when 'ASSET_BUSINESS' THEN '资产业务' WHEN 'MAJOR_BUSINESS' THEN '大中型业务' WHEN 'ITEM_BUSINESS' THEN '土规业务' else '个贷业务' end) as businessType,
- orf.order_id,
- orf.order_name,
- (orf.should_amount=orf.real_amount) as isPayAll,
- u.name AS applyName,
- pf.production_no
- FROM
- finance_invoice fi
- LEFT JOIN order_fund orf ON fi.order_fund_id = orf.id
- LEFT JOIN user u ON u.id = fi.apply_id
- left join production_fund pf on pf.id = fi.production_fund_id
- where fi.deleted = 0 and orf.deleted = 0
- <if test="vo!=null and vo.state!=null and vo.state!='' and vo.state=='审核中' ">
- and (fi.state = '申请作废' or fi.state = '审核中')
- </if>
- <if test="vo!=null and vo.state!=null and vo.state!='' and vo.state!='审核中' ">
- and fi.state = #{vo.state}
- </if>
- <if test="keyword!=null and keyword!='' ">
- and (
- fi.title like concat ('%',#{keyword},'%')
- or orf.order_name like concat('%',#{keyword},'%')
- or orf.order_id like concat('%',#{keyword},'%')
- or orf.business_type like concat('%',#{keyword},'%')
- or u.name like concat('%',#{keyword},'%')
- or fi.type like concat('%',#{keyword},'%')
- or fi.tax_no like concat('%',#{keyword},'%')
- or fi.plan_amount like concat('%',#{keyword},'%')
- or fi.state like concat('%',#{keyword},'%')
- or fi.remark like concat('%',#{keyword},'%')
- or pf.production_no like concat('%',#{keyword},'%')
- )
- </if>
- <if test="vo!=null and vo.pStartDate!=null and vo.pStartDate!=''">
- and fi.plan_make_date >= #{vo.pStartDate}
- </if>
- <if test="vo!=null and vo.pEndDate!=null and vo.pEndDate!=''">
- and fi.plan_make_date <= #{vo.pEndDate}
- </if>
- <if test="vo!=null and vo.rStartDate!=null and vo.rStartDate!=''">
- and fi.real_make_date >= #{vo.rStartDate}
- </if>
- <if test="vo!=null and vo.rEndDate!=null and vo.rEndDate!=''">
- and fi.real_make_date <= #{vo.rEndDate}
- </if>
- <if test="vo!=null and vo.dStartDate!=null and vo.dStartDate!=''">
- and fi.modified >= #{vo.dStartDate}
- </if>
- <if test="vo!=null and vo.dEndDate!=null and vo.dEndDate!=''">
- and fi.modified <= #{vo.dEndDate}
- </if>
- <if test="vo!=null and vo.aStartDate!=null and vo.aStartDate!=''">
- and fi.created >= #{vo.aStartDate}
- </if>
- <if test="vo!=null and vo.aEndDate!=null and vo.aEndDate!=''">
- and fi.created <= #{vo.aEndDate}
- </if>
- <if test="vo!=null and vo.state!=null and vo.state!='' and vo.state!='审核中' ">
- order by fi.modified DESC
- </if>
- <if test="vo!=null and vo.state!=null and vo.state!='' and vo.state=='审核中' ">
- order by fi.created DESC
- </if>
- </sql>
- <!--开票分页查询-->
- <select id="getPage" parameterType="com.dayou.entity.FinanceInvoice" resultType="com.dayou.vo.FinanceInvoiceVo">
- <include refid="getPageSql" />
- </select>
- <!--开票信息导出-->
- <select id="exportPage" resultType="com.dayou.vo.FinanceInvoiceVo">
- <include refid="getPageSql" />
- </select>
- <select id="getInvoiceAmountInfo" parameterType="com.dayou.dto.MajorProductionSimpleDTO" resultType="com.dayou.vo.FinanceInvoiceVo">
- SELECT
- pf.*,
- orderFund.*,
- invoice.*
- FROM
- (
- SELECT
- id,
- business_type,
- real_amount AS orderRealAmount,
- should_amount
- FROM
- order_fund
- WHERE
- deleted = 0
- AND business_type = 'MAJOR_BUSINESS'
- AND business_id = #{dto.majorId}) orderFund
- LEFT JOIN (
- SELECT
- order_fund_id,
- bank_name,
- real_amount AS invoiceAmount,
- title AS invoiceTitle,
- type AS invoiceType,
- tax_no,
- tax_amount AS invoiceTaxAmount,
- tax_rate AS invoiceTaxRate,
- state AS invoiceState,
- real_make_date AS invoiceDate
- FROM
- finance_invoice
- WHERE
- state != '驳回'
- AND state != '作废'
- AND deleted = 0
- ) invoice ON invoice.order_fund_id = orderFund.id
- LEFT JOIN (
- SELECT
- mp.id,
- p.real_amount AS prodRealAmount,
- mp.standard_amount,
- p.order_fund_id,
- p.business_type,
- mp.report_no as productionNo,
- ( CASE mp.production WHEN 'STATEMENT' THEN '价值意见书' WHEN 'REPORT' THEN '报告' ELSE '复评函' END ) AS productionType
- FROM
- major_production mp
- left JOIN production_fund p ON ( mp.report_no = ifnull(p.production_no,mp.report_no) AND mp.major_id = ifnull(p.business_id,mp.major_id ))
- WHERE
- mp.deleted = 0
- AND mp.major_id = #{dto.majorId}
- <if test="dto.productionNos!=null and dto.productionNos.size()>0">
- and mp.report_no in (
- <foreach collection="dto.productionNos" separator="," index="index" item="item">
- #{item}
- </foreach>
- )
- </if>
- ) pf on ( orderFund.id = ifnull(pf.order_fund_id,orderFund.id) AND orderFund.business_type = ifnull(pf.business_type,orderFund.business_type) )
- order by pf.id asc
- </select>
- <select id="getInvoiceAmountInfoEmptyProduction" parameterType="com.dayou.dto.MajorProductionSimpleDTO" resultType="com.dayou.vo.FinanceInvoiceVo">
- SELECT
- orderFund.*,
- invoice.*
- FROM
- (
- SELECT
- id,
- business_type,
- real_amount AS orderRealAmount,
- should_amount
- FROM
- order_fund
- WHERE
- deleted = 0
- AND business_type = 'MAJOR_BUSINESS'
- AND business_id = #{dto.majorId}) orderFund
- LEFT JOIN (
- SELECT
- order_fund_id,
- bank_name,
- real_amount AS invoiceAmount,
- title AS invoiceTitle,
- type AS invoiceType,
- tax_no,
- tax_amount AS invoiceTaxAmount,
- tax_rate AS invoiceTaxRate,
- state AS invoiceState,
- real_make_date AS invoiceDate
- FROM
- finance_invoice
- WHERE
- state != '驳回'
- AND state != '作废'
- AND deleted = 0
- ) invoice ON invoice.order_fund_id = orderFund.id
- </select>
- <!--根据收款信息获取发票号-->
- <select id="getInvoiceNoByFundId" resultType="java.lang.String">
- SELECT GROUP_CONCAT(ticket_no SEPARATOR ',')
- FROM finance_invoice
- WHERE finance_invoice.deleted = 0
- AND finance_invoice.order_fund_id = #{orderFundId}
- <if test="productionFundId != null">
- AND finance_invoice.production_fund_id = #{productionFundId}
- </if>
- </select>
- <select id="getList" resultType="com.dayou.entity.FinanceInvoice">
- select * from finance_invoice where deleted = 0 and order_fund_id = #{orderFundId}
- <if test="productionFundId!=null">
- and production_fund_id = #{productionFundId}
- </if>
- <if test="productionFundId == null">
- and production_fund_id is null
- </if>
- order by created DESC
- </select>
- </mapper>
|