rabin 1 tahun lalu
melakukan
7cd2fa21d4
19 mengubah file dengan 2641 tambahan dan 0 penghapusan
  1. 2 0
      README.md
  2. 44 0
      api/main.php
  3. 232 0
      database/address.php
  4. 244 0
      database/auth.php
  5. 105 0
      database/avatar.php
  6. 296 0
      database/info.php
  7. 225 0
      database/invoice.php
  8. 128 0
      database/login.php
  9. 167 0
      database/project.php
  10. 152 0
      database/stat.php
  11. 84 0
      database/user_project.php
  12. 212 0
      database/wechat.php
  13. 13 0
      index.php
  14. 128 0
      lib/Address.php
  15. 116 0
      lib/Info.php
  16. 65 0
      lib/Stat.php
  17. 80 0
      src/Address.php
  18. 218 0
      src/Info.php
  19. 130 0
      src/Invoice.php

+ 2 - 0
README.md

@@ -0,0 +1,2 @@
+# user
+

+ 44 - 0
api/main.php

@@ -0,0 +1,44 @@
+<?php
+# 注册api,这里是为了安全考虑,否则可以不用在此注册,注册之后
+# api仅有三种类型:get、update、delete
+
+return array
+(
+	/*
+	'reg.getMCode' => array
+	(
+		'name' => '获取验证码:手机号未注册',
+		'request' => array
+		(
+			'sid' => '临时id',
+			'skin' => '模板',
+		),
+		'response' => array
+		(
+			'info' => '响应信息',
+		),
+		'order' => 100,
+		'type' => 2,
+		# 安全加密
+		'secure' => true,
+	),
+
+	'reg.getMCodeLogin' => array
+	(
+		'name' => '获取验证码:手机号已注册',
+		'request' => array
+		(
+			'sid' => '临时id',
+			'skin' => '模板',
+		),
+		'response' => array
+		(
+			'info' => '响应信息',
+		),
+		'order' => 99,
+		'type' => 2,
+		# 安全加密
+		'secure' => true,
+	),
+	*/
+);

+ 232 - 0
database/address.php

@@ -0,0 +1,232 @@
+<?php
+
+$type = array
+(
+	1 => '普通地址',
+	2 => '默认地址',
+);
+
+$tag = array
+(
+    1 => '公司',
+    2 => '家',
+    3 => '学校',
+    4 => '其他',
+);
+
+return array
+(
+    # 表名
+    'name' => 'address',
+    # 显示给用户看的名称
+    'lang' => '用户地址库',
+    'end' => array
+	(
+		'insert' => 'user/lib/address.manage_update',
+		'update' => 'user/lib/address.manage_update',
+	),
+    'menu' => false,
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'update'    => 'hidden',
+            //'list'        => true,
+        ),
+
+        'uid'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '用户名',
+			'default' 	=> '0',
+			'desc' 		=> '请选择用户',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'hidden',
+			'search'    => array
+            (
+                'api' => 'user/info-like',
+                'col' => 'search',
+                'result' => 'id',
+            ),
+            'value'     => Dever::input('search_option_uid'),
+			'list'       => 'Dever::load("user/lib/info.get#name", {uid})',
+		),
+
+		'type'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '类型',
+			'default' 	=> '2',
+			'desc' 		=> '类型',
+			'match' 	=> 'is_numeric',
+			'option' 	=> $type,
+			'update'	=> 'radio',
+			'list'		=> true,
+			'order'		=> 'desc',
+		),
+
+		'truename'		=> array
+		(
+			'type' 		=> 'varchar-100',
+			'name' 		=> '联系人',
+			'default' 	=> '',
+			'desc' 		=> '联系人',
+			'match' 	=> 'option',
+			'search'	=> 'fulltext',
+			'update'	=> 'text',
+			'list'		=> true,
+		),
+
+		'tel'		=> array
+		(
+			'type' 		=> 'varchar-100',
+			'name' 		=> '联系电话',
+			'default' 	=> '',
+			'desc' 		=> '联系电话',
+			'match' 	=> 'option',
+			'search'	=> 'fulltext',
+			'update'	=> 'text',
+			'list'		=> true,
+		),
+
+		'province'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '省份',
+			'default' 	=> '',
+			'desc' 		=> '省份',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+		),
+
+		'city'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '城市',
+			'default' 	=> '',
+			'desc' 		=> '城市',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+		),
+
+		'county'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '县区',
+			'default' 	=> '',
+			'desc' 		=> '县区',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+		),
+
+		'town'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '街道',
+			'default' 	=> '',
+			'desc' 		=> '街道',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+		),
+
+		'area'		=> array
+		(
+			'type' 		=> 'varchar-800',
+			'name' 		=> '城市地区',
+			'default' 	=> '',
+			'desc' 		=> '城市地区',
+			'match' 	=> 'is_string',
+			'search'	=> 'linkage',
+			'update'	=> 'linkage',
+			'option'	=> Dever::url('api.get?level_total=3', 'area'),
+			'list'		=> 'Dever::load("area/api.string", "{area}")',
+		),
+
+		'address'		=> array
+		(
+			'type' 		=> 'varchar-1000',
+			'name' 		=> '详细地址',
+			'default' 	=> '',
+			'desc' 		=> '详细地址',
+			'match' 	=> 'option',
+			'update'	=> 'textarea',
+			'list'		=> true,
+		),
+
+        'tag'      => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '标签',
+            'default'   => '1',
+            'desc'      => '标签',
+            'match'     => 'is_numeric',
+            'option'    => $tag,
+            'update'    => 'radio',
+            '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
+    (
+        
+    ),
+
+    'request' => array
+    (
+		'getList' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'uid' => 'yes',
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('type' => 'desc','id' => 'desc'),
+			'page' => array(10, 'list'),
+			'col' => '*',
+		),
+
+        'updateType' => array
+        (
+            'set' => array
+            (
+                'type' => 'yes',
+            ),
+            'where' => array
+            (
+                'type' => 'yes',
+            ),
+            'type' => 'update',
+        ),
+    ),
+);

+ 244 - 0
database/auth.php

