unis_sip/ruoyi-sip/src/main/resources/mapper/sip/OmsInvoiceBillMapper.xml

652 lines
28 KiB
XML

<?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.ruoyi.sip.mapper.OmsInvoiceBillMapper">
<resultMap type="com.ruoyi.sip.domain.OmsInvoiceBill" id="OmsInvoiceBillResult">
<result property="id" column="id" />
<result property="invoiceBillCode" column="invoice_bill_code" />
<result property="invoiceType" column="invoice_type" />
<result property="invoiceBillType" column="invoice_bill_type" />
<result property="invoiceTime" column="invoice_time" />
<result property="partnerCode" column="partner_code" />
<result property="totalPriceWithTax" column="total_price_with_tax" />
<result property="totalPriceWithoutTax" column="total_price_without_tax" />
<result property="invoicePriceWithTax" column="invoice_price_with_tax" />
<result property="invoicePriceWithoutTax" column="invoice_price_without_tax" />
<result property="taxRate" column="tax_rate" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<result property="delFlag" column="del_flag" />
<result property="actualInvoiceTime" column="actual_invoice_time" />
<result property="invoiceStatus" column="invoice_status" />
<result property="approveStatus" column="approve_status" />
<result property="approveNode" column="approve_node" />
<result property="approveTime" column="approve_time" />
<result property="refundStatus" column="refund_status" />
<result property="originalBillId" column="original_bill_id" />
<result property="invoiceApplyUser" column="invoice_apply_user" />
<result property="buyerName" column="buyer_name" />
<result property="buyerCreditCode" column="buyer_credit_code" />
<result property="buyerBank" column="buyer_bank" />
<result property="buyerBankAccount" column="buyer_bank_account" />
<result property="sellerName" column="seller_name" />
<result property="sellerCreditCode" column="seller_credit_code" />
<result property="sellerBank" column="seller_bank" />
<result property="sellerBankAccount" column="seller_bank_account" />
</resultMap>
<sql id="selectOmsInvoiceBillVo">
select t1.id, t1.invoice_bill_code, t1.invoice_type, t1.invoice_bill_type,
t1.invoice_time, t1.partner_code,t1.partner_name, t1.total_price_with_tax, t1.total_price_without_tax,t1.invoice_price_with_tax,t1.invoice_price_without_tax,
t1.tax_rate, t1.create_by, t1.create_time, t1.update_by, t1.update_time,
t1.remark, t1.del_flag, t1.actual_invoice_time, t1.invoice_status,
t1.approve_status, t1.approve_time, t1.refund_status
, t1.original_bill_id, t1.invoice_apply_user, t1.buyer_name, t1.buyer_credit_code, t1.buyer_bank, t1.buyer_bank_account,
t1.seller_name, t1.seller_credit_code, t1.seller_bank, t1.seller_bank_account
from oms_invoice_bill t1
</sql>
<select id="selectOmsInvoiceBillList" parameterType="com.ruoyi.sip.domain.OmsInvoiceBill" resultMap="OmsInvoiceBillResult">
<include refid="selectOmsInvoiceBillVo"/>
<where>
<if test="invoiceBillCode != null and invoiceBillCode != ''">
and t1.invoice_bill_code = #{invoiceBillCode}
</if>
<if test="receivableBillCode != null and receivableBillCode != ''">
and t1.invoice_bill_code in (
select invoice_bill_code from oms_receivable_invoice_detail orrd
left join oms_receivable_bill orb on orrd.receivable_bill_id=orb.id
where orb.receivable_bill_code=#{receivableBillCode}
)
</if>
<if test="projectCode != null and projectCode != ''">
and t1.invoice_bill_code in (
select t1.invoice_bill_code from oms_receivable_invoice_detail t1
inner join oms_receivable_bill t2 on t1.receivable_bill_id=t2.id
inner join project_order_info t3 on t2.order_code=t3.order_code
inner join project_info t4 on t3.project_id=t4.id
where t4.project_code = #{projectCode}
)
</if>
<if test="projectName != null and projectName != ''">
and t1.invoice_bill_code in (
select t1.invoice_bill_code from oms_receivable_invoice_detail t1
inner join oms_receivable_bill t2 on t1.receivable_bill_id=t2.id
inner join project_order_info t3 on t2.order_code=t3.order_code
inner join project_info t4 on t3.project_id=t4.id
where t4.project_name like concat('%',#{projectName},'%')
)
</if>
<if test="invoiceType != null and invoiceType != ''">
and t1.invoice_type = #{invoiceType}
</if>
<if test="invoiceBillType != null and invoiceBillType != ''">
and t1.invoice_bill_type = #{invoiceBillType}
</if>
<if test="invoiceTime != null ">
and invoice_time = #{invoiceTime}
</if>
<if test="partnerCode != null and partnerCode != ''">
and t1.partner_code = #{partnerCode}
</if>
<if test="partnerName != null and partnerName != ''">
and t1.partner_name = #{partnerName}
</if>
<if test="totalPriceWithTax != null ">
and total_price_with_tax = #{totalPriceWithTax}
</if>
<if test="totalPriceWithoutTax != null ">
and total_price_without_tax = #{totalPriceWithoutTax}
</if>
<if test="taxRate != null ">
and tax_rate = #{taxRate}
</if>
<if test="createBy != null and createBy != ''">
and create_by = #{createBy}
</if>
<if test="createTime != null ">
and create_time = #{createTime}
</if>
<if test="updateBy != null and updateBy != ''">
and update_by = #{updateBy}
</if>
<if test="updateTime != null ">
and update_time = #{updateTime}
</if>
<if test="remark != null and remark != ''">
and remark = #{remark}
</if>
<if test="delFlag != null and delFlag != ''">
and del_flag = #{delFlag}
</if>
<if test="actualInvoiceTime != null ">
and actual_invoice_time = #{actualInvoiceTime}
</if>
<if test="invoiceStatus != null and invoiceStatus != ''">
and t1.invoice_status = #{invoiceStatus}
</if>
<if test="approveStatus != null and approveStatus != ''">
and t1.approve_status = #{approveStatus}
</if>
<if test="approveNode != null and approveNode != ''">
and t1.invoice_bill_code in
(
select business_key from bu_todo where approve_user_name like concat('%', #{approveNode}, '%') and process_key in (
'finance_invoice_approve','finance_invoice_refound')
)
</if>
<if test="approveTime != null ">
and approve_time = #{approveTime}
</if>
<if test="refundStatus != null and refundStatus != ''">
and refund_status = #{refundStatus}
</if>
<if test="originalBillId != null ">
and original_bill_id = #{originalBillId}
</if>
<if test="buyerName != null and buyerName != ''">
and buyer_name = #{buyerName}
</if>
<if test="buyerCreditCode != null and buyerCreditCode != ''">
and buyer_credit_code = #{buyerCreditCode}
</if>
<if test="buyerBank != null and buyerBank != ''">
and buyer_bank = #{buyerBank}
</if>
<if test="buyerBankAccount != null and buyerBankAccount != ''">
and buyer_bank_account = #{buyerBankAccount}
</if>
<if test="sellerName != null and sellerName != ''">
and seller_name = #{sellerName}
</if>
<if test="sellerCreditCode != null and sellerCreditCode != ''">
and seller_credit_code = #{sellerCreditCode}
</if>
<if test="sellerBank != null and sellerBank != ''">
and seller_bank = #{sellerBank}
</if>
<if test="sellerBankAccount != null and sellerBankAccount != ''">
and seller_bank_account = #{sellerBankAccount}
</if>
<if test="(params.beginApproveTime != null and params.beginApproveTime != '') or (params.endApproveTime != null and params.endApproveTime!='')">
<choose>
<when test="(params.beginApproveTime != null and params.beginApproveTime != '') and (params.endApproveTime != null and params.endApproveTime!='')">
and t1.approve_time between #{params.beginApproveTime} and #{params.endApproveTime}
</when>
<when test="(params.beginApproveTime != null and params.beginApproveTime != '')">
and t1.approve_time <![CDATA[ >= ]]> #{params.beginApproveTime}
</when>
<when test="(params.endApproveTime != null and params.endApproveTime!='')">
and t1.approve_time <![CDATA[ <= ]]> #{params.endApproveTime}
</when>
</choose>
</if>
<if test="(params.beginInvoiceTime != null and params.beginInvoiceTime != '') or (params.endInvoiceTime != null and params.endInvoiceTime!='')">
<choose>
<when test="(params.beginInvoiceTime != null and params.beginInvoiceTime != '') and (params.endInvoiceTime != null and params.endInvoiceTime!='')">
and t1.invoice_time between #{params.beginInvoiceTime} and #{params.endInvoiceTime}
</when>
<when test="(params.beginInvoiceTime != null and params.beginInvoiceTime != '')">
and t1.invoice_time <![CDATA[ >= ]]> #{params.beginInvoiceTime}
</when>
<when test="(params.endInvoiceTime != null and params.endInvoiceTime!='')">
and t1.invoice_time <![CDATA[ <= ]]> #{params.endInvoiceTime}
</when>
</choose>
</if>
</where>
</select>
<select id="selectOmsInvoiceBillById" parameterType="Long" resultMap="OmsInvoiceBillResult">
<include refid="selectOmsInvoiceBillVo"/>
where id = #{id}
</select>
<insert id="insertOmsInvoiceBill" parameterType="com.ruoyi.sip.domain.OmsInvoiceBill" useGeneratedKeys="true" keyProperty="id">
insert into oms_invoice_bill
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="invoiceBillCode != null and invoiceBillCode != ''">
invoice_bill_code,
</if>
<if test="invoiceType != null and invoiceType != ''">
invoice_type,
</if>
<if test="invoiceBillType != null and invoiceBillType != ''">
invoice_bill_type,
</if>
<if test="invoiceTime != null">
invoice_time,
</if>
<if test="partnerCode != null and partnerCode != ''">
partner_code,
</if>
<if test="partnerName != null and partnerName != ''">
partner_name,
</if>
<if test="totalPriceWithTax != null">
total_price_with_tax,
</if>
<if test="totalPriceWithoutTax != null">
total_price_without_tax,
</if>
<if test="invoicePriceWithTax != null">
invoice_price_with_tax,
</if>
<if test="invoicePriceWithoutTax != null">
invoice_price_without_tax,
</if>
<if test="taxRate != null">
tax_rate,
</if>
<if test="createBy != null and createBy != ''">
create_by,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateBy != null and updateBy != ''">
update_by,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="remark != null and remark != ''">
remark,
</if>
<if test="delFlag != null and delFlag != ''">
del_flag,
</if>
<if test="actualInvoiceTime != null">
actual_invoice_time,
</if>
<if test="invoiceStatus != null and invoiceStatus != ''">
invoice_status,
</if>
<if test="approveStatus != null and approveStatus != ''">
approve_status,
</if>
<if test="approveNode != null and approveNode != ''">
approve_node,
</if>
<if test="approveTime != null">
approve_time,
</if>
<if test="refundStatus != null and refundStatus != ''">
refund_status,
</if>
<if test="originalBillId != null">
original_bill_id,
</if>
<if test="buyerName != null and buyerName != ''">
buyer_name,
</if>
<if test="buyerCreditCode != null and buyerCreditCode != ''">
buyer_credit_code,
</if>
<if test="buyerBank != null and buyerBank != ''">
buyer_bank,
</if>
<if test="buyerBankAccount != null and buyerBankAccount != ''">
buyer_bank_account,
</if>
<if test="sellerName != null and sellerName != ''">
seller_name,
</if>
<if test="sellerCreditCode != null and sellerCreditCode != ''">
seller_credit_code,
</if>
<if test="sellerBank != null and sellerBank != ''">
seller_bank,
</if>
<if test="sellerBankAccount != null and sellerBankAccount != ''">
seller_bank_account,
</if>
<if test="invoiceApplyUser != null and invoiceApplyUser != ''">
invoice_apply_user,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="invoiceBillCode != null and invoiceBillCode != ''">
#{invoiceBillCode},
</if>
<if test="invoiceType != null and invoiceType != ''">
#{invoiceType},
</if>
<if test="invoiceBillType != null and invoiceBillType != ''">
#{invoiceBillType},
</if>
<if test="invoiceTime != null">
#{invoiceTime},
</if>
<if test="partnerCode != null and partnerCode != ''">
#{partnerCode},
</if>
<if test="partnerName != null and partnerName != ''">
#{partnerName},
</if>
<if test="totalPriceWithTax != null">
#{totalPriceWithTax},
</if>
<if test="totalPriceWithoutTax != null">
#{totalPriceWithoutTax},
</if>
<if test="invoicePriceWithTax != null">
#{invoicePriceWithTax},
</if>
<if test="invoicePriceWithoutTax != null">
#{invoicePriceWithoutTax},
</if>
<if test="taxRate != null">
#{taxRate},
</if>
<if test="createBy != null and createBy != ''">
#{createBy},
</if>
<if test="createTime != null">
#{createTime},
</if>
<if test="updateBy != null and updateBy != ''">
#{updateBy},
</if>
<if test="updateTime != null">
#{updateTime},
</if>
<if test="remark != null and remark != ''">
#{remark},
</if>
<if test="delFlag != null and delFlag != ''">
#{delFlag},
</if>
<if test="actualInvoiceTime != null">
#{actualInvoiceTime},
</if>
<if test="invoiceStatus != null and invoiceStatus != ''">
#{invoiceStatus},
</if>
<if test="approveStatus != null and approveStatus != ''">
#{approveStatus},
</if>
<if test="approveNode != null and approveNode != ''">
#{approveNode},
</if>
<if test="approveTime != null">
#{approveTime},
</if>
<if test="refundStatus != null and refundStatus != ''">
#{refundStatus},
</if>
<if test="originalBillId != null">
#{originalBillId},
</if>
<if test="buyerName != null and buyerName != ''">
#{buyerName},
</if>
<if test="buyerCreditCode != null and buyerCreditCode != ''">
#{buyerCreditCode},
</if>
<if test="buyerBank != null and buyerBank != ''">
#{buyerBank},
</if>
<if test="buyerBankAccount != null and buyerBankAccount != ''">
#{buyerBankAccount},
</if>
<if test="sellerName != null and sellerName != ''">
#{sellerName},
</if>
<if test="sellerCreditCode != null and sellerCreditCode != ''">
#{sellerCreditCode},
</if>
<if test="sellerBank != null and sellerBank != ''">
#{sellerBank},
</if>
<if test="sellerBankAccount != null and sellerBankAccount != ''">
#{sellerBankAccount},
</if>
<if test="invoiceApplyUser != null and invoiceApplyUser != ''">
#{invoiceApplyUser},
</if>
</trim>
</insert>
<update id="updateOmsInvoiceBill" parameterType="com.ruoyi.sip.domain.OmsInvoiceBill">
update oms_invoice_bill
<trim prefix="SET" suffixOverrides=",">
<if test="invoiceBillCode != null and invoiceBillCode != ''">
invoice_bill_code = #{invoiceBillCode},
</if>
<if test="invoiceType != null and invoiceType != ''">
invoice_type = #{invoiceType},
</if>
<if test="invoiceBillType != null and invoiceBillType != ''">
invoice_bill_type = #{invoiceBillType},
</if>
<if test="invoiceTime != null">
invoice_time = #{invoiceTime},
</if>
<if test="partnerCode != null and partnerCode != ''">
partner_code = #{partnerCode},
</if>
<if test="totalPriceWithTax != null">
total_price_with_tax = #{totalPriceWithTax},
</if>
<if test="totalPriceWithoutTax != null">
total_price_without_tax = #{totalPriceWithoutTax},
</if>
<if test="invoicePriceWithTax != null">
invoice_price_with_tax = #{invoicePriceWithTax},
</if>
<if test="invoicePriceWithoutTax != null">
invoice_price_without_tax = #{invoicePriceWithoutTax},
</if>
<if test="taxRate != null">
tax_rate = #{taxRate},
</if>
<if test="createBy != null and createBy != ''">
create_by = #{createBy},
</if>
<if test="createTime != null">
create_time = #{createTime},
</if>
<if test="updateBy != null and updateBy != ''">
update_by = #{updateBy},
</if>
<if test="remark != null and remark != ''">
remark = #{remark},
</if>
<if test="delFlag != null and delFlag != ''">
del_flag = #{delFlag},
</if>
<if test="actualInvoiceTime != null">
actual_invoice_time = #{actualInvoiceTime},
</if>
<if test="invoiceStatus != null and invoiceStatus != ''">
invoice_status = #{invoiceStatus},
</if>
<if test="approveStatus != null and approveStatus != ''">
approve_status = #{approveStatus},
</if>
<if test="approveNode != null and approveNode != ''">
approve_node = #{approveNode},
</if>
<if test="approveTime != null">
approve_time = #{approveTime},
</if>
<if test="refundStatus != null and refundStatus != ''">
refund_status = #{refundStatus},
</if>
<if test="originalBillId != null">
original_bill_id = #{originalBillId},
</if>
<if test="buyerName != null and buyerName != ''">
buyer_name = #{buyerName},
</if>
<if test="buyerCreditCode != null and buyerCreditCode != ''">
buyer_credit_code = #{buyerCreditCode},
</if>
<if test="buyerBank != null and buyerBank != ''">
buyer_bank = #{buyerBank},
</if>
<if test="buyerBankAccount != null and buyerBankAccount != ''">
buyer_bank_account = #{buyerBankAccount},
</if>
<if test="sellerName != null and sellerName != ''">
seller_name = #{sellerName},
</if>
<if test="sellerCreditCode != null and sellerCreditCode != ''">
seller_credit_code = #{sellerCreditCode},
</if>
<if test="sellerBank != null and sellerBank != ''">
seller_bank = #{sellerBank},
</if>
<if test="sellerBankAccount != null and sellerBankAccount != ''">
seller_bank_account = #{sellerBankAccount},
</if>
<if test="invoiceApplyUser != null and invoiceApplyUser != ''">
invoice_apply_user = #{invoiceApplyUser},
</if>
update_time = now()
</trim>
where id = #{id}
</update>
<update id="updateOmsInvoiceBillByCode" parameterType="com.ruoyi.sip.domain.OmsInvoiceBill">
update oms_invoice_bill
<trim prefix="SET" suffixOverrides=",">
<if test="invoiceStatus != null and invoiceStatus != ''">
invoice_status = #{invoiceStatus},
</if>
<if test="approveStatus != null and approveStatus != ''">
approve_status = #{approveStatus},
</if>
<if test="approveNode != null and approveNode != ''">
approve_node = #{approveNode},
</if>
<if test="approveTime != null">
approve_time = #{approveTime},
</if>
<if test="actualInvoiceTime != null">
actual_invoice_time = #{actualInvoiceTime},
</if>
<if test="refundStatus != null and refundStatus != ''">
refund_status = #{refundStatus},
</if>
update_time = now()
</trim>
where invoice_bill_code = #{invoiceBillCode}
</update>
<update id="applyInvoice">
update oms_invoice_bill
set buyer_name = #{buyerName},
buyer_credit_code = #{buyerCreditCode},
buyer_bank = #{buyerBank},
buyer_bank_account = #{buyerBankAccount},
seller_name = #{sellerName},
seller_credit_code = #{sellerCreditCode},
seller_bank = #{sellerBank},
seller_bank_account = #{sellerBankAccount},
approve_status=#{approveStatus},
invoice_type=#{invoiceType},
remark=#{remark},
update_time=now()
where invoice_bill_code = #{invoiceBillCode}
</update>
<update id="clearApprove">
update oms_invoice_bill
set approve_status=#{approveStatus},
approve_time=null,
update_time=now()
where id = #{id}
</update>
<update id="updateReturnWriteOffBatch">
<foreach collection="list" item="item" separator=";">
update oms_invoice_bill
set
invoice_status=#{item.invoiceStatus},
approve_status=#{item.approveStatus},
approve_time=null,
actual_invoice_time=null,
update_time=now()
where id = #{item.id}
</foreach>
</update>
<delete id="deleteOmsInvoiceBillById" parameterType="Long">
delete from oms_invoice_bill where id = #{id}
</delete>
<delete id="deleteOmsInvoiceBillByIds" parameterType="String">
delete from oms_invoice_bill where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<delete id="clearRelationReceivable">
delete from oms_receivable_invoice_detail where invoice_bill_code=#{code}
</delete>
<select id="listApprove" resultType="com.ruoyi.sip.domain.OmsInvoiceBill">
select t1.*
${flowRelationDto.querySql}
from oms_invoice_bill t1
${flowRelationDto.joinSql}
where 1=1
<if test="entity.invoiceBillCode != null and entity.invoiceBillCode != ''">
and t1.invoice_bill_code = #{entity.invoiceBillCode}
</if>
<if test="entity.partnerName != null and entity.partnerName != ''">
and t1.partner_name like concat('%',#{entity.partnerName},'%')
</if>
<if test="entity.projectName != null and entity.projectName != ''">
and t1.invoice_bill_code in (
select t1.receipt_bill_code from oms_receivable_invoice_detail t1
inner join oms_receivable_bill t2 on t1.receivable_bill_id=t2.id
inner join project_order_info t3 on t2.order_code=t3.order_code
inner join project_info t4 on t3.project_id=t4.id
where t4.project_name like concat('%',#{entity.projectName},'%')
)
</if>
<if test="(entity.params.beginApplyTime != null and entity.params.beginApplyTime != '') or (entity.params.endApplyTime != null and entity.params.endApplyTime!='')">
<choose>
<when test="(entity.params.beginApplyTime != null and entity.params.beginApplyTime != '') and (entity.params.endApplyTime != null and entity.params.endApplyTime!='')">
and flow.apply_time between #{entity.params.beginApplyTime} and #{entity.params.endApplyTime}
</when>
<when test="(entity.params.beginApplyTime != null and entity.params.beginApplyTime != '')">
and flow.apply_time <![CDATA[ >= ]]> #{entity.params.beginApplyTime}
</when>
<when test="(entity.params.endApplyTime != null and entity.params.endApplyTime!='')">
and flow.apply_time <![CDATA[ <= ]]> #{entity.params.endApplyTime}
</when>
</choose>
</if>
order by t1.create_time desc
</select>
<select id="selectOmsInvoiceBillByCode" resultType="com.ruoyi.sip.domain.OmsInvoiceBill">
<include refid="selectOmsInvoiceBillVo"/>
where invoice_bill_code = #{invoiceBillCode}
</select>
<select id="selectMaxCodeByPrefix" resultType="java.lang.Integer">
select ifnull(max(SUBSTR(invoice_bill_code FROM LENGTH(#{codePrefix}) + 1 FOR 4)), 0)
from oms_invoice_bill
where invoice_bill_code LIKE CONCAT(#{codePrefix}, '%')
</select>
</mapper>