rabin 6 năm trước cách đây
mục cha
commit
7907b3c7d6

+ 8 - 0
boot.php

@@ -0,0 +1,8 @@
+<?php
+define('DEVER_PROJECT', 'hiz');
+define('DEVER_PROJECT_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+if (defined('DEVER_PACKAGE')) {
+	include('dever_package/'.DEVER_PACKAGE.'/index.php');
+} else {
+	include('dever/boot.php');
+}

+ 80 - 0
config/base.php

@@ -0,0 +1,80 @@
+<?php
+
+# 一些基本配置
+$config['base'] = array
+(
+	# 名称
+	'name' => '橙猫内部管理系统',
+	# 版本配置
+	'version' => '1.0.0 Beta',
+
+	# 微信小程序登录地址
+	'wechat' => 'https://api.weixin.qq.com/sns/jscode2session',
+	# 登录验证key
+	'secret' => 'chengmao2018_898930',
+	# 后台头部菜单
+	'top' => 'set/info_id',
+
+
+	# 微信组件url
+	'wechat_url' => 'http://wx.5dev.cn/wechat/applet/?',
+
+	# 基本数据类型
+	'type' => array
+	(
+		1 => '资讯',
+		2 => '课程',
+		3 => '会议',
+		4 => '评论',
+		5 => '服务',
+		6 => '文章',
+		7 => '商务合作',
+		8 => '活动',
+	),
+
+	# 基本数据类型 对应的表
+	'table' => array
+	(
+		1 => 'content/news',
+        2 => 'content/course',
+        3 => 'content/meeting',
+        4 => 'comment/review',
+        5 => 'content/service',
+        6 => 'content/article',
+        8 => 'activity/active',
+	),
+
+	'copyType' => array
+	(
+		1 => '手动录入',
+		2 => '复制',
+	),
+);
+
+$config['template'] = array
+(
+	# 使用的模板 注意:定义这个之后,将会强制将本项目模板(assets中的html、template)变成这个
+	'assets' => 'default',
+	# 定义这个之后,将强制将template的目录改为这个,不定义或不填写,则强制使用为template定义
+	'template' => 'default',
+	# 替换设置 一般用于替换资源,将模板中的(html中的)js等相对url换成绝对url,如果不定义,则默认为../js这样的
+	'replace' => array
+	(
+		'css' => '../css/',
+		'js' => '../js/',
+		'img' => array('../image/', '../img/', '../images/'),
+		'core' => '../../core/',
+		'lib' => '../lib/',
+		'manage' => '../manage/',
+		
+		# 以下的替换主要用于合并操作(host里的merge项)
+		'font' => '../fonts/',
+	),
+	
+	'strip' => false,
+
+	# 是否启用layout 如启用,填写要替换的class或者id即可,具体效果可参考youtube,只加载部分内容,前端请加载pjax.js
+	'layout' => '.pjax-content',
+);
+
+return $config;

+ 11 - 0
config/dyna.php

@@ -0,0 +1,11 @@
+<?php
+# 动态配置,可以用于seo配置,请在项目下建立该配置文件
+
+return array
+(
+	# 首页 可与route相同
+	'home' => array
+	(
+		
+	)
+);

+ 252 - 0
config/env/localhost/group.php