@@ -0,0 +1,244 @@
+<?php
+
+$type = array
+(
+	1 => '个人',
+	2 => '个体户',
+	3 => '企业',
+);
+
+$status = array
+(
+    1 => '已认证',
+    2 => '未认证',
+);
+
+return array
+(
+	# 表名
+	'name' => 'auth',
+	# 显示给用户看的名称
+	'lang' => '认证管理',
+	# 是否显示在后台菜单
+	'order' => 9,
+    'menu' => false,
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+		),
+
+		'uid'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '用户名',
+			'default' 	=> '0',
+			'desc' 		=> '请选择用户',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'hidden',
+			'search'    => array
+            (
+                'api' => 'user/info-like',
+                'col' => 'search',
+                'result' => 'id',
+            ),
+            'value'     => Dever::input('search_option_uid'),
+			'list'       => 'Dever::load("user/lib/info.get#name", {uid})',
+		),
+
+        'name'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '真实姓名',
+            'default'   => '',
+            'desc'      => '真实姓名',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'tel'      => array
+        (
+            'type'      => 'varchar-50',
+            'name'      => '联系电话',
+            'default'   => '',
+            'desc'      => '联系电话',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'email'      => array
+        (
+            'type'      => 'varchar-50',
+            'name'      => '联系邮箱',
+            'default'   => '',
+            'desc'      => '联系邮箱',
+            'match'     => 'option',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'area'       => array
+        (
+            'type'      => 'varchar-500',
+            'name'      => '城市地区',
+            'default'   => '',
+            'desc'      => '城市地区',
+            'match'     => 'option',
+            'search'    => 'linkage',
+            'update'    => 'linkage',
+            'option'    => Dever::url('api.get?level_total=3', 'area'),
+            'list'      => 'Dever::load("area/api.string", "{area}")',
+        ),
+
+        'address'       => array
+        (
+            'type'      => 'varchar-1000',
+            'name'      => '联系地址',
+            'default'   => '',
+            'desc'      => '联系地址',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'      => true,
+        ),
+
+        'idcard'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '身份证号',
+            'default'   => '',
+            'desc'      => '身份证号',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'      => true,
+        ),
+
+        'type'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '认证身份',
+            'default'   => '1',
+            'desc'      => '认证身份',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'search'    => 'select',
+            'option'    => $type,
+            'control'	=> 'type',
+            'list'      => true,
+        ),
+
+        'idcard_front'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '身份证正面-如果是个人,这里上传联系人身份证,如果是个体户或者企业,这里上传法人身份证',
+            'default'   => '',
+            'desc'      => '身份证正面',
+            'match'     => 'option',
+            'update'    => 'image',
+            'key'       => '8',
+        ),
+
+        'idcard_back'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '身份证背面-如果是个人,这里上传联系人身份证,如果是个体户或者企业,这里上传法人身份证',
+            'default'   => '',
+            'desc'      => '身份证背面',
+            'match'     => 'option',
+            'update'    => 'image',
+            'key'       => '8',
+        ),
+
+        'company_license'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '营业执照',
+            'default'   => '',
+            'desc'      => '企业营业执照',
+            'match'     => 'option',
+            'update'    => 'image',
+            'key'       => '8',
+            'show'		=> 'identity=2,3',
+        ),
+
+        'company_name'      => array
+        (
+            'type'      => 'varchar-200',
+            'name'      => '企业全称',
+            'default'   => '',
+            'desc'      => '企业全称',
+            'match'     => 'option',
+            //'update'    => 'text',
+            'show'      => 'identity=2,3',
+        ),
+
+        'company_number'      => array
+        (
+            'type'      => 'varchar-200',
+            'name'      => '社会信用代码',
+            'default'   => '',
+            'desc'      => '社会信用代码',
+            'match'     => 'option',
+            //'update'    => 'text',
+            'show'      => 'identity=2,3',
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '状态',
+            'match'     => 'is_numeric',
+            'update'  => 'select',
+            'option'    => $status,
+            'search'    => 'select',
+            '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
+    (
+        'delete' => false,
+        //'edit' => false,
+        'insert' => false,
+
+        # 列表
+        'list_button' => array
+        (
+            //'fast_add' => array('账户操作', 'push&project=account&uid={id}'),
+        ),
+    ),
+);

+ 105 - 0
database/avatar.php

@@ -0,0 +1,105 @@
+<?php
+
+$sex = array
+(
+    -1 => '系统',
+    1 => '男',
+    2 => '女',
+    3 => '中性',
+    4 => '全部',
+);
+
+return array
+(
+    # 表名
+    'name' => 'avatar',
+    # 显示给用户看的名称
+    'lang' => '默认头像',
+    'order' => -1,
+
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order,fulltext',
+            'list'      => true,
+        ),
+
+        'sex'       => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '头像性别',
+            'default'   => '4',
+            'desc'      => '头像性别',
+            'match'     => 'is_numeric',
+            'option'    => $sex,
+            'update'    => 'radio',
+            'list'        => true,
+        ),
+        
+        //search_exist_avatar=yes
+        'avatar'        => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '头像',
+            'default'   => '',
+            'desc'      => '请选择头像',
+            'match'     => 'option',
+            'update'    => 'image',
+            'key'       => '1',
+            'place'     => '150',
+            'list'        => '"{avatar}" ? "<img src=\'{avatar}\' width=\'150\'>": ""',
+            //'list'      => 'Dever::load("passport/lib/manage.showAvatar", {id})',
+        ),
+
+        '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,
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+
+    'manage' => array
+    (
+        
+    ),
+    
+    # request 请求接口定义
+    'request' => array
+    (
+        # 后台搜索用到
+        'rand' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'sex' => array('yes', 'in'),
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'order' => 'rand()',
+            'col' => '*',
+        ),
+    ),
+);

+ 296 - 0
database/info.php

