emis-service/emis-biz/src/main/resources/mapper/EmisSettleInvoiceRelMapper.xml
2024-09-24 10:24:12 +08:00

178 lines
9.3 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.EmisSettleInvoiceRelMapper">
<resultMap type="EmisSettleInvoiceRel" id="EmisSettleInvoiceRelResult" extends="com.xdadan.erp.emis.mapper.EmisBaseMapper.EmisBaseResult">
<result property="id" column="id" />
<result property="applySeqNo" column="apply_seq_no" />
<result property="payId" column="pay_id" />
<result property="billNo" column="bill_no" />
<result property="money" column="money" />
</resultMap>
<resultMap id="EmisSettleInvoiceRelWithSubBillResult" type="EmisSettleInvoiceRel" extends="EmisSettleInvoiceRelResult" >
<association property="waybillDetail"
column="bill_no"
select="com.xdadan.erp.emis.mapper.EmisWaybillMapper.selectWaybillBaseInfoByBillCode"
fetchType="lazy"
/>
</resultMap>
<sql id="selectEmisSettleInvoiceRelVo">
select id, apply_seq_no, pay_id, bill_no, money, del_flag, create_by, create_time, update_by, update_time, create_site, update_site from emis_settle_invoice_rel
</sql>
<select id="selectEmisSettleInvoiceRelList" parameterType="EmisSettleInvoiceRel" resultMap="EmisSettleInvoiceRelWithSubBillResult">
<include refid="selectEmisSettleInvoiceRelVo"/>
<where>
del_flag='0'
<if test="id != null "> and id = #{id}</if>
<if test="applySeqNo != null and applySeqNo != ''"> and apply_seq_no=#{applySeqNo}</if>
<if test="payId != null and payId != ''"> and pay_id like concat('%', #{payId}, '%')</if>
<if test="billNo != null and billNo != ''"> and bill_no like concat('%', #{billNo}, '%')</if>
<if test="money != null "> and money = #{money}</if>
<if test="delFlag != null and delFlag != ''"> and del_flag like concat('%', #{delFlag}, '%')</if>
<if test="createBy != null and createBy != ''"> and create_by like concat('%', #{createBy}, '%')</if>
<if test="createTime != null "> and create_time = #{createTime}</if>
<if test="updateBy != null and updateBy != ''"> and update_by like concat('%', #{updateBy}, '%')</if>
<if test="updateTime != null "> and update_time = #{updateTime}</if>
<if test="createSite != null and createSite != ''"> and create_site like concat('%', #{createSite}, '%')</if>
<if test="updateSite != null and updateSite != ''"> and update_site like concat('%', #{updateSite}, '%')</if>
</where>
order by create_time desc
</select>
<select id="checkUnique" parameterType="EmisSettleInvoiceRel" resultType="int">
select count(1) from emis_settle_invoice_rel
where del_flag='0'
and id = #{id}
and apply_seq_no = #{applySeqNo}
and pay_id = #{payId}
and bill_no = #{billNo}
and money = #{money}
and del_flag = #{delFlag}
and create_by = #{createBy}
and create_time = #{createTime}
and update_by = #{updateBy}
and update_time = #{updateTime}
and create_site = #{createSite}
and update_site = #{updateSite}
limit 1
</select>
<select id="selectEmisSettleInvoiceRelById" parameterType="Long" resultMap="EmisSettleInvoiceRelResult">
select id, apply_seq_no, pay_id, bill_no, money, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
from emis_settle_invoice_rel a
where a.id = #{id}
</select>
<select id="selectListByApplySeqNo" parameterType="String" resultMap="EmisSettleInvoiceRelWithSubBillResult">
select id, apply_seq_no, pay_id, bill_no, money, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
from emis_settle_invoice_rel a
where a.apply_seq_no = #{applySeqNo} and del_flag='0'
</select>
<select id="selectHasOpenListBySettleBillNo" parameterType="String" resultMap="EmisSettleInvoiceRelWithSubBillResult">
select id, apply_seq_no, pay_id, bill_no, money, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
from emis_settle_invoice_rel a
where del_flag='0'
AND apply_seq_no IN (
SELECT x1.apply_seq_no FROM
emis_settle_invoice_record x1,
emis_settle_bill x2
WHERE
x1.del_flag = '0' and x1.bl_audit!='2'
AND x2.del_flag = '0'
AND FIND_IN_SET( x2.settle_bill_no, x1.settle_bill_no )
AND FIND_IN_SET( x2.settle_bill_no, #{settleBillNo})
)
AND a.bill_no IN (
select essb.bill_no from emis_settle_sub_bill essb where essb.del_flag='0' and FIND_IN_SET( essb.settle_bill_no, #{settleBillNo})
)
</select>
<select id="selectHasOpenInvoiceMapList" parameterType="String" resultType="map">
select bill_no as billNo, sum(money) sumMoney
from emis_settle_invoice_rel a
where del_flag='0'
AND apply_seq_no IN (
SELECT x1.apply_seq_no FROM
emis_settle_invoice_record x1,
emis_settle_bill x2
WHERE
x1.del_flag = '0' and x1.bl_audit!='2'
AND x2.del_flag = '0'
AND FIND_IN_SET( x2.settle_bill_no, x1.settle_bill_no )
AND FIND_IN_SET( x2.settle_bill_no, #{settleBillNo})
)
AND a.bill_no IN (
select essb.bill_no from emis_settle_sub_bill essb where essb.del_flag='0' and FIND_IN_SET( essb.settle_bill_no, #{settleBillNo})
)
group by bill_no
</select>
<insert id="insertEmisSettleInvoiceRel" parameterType="EmisSettleInvoiceRel" useGeneratedKeys="true" keyProperty="id">
insert into emis_settle_invoice_rel
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="applySeqNo != null and applySeqNo != ''">apply_seq_no,</if>
<if test="payId != null and payId != ''">pay_id,</if>
<if test="billNo != null and billNo != ''">bill_no,</if>
<if test="money != null">money,</if>
<if test="delFlag != null and delFlag != ''">del_flag,</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="createSite != null and createSite != ''">create_site,</if>
<if test="updateSite != null and updateSite != ''">update_site,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="applySeqNo != null and applySeqNo != ''">#{applySeqNo},</if>
<if test="payId != null and payId != ''">#{payId},</if>
<if test="billNo != null and billNo != ''">#{billNo},</if>
<if test="money != null">#{money},</if>
<if test="delFlag != null and delFlag != ''">#{delFlag},</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="createSite != null and createSite != ''">#{createSite},</if>
<if test="updateSite != null and updateSite != ''">#{updateSite},</if>
</trim>
</insert>
<update id="updateEmisSettleInvoiceRel" parameterType="EmisSettleInvoiceRel">
update emis_settle_invoice_rel
<trim prefix="SET" suffixOverrides=",">
<if test="applySeqNo != null and applySeqNo != ''">apply_seq_no = #{applySeqNo},</if>
<if test="payId != null and payId != ''">pay_id = #{payId},</if>
<if test="billNo != null and billNo != ''">bill_no = #{billNo},</if>
<if test="money != null">money = #{money},</if>
<if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</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="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>
</trim>
where id = #{id}
</update>
<delete id="deleteEmisSettleInvoiceRelById" parameterType="Long">
delete from emis_settle_invoice_rel where id = #{id}
</delete>
<delete id="deleteEmisSettleInvoiceRelByIds" parameterType="String">
delete from emis_settle_invoice_rel where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>