@@ -0,0 +1,252 @@
+<?php
+# 集成项目的大部分配置,此为默认设置。环境不同,以下的配置也有可能不同,可以根据项目名建立配置文件
+
+# 基本配置
+$config['base'] = array
+(
+	# 项目部署的相对路径(部署在服务器的根目录,如果不定义DEVER_PROJECT_NAME,则本项必须启用并有效)
+	'path' => DIRECTORY_SEPARATOR . 'workspace' . DIRECTORY_SEPARATOR,
+
+	# 访问assets目录的物理路径
+	'assets' => DEVER_APP_PATH . 'assets' . DIRECTORY_SEPARATOR,
+
+	# 访问data目录的物理路径
+	'data' 	=> DEVER_PROJECT_PATH . 'data' . DIRECTORY_SEPARATOR,
+
+	# 访问当前项目目录的物理路径,如果项目和dever类库在一个目录中,则为DEVER_PATH,如果不在,则为DEVER_APP_PATH,当然也可随意更改,这里目前只影响合并操作(merge)
+	'workspace' => DEVER_APP_PATH,
+	
+	# 定义api的token明文,如果和其他业务有合作,建议使用系统自带的接口api,自带加密解密程序。
+	'token' => 'dever_api_2016',
+	
+	# 是否启用nocache,如果是互动类的项目且主域增加了cdn,建议开启
+	'clearHeaderCache' => false,
+
+	# api文档生成是否开启,开启后,将会根据访问来生成文档。生产环境建议禁止
+	'apiDoc' => true,
+	# api日志是否开启,开启后,将会记录所有带有_api后缀方法的请求参数和响应参数
+	'apiLog' => false,
+
+	# 定义自动转为api的目录,可以将该目录下的所有类的公共方法,都转为可以访问的api,开启该功能可能有安全性问题。
+	'apiOpenPath' => 'src',
+
+	# 启用后,将会根据api目录下的配置文件自动定位api
+	//'apiConfig' => true,
+	
+	# 开启用户触发cron,主要用于无法加到系统计划任务的虚拟主机,必须安装manage组件,谨慎开启,会稍微影响程序执行效率
+	//'cron' => true,
+);
+
+# 模板配置
+$config['template'] = array
+(
+	# 是否启用静态资源域名动态化,启用之后,静态资源的域名将动态加载,适合使用多个域名或publish启用
+	'domain' => true,
+
+	# 是否开启强制刷新页面缓存
+	'shell' => 'temp',
+	
+	# 是否开启手动更改模板名称,允许通过$_GET的方式来更改当前模板,值为$_GET的key值,默认关闭
+	//'name' => 'template',
+
+	# publish 是否发布,此项开启后,系统不会检测service(意味着不用将service打包上线),适合生产环境,并能对代码起到一定的加密保护。
+	//'publish' => true,
+);
+
+# 数据库配置
+$config['database'] = array
+(
+	# database 中的reuqest的兼容定义,如果启用了该选项,需要自行开发database/compatible目录下相对应的数据表文件中的request方法。
+	//'compatible' => 'model',
+
+	# 是否开启sql自动优化,将sql中的select * 转换为 select a,b形式,将sql中的where条件按照索引从左到右自动排序,必须打开上述的opt选项,数据量大时建议打开。
+	//'sql' => true,
+
+	# 关闭自助建表,生产环境建议开启,开启之后无法对数据表结构进行更新操作
+	//'create' => true,
+
+	# 是否开启mysql自助优化功能,开启后,会记录所有where条件和order的字段,可以方便的在后台进行分析、增加索引,必须安装manage组件
+	'opt' => true,
+
+	# 默认数据库配置
+	'default' => array
+	(
+		'type' => 'pdo',
+		'host' => array
+		(
+			'read' => 'web-mysql:3306',
+			'update' => 'web-mysql:3306',
+		),
+		'database' => 'group',
+		'username' => 'root',
+		'password' => '123456',
+		'charset' => 'utf8',
+	),
+
+	'applet' => array
+	(
+		'type' => 'pdo',
+		'host' => array
+		(
+			'read' => 'web-mysql:3306',
+			'update' => 'web-mysql:3306',
+		),
+		'database' => 'my',
+		'username' => 'root',
+		'password' => '123456',
+		'charset' => 'utf8',
+	),
+);
+
+# 缓存配置
+$config['cache'] = array
+(
+	# 启用mysql数据库缓存,这个缓存是根据表名自动生成,dever::load形式和service的all、one形式均自动支持,无需手动添加
+	'mysql' => 0,
+	# 启用页面缓存 会根据当前的url来生成缓存,相当于页面静态化。
+	'html' => 0,
+	# 启用数据级别缓存 这个缓存是程序员自定义的:Dever::cache('name', 'value', 3600);
+	'data' => 3600,
+	# 启用load加载器缓存,一般不加载
+	'load' => 0,
+	# 启用load加载器的远程加载缓存
+	'curl' => 3600,
+
+	# 缓存精细控制,可以根据缓存的key(mysql为表名、service为小写类名,规则是模糊匹配),来控制每一条缓存
+	'loadKey' => array
+	(
+		# 定义缓存名为auth.data的缓存时间
+		'auth.data' => 200,
+	),
+	
+	# 缓存清理的参数名,请通过shell=clearcache执行
+	'shell' => 'clearcache',
+
+	# 是否启用key失效时间记录,启用之后,将会记录每个key的失效时间
+	'expire' => true,
+
+	# 缓存类型
+	'type' => 'memcache',//memcache、redis
+
+	# 缓存保存方式,支持多个数据源、多台缓存服务器
+	'store' => array
+	(
+		/*
+		array
+		(
+			'host' => 'server_memcached',
+			'port' => '11211',
+			'weight' => 100,
+		),
+
+		array
+		(
+			'host' => 'server_memcached',
+			'port' => '11212',
+			'weight' => 100,
+		),
+		*/
+	),
+);
+
+# debug配置
+$config['debug'] = array
+(
+	# 开启错误提示 生产环境建议禁止
+	'error' => true,
+	
+	# 错误日志记录,为空则不开启,为数组则为socket等服务
+	'log' => true,//array('type' => 'udp', 'host' => 'host', 'port' => 'port')
+	# 是否开启记录超时时间,单位为秒
+	'overtime' => 3,
+
+	# 开始访问报告
+	# 生产环境建议禁止或添加ip限制,多个ip用逗号隔开
+	# 如禁止,值为false,下述shell也将失效
+	# 值为2,则开启强制模式,任何输出都将打印debug
+	'request' => Dever::ip(),
+
+	# 设定打印访问报告的指令
+	'shell' => 'debug',
+	# 以上指令,请通过&shell=debug来执行,如果你想设置断点或者打印当前业务逻辑下的sql,请直接用Dever::debug();打印数据
+
+);
+$local = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost';
+# 本地可用这个
+$host = 'http://'.$local . '/';
+
+# 定义assets的域名
+$assets = DEVER_APP_HOST . 'assets/';
+if (DEVER_APP_NAME == 'manage') {
+	$assets = $host . 'dever_package/manage/assets/';
+}
+
+# host 设置
+$config['host'] = array
+(
+	# 跟域名
+	'base' 	=> DEVER_APP_HOST,
+
+	# cookie 域名
+	'cookie' => '',
+	
+	# assets网络路径,会自动将assets替换为assets/模板
+	'assets' => $assets,
+	# public
+	'public' => $assets . 'public/',
+	'css' => $assets . 'css/',
+	'js' => $assets . 'js/',
+	'img' => $assets . 'img/',
+	'images' => $assets . 'images/',
+	'lib' => $assets . 'lib/',
+
+	# 后台管理系统的assets路径
+	'manage' => $host . 'dever_package/manage/assets/public/',
+	
+	# 合并之后的网络路径,填写之后自动合并资源,不填写则不合并,适合把资源放到云端
+	'merge' => $host . 'applet/data/assets/' . DEVER_PROJECT . '/',
+	
+	# 上传系统的上传路径的域名(不带action)
+	'upload'=> $host . 'applet/upload/?save',
+	# 上传系统的资源访问地址
+	'uploadRes'	=> $host . 'applet/data/upload/',
+
+	# 域名替换,支持*通配符
+	/*
+    'domain' => array
+    (
+        'rule' => function()
+        {
+            $source = $desc = 'http://';
+            if(function_exists('isHttps') && isHttps())
+            {
+                $desc = 'https://';
+            }
+
+            return array($source, $desc);
+        },
+        'replace' => array('*.selfimg.com.cn')
+    ),
+    */
+	
+	# 是否启用代理功能
+	//'proxy' => $host . 'dever/application/applet/main/?data.proxy?',
+
+	# 项目定义,Dever::load将自动转为这个配置,替换掉data/project/default.php里的数据
+	'project' => array
+	(
+		/*
+		'set' => array
+		(
+			'url' => 'http://cm.5dev.cn/applet_on/set/?',
+			'path' => 'http://cm.5dev.cn/applet_on/set/?',
+		),
+		*/
+	),
+);
+
+if (DEVER_APP_NAME == 'manage') {
+	$config['host']['merge'] = false;
+}
+
+return $config;