@@ -0,0 +1,296 @@
+<?php
+
+$button = array();
+$list_button = array
+(
+	'list' => array('认证', '"auth&search_option_uid={id}&oper_table=info"'),
+
+	'list1' => array('地址', '"address&search_option_uid={id}&oper_table=info"'),
+);
+if (Dever::project('account')) {
+	$list_button += array
+	(
+		'list99' => array('钱包', '"info_log&project=account&config_key=qianbao&search_option_uid={id}&oper_table=info&oper_project=user"'),
+	);
+}
+if (Dever::project('score')) {
+	$list_button += array
+	(
+		'list100' => array('积分', '"user&project=score&search_option_uid={id}&oper_table=info&oper_project=user"'),
+		'list101' => array('等级', '"user_level&project=score&search_option_uid={id}&oper_table=info&oper_project=user"'),
+	);
+}
+
+$project = function()
+{
+	return Dever::db('user/project')->state();
+};
+
+$sex = array
+(
+	1 => '男',
+	2 => '女',
+	3 => '未知',
+);
+
+$system_source = Dever::config('base')->system_source;
+
+return array
+(
+	# 表名
+	'name' => 'info',
+	# 显示给用户看的名称
+	'lang' => '用户管理',
+	'order' => 10,
+	'set' => array
+	(
+		'system_source' => $system_source,
+		'sex' => $sex,
+	),
+	# 数据结构
+	'struct' => array
+	(
+	
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '用户ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'search'	=> 'order,fulltext',
+			'list'		=> true,
+		),
+		
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-50',
+			'name' 		=> '用户名',
+			'default' 	=> '',
+			'desc' 		=> '请输入用户名',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'mobile'		=> array
+		(
+			'type' 		=> 'varchar-32',
+			'name' 		=> '手机号',
+			'default' 	=> '',
+			'desc' 		=> '请输入用户手机号',
+			'match' 	=> Dever::rule('mobile'),
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'email'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '邮箱',
+			'default' 	=> '',
+			'desc' 		=> '请输入邮箱',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+			//'search'	=> 'fulltext',
+			//'list'		=> true,
+		),
+		
+		'password'		=> array
+		(
+			'type' 		=> 'varchar-50',
+			'name' 		=> '密码',
+			'default' 	=> '',
+			'desc' 		=> '请输入密码',
+			'match' 	=> 'option',
+			'update'	=> 'password',
+			'callback'	=> 'sha1',
+		),
+
+		'project_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '所属项目',
+			'default' 	=> '1',
+			'desc' 		=> '所属项目',
+			'match' 	=> 'is_numeric',
+			'option' 	=> $project,
+			'update'	=> 'radio',
+			'search'	=> 'select',
+			'list'		=> true,
+		),
+
+		'system_source'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '用户来源',
+			'default' 	=> '100',
+			'desc' 		=> '用户来源',
+			'match' 	=> 'is_numeric',
+			'option' 	=> $system_source,
+			'update'	=> 'radio',
+			'search'	=> 'select',
+			'list'		=> true,
+		),
+
+		'avatar_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '头像',
+			'default' 	=> '1',
+			'desc' 		=> '头像',
+			'match' 	=> 'is_numeric',
+		),
+
+		'avatar'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '头像',
+			'default' 	=> '',
+			'desc' 		=> '请选择头像',
+			'match' 	=> 'option',
+			'update'	=> 'image',
+			'key' 		=> '1',
+			'place'		=> '150',
+		),
+
+		'sex'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '性别',
+			'default' 	=> '3',
+			'desc' 		=> '性别',
+			'match' 	=> 'is_numeric',
+			'option' 	=> $sex,
+			'update'	=> 'radio',
+			'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,
+			'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+
+	'manage' => array
+	(
+		'excel' => true,
+		'button' => $button,
+		'list_button' => $list_button,
+	),
+
+	# 更新表结构
+	/*
+	'alter' => array
+	(
+		1 => array
+		(
+			array('add', 'bind', 'bind', 'tinyint-1 2 是否绑定手机'),
+		),
+		'version' => 1,
+	),
+	*/
+	# 索引
+	'index' => array
+	(
+		1 => array
+		(
+			'mobile' => 'mobile',
+		),
+		
+		# 版本号 更改版本号会更新当前表的索引
+		'version' => 1,
+	),
+	
+	# request 请求接口定义
+	'request' => array
+	(
+		# 此处定义是为跳出auth
+		'login' => array
+		(
+			'option' => array
+			(
+				'username' => 'yes',
+				'mobile' => 'yes',
+				'email' => 'yes',
+				'password' => 'yes',
+			),
+			'type' => 'one',
+		),
+
+		# 验证手机号是否被使用 
+		'checkMobile' => array
+		(
+			# 匹配的正则或函数 选填项
+			'where' => array
+			(
+				'mobile' => 'yes',
+				'id' => array('yes', '!='),
+			),
+			'type' => 'one',
+		),
+
+		# 后台搜索用到
+		'search' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'ids' => array('yes-id', 'in'),
+				'search' => array('yes-mobile,name', 'like'),
+				'id' => 'yes',
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('id' => 'desc'),
+			'limit' => '0,1000',
+			'col' => 'concat(name, "-", mobile) as name, id, id as value, "" as selected, "" as disabled|id',
+		),
+
+		'getNum' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'start' => array('yes-cdate', '>='),
+                'end' => array('yes-cdate', '<='),
+                'state' => 1,
+            ),
+            'type' => 'count',
+            'col' => '*',
+        ),
+
+        'like' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+            	'search' => array('yes-mobile,name', 'like'),
+            	'mobile' => array('yes', 'like'),
+                'name' => array('yes', 'like'),
+                'id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('id' => 'desc'),
+            'col' => '*|id',
+        ),
+	),
+);

+ 225 - 0
database/invoice.php

@@ -0,0 +1,225 @@
+<?php
+
+$type = array
+(
+    1 => '普通发票',
+    2 => '默认发票',
+);
+
+$title_type = array
+(
+    1 => '企业单位',
+    2 => '个人',
+);
+
+return array
+(
+    # 表名
+    'name' => 'invoice',
+    # 显示给用户看的名称
+    'lang' => '用户发票库',
+    'menu' => false,
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'update'    => 'hidden',
+            //'list'        => true,
+        ),
+
+        'uid'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '用户名',
+            'default'   => '0',
+            'desc'      => '请选择用户',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            //'search'  => 'select',
+            'search'    => array
+            (
+                'api' => 'user/info-like',
+                'col' => 'search',
+                'result' => 'id',
+            ),
+            'list'      => 'Dever::load("user/lib/info.get#name", {uid})',
+        ),
+
+        'type'      => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '类型',
+            'default'   => '2',
+            'desc'      => '类型',
+            'match'     => 'is_numeric',
+            'option'    => $type,
+            'update'    => 'select',
+            //'list'        => true,
+        ),
+
+        'title_type'      => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '抬头类型',
+            'default'   => '1',
+            'desc'      => '抬头类型',
+            'match'     => 'is_numeric',
+            'option'    => $title_type,
+            'update'    => 'radio',
+            //'list'        => true,
+        ),
+
+        'title'       => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '抬头名称',
+            'default'   => '',
+            'desc'      => '抬头名称',
+            'match'     => 'option',
+            'search'    => 'fulltext',
+            //'update'  => 'text',
+            //'list'        => true,
+        ),
+
+        'email'        => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '邮箱',
+            'default'   => '',
+            'desc'      => '邮箱',
+            'match'     => 'option',
+            'search'    => 'fulltext',
+            //'update'  => 'text',
+            //'list'        => true,
+        ),
+
+        'mobile'        => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '手机号',
+            'default'   => '',
+            'desc'      => '手机号',
+            'match'     => 'option',
+            'search'    => 'fulltext',
+            //'update'  => 'text',
+            //'list'        => true,
+        ),
+
+        'number'       => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '公司税号',
+            'default'   => '',
+            'desc'      => '公司税号',
+            'match'     => 'option',
+            //'update'  => 'text',
+        ),
+
+        'phone'       => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '公司电话',
+            'default'   => '',
+            'desc'      => '公司电话',
+            'match'     => 'option',
+            //'update'  => 'text',
+        ),
+
+        'address'       => array
+        (
+            'type'      => 'varchar-1000',
+            'name'      => '注册地址',
+            'default'   => '',
+            'desc'      => '注册地址',
+            'match'     => 'option',
+            //'update'  => 'text',
+            //'list'        => true,
+        ),
+
+        'bank'       => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '开户银行',
+            'default'   => '',
+            'desc'      => '开户银行',
+            'match'     => 'option',
+            //'update'  => 'text',
+            //'list'        => true,
+        ),
+
+        'bank_number'       => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '银行账号',
+            'default'   => '',
+            'desc'      => '银行账号',
+            'match'     => 'option',
+            //'update'  => 'text',
+            //'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
+    (
+        
+    ),
+
+    'request' => array
+    (
+        'getList' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'uid' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('type' => 'desc','id' => 'desc'),
+            'page' => array(10, 'list'),
+            'col' => '*',
+        ),
+
+        'updateType' => array
+        (
+            'set' => array
+            (
+                'type' => 'yes',
+            ),
+            'where' => array
+            (
+                'type' => 'yes',
+            ),
+            'type' => 'update',
+        ),
+    ),
+);

