This commit is contained in:
wuweihua
2026-09-17 10:00:13 +08:00
48 changed files with 1871 additions and 1815 deletions
@@ -31,8 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
case l.object_type
when 'BILL' then b.bill_no
when 'EXPORT' then coalesce(e.file_name, b.bill_no)
when 'RECEIPT' then r.receipt_no
when 'WRITEOFF' then w.writeoff_no
when 'BALANCE_WRITEOFF' then bw.writeoff_no
else null
end as object_display,
l.from_status, l.to_status, l.before_data, l.after_data, l.operator_id, l.operator_name,
@@ -40,8 +39,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from ar_bill_log l
left join ar_bill b on b.ar_bill_id = l.ar_bill_id
left join ar_bill_export e on e.export_id = case when l.object_type = 'EXPORT' then cast(l.object_id as unsigned) end
left join ar_receipt r on r.receipt_id = case when l.object_type = 'RECEIPT' then cast(l.object_id as unsigned) end
left join ar_receipt_writeoff w on w.writeoff_id = case when l.object_type = 'WRITEOFF' then cast(l.object_id as unsigned) end
left join ar_balance_writeoff bw on bw.writeoff_id = case when l.object_type = 'BALANCE_WRITEOFF' then cast(l.object_id as unsigned) end
<where>
<if test="arBillId != null">and l.ar_bill_id = #{arBillId}</if>
<if test="objectType != null and objectType != ''">and l.object_type = #{objectType}</if>
@@ -1,97 +0,0 @@
<?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.ar.mapper.ArReceiptMapper">
<resultMap id="ArReceiptResult" type="ArReceipt">
<id property="receiptId" column="receipt_id"/>
<result property="receiptNo" column="receipt_no"/>
<result property="customerId" column="customer_id"/>
<result property="customerName" column="customer_name"/>
<result property="customerCode" column="customer_code"/>
<result property="receiptDate" column="receipt_date"/>
<result property="currency" column="currency"/>
<result property="receiptAmount" column="receipt_amount"/>
<result property="unallocatedAmount" column="unallocated_amount"/>
<result property="paymentMethod" column="payment_method"/>
<result property="bankReference" column="bank_reference"/>
<result property="status" column="status"/>
<result property="remark" column="remark"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
</resultMap>
<sql id="selectReceiptColumns">
select r.receipt_id, r.receipt_no, r.customer_id, c.customer_name, c.customer_code,
r.receipt_date, r.currency, r.receipt_amount, r.unallocated_amount,
r.payment_method, r.bank_reference, r.status, r.remark,
r.create_by, r.create_time, r.update_by, r.update_time
from ar_receipt r
left join bms_customer c on c.customer_id = r.customer_id and c.del_flag = '0'
</sql>
<!-- 加锁更新只读取收款主表,避免锁定展示关联表。 -->
<sql id="selectReceiptLockColumns">
select receipt_id, receipt_no, customer_id, receipt_date, currency, receipt_amount,
unallocated_amount, payment_method, bank_reference, status, remark,
create_by, create_time, update_by, update_time
from ar_receipt
</sql>
<select id="selectArReceiptList" parameterType="com.ruoyi.ar.domain.vo.ArReceiptQuery" resultMap="ArReceiptResult">
<include refid="selectReceiptColumns"/>
<where>
<if test="receiptNo != null and receiptNo != ''">and r.receipt_no like concat('%', #{receiptNo}, '%')</if>
<if test="customerId != null">and r.customer_id = #{customerId}</if>
<if test="currency != null and currency != ''">and r.currency = #{currency}</if>
<if test="paymentMethod != null and paymentMethod != ''">and r.payment_method = #{paymentMethod}</if>
<if test="status != null and status != ''">and r.status = #{status}</if>
<if test="receiptDateStart != null">and r.receipt_date &gt;= #{receiptDateStart}</if>
<if test="receiptDateEnd != null">and r.receipt_date &lt;= #{receiptDateEnd}</if>
</where>
order by r.receipt_date desc, r.receipt_id desc
</select>
<select id="selectArReceiptById" parameterType="long" resultMap="ArReceiptResult">
<include refid="selectReceiptColumns"/> where r.receipt_id = #{receiptId}
</select>
<select id="selectArReceiptByIdForUpdate" parameterType="long" resultMap="ArReceiptResult">
<include refid="selectReceiptLockColumns"/> where receipt_id = #{receiptId} for update
</select>
<select id="selectArReceiptByNo" parameterType="string" resultMap="ArReceiptResult">
<include refid="selectReceiptColumns"/> where r.receipt_no = #{receiptNo}
</select>
<select id="selectArReceiptByReference" resultMap="ArReceiptResult">
<include refid="selectReceiptColumns"/>
where r.payment_method = #{paymentMethod} and r.bank_reference = #{bankReference}
limit 1
</select>
<insert id="insertArReceipt" parameterType="ArReceipt" useGeneratedKeys="true" keyProperty="receiptId">
insert into ar_receipt (
receipt_no, customer_id, receipt_date, currency, receipt_amount, unallocated_amount,
payment_method, bank_reference, status, remark, create_by, create_time, update_by, update_time
) values (
#{receiptNo}, #{customerId}, #{receiptDate}, #{currency}, #{receiptAmount}, #{unallocatedAmount},
#{paymentMethod}, #{bankReference}, #{status}, #{remark}, #{createBy}, sysdate(), #{updateBy}, sysdate()
)
</insert>
<update id="updateBalanceAndStatus">
update ar_receipt
set unallocated_amount = #{unallocatedAmount}, status = #{status},
update_by = #{operator}, update_time = sysdate()
where receipt_id = #{receiptId}
</update>
<update id="updateCancelled">
update ar_receipt set status = 'CANCELLED', remark = #{remark},
update_by = #{operator}, update_time = sysdate()
where receipt_id = #{receiptId}
</update>
</mapper>
@@ -1,81 +0,0 @@
<?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.ar.mapper.ArReceiptWriteoffMapper">
<resultMap id="ArReceiptWriteoffResult" type="ArReceiptWriteoff">
<id property="writeoffId" column="writeoff_id"/>
<result property="receiptId" column="receipt_id"/>
<result property="arBillId" column="ar_bill_id"/>
<result property="billNo" column="bill_no"/>
<result property="receiptNo" column="receipt_no"/>
<result property="writeoffNo" column="writeoff_no"/>
<result property="writeoffAmount" column="writeoff_amount"/>
<result property="currency" column="currency"/>
<result property="writeoffDate" column="writeoff_date"/>
<result property="status" column="status"/>
<result property="remark" column="remark"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="cancelBy" column="cancel_by"/>
<result property="cancelTime" column="cancel_time"/>
</resultMap>
<sql id="selectWriteoffColumns">
select w.writeoff_id, w.receipt_id, w.ar_bill_id, b.bill_no, r.receipt_no,
w.writeoff_no, w.writeoff_amount, w.currency, w.writeoff_date, w.status,
w.remark, w.create_by, w.create_time, w.cancel_by, w.cancel_time
from ar_receipt_writeoff w
left join ar_bill b on b.ar_bill_id = w.ar_bill_id
left join ar_receipt r on r.receipt_id = w.receipt_id
</sql>
<!-- 加锁更新只读取核销关系主表,展示字段不参与锁定。 -->
<sql id="selectWriteoffLockColumns">
select writeoff_id, receipt_id, ar_bill_id, writeoff_no, writeoff_amount, currency,
writeoff_date, status, remark, create_by, create_time, cancel_by, cancel_time
from ar_receipt_writeoff
</sql>
<select id="selectByBillId" parameterType="long" resultMap="ArReceiptWriteoffResult">
<include refid="selectWriteoffColumns"/> where w.ar_bill_id = #{arBillId} order by w.create_time desc
</select>
<select id="selectByReceiptId" parameterType="long" resultMap="ArReceiptWriteoffResult">
<include refid="selectWriteoffColumns"/> where w.receipt_id = #{receiptId} order by w.create_time desc
</select>
<select id="selectById" parameterType="long" resultMap="ArReceiptWriteoffResult">
<include refid="selectWriteoffColumns"/> where w.writeoff_id = #{writeoffId}
</select>
<select id="selectByIdForUpdate" parameterType="long" resultMap="ArReceiptWriteoffResult">
<include refid="selectWriteoffLockColumns"/> where writeoff_id = #{writeoffId} for update
</select>
<insert id="insert" parameterType="ArReceiptWriteoff" useGeneratedKeys="true" keyProperty="writeoffId">
insert into ar_receipt_writeoff (
receipt_id, ar_bill_id, writeoff_no, writeoff_amount, currency, writeoff_date,
status, remark, create_by, create_time
) values (
#{receiptId}, #{arBillId}, #{writeoffNo}, #{writeoffAmount}, #{currency}, #{writeoffDate},
#{status}, #{remark}, #{createBy}, sysdate()
)
</insert>
<update id="updateCancelled">
update ar_receipt_writeoff
set status = 'CANCELLED', remark = #{remark}, cancel_by = #{cancelBy}, cancel_time = sysdate()
where writeoff_id = #{writeoffId} and status = 'EFFECTIVE'
</update>
<select id="sumEffectiveByBillId" parameterType="long" resultType="java.math.BigDecimal">
select coalesce(sum(writeoff_amount), 0) from ar_receipt_writeoff
where ar_bill_id = #{arBillId} and status = 'EFFECTIVE'
</select>
<select id="sumEffectiveByReceiptId" parameterType="long" resultType="java.math.BigDecimal">
select coalesce(sum(writeoff_amount), 0) from ar_receipt_writeoff
where receipt_id = #{receiptId} and status = 'EFFECTIVE'
</select>
</mapper>
@@ -0,0 +1,129 @@
<?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.customer.customermoney.mapper.CustomerCreditApplyMapper">
<resultMap type="com.ruoyi.customer.customermoney.domain.CustomerCreditApply" id="CustomerCreditApplyResult">
<id property="applyId" column="apply_id" />
<result property="applyNo" column="apply_no" />
<result property="customerId" column="customer_id" />
<result property="accountId" column="account_id" />
<result property="creditType" column="credit_type" />
<result property="adjustMode" column="adjust_mode" />
<result property="changeAmount" column="change_amount" />
<result property="effectiveDate" column="effective_date" />
<result property="expireDate" column="expire_date" />
<result property="reason" column="reason" />
<result property="status" column="status" />
<result property="applyBy" column="apply_by" />
<result property="applyUserId" column="apply_user_id" />
<result property="applyTime" column="apply_time" />
<result property="approveBy" column="approve_by" />
<result property="approveUserId" column="approve_user_id"/>
<result property="approveTime" column="approve_time" />
<result property="approveRemark" column="approve_remark" />
<result property="flowId" column="flow_id" />
<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="customerCode" column="customer_code" />
<result property="customerName" column="customer_name" />
</resultMap>
<sql id="applyVo">
select a.apply_id, a.apply_no, a.customer_id, a.account_id, a.credit_type, a.adjust_mode,
a.change_amount, a.effective_date, a.expire_date, a.reason, a.status,
a.apply_by, a.apply_user_id, a.apply_time,
a.approve_by, a.approve_user_id, a.approve_time, a.approve_remark, a.flow_id,
a.create_by, a.create_time, a.update_by, a.update_time, a.remark, a.del_flag,
c.customer_code, c.customer_name
from customer_credit_apply a
left join bms_customer c on c.customer_id = a.customer_id
</sql>
<select id="selectApplyList"
parameterType="com.ruoyi.customer.customermoney.domain.CustomerCreditApply"
resultMap="CustomerCreditApplyResult">
<include refid="applyVo"/>
<where>
a.del_flag = '0'
<if test="customerId != null"> and a.customer_id = #{customerId}</if>
<if test="status != null and status != ''"> and a.status = #{status}</if>
<if test="creditType != null and creditType != ''"> and a.credit_type = #{creditType}</if>
<if test="applyNo != null and applyNo != ''"> and a.apply_no like concat('%', #{applyNo}, '%')</if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 申请时间范围 -->
and date_format(a.apply_time, '%y%m%d') &gt;= date_format(#{params.beginTime}, '%y%m%d')
</if>
<if test="params.endTime != null and params.endTime != ''">
and date_format(a.apply_time, '%y%m%d') &lt;= date_format(#{params.endTime}, '%y%m%d')
</if>
</where>
order by a.apply_id desc
</select>
<select id="selectApplyById" resultMap="CustomerCreditApplyResult">
<include refid="applyVo"/>
where a.apply_id = #{applyId} and a.del_flag = '0'
</select>
<select id="selectApplyByIdForUpdate" resultMap="CustomerCreditApplyResult">
select * from customer_credit_apply where apply_id = #{applyId} and del_flag = '0' for update
</select>
<insert id="insertApply"
parameterType="com.ruoyi.customer.customermoney.domain.CustomerCreditApply"
useGeneratedKeys="true" keyProperty="applyId">
insert into customer_credit_apply (
apply_no, customer_id, credit_type, adjust_mode, change_amount,
effective_date, expire_date, reason, status,
apply_by, apply_user_id, apply_time,
create_by, create_time, remark
) values (
#{applyNo}, #{customerId}, #{creditType}, #{adjustMode}, #{changeAmount},
#{effectiveDate}, #{expireDate}, #{reason}, #{status},
#{applyBy}, #{applyUserId}, #{applyTime},
#{createBy}, sysdate(), #{remark}
)
</insert>
<update id="updateApproved"
parameterType="com.ruoyi.customer.customermoney.domain.CustomerCreditApply">
update customer_credit_apply
set status = 'APPROVED',
account_id = #{accountId},
flow_id = #{flowId},
approve_by = #{approveBy},
approve_user_id = #{approveUserId},
approve_time = sysdate(),
approve_remark = #{approveRemark},
update_by = #{approveBy},
update_time = sysdate()
where apply_id = #{applyId} and status = 'PENDING' and del_flag = '0'
</update>
<update id="updateRejected"
parameterType="com.ruoyi.customer.customermoney.domain.CustomerCreditApply">
update customer_credit_apply
set status = 'REJECTED',
approve_by = #{approveBy},
approve_user_id = #{approveUserId},
approve_time = sysdate(),
approve_remark = #{approveRemark},
update_by = #{approveBy},
update_time = sysdate()
where apply_id = #{applyId} and status = 'PENDING' and del_flag = '0'
</update>
<update id="updateCancelled">
update customer_credit_apply
set status = 'CANCELLED',
update_by = #{updateBy},
update_time = sysdate()
where apply_id = #{applyId} and status = 'PENDING' and del_flag = '0'
</update>
</mapper>
@@ -114,6 +114,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="accountId" column="account_id" />
<result property="creditType" column="credit_type" />
<result property="changeType" column="change_type" />
<result property="bizType" column="biz_type" />
<result property="bizId" column="biz_id" />
<result property="bizNo" column="biz_no" />
<result property="direction" column="direction" />
<result property="beforeAmount" column="before_amount" />
<result property="changeAmount" column="change_amount" />
@@ -133,7 +136,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectCustomerCreditFlowVo">
select id, flow_no, customer_id, account_id, credit_type, change_type, direction,
select id, flow_no, customer_id, account_id, credit_type, change_type, biz_type, biz_id, biz_no, direction,
before_amount, change_amount, after_amount, used_credit,
effective_date, expire_date, reason, adjust_mode, operator_id,
create_by, create_time, update_by, update_time, remark, del_flag
@@ -147,6 +150,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="customerId != null"> and customer_id = #{customerId}</if>
<if test="creditType != null and creditType != ''"> and credit_type = #{creditType}</if>
<if test="changeType != null and changeType != ''"> and change_type = #{changeType}</if>
<if test="bizType != null and bizType != ''"> and biz_type = #{bizType}</if>
<if test="bizId != null"> and biz_id = #{bizId}</if>
<if test="params.beginTime != null and params.beginTime != ''"> and date(create_time) &gt;= #{params.beginTime}</if>
<if test="params.endTime != null and params.endTime != ''"> and date(create_time) &lt;= #{params.endTime}</if>
and del_flag = '0'
@@ -163,6 +168,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="accountId != null">account_id,</if>
<if test="creditType != null">credit_type,</if>
<if test="changeType != null">change_type,</if>
<if test="bizType != null">biz_type,</if>
<if test="bizId != null">biz_id,</if>
<if test="bizNo != null">biz_no,</if>
<if test="direction != null">direction,</if>
<if test="beforeAmount != null">before_amount,</if>
<if test="changeAmount != null">change_amount,</if>
@@ -183,6 +191,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="accountId != null">#{accountId},</if>
<if test="creditType != null">#{creditType},</if>
<if test="changeType != null">#{changeType},</if>
<if test="bizType != null">#{bizType},</if>
<if test="bizId != null">#{bizId},</if>
<if test="bizNo != null">#{bizNo},</if>
<if test="direction != null">#{direction},</if>
<if test="beforeAmount != null">#{beforeAmount},</if>
<if test="changeAmount != null">#{changeAmount},</if>