This commit is contained in:
luojiaquan
2026-09-30 16:00:12 +08:00
7 changed files with 51 additions and 47 deletions
@@ -34,6 +34,10 @@ public class ArBillDetail implements Serializable {
private BigDecimal actualWeight; private BigDecimal actualWeight;
private BigDecimal volumeWeight; private BigDecimal volumeWeight;
private BigDecimal chargeWeight; private BigDecimal chargeWeight;
/** 订单计费时命中的运费单价快照,对应 prc_order_bill.freight_rate。 */
private BigDecimal freightRate;
/** 订单计费时的标准处理费快照,对应 prc_order_bill.registration_fee。 */
private BigDecimal registrationFee;
private BigDecimal pkgLength; private BigDecimal pkgLength;
private BigDecimal pkgWidth; private BigDecimal pkgWidth;
private BigDecimal pkgHeight; private BigDecimal pkgHeight;
@@ -1142,6 +1142,8 @@ public class ArBillServiceImpl implements IArBillService {
detail.setActualWeight(source.getActualWeight()); detail.setActualWeight(source.getActualWeight());
detail.setVolumeWeight(source.getVolumeWeight()); detail.setVolumeWeight(source.getVolumeWeight());
detail.setChargeWeight(source.getChargeWeight() == null ? source.getWeight() : source.getChargeWeight()); detail.setChargeWeight(source.getChargeWeight() == null ? source.getWeight() : source.getChargeWeight());
detail.setFreightRate(source.getFreightRate());
detail.setRegistrationFee(source.getRegistrationFee());
detail.setPkgLength(source.getPkgLength()); detail.setPkgLength(source.getPkgLength());
detail.setPkgWidth(source.getPkgWidth()); detail.setPkgWidth(source.getPkgWidth());
detail.setPkgHeight(source.getPkgHeight()); detail.setPkgHeight(source.getPkgHeight());
@@ -1614,42 +1616,11 @@ public class ArBillServiceImpl implements IArBillService {
} }
private BigDecimal exportUnitPrice(ArBillDetail detail) { private BigDecimal exportUnitPrice(ArBillDetail detail) {
BigDecimal direct = firstFeeUnitPrice(detail.getFees()); return detail == null ? null : detail.getFreightRate();
if (direct != null) {
return direct;
}
BigDecimal freight = feeAmount(detail, "BASIC_FREIGHT");
if (freight == null || detail.getChargeWeight() == null || detail.getChargeWeight().compareTo(BigDecimal.ZERO) <= 0) {
return null;
}
return freight.divide(detail.getChargeWeight(), 4, java.math.RoundingMode.HALF_UP);
}
private BigDecimal firstFeeUnitPrice(List<ArBillDetailFee> fees) {
if (fees == null) {
return null;
}
for (ArBillDetailFee fee : fees) {
if (fee.getUnitPrice() != null) {
return fee.getUnitPrice();
}
}
return null;
} }
private BigDecimal exportProcessingFee(ArBillDetail detail) { private BigDecimal exportProcessingFee(ArBillDetail detail) {
BigDecimal total = BigDecimal.ZERO; return detail == null ? null : detail.getRegistrationFee();
boolean found = false;
if (detail.getFees() != null) {
for (ArBillDetailFee fee : detail.getFees()) {
String name = fee.getFeeName() == null ? "" : fee.getFeeName();
if ("REGISTRATION_FEE".equalsIgnoreCase(fee.getFeeType()) || name.contains("处理费")) {
total = total.add(nvl(fee.getAmount()));
found = true;
}
}
}
return found ? total : null;
} }
private String exportFormula(ArBillDetail detail) { private String exportFormula(ArBillDetail detail) {
@@ -1586,10 +1586,17 @@ public class BmsProductServiceImpl implements IBmsProductService
{ {
return null; return null;
} }
s = s.trim();
// Excel NA markers: / 、- 、— 、N/A
if ("/".equals(s) || "-".equals(s) || "\u2014".equals(s) || "\uff0d".equals(s)
|| "N/A".equalsIgnoreCase(s) || "NA".equalsIgnoreCase(s))
{
return null;
}
// strip currency / unit suffixes: 56、56元、56 RMB // strip currency / unit suffixes: 56、56元、56 RMB
s = s.replace(",", "").replace("\uffe5", "").replace("\u5143", "") s = s.replace(",", "").replace("\uffe5", "").replace("\u5143", "")
.replace("RMB", "").replace("rmb", "").trim(); .replace("RMB", "").replace("rmb", "").trim();
if (s.isEmpty()) if (s.isEmpty() || "/".equals(s))
{ {
return null; return null;
} }
@@ -1031,7 +1031,12 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
} }
continue; continue;
} }
// New band: always insert weight/country row (fees may be null; editable later). // New band: skip when Excel has no usable fee (blank / slash = no service).
if (freight == null && registration == null)
{
skippedFee++;
continue;
}
PrcPriceSetDetail created = buildDetailFromImportRow( PrcPriceSetDetail created = buildDetailFromImportRow(
priceSetId, psvId, productCode, productName, row, freight, registration); priceSetId, psvId, productCode, productName, row, freight, registration);
created.setPspId(pspId); created.setPspId(pspId);
@@ -1041,10 +1046,6 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
{ {
touched.add(created.getPsdId()); touched.add(created.getPsdId());
} }
if (freight == null && registration == null)
{
skippedFee++;
}
inserted++; inserted++;
} }
} }
@@ -22,6 +22,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="actualWeight" column="actual_weight"/> <result property="actualWeight" column="actual_weight"/>
<result property="volumeWeight" column="volume_weight"/> <result property="volumeWeight" column="volume_weight"/>
<result property="chargeWeight" column="charge_weight"/> <result property="chargeWeight" column="charge_weight"/>
<result property="freightRate" column="freight_rate"/>
<result property="registrationFee" column="registration_fee"/>
<result property="pkgLength" column="pkg_length"/> <result property="pkgLength" column="pkg_length"/>
<result property="pkgWidth" column="pkg_width"/> <result property="pkgWidth" column="pkg_width"/>
<result property="pkgHeight" column="pkg_height"/> <result property="pkgHeight" column="pkg_height"/>
@@ -35,7 +37,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectByBillId" parameterType="long" resultMap="ArBillDetailResult"> <select id="selectByBillId" parameterType="long" resultMap="ArBillDetailResult">
select detail_id, ar_bill_id, prc_order_bill_id, detail_no, order_no, tracking_no, transfer_no, receive_time, select detail_id, ar_bill_id, prc_order_bill_id, detail_no, order_no, tracking_no, transfer_no, receive_time,
product_code, product_name, goods_description, country_code, country_name, dest_postcode, product_code, product_name, goods_description, country_code, country_name, dest_postcode,
actual_weight, volume_weight, charge_weight, pkg_length, pkg_width, pkg_height, actual_weight, volume_weight, charge_weight, freight_rate, registration_fee, pkg_length, pkg_width, pkg_height,
currency, total_amount, remark, create_by, create_time currency, total_amount, remark, create_by, create_time
from ar_bill_detail where ar_bill_id = #{arBillId} order by detail_no from ar_bill_detail where ar_bill_id = #{arBillId} order by detail_no
</select> </select>
@@ -43,7 +45,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectByBillIdAndSourceIds" resultMap="ArBillDetailResult"> <select id="selectByBillIdAndSourceIds" resultMap="ArBillDetailResult">
select detail_id, ar_bill_id, prc_order_bill_id, detail_no, order_no, tracking_no, transfer_no, receive_time, select detail_id, ar_bill_id, prc_order_bill_id, detail_no, order_no, tracking_no, transfer_no, receive_time,
product_code, product_name, goods_description, country_code, country_name, dest_postcode, product_code, product_name, goods_description, country_code, country_name, dest_postcode,
actual_weight, volume_weight, charge_weight, pkg_length, pkg_width, pkg_height, actual_weight, volume_weight, charge_weight, freight_rate, registration_fee, pkg_length, pkg_width, pkg_height,
currency, total_amount, remark, create_by, create_time currency, total_amount, remark, create_by, create_time
from ar_bill_detail from ar_bill_detail
where ar_bill_id = #{arBillId} where ar_bill_id = #{arBillId}
@@ -79,7 +81,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectByBillIdWithFees" parameterType="long" resultMap="ArBillDetailWithFeesResult"> <select id="selectByBillIdWithFees" parameterType="long" resultMap="ArBillDetailWithFeesResult">
select d.detail_id, d.ar_bill_id, d.prc_order_bill_id, d.detail_no, d.order_no, d.tracking_no, d.transfer_no, d.receive_time, select d.detail_id, d.ar_bill_id, d.prc_order_bill_id, d.detail_no, d.order_no, d.tracking_no, d.transfer_no, d.receive_time,
d.product_code, d.product_name, d.goods_description, d.country_code, d.country_name, d.dest_postcode, 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.actual_weight, d.volume_weight, d.charge_weight, d.freight_rate, d.registration_fee, d.pkg_length, d.pkg_width, d.pkg_height,
d.currency, d.total_amount, d.remark, d.create_by, d.create_time, 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.detail_fee_id as fee_detail_id, f.detail_id as fee_parent_detail_id,
f.prc_income_bill_fee_id as fee_prc_income_bill_fee_id, f.prc_income_bill_fee_id as fee_prc_income_bill_fee_id,
@@ -97,7 +99,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectExportPage" resultMap="ArBillDetailResult"> <select id="selectExportPage" resultMap="ArBillDetailResult">
select detail_id, ar_bill_id, prc_order_bill_id, detail_no, order_no, tracking_no, transfer_no, receive_time, select detail_id, ar_bill_id, prc_order_bill_id, detail_no, order_no, tracking_no, transfer_no, receive_time,
product_code, product_name, goods_description, country_code, country_name, dest_postcode, product_code, product_name, goods_description, country_code, country_name, dest_postcode,
actual_weight, volume_weight, charge_weight, pkg_length, pkg_width, pkg_height, actual_weight, volume_weight, charge_weight, freight_rate, registration_fee, pkg_length, pkg_width, pkg_height,
currency, total_amount, remark, create_by, create_time currency, total_amount, remark, create_by, create_time
from ar_bill_detail from ar_bill_detail
where ar_bill_id = #{arBillId} and detail_no &gt; #{lastDetailNo} where ar_bill_id = #{arBillId} and detail_no &gt; #{lastDetailNo}
@@ -110,12 +112,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
product_code, product_code,
product_name, goods_description, country_code, country_name, dest_postcode, product_name, goods_description, country_code, country_name, dest_postcode,
actual_weight, actual_weight,
volume_weight, charge_weight, pkg_length, pkg_width, pkg_height, currency, volume_weight, charge_weight, freight_rate, registration_fee, pkg_length, pkg_width, pkg_height, currency,
total_amount, total_amount,
remark, create_by, create_time) remark, create_by, create_time)
values (#{arBillId}, #{prcOrderBillId}, #{detailNo}, #{orderNo}, #{trackingNo}, #{transferNo}, #{receiveTime}, values (#{arBillId}, #{prcOrderBillId}, #{detailNo}, #{orderNo}, #{trackingNo}, #{transferNo}, #{receiveTime},
#{productCode}, #{productName}, #{goodsDescription}, #{countryCode}, #{countryName}, #{productCode}, #{productName}, #{goodsDescription}, #{countryCode}, #{countryName},
#{destPostcode}, #{actualWeight}, #{volumeWeight}, #{chargeWeight}, #{pkgLength}, #{pkgWidth}, #{destPostcode}, #{actualWeight}, #{volumeWeight}, #{chargeWeight}, #{freightRate}, #{registrationFee}, #{pkgLength}, #{pkgWidth},
#{pkgHeight}, #{currency}, #{totalAmount}, #{remark}, #{createBy}, sysdate()) #{pkgHeight}, #{currency}, #{totalAmount}, #{remark}, #{createBy}, sysdate())
</insert> </insert>
@@ -123,14 +125,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
insert into ar_bill_detail ( insert into ar_bill_detail (
ar_bill_id, prc_order_bill_id, detail_no, order_no, tracking_no, transfer_no, receive_time, product_code, ar_bill_id, prc_order_bill_id, detail_no, order_no, tracking_no, transfer_no, receive_time, product_code,
product_name, goods_description, country_code, country_name, dest_postcode, actual_weight, 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, volume_weight, charge_weight, freight_rate, registration_fee, pkg_length, pkg_width, pkg_height, currency, total_amount,
remark, create_by, create_time remark, create_by, create_time
) values ) values
<foreach collection="list" item="item" separator=","> <foreach collection="list" item="item" separator=",">
(#{item.arBillId}, #{item.prcOrderBillId}, #{item.detailNo}, #{item.orderNo}, #{item.trackingNo}, (#{item.arBillId}, #{item.prcOrderBillId}, #{item.detailNo}, #{item.orderNo}, #{item.trackingNo},
#{item.transferNo}, #{item.receiveTime}, #{item.productCode}, #{item.productName}, #{item.goodsDescription}, #{item.transferNo}, #{item.receiveTime}, #{item.productCode}, #{item.productName}, #{item.goodsDescription},
#{item.countryCode}, #{item.countryName}, #{item.destPostcode}, #{item.actualWeight}, #{item.countryCode}, #{item.countryName}, #{item.destPostcode}, #{item.actualWeight},
#{item.volumeWeight}, #{item.chargeWeight}, #{item.pkgLength}, #{item.pkgWidth}, #{item.pkgHeight}, #{item.volumeWeight}, #{item.chargeWeight}, #{item.freightRate}, #{item.registrationFee}, #{item.pkgLength}, #{item.pkgWidth}, #{item.pkgHeight},
#{item.currency}, #{item.totalAmount}, #{item.remark}, #{item.createBy}, sysdate()) #{item.currency}, #{item.totalAmount}, #{item.remark}, #{item.createBy}, sysdate())
</foreach> </foreach>
</insert> </insert>
@@ -0,0 +1,17 @@
-- 应收账单订单明细保留订单计费时实际命中的运费单价快照。
ALTER TABLE `ar_bill_detail`
ADD COLUMN `freight_rate` decimal(10,4) DEFAULT NULL COMMENT '运费单价快照' AFTER `charge_weight`;
ALTER TABLE `ar_bill_detail`
ADD COLUMN `registration_fee` decimal(10,2) DEFAULT NULL COMMENT '处理费快照' AFTER `freight_rate`;
-- 回填已生成的历史应收账单,避免导出单价为空。
UPDATE `ar_bill_detail` d
INNER JOIN `prc_order_bill` p ON p.`bill_id` = d.`prc_order_bill_id`
SET d.`freight_rate` = p.`freight_rate`
WHERE d.`freight_rate` IS NULL;
UPDATE `ar_bill_detail` d
INNER JOIN `prc_order_bill` p ON p.`bill_id` = d.`prc_order_bill_id`
SET d.`registration_fee` = p.`registration_fee`
WHERE d.`registration_fee` IS NULL;
+2
View File
@@ -118,6 +118,8 @@ CREATE TABLE `ar_bill_detail` (
`actual_weight` decimal(12,3) DEFAULT NULL COMMENT '实际重量KG', `actual_weight` decimal(12,3) DEFAULT NULL COMMENT '实际重量KG',
`volume_weight` decimal(12,3) DEFAULT NULL COMMENT '材积重量KG', `volume_weight` decimal(12,3) DEFAULT NULL COMMENT '材积重量KG',
`charge_weight` decimal(12,3) DEFAULT NULL COMMENT '计费重量KG', `charge_weight` decimal(12,3) DEFAULT NULL COMMENT '计费重量KG',
`freight_rate` decimal(10,4) DEFAULT NULL COMMENT '运费单价快照',
`registration_fee` decimal(10,2) DEFAULT NULL COMMENT '处理费快照',
`pkg_length` decimal(10,2) DEFAULT NULL COMMENT '长度CM', `pkg_length` decimal(10,2) DEFAULT NULL COMMENT '长度CM',
`pkg_width` decimal(10,2) DEFAULT NULL COMMENT '宽度CM', `pkg_width` decimal(10,2) DEFAULT NULL COMMENT '宽度CM',
`pkg_height` decimal(10,2) DEFAULT NULL COMMENT '高度CM', `pkg_height` decimal(10,2) DEFAULT NULL COMMENT '高度CM',