+ 128 - 0
database/login.php

@@ -0,0 +1,128 @@
+<?php
+
+$source_type = array (
+	'ios' => 'ios',
+	'android' => 'android',
+);
+
+$system_source = Dever::config('base')->system_source;
+
+return array
+(
+	# 表名
+	'name' => 'login',
+	# 显示给用户看的名称
+	'lang' => '用户登录记录',
+	'order' => 9,
+	'menu' => false,
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			//'search'	=> 'order',
+			'order'		=> 'desc',
+			'list'		=> true,
+		),
+
+		'project_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '所属项目',
+			'default' 	=> '1',
+			'desc' 		=> '所属项目',
+			'match' 	=> 'is_numeric',
+			//'option' 	=> $level,
+			//'update'	=> 'select',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'uid'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '用户',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			//'update'	=> 'select',
+			'search'	=> 'fulltext',
+			'list'		=> 'Dever::load("user/lib/info.get#name", {uid})',
+			//'list'		=> true,
+			//'edit'		=> true,
+		),
+
+		'system_source'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '用户来源',
+			'default' 	=> '1',
+			'desc' 		=> '用户来源',
+			'match' 	=> 'is_numeric',
+			'option' 	=> $system_source,
+			'update'	=> 'radio',
+			'search'	=> 'select',
+			'list'		=> true,
+		),
+
+		'uuid'       => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => 'uuid',
+            'default'   => '',
+            'desc'      => 'uuid',
+            'match'     => 'is_string',
+            //'update'  => 'text',
+            '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时才生效
+			'search'	=> 'date',
+			'insert'	=> true,
+			'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+	
+	'manage' => array
+	(
+		'insert' => false,
+		'edit' => false,
+		'delete' => false,
+	),
+	
+	# request 请求接口定义
+	'request' => array
+	(
+		# 此处定义是为跳出auth
+		'getAllByUids' => array
+		(
+			'option' => array
+			(
+				'uid' => array('yes', 'in'),
+				'state' => 1,
+			),
+			'type' => 'all',
+			'col' => '*',
+		),
+	),
+);

+ 167 - 0
database/project.php

@@ -0,0 +1,167 @@
+<?php
+
+$token = array();
+if (Dever::project('token')) {
+	$token = function()
+	{
+		$array = array();
+		$info = Dever::db('token/project')->state();
+		if ($info) {
+			$array += $info;
+		}
+		return $array;
+	};
+}
+
+return array
+(
+	# 表名
+	'name' => 'project',
+	# 显示给用户看的名称
+	'lang' => '项目管理',
+	# 后台菜单排序
+	'order' => 1,
+	/*
+	'end' => array
+	(
+		'insert' => array
+		(
+			'manage/top.sync',
+		),
+		'update' => array
+		(
+			'manage/top.sync',
+		),
+	),
+	*/
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'search'	=> 'order',
+			'list'		=> true,
+			'order'		=> 'desc',
+		),
+		
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-32',
+			'name' 		=> '项目名称',
+			'default' 	=> '',
+			'desc' 		=> '项目名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'token_project_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '关联token',
+			'default' 	=> '-1',
+			'desc' 		=> '关联token',
+			'match' 	=> 'is_numeric',
+			'option' 	=> $token,
+			'update'	=> $token ? 'select' : false,
+			'list'		=> $token ? true : false,
+		),
+		
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序(数值越大越靠前)',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+			'search'	=> 'order',
+			'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,
+			'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+
+	# 默认值
+	'default' => array
+	(
+		'col' => 'name,state,cdate',
+		'value' => array
+		(
+			'"默认项目",1,' . time(),
+		),
+	),
+
+	'manage' => array
+	(
+		'insert' => false,
+		'edit' => false,
+
+		# 自定义快捷新增和编辑
+		'button' => array
+		(
+			'新增' => array('fast'),
+		),
+		# 快捷更新
+		'list_button' => array
+		(
+			'edit' => array('编辑'),
+		),
+	),
+
+	/*
+	'top' => array
+	(
+		# 数据来源
+		'data' => 'state',
+		# 菜单名
+		'name' => '项目选择',
+		# 默认值
+		'value' => 1,
+		# 对应的字段值,设置这个之后,所有设置等于这个值的字段,都要遵循这个权限的控制
+		'key' => 'user/project_id',
+		# 本表中代表名称的字段
+		'col' => 'name',
+	),*/
+
+	'request' => array
+	(
+		'getAll' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc','id' => 'desc'),
+			'col' => '*',
+		),
+	),
+);

+ 152 - 0
database/stat.php

@@ -0,0 +1,152 @@
+<?php
+
+return array
+(
+    # 表名
+    'name' => 'stat',
+    # 显示给用户看的名称
+    'lang' => '用户统计',
+    'order' => -100,
+    'menu'	=> false,
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            //'list'      => true,
+        ), 
+
+        'day'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '日期',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '',
+            'search'    => 'day',
+            'search_button' => array
+            (
+            	'sum' => 'user',
+            	'option' => array(
+            		'day' => '按天',
+	            	'week' => '按周',
+	            	'month' => '按月',
+            	),
+            ),
+            'order'     => 'desc',
+            'list'      => 'Dever::showDay("{day}")',
+        ),
+
+        'user'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '新增用户量',
+            'default'   => '0',
+            'desc'      => '新增用户量',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'      => true,
+        ),
+
+        'order_user'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '下单用户量',
+            'default'   => '0',
+            'desc'      => '下单用户量',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'      => Dever::config('base')->passport_stat_order ? true : false,
+        ),
+
+        'qoq'      => array
+        (
+            'type'      => 'varchar-11',
+            'name'      => '新增环比增长率',
+            'default'   => '0',
+            'desc'      => '新增环比增长率',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'      => 'Dever::load("user/lib/stat.qoq", "{user}", "{day}")',
+        ),
+
+        '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,
+        ),
+    ),
+
+    'manage' => array
+    (
+        'delete' => false,
+        'edit' => false,
+        'insert' => false,
+        'chart' => array
+        (
+        	'x' => 'day',
+        	'data' => array('user'),
+        ),
+        'data' => array
+        (
+        	array('用户总量', function() {return Dever::db('user/info')->total();}),
+        	array('今日新增用户量', function() {list($start, $end) = Dever::day();return Dever::db('user/info')->total(array('start' => $start, 'end' => $end));}),
+        	array('昨日新增用户量', function() {list($start, $end) = Dever::day(1);return Dever::db('user/info')->total(array('start' => $start, 'end' => $end));}),
+        	array('本月新增用户量', function() {list($start, $end) = Dever::month();return Dever::db('user/info')->total(array('start' => $start, 'end' => $end));}),
+        ),
+    ),
+
+    'request' => array
+    (
+        # 获取总金额
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'start' => array('yes-day', '>='),
+                'end' => array('yes-day', '<='),
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'col' => '*',
+        ),
+
+        'prev' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'day' => array('yes-day', '<'),
+                //'start_day' => array('yes-day', '>='),
+                //'end_day' => array('yes-day', '<='),
+                'state' => 1,
+            ),
+            'order' => array('day' => 'desc', 'id' => 'desc'),
+            'type' => 'one',
+            'col' => '*',
+            # 允许自定义以上配置
+            'config' => true,
+        ),
+    ),
+);

