应收账单功能实现

This commit is contained in:
caojia
2026-09-16 11:02:18 +08:00
parent 58d13904ec
commit 7172621fd3
64 changed files with 4103 additions and 4 deletions
@@ -0,0 +1,30 @@
<?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.ArBankAccountMapper">
<resultMap id="ArBankAccountResult" type="ArBankAccount">
<id property="bankAccountId" column="bank_account_id"/>
<result property="accountName" column="account_name"/>
<result property="accountNo" column="account_no"/>
<result property="bankName" column="bank_name"/>
<result property="currency" column="currency"/>
<result property="isDefault" column="is_default"/>
<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>
<select id="selectDefaultByCurrency" resultMap="ArBankAccountResult">
select bank_account_id, account_name, account_no, bank_name, currency,
is_default, status, remark, create_by, create_time, update_by, update_time
from ar_bank_account
where currency = #{currency}
and status = '0'
order by is_default desc, bank_account_id
limit 1
</select>
</mapper>
@@ -0,0 +1,62 @@
<?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.ArBillDetailFeeMapper">
<resultMap id="ArBillDetailFeeResult" type="ArBillDetailFee">
<id property="detailFeeId" column="detail_fee_id"/>
<result property="detailId" column="detail_id"/>
<result property="prcFeeId" column="prc_fee_id"/>
<result property="feeNo" column="fee_no"/>
<result property="feeType" column="fee_type"/>
<result property="feeName" column="fee_name"/>
<result property="scId" column="sc_id"/>
<result property="quantity" column="quantity"/>
<result property="unit" column="unit"/>
<result property="unitPrice" column="unit_price"/>
<result property="amount" column="amount"/>
<result property="currency" column="currency"/>
<result property="calculationFormula" column="calculation_formula"/>
<result property="roundMode" column="round_mode"/>
<result property="remark" column="remark"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
</resultMap>
<select id="selectByDetailId" parameterType="long" resultMap="ArBillDetailFeeResult">
select detail_fee_id, detail_id, prc_fee_id, fee_no, fee_type, fee_name, sc_id, quantity,
unit, unit_price, amount, currency, calculation_formula, round_mode, remark, create_by, create_time
from ar_bill_detail_fee where detail_id = #{detailId} order by fee_no, detail_fee_id
</select>
<select id="selectByBillId" parameterType="long" resultMap="ArBillDetailFeeResult">
select detail_fee_id, detail_id, prc_fee_id, fee_no, fee_type, fee_name, sc_id, quantity,
unit, unit_price, amount, currency, calculation_formula, round_mode, remark, create_by, create_time
from ar_bill_detail_fee
where detail_id in (select detail_id from ar_bill_detail where ar_bill_id = #{arBillId})
order by detail_id, fee_no, detail_fee_id
</select>
<insert id="insert" parameterType="ArBillDetailFee" useGeneratedKeys="true" keyProperty="detailFeeId">
insert into ar_bill_detail_fee (
detail_id, prc_fee_id, fee_no, fee_type, fee_name, sc_id, quantity, unit, unit_price,
amount, currency, calculation_formula, round_mode, remark, create_by, create_time
) values (
#{detailId}, #{prcFeeId}, #{feeNo}, #{feeType}, #{feeName}, #{scId}, #{quantity}, #{unit},
#{unitPrice}, #{amount}, #{currency}, #{calculationFormula}, #{roundMode}, #{remark},
#{createBy}, sysdate()
)
</insert>
<insert id="insertBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="detailFeeId">
insert into ar_bill_detail_fee (
detail_id, prc_fee_id, fee_no, fee_type, fee_name, sc_id, quantity, unit, unit_price,
amount, currency, calculation_formula, round_mode, remark, create_by, create_time
) values
<foreach collection="list" item="item" separator=",">
(#{item.detailId}, #{item.prcFeeId}, #{item.feeNo}, #{item.feeType}, #{item.feeName}, #{item.scId},
#{item.quantity}, #{item.unit}, #{item.unitPrice}, #{item.amount}, #{item.currency},
#{item.calculationFormula}, #{item.roundMode}, #{item.remark}, #{item.createBy}, sysdate())
</foreach>
</insert>
</mapper>
@@ -0,0 +1,109 @@
<?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.ArBillDetailMapper">
<resultMap id="ArBillDetailResult" type="ArBillDetail">
<id property="detailId" column="detail_id"/>
<result property="arBillId" column="ar_bill_id"/>
<result property="prcBillId" column="prc_bill_id"/>
<result property="detailNo" column="detail_no"/>
<result property="orderNo" column="order_no"/>
<result property="trackingNo" column="tracking_no"/>
<result property="receiveTime" column="receive_time"/>
<result property="productCode" column="product_code"/>
<result property="productName" column="product_name"/>
<result property="goodsDescription" column="goods_description"/>
<result property="countryCode" column="country_code"/>
<result property="countryName" column="country_name"/>
<result property="destPostcode" column="dest_postcode"/>
<result property="actualWeight" column="actual_weight"/>
<result property="volumeWeight" column="volume_weight"/>
<result property="chargeWeight" column="charge_weight"/>
<result property="pkgLength" column="pkg_length"/>
<result property="pkgWidth" column="pkg_width"/>
<result property="pkgHeight" column="pkg_height"/>
<result property="currency" column="currency"/>
<result property="totalAmount" column="total_amount"/>
<result property="remark" column="remark"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
</resultMap>
<select id="selectByBillId" parameterType="long" resultMap="ArBillDetailResult">
select detail_id, ar_bill_id, prc_bill_id, detail_no, order_no, tracking_no, receive_time,
product_code, product_name, goods_description, country_code, country_name, dest_postcode,
actual_weight, volume_weight, charge_weight, pkg_length, pkg_width, pkg_height,
currency, total_amount, remark, create_by, create_time
from ar_bill_detail where ar_bill_id = #{arBillId} order by detail_no
</select>
<resultMap id="ArBillDetailWithFeesResult" type="ArBillDetail" extends="ArBillDetailResult">
<collection property="fees" ofType="ArBillDetailFee">
<id property="detailFeeId" column="fee_detail_id"/>
<result property="detailId" column="fee_parent_detail_id"/>
<result property="prcFeeId" column="fee_prc_fee_id"/>
<result property="feeNo" column="fee_no"/>
<result property="feeType" column="fee_type"/>
<result property="feeName" column="fee_name"/>
<result property="scId" column="fee_sc_id"/>
<result property="quantity" column="fee_quantity"/>
<result property="unit" column="fee_unit"/>
<result property="unitPrice" column="fee_unit_price"/>
<result property="amount" column="fee_amount"/>
<result property="currency" column="fee_currency"/>
<result property="calculationFormula" column="fee_calculation_formula"/>
<result property="roundMode" column="fee_round_mode"/>
<result property="remark" column="fee_remark"/>
<result property="createBy" column="fee_create_by"/>
<result property="createTime" column="fee_create_time"/>
</collection>
</resultMap>
<select id="selectByBillIdWithFees" parameterType="long" resultMap="ArBillDetailWithFeesResult">
select d.detail_id, d.ar_bill_id, d.prc_bill_id, d.detail_no, d.order_no, d.tracking_no, d.receive_time,
d.product_code, d.product_name, d.goods_description, d.country_code, d.country_name, d.dest_postcode,
d.actual_weight, d.volume_weight, d.charge_weight, d.pkg_length, d.pkg_width, d.pkg_height,
d.currency, d.total_amount, d.remark, d.create_by, d.create_time,
f.detail_fee_id as fee_detail_id, f.detail_id as fee_parent_detail_id, f.prc_fee_id as fee_prc_fee_id,
f.fee_no, f.fee_type, f.fee_name, f.sc_id as fee_sc_id, f.quantity as fee_quantity,
f.unit as fee_unit, f.unit_price as fee_unit_price, f.amount as fee_amount,
f.currency as fee_currency, f.calculation_formula as fee_calculation_formula,
f.round_mode as fee_round_mode, f.remark as fee_remark, f.create_by as fee_create_by,
f.create_time as fee_create_time
from ar_bill_detail d
left join ar_bill_detail_fee f on f.detail_id = d.detail_id
where d.ar_bill_id = #{arBillId}
order by d.detail_no, d.detail_id, f.fee_no, f.detail_fee_id
</select>
<insert id="insert" parameterType="ArBillDetail" useGeneratedKeys="true" keyProperty="detailId">
insert into ar_bill_detail (
ar_bill_id, prc_bill_id, detail_no, order_no, tracking_no, receive_time, product_code,
product_name, goods_description, country_code, country_name, dest_postcode, actual_weight,
volume_weight, charge_weight, pkg_length, pkg_width, pkg_height, currency, total_amount,
remark, create_by, create_time
) values (
#{arBillId}, #{prcBillId}, #{detailNo}, #{orderNo}, #{trackingNo}, #{receiveTime},
#{productCode}, #{productName}, #{goodsDescription}, #{countryCode}, #{countryName},
#{destPostcode}, #{actualWeight}, #{volumeWeight}, #{chargeWeight}, #{pkgLength}, #{pkgWidth},
#{pkgHeight}, #{currency}, #{totalAmount}, #{remark}, #{createBy}, sysdate()
)
</insert>
<insert id="insertBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="detailId">
insert into ar_bill_detail (
ar_bill_id, prc_bill_id, detail_no, order_no, tracking_no, receive_time, product_code,
product_name, goods_description, country_code, country_name, dest_postcode, actual_weight,
volume_weight, charge_weight, pkg_length, pkg_width, pkg_height, currency, total_amount,
remark, create_by, create_time
) values
<foreach collection="list" item="item" separator=",">
(#{item.arBillId}, #{item.prcBillId}, #{item.detailNo}, #{item.orderNo}, #{item.trackingNo},
#{item.receiveTime}, #{item.productCode}, #{item.productName}, #{item.goodsDescription},
#{item.countryCode}, #{item.countryName}, #{item.destPostcode}, #{item.actualWeight},
#{item.volumeWeight}, #{item.chargeWeight}, #{item.pkgLength}, #{item.pkgWidth}, #{item.pkgHeight},
#{item.currency}, #{item.totalAmount}, #{item.remark}, #{item.createBy}, sysdate())
</foreach>
</insert>
</mapper>
@@ -0,0 +1,52 @@
<?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.ArBillExportMapper">
<resultMap id="ArBillExportResult" type="ArBillExport">
<id property="exportId" column="export_id"/>
<result property="arBillId" column="ar_bill_id"/>
<result property="fileName" column="file_name"/>
<result property="fileType" column="file_type"/>
<result property="templateCode" column="template_code"/>
<result property="templateVersion" column="template_version"/>
<result property="storageKey" column="storage_key"/>
<result property="fileSize" column="file_size"/>
<result property="fileHash" column="file_hash"/>
<result property="rowCount" column="row_count"/>
<result property="exportStatus" column="export_status"/>
<result property="exportBy" column="export_by"/>
<result property="exportTime" column="export_time"/>
<result property="remark" column="remark"/>
</resultMap>
<sql id="selectExportColumns">
select export_id, ar_bill_id, file_name, file_type, template_code, template_version,
storage_key, file_size, file_hash, row_count, export_status, export_by, export_time, remark
from ar_bill_export
</sql>
<select id="selectByBillId" parameterType="long" resultMap="ArBillExportResult">
<include refid="selectExportColumns"/> where ar_bill_id = #{arBillId} order by export_time desc
</select>
<select id="selectById" parameterType="long" resultMap="ArBillExportResult">
<include refid="selectExportColumns"/> where export_id = #{exportId}
</select>
<select id="selectLatestSuccessByBillId" parameterType="long" resultMap="ArBillExportResult">
<include refid="selectExportColumns"/>
where ar_bill_id = #{arBillId} and export_status = 'SUCCESS'
order by export_time desc limit 1
</select>
<insert id="insert" parameterType="ArBillExport" useGeneratedKeys="true" keyProperty="exportId">
insert into ar_bill_export (
ar_bill_id, file_name, file_type, template_code, template_version, storage_key,
file_size, file_hash, row_count, export_status, export_by, export_time, remark
) values (
#{arBillId}, #{fileName}, #{fileType}, #{templateCode}, #{templateVersion}, #{storageKey},
#{fileSize}, #{fileHash}, #{rowCount}, #{exportStatus}, #{exportBy}, sysdate(), #{remark}
)
</insert>
</mapper>
@@ -0,0 +1,76 @@
<?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.ArBillLogMapper">
<resultMap id="ArBillLogResult" type="ArBillLog">
<id property="logId" column="log_id"/>
<result property="arBillId" column="ar_bill_id"/>
<result property="objectType" column="object_type"/>
<result property="objectId" column="object_id"/>
<result property="objectDisplay" column="object_display"/>
<result property="operationType" column="operation_type"/>
<result property="operationDesc" column="operation_desc"/>
<result property="fromStatus" column="from_status"/>
<result property="toStatus" column="to_status"/>
<result property="beforeData" column="before_data"/>
<result property="afterData" column="after_data"/>
<result property="operatorId" column="operator_id"/>
<result property="operatorName" column="operator_name"/>
<result property="operationSource" column="operation_source"/>
<result property="requestId" column="request_id"/>
<result property="traceId" column="trace_id"/>
<result property="result" column="result"/>
<result property="errorMessage" column="error_message"/>
<result property="clientIp" column="client_ip"/>
<result property="createTime" column="create_time"/>
</resultMap>
<select id="selectList" parameterType="ArBillLog" resultMap="ArBillLogResult">
select l.log_id, l.ar_bill_id, l.object_type, l.object_id, l.operation_type, l.operation_desc,
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
else null
end as object_display,
l.from_status, l.to_status, l.before_data, l.after_data, l.operator_id, l.operator_name,
l.operation_source, l.request_id, l.trace_id, l.result, l.error_message, l.client_ip, l.create_time
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
<where>
<if test="arBillId != null">and l.ar_bill_id = #{arBillId}</if>
<if test="objectType != null and objectType != ''">and l.object_type = #{objectType}</if>
<if test="objectId != null and objectId != ''">and l.object_id = #{objectId}</if>
<if test="operationType != null and operationType != ''">and l.operation_type = #{operationType}</if>
<if test="requestId != null and requestId != ''">and l.request_id = #{requestId}</if>
<if test="result != null and result != ''">and l.result = #{result}</if>
</where>
order by l.create_time desc, l.log_id desc
</select>
<select id="selectSuccessByRequestId" resultMap="ArBillLogResult">
select log_id, ar_bill_id, object_type, object_id, operation_type, operation_desc,
from_status, to_status, before_data, after_data, operator_id, operator_name,
operation_source, request_id, trace_id, result, error_message, client_ip, create_time
from ar_bill_log
where request_id = #{requestId} and object_type = #{objectType} and result = 'SUCCESS'
order by log_id limit 1
</select>
<insert id="insert" parameterType="ArBillLog" useGeneratedKeys="true" keyProperty="logId">
insert into ar_bill_log (
ar_bill_id, object_type, object_id, operation_type, operation_desc, from_status, to_status,
before_data, after_data, operator_id, operator_name, operation_source, request_id,
trace_id, result, error_message, client_ip, create_time
) values (
#{arBillId}, #{objectType}, #{objectId}, #{operationType}, #{operationDesc}, #{fromStatus}, #{toStatus},
#{beforeData}, #{afterData}, #{operatorId}, #{operatorName}, #{operationSource}, #{requestId},
#{traceId}, #{result}, #{errorMessage}, #{clientIp}, sysdate()
)
</insert>
</mapper>
@@ -0,0 +1,113 @@
<?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.ArBillMapper">
<resultMap id="ArBillResult" type="ArBill">
<id property="arBillId" column="ar_bill_id"/>
<result property="billNo" column="bill_no"/>
<result property="billName" column="bill_name"/>
<result property="customerId" column="customer_id"/>
<result property="customerCode" column="customer_code"/>
<result property="customerName" column="customer_name"/>
<result property="billPeriodStart" column="bill_period_start"/>
<result property="billPeriodEnd" column="bill_period_end"/>
<result property="billDate" column="bill_date"/>
<result property="currency" column="currency"/>
<result property="orderCount" column="order_count"/>
<result property="totalAmount" column="total_amount"/>
<result property="writtenOffAmount" column="written_off_amount"/>
<result property="unwrittenAmount" column="unwritten_amount"/>
<result property="status" column="status"/>
<result property="billVersion" column="bill_version"/>
<result property="bankAccountName" column="bank_account_name"/>
<result property="bankAccountNo" column="bank_account_no"/>
<result property="bankName" column="bank_name"/>
<result property="remark" column="remark"/>
<result property="confirmedBy" column="confirmed_by"/>
<result property="confirmedTime" column="confirmed_time"/>
<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="selectArBillColumns">
select ar_bill_id, bill_no, bill_name, customer_id, customer_code, customer_name,
bill_period_start, bill_period_end, bill_date, currency, order_count,
total_amount, written_off_amount, unwritten_amount, status, bill_version,
bank_account_name, bank_account_no, bank_name, remark, confirmed_by,
confirmed_time, create_by, create_time, update_by, update_time
from ar_bill
</sql>
<select id="selectArBillList" parameterType="ArBill" resultMap="ArBillResult">
<include refid="selectArBillColumns"/>
<where>
<if test="billNo != null and billNo != ''">and bill_no like concat('%', #{billNo}, '%')</if>
<if test="billName != null and billName != ''">and bill_name like concat('%', #{billName}, '%')</if>
<if test="customerCode != null and customerCode != ''">and customer_code like concat('%', #{customerCode}, '%')</if>
<if test="customerName != null and customerName != ''">and customer_name like concat('%', #{customerName}, '%')</if>
<if test="customerId != null">and customer_id = #{customerId}</if>
<if test="status != null and status != ''">and status = #{status}</if>
<if test="currency != null and currency != ''">and currency = #{currency}</if>
<if test="billPeriodStart != null">and bill_period_end &gt;= #{billPeriodStart}</if>
<if test="billPeriodEnd != null">and bill_period_start &lt;= #{billPeriodEnd}</if>
</where>
order by create_time desc, ar_bill_id desc
</select>
<select id="selectArBillById" parameterType="long" resultMap="ArBillResult">
<include refid="selectArBillColumns"/> where ar_bill_id = #{arBillId}
</select>
<select id="selectArBillByBillNo" parameterType="string" resultMap="ArBillResult">
<include refid="selectArBillColumns"/> where bill_no = #{billNo}
</select>
<select id="selectMaxBillVersion" resultType="int">
select bill_version
from ar_bill
where customer_id = #{customerId}
and bill_period_end = #{cutoffDate}
and currency = #{currency}
order by bill_version desc
limit 1
for update
</select>
<select id="selectArBillByIdForUpdate" parameterType="long" resultMap="ArBillResult">
<include refid="selectArBillColumns"/> where ar_bill_id = #{arBillId} for update
</select>
<insert id="insertArBill" parameterType="ArBill" useGeneratedKeys="true" keyProperty="arBillId">
insert into ar_bill (
bill_no, bill_name, customer_id, customer_code, customer_name, bill_period_start, bill_period_end,
bill_date, currency, order_count, total_amount, written_off_amount, unwritten_amount,
status, bill_version, bank_account_name, bank_account_no, bank_name, remark,
confirmed_by, confirmed_time, create_by, create_time, update_by, update_time
) values (
#{billNo}, #{billName}, #{customerId}, #{customerCode}, #{customerName}, #{billPeriodStart}, #{billPeriodEnd},
#{billDate}, #{currency}, #{orderCount}, #{totalAmount}, #{writtenOffAmount}, #{unwrittenAmount},
#{status}, #{billVersion}, #{bankAccountName}, #{bankAccountNo}, #{bankName}, #{remark},
#{confirmedBy}, #{confirmedTime}, #{createBy}, sysdate(), #{updateBy}, sysdate()
)
</insert>
<update id="updateArBillStatus">
update ar_bill
set status = #{status}, remark = #{remark}, update_by = #{operator}, update_time = sysdate(),
confirmed_by = case when #{status} = 'CONFIRMED' then #{operator} else confirmed_by end,
confirmed_time = case when #{status} = 'CONFIRMED' then sysdate() else confirmed_time end
where ar_bill_id = #{arBillId}
and status = #{fromStatus}
</update>
<update id="updateArBillAmounts">
update ar_bill
set written_off_amount = #{writtenOffAmount}, unwritten_amount = #{unwrittenAmount},
status = #{status}, update_by = #{operator}, update_time = sysdate()
where ar_bill_id = #{arBillId}
and status = #{fromStatus}
</update>
</mapper>
@@ -0,0 +1,97 @@
<?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>
@@ -0,0 +1,81 @@
<?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>
@@ -24,6 +24,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by field(fee_type, 'BASIC_FREIGHT', 'REGISTRATION_FEE', 'SURCHARGE'), fee_id
</select>
<select id="selectByBillIds" resultMap="PrcIncomeBillFeeResult">
select fee_id, bill_id, fee_type, fee_name, sc_id, amount, currency, round_mode, remark, create_time
from prc_income_bill_fee
where bill_id in
<foreach collection="billIds" item="billId" open="(" separator="," close=")">
#{billId}
</foreach>
order by bill_id, field(fee_type, 'BASIC_FREIGHT', 'REGISTRATION_FEE', 'SURCHARGE'), fee_id
</select>
<insert id="insertPrcIncomeBillFee" parameterType="PrcIncomeBillFee">
insert into prc_income_bill_fee (
fee_id, bill_id, fee_type, fee_name, sc_id, amount, currency, round_mode, remark, create_time
@@ -28,7 +28,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="productCode" column="product_code" />
<result property="productName" column="product_name" />
<result property="countryCode" column="country_code" />
<result property="countryName" column="country_name" />
<result property="countryName" column="country_name" />
<result property="weight" column="weight" />
<result property="bizDate" column="biz_date" />
<result property="tmsId" column="tms_id" />
@@ -55,6 +55,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="incomeTotal" column="income_total" />
<result property="payTotal" column="pay_total" />
<result property="currency" column="currency" />
<result property="arBillStatus" column="ar_bill_status" />
<result property="roundMode" column="round_mode" />
<result property="createBy" column="created_by" />
<result property="createTime" column="create_time" />
@@ -71,7 +72,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
set_type, bind_priority, customer_priceset_id, product_country_id,
weight_min, weight_max, weight_label, effective_date, charge_weight,
freight_rate, base_freight_rate, discount_percent, registration_fee,
freight_amount, surcharge_amount, income_total, pay_total, currency, round_mode,
freight_amount, surcharge_amount, income_total, pay_total, currency, ar_bill_status, round_mode,
created_by, create_time, updated_by, update_time
from prc_order_bill
</sql>
@@ -123,6 +124,39 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by create_time desc, bill_id desc
</select>
<!-- The repository's rename_bill_tables.sql maps the requirement's prc_bill to prc_order_bill. -->
<select id="selectPrcOrderBillByCustomerPeriod" resultMap="PrcOrderBillResult">
<include refid="selectPrcOrderBillVo"/>
where customer_id = #{customerId}
<if test="customerCode != null and customerCode != ''">
and customer_code like concat('%', #{customerCode}, '%')
</if>
and biz_date &lt;= #{cutoffDate}
and ar_bill_status = #{arBillStatus}
<if test="currency != null and currency != ''">
and currency = #{currency}
</if>
order by biz_date, order_no, bill_id
</select>
<select id="selectPrcOrderBillByCustomerCutoffAndIds" resultMap="PrcOrderBillResult">
<include refid="selectPrcOrderBillVo"/>
where customer_id = #{customerId}
and biz_date &lt;= #{cutoffDate}
and ar_bill_status = #{arBillStatus}
and bill_id in
<foreach collection="billIds" item="billId" open="(" separator="," close=")">
#{billId}
</foreach>
<if test="customerCode != null and customerCode != ''">
and customer_code like concat('%', #{customerCode}, '%')
</if>
<if test="currency != null and currency != ''">
and currency = #{currency}
</if>
order by biz_date, order_no, bill_id
</select>
<insert id="insertPrcOrderBill" parameterType="PrcOrderBill">
insert into prc_order_bill (
bill_id, bill_key, order_no, tracking_no, customer_id, customer_code, customer_name,
@@ -172,7 +206,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
product_code = #{productCode},
product_name = #{productName},
country_code = #{countryCode},
country_name = #{countryName},
country_name = #{countryName},
weight = #{weight},
biz_date = #{bizDate},
tms_id = #{tmsId},
@@ -212,4 +248,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
update_time = sysdate()
where bill_id = #{billId}
</update>
<update id="claimArBillOrders">
update prc_order_bill
set ar_bill_status = #{toStatus}, updated_by = #{operator}, update_time = sysdate()
where ar_bill_status = #{fromStatus}
and bill_id in
<foreach collection="billIds" item="billId" open="(" separator="," close=")">
#{billId}
</foreach>
</update>
<update id="releaseArBillOrders">
update prc_order_bill
set ar_bill_status = #{toStatus}, updated_by = #{operator}, update_time = sysdate()
where ar_bill_status = #{fromStatus}
and bill_id in
<foreach collection="billIds" item="billId" open="(" separator="," close=")">
#{billId}
</foreach>
</update>
</mapper>