ALTER TABLE `xxk_wallet_recharge_order`
  ADD COLUMN `gift_amount` decimal(18,2) NOT NULL DEFAULT 0.00 COMMENT '充值赠送金额' AFTER `amount`,
  ADD COLUMN `credited_amount` decimal(18,2) NOT NULL DEFAULT 0.00 COMMENT '实际到账金额' AFTER `gift_amount`,
  ADD COLUMN `promotion_rule_snapshot` text NULL COMMENT '命中的充值活动规则快照' AFTER `credited_amount`;

UPDATE `xxk_wallet_recharge_order`
SET `gift_amount` = IFNULL(`gift_amount`, 0.00),
    `credited_amount` = CASE
      WHEN IFNULL(`credited_amount`, 0.00) > 0 THEN `credited_amount`
      ELSE IFNULL(`amount`, 0.00) + IFNULL(`gift_amount`, 0.00)
    END;