+ 14 - 0
config/plugin.php

@@ -0,0 +1,14 @@
+<?php
+//插件配置
+$config = array
+(
+	# manage 下的 node类
+	'manage/node.get_api' => array
+	(
+		'start' => 'test.get',
+		//'end' => 'test.get',
+		//'cover' => 'test.get',
+	),
+);
+
+return $config;

+ 6 - 0
config/route.php

@@ -0,0 +1,6 @@
+<?php
+
+return array
+(
+	'home' => 'home',
+);

+ 2 - 0
index.php

@@ -0,0 +1,2 @@
+<?php
+include('main/index.php');

+ 7 - 0
manage/daemon/loop.php

@@ -0,0 +1,7 @@
+<?php
+
+define('DEVER_DAEMON', true);
+
+include(dirname(__FILE__) . DIRECTORY_SEPARATOR . '../index.php');
+
+Dever::load('manage/project.loop');

+ 7 - 0
manage/daemon/main.php

@@ -0,0 +1,7 @@
+<?php
+
+define('DEVER_DAEMON', true);
+
+include(dirname(__FILE__) . DIRECTORY_SEPARATOR . '../index.php');
+
+Dever::load('manage/project.cron');

+ 4 - 0
manage/index.php

@@ -0,0 +1,4 @@
+<?php
+define('DEVER_PACKAGE',  'manage');
+define('DEVER_APP_SETUP', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+include(dirname(__FILE__) . DIRECTORY_SEPARATOR . '../boot.php');

+ 4 - 0
passport/index.php

@@ -0,0 +1,4 @@
+<?php
+define('DEVER_PACKAGE',  'passport');
+define('DEVER_APP_SETUP', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+include(dirname(__FILE__) . DIRECTORY_SEPARATOR . '../boot.php');

+ 81 - 0
task/database/cate.php

@@ -0,0 +1,81 @@
+<?php
+
+
+return array
+(
+    # 表名
+    'name' => 'cate',
+    # 显示给用户看的名称
+    'lang' => '任务类别',
+    'order' => 98,
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            //'search'  => 'order',
+            'order'     => 'desc',
+            'list'      => true,
+        ),
+        
+        'name'      => array
+        (
+            'type'      => 'varchar-60',
+            'name'      => '名称',
+            'default'   => '',
+            'desc'      => '名称',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'reorder'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '排序(数值越大越靠前)',
+            'default'   => '1',
+            'desc'      => '请输入排序',
+            'match'     => 'option',
+            'update'    => 'text',
+            'search'    => 'order',
+            'list_name' => '排序',
+            'list'      => true,
+            'order'     => 'desc',
+            'edit'      => true,
+        ),
+
+        'state'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
+        
+        'cdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '录入时间',
+            'match'     => array('is_numeric', time()),
+            'desc'      => '',
+            # 只有insert时才生效
+            'insert'    => true,
+            'search'    => 'date',
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+    
+    'manage' => array
+    (
+        //'insert' => false,
+        //'edit' => false,
+        //'delete' => false,
+    ),
+);

+ 78 - 0
task/database/company.php

@@ -0,0 +1,78 @@
+<?php
+
+
+return array
+(
+    # 表名
+    'name' => 'company',
+    # 显示给用户看的名称
+    'lang' => '商家管理',
+    'order' => 10,
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            //'search'  => 'order',
+            'order'     => 'desc',
+            'list'      => true,
+        ),
+        
+        'name'      => array
+        (
+            'type'      => 'varchar-60',
+            'name'      => '商家名称',
+            'default'   => '',
+            'desc'      => '商家名称',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'link'      => array
+        (
+            'type'      => 'varchar-200',
+            'name'      => '商家网址',
+            'default'   => '',
+            'desc'      => '商家网址',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'state'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
+        
+        'cdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '录入时间',
+            'match'     => array('is_numeric', time()),
+            'desc'      => '',
+            # 只有insert时才生效
+            'insert'    => true,
+            'search'    => 'date',
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+    
+    'manage' => array
+    (
+        //'insert' => false,
+        //'edit' => false,
+        //'delete' => false,
+    ),
+);

+ 232 - 0
task/database/info.php

@@ -0,0 +1,232 @@
+<?php
+
+$cate = function()
+{
+	$array = array();
+	$info = Dever::db('task/cate')->state();
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+$level = function()
+{
+	$array = array();
+	$info = Dever::db('task/level')->state();
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+$company = function()
+{
+	$array = array();
+	$info = Dever::db('task/company')->state();
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+$demand = array
+(
+	'username' => '账号名',
+	'crop' => '截图',
+	'link' => '链接',
+	'desc' => '文字说明',
+);
+
+return array
+(
+	# 表名
+	'name' => 'info',
+	# 显示给用户看的名称
+	'lang' => '任务管理',
+	'order' => 200,
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			//'search'	=> 'order',
+			'order'		=> 'desc',
+			'list'		=> true,
+		),
+
+		'hr1'		=> array
+		(
+			'name' 		=> '基本设置',
+			'class'		=> '',//本项必须填写
+			'attr'		=> '',
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-60',
+			'name' 		=> '任务标题',
+			'default' 	=> '',
+			'desc' 		=> '任务标题',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'sdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '开始日',
+			'match' 	=> 'is_numeric',
+			'desc' 		=> '开始时间',
+			'update'	=> 'time',
+			//'list'		=> 'date("Y-m-d H:i:s", {sdate})',
+			'callback'	=> 'maketime',
+			'list_name'	=> '时间',
+			'list' => 'date("Y-m-d", {sdate})."~".date("Y-m-d", {edate})'
+		),
+
+		'edate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '结束日',
+			'match' 	=> 'is_numeric',
+			'desc' 		=> '结束日',
+			'update'	=> 'time',
+			//'list'		=> 'date("Y-m-d H:i:s", {edate})',
+			'callback'	=> 'maketime',
+		),
+
+		'company_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '所属商家',
+			'default' 	=> '',
+			'desc' 		=> '所属商家',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'select',
+			'search'	=> 'select',
+			'option'	=> $company,
+			'list'		=> true,
+		),
+
+		'level_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '任务级别',
+			'default' 	=> '',
+			'desc' 		=> '任务级别',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'select',
+			'search'	=> 'select',
+			'option'	=> $level,
+			'list'		=> true,
+		),
+
+		'cate_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '任务类别',
+			'default' 	=> '',
+			'desc' 		=> '任务类别',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'search'	=> 'select',
+			'option'	=> $cate,
+			'list'		=> true,
+		),
+
+		'hr2'		=> array
+		(
+			'name' 		=> '限制设置',
+			'class'		=> '',//本项必须填写
+			'attr'		=> '',
+		),
+
+		'num'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '领取人数',
+			'default' 	=> '0',
+			'match' 	=> '领取人数',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'text',
+			//'list'		=> true,
+		),
+
+		'report_num'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '报告上限',
+			'default' 	=> '0',
+			'match' 	=> '报告上限',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'text',
+			//'list'		=> true,
+		),
+
+		'hr3'		=> array
+		(
+			'name' 		=> '限制设置',
+			'class'		=> '',//本项必须填写
+			'attr'		=> '',
+		),
+
+		'report_demand'		=> array
+		(
+			'type' 		=> 'varchar-50',
+			'name' 		=> '报告要求',
+			'default' 	=> 'username',
+			'desc' 		=> '状态',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'checkbox',
+			'option'	=> $demand,
+			//'list'		=> true,
+		),
+
+		'content'		=> array
+		(
+			'type' 		=> 'text-255',
+			'name' 		=> '任务说明',
+			'default' 	=> '',
+			'desc' 		=> '任务说明',
+			'match' 	=> 'option',
+			'update'	=> 'editor',
+		),
+
+		'state'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '状态',
+			'default' 	=> '1',
+			'desc' 		=> '请选择状态',
+			'match' 	=> 'is_numeric',
+		),
+		
+		'cdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '录入时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+			# 只有insert时才生效
+			'insert'	=> true,
+			//'search'	=> 'date',
+			//'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+	
+	'manage' => array
+	(
+		
+	),
+);

