🐛 修正应收账单收货重快照字段来源
This commit is contained in:
@@ -32,8 +32,8 @@ public class ArBillDetail implements Serializable {
|
|||||||
private String countryName;
|
private String countryName;
|
||||||
private String destPostcode;
|
private String destPostcode;
|
||||||
private BigDecimal actualWeight;
|
private BigDecimal actualWeight;
|
||||||
/** prc_order_bill.weight 来源快照。 */
|
/** prc_order_bill.receive_weight 收货重来源快照。 */
|
||||||
private BigDecimal weight;
|
private BigDecimal receiveWeight;
|
||||||
private BigDecimal volumeWeight;
|
private BigDecimal volumeWeight;
|
||||||
private BigDecimal chargeWeight;
|
private BigDecimal chargeWeight;
|
||||||
/** 订单计费时命中的运费单价快照,对应 prc_order_bill.freight_rate。 */
|
/** 订单计费时命中的运费单价快照,对应 prc_order_bill.freight_rate。 */
|
||||||
|
|||||||
@@ -1169,9 +1169,9 @@ public class ArBillServiceImpl implements IArBillService {
|
|||||||
detail.setCountryName(source.getCountryName());
|
detail.setCountryName(source.getCountryName());
|
||||||
detail.setDestPostcode(source.getDestPostcode());
|
detail.setDestPostcode(source.getDestPostcode());
|
||||||
detail.setActualWeight(source.getActualWeight());
|
detail.setActualWeight(source.getActualWeight());
|
||||||
detail.setWeight(source.getWeight());
|
detail.setReceiveWeight(source.getReceiveWeight());
|
||||||
detail.setVolumeWeight(source.getVolumeWeight());
|
detail.setVolumeWeight(source.getVolumeWeight());
|
||||||
detail.setChargeWeight(source.getChargeWeight() == null ? source.getWeight() : source.getChargeWeight());
|
detail.setChargeWeight(source.getChargeWeight());
|
||||||
detail.setFreightRate(source.getFreightRate());
|
detail.setFreightRate(source.getFreightRate());
|
||||||
detail.setRegistrationFee(source.getRegistrationFee());
|
detail.setRegistrationFee(source.getRegistrationFee());
|
||||||
detail.setPkgLength(source.getPkgLength());
|
detail.setPkgLength(source.getPkgLength());
|
||||||
@@ -1497,7 +1497,7 @@ public class ArBillServiceImpl implements IArBillService {
|
|||||||
detail.getOrderNo(), detail.getTrackingNo(),
|
detail.getOrderNo(), detail.getTrackingNo(),
|
||||||
StringUtils.isEmpty(detail.getProductName()) ? detail.getProductCode() : detail.getProductName(),
|
StringUtils.isEmpty(detail.getProductName()) ? detail.getProductCode() : detail.getProductName(),
|
||||||
StringUtils.isEmpty(detail.getCountryName()) ? detail.getCountryCode() : detail.getCountryName(),
|
StringUtils.isEmpty(detail.getCountryName()) ? detail.getCountryCode() : detail.getCountryName(),
|
||||||
detail.getDestPostcode(), decimal(detail.getWeight(), 3), decimal(detail.getPkgLength(), 2),
|
detail.getDestPostcode(), decimal(detail.getReceiveWeight(), 3), decimal(detail.getPkgLength(), 2),
|
||||||
decimal(detail.getPkgHeight(), 2), decimal(detail.getPkgWidth(), 2), decimal(detail.getVolumeWeight(), 3),
|
decimal(detail.getPkgHeight(), 2), decimal(detail.getPkgWidth(), 2), decimal(detail.getVolumeWeight(), 3),
|
||||||
decimal(detail.getChargeWeight(), 3), exportUnitPrice(detail), exportProcessingFee(detail),
|
decimal(detail.getChargeWeight(), 3), exportUnitPrice(detail), exportProcessingFee(detail),
|
||||||
exportFormula(detail), exportFeeType(), detail.getCurrency(), detail.getTotalAmount(), exportRemark(detail)
|
exportFormula(detail), exportFeeType(), detail.getCurrency(), detail.getTotalAmount(), exportRemark(detail)
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<result property="countryName" column="country_name"/>
|
<result property="countryName" column="country_name"/>
|
||||||
<result property="destPostcode" column="dest_postcode"/>
|
<result property="destPostcode" column="dest_postcode"/>
|
||||||
<result property="actualWeight" column="actual_weight"/>
|
<result property="actualWeight" column="actual_weight"/>
|
||||||
<result property="weight" column="weight"/>
|
<result property="receiveWeight" column="receive_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="freightRate" column="freight_rate"/>
|
||||||
@@ -40,7 +40,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, weight, volume_weight, charge_weight, freight_rate, registration_fee, pkg_length, pkg_width, pkg_height,
|
actual_weight, receive_weight, volume_weight, charge_weight, freight_rate, registration_fee, pkg_length, pkg_width, pkg_height,
|
||||||
currency, total_amount, product_amount, redline_amount, remark, create_by, create_time
|
currency, total_amount, product_amount, redline_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>
|
||||||
@@ -48,7 +48,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, weight, volume_weight, charge_weight, freight_rate, registration_fee, pkg_length, pkg_width, pkg_height,
|
actual_weight, receive_weight, volume_weight, charge_weight, freight_rate, registration_fee, pkg_length, pkg_width, pkg_height,
|
||||||
currency, total_amount, product_amount, redline_amount, remark, create_by, create_time
|
currency, total_amount, product_amount, redline_amount, remark, create_by, create_time
|
||||||
from ar_bill_detail
|
from ar_bill_detail
|
||||||
where ar_bill_id = #{arBillId}
|
where ar_bill_id = #{arBillId}
|
||||||
@@ -86,7 +86,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.weight, d.volume_weight, d.charge_weight, d.freight_rate, d.registration_fee, d.pkg_length, d.pkg_width, d.pkg_height,
|
d.actual_weight, d.receive_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.product_amount, d.redline_amount, d.remark, d.create_by, d.create_time,
|
d.currency, d.total_amount, d.product_amount, d.redline_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,
|
||||||
@@ -105,7 +105,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, weight, volume_weight, charge_weight, freight_rate, registration_fee, pkg_length, pkg_width, pkg_height,
|
actual_weight, receive_weight, volume_weight, charge_weight, freight_rate, registration_fee, pkg_length, pkg_width, pkg_height,
|
||||||
currency, total_amount, product_amount, redline_amount, remark, create_by, create_time
|
currency, total_amount, product_amount, redline_amount, remark, create_by, create_time
|
||||||
from ar_bill_detail
|
from ar_bill_detail
|
||||||
where ar_bill_id = #{arBillId} and detail_no > #{lastDetailNo}
|
where ar_bill_id = #{arBillId} and detail_no > #{lastDetailNo}
|
||||||
@@ -123,20 +123,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
insert into ar_bill_detail (ar_bill_id, prc_order_bill_id, detail_no, order_no, tracking_no, transfer_no, receive_time,
|
insert into ar_bill_detail (ar_bill_id, prc_order_bill_id, detail_no, order_no, tracking_no, transfer_no, receive_time,
|
||||||
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, weight,
|
actual_weight, receive_weight,
|
||||||
volume_weight, charge_weight, freight_rate, registration_fee, pkg_length, pkg_width, pkg_height, currency,
|
volume_weight, charge_weight, freight_rate, registration_fee, pkg_length, pkg_width, pkg_height, currency,
|
||||||
total_amount, product_amount, redline_amount,
|
total_amount, product_amount, redline_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}, #{weight}, #{volumeWeight}, #{chargeWeight}, #{freightRate}, #{registrationFee}, #{pkgLength}, #{pkgWidth},
|
#{destPostcode}, #{actualWeight}, #{receiveWeight}, #{volumeWeight}, #{chargeWeight}, #{freightRate}, #{registrationFee}, #{pkgLength}, #{pkgWidth},
|
||||||
#{pkgHeight}, #{currency}, #{totalAmount}, #{productAmount}, #{redlineAmount}, #{remark}, #{createBy}, sysdate())
|
#{pkgHeight}, #{currency}, #{totalAmount}, #{productAmount}, #{redlineAmount}, #{remark}, #{createBy}, sysdate())
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<insert id="insertBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="detailId">
|
<insert id="insertBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="detailId">
|
||||||
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, weight,
|
product_name, goods_description, country_code, country_name, dest_postcode, actual_weight, receive_weight,
|
||||||
volume_weight, charge_weight, freight_rate, registration_fee, 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,
|
||||||
product_amount, redline_amount,
|
product_amount, redline_amount,
|
||||||
remark, create_by, create_time
|
remark, create_by, create_time
|
||||||
@@ -144,7 +144,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<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.weight},
|
#{item.countryCode}, #{item.countryName}, #{item.destPostcode}, #{item.actualWeight}, #{item.receiveWeight},
|
||||||
#{item.volumeWeight}, #{item.chargeWeight}, #{item.freightRate}, #{item.registrationFee}, #{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.productAmount}, #{item.redlineAmount},
|
#{item.currency}, #{item.totalAmount}, #{item.productAmount}, #{item.redlineAmount},
|
||||||
#{item.remark}, #{item.createBy}, sysdate())
|
#{item.remark}, #{item.createBy}, sysdate())
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
-- 应收账单订单明细冗余 prc_order_bill.weight,供账单导出使用。
|
-- 应收账单订单明细冗余 prc_order_bill.receive_weight(收货重),供账单导出使用。
|
||||||
-- 来源字段为空时快照保留 NULL,不伪造为 0。
|
-- 来源字段为空时快照保留 NULL,不伪造为 0。
|
||||||
|
|
||||||
SET @column_exists := (
|
SET @column_exists := (
|
||||||
SELECT COUNT(1) FROM information_schema.COLUMNS
|
SELECT COUNT(1) FROM information_schema.COLUMNS
|
||||||
WHERE TABLE_SCHEMA = DATABASE()
|
WHERE TABLE_SCHEMA = DATABASE()
|
||||||
AND TABLE_NAME = 'ar_bill_detail'
|
AND TABLE_NAME = 'ar_bill_detail'
|
||||||
AND COLUMN_NAME = 'weight'
|
AND COLUMN_NAME = 'receive_weight'
|
||||||
);
|
);
|
||||||
SET @sql := IF(@column_exists = 0,
|
SET @sql := IF(@column_exists = 0,
|
||||||
'ALTER TABLE `ar_bill_detail` ADD COLUMN `weight` decimal(10,3) DEFAULT NULL COMMENT ''prc_order_bill.weight来源快照'' AFTER `actual_weight`',
|
'ALTER TABLE `ar_bill_detail` ADD COLUMN `receive_weight` decimal(10,3) DEFAULT NULL COMMENT ''prc_order_bill.receive_weight收货重来源快照'' AFTER `actual_weight`',
|
||||||
'SELECT 1'
|
'SELECT 1'
|
||||||
);
|
);
|
||||||
PREPARE stmt FROM @sql;
|
PREPARE stmt FROM @sql;
|
||||||
@@ -17,5 +17,5 @@ DEALLOCATE PREPARE stmt;
|
|||||||
|
|
||||||
UPDATE `ar_bill_detail` d
|
UPDATE `ar_bill_detail` d
|
||||||
INNER JOIN `prc_order_bill` p ON p.`bill_id` = d.`prc_order_bill_id`
|
INNER JOIN `prc_order_bill` p ON p.`bill_id` = d.`prc_order_bill_id`
|
||||||
SET d.`weight` = p.`weight`
|
SET d.`receive_weight` = p.`receive_weight`
|
||||||
WHERE d.`weight` IS NULL AND p.`weight` IS NOT NULL;
|
WHERE d.`receive_weight` IS NULL AND p.`receive_weight` IS NOT NULL;
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
-- 应收账单快照字段 weight 重命名为 receive_weight,并以 prc_order_bill.receive_weight 修正历史值。
|
||||||
|
-- 来源字段为空时保留 NULL;本迁移完成后删除旧 weight 列。
|
||||||
|
|
||||||
|
SET @column_exists := (
|
||||||
|
SELECT COUNT(1) FROM information_schema.COLUMNS
|
||||||
|
WHERE TABLE_SCHEMA = DATABASE()
|
||||||
|
AND TABLE_NAME = 'ar_bill_detail'
|
||||||
|
AND COLUMN_NAME = 'receive_weight'
|
||||||
|
);
|
||||||
|
SET @sql := IF(@column_exists = 0,
|
||||||
|
'ALTER TABLE `ar_bill_detail` ADD COLUMN `receive_weight` decimal(10,3) DEFAULT NULL COMMENT ''prc_order_bill.receive_weight收货重来源快照'' AFTER `actual_weight`',
|
||||||
|
'SELECT 1'
|
||||||
|
);
|
||||||
|
PREPARE stmt FROM @sql;
|
||||||
|
EXECUTE stmt;
|
||||||
|
DEALLOCATE PREPARE stmt;
|
||||||
|
|
||||||
|
UPDATE `ar_bill_detail` d
|
||||||
|
INNER JOIN `prc_order_bill` p ON p.`bill_id` = d.`prc_order_bill_id`
|
||||||
|
SET d.`receive_weight` = p.`receive_weight`
|
||||||
|
WHERE NOT (d.`receive_weight` <=> p.`receive_weight`);
|
||||||
|
|
||||||
|
SET @column_exists := (
|
||||||
|
SELECT COUNT(1) FROM information_schema.COLUMNS
|
||||||
|
WHERE TABLE_SCHEMA = DATABASE()
|
||||||
|
AND TABLE_NAME = 'ar_bill_detail'
|
||||||
|
AND COLUMN_NAME = 'weight'
|
||||||
|
);
|
||||||
|
SET @sql := IF(@column_exists > 0,
|
||||||
|
'ALTER TABLE `ar_bill_detail` DROP COLUMN `weight`',
|
||||||
|
'SELECT 1'
|
||||||
|
);
|
||||||
|
PREPARE stmt FROM @sql;
|
||||||
|
EXECUTE stmt;
|
||||||
|
DEALLOCATE PREPARE stmt;
|
||||||
@@ -116,7 +116,7 @@ CREATE TABLE `ar_bill_detail` (
|
|||||||
`country_name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '目的国家名称',
|
`country_name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '目的国家名称',
|
||||||
`dest_postcode` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '目的邮编',
|
`dest_postcode` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '目的邮编',
|
||||||
`actual_weight` decimal(12,3) DEFAULT NULL COMMENT '实际重量KG',
|
`actual_weight` decimal(12,3) DEFAULT NULL COMMENT '实际重量KG',
|
||||||
`weight` decimal(10,3) DEFAULT NULL COMMENT 'prc_order_bill.weight来源快照',
|
`receive_weight` decimal(10,3) DEFAULT NULL COMMENT 'prc_order_bill.receive_weight收货重来源快照',
|
||||||
`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 '运费单价快照',
|
`freight_rate` decimal(10,4) DEFAULT NULL COMMENT '运费单价快照',
|
||||||
|
|||||||
Reference in New Issue
Block a user