CREATE TABLE IF NOT EXISTS `gy_jifenshangcheng_account`.`t_app_user` (
	`id` bigint NOT NULL COMMENT '主键',
	`user_type` int DEFAULT '1' COMMENT '用户类型（1=普通用户，2=门店员工）',
	`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '用户',
	`phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '手机号',
	`avatar` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '头像',
	`vip_id` int DEFAULT NULL COMMENT '会员id（1=普通会员，2=黄金会员，3=钻石会员，4=准代理，5=代理，6=总代，7=合伙人））',
	`wx_openid` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '微信openid',
	`ali_openid` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '支付宝openid',
	`status` int DEFAULT '1' COMMENT '状态（1=正常，2=冻结，3=注销）',
	`create_time` datetime DEFAULT NULL COMMENT '添加时间',
	`del_flag` tinyint(1) UNSIGNED ZEROFILL DEFAULT '0' COMMENT '删除（0=否，1=是）',
	`first_add` int DEFAULT NULL COMMENT '0否1是第一次添加',
	`last_login_time` datetime DEFAULT NULL COMMENT '最后一次登录时间',
	`top_invite_id` bigint DEFAULT NULL COMMENT '顶级推广人id',
	`invite_user_id` bigint DEFAULT NULL COMMENT '推广人id',
	`shop_id` int DEFAULT NULL COMMENT '绑定门店id',
	`part_point` int DEFAULT '0' COMMENT '合伙人积分数',
	`part_grow_point` int DEFAULT '0' COMMENT '合伙人培育积分数',
	`last_shop_time` datetime DEFAULT NULL COMMENT '最后消费时间',
	`shop_point` int DEFAULT '0' COMMENT '消费积分数',
	`share_point` int DEFAULT '0' COMMENT '返佣积分数',
	`shop_share_point` int DEFAULT '0' COMMENT '门店返佣积分',
	`shop_achievement_point` int DEFAULT '0' COMMENT '门店业绩积分',
	`lower_level_share_point` int DEFAULT '0' COMMENT '绑定下级门店分佣积分',
	`total_invite_point` int DEFAULT '0' COMMENT '拉新人积分总数',
	`total_register_point` int DEFAULT '0' COMMENT '注册积分总数',
	`total_performance_point` int DEFAULT '0' COMMENT '业绩积分总数',
	`total_share_point` int DEFAULT '0' COMMENT '每日分享积分',
	`total_sign_point` int DEFAULT '0' COMMENT '每日签到积分',
	`total_hour_point` int DEFAULT '0' COMMENT '使用时长积分',
	`lave_point` int DEFAULT '0' COMMENT '剩余积分',
	`available_point` int DEFAULT '0' COMMENT '可用积分',
	`transferable_point` int DEFAULT '0' COMMENT '可转增积分',
	`total_available_point` int DEFAULT '0' COMMENT '可用总积分数',
	`total_point` int DEFAULT '0' COMMENT '总积分',
	`shop_amount` decimal(10, 2) DEFAULT '0.00' COMMENT '消费总金额',
	`withdrawable_amount` decimal(10, 2) DEFAULT '0.00' COMMENT '可提现金额',
	`withdrawn_amount` decimal(10, 2) DEFAULT '0.00' COMMENT '已提现金额',
	`total_recharge_amount` decimal(10, 2) DEFAULT '0.00' COMMENT '充值总金额',
	`total_red_packet_amount` decimal(10, 2) DEFAULT '0.00' COMMENT '红包总金额',
	`total_distribution_amount` decimal(10, 2) DEFAULT '0.00' COMMENT '分销总金额',
	`shop_service_fee` decimal(10, 2) DEFAULT '0.00' COMMENT '门店服务费（门店核销获得）',
	`shop_commission` decimal(10, 2) DEFAULT '0.00' COMMENT '门店返佣金额（绑定用户消费后返佣）',
	`balance` decimal(10, 2) DEFAULT '0.00' COMMENT '账户余额',
	`change_promoter` int DEFAULT '0' COMMENT '是否可更换推广人（0=否，1=是）',
	`longitude` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '经度',
	`latitude` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '纬度',
	`province` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '省',
	`province_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '省编号',
	`city` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '市',
	`city_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '市编号',
	`district` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '区',
	`district_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '区编号',
	`qr_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '推广二维码',
	`is_danger` int DEFAULT '0' COMMENT '降级预警（0=否，1=是）',
	`freeze_commission_amount` decimal(10, 2) DEFAULT NULL COMMENT '冻结分佣金额',
	`freeze_commission_point` int DEFAULT NULL COMMENT '冻结分佣积分',
	`recharge_point` int DEFAULT '0' COMMENT '充值积分',
	`cancel_point` int DEFAULT '0' COMMENT '取消订单积分',
	`exchange_point` int DEFAULT '0' COMMENT '兑换商品积分',
	`transferable_in_point` int DEFAULT '0' COMMENT '转赠（转入）积分',
	`transferable_out_point` int DEFAULT '0' COMMENT '转赠（转出）积分',
	PRIMARY KEY USING BTREE (`id`)
) ENGINE = InnoDB CHARSET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = DYNAMIC COMMENT 'app用户';

