
CREATE TABLE `cb_customer`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `open_kfid` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '客服ID',
  `external_userid` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '微信客户的external_userid',
  `nickname` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '昵称',
  `avatar` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '图片',
  `gender` tinyint(4) NOT NULL COMMENT '性别',
  `service_state` tinyint(4) NOT NULL DEFAULT -1 COMMENT '会话状态：0未处理，1由智能助手接待，2待接入池排队中，3由人工接待，4已结束/未开始',
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `last_msg_time` bigint(20) NULL DEFAULT NOT NULL COMMENT '最后消息时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `open_kfid`(`open_kfid`, `external_userid`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '客户信息表' ROW_FORMAT = Compact;
