text: CREATE TABLE IF NOT EXISTS `wp_prize` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
  `addon`  varchar(255) NULL  DEFAULT 'Scratch' COMMENT '来源插件',
  `target_id`  int(10) unsigned NULL   COMMENT '来源ID',
  `title`  varchar(255) NULL  COMMENT '奖项标题',
  `name`  varchar(255) NULL  COMMENT '奖项',
  `num`  int(10) unsigned NULL   COMMENT '名额数量',
  `sort`  int(10) unsigned NULL   DEFAULT 0 COMMENT '排序号',
  `img`  int(10) unsigned NULL   COMMENT '奖品图片',
  `token`  varchar(255) NULL  COMMENT 'Token',
  PRIMARY KEY (`id`)
  ) ENGINE=MyISAM DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci CHECKSUM=0 ROW_FORMAT=DYNAMIC DELAY_KEY_WRITE=0;
  INSERT INTO `wp_model` (`name`,`title`,`extend`,`relation`,`need_pk`,`field_sort`,`field_group`,`attribute_list`,`template_list`,`template_add`,`template_edit`,`list_grid`,`list_row`,`search_key`,`search_list`,`create_time`,`update_time`,`status`,`engine_type`,`addon`) VALUES ('prize','奖项设置','0','','1','["title","name","num","img","sort"]','1:基础','','','','','title:奖项标题\r\nname:奖项\r\nnum:名额数量\r\nimg|get_img_html:奖品图片\r\nids:操作:[EDIT]|编辑,[DELETE]|删除','20','title','','1399348610','1399702991','1','MyISAM','Scratch');
  INSERT INTO `wp_attribute` (`name`,`title`,`field`,`type`,`value`,`remark`,`is_show`,`extra`,`model_id`,`model_name`,`is_must`,`status`,`update_time`,`create_time`,`validate_rule`,`validate_time`,`error_info`,`validate_type`,`auto_rule`,`auto_time`,`auto_type`) VALUES ('addon','来源插件','varchar(255) NULL','string','Scratch','','0','','0','prize','0','1','1399348676','1399348676','','3','','regex','','3','function');
  INSERT INTO `wp_attribute` (`name`,`title`,`field`,`type`,`value`,`remark`,`is_show`,`extra`,`model_id`,`model_name`,`is_must`,`status`,`update_time`,`create_time`,`validate_rule`,`validate_time`,`error_info`,`validate_type`,`auto_rule`,`auto_time`,`auto_type`) VALUES ('target_id','来源ID','int(10) unsigned NULL ','','','','1','','0','prize','0','1','1420980352','1399348699','','3','','regex','','3','function');
  INSERT INTO `wp_attribute` (`name`,`title`,`field`,`type`,`value`,`remark`,`is_show`,`extra`,`model_id`,`model_name`,`is_must`,`status`,`update_time`,`create_time`,`validate_rule`,`validate_time`,`error_info`,`validate_type`,`auto_rule`,`auto_time`,`auto_type`) VALUES ('title','奖项标题','varchar(255) NULL','string','','如特等奖、一等奖。。。','1','','0','prize','1','1','1439370111','1399348734','','3','','regex','','3','function');
  INSERT INTO `wp_attribute` (`name`,`title`,`field`,`type`,`value`,`remark`,`is_show`,`extra`,`model_id`,`model_name`,`is_must`,`status`,`update_time`,`create_time`,`validate_rule`,`validate_time`,`error_info`,`validate_type`,`auto_rule`,`auto_time`,`auto_type`) VALUES ('name','奖项','varchar(255) NULL','string','','如iphone、吹风机等','1','','0','prize','1','1','1439370125','1399348785','','3','','regex','','3','function');
  INSERT INTO `wp_attribute` (`name`,`title`,`field`,`type`,`value`,`remark`,`is_show`,`extra`,`model_id`,`model_name`,`is_must`,`status`,`update_time`,`create_time`,`validate_rule`,`validate_time`,`error_info`,`validate_type`,`auto_rule`,`auto_time`,`auto_type`) VALUES ('num','名额数量','int(10) unsigned NULL ','num','','','1','','0','prize','1','1','1439370137','1399348843','','3','','regex','','3','function');
  INSERT INTO `wp_attribute` (`name`,`title`,`field`,`type`,`value`,`remark`,`is_show`,`extra`,`model_id`,`model_name`,`is_must`,`status`,`update_time`,`create_time`,`validate_rule`,`validate_time`,`error_info`,`validate_type`,`auto_rule`,`auto_time`,`auto_type`) VALUES ('sort','排序号','int(10) unsigned NULL ','num','0','值越小越靠前','1','','0','prize','0','1','1399557716','1399557716','','3','','regex','','3','function');
  INSERT INTO `wp_attribute` (`name`,`title`,`field`,`type`,`value`,`remark`,`is_show`,`extra`,`model_id`,`model_name`,`is_must`,`status`,`update_time`,`create_time`,`validate_rule`,`validate_time`,`error_info`,`validate_type`,`auto_rule`,`auto_time`,`auto_type`) VALUES ('img','奖品图片','int(10) unsigned NULL ','picture','','','1','','0','prize','0','1','1399557997','1399557997','','3','','regex','','3','function');
  INSERT INTO `wp_attribute` (`name`,`title`,`field`,`type`,`value`,`remark`,`is_show`,`extra`,`model_id`,`model_name`,`is_must`,`status`,`update_time`,`create_time`,`validate_rule`,`validate_time`,`error_info`,`validate_type`,`auto_rule`,`auto_time`,`auto_type`) VALUES ('token','Token','varchar(255) NULL','string','','','0','','0','prize','0','1','1404525428','1404525428','','3','','regex','get_token','1','function');
  UPDATE `wp_attribute` SET model_id= (SELECT MAX(id) FROM `wp_model`) WHERE model_id=0;
  
  
  CREATE TABLE IF NOT EXISTS `wp_scratch` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
  `keyword`  varchar(100) NOT NULL  COMMENT '关键词',
  `use_tips`  varchar(255) NOT NULL  COMMENT '使用说明',
  `title`  varchar(255) NOT NULL  COMMENT '标题',
  `intro`  text NULL  COMMENT '封面简介',
  `end_time`  int(10) NULL  COMMENT '结束时间',
  `cover`  int(10) unsigned NULL   COMMENT '封面图片',
  `cTime`  int(10) unsigned NULL   COMMENT '发布时间',
  `token`  varchar(255) NULL  COMMENT 'Token',
  `start_time`  int(10) NULL  COMMENT '开始时间',
  `end_tips`  text NULL  COMMENT '过期说明',
  `end_img`  int(10) unsigned NULL   COMMENT '过期提示图片',
  `predict_num`  int(10) unsigned NOT NULL   COMMENT '预计参与人数',
  `max_num`  int(10) unsigned NULL   DEFAULT 1 COMMENT '每人最多允许抽奖次数',
  `follower_condtion`  char(50) NULL  DEFAULT 1 COMMENT '粉丝状态',
  `credit_conditon`  int(10) unsigned NULL   DEFAULT 0 COMMENT '积分限制',
  `credit_bug`  int(10) unsigned NULL   DEFAULT 0 COMMENT '积分消费',
  `addon_condition`  varchar(255) NULL  COMMENT '插件场景限制',
  `collect_count`  int(10) unsigned NULL   DEFAULT 0 COMMENT '已领取人数',
  `view_count`  int(10) unsigned NULL   DEFAULT 0 COMMENT '浏览人数',
  `update_time`  int(10) NULL  COMMENT '更新时间',
  `template`  varchar(255) NULL  DEFAULT 'default' COMMENT '素材模板',
  PRIMARY KEY (`id`)
  ) ENGINE=MyISAM DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci CHECKSUM=0 ROW_FORMAT=DYNAMIC DELAY_KEY_WRITE=0;
  INSERT INTO `wp_model` (`name`,`title`,`extend`,`relation`,`need_pk`,`field_sort`,`field_group`,`attribute_list`,`template_list`,`template_add`,`template_edit`,`list_grid`,`list_row`,`search_key`,`search_list`,`create_time`,`update_time`,`status`,`engine_type`,`addon`) VALUES ('scratch','刮刮卡','0','','1','["keyword","title","intro","cover","use_tips","start_time","end_time","end_tips","end_img","predict_num","max_num","follower_condtion","credit_conditon","credit_bug","addon_condition","collect_count","view_count","template"]','1:基础','','','','','id:刮刮卡ID\r\nkeyword:关键词\r\ntitle:标题\r\ncollect_count:获取人数\r\ncTime|time_format:发布时间\r\nids:操作:[EDIT]|编辑,[DELETE]|删除,lists?target_id=[id]&target=_blank&_controller=Sn|中奖管理,lists?target_id=[id]&target=_blank&_controller=Prize|奖品管理,preview?id=[id]&target=_blank|预览','20','title','','1396061373','1437035669','1','MyISAM','Scratch');
  INSERT INTO `wp_attribute` (`name`,`title`,`field`,`type`,`value`,`remark`,`is_show`,`extra`,`model_id`,`model_name`,`is_must`,`status`,`update_time`,`create_time`,`validate_rule`,`validate_time`,`error_info`,`validate_type`,`auto_rule`,`auto_time`,`auto_type`) VALUES ('keyword','关键词','varchar(100) NOT NULL','string','','','1','','0','scratch','1','1','1396624337','1396061575','','3','','regex','','3','function');
  INSERT INTO `wp_attribute` (`name`,`title`,`field`,`type`,`value`,`remark`,`is_show`,`extra`,`model_id`,`model_name`,`is_must`,`status`,`update_time`,`create_time`,`validate_rule`,`validate_time`,`error_info`,`validate_type`,`auto_rule`,`auto_time`,`auto_type`) VALUES ('use_tips','使用说明','varchar(255) NOT NULL','textarea','','用户获取刮刮卡后显示的提示信息','1','','0','scratch','1','1','1420989679','1399259489','','3','','regex','','3','function');
  INSERT INTO `wp_attribute` (`name`,`title`,`field`,`type`,`value`,`remark`,`is_show`,`extra`,`model_id`,`model_name`,`is_must`,`status`,`update_time`,`create_time`,`validate_rule`,`validate_time`,`error_info`,`validate_type`,`auto_rule`,`auto_time`,`auto_type`) VALUES ('title','标题','varchar(255) NOT NULL','string','','','1','','0','scratch','1','1','1396624461','1396061859','','3','','regex','','3','function');
  INSERT INTO `wp_attribute` (`name`,`title`,`field`,`type`,`value`,`remark`,`is_show`,`extra`,`model_id`,`model_name`,`is_must`,`status`,`update_time`,`create_time`,`validate_rule`,`validate_time`,`error_info`,`validate_type`,`auto_rule`,`auto_time`,`auto_type`) VALUES ('intro','封面简介','text NULL','editor','','','1','','0','scratch','0','1','1420983308','1396061947','','3','','regex','','3','function');
  INSERT INTO `wp_attribute` (`name`,`title`,`field`,`type`,`value`,`remark`,`is_show`,`extra`,`model_id`,`model_name`,`is_must`,`status`,`update_time`,`create_time`,`validate_rule`,`validate_time`,`error_info`,`validate_type`,`auto_rule`,`auto_time`,`auto_type`) VALUES ('end_time','结束时间','int(10) NULL','datetime','','','1','','0','scratch','0','1','1399259433','1399259433','','3','','regex','','3','function');
  INSERT INTO `wp_attribute` (`name`,`title`,`field`,`type`,`value`,`remark`,`is_show`,`extra`,`model_id`,`model_name`,`is_must`,`status`,`update_time`,`create_time`,`validate_rule`,`validate_time`,`error_info`,`validate_type`,`auto_rule`,`auto_time`,`auto_type`) VALUES ('cover','封面图片','int(10) unsigned NULL ','picture','','可为空','1','','0','scratch','0','1','1399710705','1396062093','','3','','regex','','3','function');
  INSERT INTO `wp_attribute` (`name`,`title`,`field`,`type`,`value`,`remark`,`is_show`,`extra`,`model_id`,`model_name`,`is_must`,`status`,`update_time`,`create_time`,`validate_rule`,`validate_time`,`error_info`,`validate_type`,`auto_rule`,`auto_time`,`auto_type`) VALUES ('cTime','发布时间','int(10) unsigned NULL ','datetime','','','0','','0','scratch','0','1','1396624612','1396075102','','3','','regex','time','1','function');
  INSERT INTO `wp_attribute` (`name`,`title`,`field`,`type`,`value`,`remark`,`is_show`,`extra`,`model_id`,`model_name`,`is_must`,`status`,`update_time`,`create_time`,`validate_rule`,`validate_time`,`error_info`,`validate_type`,`auto_rule`,`auto_time`,`auto_type`) VALUES ('token','Token','varchar(255) NULL','string','','','0','','0','scratch','0','1','1396602871','1396602859','','3','','regex','get_token','1','function');
  INSERT INTO `wp_attribute` (`name`,`title`,`field`,`type`,`value`,`remark`,`is_show`,`extra`,`model_id`,`model_name`,`is_must`,`status`,`update_time`,`create_time`,`validate_rule`,`validate_time`,`error_info`,`validate_type`,`auto_rule`,`auto_time`,`auto_type`) VALUES ('start_time','开始时间','int(10) NULL','datetime','','','1','','0','scratch','0','1','1399259416','1399259416','','3','','regex','','3','function');
  INSERT INTO `wp_attribute` (`name`,`title`,`field`,`type`,`value`,`remark`,`is_show`,`extra`,`model_id`,`model_name`,`is_must`,`status`,`update_time`,`create_time`,`validate_rule`,`validate_time`,`error_info`,`validate_type`,`auto_rule`,`auto_time`,`auto_type`) VALUES ('end_tips','过期说明','text NULL','textarea','','活动过期或者结束说明','1','','0','scratch','0','1','1399259570','1399259570','','3','','regex','','3','function');
  INSERT INTO `wp_attribute` (`name`,`title`,`field`,`type`,`value`,`remark`,`is_show`,`extra`,`model_id`,`model_name`,`is_must`,`status`,`update_time`,`create_time`,`validate_rule`,`validate_time`,`error_info`,`validate_type`,`auto_rule`,`auto_time`,`auto_type`) VALUES ('end_img','过期提示图片','int(10) unsigned NULL ','picture','','可为空','1','','0','scratch','0','1','1399712676','1399711987','','3','','regex','','3','function');
  INSERT INTO `wp_attribute` (`name`,`title`,`field`,`type`,`value`,`remark`,`is_show`,`extra`,`model_id`,`model_name`,`is_must`,`status`,`update_time`,`create_time`,`validate_rule`,`validate_time`,`error_info`,`validate_type`,`auto_rule`,`auto_time`,`auto_type`) VALUES ('predict_num','预计参与人数','int(10) unsigned NOT NULL ','num','','预计人数直接影响抽奖概率：中奖概率 = 奖品总数/(预估活动人数*每人抽奖次数) 要确保100%中奖可设置为1','1','','0','scratch','1','1','1399710446','1399259992','','3','','regex','','3','function');
  INSERT INTO `wp_attribute` (`name`,`title`,`field`,`type`,`value`,`remark`,`is_show`,`extra`,`model_id`,`model_name`,`is_must`,`status`,`update_time`,`create_time`,`validate_rule`,`validate_time`,`error_info`,`validate_type`,`auto_rule`,`auto_time`,`auto_type`) VALUES ('max_num','每人最多允许抽奖次数','int(10) unsigned NULL ','num','1','0表示不限制数量','1','','0','scratch','0','1','1399260079','1399260079','','3','','regex','','3','function');
  INSERT INTO `wp_attribute` (`name`,`title`,`field`,`type`,`value`,`remark`,`is_show`,`extra`,`model_id`,`model_name`,`is_must`,`status`,`update_time`,`create_time`,`validate_rule`,`validate_time`,`error_info`,`validate_type`,`auto_rule`,`auto_time`,`auto_type`) VALUES ('follower_condtion','粉丝状态','char(50) NULL','select','1','粉丝达到设置的状态才能获取','1','0:不限制\r\n1:已关注\r\n2:已绑定信息\r\n3:会员卡成员','0','scratch','0','1','1399260479','1399260479','','3','','regex','','3','function');
  INSERT INTO `wp_attribute` (`name`,`title`,`field`,`type`,`value`,`remark`,`is_show`,`extra`,`model_id`,`model_name`,`is_must`,`status`,`update_time`,`create_time`,`validate_rule`,`validate_time`,`error_info`,`validate_type`,`auto_rule`,`auto_time`,`auto_type`) VALUES ('credit_conditon','积分限制','int(10) unsigned NULL ','num','0','粉丝达到多少积分后才能领取，领取后不扣积分','1','','0','scratch','0','1','1399260618','1399260618','','3','','regex','','3','function');
  INSERT INTO `wp_attribute` (`name`,`title`,`field`,`type`,`value`,`remark`,`is_show`,`extra`,`model_id`,`model_name`,`is_must`,`status`,`update_time`,`create_time`,`validate_rule`,`validate_time`,`error_info`,`validate_type`,`auto_rule`,`auto_time`,`auto_type`) VALUES ('credit_bug','积分消费','int(10) unsigned NULL ','num','0','用积分中的财富兑换、兑换后扣除相应的积分财富','1','','0','scratch','0','1','1399260764','1399260764','','3','','regex','','3','function');
  INSERT INTO `wp_attribute` (`name`,`title`,`field`,`type`,`value`,`remark`,`is_show`,`extra`,`model_id`,`model_name`,`is_must`,`status`,`update_time`,`create_time`,`validate_rule`,`validate_time`,`error_info`,`validate_type`,`auto_rule`,`auto_time`,`auto_type`) VALUES ('addon_condition','插件场景限制','varchar(255) NULL','string','','格式：[插件名:id值]，如[投票:10]表示对ID为10的投票投完才能领取，更多的说明见表单上的提示','1','','0','scratch','0','1','1399274022','1399261026','','3','','regex','','3','function');
  INSERT INTO `wp_attribute` (`name`,`title`,`field`,`type`,`value`,`remark`,`is_show`,`extra`,`model_id`,`model_name`,`is_must`,`status`,`update_time`,`create_time`,`validate_rule`,`validate_time`,`error_info`,`validate_type`,`auto_rule`,`auto_time`,`auto_type`) VALUES ('collect_count','已领取人数','int(10) unsigned NULL ','num','0','','1','','0','scratch','0','1','1420980201','1399270900','','3','','regex','','3','function');
  INSERT INTO `wp_attribute` (`name`,`title`,`field`,`type`,`value`,`remark`,`is_show`,`extra`,`model_id`,`model_name`,`is_must`,`status`,`update_time`,`create_time`,`validate_rule`,`validate_time`,`error_info`,`validate_type`,`auto_rule`,`auto_time`,`auto_type`) VALUES ('view_count','浏览人数','int(10) unsigned NULL ','num','0','','1','','0','scratch','0','1','1420980183','1399270926','','3','','regex','','3','function');
  INSERT INTO `wp_attribute` (`name`,`title`,`field`,`type`,`value`,`remark`,`is_show`,`extra`,`model_id`,`model_name`,`is_must`,`status`,`update_time`,`create_time`,`validate_rule`,`validate_time`,`error_info`,`validate_type`,`auto_rule`,`auto_time`,`auto_type`) VALUES ('update_time','更新时间','int(10) NULL','datetime','','','0','','0','scratch','0','1','1399562468','1399359204','','3','','regex','time','3','function');
  INSERT INTO `wp_attribute` (`name`,`title`,`field`,`type`,`value`,`remark`,`is_show`,`extra`,`model_id`,`model_name`,`is_must`,`status`,`update_time`,`create_time`,`validate_rule`,`validate_time`,`error_info`,`validate_type`,`auto_rule`,`auto_time`,`auto_type`) VALUES ('template','素材模板','varchar(255) NULL','string','default','','1','','0','scratch','0','1','1430201266','1430201266','','3','','regex','','3','function');
  UPDATE `wp_attribute` SET model_id= (SELECT MAX(id) FROM `wp_model`) WHERE model_id=0;
  
  
  