CREATE TABLE IF NOT EXISTS `gy_jifenshangcheng_account`.`t_app_user_bank` (
	`id` bigint NOT NULL,
	`app_user_id` bigint DEFAULT NULL COMMENT '用户id',
	`bank_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '开户银行名称',
	`bank_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '银行卡号',
	PRIMARY KEY (`id`)
) ENGINE = InnoDB CHARSET = utf8mb4 COLLATE = utf8mb4_bin COMMENT '用户银行卡';

CREATE TABLE IF NOT EXISTS `gy_jifenshangcheng_account`.`t_app_user_shop` (
	`id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
	`app_user_id` bigint DEFAULT NULL COMMENT '用户id',
	`shop_id` int DEFAULT NULL COMMENT '门店id',
	`role_type` int DEFAULT NULL COMMENT '角色（1=店长，2=店员，3=技师）',
	PRIMARY KEY (`id`)
) ENGINE = InnoDB AUTO_INCREMENT = 133 CHARSET = utf8mb4 COLLATE = utf8mb4_bin COMMENT '门店员工关联表（移动端）';

CREATE TABLE IF NOT EXISTS `gy_jifenshangcheng_account`.`t_apply_for_admission` (
	`id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
	`apply_user_id` bigint DEFAULT NULL COMMENT '申请人id',
	`shop_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '商家名称',
	`home_picture` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '商家封面图',
	`details_picture` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '店铺详情图',
	`certification` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '资质证书图片',
	`shop_manager` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '店长姓名',
	`phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '电话',
	`service_Tel` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '客服电话（同步到t_phone表）',
	`business_time` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '营业时间',
	`longitude` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '经度',
	`latitude` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '纬度',
	`address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '商家地址（地图地址）',
	`detail_address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '详细地址',
	`status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '状态（0-待审核，1-审核通过，2-审核不通过）',
	`remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '备注',
	`create_time` datetime DEFAULT NULL COMMENT '创建时间',
	`update_time` datetime DEFAULT NULL COMMENT '修改时间',
	PRIMARY KEY USING BTREE (`id`)
) ENGINE = InnoDB AUTO_INCREMENT = 17 CHARSET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = DYNAMIC;

CREATE TABLE IF NOT EXISTS `gy_jifenshangcheng_account`.`t_balance_change_record` (
	`id` bigint(20) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT,
	`app_user_id` bigint DEFAULT NULL COMMENT '用户id',
	`order_id` bigint DEFAULT NULL COMMENT '订单id',
	`change_type` int DEFAULT NULL COMMENT '1充值2提现3红包4分佣5商城购物6取消订单退款',
	`before_amount` decimal(10, 2) DEFAULT NULL COMMENT '变更前金额',
	`change_amount` decimal(10, 2) DEFAULT NULL COMMENT '变更金额',
	`after_amount` decimal(10, 2) DEFAULT NULL COMMENT '变更后金额',
	`del_flag` int DEFAULT '0' COMMENT '删除（0=否，1=是）',
	`create_time` datetime DEFAULT NULL COMMENT '添加时间',
	`vip_id` int DEFAULT NULL COMMENT '会员等级',
	PRIMARY KEY (`id`)
) ENGINE = InnoDB CHARSET = utf8mb4 COLLATE = utf8mb4_bin COMMENT '用户余额变更记录';
CREATE TABLE IF NOT EXISTS `gy_jifenshangcheng_account`.`t_balance_payment` (
	`id` bigint NOT NULL COMMENT '主键',
	`app_user_id` bigint DEFAULT NULL COMMENT '用户id',
	`money` decimal(10, 2) DEFAULT NULL COMMENT '支付金额',
	`serial_number` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '微信支付流水号',
	`status` int DEFAULT '1' COMMENT '微信支付状态（1=待支付，2=已支付）',
	`payment_time` datetime DEFAULT NULL COMMENT '完成支付时间',
	`balance_change_record_id` bigint DEFAULT NULL COMMENT '余额变更记录id',
	`create_time` datetime DEFAULT NULL COMMENT '添加时间',
	PRIMARY KEY (`id`)
) ENGINE = InnoDB CHARSET = utf8mb4 COLLATE = utf8mb4_bin COMMENT '账户余额充值记录';

