admin/sql/migrate_channel_payable_weight_20261123.sql
zzh f66d567c49
All checks were successful
Build and Deploy / deploy (push) Successful in 1m24s
feat: 服务渠道独立计重,应付与揽收应付用渠道计费重
应收仍走销售产品计重;排货/重算应付/对账/揽收推费按渠道计重写入 PayableChargeableWeight,不改 ChargeableWeight。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-23 16:32:05 +08:00

73 lines
2.3 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- 服务渠道独立计重(应付);订单件重尺增加应付计费重。
-- 可重复执行。不改 ChargeableWeight 语义(仍为应收计费重)。
SET @db := DATABASE();
-- t_service_channel.WeightRuleId
SET @exists := (
SELECT COUNT(1)
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = @db
AND TABLE_NAME = 't_service_channel'
AND COLUMN_NAME = 'WeightRuleId'
);
SET @sql := IF(
@exists = 0,
'ALTER TABLE `t_service_channel` ADD COLUMN `WeightRuleId` INT NULL COMMENT ''计重规则ID(应付)'' AFTER `RemoteAreaId`',
'SELECT ''t_service_channel.WeightRuleId already exists'' AS info'
);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
-- t_service_channel.WeightRoundingId
SET @exists := (
SELECT COUNT(1)
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = @db
AND TABLE_NAME = 't_service_channel'
AND COLUMN_NAME = 'WeightRoundingId'
);
SET @sql := IF(
@exists = 0,
'ALTER TABLE `t_service_channel` ADD COLUMN `WeightRoundingId` INT NULL COMMENT ''计重进位ID(应付)'' AFTER `WeightRuleId`',
'SELECT ''t_service_channel.WeightRoundingId already exists'' AS info'
);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
-- t_order_weight.PayableChargeableWeight
SET @exists := (
SELECT COUNT(1)
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = @db
AND TABLE_NAME = 't_order_weight'
AND COLUMN_NAME = 'PayableChargeableWeight'
);
SET @sql := IF(
@exists = 0,
'ALTER TABLE `t_order_weight` ADD COLUMN `PayableChargeableWeight` DECIMAL(10,3) NULL COMMENT ''应付计费重(kg),渠道计重'' AFTER `ChargeableWeight`',
'SELECT ''t_order_weight.PayableChargeableWeight already exists'' AS info'
);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
-- t_pickup_order.PayableChargeableWeight
SET @exists := (
SELECT COUNT(1)
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = @db
AND TABLE_NAME = 't_pickup_order'
AND COLUMN_NAME = 'PayableChargeableWeight'
);
SET @sql := IF(
@exists = 0,
'ALTER TABLE `t_pickup_order` ADD COLUMN `PayableChargeableWeight` DECIMAL(18,3) NULL COMMENT ''应付计费重(kg),渠道计重'' AFTER `ChargeableWeight`',
'SELECT ''t_pickup_order.PayableChargeableWeight already exists'' AS info'
);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;