-- 应收账单订单明细保留订单计费时实际命中的运费单价快照。 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;