-- ----------------------------
-- Table structure for qimall_addons_operating_note_ad
-- ----------------------------
DROP TABLE IF EXISTS `qimall_addons_operating_note_ad`;
CREATE TABLE `qimall_addons_operating_note_ad`  (
  `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `mall_id` int(11) NOT NULL COMMENT '商城id',
  `sort` int(11) NOT NULL COMMENT '排序',
  `title` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '广告标题',
  `img` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '广告图',
  `jump_href` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '跳转链接',
  `status` tinyint(2) NOT NULL DEFAULT 1 COMMENT '-1是删除，0是禁用，1是启用',
  `created_at` int(11) NOT NULL,
  `updated_at` int(11) NOT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `index_mall_id`(`mall_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '运营笔记广告图' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for qimall_addons_operating_note_buy
-- ----------------------------
DROP TABLE IF EXISTS `qimall_addons_operating_note_buy`;
CREATE TABLE `qimall_addons_operating_note_buy`  (
  `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `mall_id` int(11) NOT NULL COMMENT '商城ID',
  `order_no` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '订单编号',
  `out_trade_no` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '外部交易单号',
  `user_id` int(11) NOT NULL COMMENT '用户id',
  `note_id` int(11) NOT NULL COMMENT '笔记id',
  `view_limit` tinyint(2) NOT NULL COMMENT '付费类型',
  `buy_price` decimal(19, 2) NOT NULL DEFAULT 0.00 COMMENT '付费金额',
  `is_pay` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否支付：0.未支付|1.已支付',
  `status` tinyint(5) NOT NULL DEFAULT 1,
  `created_at` int(11) NOT NULL,
  `updated_at` int(11) NOT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `index_user_id`(`user_id`) USING BTREE,
  INDEX `index_note_id`(`note_id`) USING BTREE,
  INDEX `index_order_no`(`order_no`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '运营笔记用户付费购买的文章' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for qimall_addons_operating_note_cate
-- ----------------------------
DROP TABLE IF EXISTS `qimall_addons_operating_note_cate`;
CREATE TABLE `qimall_addons_operating_note_cate`  (
  `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `mall_id` int(11) NOT NULL COMMENT '商城id',
  `name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '分类名/不超过6个字符',
  `status` tinyint(5) NOT NULL DEFAULT 1 COMMENT '-1是删除，0是禁用，1是启用',
  `created_at` int(11) NULL DEFAULT NULL COMMENT '创建时间',
  `updated_at` int(11) NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `index_mall_id`(`mall_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '运营笔记分类' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for qimall_addons_operating_note_comment
-- ----------------------------
DROP TABLE IF EXISTS `qimall_addons_operating_note_comment`;
CREATE TABLE `qimall_addons_operating_note_comment`  (
  `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `mall_id` int(11) NOT NULL COMMENT '商城id',
  `user_id` int(11) NOT NULL DEFAULT 0 COMMENT '用户id 为0表示后台发布',
  `note_content_id` int(11) NOT NULL COMMENT '回复的笔记id',
  `level` tinyint(2) NOT NULL DEFAULT 1 COMMENT '第n级回复',
  `reply_id` int(11) NOT NULL DEFAULT 0 COMMENT '一级评论id',
  `content` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '评论内容',
  `is_top` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否置顶 0/否 1/是',
  `top_time` int(11) NOT NULL DEFAULT 0 COMMENT '置顶时间',
  `status` int(11) NOT NULL DEFAULT 1 COMMENT '-1是删除，0是禁用 1是启用',
  `created_at` int(11) NOT NULL DEFAULT 0,
  `updated_at` int(11) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `index_mall_id,index_note_content_id,index_level`(`mall_id`, `note_content_id`, `level`) USING BTREE,
  INDEX `index_status`(`status`) USING BTREE,
  INDEX `index_reply_id`(`reply_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for qimall_addons_operating_note_config
-- ----------------------------
DROP TABLE IF EXISTS `qimall_addons_operating_note_config`;
CREATE TABLE `qimall_addons_operating_note_config`  (
  `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `mall_id` int(11) NOT NULL COMMENT '商城id',
  `page_name` int(11) NOT NULL COMMENT '页面名称',
  `hidden_search` int(11) NOT NULL COMMENT '是否显示搜索 1/是 2/否',
  `search_title` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '搜索标题',
  `allow_user_create` int(11) NOT NULL COMMENT '是否允许发布 1/是 2/否',
  `need_check` int(11) NOT NULL COMMENT '是否需要审核 1/是 2/否',
  `share_user_show` int(11) NOT NULL COMMENT '分享者显示',
  `decorate` text CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '装修信息',
  `created_at` int(11) NOT NULL,
  `updated_at` int(11) NOT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `index_mall_id`(`mall_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '运营笔记配置' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for qimall_addons_operating_note_content
-- ----------------------------
DROP TABLE IF EXISTS `qimall_addons_operating_note_content`;
CREATE TABLE `qimall_addons_operating_note_content`  (
  `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `mall_id` int(11) NOT NULL COMMENT '商城id',
  `user_id` int(11) NOT NULL DEFAULT 0 COMMENT '发布者id(后台发布为0)',
  `goods_id` int(11) NOT NULL DEFAULT 0 COMMENT '关联商品id',
  `cate_id` int(11) NOT NULL COMMENT '分类id',
  `sort` int(11) NOT NULL DEFAULT 0 COMMENT '排序(数字越大排在前面)',
  `note_type` tinyint(4) NOT NULL COMMENT '笔记类型(1文章/2视频/3广告)',
  `cover_img` varchar(5000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '封面/数组',
  `title` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '笔记标题',
  `content` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '笔记内容',
  `content_href` varchar(5000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '笔记文件链接',
  `hidden_comment` tinyint(2) NOT NULL DEFAULT 1 COMMENT '是否显示评价 1/是 0/否',
  `show_type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '[1,2,3,4]' COMMENT '展示内容(阅读数/点赞数/发布时间/发布者)',
  `share_visit_num` int(11) NOT NULL DEFAULT 0 COMMENT '分享访问次数',
  `reply_num` int(10) NOT NULL DEFAULT 0 COMMENT '回复数量',
  `views_people_num` int(11) NOT NULL DEFAULT 0 COMMENT '浏览人数',
  `views_num` int(11) NOT NULL DEFAULT 0 COMMENT '实际阅读数量',
  `likes_num` int(11) NOT NULL DEFAULT 0 COMMENT '实际点赞数量',
  `share_num` int(11) NOT NULL DEFAULT 0 COMMENT '分享次数',
  `virtual_views_num` int(11) NOT NULL DEFAULT 0 COMMENT '虚拟阅读数量',
  `virtual_likes_num` int(11) NOT NULL DEFAULT 0 COMMENT '虚拟点赞数量',
  `order_people_num` int(11) NOT NULL DEFAULT 0 COMMENT '付款人数',
  `goods_views_count` int(11) NOT NULL DEFAULT 0 COMMENT '进入商品详情次数',
  `order_amount` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '订单金额',
  `is_top` tinyint(2) NOT NULL DEFAULT 0 COMMENT '是否置顶 1/是 0/否',
  `is_top_updated_at` int(11) NOT NULL DEFAULT 0 COMMENT '置顶时间',
  `share_title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '分享标题',
  `share_title_type` tinyint(2) NOT NULL DEFAULT 0 COMMENT '分享标题类型 0/文章标题 1/自定义',
  `view_limit` tinyint(5) NOT NULL DEFAULT 0 COMMENT '浏览限制类型',
  `view_limit_content` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'all' COMMENT '浏览限制类容',
  `pay_people_num` int(11) NOT NULL DEFAULT 0 COMMENT '付费观看人数',
  `pay_amount` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '付费总额',
  `pay_score_amount` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '付费积分总额',
  `share_reward` tinyint(2) NOT NULL DEFAULT 0 COMMENT '分享奖励是否开启1/是 0/否',
  `share_reward_type` tinyint(2) NOT NULL DEFAULT 0 COMMENT '分享奖励类型',
  `share_reward_max_time` int(5) NOT NULL DEFAULT 0 COMMENT '分享最多奖励次数',
  `share_reward_content` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '分享奖励内容',
  `view_reward` tinyint(2) NOT NULL DEFAULT 0 COMMENT '浏览奖励是否开启',
  `view_reward_max_time` int(5) NOT NULL DEFAULT 0 COMMENT '浏览最多奖励次数',
  `view_reward_content` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '浏览奖励内容',
  `view_reward_type` tinyint(2) NOT NULL DEFAULT 0 COMMENT '浏览奖励类型',
  `is_release` tinyint(2) NOT NULL DEFAULT 1 COMMENT '是否发布 1/是 0/否',
  `status` tinyint(2) NOT NULL DEFAULT 1 COMMENT '状态，-1是删除，0是禁用，1是启用',
  `check_status` tinyint(4) NOT NULL DEFAULT 0 COMMENT '审核状态：0：未审核 1：审核通过 2：审核不通过',
  `check_remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '审核原因',
  `check_time` int(11) NOT NULL DEFAULT 0 COMMENT '审核时间',
  `created_at` int(11) NOT NULL DEFAULT 0,
  `updated_at` int(11) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `index_mall_id,index_cate_id`(`mall_id`, `cate_id`) USING BTREE,
  INDEX `index_not_type`(`note_type`) USING BTREE,
  INDEX `index_user_id`(`user_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '运营笔记列表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for qimall_addons_operating_note_reward_record
-- ----------------------------
DROP TABLE IF EXISTS `qimall_addons_operating_note_reward_record`;
CREATE TABLE `qimall_addons_operating_note_reward_record`  (
  `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `mall_id` int(11) NOT NULL COMMENT '商城id',
  `user_id` int(11) NOT NULL COMMENT '用户id',
  `note_content_id` int(11) NOT NULL COMMENT '获取奖励来源笔记id',
  `note_cate_id` int(11) NOT NULL COMMENT '笔记分类id',
  `note_type` tinyint(5) NOT NULL COMMENT '笔记类型',
  `reward_type` int(11) NOT NULL COMMENT '奖励类型(积分/余额)',
  `reward_source` tinyint(2) NOT NULL COMMENT '奖励来源 (1阅读/2分享)',
  `reward_content` decimal(10, 2) NOT NULL COMMENT '奖励信息',
  `status` tinyint(2) NOT NULL DEFAULT 1,
  `created_at` int(11) NOT NULL DEFAULT 0,
  `updated_at` int(11) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `index_mall_id`(`mall_id`) USING BTREE,
  INDEX `index_user_id`(`user_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '运营笔记奖励' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for qimall_addons_operating_note_share_record
-- ----------------------------
DROP TABLE IF EXISTS `qimall_addons_operating_note_share_record`;
CREATE TABLE `qimall_addons_operating_note_share_record`  (
  `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `mall_id` int(11) NOT NULL COMMENT '商城id',
  `user_id` int(11) NOT NULL COMMENT '用户id',
  `note_id` int(11) NOT NULL COMMENT '笔记id',
  `has_gift` tinyint(2) NOT NULL DEFAULT 0 COMMENT '是否奖励',
  `status` tinyint(2) NOT NULL DEFAULT 1,
  `created_at` int(11) NOT NULL,
  `updated_at` int(11) NOT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `index_user_id`(`user_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for qimall_addons_operating_note_user_like
-- ----------------------------
DROP TABLE IF EXISTS `qimall_addons_operating_note_user_like`;
CREATE TABLE `qimall_addons_operating_note_user_like`  (
  `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `mall_id` int(11) NOT NULL COMMENT '商城ID',
  `user_id` int(11) NOT NULL COMMENT '用户id',
  `note_content_id` int(11) NOT NULL COMMENT '点赞笔记id',
  `is_like` tinyint(2) NOT NULL DEFAULT 1 COMMENT '是否点赞 1/是 0/否',
  `status` tinyint(2) NOT NULL DEFAULT 1,
  `created_at` int(11) NOT NULL DEFAULT 0,
  `updated_at` int(11) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `index_mall_id`(`mall_id`) USING BTREE,
  INDEX `index_note_content_id`(`note_content_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '运营笔记用户点赞' ROW_FORMAT = Dynamic;

-- ----------------------------
-- 链接分类
-- ----------------------------
INSERT INTO `qimall_link_category` (`name`, `title`, `pid`, `is_list`, `remark`, `status`, `created_at`, `updated_at`) VALUES 
('operating_note', '运营笔记', 19, 1, '备注', 1, 1646382501, 1646382501);

-- ----------------------------
-- 装修组件
-- ----------------------------
INSERT INTO `qimall_diy_components` (`code`, `title`, `group`, `icon`, `count`, `is_top`, `permission`, `sort`, `source`, `status`, `created_at`, `updated_at`) VALUES
('notes-articles', '运营笔记', 'marketing', '', 999, 0, '{\"is_drag\":\"true\",\"is_up\":\"true\",\"id_down\":\"true\",\"is_copy\":\"true\"}', 999, 'OperatingNote', 1, 1634538238, 1634538238);

-- ----------------------------
-- 修改字段长度
-- ----------------------------
ALTER TABLE qimall_addons_operating_note_ad modify COLUMN jump_href varchar(5000);

ALTER TABLE `qimall_addons_operating_note_content`
ADD COLUMN `cover_type` tinyint(2) NOT NULL COMMENT '封面类型：1小单图2大单图3二图4三图5竖屏6横屏' AFTER `view_reward_max_time`;

