调整应付配置和应付列表订单的费用重算

This commit is contained in:
liuminghui
2026-11-17 17:47:01 +08:00
parent 9483bb4899
commit 6b2b205083
45 changed files with 1448 additions and 2131 deletions
@@ -13,7 +13,7 @@
p.product_floor as channelName,
p.charge_weight as chargeWeight,
ifnull(b.pay_total, p.pay_total) as payTotal,
p.currency as currency,
ifnull(nullif(trim(b.currency), ''), 'CNY') as currency,
b.pay_calc_status as payCalcStatus,
b.pay_calc_msg as payCalcMsg,
b.update_by as updateBy,
@@ -1,35 +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.bms.price.mapper.PaySurchargeRuleLogMapper">
<select id="selectByTerm" resultType="com.bms.price.domain.PaySurchargeRuleLog">
select log_id as logId, product_id as productId, term_id as termId, version_no as versionNo,
operation_type as operationType, rule_key as ruleKey, change_content as changeContent,
create_by as createBy, create_time as createTime
from pay_surcharge_rule_log
where product_id = #{productId}
and term_id = #{termId}
order by log_id desc
</select>
<select id="selectByProductIds" resultType="com.bms.price.domain.PaySurchargeRuleLog">
select log_id as logId, product_id as productId, term_id as termId, version_no as versionNo,
operation_type as operationType, rule_key as ruleKey, change_content as changeContent,
create_by as createBy, create_time as createTime
from pay_surcharge_rule_log
where product_id in
<foreach collection="productIds" item="id" open="(" separator="," close=")">#{id}</foreach>
order by log_id desc
</select>
<insert id="insertBatch">
insert into pay_surcharge_rule_log (
product_id, term_id, version_no, operation_type, rule_key, change_content, create_by, create_time
) values
<foreach collection="list" item="row" separator=",">
(#{row.productId}, #{row.termId}, #{row.versionNo}, #{row.operationType}, #{row.ruleKey},
#{row.changeContent}, #{row.createBy}, sysdate())
</foreach>
</insert>
</mapper>
@@ -1,47 +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.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>
<select id="selectByProductId" 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}
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>
<delete id="deleteByProductIds">
delete from pay_surcharge_rule
where product_id in
<foreach collection="productIds" item="id" open="(" separator="," close=")">#{id}</foreach>
</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>
</mapper>
@@ -953,7 +953,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<foreach collection="billIds" item="billId" open="(" separator="," close=")">#{billId}</foreach>
group by bill_id
) s on s.bill_id = o.bill_id
set o.pay_total = ifnull(s.total, 0),
set o.pay_total = round(ifnull(s.total, 0), 2),
o.update_time = sysdate()
where o.bill_id in
<foreach collection="billIds" item="billId" open="(" separator="," close=")">#{billId}</foreach>
@@ -46,11 +46,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join sys_dict_data dict on dict.dict_type = 'bms_fee_type' and dict.dict_value = f.fee_type
</sql>
<sql id="feeUserName">
(
select case
when nullif(trim(u.nick_name), '') is not null then u.nick_name
else u.user_name
end
from sys_user u
where u.del_flag = '0'
and (
(${column} regexp '^[0-9]+$' and u.user_id = cast(${column} as unsigned))
or (ifnull(${column}, '') not regexp '^[0-9]+$' and u.user_name = ${column})
)
limit 1
)
</sql>
<select id="selectByBillId" parameterType="Long" resultMap="PrcPayBillFeeResult">
select f.fee_id, f.bill_id, f.pay_bill_id, f.fee_type, <include refid="feeItemName"/> as fee_name,
f.sc_id, f.fee_level, f.amount, f.currency, f.round_mode, f.remark,
f.fee_source, f.source_id, f.is_deleted, f.statement_line_id,
f.create_by, f.create_time, f.update_by, f.update_time
ifnull(<include refid="feeUserName"><property name="column" value="f.create_by"/></include>, f.create_by) as create_by,
f.create_time,
ifnull(<include refid="feeUserName"><property name="column" value="f.update_by"/></include>, f.update_by) as update_by,
f.update_time
from prc_pay_bill_fee f
<include refid="feeItemJoin"/>
where f.bill_id = #{billId}
@@ -62,7 +81,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select f.fee_id, f.bill_id, f.pay_bill_id, f.fee_type, <include refid="feeItemName"/> as fee_name,
f.sc_id, f.fee_level, f.amount, f.currency, f.round_mode, f.remark,
f.fee_source, f.source_id, f.is_deleted, f.statement_line_id,
f.create_by, f.create_time, f.update_by, f.update_time
ifnull(<include refid="feeUserName"><property name="column" value="f.create_by"/></include>, f.create_by) as create_by,
f.create_time,
ifnull(<include refid="feeUserName"><property name="column" value="f.update_by"/></include>, f.update_by) as update_by,
f.update_time
from prc_pay_bill_fee f
<include refid="feeItemJoin"/>
where f.fee_id = #{feeId}
@@ -92,22 +114,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertPrcPayBillFee" parameterType="PrcPayBillFee">
insert into prc_pay_bill_fee (
fee_id, bill_id, pay_bill_id, fee_type, fee_name, sc_id, fee_level, amount, currency, round_mode, remark,
fee_source, source_id, is_deleted, create_time
fee_source, source_id, is_deleted, create_by, create_time, update_by, update_time
) values (
#{feeId}, #{billId}, #{payBillId}, #{feeType}, #{feeName}, #{scId}, #{feeLevel}, #{amount}, #{currency}, #{roundMode}, #{remark},
ifnull(#{feeSource}, 'CALC'), #{sourceId}, ifnull(#{isDeleted}, '0'), sysdate()
ifnull(#{feeSource}, 'CALC'), #{sourceId}, ifnull(#{isDeleted}, '0'), #{createBy}, sysdate(), #{updateBy}, sysdate()
)
</insert>
<insert id="insertBatch" parameterType="java.util.List">
insert into prc_pay_bill_fee (
fee_id, bill_id, pay_bill_id, fee_type, fee_name, sc_id, fee_level, amount, currency, round_mode, remark,
fee_source, source_id, is_deleted, create_time
fee_source, source_id, is_deleted, create_by, create_time, update_by, update_time
) values
<foreach collection="list" item="item" separator=",">
(#{item.feeId}, #{item.billId}, #{item.payBillId}, #{item.feeType}, #{item.feeName}, #{item.scId}, #{item.feeLevel},
#{item.amount}, #{item.currency}, #{item.roundMode}, #{item.remark}, ifnull(#{item.feeSource}, 'CALC'),
#{item.sourceId}, ifnull(#{item.isDeleted}, '0'), sysdate())
#{item.sourceId}, ifnull(#{item.isDeleted}, '0'), #{item.createBy}, sysdate(), #{item.updateBy}, sysdate())
</foreach>
</insert>
@@ -123,7 +123,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<foreach collection="billIds" item="billId" open="(" separator="," close=")">#{billId}</foreach>
group by bill_id
) s on s.bill_id = b.bill_id
set b.pay_total = ifnull(s.total, 0),
set b.pay_total = round(ifnull(s.total, 0), 2),
b.currency = case
when not exists (
select 1 from prc_pay_bill_fee fx
where fx.bill_id = b.bill_id
and ifnull(fx.is_deleted, '0') = '0'
and upper(ifnull(fx.currency, 'CNY')) not in ('CNY', 'RMB')
) then 'CNY'
else b.currency
end,
b.update_time = sysdate()
where b.bill_id in
<foreach collection="billIds" item="billId" open="(" separator="," close=")">#{billId}</foreach>
@@ -5,7 +5,7 @@
<select id="selectPendingFees" resultType="com.bms.price.airbill.domain.SrvBillAirAllocFee">
select f.id, f.bill_code as billCode, a.guid as ladingId, f.fee_level as feeLevel,
f.bill_fee_status as billFeeStatus, f.fee_type as feeType, sc.sc_name as feeName, f.price, f.currency,
f.alloc_dim as allocDim
f.create_time as createTime, f.alloc_dim as allocDim
from srv_bill_air_fee f
left join srv_bill_air a on a.bill_code = f.bill_code
left join prc_surcharge sc on sc.sc_id = f.sc_id and ifnull(sc.is_del, '0') = '0'