+ 84 - 0
database/user_project.php

@@ -0,0 +1,84 @@
+<?php
+$project = function()
+{
+	$array = array();
+	$info = Dever::db('user/project')->state();
+	if ($info) {
+		$array += $info;
+	}
+	return $array;
+};
+return array
+(
+	# 表名
+	'name' => 'user_project',
+	# 显示给用户看的名称
+	'lang' => '用户与项目关联表',
+	'order' => 10,
+	'menu'	=> false,
+	# 数据结构
+	'struct' => array
+	(
+	
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '用户ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'search'	=> 'order,fulltext',
+			'list'		=> true,
+		),
+		
+		'uid'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '用户名',
+			'default' 	=> '0',
+			'desc' 		=> '请选择用户',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'text',
+			//'search'	=> 'select',
+			'search'    => array
+            (
+                'api' => 'user/info-like',
+                'col' => 'search',
+                'result' => 'id',
+            ),
+			'list'		=> 'Dever::load("user/lib/info.get#name", {uid})',
+		),
+
+		'project_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '所属项目',
+			'default' 	=> '1',
+			'desc' 		=> '所属项目',
+			'match' 	=> 'is_numeric',
+			'option' 	=> $project,
+			//'update'	=> 'select',
+			//'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,
+			'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+);

+ 212 - 0
database/wechat.php

@@ -0,0 +1,212 @@
+<?php
+
+$system_source = Dever::config('base')->system_source;
+
+return array
+(
+	# 表名
+	'name' => 'wechat',
+	# 显示给用户看的名称
+	'lang' => '微信绑定列表',
+	'order' => 10,
+	'menu' => false,
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			//'search'	=> 'order',
+			'order'		=> 'desc',
+			'list'		=> true,
+		),
+
+		'project_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '所属项目',
+			'default' 	=> '1',
+			'desc' 		=> '所属项目',
+			'match' 	=> 'is_numeric',
+			//'option' 	=> $level,
+			//'update'	=> 'select',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'uid'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '用户',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			//'update'	=> 'select',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+			//'edit'		=> true,
+		),
+
+		'system_source'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '用户来源',
+			'default' 	=> '1',
+			'desc' 		=> '用户来源',
+			'match' 	=> 'is_numeric',
+			'option' 	=> $system_source,
+			'update'	=> 'radio',
+			'search'	=> 'select',
+			'list'		=> true,
+		),
+
+		'openid'		=> array
+		(
+			'type' 		=> 'varchar-50',
+			'name' 		=> 'openid-微信的唯一用户id',
+			'default' 	=> '',
+			'desc' 		=> 'openid',
+			'match' 	=> 'is_string',
+			//'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'unionid'		=> array
+		(
+			'type' 		=> 'varchar-50',
+			'name' 		=> 'unionid-微信的唯一用户id',
+			'default' 	=> '',
+			'desc' 		=> 'unionid',
+			'match' 	=> 'is_string',
+			//'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'session_key'		=> array
+		(
+			'type' 		=> 'varchar-50',
+			'name' 		=> 'session_key',
+			'default' 	=> '',
+			'desc' 		=> 'session_key',
+			'match' 	=> 'is_string',
+			//'update'	=> 'text',
+		),
+
+		'access_token'       => array
+        (
+            'type'      => 'varchar-200',
+            'name'      => 'access_token',
+            'default'   => '',
+            'desc'      => 'access_token',
+            'match'     => 'is_string',
+            //'update'  => 'text',
+        ),
+
+        'refresh_token'       => array
+        (
+            'type'      => 'varchar-200',
+            'name'      => 'refresh_token',
+            'default'   => '',
+            'desc'      => 'refresh_token',
+            'match'     => 'is_string',
+            //'update'  => 'text',
+        ),
+
+        'expires_in'       => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => 'expires_in',
+            'default'   => '',
+            'desc'      => 'expires_in',
+            'match'     => 'is_string',
+            //'update'  => 'text',
+        ),
+
+		'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时才生效
+			'search'	=> 'date',
+			'insert'	=> true,
+			'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+	
+	'manage' => array
+	(
+		'insert' => false,
+		'edit' => false,
+		'delete' => false,
+	),
+
+	# 索引
+	'index' => array
+	(
+		11 => array
+		(
+			'openid' => 'uid,openid,unionid',
+		),
+		
+		# 版本号 更改版本号会更新当前表的索引
+		'version' => 11,
+	),
+	
+	# request 请求接口定义
+	'request' => array
+	(
+		'getByUnionid' => array
+		(
+			'option' => array
+			(
+				'unionid' => 'yes',
+			),
+			'type' => 'all',
+			'order' => array('id' => 'asc'),
+			'col' => '*',
+		),
+
+		'updates' => array
+		(
+			'set' => array
+			(
+				'uid' => 'yes',
+			),
+			'where' => array
+			(
+				'uid' => array('yes', 'in'),
+			),
+			'type' => 'update',
+		),
+
+		'updateByOpenid' => array
+		(
+			'set' => array
+			(
+				'session_key' => 'yes',
+			),
+			'where' => array
+			(
+				'openid' => 'yes',
+			),
+			'type' => 'update',
+		),
+	),
+);

+ 13 - 0
index.php

@@ -0,0 +1,13 @@
+<?php
+
+define('DEVER_APP_NAME', 'user');
+define('DEVER_APP_LANG', '用户管理');
+define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+define('DEVER_MANAGE_ORDER', -10);
+define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-user layui-icon-username');
+if (!defined('DEVER_GROUP_NAME')) {
+	define('DEVER_GROUP_ORDER', -10);
+	define('DEVER_GROUP_NAME', '社区管理');
+}
+
+include(DEVER_APP_PATH . '../boot.php');

