应付账单初始化

This commit is contained in:
caojia
2026-11-04 16:04:38 +08:00
committed by liuminghui
parent 04be15deab
commit 51a89b18e1
90 changed files with 15661 additions and 6 deletions
@@ -0,0 +1,128 @@
<?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.PayBillMapper">
<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
from pay_bill
<where>
<if test="billNo != null and billNo != ''">and bill_no like concat('%', #{billNo}, '%')</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 bill_id desc
</select>
<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
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
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
from pay_bill_log where bill_id = #{billId} order by log_id
</select>
<select id="selectCandidateOrders" resultType="com.bms.price.domain.PayBillOrder">
select o.bill_id as billId, o.order_no as orderNo, o.tracking_no as trackingNo, o.biz_date as bizDate,
o.pay_total as payTotal, o.currency as currency, o.pieces as pieces, o.charge_weight as chargeWeight,
o.product_name as productName, o.country_code as countryCode, o.country_name as countryName,
o.dest_postcode as destPostcode, e.air_no_old as ladingNo, e.product_floor as channelName,
e.supplier_name as supplierName,
(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) as feeText,
(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'
limit 1) as occupiedBillNo
from prc_order_bill o
left join prc_order_bill_ext e on e.bill_id = o.bill_id
<where>
<if test="orderNos != null and orderNos.size() &gt; 0">
and o.order_no in
<foreach collection="orderNos" item="no" open="(" separator="," close=")">#{no}</foreach>
</if>
<if test="beginDate != null and beginDate != ''">
and o.biz_date &gt;= #{beginDate}
</if>
<if test="endDate != null and endDate != ''">
and o.biz_date &lt; date_add(#{endDate}, interval 1 day)
</if>
<if test="ladingNos != null and ladingNos.size() &gt; 0">
and (
e.air_no_old in
<foreach collection="ladingNos" item="no" open="(" separator="," close=")">#{no}</foreach>
or e.lading_id in (
select lading_id from pay_lading where lading_no in
<foreach collection="ladingNos" item="no" open="(" separator="," close=")">#{no}</foreach>
)
)
</if>
</where>
order by o.biz_date, o.order_no
limit 2000
</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
from prc_pay_bill_fee
where bill_id in
<foreach collection="billIds" item="id" open="(" separator="," close=")">#{id}</foreach>
order by bill_id, fee_id
</select>
<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
) values (
#{billNo}, #{supplierId}, #{supplierName}, #{currency}, #{sourceType}, #{periodStart}, #{periodEnd},
#{orderCount}, #{totalAmount}, 'DRAFT', #{createBy}, sysdate(), #{remark}
)
</insert>
<update id="updatePayBillStatus">
update pay_bill
set status = #{status},
void_reason = #{voidReason},
void_by = #{voidBy},
void_time = #{voidTime},
update_by = #{updateBy},
update_time = sysdate()
where bill_id = #{billId}
</update>
<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
) 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})
</foreach>
</insert>
<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>
</mapper>