应付配置增加附加费配置,应付账单新增核销、对账、凭证、审核功能

This commit is contained in:
liuminghui
2026-11-12 18:20:32 +08:00
parent 1ba431540d
commit 6675808dfc
55 changed files with 5898 additions and 185 deletions
@@ -5,8 +5,13 @@
<select id="selectPayBillList" resultType="com.bms.price.domain.PayBill">
select bill_id as billId, bill_no as billNo, supplier_id as supplierId, supplier_name as supplierName,
currency, source_type as sourceType, period_start as periodStart, period_end as periodEnd,
order_count as orderCount, total_amount as totalAmount, status, void_reason as voidReason,
void_by as voidBy, void_time as voidTime, create_by as createBy, create_time as createTime, remark
order_count as orderCount, total_amount as totalAmount, supplier_amount as supplierAmount,
diff_amount as diffAmount, paid_amount as paidAmount, due_date as dueDate, status,
bill_kind as billKind, original_bill_id as originalBillId, void_reason as voidReason,
void_by as voidBy, void_time as voidTime, confirm_by as confirmBy, confirm_time as confirmTime,
tax_rate as taxRate, amount_net as amountNet, tax_amount as taxAmount, exchange_rate as exchangeRate,
base_amount as baseAmount, rate_date as rateDate, term_days as termDays, submit_by as submitBy,
create_by as createBy, create_time as createTime, remark
from pay_bill
<where>
<if test="billNo != null and billNo != ''">and bill_no like concat('%', #{billNo}, '%')</if>
@@ -20,22 +25,30 @@
<select id="selectPayBillById" resultType="com.bms.price.domain.PayBill">
select bill_id as billId, bill_no as billNo, supplier_id as supplierId, supplier_name as supplierName,
currency, source_type as sourceType, period_start as periodStart, period_end as periodEnd,
order_count as orderCount, total_amount as totalAmount, status, void_reason as voidReason,
void_by as voidBy, void_time as voidTime, create_by as createBy, create_time as createTime, remark
order_count as orderCount, total_amount as totalAmount, supplier_amount as supplierAmount,
diff_amount as diffAmount, paid_amount as paidAmount, due_date as dueDate, status,
bill_kind as billKind, original_bill_id as originalBillId, void_reason as voidReason,
void_by as voidBy, void_time as voidTime, confirm_by as confirmBy, confirm_time as confirmTime,
tax_rate as taxRate, amount_net as amountNet, tax_amount as taxAmount, exchange_rate as exchangeRate,
base_amount as baseAmount, rate_date as rateDate, term_days as termDays, submit_by as submitBy,
create_by as createBy, create_time as createTime, remark
from pay_bill where bill_id = #{billId}
</select>
<select id="selectLines" resultType="com.bms.price.domain.PayBillLine">
select line_id as lineId, bill_id as billId, order_bill_id as orderBillId, order_no as orderNo,
lading_no as ladingNo, lading_fee_id as ladingFeeId, fee_name as feeName, amount, currency,
price_date as priceDate, version_no as versionNo, remote_flag as remoteFlag,
density_level as densityLevel, line_source as lineSource
select line_id as lineId, bill_id as billId, fee_id as feeId, order_bill_id as orderBillId, order_no as orderNo,
lading_no as ladingNo, lading_fee_id as ladingFeeId, fee_name as feeName, fee_source as feeSource,
fee_level as feeLevel, amount, supplier_amount as supplierAmount, diff_amount as diffAmount,
diff_status as diffStatus, currency, price_date as priceDate, version_no as versionNo,
remote_flag as remoteFlag, density_level as densityLevel, line_source as lineSource
from pay_bill_line where bill_id = #{billId} order by line_id
</select>
<select id="selectLogs" resultType="com.bms.price.domain.PayBillLog">
select log_id as logId, bill_id as billId, operation_type as operationType, from_status as fromStatus,
to_status as toStatus, operation_desc as operationDesc, operator_name as operatorName, create_time as createTime
select log_id as logId, bill_id as billId, biz_type as bizType, biz_id as bizId, line_id as lineId,
fee_id as feeId, operation_type as operationType, from_status as fromStatus, to_status as toStatus,
operation_desc as operationDesc, amount_before as amountBefore, amount_after as amountAfter,
operator_name as operatorName, create_time as createTime
from pay_bill_log where bill_id = #{billId} order by log_id
</select>
@@ -48,9 +61,21 @@
(select group_concat(concat(ifnull(nullif(trim(f.fee_name), ''), ifnull(f.fee_type, '费用')), ' ', format(f.amount, 2))
order by field(f.fee_type, 'BASIC_FREIGHT', 'REGISTRATION_FEE', 'SURCHARGE', 'REFUND'), f.fee_id separator ';')
from prc_pay_bill_fee f where f.bill_id = o.bill_id and f.is_deleted = '0') as feeText,
(select count(*) from prc_pay_bill_fee f
where f.bill_id = o.bill_id and ifnull(f.is_deleted, '0') = '0') as feeCount,
(select count(*) from prc_pay_bill_fee f
where f.bill_id = o.bill_id and ifnull(f.is_deleted, '0') = '0'
and f.statement_line_id is null
and not exists (
select 1 from pay_bill_line l
inner join pay_bill b on b.bill_id = l.bill_id
where l.order_bill_id = o.bill_id
and (l.fee_id is null or l.fee_id = '')
and b.status not in ('VOID', 'RED')
)) as unbilledCount,
(select b.bill_no from pay_bill_line l
inner join pay_bill b on b.bill_id = l.bill_id
where l.order_bill_id = o.bill_id and b.status &lt;&gt; 'VOID'
where l.order_bill_id = o.bill_id and b.status not in ('VOID', 'RED')
limit 1) as occupiedBillNo
from prc_order_bill o
left join prc_order_bill_ext e on e.bill_id = o.bill_id
@@ -81,8 +106,9 @@
</select>
<select id="selectOrderFees" resultType="com.bms.price.domain.PrcPayBillFee">
select fee_id as feeId, bill_id as billId, fee_name as feeName, amount, currency, fee_source as feeSource,
source_id as sourceId, is_deleted as isDeleted
select fee_id as feeId, bill_id as billId, pay_bill_id as payBillId, fee_type as feeType, fee_name as feeName,
sc_id as scId, fee_level as feeLevel, amount, currency, fee_source as feeSource, source_id as sourceId,
is_deleted as isDeleted
from prc_pay_bill_fee
where is_deleted = '0'
and bill_id in
@@ -93,10 +119,15 @@
<insert id="insertPayBill" useGeneratedKeys="true" keyProperty="billId">
insert into pay_bill (
bill_no, supplier_id, supplier_name, currency, source_type, period_start, period_end,
order_count, total_amount, status, create_by, create_time, remark
order_count, total_amount, supplier_amount, diff_amount, paid_amount, due_date, status, bill_kind,
original_bill_id, tax_rate, amount_net, tax_amount, exchange_rate, base_amount, rate_date, term_days,
create_by, create_time, remark
) values (
#{billNo}, #{supplierId}, #{supplierName}, #{currency}, #{sourceType}, #{periodStart}, #{periodEnd},
#{orderCount}, #{totalAmount}, 'DRAFT', #{createBy}, sysdate(), #{remark}
#{orderCount}, #{totalAmount}, #{supplierAmount}, #{diffAmount}, #{paidAmount}, #{dueDate}, 'DRAFT',
ifnull(#{billKind}, 'BLUE'), #{originalBillId}, ifnull(#{taxRate}, 0), ifnull(#{amountNet}, #{totalAmount}),
ifnull(#{taxAmount}, 0), ifnull(#{exchangeRate}, 1), ifnull(#{baseAmount}, #{totalAmount}), #{rateDate},
#{termDays}, #{createBy}, sysdate(), #{remark}
)
</insert>
@@ -113,18 +144,245 @@
<insert id="insertLines">
insert into pay_bill_line (
bill_id, order_bill_id, order_no, lading_no, lading_fee_id, fee_name, amount, currency,
price_date, version_no, remote_flag, density_level, line_source
bill_id, fee_id, order_bill_id, order_no, lading_no, lading_fee_id, fee_name, fee_source, fee_level,
amount, supplier_amount, diff_amount, diff_status, currency, price_date, version_no, remote_flag,
density_level, line_source
) values
<foreach collection="list" item="item" separator=",">
(#{item.billId}, #{item.orderBillId}, #{item.orderNo}, #{item.ladingNo}, #{item.ladingFeeId},
#{item.feeName}, #{item.amount}, #{item.currency}, #{item.priceDate}, #{item.versionNo},
#{item.remoteFlag}, #{item.densityLevel}, #{item.lineSource})
(#{item.billId}, #{item.feeId}, #{item.orderBillId}, #{item.orderNo}, #{item.ladingNo}, #{item.ladingFeeId},
#{item.feeName}, #{item.feeSource}, #{item.feeLevel}, #{item.amount}, #{item.supplierAmount},
#{item.diffAmount}, ifnull(#{item.diffStatus}, 'NONE'), #{item.currency}, #{item.priceDate},
#{item.versionNo}, #{item.remoteFlag}, #{item.densityLevel}, #{item.lineSource})
</foreach>
</insert>
<insert id="insertLine" useGeneratedKeys="true" keyProperty="lineId">
insert into pay_bill_line (
bill_id, fee_id, order_bill_id, order_no, lading_no, lading_fee_id, fee_name, fee_source, fee_level,
amount, supplier_amount, diff_amount, diff_status, currency, price_date, version_no, remote_flag,
density_level, line_source
) values (
#{billId}, #{feeId}, #{orderBillId}, #{orderNo}, #{ladingNo}, #{ladingFeeId}, #{feeName}, #{feeSource},
#{feeLevel}, #{amount}, #{supplierAmount}, #{diffAmount}, ifnull(#{diffStatus}, 'NONE'), #{currency},
#{priceDate}, #{versionNo}, #{remoteFlag}, #{densityLevel}, #{lineSource}
)
</insert>
<update id="bindFeeLine">
update prc_pay_bill_fee
set statement_line_id = #{lineId}
where fee_id = #{feeId}
and statement_line_id is null
and ifnull(is_deleted, '0') = '0'
</update>
<update id="clearFeeLine">
update prc_pay_bill_fee set statement_line_id = null where statement_line_id = #{lineId}
</update>
<update id="clearFeeLines">
update prc_pay_bill_fee f
inner join pay_bill_line l on l.line_id = f.statement_line_id
set f.statement_line_id = null
where l.bill_id = #{billId}
</update>
<update id="updatePayBillMoney">
update pay_bill
set total_amount = #{totalAmount},
supplier_amount = #{supplierAmount},
diff_amount = #{diffAmount},
paid_amount = #{paidAmount},
order_count = #{orderCount},
status = #{status},
confirm_by = #{confirmBy},
confirm_time = #{confirmTime},
tax_rate = ifnull(#{taxRate}, 0),
amount_net = ifnull(#{amountNet}, #{totalAmount}),
tax_amount = ifnull(#{taxAmount}, 0),
exchange_rate = ifnull(#{exchangeRate}, 1),
base_amount = ifnull(#{baseAmount}, #{totalAmount}),
rate_date = #{rateDate},
term_days = #{termDays},
update_by = #{updateBy},
update_time = sysdate()
where bill_id = #{billId}
</update>
<update id="updateLineAmount">
update pay_bill_line
set supplier_amount = #{supplierAmount},
diff_amount = #{diffAmount},
diff_status = #{diffStatus}
where line_id = #{lineId}
and bill_id = #{billId}
</update>
<delete id="deleteOpenDiff">
delete from pay_bill_diff where line_id = #{lineId} and handle_type = 'OPEN'
</delete>
<delete id="deleteLine">
delete from pay_bill_line where bill_id = #{billId} and line_id = #{lineId}
</delete>
<select id="selectFreeFees" resultType="com.bms.price.domain.PrcPayBillFee">
select f.fee_id as feeId, f.bill_id as billId, f.pay_bill_id as payBillId, f.fee_type as feeType,
f.fee_name as feeName, f.sc_id as scId, f.fee_level as feeLevel, f.amount, f.currency,
f.fee_source as feeSource, f.source_id as sourceId, f.settle_supplier_id as settleSupplierId,
f.settle_supplier_name as settleSupplierName
from prc_pay_bill_fee f
where ifnull(f.is_deleted, '0') = '0'
and f.statement_line_id is null
and f.bill_id in
<foreach collection="billIds" item="id" open="(" separator="," close=")">#{id}</foreach>
and not exists (
select 1 from pay_bill_line l
inner join pay_bill b on b.bill_id = l.bill_id
where l.order_bill_id = f.bill_id
and (l.fee_id is null or l.fee_id = '')
and b.status not in ('VOID', 'RED')
)
order by f.bill_id, f.fee_id
</select>
<select id="countCalcFees" resultType="int">
select count(*)
from prc_pay_bill_fee
where bill_id = #{billId}
and ifnull(is_deleted, '0') = '0'
and fee_source = 'CALC'
</select>
<select id="selectDiffs" resultType="com.bms.price.domain.PayBillDiff">
select diff_id as diffId, bill_id as billId, line_id as lineId, fee_id as feeId, our_amount as ourAmount,
supplier_amount as supplierAmount, diff_amount as diffAmount, reason, handle_type as handleType,
adjust_fee_id as adjustFeeId, create_by as createBy, create_time as createTime
from pay_bill_diff where bill_id = #{billId} order by diff_id
</select>
<select id="selectFiles" resultType="com.bms.price.domain.PayBillFile">
select file_id as fileId, bill_id as billId, file_type as fileType, invoice_no as invoiceNo,
invoice_date as invoiceDate, amount, tax_amount as taxAmount, amount_net as amountNet,
seller_name as sellerName, matched_amount as matchedAmount, currency, file_name as fileName,
file_url as fileUrl, deleted, create_by as createBy, create_time as createTime
from pay_bill_file
where bill_id = #{billId} and deleted = '0'
order by file_id
</select>
<select id="selectApprovals" resultType="com.bms.price.domain.PayBillApproval">
select approval_id as approvalId, bill_id as billId, action, opinion, operator_name as operatorName,
create_time as createTime
from pay_bill_approval where bill_id = #{billId} order by approval_id
</select>
<select id="selectLine" resultType="com.bms.price.domain.PayBillLine">
select line_id as lineId, bill_id as billId, fee_id as feeId, order_bill_id as orderBillId, order_no as orderNo,
lading_no as ladingNo, fee_name as feeName, fee_source as feeSource, fee_level as feeLevel, amount,
supplier_amount as supplierAmount, diff_amount as diffAmount, diff_status as diffStatus, currency,
line_source as lineSource
from pay_bill_line where line_id = #{lineId}
</select>
<select id="selectOpenDiff" resultType="com.bms.price.domain.PayBillDiff">
select diff_id as diffId, bill_id as billId, line_id as lineId, fee_id as feeId, our_amount as ourAmount,
supplier_amount as supplierAmount, diff_amount as diffAmount, reason, handle_type as handleType,
adjust_fee_id as adjustFeeId
from pay_bill_diff
where line_id = #{lineId} and handle_type = 'OPEN'
order by diff_id desc
limit 1
</select>
<insert id="insertDiff" useGeneratedKeys="true" keyProperty="diffId">
insert into pay_bill_diff (
bill_id, line_id, fee_id, our_amount, supplier_amount, diff_amount, reason, handle_type, adjust_fee_id,
create_by, create_time
) values (
#{billId}, #{lineId}, #{feeId}, #{ourAmount}, #{supplierAmount}, #{diffAmount}, #{reason}, #{handleType},
#{adjustFeeId}, #{createBy}, sysdate()
)
</insert>
<update id="updateDiff">
update pay_bill_diff
set our_amount = #{ourAmount},
supplier_amount = #{supplierAmount},
diff_amount = #{diffAmount},
reason = #{reason},
handle_type = #{handleType},
adjust_fee_id = #{adjustFeeId}
where diff_id = #{diffId}
</update>
<delete id="deleteDiffsByLine">
delete from pay_bill_diff where line_id = #{lineId}
</delete>
<insert id="insertFile" useGeneratedKeys="true" keyProperty="fileId">
insert into pay_bill_file (
bill_id, file_type, invoice_no, invoice_date, amount, tax_amount, amount_net, seller_name, matched_amount,
currency, file_name, file_url, deleted, create_by, create_time
) values (
#{billId}, #{fileType}, #{invoiceNo}, #{invoiceDate}, #{amount}, #{taxAmount}, #{amountNet}, #{sellerName},
ifnull(#{matchedAmount}, 0), #{currency}, #{fileName}, #{fileUrl}, '0', #{createBy}, sysdate()
)
</insert>
<select id="selectFile" resultType="com.bms.price.domain.PayBillFile">
select file_id as fileId, bill_id as billId, file_type as fileType, invoice_no as invoiceNo,
file_name as fileName, file_url as fileUrl, deleted
from pay_bill_file where file_id = #{fileId}
</select>
<update id="markFileDeleted">
update pay_bill_file set deleted = '1' where file_id = #{fileId}
</update>
<insert id="insertApproval">
insert into pay_bill_approval (bill_id, action, opinion, operator_name, create_time)
values (#{billId}, #{action}, #{opinion}, #{operatorName}, sysdate())
</insert>
<select id="selectFileList" resultType="com.bms.price.domain.PayBillFile">
select f.file_id as fileId, f.bill_id as billId, b.bill_no as billNo, b.supplier_name as supplierName,
f.file_type as fileType, f.invoice_no as invoiceNo, f.invoice_date as invoiceDate, f.amount,
f.tax_amount as taxAmount, f.file_name as fileName, f.file_url as fileUrl, f.create_by as createBy,
f.create_time as createTime
from pay_bill_file f
inner join pay_bill b on b.bill_id = f.bill_id
where f.deleted = '0'
<if test="billNo != null and billNo != ''">and b.bill_no like concat('%', #{billNo}, '%')</if>
<if test="supplierName != null and supplierName != ''">and b.supplier_name like concat('%', #{supplierName}, '%')</if>
<if test="invoiceNo != null and invoiceNo != ''">and f.invoice_no like concat('%', #{invoiceNo}, '%')</if>
<if test="fileType != null and fileType != ''">and f.file_type = #{fileType}</if>
order by f.file_id desc
</select>
<select id="countActiveFiles" resultType="int">
select count(*) from pay_bill_file where bill_id = #{billId} and deleted = '0'
</select>
<select id="selectOpenBills" resultType="com.bms.price.domain.PayPaymentAlloc">
select bill_id as billId, bill_no as billNo, currency, supplier_id as supplierId, supplier_name as supplierName,
(total_amount - ifnull(paid_amount, 0)) as openAmount
from pay_bill
where supplier_id = #{supplierId}
and currency = #{currency}
and status in ('CONFIRMED', 'PARTIAL')
and ifnull(bill_kind, 'BLUE') &lt;&gt; 'RED'
and total_amount - ifnull(paid_amount, 0) &gt; 0
order by bill_id
</select>
<insert id="insertLog">
insert into pay_bill_log (bill_id, operation_type, from_status, to_status, operation_desc, operator_name, create_time)
values (#{billId}, #{operationType}, #{fromStatus}, #{toStatus}, #{operationDesc}, #{operatorName}, sysdate())
insert into pay_bill_log (
bill_id, biz_type, biz_id, line_id, fee_id, operation_type, from_status, to_status, operation_desc,
amount_before, amount_after, operator_name, create_time
) values (
#{billId}, #{bizType}, #{bizId}, #{lineId}, #{feeId}, #{operationType}, #{fromStatus}, #{toStatus},
#{operationDesc}, #{amountBefore}, #{amountAfter}, #{operatorName}, sysdate()
)
</insert>
</mapper>
@@ -0,0 +1,71 @@
<?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.price.mapper.PayFinanceMapper">
<update id="updateFinanceHead">
update pay_bill
set tax_rate = #{taxRate},
exchange_rate = #{exchangeRate},
rate_date = #{rateDate},
update_time = sysdate()
where bill_id = #{billId}
</update>
<update id="updateSubmitBy">
update pay_bill set submit_by = #{submitBy} where bill_id = #{billId}
</update>
<update id="updateLineTax">
update pay_bill_line
set tax_rate = #{taxRate},
amount_net = round(amount / (1 + #{taxRate}), 4),
tax_amount = round(amount - amount / (1 + #{taxRate}), 4),
base_amount = round(amount * #{exchangeRate}, 4)
where bill_id = #{billId}
</update>
<select id="countDuplicateInvoice" resultType="int">
select count(*)
from pay_bill_file f
inner join pay_bill b on b.bill_id = f.bill_id
where f.deleted = '0'
and f.file_type = 'INVOICE'
and f.invoice_no = #{invoiceNo}
and b.supplier_id = #{supplierId}
and b.status &lt;&gt; 'VOID'
<if test="fileId != null">and f.file_id &lt;&gt; #{fileId}</if>
</select>
<update id="markInvoiceMatched">
update pay_bill_file
set matched_amount = ifnull(amount, 0)
where bill_id = #{billId}
and deleted = '0'
and file_type = 'INVOICE'
</update>
<select id="selectLadingSupplier" resultType="long">
select supplier_id
from pay_lading
where lading_no = #{ladingNo}
and supplier_id is not null
limit 1
</select>
<update id="stampFee">
update prc_pay_bill_fee
set settle_supplier_id = #{supplierId},
settle_supplier_name = #{supplierName}
where fee_id = #{feeId}
</update>
<update id="stampCalc">
update prc_pay_bill_fee
set settle_supplier_id = #{supplierId},
settle_supplier_name = #{supplierName}
where bill_id = #{billId}
and ifnull(is_deleted, '0') = '0'
and statement_line_id is null
and (fee_source is null or fee_source = '' or fee_source = 'CALC')
</update>
</mapper>
@@ -0,0 +1,71 @@
<?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.price.mapper.PayPaymentMapper">
<select id="selectPayPaymentList" resultType="com.bms.price.domain.PayPayment">
select payment_id as paymentId, payment_no as paymentNo, supplier_id as supplierId, supplier_name as supplierName,
currency, pay_date as payDate, pay_method as payMethod, bank_account as bankAccount, amount, bank_fee as bankFee,
exchange_rate as exchangeRate, base_amount as baseAmount, alloc_amount as allocAmount,
status, remark, create_by as createBy, create_time as createTime, confirm_by as confirmBy, confirm_time as confirmTime
from pay_payment
<where>
<if test="paymentNo != null and paymentNo != ''">and payment_no like concat('%', #{paymentNo}, '%')</if>
<if test="supplierName != null and supplierName != ''">and supplier_name like concat('%', #{supplierName}, '%')</if>
<if test="status != null and status != ''">and status = #{status}</if>
<if test="currency != null and currency != ''">and currency = #{currency}</if>
</where>
order by payment_id desc
</select>
<select id="selectPayPaymentById" resultType="com.bms.price.domain.PayPayment">
select payment_id as paymentId, payment_no as paymentNo, supplier_id as supplierId, supplier_name as supplierName,
currency, pay_date as payDate, pay_method as payMethod, bank_account as bankAccount, amount, bank_fee as bankFee,
exchange_rate as exchangeRate, base_amount as baseAmount, alloc_amount as allocAmount,
status, remark, create_by as createBy, create_time as createTime, confirm_by as confirmBy, confirm_time as confirmTime
from pay_payment where payment_id = #{paymentId}
</select>
<select id="selectAllocs" resultType="com.bms.price.domain.PayPaymentAlloc">
select a.alloc_id as allocId, a.payment_id as paymentId, a.bill_id as billId, b.bill_no as billNo,
a.alloc_amount as allocAmount, a.alloc_status as allocStatus, b.currency
from pay_payment_alloc a
left join pay_bill b on b.bill_id = a.bill_id
where a.payment_id = #{paymentId}
order by a.alloc_id
</select>
<insert id="insertPayPayment" useGeneratedKeys="true" keyProperty="paymentId">
insert into pay_payment (
payment_no, supplier_id, supplier_name, currency, pay_date, pay_method, bank_account, amount, bank_fee,
exchange_rate, status, remark, create_by, create_time
) values (
#{paymentNo}, #{supplierId}, #{supplierName}, #{currency}, #{payDate}, #{payMethod}, #{bankAccount},
#{amount}, #{bankFee}, ifnull(#{exchangeRate}, 1), 'DRAFT', #{remark}, #{createBy}, sysdate()
)
</insert>
<insert id="insertAlloc">
insert into pay_payment_alloc (payment_id, bill_id, alloc_amount, alloc_status)
values (#{paymentId}, #{billId}, #{allocAmount}, 'ACTIVE')
</insert>
<update id="updatePayPaymentStatus">
update pay_payment
set status = #{status},
confirm_by = #{confirmBy},
confirm_time = #{confirmTime},
exchange_rate = ifnull(#{exchangeRate}, exchange_rate),
base_amount = ifnull(#{baseAmount}, base_amount),
alloc_amount = ifnull(#{allocAmount}, alloc_amount)
where payment_id = #{paymentId}
</update>
<update id="reverseAlloc">
update pay_payment_alloc
set alloc_status = 'REVERSED',
reverse_by = #{reverseBy},
reverse_time = sysdate()
where alloc_id = #{allocId}
and alloc_status = 'ACTIVE'
</update>
</mapper>
@@ -155,8 +155,8 @@
</select>
<select id="selectLinesByGroups" resultType="com.bms.price.domain.PayPostcodeLine">
select line_id as lineId, group_id as groupId, region_name as regionName, zone_name as zoneName,
postcode, postcode_end as postcodeEnd
select line_id as lineId, group_id as groupId, country_name as countryName, country_code as countryCode,
region_name as regionName, zone_name as zoneName, postcode, postcode_end as postcodeEnd
from pay_postcode_line
where group_id in
<foreach collection="groupIds" item="id" open="(" separator="," close=")">#{id}</foreach>
@@ -0,0 +1,46 @@
<?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.price.mapper.PaySurchargeRuleMapper">
<select id="selectByProduct" resultType="com.bms.price.domain.PaySurchargeRule">
select rule_id as ruleId, product_id as productId, term_id as termId, version_no as versionNo,
calc_rule as calcRule, enabled, calc_param as calcParam, rule_detail as ruleDetail, postcode_param as postcodeParam,
zone_name as zoneName, weight_min as weightMin, weight_max as weightMax, sort_no as sortNo
from pay_surcharge_rule
where product_id = #{productId}
and term_id = #{termId}
order by calc_rule, sort_no, rule_id
</select>
<delete id="deleteByTerm">
delete from pay_surcharge_rule
where product_id = #{productId}
and term_id = #{termId}
</delete>
<insert id="insertBatch">
insert into pay_surcharge_rule (
product_id, term_id, version_no, calc_rule, enabled, calc_param, rule_detail, postcode_param,
zone_name, weight_min, weight_max, sort_no, create_by, create_time, update_by, update_time
) values
<foreach collection="list" item="row" separator=",">
(#{row.productId}, #{row.termId}, ifnull(#{row.versionNo}, 1), #{row.calcRule}, ifnull(#{row.enabled}, '1'),
#{row.calcParam}, #{row.ruleDetail}, #{row.postcodeParam}, #{row.zoneName}, #{row.weightMin}, #{row.weightMax}, ifnull(#{row.sortNo}, 0),
#{row.createBy}, sysdate(), #{row.updateBy}, sysdate())
</foreach>
</insert>
<select id="selectPreviousVersion" resultType="com.bms.price.domain.PaySurchargeRule">
select v.product_id as productId, t.term_id as termId, ifnull(v.version_no, 1) as versionNo
from pay_product cur
join pay_product v on v.dict_value = cur.dict_value
and v.dict_value is not null and v.dict_value &lt;&gt; ''
and v.product_id &lt;&gt; cur.product_id
and (v.channel_id is null or v.channel_id = '')
and ifnull(v.version_no, 1) &lt; ifnull(cur.version_no, 1)
join pay_product_term t on t.product_id = v.product_id and t.price_set_id is null
where cur.product_id = #{productId}
order by ifnull(v.version_no, 1) desc, t.term_id desc
limit 1
</select>
</mapper>