+ 128 - 0
lib/Address.php

@@ -0,0 +1,128 @@
+<?php
+namespace User\Lib;
+
+use Dever;
+
+class Address
+{
+	public function manage_update($id, $name, $param)
+    {
+        $area = Dever::param('area', $param);
+        $type = Dever::param('type', $param);
+        if ($area && is_array($area)) {
+            $update['where_id'] = $id;
+            $update['province'] = $area[0];
+            $update['city'] = $area[1];
+            $update['county'] = isset($area[2]) ? $area[2] : '';
+            $update['town'] = isset($area[3]) ? $area[3] : '';
+
+            if ($type == 2) {
+                Dever::db('user/address')->updateType(array('where_type' => 2, 'set_type' => 1));
+            }
+            $update['type'] = $type;
+            Dever::db('user/address')->update($update);
+        }
+    }
+
+    public function getInfo($data)
+    {
+        $data['area_string'] = Dever::load('area/api')->string($data['area']);
+        $data['province_name'] = $data['city_name'] = $data['county_name'] = $data['town_name'] = '';
+        if ($data['town'] && $data['town'] > 0) {
+            $info = Dever::db('area/town')->find($data['town']);
+            if ($info) {
+                $data['town_name'] = $info['name'];
+            }
+        }
+        
+        if ($data['county']) {
+            $info = Dever::db('area/county')->find($data['county']);
+            if ($info) {
+                $data['county_name'] = $info['name'];
+            }
+        }
+
+        if ($data['city']) {
+            $info = Dever::db('area/city')->find($data['city']);
+            if ($info) {
+                $data['city_name'] = $info['name'];
+            }
+        }
+
+        if ($data['province']) {
+            $info = Dever::db('area/province')->find($data['province']);
+            if ($info) {
+                $data['province_name'] = $info['name'];
+            }
+        }
+
+        return $data;
+    }
+
+    # 添加或者更新地址
+    public function update($id, $uid, $type = 2, $mobile, $contact, $province = '', $city = '', $county = '', $town = '', $address = '', $country = '', $tag = '')
+    {
+        if ($contact) {
+            $update['contact'] = $contact;
+        }
+
+        if ($mobile) {
+            $update['mobile'] = $mobile;
+        } else {
+            Dever::alert('请输入手机号');
+        }
+
+        if ($province) {
+            $update['province'] = $province;
+        } else {
+            Dever::alert('请选择省份');
+        }
+
+        if ($city) {
+            $update['city'] = $city;
+        } else {
+            Dever::alert('请选择城市');
+        }
+
+        if ($county) {
+            $update['county'] = $county;
+        } else {
+            Dever::alert('请选择区域');
+        }
+
+        if ($town) {
+            $update['town'] = $town;
+        }
+        
+        if ($province && $city && $county) {
+	        $update['area'] = $province . ',' . $city . ',' . $county;
+        }
+        if ($town) {
+            $update['area'] .= ',' . $town;
+        }
+
+        $update['type'] = $type;
+
+        if ($address) {
+            $update['address'] = $address;
+        }
+
+        if ($tag) {
+            $update['tag'] = $tag;
+        }
+
+        if ($type == 2) {
+            Dever::db('user/address')->updateType(array('where_type' => 2, 'set_type' => 1));
+        }
+        
+        if ($id) {
+            $update['where_id'] = $id;
+            Dever::db('user/address')->update($update);
+        } else {
+            $update['uid'] = $uid;
+            $id = Dever::db('user/address')->insert($update);
+        }
+
+        return $id;
+    }
+}

+ 116 - 0
lib/Info.php

@@ -0,0 +1,116 @@
+<?php
+namespace User\Lib;
+
+use Dever;
+
+class Info
+{
+    public function manage_search_api()
+    {
+        $table = 'user/info';
+        $keyword = Dever::input('keyword');
+
+        $yes = Dever::input('yes');
+
+        $where = array();
+
+        $cate = Dever::input('cate');
+        if ($cate) {
+            $where['cate_id'] = $cate;
+        }
+
+        if ($yes) {
+            $yes = Dever::db($table)->search(array('ids' => $yes));
+        }
+        if (!$keyword) {
+            $where['limit'] = '0,10';
+            $data = Dever::db($table)->search($where);
+        } else {
+            $where['search'] = $keyword;
+            $data = Dever::db($table)->search($where);
+        }
+
+        $result = array();
+        if ($yes) {
+            foreach ($yes as $k => $v) {
+                if (isset($data[$k])) {
+                    unset($data[$k]);
+                }
+                $yes[$k]['selected'] = true;
+            }
+            $data = $yes + $data;
+
+            $data = array_merge($data, array());
+        } else {
+            $data = array_merge($data, array());
+        }
+
+        if (!$data) {
+            Dever::alert('暂无数据');
+        }
+
+        return $data;
+    }
+
+    public function get($uid)
+    {
+        $info = Dever::db('user/info')->find($uid);
+        if ($info) {
+            if ($info['area']) {
+                $info['area_string'] = Dever::load('area/api')->string($info['area']);
+            }
+
+            if (!$info['avatar'] && $info['avatar_id'] > 0) {
+                $avatar = Dever::db('user/avatar')->one($info['avatar_id']);
+                $info['avatar'] = $avatar['avatar'];
+            }
+        }
+        
+        return $info;
+    }
+
+    /**
+     * 设置项目
+     *
+     * @return mixed
+     */
+    public function setProject($uid, $project)
+    {
+        $where['uid'] = $uid;
+        $where['project_id'] = $project;
+        $one = Dever::db('user/user_project')->find($where);
+
+        if (!$one) {
+            Dever::db('user/user_project')->insert($where);
+        }
+    }
+
+    /**
+     * 获取加密信息
+     *
+     * @return mixed
+     */
+    public function getSign($uid, $data = array())
+    {
+        $data['signature'] = Dever::login($uid);
+        return $data;
+    }
+
+    /**
+     * 检测用户有效性
+     *
+     * @return mixed
+     */
+    public function check($state = true, $name = 'signature')
+    {
+        $signature = Dever::input($name);
+        $user = Dever::checkLogin($signature, $state);
+        if ($state && !isset($user['uid'])) {
+            Dever::alert('user error');
+        }
+        if (isset($user['uid']) && $user['uid']) {
+            return $user['uid'];
+        }
+        return -1;
+    }
+}

+ 65 - 0
lib/Stat.php

