101 lines
5.3 KiB
XML
101 lines
5.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.bms.ar.mapper.ArBalanceWriteoffMapper">
|
|
|
|
<resultMap id="ArBalanceWriteoffResult" type="ArBalanceWriteoff">
|
|
<id property="writeoffId" column="writeoff_id"/>
|
|
<result property="writeoffNo" column="writeoff_no"/>
|
|
<result property="arBillId" column="ar_bill_id"/>
|
|
<result property="billNo" column="bill_no"/>
|
|
<result property="customerId" column="customer_id"/>
|
|
<result property="receiptId" column="receipt_id"/>
|
|
<result property="accountId" column="account_id"/>
|
|
<result property="currency" column="currency"/>
|
|
<result property="writeoffAmount" column="writeoff_amount"/>
|
|
<result property="balanceFlowId" column="balance_flow_id"/>
|
|
<result property="reverseFlowId" column="reverse_flow_id"/>
|
|
<result property="writeoffDate" column="writeoff_date"/>
|
|
<result property="status" column="status"/>
|
|
<result property="remark" column="remark"/>
|
|
<result property="createUserId" column="create_user_id"/>
|
|
<result property="createBy" column="create_by"/>
|
|
<result property="createTime" column="create_time"/>
|
|
<result property="cancelUserId" column="cancel_user_id"/>
|
|
<result property="cancelBy" column="cancel_by"/>
|
|
<result property="cancelTime" column="cancel_time"/>
|
|
<result property="cancelRemark" column="cancel_remark"/>
|
|
<result property="billName" column="bill_name"/>
|
|
<result property="customerName" column="customer_name"/>
|
|
</resultMap>
|
|
|
|
<sql id="selectColumns">
|
|
select w.writeoff_id, w.writeoff_no, w.ar_bill_id, w.bill_no, w.customer_id, w.receipt_id, w.account_id,
|
|
w.currency, w.writeoff_amount, w.balance_flow_id, w.reverse_flow_id,
|
|
w.writeoff_date, w.status, w.remark, w.create_user_id, w.create_by, w.create_time,
|
|
w.cancel_user_id, w.cancel_by, w.cancel_time, w.cancel_remark,
|
|
b.bill_name, b.customer_name
|
|
from ar_balance_writeoff w
|
|
left join ar_bill b on b.ar_bill_id = w.ar_bill_id
|
|
</sql>
|
|
|
|
<insert id="insertArBalanceWriteoff" parameterType="ArBalanceWriteoff"
|
|
useGeneratedKeys="true" keyProperty="writeoffId">
|
|
insert into ar_balance_writeoff (
|
|
writeoff_no, ar_bill_id, bill_no, customer_id, receipt_id, account_id, currency,
|
|
writeoff_amount, balance_flow_id, reverse_flow_id, writeoff_date,
|
|
status, remark, create_user_id, create_by, create_time
|
|
) values (
|
|
#{writeoffNo}, #{arBillId}, #{billNo}, #{customerId}, #{receiptId}, #{accountId}, #{currency},
|
|
#{writeoffAmount}, #{balanceFlowId}, #{reverseFlowId}, #{writeoffDate},
|
|
#{status}, #{remark}, #{createUserId}, #{createBy}, sysdate()
|
|
)
|
|
</insert>
|
|
|
|
<update id="updateFlowRefs">
|
|
update ar_balance_writeoff
|
|
set account_id = #{accountId},
|
|
balance_flow_id = #{balanceFlowId}
|
|
where writeoff_id = #{writeoffId}
|
|
</update>
|
|
|
|
<select id="selectByIdForUpdate" resultMap="ArBalanceWriteoffResult">
|
|
<include refid="selectColumns"/>
|
|
where w.writeoff_id = #{writeoffId}
|
|
for update
|
|
</select>
|
|
|
|
<update id="updateCancelled">
|
|
update ar_balance_writeoff
|
|
set status = #{status},
|
|
reverse_flow_id = #{reverseFlowId},
|
|
cancel_user_id = #{cancelUserId},
|
|
cancel_by = #{cancelBy},
|
|
cancel_time = sysdate(),
|
|
cancel_remark = #{cancelRemark}
|
|
where writeoff_id = #{writeoffId} and status = #{effectiveStatus}
|
|
</update>
|
|
|
|
<select id="selectWriteoffList" resultMap="ArBalanceWriteoffResult">
|
|
<include refid="selectColumns"/>
|
|
<where>
|
|
<if test="query.customerId != null">and w.customer_id = #{query.customerId}</if>
|
|
<if test="query.arBillId != null">and w.ar_bill_id = #{query.arBillId}</if>
|
|
<if test="query.status != null and query.status != ''">and w.status = #{query.status}</if>
|
|
<if test="query.currency != null and query.currency != ''">and w.currency = #{query.currency}</if>
|
|
<if test="query.writeoffNo != null and query.writeoffNo != ''">and w.writeoff_no like concat('%', #{query.writeoffNo}, '%')</if>
|
|
<if test="query.billNo != null and query.billNo != ''">and w.bill_no like concat('%', #{query.billNo}, '%')</if>
|
|
<if test="query.receiptId != null">and w.receipt_id = #{query.receiptId}</if>
|
|
<if test="query.params != null and query.params.beginTime != null and query.params.beginTime != ''">
|
|
and date_format(w.writeoff_date,'%y%m%d') >= date_format(#{query.params.beginTime},'%y%m%d')
|
|
</if>
|
|
<if test="query.params != null and query.params.endTime != null and query.params.endTime != ''">
|
|
and date_format(w.writeoff_date,'%y%m%d') <= date_format(#{query.params.endTime},'%y%m%d')
|
|
</if>
|
|
<include refid="com.bms.ar.mapper.ArBillScopeMapper.billScope"/>
|
|
</where>
|
|
order by w.create_time desc, w.writeoff_id desc
|
|
</select>
|
|
</mapper>
|