Files
BMS/bms-back/sql/data/customer_receipt_base_currency.sql
T
2026-09-14 17:48:46 +08:00

21 lines
1.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.
-- ----------------------------
-- 收款/流水 增加「对CNY汇率」「本位币金额(CNY)」
-- 统一本位币核算:原币登记,审核后一律折算为 CNY 入客户本位币账户
-- 汇率定义:1 单位原币 = exchange_rate 单位 CNY(CNY 本币汇率固定为 1)
-- ----------------------------
ALTER TABLE `customer_receipt`
ADD COLUMN `exchange_rate` decimal(18,8) DEFAULT 1.00000000 COMMENT '对CNY汇率(1原币=?CNY,CNY为1)' AFTER `currency`,
ADD COLUMN `base_amount` decimal(18,2) DEFAULT 0.00 COMMENT '本位币金额(CNY,原币金额×汇率)' AFTER `exchange_rate`;
-- 历史数据(均为CNY收款):汇率1,本位币金额=原金额
UPDATE `customer_receipt` SET `exchange_rate` = 1, `base_amount` = `amount`
WHERE `exchange_rate` = 1 AND (`base_amount` = 0 OR `base_amount` IS NULL);
ALTER TABLE `customer_balance_flow`
ADD COLUMN `exchange_rate` decimal(18,8) DEFAULT 1.00000000 COMMENT '对CNY汇率(1原币=?CNY,CNY为1)' AFTER `currency`,
ADD COLUMN `base_amount` decimal(18,2) DEFAULT 0.00 COMMENT '本位币金额(CNY,变动额折算)' AFTER `exchange_rate`;
UPDATE `customer_balance_flow` SET `exchange_rate` = 1, `base_amount` = `amount`
WHERE `exchange_rate` = 1 AND (`base_amount` = 0 OR `base_amount` IS NULL);