-- 钱包在线充值单升级脚本
-- 说明：
-- 1. 新增会员钱包在线充值单，独立承接 DaxPay 支付链路。
-- 2. 钱包入账仍然落到 xxk_wallet_account / xxk_wallet_flow。

CREATE TABLE IF NOT EXISTS `xxk_wallet_recharge_order` (
  `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `recharge_no` VARCHAR(64) NOT NULL COMMENT '充值单号',
  `pay_order_no` VARCHAR(64) NOT NULL COMMENT '支付单号',
  `member_user_id` BIGINT NOT NULL COMMENT '会员ID',
  `payment_type` VARCHAR(32) NOT NULL COMMENT '支付方式(ALIPAY/WECHAT)',
  `pay_status` VARCHAR(32) NOT NULL DEFAULT 'INIT' COMMENT '支付状态(INIT/PAYING/PAID/FAIL/CLOSED)',
  `channel_order_no` VARCHAR(128) DEFAULT NULL COMMENT '渠道支付单号',
  `channel_response` TEXT DEFAULT NULL COMMENT '渠道原始响应',
  `client_type` VARCHAR(32) DEFAULT NULL COMMENT '客户端类型(PC/H5/APP/MINI_PROGRAM)',
  `return_url` VARCHAR(500) DEFAULT NULL COMMENT '支付完成跳转地址',
  `amount` DECIMAL(18,2) NOT NULL DEFAULT 0.00 COMMENT '充值金额',
  `currency` VARCHAR(16) DEFAULT 'CNY' COMMENT '币种',
  `paid_time` DATETIME DEFAULT NULL COMMENT '支付成功时间',
  `remark` VARCHAR(255) DEFAULT NULL COMMENT '备注',
  `create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `is_deleted` TINYINT NOT NULL DEFAULT 0 COMMENT '是否删除(0否 1是)',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_xxk_wallet_recharge_no` (`recharge_no`),
  UNIQUE KEY `uk_xxk_wallet_recharge_pay_order_no` (`pay_order_no`),
  KEY `idx_xxk_wallet_recharge_member_status` (`member_user_id`, `pay_status`, `create_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='钱包在线充值单';


-- 钱包充值订单管理菜单

INSERT INTO `sys_menu`
(`id`, `parent_id`, `tree_path`, `name`, `type`, `route_name`, `route_path`, `component`, `perm`,
 `always_show`, `keep_alive`, `visible`, `sort`, `icon`, `redirect`, `create_time`, `update_time`, `params`)
VALUES
(11910, 1190, '0,1100,1190', '充值订单', 'C', 'ProxyWalletRecharge', 'wallet-recharge', 'proxy/wallet-recharge/index', NULL,
 0, 1, 1, 3, 'wallet', NULL, now(), now(), NULL),
(11911, 11910, '0,1100,1190,11910', '充值订单查询', 'B', NULL, '', NULL, 'proxy:wallet:recharge-order:list',
 NULL, NULL, 1, 1, '', NULL, now(), now(), NULL)
ON DUPLICATE KEY UPDATE
`name` = VALUES(`name`),
`route_name` = VALUES(`route_name`),
`route_path` = VALUES(`route_path`),
`component` = VALUES(`component`),
`perm` = VALUES(`perm`),
`keep_alive` = VALUES(`keep_alive`),
`visible` = VALUES(`visible`),
`sort` = VALUES(`sort`),
`update_time` = now();
