327 lines
19 KiB
XML
327 lines
19 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.xdadan.erp.emis.mapper.EmisInvoiceCancellationMapper">
|
|
|
|
<resultMap type="com.xdadan.erp.emis.domain.EmisInvoiceCancellation" id="EmisInvoiceCancellationResult"
|
|
extends="com.xdadan.erp.emis.mapper.EmisBaseMapper.EmisBaseResult">
|
|
<id property="id" column="id"/>
|
|
<result property="invoiceId" column="invoice_id"/>
|
|
<result property="applySeqNo" column="apply_seq_no"/>
|
|
<result property="applyDate" column="apply_date"/>
|
|
<result property="applyReason" column="apply_reason"/>
|
|
<result property="applyTextUrl" column="apply_text_url"/>
|
|
<result property="applyManCode" column="apply_man_code"/>
|
|
<result property="applySiteCode" column="apply_site_code"/>
|
|
<result property="auditStatus" column="audit_status"/>
|
|
<result property="auditDate" column="audit_date"/>
|
|
<result property="auditManCode" column="audit_man_code"/>
|
|
<result property="auditSiteCode" column="audit_site_code"/>
|
|
<result property="auditRejectReason" column="audit_reject_reason"/>
|
|
<result property="billMonth" column="bill_month"/>
|
|
<result property="custNo" column="cust_no"/>
|
|
<result property="customerName" column="customer_name"/>
|
|
|
|
<association property="applyManName" column="apply_man_code"
|
|
select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectEmpNameByCode"/>
|
|
<association property="applySiteName" column="apply_site_code"
|
|
select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectSiteNameByCode"/>
|
|
<association property="auditManName" column="audit_man_code"
|
|
select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectEmpNameByCode"/>
|
|
<association property="auditSiteName" column="audit_site_code"
|
|
select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectSiteNameByCode"/>
|
|
|
|
<association property="emisSettleInvoiceRecord" javaType="com.xdadan.erp.emis.domain.EmisSettleInvoiceRecord">
|
|
<id property="id" column="inv_id"/>
|
|
<result property="applySeqNo" column="inv_apply_seq_no"/>
|
|
<result property="applyDate" column="inv_apply_date"/>
|
|
<result property="customerCode" column="inv_customer_code"/>
|
|
<result property="customerName" column="inv_customer_name"/>
|
|
<result property="settleBillNo" column="inv_settle_bill_no"/>
|
|
<result property="settleBillName" column="inv_settle_bill_name"/>
|
|
<result property="applyMoney" column="inv_apply_money"/>
|
|
<result property="addTaxRate" column="inv_add_tax_rate"/>
|
|
<result property="addOpenMoney" column="inv_add_open_money"/>
|
|
<result property="recedMoney" column="inv_reced_money"/>
|
|
<result property="companyName" column="inv_company_name"/>
|
|
<result property="companyTaxNo" column="inv_company_tax_no"/>
|
|
<result property="invoiceNo" column="inv_invoice_no"/>
|
|
<result property="invoiceStatus" column="inv_invoice_status"/>
|
|
<result property="paymentStatus" column="inv_payment_status"/>
|
|
</association>
|
|
</resultMap>
|
|
|
|
<sql id="selectEmisInvoiceCancellationVo">
|
|
select c.id, c.invoice_id, c.apply_seq_no, c.apply_date, c.apply_reason, c.apply_text_url,
|
|
c.apply_man_code, c.apply_site_code, c.audit_status, c.audit_date, c.audit_man_code, c.audit_site_code,
|
|
c.audit_reject_reason, c.remark, c.del_flag, c.create_by, c.create_time, c.update_by,
|
|
c.update_time, c.create_site, c.update_site,
|
|
i.id as inv_id, i.apply_seq_no as inv_apply_seq_no, i.apply_date as inv_apply_date,
|
|
i.customer_code as inv_customer_code, i.customer_name as inv_customer_name,
|
|
i.settle_bill_no as inv_settle_bill_no, i.settle_bill_name as inv_settle_bill_name,
|
|
i.apply_money as inv_apply_money, i.add_tax_rate as inv_add_tax_rate, i.add_open_money as inv_add_open_money,
|
|
i.reced_money as inv_reced_money, i.company_name as inv_company_name, i.company_tax_no as inv_company_tax_no,
|
|
i.invoice_no as inv_invoice_no, i.invoice_status as inv_invoice_status, i.payment_status as inv_payment_status,
|
|
GROUP_CONCAT(DISTINCT b.bill_month ORDER BY b.bill_month SEPARATOR ',') as bill_month,
|
|
GROUP_CONCAT(DISTINCT b.cust_no ORDER BY b.cust_no SEPARATOR ',') as cust_no,
|
|
GROUP_CONCAT(DISTINCT b.cust_name ORDER BY b.cust_name SEPARATOR ',') as customer_name
|
|
from emis_invoice_cancellation c
|
|
left join emis_settle_invoice_record i on c.invoice_id = i.id and i.del_flag = '0'
|
|
left join emis_settle_invoice_bill_rel rel on i.apply_seq_no = rel.apply_seq_no and rel.del_flag = '0'
|
|
left join emis_settle_bill b on rel.settle_bill_no = b.settle_bill_no and b.del_flag = '0'
|
|
</sql>
|
|
|
|
<select id="selectEmisInvoiceCancellationList" parameterType="EmisInvoiceCancellation"
|
|
resultMap="EmisInvoiceCancellationResult">
|
|
<include refid="selectEmisInvoiceCancellationVo"/>
|
|
<where>
|
|
c.del_flag = '0'
|
|
<if test="id != null"> and c.id = #{id}</if>
|
|
<if test="invoiceId != null"> and c.invoice_id = #{invoiceId}</if>
|
|
<if test="applySeqNo != null and applySeqNo != ''"> and c.apply_seq_no = #{applySeqNo}</if>
|
|
<if test="applyReason != null and applyReason != ''"> and c.apply_reason like concat('%', #{applyReason}, '%')</if>
|
|
<if test="applyManCode != null and applyManCode != ''"> and c.apply_man_code = #{applyManCode}</if>
|
|
<if test="applySiteCode != null and applySiteCode != ''"> and c.apply_site_code = #{applySiteCode}</if>
|
|
<if test="auditStatus != null and auditStatus != ''"> and c.audit_status = #{auditStatus}</if>
|
|
<if test="auditManCode != null and auditManCode != ''"> and c.audit_man_code = #{auditManCode}</if>
|
|
<if test="auditSiteCode != null and auditSiteCode != ''"> and c.audit_site_code = #{auditSiteCode}</if>
|
|
<if test="params.beginApplyDate != null and params.beginApplyDate != ''">
|
|
and c.apply_date <![CDATA[ >= ]]> #{params.beginApplyDate}
|
|
</if>
|
|
<if test="params.endApplyDate != null and params.endApplyDate != ''">
|
|
and c.apply_date <![CDATA[ <= ]]> #{params.endApplyDate}
|
|
</if>
|
|
<if test="params.beginAuditDate != null and params.beginAuditDate != ''">
|
|
and c.audit_date <![CDATA[ >= ]]> #{params.beginAuditDate}
|
|
</if>
|
|
<if test="params.endAuditDate != null and params.endAuditDate != ''">
|
|
and c.audit_date <![CDATA[ <= ]]> #{params.endAuditDate}
|
|
</if>
|
|
<if test="params.settleBillNo != null and params.settleBillNo != ''">
|
|
and find_in_set(i.settle_bill_no, #{params.settleBillNo})
|
|
</if>
|
|
<if test="params.invoiceNo != null and params.invoiceNo != ''">
|
|
and find_in_set(i.invoice_no, #{params.invoiceNo})
|
|
</if>
|
|
<if test="params.applySeqNo != null and params.applySeqNo != ''">
|
|
and find_in_set(i.apply_seq_no, #{params.applySeqNo})
|
|
</if>
|
|
<if test="params.billCode != null and params.billCode != ''">
|
|
and exists(select 1 from emis_settle_invoice_rel rel
|
|
where rel.del_flag='0' and rel.apply_seq_no = i.apply_seq_no
|
|
and find_in_set(rel.bill_no, #{params.billCode}))
|
|
</if>
|
|
<if test="params.salesmen != null and params.salesmen != ''">
|
|
and exists(select 1
|
|
from emis_settle_invoice_bill_rel rel
|
|
join emis_settle_bill b on rel.settle_bill_no = b.settle_bill_no
|
|
where rel.del_flag = '0'
|
|
and b.del_flag = '0'
|
|
and rel.apply_seq_no = i.apply_seq_no
|
|
and b.salesmen = #{params.salesmen})
|
|
</if>
|
|
<if test="params.payee != null and params.payee != ''">
|
|
and exists(select 1
|
|
from emis_settle_invoice_bill_rel rel
|
|
join emis_settle_bill b on rel.settle_bill_no = b.settle_bill_no
|
|
where rel.del_flag = '0'
|
|
and b.del_flag = '0'
|
|
and rel.apply_seq_no = i.apply_seq_no
|
|
and b.payee = #{params.payee})
|
|
</if>
|
|
<if test="params.custNo != null and params.custNo != ''">
|
|
and exists(select 1
|
|
from emis_settle_invoice_bill_rel rel
|
|
join emis_settle_bill b on rel.settle_bill_no = b.settle_bill_no
|
|
where rel.del_flag = '0'
|
|
and b.del_flag = '0'
|
|
and rel.apply_seq_no = i.apply_seq_no
|
|
and b.cust_no = #{params.custNo})
|
|
</if>
|
|
<if test="params.privSiteCode != null and params.privSiteCode != '88888'">
|
|
|
|
and EXISTS(
|
|
select 1 from emis_settle_bill x2,emis_settle_invoice_bill_rel x3
|
|
where x2.del_flag = '0' and x3.del_flag = '0'
|
|
and i.apply_seq_no=x3.apply_seq_no and x2.settle_bill_no=x3.settle_bill_no
|
|
AND (
|
|
x2.salesmen = #{params.privEmpName}
|
|
OR x2.payee = #{params.privEmpName}
|
|
OR x2.salesmen IN (
|
|
SELECT salesmen
|
|
FROM emis_salesmen_rel esr
|
|
where esr.del_flag='0' and esr.bl_open='1'
|
|
and now() <![CDATA[ >= ]]> esr.start_date and now() <![CDATA[ <= ]]> esr.end_date
|
|
and esr.sales_ass = #{params.privEmpName}
|
|
)
|
|
)
|
|
)
|
|
|
|
</if>
|
|
</where>
|
|
group by c.id, c.invoice_id, c.apply_seq_no, c.apply_date, c.apply_reason, c.apply_text_url,
|
|
c.apply_man_code, c.apply_site_code, c.audit_status, c.audit_date, c.audit_man_code, c.audit_site_code,
|
|
c.audit_reject_reason, c.remark, c.del_flag, c.create_by, c.create_time, c.update_by,
|
|
c.update_time, c.create_site, c.update_site,
|
|
i.id, i.apply_seq_no, i.apply_date, i.customer_code, i.customer_name,
|
|
i.settle_bill_no, i.settle_bill_name, i.apply_money, i.add_tax_rate, i.add_open_money,
|
|
i.reced_money, i.company_name, i.company_tax_no, i.invoice_no, i.invoice_status, i.payment_status
|
|
order by c.apply_date desc, c.id desc
|
|
</select>
|
|
|
|
<select id="selectEmisInvoiceCancellationById" parameterType="Long"
|
|
resultMap="EmisInvoiceCancellationResult">
|
|
<include refid="selectEmisInvoiceCancellationVo"/>
|
|
where c.del_flag = '0' and c.id = #{id}
|
|
group by c.id, c.invoice_id, c.apply_seq_no, c.apply_date, c.apply_reason, c.apply_text_url,
|
|
c.apply_man_code, c.apply_site_code, c.audit_status, c.audit_date, c.audit_man_code, c.audit_site_code,
|
|
c.audit_reject_reason, c.remark, c.del_flag, c.create_by, c.create_time, c.update_by,
|
|
c.update_time, c.create_site, c.update_site,
|
|
i.id, i.apply_seq_no, i.apply_date, i.customer_code, i.customer_name,
|
|
i.settle_bill_no, i.settle_bill_name, i.apply_money, i.add_tax_rate, i.add_open_money,
|
|
i.reced_money, i.company_name, i.company_tax_no, i.invoice_no, i.invoice_status, i.payment_status
|
|
</select>
|
|
|
|
<insert id="insertEmisInvoiceCancellation" parameterType="EmisInvoiceCancellation" useGeneratedKeys="true"
|
|
keyProperty="id">
|
|
insert into emis_invoice_cancellation
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="invoiceId != null">invoice_id,</if>
|
|
<if test="applySeqNo != null and applySeqNo != ''">apply_seq_no,</if>
|
|
<if test="applyDate != null">apply_date,</if>
|
|
<if test="applyReason != null and applyReason != ''">apply_reason,</if>
|
|
<if test="applyTextUrl != null and applyTextUrl != ''">apply_text_url,</if>
|
|
<if test="applyManCode != null and applyManCode != ''">apply_man_code,</if>
|
|
<if test="applySiteCode != null and applySiteCode != ''">apply_site_code,</if>
|
|
<if test="auditStatus != null and auditStatus != ''">audit_status,</if>
|
|
<if test="auditDate != null">audit_date,</if>
|
|
<if test="auditManCode != null and auditManCode != ''">audit_man_code,</if>
|
|
<if test="auditSiteCode != null and auditSiteCode != ''">audit_site_code,</if>
|
|
<if test="auditRejectReason != null and auditRejectReason != ''">audit_reject_reason,</if>
|
|
<if test="remark != null and remark != ''">remark,</if>
|
|
del_flag,
|
|
<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="createSite != null and createSite != ''">create_site,</if>
|
|
<if test="updateSite != null and updateSite != ''">update_site,</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="invoiceId != null">#{invoiceId},</if>
|
|
<if test="applySeqNo != null and applySeqNo != ''">#{applySeqNo},</if>
|
|
<if test="applyDate != null">#{applyDate},</if>
|
|
<if test="applyReason != null and applyReason != ''">#{applyReason},</if>
|
|
<if test="applyTextUrl != null and applyTextUrl != ''">#{applyTextUrl},</if>
|
|
<if test="applyManCode != null and applyManCode != ''">#{applyManCode},</if>
|
|
<if test="applySiteCode != null and applySiteCode != ''">#{applySiteCode},</if>
|
|
<if test="auditStatus != null and auditStatus != ''">#{auditStatus},</if>
|
|
<if test="auditDate != null">#{auditDate},</if>
|
|
<if test="auditManCode != null and auditManCode != ''">#{auditManCode},</if>
|
|
<if test="auditSiteCode != null and auditSiteCode != ''">#{auditSiteCode},</if>
|
|
<if test="auditRejectReason != null and auditRejectReason != ''">#{auditRejectReason},</if>
|
|
<if test="remark != null and remark != ''">#{remark},</if>
|
|
'0',
|
|
<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="createSite != null and createSite != ''">#{createSite},</if>
|
|
<if test="updateSite != null and updateSite != ''">#{updateSite},</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<update id="updateEmisInvoiceCancellation" parameterType="EmisInvoiceCancellation">
|
|
update emis_invoice_cancellation
|
|
<set>
|
|
<if test="invoiceId != null">invoice_id = #{invoiceId},</if>
|
|
<if test="applySeqNo != null and applySeqNo != ''">apply_seq_no = #{applySeqNo},</if>
|
|
<if test="applyDate != null">apply_date = #{applyDate},</if>
|
|
<if test="applyReason != null and applyReason != ''">apply_reason = #{applyReason},</if>
|
|
<if test="applyTextUrl != null and applyTextUrl != ''">apply_text_url = #{applyTextUrl},</if>
|
|
<if test="applyManCode != null and applyManCode != ''">apply_man_code = #{applyManCode},</if>
|
|
<if test="applySiteCode != null and applySiteCode != ''">apply_site_code = #{applySiteCode},</if>
|
|
<if test="auditStatus != null and auditStatus != ''">audit_status = #{auditStatus},</if>
|
|
<if test="auditDate != null">audit_date = #{auditDate},</if>
|
|
<if test="auditManCode != null and auditManCode != ''">audit_man_code = #{auditManCode},</if>
|
|
<if test="auditSiteCode != null and auditSiteCode != ''">audit_site_code = #{auditSiteCode},</if>
|
|
<if test="auditRejectReason != null and auditRejectReason != ''">audit_reject_reason = #{auditRejectReason},</if>
|
|
<if test="remark != null and remark != ''">remark = #{remark},</if>
|
|
<if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
|
|
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
<if test="createSite != null and createSite != ''">create_site = #{createSite},</if>
|
|
<if test="updateSite != null and updateSite != ''">update_site = #{updateSite},</if>
|
|
</set>
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<delete id="deleteEmisInvoiceCancellationById" parameterType="Long">
|
|
update emis_invoice_cancellation set del_flag = '2' where id = #{id}
|
|
</delete>
|
|
|
|
<delete id="deleteEmisInvoiceCancellationByIds" parameterType="Long">
|
|
update emis_invoice_cancellation set del_flag = '2'
|
|
where id in
|
|
<foreach item="item" index="index" collection="array" open="(" separator="," close=")">
|
|
#{item}
|
|
</foreach>
|
|
</delete>
|
|
|
|
<update id="cancelApply">
|
|
update emis_invoice_cancellation
|
|
set audit_status = '3',
|
|
update_by = #{updateBy},
|
|
update_site = #{updateSite},
|
|
update_time = now()
|
|
where del_flag = '0'
|
|
and id in
|
|
<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
|
|
#{item}
|
|
</foreach>
|
|
</update>
|
|
|
|
<update id="auditPass">
|
|
update emis_invoice_cancellation
|
|
set audit_status = '1',
|
|
audit_date = now(),
|
|
audit_man_code = #{auditManCode},
|
|
audit_site_code = #{auditSiteCode},
|
|
update_by = #{auditManCode},
|
|
update_site = #{auditSiteCode},
|
|
update_time = now()
|
|
where del_flag = '0'
|
|
and id in
|
|
<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
|
|
#{item}
|
|
</foreach>
|
|
</update>
|
|
|
|
<update id="auditReject">
|
|
update emis_invoice_cancellation
|
|
set audit_status = '2',
|
|
audit_reject_reason = #{auditRejectReason},
|
|
audit_date = now(),
|
|
audit_man_code = #{auditManCode},
|
|
audit_site_code = #{auditSiteCode},
|
|
update_by = #{auditManCode},
|
|
update_site = #{auditSiteCode},
|
|
update_time = now()
|
|
where del_flag = '0'
|
|
and id in
|
|
<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
|
|
#{item}
|
|
</foreach>
|
|
</update>
|
|
|
|
<select id="countActiveApply" resultType="int">
|
|
select count(1)
|
|
from emis_invoice_cancellation
|
|
where del_flag = '0'
|
|
and audit_status in ('0','1')
|
|
and invoice_id = #{invoiceId}
|
|
</select>
|
|
|
|
</mapper>
|