@@ -0,0 +1,65 @@
+<?php
+namespace User\Lib;
+
+use Dever;
+
+class Stat
+{
+    # 获取用户每日新增数量
+    public function cron_api(){}
+    public function cron()
+    {
+        $num = Dever::input('num', 1);
+        $start = Dever::input('start', date('Y-m-d', strtotime('-'.$num.' day')));
+        $end = Dever::input('end', date('Y-m-d'));
+
+        $start = Dever::maketime($start . ' 00:00:00');
+        $end = Dever::maketime($end . ' 23:59:59');
+        $day = intval(($end - $start)/86400);
+
+        for($i=0; $i<=$day; $i++) {
+            $where['start'] = $start + 86400*$i;
+            $where['end'] = $start + 86400*$i + 86399;
+            $num = Dever::db('user/info')->getNum($where);
+            if ($num <= 0) {
+                continue;
+            }
+            $data = array();
+            $data['day'] = $where['start'];
+            $info = Dever::db('user/stat')->find($data);
+            $data['user'] = $num;
+            $order = Dever::config('base')->passport_stat_order;
+            if ($order) {
+                $order = Dever::load($order, $where);
+                $data['order_user'] = $order;
+            }
+            $data['qoq'] = 0;
+            
+            if (!$info) {
+                Dever::db('user/stat')->insert($data);
+            } else {
+                $data['where_id'] = $info['id'];
+                Dever::db('user/stat')->update($data);
+            }
+        }
+    }
+
+    # 获取环比增长
+    public function qoq($user, $day)
+    {
+        $where = array('day' => Dever::maketime($day));
+        $search = Dever::search_button();
+        if ($search) {
+            $where['config']['group'] = $search[0];
+            $where['config']['col'] = str_replace('|id', '', $search[1]);
+        }
+        $prev = Dever::db('user/stat')->prev($where);
+        if ($prev) {
+            $qoq = round(($user-$prev['user'])/$prev['user'], 2)*100;
+        } else {
+            $qoq = 0;
+        }
+
+        return $qoq . '%';
+    }
+}

+ 80 - 0
src/Address.php

@@ -0,0 +1,80 @@
+<?php
+namespace User\Src;
+
+use Dever;
+
+class Address
+{
+    # 获取默认地址
+    public function getDefault($uid)
+    {
+        $where['uid'] = $uid;
+        $where['type'] = 2;
+        $data = Dever::db('user/address')->one($where);
+
+        return $data;
+    }
+
+    # 获取某个收货地址
+    public function getInfo($uid, $id)
+    {
+        $where['uid'] = $uid;
+        $where['id'] = $id;
+        $data = Dever::db('user/address')->one($where);
+
+        if ($data && Dever::project('area')) {
+            $data = Dever::load('user/lib/address')->getInfo($data);
+        }
+
+        return $data;
+    }
+
+    # 获取地址列表
+    public function getList($uid)
+    {
+        $where['uid'] = $uid;
+        $data = Dever::db('user/address')->getList($where);
+
+        if ($data && Dever::project('area')) {
+            foreach ($data as $k => $v) {
+                $data[$k] = Dever::load('user/lib/address')->getInfo($v);
+            }
+        }
+
+        return $data;
+    }
+
+
+    # 删除和恢复
+    public function delete($uid, $id, $state = 2)
+    {
+        $info = $this->getOne($uid, $id);
+        if ($info) {
+            $update['where_id'] = $info['id'];
+            $update['state'] = $state;
+            Dever::db('user/address')->update($update);
+        } else {
+            Dever::alert('更新失败');
+        }
+
+        return 'ok';
+    }
+
+    # 添加或者更新地址接口
+    public function update()
+    {
+        $uid = $this->check();
+        $id = Dever::input('id');
+        $type = Dever::input('type', 2);
+        $province = Dever::input('province');
+        $city = Dever::input('city');
+        $county = Dever::input('county');
+        $contact = Dever::input('contact');
+        $address = Dever::input('address');
+        $town = Dever::input('town');
+        $mobile = Dever::input('mobile');
+        $tag = Dever::input('tag');
+
+        return Dever::load('user/lib/address')->update($id, $uid, $type, $mobile, $contact, $province, $city, $town, $address, $country, $tag);
+    }
+}

+ 218 - 0
src/Info.php

