-- C 端会员主档
CREATE TABLE IF NOT EXISTS `biz_member` (
  `member_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '会员ID',
  `mobile` varchar(20) NOT NULL COMMENT '手机号',
  `member_code` varchar(64) NOT NULL DEFAULT '' COMMENT '会员名称',
  `nick_name` varchar(64) NOT NULL DEFAULT '' COMMENT '昵称',
  `password` varchar(100) NOT NULL COMMENT '密码BCrypt',
  `member_level` tinyint(4) DEFAULT NULL COMMENT '会员等级（字典 biz_member_level，选填）',
  `status` char(1) NOT NULL DEFAULT '0' COMMENT '0启用1禁用',
  `order_count` int(11) NOT NULL DEFAULT '0' COMMENT '已完成订单笔数',
  `total_amount` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '已完成实付合计',
  `register_time` datetime NOT NULL COMMENT '注册时间',
  `avatar` varchar(512) DEFAULT NULL COMMENT '头像URL',
  `del_flag` char(1) NOT NULL DEFAULT '0' COMMENT '0存在2删除',
  `create_by` varchar(64) DEFAULT '',
  `create_time` datetime DEFAULT NULL,
  `update_by` varchar(64) DEFAULT '',
  `update_time` datetime DEFAULT NULL,
  `remark` varchar(500) DEFAULT NULL,
  PRIMARY KEY (`member_id`),
  KEY `idx_register` (`register_time`),
  KEY `idx_status` (`status`,`del_flag`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='C端会员';

-- 会员收货地址
CREATE TABLE IF NOT EXISTS `biz_member_address` (
  `address_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '地址ID',
  `member_id` bigint(20) NOT NULL COMMENT '会员ID',
  `consignee_name` varchar(64) NOT NULL COMMENT '收货人',
  `mobile` varchar(20) NOT NULL COMMENT '联系电话',
  `province` varchar(32) NOT NULL DEFAULT '',
  `city` varchar(32) NOT NULL DEFAULT '',
  `district` varchar(32) NOT NULL DEFAULT '',
  `detail_address` varchar(256) NOT NULL COMMENT '详细地址',
  `is_default` char(1) NOT NULL DEFAULT '0' COMMENT '0否1默认',
  `del_flag` char(1) NOT NULL DEFAULT '0' COMMENT '0存在2删除',
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  PRIMARY KEY (`address_id`),
  KEY `idx_member` (`member_id`,`del_flag`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='会员收货地址';
