修改计费文档,加上客户代码

This commit is contained in:
wuweihua
2026-09-29 09:20:59 +08:00
parent b8e1f8cd40
commit d08758aa35
7 changed files with 78 additions and 6 deletions
@@ -0,0 +1,26 @@
-- prc_billing_task add customer_code for customer filter / rebill
SET NAMES utf8mb4;
SET @col := (
SELECT COLUMN_NAME FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = 'prc_billing_task'
AND COLUMN_NAME = 'customer_code'
LIMIT 1
);
SET @sql := IF(
@col IS NULL,
CONCAT(
'ALTER TABLE prc_billing_task ADD COLUMN customer_code varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT ',
CHAR(39), '客户代码', CHAR(39),
' AFTER order_no, ADD KEY idx_billing_task_customer (customer_code)'
),
'SELECT 1'
);
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
UPDATE prc_billing_task t
INNER JOIN prc_order_bill b ON b.bill_id = t.bill_id
SET t.customer_code = b.customer_code
WHERE (t.customer_code IS NULL OR t.customer_code = '')
AND b.customer_code IS NOT NULL AND b.customer_code <> '';