@@ -0,0 +1,218 @@
+<?php
+namespace User\Src;
+
+use Dever;
+class Info
+{
+	/**
+     * 获取验证码
+     * @return mixed
+     */
+    public function getCode()
+    {
+        return Dever::load('sms/api.sendCode', 'code', $this->getMobile());
+    }
+
+    /**
+     * 检测验证码
+     * @return mixed
+     */
+    private function checkCode()
+    {
+        return Dever::load('sms/api.checkCode', 'code', $this->getMobile(), Dever::input('code'), 1);
+    }
+
+    /**
+     * 获取手机号
+     * @return mixed
+     */
+    private function getMobile()
+    {
+        $rule = Dever::rule('mobile');
+
+        $mobile = Dever::input('mobile');
+
+        if (!$mobile) {
+            Dever::alert('手机号不能为空');
+        }
+        if (!preg_match($rule, $mobile)) {
+            Dever::alert('请填写正确的手机号');
+        }
+
+        return $mobile;
+    }
+
+    /**
+     * 登录以及注册
+     * @return mixed
+     */
+    public function login()
+    {
+    	$password = Dever::input('password');
+    	if ($password) {
+    		$password = sha1($password);
+    		$param['mobile'] = $this->getMobile();
+    	} else {
+    		$param['mobile'] = $this->checkCode();
+    	}
+    	$param['project_id'] = Dever::input('project_id', 1);
+    	$info = Dever::db('passport/user')->one($param);
+    	if ($info) {
+    		if ($password != $info['password']) {
+    			Dever::alert('您的账号或密码错误');
+    		}
+    		$uid = $info['id'];
+    	} else {
+    		$param['system_source'] = Dever::input('system_source', 1);
+	    	$param['username'] = Dever::input('username');
+        	if (!$param['username']) {
+        		$param['username'] = Dever::hide($param['mobile']);
+        	}
+        	if ($password) {
+        		$param['password'] = $password;
+        	}
+        	$uid = Dever::db('passport/user')->insert($param);
+        	if ($uid) {
+        		Dever::score($uid, 'reg', '账号注册');
+        		if (Dever::project('message')) {
+        			$project = Dever::db('user/project')->find($param['project_id']);
+	                $content = '亲爱的' . $param['username'] . ',欢迎来到' . $project['name'];
+	                Dever::load('message/lib/data')->push(-1, $uid, '欢迎语', $content, 1);
+	            }
+	            $invite = Dever::input('invite');
+		        if ($invite && Dever::project('invite')) {
+		            Dever::load('invite/api')->setRelation($uid, false, $invite);
+		        }
+        	}
+    	}
+
+        # 记录登录日志
+        $log['uid'] = $uid;
+        $log['project_id'] = $param['project_id'];
+        $log['system_source'] = $param['system_source'];
+        Dever::db('user/login')->insert($log);
+
+        Dever::load('user/lib/info')->setProject($uid, $param['project_id']);
+        return Dever::load('user/lib/info')->getSign($uid);
+    }
+
+    /**
+     * 更新用户信息
+     *
+     * @return mixed
+     */
+    public function update()
+    {
+        $uid = Dever::load('user/lib/info')->check();
+        $name = Dever::input('username');
+        $avatar = Dever::input('avatar');
+        $sex = Dever::input('sex');
+        $province = Dever::input('province');
+        $city = Dever::input('city');
+        $country = Dever::input('country');
+
+        $info = Dever::load('passport/user-one', $uid);
+        if ($info) {
+            $update['username'] = $name;
+            $update['avatar'] = $avatar;
+            $update['sex'] = $sex;
+            $update['province'] = $province;
+            $update['country'] = $country;
+            $update['city'] = $city;
+            if ($country && $province && $city) {
+            	$update['area'] = $country . ',' . $province . ',' . $city;
+            }
+            
+            $update['where_id'] = $uid;
+            Dever::load('passport/user-update', $update);
+        } else {
+            Dever::alert('无效的用户id,请重新登录');
+        }
+
+        $result = Dever::db('passport/user')->one(array('id' => $uid, 'clear' => true));
+       
+        return Dever::load('user/lib/info')->getSign($uid, $result);
+    }
+
+    /**
+     * 修改手机号
+     *
+     * @return mixed
+     */
+    public function updateMobile()
+    {
+        $uid = $this->check();
+        $mobile = $this->checkCode();
+
+        $info = Dever::load('passport/user-one', $uid);
+
+        if ($info) {
+            $update['mobile'] = $mobile;
+            $update['where_id'] = $uid;
+            Dever::load('passport/user-update', $update);
+        } else {
+            Dever::alert('更新失败');
+        }
+
+        $result = Dever::load('user/lib/info')->getSign($uid);
+
+        return $result;
+    }
+
+    /**
+     * 修改头像
+     *
+     * @return mixed
+     */
+    public function updateAvatar()
+    {
+        $uid = $this->check();
+        $avatar = Dever::input('avatar');
+
+        $info = Dever::load('passport/user-one', $uid);
+
+        if ($info) {
+            $update['avatar'] = $avatar;
+            $update['where_id'] = $uid;
+            Dever::load('passport/user-update', $update);
+        } else {
+            Dever::alert('更新失败');
+        }
+
+        $result = Dever::load('user/lib/info')->getSign($uid);
+
+        return $result;
+    }
+
+    /**
+     * 修改密码
+     *
+     * @return mixed
+     */
+    public function updatePassword()
+    {
+        $uid = $this->check();
+        $old_password = Dever::input('old_password');
+        $password = Dever::input('password');
+        if ($old_password == $password) {
+        	Dever::alert('旧密码与新密码相同');
+        }
+        $cpassword = Dever::input('cpassword');
+        if ($password != $cpassword) {
+        	Dever::alert('新密码与确认密码不同');
+        }
+
+        $info = Dever::load('passport/user-one', $uid);
+        if ($info) {
+            $update['password'] = sha1($password);
+            $update['where_id'] = $uid;
+            Dever::load('passport/user-update', $update);
+        } else {
+            Dever::alert('更新失败');
+        }
+
+        $result = Dever::load('user/lib/info')->getSign($uid);
+
+        return $result;
+    }
+}

+ 130 - 0
src/Invoice.php

@@ -0,0 +1,130 @@
+<?php
+namespace User\Src;
+
+use Dever;
+
+class Invoice
+{
+    # 获取默认地址
+    public function getDefault($uid)
+    {
+        $where['uid'] = $uid;
+        $where['type'] = 2;
+        $data = Dever::db('user/invoice')->find($where);
+
+        return $data;
+    }
+
+    # 获取某个收货地址
+    public function getOne($uid, $id)
+    {
+        $where['uid'] = $uid;
+        $where['id'] = $id;
+        $data = Dever::db('user/invoice')->find($where);
+
+        if ($data) {
+            if ($data['title_type'] == 1) {
+                $data['title_type_name'] = '企业单位';
+            } else {
+                $data['title_type_name'] = '个人';
+            }
+        }
+
+        return $data;
+    }
+
+    # 获取地址列表
+    public function get($uid)
+    {
+        $where['uid'] = $uid;
+        $data = Dever::db('user/invoice')->getList($where);
+
+        return $data;
+    }
+
+    # 删除和恢复
+    public function del($uid, $id, $state = 2)
+    {
+        $info = $this->getOne($uid, $id);
+        if ($info) {
+            $update['where_id'] = $info['id'];
+            $update['state'] = $state;
+            Dever::db('user/invoice')->update($update);
+        } else {
+            Dever::alert('更新失败');
+        }
+
+        return 'ok';
+    }
+
+    # 添加或者更新地址接口
+    public function up()
+    {
+        $uid = $this->check();
+        $id = Dever::input('id');
+        $type = Dever::input('type', 2);
+        $title_type = Dever::input('title_type');
+        $title = Dever::input('title');
+        $email = Dever::input('email');
+        $mobile = Dever::input('mobile');
+        $number = Dever::input('number');
+        $phone = Dever::input('phone');
+        $address = Dever::input('address');
+        $bank = Dever::input('bank');
+        $bank_number = Dever::input('bank_number');
+
+        return $this->update($id, $uid, $type, $title_type, $title, $email, $mobile, $number, $phone, $address, $bank, $bank_number);
+    }
+
+    # 添加或者更新地址
+    public function update($id, $uid, $type = 2, $title_type = 1, $title = '', $email = '', $mobile = '', $number = '', $phone = '', $address = '', $bank = '', $bank_number = '')
+    {
+        $update['title_type'] = $title_type;
+        if ($title_type == 1) {
+            if (!$number) {
+                Dever::alert('公司税号不能为空');
+            }
+            $update['number'] = $number;
+        }
+
+        $update['type'] = $type;
+        $update['title'] = $title;
+
+        if (!$title) {
+            Dever::alert('发票抬头不能为空');
+        }
+
+        if ($email) {
+            $update['email'] = $email;
+        }
+        if ($mobile) {
+            $update['mobile'] = $mobile;
+        }
+        if ($phone) {
+            $update['phone'] = $phone;
+        }
+        if ($address) {
+            $update['address'] = $address;
+        }
+        if ($bank) {
+            $update['bank'] = $bank;
+        }
+        if ($bank_number) {
+            $update['bank_number'] = $bank_number;
+        }
+
+        if ($type == 2) {
+            Dever::db('user/invoice')->updateType(array('where_type' => 2, 'set_type' => 1));
+        }
+        
+        if ($id) {
+            $update['where_id'] = $id;
+            Dever::db('user/invoice')->update($update);
+        } else {
+            $update['uid'] = $uid;
+            $id = Dever::db('user/invoice')->insert($update);
+        }
+
+        return $id;
+    }
+}