+ 93 - 0
task/database/level.php

@@ -0,0 +1,93 @@
+<?php
+
+
+return array
+(
+	# 表名
+	'name' => 'level',
+	# 显示给用户看的名称
+	'lang' => '任务级别',
+	'order' => 99,
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			//'search'	=> 'order',
+			'order'		=> 'desc',
+			'list'		=> true,
+		),
+		
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-60',
+			'name' 		=> '名称',
+			'default' 	=> '',
+			'desc' 		=> '名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'num'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '级别数字',
+			'default' 	=> '',
+			'desc' 		=> '名称',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序(数值越大越靠前)',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+			'search'	=> 'order',
+			'list_name' => '排序',
+			'list'		=> true,
+			'order'		=> 'desc',
+			'edit'		=> true,
+		),
+
+		'state'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '状态',
+			'default' 	=> '1',
+			'desc' 		=> '请选择状态',
+			'match' 	=> 'is_numeric',
+		),
+		
+		'cdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '录入时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+			# 只有insert时才生效
+			'insert'	=> true,
+			'search'	=> 'date',
+			'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+	
+	'manage' => array
+	(
+		//'insert' => false,
+		//'edit' => false,
+		//'delete' => false,
+	),
+);

+ 8 - 0
task/index.php

@@ -0,0 +1,8 @@
+<?php
+
+define('DEVER_APP_NAME', 'task');
+define('DEVER_APP_LANG', '任务系统');
+define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+define('DEVER_MANAGE_ORDER', 5);
+define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-briefcase');
+include(DEVER_APP_PATH . '../boot.php');

