USE tmerclub_user;
DROP TABLE IF EXISTS `cost_per_popup`;
CREATE TABLE `cost_per_popup` (
  `popup_id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '弹窗广告id',
  `shop_id` bigint NOT NULL COMMENT '店铺id',
  `popup_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '弹窗名称',
  `status` tinyint NOT NULL COMMENT '状态  1.未开始 2.投放中 3.已结束',
  `page_type` tinyint NOT NULL COMMENT '触发页面类型 1.平台首页 2.会员中心 3.支付成功 4.店铺首页 5.商品详情',
  `popup_pic` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '弹窗图片',
  `jump_url` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '跳转页面',
  `user_type` tinyint NOT NULL DEFAULT '0' COMMENT '推送用户类型 0.所有用户 1.免费会员 2.付费会员 3.店铺客户',
  `start_time` datetime NOT NULL COMMENT '推送开始时间',
  `end_time` datetime NOT NULL COMMENT '推送结束时间',
  `push_frequency` tinyint NOT NULL DEFAULT '0' COMMENT '推送频次 0.永久一次 1.每次进入 2.自定义频次',
  `day_frequency` tinyint DEFAULT NULL COMMENT '按x天推送',
  `week_frequency` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '按周推送 eg. 1,2',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`popup_id`),
  KEY `shop_id` (`popup_id`,`shop_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='弹窗广告';

DROP TABLE IF EXISTS `popup_relate`;
CREATE TABLE `popup_relate` (
    `relate_id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '关联id',
    `popup_id` bigint NOT NULL COMMENT '弹窗广告id',
    `spu_id` bigint DEFAULT NULL COMMENT '商品id',
    `user_level_id` bigint DEFAULT NULL COMMENT '会员等级id',
    `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    PRIMARY KEY (`relate_id`),
    KEY `popup_id` (`popup_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='弹窗广告关联';