CREATE TABLE IF NOT EXISTS `gy_jifenshangcheng_account`.`t_user_cancellation_log` (
	`id` bigint NOT NULL COMMENT '主键',
	`del_flag` tinyint DEFAULT '0' COMMENT '删除标志（0=否，1=是）',
	`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间',
	`app_user_id` bigint DEFAULT NULL COMMENT '用户id',
	`vip_id` int DEFAULT NULL COMMENT '会员等级',
	PRIMARY KEY (`id`)
) ENGINE = InnoDB CHARSET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT '注销记录';

CREATE TABLE IF NOT EXISTS `gy_jifenshangcheng_account`.`t_user_point` (
	`id` bigint NOT NULL COMMENT '主键',
	`type` int DEFAULT NULL COMMENT '变动类型（1-消费返，2-返佣，3-拉新，4-每日分享，5-每日签到，6-使用时长， 7-注册积分， 8-门店业绩，9-门店返佣，10-技师业绩，11-兑换商品，12-他人赠送，13-赠与他人，14-下级门店返佣，15=兑换优惠券）',
	`historical_point` int DEFAULT NULL COMMENT '历史余额',
	`variable_point` int DEFAULT NULL COMMENT '变动金额',
	`balance` int DEFAULT NULL COMMENT '变动后金额',
	`create_time` datetime DEFAULT NULL COMMENT '变动时间',
	`app_user_id` bigint DEFAULT NULL COMMENT '变动用户id',
	`transfer_user_id` bigint DEFAULT NULL COMMENT '转赠用户id',
	`receive_user_id` bigint DEFAULT NULL COMMENT '受赠用户id',
	`object_id` bigint DEFAULT NULL COMMENT '关联对象id',
	`extention` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '拓展字段',
	`change_direction` int DEFAULT NULL COMMENT '变动方向（-1：减少，1：增加）',
	PRIMARY KEY USING BTREE (`id`)
) ENGINE = InnoDB CHARSET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = DYNAMIC COMMENT '用户积分流水';

CREATE TABLE IF NOT EXISTS `gy_jifenshangcheng_account`.`t_withdrawal_requests` (
	`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
	`del_flag` tinyint DEFAULT '0' COMMENT '删除标志（0=否，1=是）',
	`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间',
	`app_user_id` bigint DEFAULT NULL COMMENT '用户id',
	`withdrawal_amount` decimal(10, 2) DEFAULT NULL COMMENT '提现金额',
	`arrival_amount` decimal(10, 2) DEFAULT NULL COMMENT '到账金额',
	`service_charge` decimal(10, 2) DEFAULT NULL COMMENT '手续费',
	`withdrawal_method` int DEFAULT NULL COMMENT '1微信2银行卡',
	`account_holder` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '开户人',
	`bank_card_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '银行卡号',
	`audit_status` int DEFAULT NULL COMMENT '审核状态 1''待审核'',2''审核通过'',3''审核拒绝'' ',
	`status` int DEFAULT NULL COMMENT '状态（1=处理中，2=成功，3=失败）',
	`remark` text COMMENT '处理结果',
	`arrival_time` datetime DEFAULT NULL COMMENT '到账时间',
	PRIMARY KEY (`id`)
) ENGINE = InnoDB CHARSET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT '提现申请';



