DROP TABLE IF EXISTS `kx_rider_wallet_transaction`;
CREATE TABLE `kx_rider_wallet_transaction`  (
                                                `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
                                                `rider_id` bigint(20) NOT NULL COMMENT '骑手ID',
                                                `transaction_no` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '交易流水号',
                                                `amount` decimal(10, 2) NOT NULL COMMENT '交易金额',
                                                `balance` decimal(10, 2) NOT NULL COMMENT '交易后余额',
                                                `transaction_type` tinyint(4) NOT NULL COMMENT '交易类型(1:收入,2:支出,3:提现,4:退款)',
                                                `transaction_source` tinyint(4) NULL DEFAULT NULL COMMENT '交易来源(1:配送费,2:小费,3:系统调整,4:其他)',
                                                `order_no` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '关联订单ID',
                                                `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '交易备注',
                                                `status` tinyint(4) NOT NULL DEFAULT 1 COMMENT '状态(1:成功,2:处理中,3:失败)',
                                                `create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '创建时间',
                                                `update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '更新时间',
                                                `create_by` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人',
                                                `update_by` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '更新人',
                                                PRIMARY KEY (`id`) USING BTREE,
                                                UNIQUE INDEX `idx_transaction_no`(`transaction_no`) USING BTREE,
                                                INDEX `idx_rider_id`(`rider_id`) USING BTREE,
                                                INDEX `idx_create_time`(`create_time`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1916836015478145027 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '骑手钱包交易记录表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for kx_rider_withdrawal
-- ----------------------------
DROP TABLE IF EXISTS `kx_rider_withdrawal`;
CREATE TABLE `kx_rider_withdrawal`  (
                                        `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
                                        `rider_id` bigint(20) NOT NULL COMMENT '骑手ID',
                                        `amount` decimal(10, 2) NOT NULL COMMENT '提现金额',
                                        `bank_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '银行名称',
                                        `bank_account` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '银行账号',
                                        `account_holder` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '开户人姓名',
                                        `status` tinyint(4) NOT NULL DEFAULT 0 COMMENT '状态(0:待审核,1:审核通过,2:审核拒绝,3:已打款)',
                                        `audit_time` datetime(0) NULL DEFAULT NULL COMMENT '审核时间',
                                        `audit_admin` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '审核人',
                                        `audit_remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '审核备注',
                                        `payment_time` datetime(0) NULL DEFAULT NULL COMMENT '打款时间',
                                        `payment_admin` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '打款人',
                                        `payment_remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '打款备注',
                                        `create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '创建时间',
                                        `update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '更新时间',
                                        `create_by` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人',
                                        `update_by` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '更新人',
                                        `payment_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '打款URL',
                                        PRIMARY KEY (`id`) USING BTREE,
                                        INDEX `idx_rider_id`(`rider_id`) USING BTREE,
                                        INDEX `idx_status`(`status`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1917233244433039363 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '骑手提现记录表' ROW_FORMAT = Dynamic;



INSERT INTO `sys_menu`(`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query_param`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (1917360667413725185, '提现审核', 1704762913992278018, 3, 'withdraw', 'rider/withdraw/index', NULL, 1, 0, 'C', '0', '0', '', '#', 'admin', '2025-04-30 07:29:41', 'admin', '2025-04-30 07:29:41', '');

ALTER TABLE `kx_rider`
    ADD COLUMN `wallet_balance` decimal(20, 2) NULL DEFAULT NULL COMMENT '钱包余额' AFTER `gzh_open_id`,
ADD COLUMN `bank_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '银行名称' AFTER `wallet_balance`,
ADD COLUMN `bank_account` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '银行账号' AFTER `bank_name`,
ADD COLUMN `account_holder` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '开户人姓名' AFTER `bank_account`,
ADD COLUMN `id_card_number` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '身份证号码' AFTER `account_holder`;



UPDATE `sys_config` SET `category` = 'riderWxMini' WHERE `config_id` = 1705582515376066561;
UPDATE `sys_config` SET `category` = 'riderWxMini' WHERE `config_id` = 1705582465266716674;