+ 617 - 0
task/src/User.php

@@ -0,0 +1,617 @@
+<?php
+
+namespace Share\Src;
+
+use Dever;
+
+class User
+{
+    const INFO = 'set/info:applet';
+    const SHARE = 'comment/share:applet';
+    const USER = 'passport/user:applet';
+    const NEWS = 'content/news:applet';
+    const COURSE = 'content/course:applet';
+    const MEETING = 'content/meeting:applet';
+    const SERVICE = 'content/service:applet';
+    const ACTIVE = 'activity/active:applet';
+    const REFLUX = 'comment/share_reflux:applet';
+    const SHARELOG = 'comment/share_log:applet';
+    const SHAREGROUP = 'comment/share_group:applet';
+
+    /**
+     * 小程序列表
+     *
+     * @return mixed
+     */
+    public function applet()
+    {
+        $info = Dever::db(self::INFO);
+        $data = $info->state();
+        return $data;
+    }
+
+    /**
+     * 导入excel
+     *
+     * @return mixed
+     */
+    public function import()
+    {
+        $file = Dever::data() . 'user.xlsx';
+        $reader = new \PHPExcel_Reader_Excel2007();
+        if(!$reader->canRead($file)){
+            $reader = new \PHPExcel_Reader_Excel5();
+            if(!$reader->canRead($file)){
+                echo 'no Excel';
+                return ;
+            }
+        }
+         
+        $xls = $reader->load($file);
+        $currentSheet = $xls->getSheet(0);
+        $column = $currentSheet->getHighestColumn();
+        $row = $currentSheet->getHighestRow();
+
+        $group = $name = $wechat = array();
+        for ($curRow = 5;$curRow <= $row; $curRow++) {
+            for ($curColumn = 'A';$curColumn<= $column; $curColumn++) {
+                $value = $currentSheet->getCellByColumnAndRow(ord($curColumn) - 65,$curRow)->getValue();
+                if ($curColumn == 'B') {
+                    //分组
+                    if ($value) {
+                        $group_id = Dever::upinto('share/group', array('name' => $value), array('name' => $value));
+                    }
+                    
+                } elseif ($curColumn == 'C') {
+                    //姓名
+                    if ($value && isset($group_id) && $group_id) {
+                        Dever::upinto('share/user', array('name' => $value), array('group_id' => $group_id, 'name' => $value));
+                    }
+                } elseif ($curColumn == 'D') {
+                    //微信
+                    $wechat[$value] = $value;
+                }
+            }
+        }
+    }
+
+    /**
+     * 导出成excel
+     *
+     * @return mixed
+     */
+    public function out()
+    {
+        $applet = $this->applet();
+        $group = Dever::db('share/group')->state();
+        $user = Dever::db('share/user')->getAll();
+
+        $day = Dever::input('day');
+        if (!$day) {
+            $day = date('Y-m-d', time()-3600*24);
+        }
+        $start = Dever::maketime(date('Y-m-01 00:00:00', Dever::maketime($day)));
+        $end = Dever::maketime(date('Y-m-t 23:59:59', Dever::maketime($day)));
+        
+        $log = Dever::db('share/log')->state();
+        $i = 0;
+        foreach ($user as $k => $v) {
+            if (!$v['wechat_name']) {
+                unset($user[$k]);
+                continue;
+            }
+            
+            $user[$k]['group'] = $group[$v['group_id']]['name'];
+            $user[$k]['info'] = Dever::db('share/info')->one(array('share_day' => $day, 'user_id' => $v['id']));
+            if (!$user[$k]['info']) {
+                $user[$k]['info']['share_article_num'] = 0;
+                $user[$k]['applet'] = '未知';
+            } else {
+                $user[$k]['applet'] = array();
+                if ($user[$k]['info']['applet']) {
+                    $temp = explode(',', $user[$k]['info']['applet']);
+                    foreach ($temp as $k1 => $v1) {
+                        $user[$k]['applet'][$k1] = $applet[$v1]['name'];
+                    }
+                }
+                
+                $user[$k]['applet'] = implode("\r\n", $user[$k]['applet']);
+            }
+            $user[$k]['log'] = Dever::db('share/log')->state(array('share_day' => $day, 'user_id' => $v['id']));
+            $total = Dever::db('share/log')->month(array('start' => $start, 'end' => $end, 'user_id' => $v['id']));
+            $user[$k]['total'] = 0;
+            if ($total) {
+                $user[$k]['total'] = $total['num'];
+            }
+
+            if (!$user[$k]['total']) {
+                $user[$k]['total'] = 0;
+            }
+
+            $user[$k]['status'] = '已达标';
+            if ($user[$k]['info']['share_article_num'] < 3) {
+                $user[$k]['status'] = '未达标';
+            }
+
+            if ($user[$k]['name'] && $user[$k]['info']) {
+                $data[$i] = array
+                (
+                    $i+1,
+                    $user[$k]['group'],
+                    $user[$k]['name'],
+                    $user[$k]['wechat_name'],
+                    $user[$k]['applet'],
+                    $user[$k]['info']['share_article_num'],
+                    $user[$k]['total'],
+                    $user[$k]['status'],
+                );
+                $i++;
+            }
+        }
+        $header = array
+        (
+            '序号', '业务板块', '姓名', '微信昵称', '负责小程序名称', '分享文章数', '月总回流', '是否达标'
+        );
+
+        $file = $day . '_小程序推广';
+        if (Dever::input('test')) {
+            print_r($header);
+            print_r($data);die;
+        }
+        
+        Dever::excelExport($data, $header, $file, $sheet = 0, $sheetName = $day);
+        return;
+    }
+
+    public function test()
+    {
+        $name = '姓名';
+        $header = array
+        (
+            $name,'手机号'
+        );
+        $data = array
+        (
+            array
+            (
+                '于斌', '15810090845'
+            ),
+            array
+            (
+                '3', '4'
+            ),
+        );
+        Dever::excelExport($data, $header, $filename = 'test');
+    }
+
+    /**
+     * 获取数据
+     *
+     * @return mixed
+     */
+    public function data()
+    {
+        $user = Dever::db('share/user')->state();
+        foreach ($user as $k => $v) {
+            if ($v['wechat_name']) {
+                $user[$k] = $this->userData($v);
+            }
+        }
+        return true;
+    }
+
+    public function userData($data)
+    {
+        if ($data['uid']) {
+            $where = array
+            (
+                'option' => array
+                (
+                    'id' => array('yes', 'in'),
+                ),
+                'id' => explode(',', $data['uid']),
+            );
+            $user = Dever::db(self::USER)->state($where);
+        } else {
+            $user = Dever::db(self::USER)->state(array('name' => $data['wechat_name']));
+        }
+
+        $ids = array();
+        if ($user) {
+            $ids = array_keys($user);
+        }
+        
+        if ($ids) {
+            $user = array();
+            $option = array
+            (
+                'share_id' => 'yes',
+                'uid' => array('yes', 'in'),
+                'start' => array('yes-cdate', '>='),
+                'end' => array('yes-cdate', '<='),
+            );
+
+            //获取昨天数据
+            $time = time() - (3600 * 24);
+            $set = Dever::input('set');
+            if ($set) {
+                $time = Dever::maketime($set);
+            }
+            $day = date('Y-m-d', $time);
+            $day_prev = date('Y-m-d', strtotime("$day -1 day"));//前天
+
+            $start = date('Y-m-d 00:00:00', $time);
+            $end = date('Y-m-d 23:59:59', $time);
+            
+            $day_start = Dever::maketime($start);
+            $day_end = Dever::maketime($end);
+            $where = array
+            (
+                'option' => $option,
+                'uid' => $ids,
+                'start' => $day_start,
+                'end' => $day_end
+            );
+            $share = Dever::db(self::SHARE)->state($where);
+            if ($share) {
+                $user['applet'] = array();
+                //$user['applet'] = $data['applet'];
+                $user['user_id'] = $data['id'];
+                $user['share_day'] = $day;
+                $user['share_num'] = 0;
+                //$user['share_reflux_num'] = Dever::db(self::REFLUX)->total(array('source_uid' => $user['id']));
+                //获取月度回流
+                unset($where['option']['uid']);
+                $where['option']['source_uid'] = array('yes', 'in');
+                $where['source_uid'] = $ids;
+
+                //$user['share_reflux_num'] = Dever::db(self::REFLUX)->total($where);
+                $user['share_group_num'] = $user['share_reflux_num'] = 0;
+                $article = array();
+                foreach ($share as $k => $v) {
+                    $info = $this->shareData($v, $where, $article);
+                    if ($info) {
+                        $user['applet'][$info['applet']['id']] = $info['applet']['id'];
+                        $article[$info['source_table'] . '_' . $info['id']] = 1;
+                        $user['share'][$k] = $info;
+                        $user['share_num'] += $user['share'][$k]['num'];
+                        $user['share_group_num'] += $user['share'][$k]['group_num'];
+                        $user['share_reflux_num'] += $user['share'][$k]['reflux_num'];
+                    }
+                }
+
+                $user['applet'] = implode(',', $user['applet']);
+                $user['share_article_num'] = count($article);
+
+                $this->updateInfo($user, $day_prev);
+            }
+        }
+
+        return $user;
+    }
+
+
+    public function shareData($data, $where)
+    {
+        $result = array();
+        $table = false;
+        switch ($data['source_table']) {
+            case 1:
+                $table = self::NEWS;
+                break;
+            case 2:
+                $table = self::COURSE;
+                break;
+            case 3:
+                $table = self::MEETING;
+                break;
+            case 5:
+                $table = self::SERVICE;
+                break;
+            case 8:
+                $table = self::ACTIVE;
+                break;
+        }
+
+        if ($table && $data['source_id'] > 0) {
+            $info = Dever::db($table)->one($data['source_id']);
+            if ($info) {
+                $result['applet'] = Dever::db(self::INFO)->one($data['info_id']);
+                $result['source_table'] = $data['source_table'];
+                $result['id'] = $info['id'];
+                $result['name'] = $info['name'];
+                $result['time'] = date('Y-m-d H:i:s', $data['cdate']);
+                $result['cdate'] = $data['cdate'];
+                $result['num'] = $data['num'];
+                $result['group_num'] = $data['group_num'];
+
+                $where['share_id'] = $data['id'];
+                $result['reflux_num'] = Dever::db(self::REFLUX)->total($where);
+
+                unset($where['option']['source_uid']);
+
+                $result['num'] = Dever::db(self::SHARELOG)->total($where);
+                $result['group_num'] = Dever::db(self::SHAREGROUP)->total($where);
+
+                if ($result['num'] <= 0) {
+                    $result['reflux_num'] = 0;
+                }
+
+                if ($result['group_num'] > $result['num']) {
+                    $result['num'] = $result['group_num'];
+                }
+            }
+        }
+
+        return $result;
+    }
+
+    public function updateInfo($user, $day_prev)
+    {
+        # 获取上个月的数据 减去上个月的数据
+        /*
+        if ($user['share_day'] != $day_prev) {
+            $where = array();
+            $where['option_user_id'] = $user['user_id'];
+            $where['option_share_day'] = $day_prev;
+            $prev = Dever::db('share/info')->one($where);
+            if ($prev) {
+                $user['share_num'] = $user['share_num'] - $prev['share_num'];
+                $user['share_group_num'] = $user['share_group_num'] - $prev['share_group_num'];
+            }
+        }*/
+        $update = array();
+        $update['user_id'] = $user['user_id'];
+        $update['applet'] = $user['applet'];
+        $update['share_day'] = $user['share_day'];
+        $update['share_num'] = $user['share_num'];
+        $update['share_reflux_num'] = $user['share_reflux_num'];
+        $update['share_article_num'] = $user['share_article_num'];
+        $update['share_group_num'] = $user['share_group_num'];
+        $update['status'] = 1;
+        if ($update['share_article_num'] >= 3) {
+            $update['status'] = 2;
+        }
+
+        $where = array();
+        $where['option_user_id'] = $update['user_id'];
+        $where['option_share_day'] = $update['share_day'];
+
+        $info = Dever::db('share/info')->one($where);
+        if (!$info) {
+            $id = Dever::db('share/info')->insert($update);
+        } else {
+            $id = $info['id'];
+            $update['where_id'] = $id;
+            Dever::db('share/info')->update($update);
+        }
+
+        if ($id > 0 && isset($user['share'])) {
+            $user['share_num'] = 0;
+            $user['share_group_num'] = 0;
+            foreach ($user['share'] as $k => $v) {
+                $result = $this->updateLog($k, $v, $id, $update['user_id'], $user['share_day'], $day_prev);
+                if (isset($result['share_num'])) {
+                    $update['share_num'] += $result['share_num'];
+                }
+                if (isset($result['share_group_num'])) {
+                    $update['share_group_num'] += $result['share_group_num'];
+                }
+            }
+            if ($user['share_num'] > 0) {
+                $update = array();
+                $update['share_num'] = $user['share_num'];
+                $update['share_group_num'] = $user['share_group_num'];
+                $update['where_id'] = $id;
+                Dever::db('share/info')->update($update);
+            }
+        }
+    }
+
+    public function updateLog($share_id, $data, $info_id, $user_id, $day, $day_prev)
+    {
+        $prev = array();
+        /*
+        if ($day != $day_prev) {
+            $where = array();
+            $where['option_share_id'] = $share_id;
+            $where['option_user_id'] = $user_id;
+            $where['option_info_id'] = $info_id;
+            $where['option_source_id'] = $data['id'];
+            $where['option_share_day'] = $day_prev;
+            $where['option_applet'] = $data['applet']['id'];
+            $prev = Dever::db('share/log')->one($where);
+            if ($prev) {
+                $data['num'] = $data['num'] - $prev['share_num'];
+                $data['group_num'] = $data['group_num'] - $prev['share_group_num'];
+            }
+        }
+        */
+        $update = array();
+        $update['user_id'] = $user_id;
+        $update['info_id'] = $info_id;
+        $update['share_id'] = $share_id;
+        $update['share_day'] = $day;
+        $update['applet'] = $data['applet']['id'];
+        $update['name'] = $data['name'];
+        $update['source_id'] = $data['id'];
+        $update['source_table'] = $data['source_table'];
+        $update['share_num'] = $data['num'];
+        $update['sdate'] = $data['cdate'];
+        $update['share_group_num'] = $data['group_num'];
+        $update['share_reflux_num'] = $data['reflux_num'];
+
+        $where = array();
+        $where['option_share_id'] = $update['share_id'];
+        $where['option_user_id'] = $update['user_id'];
+        $where['option_info_id'] = $update['info_id'];
+        $where['option_source_id'] = $update['source_id'];
+        $where['option_share_day'] = $update['share_day'];
+        $where['option_applet'] = $update['applet'];
+
+        $info = Dever::db('share/log')->one($where);
+        if (!$info) {
+            Dever::db('share/log')->insert($update);
+        } else {
+            $update['where_id'] = $info['id'];
+            Dever::db('share/log')->update($update);
+        }
+
+        if ($prev) {
+            return array
+            (
+                'share_num' => $data['num'],
+                'share_group_num' => $data['group_num'],
+            );
+        }
+        return array();
+    }
+
+    /*
+    public function userMonthData($data)
+    {
+        $user = Dever::db(self::USER)->one(array('name' => $data['wechat_name']));
+        if ($user) {
+            $option = array
+            (
+                'share_id' => 'yes',
+                'uid' => 'yes',
+                'start' => array('yes-cdate', '>='),
+                'end' => array('yes-cdate', '<='),
+            );
+
+            //获取昨天数据
+            $time = time() - (3600 * 24);
+            $set = Dever::input('set');
+            if ($set) {
+                $time = Dever::maketime($set);
+            }
+            $month = date('Y-m-d', $time);
+            $month_end = date('Y-m-t', $time);
+            $month_cur = date('Y-m-d', $time);
+            $month_prev = date('Y-m', strtotime("$month -1 month"));//上个月
+
+            $start = date('Y-m-01 00:00:00', $time);
+            if ($month_end == $month_cur || $set) {
+                $user['status'] = 1;//本月已经到月底
+                $end = date('Y-m-t 23:59:59', $time);
+            } else {
+                $user['status'] = 2;//本月还未到月底
+                $end = date('Y-m-d 23:59:59', $time);
+            }
+            
+            $month_start = Dever::maketime($start);
+            $month_end = Dever::maketime($end);
+            $where = array
+            (
+                'option' => $option,
+                'uid' => $user['id'],
+                'start' => $month_start,
+                'end' => $month_end
+            );
+            $share = Dever::db(self::SHARE)->state($where);
+            if ($share) {
+                $user['applet'] = $data['applet'];
+                $user['user_id'] = $data['id'];
+                $user['share_month'] = $month;
+                $user['share_month_se'] = $start . '-' . $end;
+                $user['share_num'] = 0;
+                //$user['share_reflux_num'] = Dever::db(self::REFLUX)->total(array('source_uid' => $user['id']));
+                //获取月度回流
+                unset($where['option']['uid']);
+                $where['option']['source_uid'] = $user['id'];
+
+                $user['share_month_reflux_num'] = Dever::db(self::REFLUX)->total($where);
+                $user['share_group_num'] = 0;
+                foreach ($share as $k => $v) {
+                    $info = $this->shareData($v, $where);
+                    if ($info && $info['num'] > 0) {
+                        $user['share'][$k] = $info;
+                        $user['share_num'] += $user['share'][$k]['num'];
+                        $user['share_group_num'] += $user['share'][$k]['group_num'];
+                    }
+                }
+
+                $this->updateInfo($user, $month_prev);
+            }
+        }
+
+        return $user;
+    }
+
+    public function updateInfo($user, $month_prev)
+    {
+        # 获取上个月的数据 减去上个月的数据
+        if ($user['share_month'] != $month_prev) {
+            $where = array();
+            $where['option_user_id'] = $user['user_id'];
+            $where['option_share_month'] = $month_prev;
+            $prev = Dever::db('share/info')->one($where);
+            if ($prev) {
+                $user['share_num'] = $user['share_num'] - $prev['share_num'];
+                $user['share_group_num'] = $user['share_group_num'] - $prev['share_group_num'];
+            }
+        }
+        $update = array();
+        $update['user_id'] = $user['user_id'];
+        $update['applet'] = $user['applet'];
+        $update['share_month'] = $user['share_month'];
+        $update['share_month_se'] = $user['share_month_se'];
+        $update['share_num'] = $user['share_num'];
+        $update['share_month_reflux_num'] = $user['share_month_reflux_num'];
+        $update['share_group_num'] = $user['share_group_num'];
+        $update['status'] = $user['status'];
+
+        $where = array();
+        $where['option_user_id'] = $update['user_id'];
+        $where['option_share_month'] = $update['share_month'];
+
+        $info = Dever::db('share/info')->one($where);
+        if (!$info) {
+            $id = Dever::db('share/info')->insert($update);
+        } else {
+            $id = $info['id'];
+            $update['where_id'] = $id;
+            Dever::db('share/info')->update($update);
+        }
+
+        if ($id > 0 && $user['share']) {
+            foreach ($user['share'] as $k => $v) {
+                $this->updateLog($k, $v, $id, $update['user_id'], $user['share_month']);
+            }
+        }
+    }
+
+    public function updateLog($share_id, $data, $info_id, $user_id, $month)
+    {
+        $update = array();
+        $update['user_id'] = $user_id;
+        $update['info_id'] = $info_id;
+        $update['share_id'] = $share_id;
+        $update['share_month'] = $month;
+        $update['applet'] = $data['applet']['id'];
+        $update['name'] = $data['name'];
+        $update['source_id'] = $data['id'];
+        $update['source_table'] = $data['source_table'];
+        $update['share_num'] = $data['num'];
+        $update['sdate'] = $data['cdate'];
+        $update['share_group_num'] = $data['group_num'];
+        $update['share_reflux_num'] = $data['month_reflux_num'];
+
+        $where = array();
+        $where['option_share_id'] = $update['share_id'];
+        $where['option_user_id'] = $update['user_id'];
+        $where['option_info_id'] = $update['info_id'];
+        $where['option_source_id'] = $update['source_id'];
+        $where['option_share_month'] = $update['share_month'];
+        $where['option_applet'] = $update['applet'];
+
+        $info = Dever::db('share/log')->one($where);
+        if (!$info) {
+            Dever::db('share/log')->insert($update);
+        } else {
+            $update['where_id'] = $info['id'];
+            Dever::db('share/log')->update($update);
+        }
+    }*/
+}

+ 4 - 0
upload/index.php

@@ -0,0 +1,4 @@
+<?php
+define('DEVER_PACKAGE',  'upload');
+define('DEVER_APP_SETUP', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+include(dirname(__FILE__) . DIRECTORY_SEPARATOR . '../boot.php');