admin/sql/migrate_channel_payable_weight_20261123.sql
zzh 8545e6c28c
All checks were successful
Build and Deploy / deploy (push) Successful in 1m21s
feat: 服务渠道支持黑名单区,排货命中跳过该渠道
合并迁移脚本含 BlacklistAreaId 与应付计重字段;规则发布钉包,LIVE 即时加载。

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

90 lines
2.8 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.BlacklistAreaId
SET @exists := (
SELECT COUNT(1)
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = @db
AND TABLE_NAME = 't_service_channel'
AND COLUMN_NAME = 'BlacklistAreaId'
);
SET @sql := IF(
@exists = 0,
'ALTER TABLE `t_service_channel` ADD COLUMN `BlacklistAreaId` INT NULL COMMENT ''黑名单分区KPI AreaId'' AFTER `RemoteAreaId`',
'SELECT ''t_service_channel.BlacklistAreaId already exists'' AS info'
);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
-- 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 `BlacklistAreaId`',
'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;