rabin 5 years ago
parent
commit
b8b97f6fe9
70 changed files with 10321 additions and 263 deletions
  1. 156 0
      app/act/database/comment.php
  2. 149 0
      app/act/database/form_id.php
  3. 121 0
      app/act/database/journal_num.php
  4. 592 0
      app/act/database/order.php
  5. 562 0
      app/act/database/order_temp.php
  6. 197 0
      app/act/database/subscribe.php
  7. 8 0
      app/act/index.php
  8. 90 0
      app/act/lib/Comment.php
  9. 38 0
      app/act/lib/Cron.php
  10. 33 0
      app/act/lib/Feedback.php
  11. 54 0
      app/act/lib/Form.php
  12. 67 0
      app/act/lib/Invite.php
  13. 65 0
      app/act/lib/Like.php
  14. 47 0
      app/act/lib/Manage.php
  15. 131 0
      app/act/lib/Note.php
  16. 151 0
      app/act/lib/Num.php
  17. 272 0
      app/act/lib/Pay.php
  18. 135 0
      app/act/lib/Score.php
  19. 163 0
      app/act/lib/Share.php
  20. 109 0
      app/act/lib/Subscribe.php
  21. 47 0
      app/act/lib/Watch.php
  22. 504 0
      app/act/src/Order.php
  23. 2 0
      app/boot.php
  24. 112 0
      app/code/database/config.php
  25. 359 0
      app/code/database/info.php
  26. 69 0
      app/code/database/seller.php
  27. 8 0
      app/code/index.php
  28. 138 0
      app/code/lib/Core.php
  29. 122 0
      app/code/lib/Manage.php
  30. 137 0
      app/content/database/applet.php
  31. 114 0
      app/content/database/page.php
  32. 136 0
      app/content/database/product.php
  33. 8 0
      app/content/index.php
  34. 61 0
      app/content/lib/Applet.php
  35. 223 0
      app/content/lib/Article.php
  36. 76 0
      app/content/lib/Author.php
  37. 19 0
      app/content/lib/Page.php
  38. 56 0
      app/journal/assets/manage/html/journal.html
  39. 216 0
      app/journal/database/active.php
  40. 145 0
      app/journal/database/buy.php
  41. 231 0
      app/journal/database/buy_num.php
  42. 294 0
      app/journal/database/cate.php
  43. 613 0
      app/journal/database/content.php
  44. 689 0
      app/journal/database/info.php
  45. 99 0
      app/journal/database/mobile.php
  46. 57 0
      app/journal/database/mobile_upload.php
  47. 151 0
      app/journal/database/star.php
  48. 8 0
      app/journal/index.php
  49. 577 0
      app/journal/lib/Manage.php
  50. 224 0
      app/journal/lib/Pay.php
  51. 76 0
      app/journal/src/Api.php
  52. 71 0
      app/journal/template/manage/journal.php
  53. 127 0
      app/product/database/cate.php
  54. 178 0
      app/product/database/info.php
  55. 8 0
      app/product/index.php
  56. 23 0
      app/product/lib/Info.php
  57. 56 0
      app/stat/assets/manage/html/journal.html
  58. 310 0
      app/stat/database/journal.php
  59. 289 0
      app/stat/database/seller.php
  60. 8 0
      app/stat/index.php
  61. 135 0
      app/stat/lib/Journal.php
  62. 22 0
      app/stat/lib/Manage.php
  63. 112 0
      app/stat/lib/Seller.php
  64. 71 0
      app/stat/template/manage/journal.php
  65. 24 70
      config/env/localhost/default.php
  66. 116 80
      doc/apidoc.php
  67. 9 65
      main/database/config.php
  68. 1 1
      main/database/version.php
  69. 0 2
      main/lib/Journal.php
  70. 50 45
      main/src/Journal.php

+ 156 - 0
app/act/database/comment.php

@@ -0,0 +1,156 @@
+<?php
+
+$page = 10;
+$table = Dever::config('base')->type;
+$table[5] = '电子刊音视频';
+
+return array
+(
+	# 表名
+	'name' => 'comment',
+	# 显示给用户看的名称
+	'lang' => '评论管理',
+	# 是否显示在后台菜单
+	'order' => 80,
+	'menu'	=> 'stat',
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'order'		=> 'desc',
+			//'list'		=> true,
+		),
+		
+
+		'uid'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '用户名',
+			'default' 	=> '0',
+			'desc' 		=> '请选择用户',
+			'match' 	=> 'is_numeric',
+			//'update'	=> 'select',
+			//'search'	=> 'select',
+			'search'    => array
+            (
+                'api' => 'passport/user-all',
+                'col' => 'username',
+                'result' => 'id',
+            ),
+			'list'		=> '{uid} > 0 ? Dever::load("passport/user-one#username", {uid}) : "匿名用户"',
+		),
+
+		'type' 		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '评论类别',
+			'default' 	=> '',
+			'desc' 		=> '评论类别',
+			'match' 	=> 'option',
+			'option' 	=> $table,
+			'search'	=> 'select',
+			'list'		=> true,
+		),
+		
+		'data_id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '标题',
+			'default' 	=> '',
+			'desc' 		=> '标题',
+			'match' 	=> 'option',
+			//'list'		=> 'Dever::load("act/lib/manage.load", "{type}", {data_id})',
+		),
+
+		'data_name' 		=> array
+		(
+			'type' 		=> 'varchar-200',
+			'name' 		=> '标题',
+			'default' 	=> '',
+			'desc' 		=> '标题',
+			'match' 	=> 'option',
+			'search'	=> 'fulltext',
+			//'list'		=> 'Dever::load("act/lib/manage.load", "{type}", {data_id})',
+			'list'		=> true,
+		),
+
+		'num_up'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '点赞数',
+			'default' 	=> '0',
+			'desc' 		=> '点赞数',
+			'match' 	=> 'option',
+			//'search'	=> 'order',
+			'list'		=> true,
+		),
+		
+		'content'		=> array
+		(
+			'type' 		=> 'text-255',
+			'name' 		=> '内容',
+			'update' 	=> 'editor',
+			'key'		=> 1,
+			'default' 	=> '',
+			'desc' 		=> '请输入内容',
+			'match' 	=> 'is_string',
+			'search'	=> 'fulltext',
+			//'list'		=> 'table',
+			//'modal'		=> '查看详情',
+			'list'		=> '"<span style=\'display:none;\' class=dever-emoji>{content}</span>"',
+		),
+		
+		'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,
+	),
+
+	# request 请求接口定义
+	'request' => array
+	(
+		'getAll' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'uid' => 'yes',
+				'type' => array('yes', 'in'),
+				'data_id' => 'yes',
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('cdate' => 'desc'),
+			'page' => array($page, 'list'),
+			'col' => '*',
+		),
+	)
+);

+ 149 - 0
app/act/database/form_id.php

@@ -0,0 +1,149 @@
+<?php
+$type = array
+(
+    1 => '普通表单',
+    2 => '支付表单',
+);
+$time = time()+(3600*24*7);
+return array
+(
+    # 表名
+    'name' => 'form_id',
+    # 显示给用户看的名称
+    'lang' => '模板form_id收集表',
+    'menu' => false,
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'list'      => true,
+        ),
+
+        'type'      => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '类型',
+            'default'   => '1',
+            'desc'      => '类型',
+            'match'     => 'option',
+            'search'    => 'select',
+            'option'    => $type,
+            'list'      => true,
+        ),
+
+        'cate_id'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '电子刊分类',
+            'default'   => '1',
+            'desc'      => '电子刊分类',
+            'match'     => 'is_numeric',
+            //'search'    => 'select',
+            'list'      => true,
+        ),
+        
+        'num'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '使用次数',
+            'default'   => '0',
+            'desc'      => '使用次数',
+            'match'     => 'is_numeric',
+            'list'      => true,
+        ),
+
+        'uid'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '用户id',
+            'default'   => '',
+            'desc'      => '用户id',
+            'match'     => 'is_numeric',
+            'list'      => true,
+        ),
+        
+        'form_id'       => array
+        (
+            'type'      => 'varchar-700',
+            'name'      => 'form_id',
+            'default'   => '',
+            'desc'      => 'form_id',
+            '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'      => '',
+            'default'   => '',
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+
+    'top' => Dever::config('base', 'applet')->top,
+
+    'manage' => array
+    (
+        //'delete' => false,
+        'insert' => false,
+        'edit' => false,
+    ),
+
+    'request' => array
+    (
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'num' => array('yes', '<'),
+                'type' => 'yes',
+                'uid' => 'yes',
+                'cate_id' => 'yes',
+                'cdate' => array($time, '<='),
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('cdate' => 'desc'),
+            'limit' => '0,100',
+            'col' => '*',
+        ),
+
+        'getAllGroupByUid' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'type' => 'yes',
+                'cate_id' => 'yes',
+                'cdate' => array($time, '<='),
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'group' => 'uid',
+            'order' => array('cdate' => 'desc'),
+            'col' => '*',
+        ),
+    ),
+);

+ 121 - 0
app/act/database/journal_num.php

@@ -0,0 +1,121 @@
+<?php
+
+$table = Dever::config('base')->type;
+
+return array
+(
+	# 表名
+	'name' => 'journal_num',
+	# 显示给用户看的名称
+	'lang' => '本数排行榜',
+	# 是否显示在后台菜单
+	'order' => 1,
+	'menu' => false,
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'order'		=> 'desc',
+			'list'		=> true,
+		),
+		
+
+		'uid'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '用户名',
+			'default' 	=> '0',
+			'desc' 		=> '请选择用户',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'text',
+			//'search'	=> 'select',
+			'search'    => array
+            (
+                'api' => 'passport/user-all',
+                'col' => 'username',
+                'result' => 'id',
+            ),
+			'list'		=> '{uid} > 0 ? Dever::load("passport/user-one#username", {uid}) : "匿名用户"',
+		),
+		
+		'journal_id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '电子刊ID',
+			'default' 	=> '',
+			'desc' 		=> '电子刊ID',
+			'update'	=> 'text',
+			'match' 	=> 'option',
+		),
+
+		'num' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '购买本数',
+			'default' 	=> '',
+			'desc' 		=> '购买本数',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+			'order'		=> 'desc',
+			'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,
+		'button' => array
+		(
+			'导出排行榜' => array('location', 'act/lib/num.out?id=' . Dever::input('search_option_journal_id')),
+		),
+	),
+
+	# request 请求接口定义
+	'request' => array
+	(
+		'getAll' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'uid' => 'yes',
+				'journal_id' => 'yes',
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('num' => 'desc','id' => 'desc'),
+			//'page' => array(100, 'list'),
+			'limit' => '0,50',
+			'col' => '*',
+		),
+	)
+);

+ 592 - 0
app/act/database/order.php

@@ -0,0 +1,592 @@
+<?php
+
+$type = array
+(
+    //1 => '购买电子刊',
+    //2 => '兑换电子刊',
+    3 => '购买兑换码',
+    //4 => '使用通用兑换码',
+);
+
+# 系统
+$system = array
+(
+    1 => '小程序',
+    2 => 'H5',
+    3 => 'ios',
+    4 => '安卓',
+);
+
+# 渠道
+$source = function()
+{
+    return Dever::db('source/info')->state();
+};
+
+$status = array
+(
+    1 => '待支付',
+    2 => '已支付',
+    3 => '支付失败',
+    //4 => '申请退款',
+    5 => '已退款',
+);
+
+$product = function()
+{
+    return Dever::db('journal/info')->state();
+};
+
+$buy = function()
+{
+    return Dever::db('journal/buy_num')->state();
+};
+# 获取电子刊分类权限
+$auth = Dever::tops();
+$cate = function() use ($auth)
+{
+    $array = array();
+    if ($auth) {
+        $info = Dever::db('journal/cate')->getIds(array('ids' => $auth));
+    } else {
+        $info = Dever::db('journal/cate')->state();
+    }
+    if($info)
+    {
+        $array += $info;
+    }
+    return $array;
+};
+
+$seller = function()
+{
+    return Dever::db('code/seller')->state();
+};
+
+return array
+(
+    # 表名
+    'name' => 'order',
+    # 显示给用户看的名称
+    'lang' => '订单管理',
+    'order' => 1,
+    'menu' => 'journal',
+
+    'end' => array
+    (
+        'update' => 'act/lib/pay.order',
+    ),
+
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            //'list'      => true,
+        ),
+
+        'order_id'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '支付订单ID/订单表ID',
+            'default'   => '',
+            'desc'      => '付款订单id',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            //'list'        => true,
+            'list'        => 'Dever::load("act/order.getOrderId", {id})',
+        ), 
+
+        'cate_journal'     => array
+        (
+            'name'      => '电子刊',
+            'default'   => '',
+            'desc'      => '电子刊',
+            'search'    => 'linkage',
+            'search_col' => 'cate_id,product_id',
+            'option'    => Dever::url('lib/manage.search_cate_journal', 'journal'),
+        ),
+
+        'cate_id'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '所属刊物',
+            'default'   => '1',
+            'desc'      => '所属刊物',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => $cate,
+            //'search'    => 'select',
+            'list'      => true,
+        ),
+
+        'name'      => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => '订单名称',
+            'default'   => '',
+            'desc'      => '订单名称',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list_name' => '订单信息',
+            'list'      => 'Dever::load("journal/lib/manage.showOrderUserV1", "{id}")',
+        ),
+
+        'uid'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '用户名',
+            'default'   => '',
+            'desc'      => '用户id',
+            'match'     => 'is_numeric',
+            'search'    => array
+            (
+                'api' => 'passport/user-all',
+                'col' => 'username',
+                'result' => 'id',
+            ),
+            'update'    => 'text',
+        ),
+
+        'source_uid'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '邀请人',
+            'default'   => '',
+            'desc'      => '邀请人',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+        ),
+
+        'note'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '是否发送状态提醒-1未发送,2已发送',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
+
+        'product_id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '电子刊',
+            'default'   => '',
+            'desc'      => '电子刊',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => $product,
+            //'search'    => 'select',
+            //'list'        => true,
+        ),
+
+        'star_id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '明星',
+            'default'   => '',
+            'desc'      => '明星',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            //'search'    => 'select',
+            //'list'        => true,
+        ),
+
+        'buy_id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '购买本数-仅做记录',
+            'default'   => '',
+            'desc'      => '购买本数',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => $buy,
+            //'search'    => 'select',
+            //'list'        => true,
+        ),
+
+        'buy_num'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '购买本数-以此为准',
+            'default'   => '',
+            'desc'      => '购买本数',
+            'match'     => 'is_numeric',
+            //'search'    => 'select',
+            //'list'        => true,
+        ),
+
+        'type'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '支付方式',
+            'default'   => '1',
+            'desc'      => '支付方式',
+            'match'     => 'is_numeric',
+            'option'    => $type,
+            'search'    => 'select',
+            'update'    => 'radio',
+            //'list'        => true,
+            'control'   => 'type',
+        ),
+
+        'system'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '系统',
+            'default'   => '1',
+            'desc'      => '系统',
+            'match'     => 'is_numeric',
+            'option'    => $system,
+            'search'    => 'select',
+            'update'    => 'radio',
+            'list'        => true,
+        ),
+
+        'seller_id'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '销售商',
+            'default'   => '1',
+            'desc'      => '销售商',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => $seller,
+            'search'    => 'select',
+            //'list'      => true,
+        ),
+
+        'notice'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '模板消息提醒次数',
+            'default'   => '0',
+            'desc'      => '模板消息提醒次数',
+            'match'     => 'is_numeric',
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'varchar-50',
+            'name'      => '支付金额',
+            'default'   => '',
+            'desc'      => '支付金额',
+            'match'     => 'option',
+            'update'    => 'text',
+            //'list'        => true,
+            'show'      => 'type=1',
+        ),
+
+        'code'      => array
+        (
+            'type'      => 'varchar-50',
+            'name'      => '使用的兑换码',
+            'default'   => '',
+            'desc'      => '使用的兑换码',
+            'match'     => 'option',
+            'update'    => 'text',
+            //'list'        => true,
+            'show'      => 'type=2',
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '订单状态',
+            'default'   => '1',
+            'desc'      => '请选择订单状态',
+            'match'     => 'is_numeric',
+            'option'    => $status,
+            'search'    => 'select',
+            'update'    => 'radio',
+            'list'      => 'Dever::load("journal/lib/manage.showOrderStatusV1", "{id}")',
+            'control'   => 'status',
+        ),
+
+        'tk_pic'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '退款截图',
+            'default'   => '',
+            'desc'      => '退款截图',
+            'match'     => 'is_string',
+            'update'    => 'image',
+            'key'       => 1
+        ),
+
+        'tk_time'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '退款时间',
+            'default'   => '',
+            'desc'      => '退款时间',
+            'match'     => 'option',
+            //'list'        => true,
+            //'update'    => 'date',
+            'callback'  => 'maketime',
+            'show'      => 'status=5',
+        ),
+
+        'tk_admin'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '退款审核人',
+            'default'   => '1',
+            'desc'      => '退款审核人',
+            'match'     => 'option',
+            //'list'        => true,
+            'show'      => 'status=5',
+        ),
+
+        'tk_desc'       => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '退款备注',
+            'default'   => '',
+            'desc'      => '退款备注',
+            'match'     => 'option',
+            'update'    => 'textarea',
+            //'show'        => 'status=5',
+        ),
+
+        '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})',
+            //'list'      => 'Dever::load("service/lib/manage.showOrderTime", "{id}")',
+        ),
+
+        'info'      => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '备注',
+            'default'   => '',
+            'desc'      => '备注',
+            'match'     => 'option',
+            'update'    => 'textarea',
+            //'show'        => 'status=5'
+            //'list'      => '"{info}" ? "{info}" : "双击添加备注"',
+            //'edit'      => true,
+        ),
+
+        'mobile'        => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '手机号',
+            'default'   => '',
+            'desc'      => '手机号',
+            'match'     => 'option',
+            //'show'        => 'status=5'
+            'search'    => array
+            (
+                'api' => 'passport/user-all',//接口地址,最好是获取多条数据的地址
+                'col' => 'mobile',//要查询的字段
+                'result' => 'id',//返回的字段
+                'search' => 'uid',//本表的字段,默认为当前的字段
+            ),
+        ),
+    ),
+
+    'top' => Dever::config('base')->top,
+
+    # 增加这个,为了给当前的list增加一个option
+    'top_option' => array
+    (
+        'value' => $auth,
+        'col' => 'cate_id',
+    ),
+
+    'manage' => array
+    (
+        'delete' => false,
+        'edit' => false,
+        'insert' => false,
+
+        'button' => array
+        (
+            //'导出订单' => array('location', 'journal/lib/manage.out'),
+        ),
+
+        'list_button' => array(
+            'edit' => array('退款', 'status,tk_time,tk_pic,tk_desc,tk_admin', '{status} >= 2 && ({type} == 1 || {type} == 3)'),
+            //'delete' => array('删除', '', '{status} == 1'),
+        ),
+    ),
+
+    'request' => array
+    (
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'type' => 'yes',
+                'create_uid' => 'yes',
+                'status' => array('1', '!='),
+                'uid' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('cdate' => 'desc'),
+            'page' => array(10, 'list'),
+            'col' => '*',
+        ),
+
+        'getYes' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'product_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('cdate' => 'desc'),
+            'col' => '*',
+        ),
+
+        # 获取提交订单超过12个小时
+        'getDataByTime' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'cdate' => array('yes', '>='),
+                'notice' => 'yes',
+                'note' => 'yes',
+                'type' => array('yes', 'in'),
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('cdate' => 'desc'),
+            'col' => '*',
+        ),
+
+        # 获取没有兑换码的订单
+        'getUnCode' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'code' => array('yes', '='),
+                'status' => 'yes',
+                'type' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('id' => 'desc'),
+            'limit' => '0,100',
+            'col' => '*',
+        ),
+
+        # 获取1,2
+        'getBuy' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'status' => 'yes',
+                'type' => array('yes', 'in'),
+                'product_id' => 'yes',
+                'order_id' => 'yes',
+                'uid' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('id' => 'desc'),
+            'col' => '*',
+        ),
+
+        'getMyAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'type' => 'yes',
+                'uid' => 'yes',
+                'status' => 'yes',
+                'cate_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('id' => 'desc'),
+            'page' => array(10, 'list'),
+            'col' => 'id,order_id,name,buy_num,cdate,cash,product_id,buy_id',
+        ),
+
+        # 删除未支付订单
+        'drop' => array
+        (
+            # 匹配的正则或函数 选填项
+            'where' => array
+            (
+                'time' => array('yes-cdate', '<='),
+                'status' => 1,
+                'state' => 1,
+            ),
+            'type' => 'delete',
+            'col' => 'id,order_id',
+        ),
+
+        # 获取数据
+        'getAllByDate' => array
+        (
+            # 匹配的正则或函数 选填项
+            'where' => array
+            (
+                'time' => array('yes-cdate', '<='),
+            ),
+            'type' => 'all',
+            'col' => 'id,order_id',
+        ),
+
+        'getNumByJournal' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'product_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'col' => 'sum(buy_num) as buy_num',
+        ),
+
+        'getNumByStar' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'star_id' => 'yes',
+                'product_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'col' => 'sum(buy_num) as buy_num',
+        ),
+    ),
+);

+ 562 - 0
app/act/database/order_temp.php

@@ -0,0 +1,562 @@
+<?php
+
+$type = array
+(
+    //1 => '购买电子刊',
+    //2 => '兑换电子刊',
+    3 => '购买兑换码',
+    //4 => '使用通用兑换码',
+);
+
+# 系统
+$system = array
+(
+    1 => '小程序',
+    2 => 'H5',
+    3 => 'ios',
+    4 => '安卓',
+);
+
+$status = array
+(
+    1 => '待支付',
+    2 => '已支付',
+    3 => '支付失败',
+    //4 => '申请退款',
+    5 => '已退款',
+);
+
+$product = function()
+{
+    return Dever::db('journal/info')->state();
+};
+
+$buy = function()
+{
+    return Dever::db('journal/buy_num')->state();
+};
+# 获取电子刊分类权限
+$auth = Dever::tops();
+$cate = function() use ($auth)
+{
+    $array = array();
+    if ($auth) {
+        $info = Dever::db('journal/cate')->getIds(array('ids' => $auth));
+    } else {
+        $info = Dever::db('journal/cate')->state();
+    }
+    if($info)
+    {
+        $array += $info;
+    }
+    return $array;
+};
+
+$seller = function()
+{
+    return Dever::db('code/seller')->state();
+};
+
+return array
+(
+    # 表名
+    'name' => 'order_temp',
+    # 显示给用户看的名称
+    'lang' => '临时订单管理',
+    'order' => 1,
+    'menu' => false,
+
+    'end' => array
+    (
+        'update' => 'act/lib/pay.order',
+    ),
+
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            //'list'      => true,
+        ),
+
+        'order_id'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '支付订单ID/订单表ID',
+            'default'   => '',
+            'desc'      => '付款订单id',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            //'list'        => true,
+            'list'        => 'Dever::load("act/order.getOrderTempId", {id})',
+        ), 
+
+        'cate_journal'     => array
+        (
+            'name'      => '电子刊',
+            'default'   => '',
+            'desc'      => '电子刊',
+            'search'    => 'linkage',
+            'search_col' => 'cate_id,product_id',
+            'option'    => Dever::url('lib/manage.search_cate_journal', 'journal'),
+        ),
+
+        'cate_id'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '电子刊分类',
+            'default'   => '1',
+            'desc'      => '电子刊分类',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => $cate,
+            //'search'    => 'select',
+            'list'      => true,
+        ),
+
+        'name'      => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => '订单名称',
+            'default'   => '',
+            'desc'      => '订单名称',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list_name' => '订单信息',
+            'list'      => 'Dever::load("journal/lib/manage.showOrderUserV1", "{id}")',
+        ),
+
+        'uid'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '用户名',
+            'default'   => '',
+            'desc'      => '用户id',
+            'match'     => 'is_numeric',
+            'search'    => array
+            (
+                'api' => 'passport/user-all',
+                'col' => 'username',
+                'result' => 'id',
+            ),
+            'update'    => 'text',
+        ),
+
+        'source_uid'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '邀请人',
+            'default'   => '',
+            'desc'      => '邀请人',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+        ),
+
+        'note'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '是否发送状态提醒-1未发送,2已发送',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
+
+        'product_id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '电子刊',
+            'default'   => '',
+            'desc'      => '电子刊',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => $product,
+            //'search'    => 'select',
+            //'list'        => true,
+        ),
+
+        'star_id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '明星',
+            'default'   => '',
+            'desc'      => '明星',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            //'search'    => 'select',
+            //'list'        => true,
+        ),
+
+        'buy_id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '购买本数',
+            'default'   => '',
+            'desc'      => '购买本数',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => $buy,
+            //'search'    => 'select',
+            //'list'        => true,
+        ),
+
+        'buy_num'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '购买本数',
+            'default'   => '',
+            'desc'      => '购买本数',
+            'match'     => 'is_numeric',
+            //'search'    => 'select',
+            //'list'        => true,
+        ),
+
+        'type'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '支付方式',
+            'default'   => '1',
+            'desc'      => '支付方式',
+            'match'     => 'is_numeric',
+            'option'    => $type,
+            'search'    => 'select',
+            'update'    => 'radio',
+            //'list'        => true,
+            'control'   => 'type',
+        ),
+
+        'system'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '系统',
+            'default'   => '1',
+            'desc'      => '系统',
+            'match'     => 'is_numeric',
+            'option'    => $system,
+            'search'    => 'select',
+            'update'    => 'radio',
+            'list'        => true,
+        ),
+
+        'seller_id'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '销售商',
+            'default'   => '1',
+            'desc'      => '销售商',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => $seller,
+            'search'    => 'select',
+            //'list'      => true,
+        ),
+
+        'notice'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '模板消息提醒次数',
+            'default'   => '0',
+            'desc'      => '模板消息提醒次数',
+            'match'     => 'is_numeric',
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'varchar-50',
+            'name'      => '支付金额',
+            'default'   => '',
+            'desc'      => '支付金额',
+            'match'     => 'option',
+            'update'    => 'text',
+            //'list'        => true,
+            'show'      => 'type=1',
+        ),
+
+        'code'      => array
+        (
+            'type'      => 'varchar-50',
+            'name'      => '使用的兑换码',
+            'default'   => '',
+            'desc'      => '使用的兑换码',
+            'match'     => 'option',
+            'update'    => 'text',
+            //'list'        => true,
+            'show'      => 'type=2',
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '订单状态',
+            'default'   => '1',
+            'desc'      => '请选择订单状态',
+            'match'     => 'is_numeric',
+            'option'    => $status,
+            'search'    => 'select',
+            'update'    => 'radio',
+            'list'		=> true,
+            //'list'      => 'Dever::load("journal/lib/manage.showOrderStatusV1", "{id}")',
+            'control'   => 'status',
+        ),
+
+        'tk_pic'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '退款截图',
+            'default'   => '',
+            'desc'      => '退款截图',
+            'match'     => 'is_string',
+            'update'    => 'image',
+            'key'       => 1
+        ),
+
+        'tk_time'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '退款时间',
+            'default'   => '',
+            'desc'      => '退款时间',
+            'match'     => 'option',
+            //'list'        => true,
+            //'update'    => 'date',
+            'callback'  => 'maketime',
+            'show'      => 'status=5',
+        ),
+
+        'tk_admin'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '退款审核人',
+            'default'   => '1',
+            'desc'      => '退款审核人',
+            'match'     => 'option',
+            //'list'        => true,
+            'show'      => 'status=5',
+        ),
+
+        'tk_desc'       => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '退款备注',
+            'default'   => '',
+            'desc'      => '退款备注',
+            'match'     => 'option',
+            'update'    => 'textarea',
+            //'show'        => 'status=5',
+        ),
+
+        '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})',
+            //'list'      => 'Dever::load("service/lib/manage.showOrderTime", "{id}")',
+        ),
+
+        'info'      => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '备注',
+            'default'   => '',
+            'desc'      => '备注',
+            'match'     => 'option',
+            'update'    => 'textarea',
+            //'show'        => 'status=5'
+            //'list'      => '"{info}" ? "{info}" : "双击添加备注"',
+            //'edit'      => true,
+        ),
+
+        'mobile'        => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '手机号',
+            'default'   => '',
+            'desc'      => '手机号',
+            'match'     => 'option',
+            //'show'        => 'status=5'
+            'search'    => array
+            (
+                'api' => 'passport/user-all',//接口地址,最好是获取多条数据的地址
+                'col' => 'mobile',//要查询的字段
+                'result' => 'id',//返回的字段
+                'search' => 'uid',//本表的字段,默认为当前的字段
+            ),
+        ),
+    ),
+
+    'top' => Dever::config('base')->top,
+
+    # 增加这个,为了给当前的list增加一个option
+    'top_option' => array
+    (
+        'value' => $auth,
+        'col' => 'cate_id',
+    ),
+
+    'manage' => array
+    (
+        'delete' => false,
+        'edit' => false,
+        'insert' => false,
+
+        'button' => array
+        (
+            //'导出订单' => array('location', 'journal/lib/manage.out'),
+        ),
+
+        'list_button' => array(
+            'edit' => array('退款', 'status,tk_time,tk_pic,tk_desc,tk_admin', '{status} == 2 && ({type} == 1 || {type} == 3)'),
+            //'delete' => array('删除', '', '{status} == 1'),
+        ),
+    ),
+
+    'request' => array
+    (
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'type' => 'yes',
+                'create_uid' => 'yes',
+                'status' => array('1', '!='),
+                'uid' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('cdate' => 'desc'),
+            'page' => array(10, 'list'),
+            'col' => '*',
+        ),
+
+        'getYes' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'product_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('cdate' => 'desc'),
+            'col' => '*',
+        ),
+
+        # 获取提交订单超过12个小时
+        'getDataByTime' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'cdate' => array('yes', '>='),
+                'notice' => 'yes',
+                'note' => 'yes',
+                'type' => array('yes', 'in'),
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('cdate' => 'desc'),
+            'col' => '*',
+        ),
+
+        # 获取没有兑换码的订单
+        'getUnCode' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'code' => array('yes', '='),
+                'status' => 'yes',
+                'type' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('id' => 'desc'),
+            'limit' => '0,100',
+            'col' => '*',
+        ),
+
+        # 获取1,2
+        'getBuy' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'status' => 'yes',
+                'type' => array('yes', 'in'),
+                'product_id' => 'yes',
+                'order_id' => 'yes',
+                'uid' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('id' => 'desc'),
+            'col' => '*',
+        ),
+
+        'getMyAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'type' => 'yes',
+                'uid' => 'yes',
+                'status' => 'yes',
+                'cate_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('id' => 'desc'),
+            'page' => array(10, 'list'),
+            'col' => 'id,order_id,name,buy_num,cdate,cash,product_id,buy_id',
+        ),
+
+        # 删除未支付订单
+        'drop' => array
+        (
+            # 匹配的正则或函数 选填项
+            'where' => array
+            (
+                'time' => array('yes-cdate', '<='),
+                'status' => 1,
+                'state' => 1,
+            ),
+            'type' => 'delete',
+            'col' => 'id,order_id',
+        ),
+
+        # 获取数据
+        'getAllByDate' => array
+        (
+            # 匹配的正则或函数 选填项
+            'where' => array
+            (
+                'time' => array('yes-cdate', '<='),
+            ),
+            'type' => 'all',
+            'col' => 'id,order_id',
+        ),
+    ),
+);

+ 197 - 0
app/act/database/subscribe.php

@@ -0,0 +1,197 @@
+<?php
+
+$table = Dever::config('base')->type;
+
+$source = array
+(
+	1 => '购买',
+	2 => '兑换码',
+	3 => '邀请活动',
+	4 => '免费阅读',
+);
+$note = array
+(
+	1 => '未发送',
+	2 => '已发送',
+);
+return array
+(
+	# 表名
+	'name' => 'subscribe',
+	# 显示给用户看的名称
+	'lang' => '订阅日志',
+	# 是否显示在后台菜单
+	'order' => 68,
+	'menu' => false,
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'order'		=> 'desc',
+			//'list'		=> true,
+		),
+		
+
+		'uid'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '用户名',
+			'default' 	=> '0',
+			'desc' 		=> '请选择用户',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'text',
+			//'search'	=> 'select',
+			'search'    => array
+            (
+                'api' => 'passport/user-all',
+                'col' => 'username',
+                'result' => 'id',
+            ),
+			'list'		=> '{uid} > 0 ? Dever::load("passport/user-one#username", {uid}) . "({uid})" : "匿名用户"',
+		),
+
+		'type' 		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '订阅类别',
+			'default' 	=> '',
+			'desc' 		=> '订阅类别',
+			'match' 	=> 'option',
+			'update'	=> 'select',
+			//'search'	=> 'select',
+			'option' 	=> $table,
+			//'list'		=> true,
+		),
+		
+		'data_id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '标题',
+			'default' 	=> '',
+			'desc' 		=> '标题',
+			'update'	=> 'text',
+			'match' 	=> 'option',
+			'list'		=> 'Dever::load("act/lib/manage.load", "{type}", {data_id}, "{id}")',
+		),
+
+		'note'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '是否发送状态提醒-1未发送,2已发送',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+            'option'	=> $note,
+            'edit'		=> true,
+            'list'		=> true,
+        ),
+
+		'source' 		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '来源',
+			'default' 	=> '',
+			'desc' 		=> '来源',
+			'match' 	=> 'option',
+			'update'	=> 'select',
+			'search'	=> 'select',
+			'option' 	=> $source,
+			'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,
+	),
+
+	# request 请求接口定义
+	'request' => array
+	(
+		'getAll' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'data_id' => 'yes',
+				'type' => 'yes',
+				'avatar' => array('yes-t_2.avatar', '!='),
+				'state' => 1,
+				'status' => 'yes-t_2.status',
+			),
+			# 联表
+			'join' => array
+			(
+				array
+				(
+					'table' => 'passport/user',
+					'type' => 'left join',
+					'on' => array('uid','id'),
+					'col' => 't_2.username,t_2.avatar',
+				),
+			),
+			'type' => 'all',
+			'order' => array('t_2.id' => 'desc'),
+			'page' => array(6, 'list'),
+			'col' => '*',
+		),
+
+		'getMyAll' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'data_id' => 'yes',
+				'type' => 'yes',
+				'uid' => 'yes',
+				'source' => array('yes', 'in'),
+				'cate_id' => 'yes-t_2.cate_id',
+				'state' => 1,
+				'status' => 'yes-t_2.status',
+			),
+			# 联表
+			'join' => array
+			(
+				array
+				(
+					'table' => 'journal/info',
+					'type' => 'left join',
+					'on' => array('data_id','id'),
+				),
+			),
+			'type' => 'all',
+			'order' => array('t_1.id' => 'desc'),
+			'page' => array(10000, 'list'),
+			'col' => '*,t_2.*,t_2.num_add_view+t_2.num_view as num_view,ROUND((t_2.num_ding+t_2.num_add_ding)*t_2.num_ratio_ding) as num_ding,t_2.num_add_ding,t_2.num_ratio_ding',
+		),
+	)
+);

+ 8 - 0
app/act/index.php

@@ -0,0 +1,8 @@
+<?php
+
+define('DEVER_APP_NAME', 'act');
+define('DEVER_APP_LANG', '互动管理');
+define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+define('DEVER_MANAGE_ORDER', 199);
+define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-tower layui-icon-theme');
+include(DEVER_APP_PATH . '../boot.php');

+ 90 - 0
app/act/lib/Comment.php

@@ -0,0 +1,90 @@
+<?php
+
+namespace Act\Lib;
+
+use Dever;
+
+class Comment
+{
+    private function table($type) {
+        if ($type == 3) {
+            $table = 'act/live_comment';
+        } else {
+            $table = 'act/comment';
+        }
+        return $table;
+    }
+    # 获取评论列表
+    public function get($id, $type, $uid = false)
+    {
+        $where['type'] = $type;
+        $where['data_id'] = $id;
+        $table = $this->table($type);
+        $data = Dever::db($table)->getAll($where);
+
+        if ($data) {
+            foreach ($data as $k => $v) {
+                $user = Dever::load('passport/api')->info($v['uid']);
+                $data[$k]['time'] = Dever::mdate($v['cdate'], 2);
+                $data[$k]['username'] = $user['username'];
+                $data[$k]['avatar'] = $user['avatar'];
+                $data[$k]['cdate_time'] = date('Y-m-d H:i:s', $v['cdate']);
+
+                # 检查是否点赞
+                if ($uid > 0) {
+                    $data[$k]['up'] = Dever::load('act/lib/like')->get($uid, $v['id'], 11);
+                } else {
+                    $data[$k]['up'] = 2;
+                }
+            }
+        }
+        return $data;
+    }
+
+    # 获取当前用户的评论列表
+    public function getList($uid)
+    {
+        $where['uid'] = $uid;
+        $where['type'] = '1,2,3,6';
+        $info = Dever::db('act/comment')->getAll($where);
+
+        return $info;
+    }
+
+    # 发表评论
+    public function submit($uid, $id, $type, $content)
+    {
+        $where['uid'] = $uid;
+        $where['data_id'] = $id;
+        $where['type'] = $type;
+        $where['content'] = Dever::emoji($content);
+        $table = $this->table($type);
+        $info = Dever::db($table)->one($where);
+        if (!$info) {
+            $data_table = Dever::config('base')->type_table[$type];
+            $data = Dever::db($data_table)->one($id);
+            if (isset($data['name']) && $data['name']) {
+                $where['data_name'] = $data['name'];
+            }
+            
+            Dever::db($table)->insert($where);
+        }
+        Dever::score($uid, 'submit_commit', '发表评论');
+
+        # 更新评论数
+        if ($type == 5) {
+            return true;
+        }
+        $where = array();
+        $where['data_id'] = $id;
+        $where['type'] = $type;
+        $where['state'] = 1;
+        $total = Dever::db($table)->total($where);
+        $table = Dever::config('base')->type_table[$type];
+        Dever::db($table)->update(array('where_id' => $id, 'num_comment' => $total));
+
+        
+
+        return true;
+    }
+}

+ 38 - 0
app/act/lib/Cron.php

@@ -0,0 +1,38 @@
+<?php
+#计划任务
+namespace Act\Lib;
+
+use Dever;
+
+class Cron
+{
+	# 清理一小时前的待支付数据
+	public function drop_order_api()
+	{
+		$where['where_time'] = time() - 3600;
+		Dever::db('act/order')->drop($where);
+		return 'ok';
+	}
+
+	# 将七天前的数据进行迁移 废弃
+	public function mv_order()
+	{
+		return 'error';
+		$where['where_time'] = time() - (86400 * 7);
+		$data = Dever::db('act/order')->getAllByDate($where);
+		if ($data) {
+			$db = Dever::db('act/order_bak');
+			foreach ($data as $k => $v) {
+				$info = $db->one(array('order_id' => $v['order_id']));
+				if (!$info) {
+					$id = $v['id'];
+					unset($v['id']);
+					$db->insert($v);
+					Dever::db('act/order')->delete($id);
+				}
+			}
+		}
+
+		return 'ok';
+	}
+}

+ 33 - 0
app/act/lib/Feedback.php

@@ -0,0 +1,33 @@
+<?php
+
+namespace Act\Lib;
+
+use Dever;
+
+class Feedback
+{
+    # 发表反馈
+    public function submit($uid, $username, $name, $type_id, $contact, $content)
+    {
+        $where['uid'] = $uid;
+        $where['username'] = $username;
+        $where['name'] = $name;
+        $where['content'] = Dever::emoji($content);
+        $table = 'act/feedback';
+        $info = Dever::db($table)->one($where);
+        if (!$info) {
+            $where['type_id'] = $type_id;
+            $where['contact'] = $contact;
+            $id = Dever::db($table)->insert($where);
+        } else {
+            $where['where_id'] = $info['id'];
+            $where['type_id'] = $type_id;
+            $where['contact'] = $contact;
+            Dever::db($table)->update($where);
+            $id = $info['id'];
+        }
+        Dever::score($uid, 'submit_feedback', '发表反馈');
+
+        return $id;
+    }
+}

+ 54 - 0
app/act/lib/Form.php

@@ -0,0 +1,54 @@
+<?php
+
+namespace Act\Lib;
+
+use Dever;
+
+class Form
+{
+    # 获取当前可用的formid
+    public function get($uid, $type = 1, $system = 1)
+    {
+        $where['uid'] = $uid;
+        if ($type > 0) {
+        	$where['type'] = $type;
+        	if ($type == 2) {
+        		# 支付表单有3次机会
+        		$where['num'] = 3;
+        	} else {
+        		# 普通表单只有一次机会
+        		$where['num'] = 1;
+        	}
+        }
+        $where['cate_id'] = $system;
+        $info = Dever::db('act/form_id')->getAll($where);
+
+        if ($info) {
+            $key = array_rand($info);
+            if (isset($info[$key])) {
+            	$update['where_id'] = $info[$key]['id'];
+            	$update['num'] = $info[$key]['num'] + 1;
+            	Dever::db('act/form_id')->update($update);
+            	return $info[$key]['form_id'];
+            }
+        } else {
+            return false;
+        }
+    }
+
+    # 提交formid
+    public function submit($uid, $id, $type = 1, $system = 1)
+    {
+        $where['uid'] = $uid;
+        $where['type'] = $type;
+        $where['cate_id'] = $system;
+        $where['form_id'] = $id;
+        $info = Dever::db('act/form_id')->one($where);
+        if (!$info) {
+        	$where['num'] = 0;
+            Dever::db('act/form_id')->insert($where);
+        }
+
+        return true;
+    }
+}

+ 67 - 0
app/act/lib/Invite.php

@@ -0,0 +1,67 @@
+<?php
+
+namespace Act\Lib;
+
+use Dever;
+
+class Invite
+{
+    # 获取小刊的邀请排行
+    public function getList($uid, $id, $type = 4, $num = false)
+    {
+        $key = 'invite_' . $uid . '_' . $type . '_' . $id;
+        //$data = Dever::cache($key);
+        $data = array();
+        if (!$data) {
+        	$where['source_uid'] = $uid;
+            $where['type'] = $type;
+            $where['data_id'] = $id;
+            if ($num > 0) {
+                $where['page'] = array(6, 'list');
+            }
+            $where['avatar'] = 'null';
+            $data = Dever::db('act/invite')->getAll($where);
+
+            if ($data) {
+                //Dever::cache($key, $data, 900);
+            }
+        }
+
+        /*
+        if ($data) {
+            foreach ($data as $k => $v) {
+                $user = Dever::load('passport/api')->info($v['uid']);
+                $data[$k]['username'] = $user['username'];
+                $data[$k]['avatar'] = $user['avatar'];
+            }
+        }
+        */
+        return $data;
+    }
+
+    # 获取小刊的邀请数量
+    public function getTotal($uid, $id, $type = 4)
+    {
+        $where['source_uid'] = $uid;
+        $where['type'] = $type;
+        $where['data_id'] = $id;
+        $data = Dever::db('act/invite')->total($where);
+
+        return $data;
+    }
+
+    public function submit($source_uid, $uid, $id, $type = 4)
+    {
+        $where['source_uid'] = $source_uid;
+        $where['uid'] = $uid;
+        $where['data_id'] = $id;
+        $where['type'] = $type;
+        $table = 'act/invite';
+        $info = Dever::db($table)->one($where);
+        if (!$info) {
+            Dever::db($table)->insert($where);
+        }
+
+        return true;
+    }
+}

+ 65 - 0
app/act/lib/Like.php

@@ -0,0 +1,65 @@
+<?php
+
+namespace Act\Lib;
+
+use Dever;
+
+class Like
+{
+    # 获取当前用户是否点赞
+    public function get($uid, $id, $type)
+    {
+        $where['uid'] = $uid;
+        $where['type'] = $type;
+        $where['data_id'] = $id;
+        $where['state'] = 1;
+        $info = Dever::db('act/like')->one($where);
+
+        if ($info) {
+            return 1;
+        } else {
+            return 2;
+        }
+    }
+
+    # 获取当前用户的点赞列表
+    public function getList($uid)
+    {
+        $where['uid'] = $uid;
+        $where['type'] = '1,2,3,6';
+        $info = Dever::db('act/like')->getAll($where);
+
+        return $info;
+    }
+
+    # 点赞+喜欢
+    public function submit($uid, $id, $type)
+    {
+        $where['uid'] = $uid;
+        $where['data_id'] = $id;
+        $where['type'] = $type;
+        $info = Dever::db('act/like')->one($where);
+        if (!$info) {
+            Dever::db('act/like')->insert($where);
+        } else {
+            if ($info['state'] == 1) {
+                Dever::db('act/like')->update(array('where_id' => $info['id'], 'state' => 2));
+            } else {
+                Dever::db('act/like')->update(array('where_id' => $info['id'], 'state' => 1));
+            }
+        }
+
+        # 更新点赞数
+        $where = array();
+        $where['data_id'] = $id;
+        $where['type'] = $type;
+        $where['state'] = 1;
+        $total = Dever::db('act/like')->total($where);
+        $table = Dever::config('base')->type_table[$type];
+        Dever::db($table)->update(array('where_id' => $id, 'num_up' => $total));
+
+        Dever::score($uid, 'submit_like', '喜欢');
+
+        return true;
+    }
+}

+ 47 - 0
app/act/lib/Manage.php

@@ -0,0 +1,47 @@
+<?php
+
+namespace Act\Lib;
+
+use Dever;
+
+class Manage
+{
+    //{source_id} > 0 ? ("{name}" ? "{name}" : Dever::load("sad/supply-one#name", {source_id})) : "{name}"
+    public function load($source_table, $id, $mid = false)
+    {
+        $table = Dever::config('base')->type_table[$source_table];
+        $data = Dever::db($table)->one($id);
+
+        if ($data && isset($data['name']) && $data['name']) {
+            return $data['name'] . '('.$mid.')';
+        }
+        if ($data && isset($data['content']) && $data['content']) {
+            return $data['content'] . '('.$mid.')';
+        }
+        return '未知' . '('.$mid.')';
+    }
+
+    # 根据data_id获取data_name
+    public function getName_api()
+    {
+        $data = Dever::db('act/comment')->state();
+        if ($data) {
+            foreach ($data as $k => $v) {
+                $name = $this->load($v['type'], $v['data_id']);
+                if ($name && $name != $v['data_name']) {
+                    Dever::db('act/comment')->update(array('where_id' => $v['id'], 'data_name' => $name));
+                }
+            }
+        }
+
+        $data = Dever::db('act/live_comment')->state();
+        if ($data) {
+            foreach ($data as $k => $v) {
+                $name = $this->load($v['type'], $v['data_id']);
+                if ($name && $name != $v['data_name']) {
+                    Dever::db('act/live_comment')->update(array('where_id' => $v['id'], 'data_name' => $name));
+                }
+            }
+        }
+    }
+}

+ 131 - 0
app/act/lib/Note.php

@@ -0,0 +1,131 @@
+<?php
+
+namespace Act\Lib;
+
+use Dever;
+
+class Note
+{
+    # 获取message的push信息
+    public function push($type, $id, $name, $link = '')
+    {
+        $param = array('type' => $type, 'id' => $id, 'name' => $name, 'link' => $link);
+
+        $push = array(json_encode($param), 'jstyle://cn.jstyle.app/route?' . http_build_query($param));
+        return $push;
+    }
+    # 获取当前用户是否预约
+    public function get($uid, $id, $type)
+    {
+        $where['uid'] = $uid;
+        $where['type'] = $type;
+        $where['data_id'] = $id;
+        $where['state'] = 1;
+        $info = Dever::db('act/live_note')->one($where);
+
+        if ($info && $info['state'] == 1) {
+            return 1;
+        } else {
+            return 2;
+        }
+    }
+
+    # 预约
+    public function submit($uid, $id, $type, $formid = '', $system = 1)
+    {
+        if ($formid) {
+            Dever::load('act/lib/form')->submit($uid, $formid, 1, $system);
+        }
+        $where['uid'] = $uid;
+        $where['data_id'] = $id;
+        $where['type'] = $type;
+        $where['cate_id'] = $system;
+        $info = Dever::db('act/live_note')->one($where);
+        if (!$info) {
+            if ($formid) {
+                $where['formid'] = $formid;
+            }
+            
+            Dever::db('act/live_note')->insert($where);
+        } else {
+            $update['cate_id'] = $system;
+            $update['where_id'] = $info['id'];
+            if ($formid) {
+                $update['formid'] = $formid;
+            }
+            $update['cdate'] = time();
+            if ($info['state'] == 1) {
+                $update['state'] = 2;
+                Dever::db('act/live_note')->update($update);
+            } else {
+                $update['state'] = 1;
+                Dever::db('act/live_note')->update($update);
+            }
+        }
+
+        return true;
+    }
+
+    # 提醒 后续实现 需要加入到cron里:act/lib/note.cron
+    public function cron()
+    {
+        $data = Dever::db('act/live_note')->getAll();
+
+        if ($data) {
+            $time = time();
+            $day = 7 * 86400;
+            $date = 800;
+            foreach ($data as $k => $v) {
+                $table = Dever::config('base')->type_table[$v['type']];
+                $info = Dever::db($table)->one($v['data_id']);
+                if ($info && $v['type'] == 3 && isset($info['sdate']) && $info['sdate'] > 0 && $info['sdate'] > $time && $info['sdate'] - $time <= $date) {
+
+                    $user = Dever::db('passport/user')->one($v['uid']);
+                    if (!$user) {
+                        continue;
+                    }
+                    Dever::db('act/live_note')->update(array('where_id' => $v['id'], 'note' => 2));
+
+                    if (Dever::project('message')) {
+                        Dever::load('message/lib/data')->push(-1, $v['uid'], '直播提醒', $info['name'] . '直播即将开始,马上观看!', 11, $v['cate_id'], 1, Dever::load('act/lib/note')->push(3, $info['id'], $info['name']));
+                    }
+                    
+                    # 发送短消息
+                    if (isset($user['mobile']) && $user['mobile'] && Dever::project('sms')) {
+                        $send = array();
+                        $send['name'] = $info['name'];
+                        Dever::load('sms/api.send', 'note_live', $user['mobile'], $send);
+                    }
+
+                    //$formid = Dever::load('act/lib/form')->get($v['uid'], 1);
+                    $formid = $v['formid'];
+                    if ($formid) {
+                        # 发送模板消息
+                        $wechat = Dever::db('passport/wechat')->one(array('uid' => $v['uid'], 'type' => 1, 'system_id' => $v['cate_id']));
+                        if ($wechat && Dever::project('wechat_applet')) {
+                            $send['key'] = 'note_live';
+                            $send['project_id'] = $v['cate_id'];
+                            $send['touser'] = $wechat['openid'];
+                            $send['page'] = Dever::config('base')->applet_index . '?scene=' . Dever::login($v['uid']) . ',' . $v['type'] . ',' . $v['id'];
+                            $send['data'] = array
+                            (
+                                'keyword1' => array('value' => $info['name']),
+                                'keyword2' => array('value' => $info['name'] . '直播即将开始,马上观看!'),
+                            );
+                            $send['data'] = json_encode($send['data']);
+                            $send['form_id'] = $formid;
+                            Dever::load('wechat_applet/msg.send', $send);
+                        }
+                    }
+                }
+            }
+        }
+
+        return 'ok';
+    }
+
+    public function cron_api()
+    {
+        
+    }
+}

+ 151 - 0
app/act/lib/Num.php

@@ -0,0 +1,151 @@
+<?php
+
+namespace Act\Lib;
+
+use Dever;
+
+class Num
+{
+    # 获取我在这个小刊中的本数
+    public function get($id, $uid)
+    {
+        $where['uid'] = $uid;
+        $where['journal_id'] = $id;
+        $where['state'] = 1;
+        $data = Dever::db('act/journal_num')->one($where);
+
+        if ($data) {
+            return $data['num'];
+        } else {
+            return 0;
+        }
+    }
+    
+    # 获取小刊的积分排行
+    public function getList($id, $uid = false)
+    {
+        $key = 'journal_num_' . $id;
+        $data = Dever::cache($key);
+        if (!$data) {
+            $where['journal_id'] = $id;
+            if ($uid > 0) {
+                $where['uid'] = $uid;
+            }
+            $data = Dever::db('act/journal_num')->getAll($where);
+
+            if ($data) {
+                foreach ($data as $k => $v) {
+                    $user = Dever::load('passport/api')->info($v['uid']);
+                    $data[$k]['username'] = $user['username'];
+                    $data[$k]['avatar'] = $user['avatar'];
+                    $data[$k]['mobile'] = $user['mobile'];
+                }
+
+                Dever::cache($key, $data, 600);
+            }
+        }
+        
+        return $data;
+    }
+
+    public function submit($id, $uid = false, $num = false, $update = true)
+    {
+        $where['uid'] = $uid;
+        $where['journal_id'] = $id;
+        $table = 'act/journal_num';
+        $db = Dever::db($table);
+        $info = $db->one($where);
+        if (!$info) {
+            $where['num'] = $num;
+            $db->insert($where);
+        } else {
+            if ($update) {
+                $where['where_id'] = $info['id'];
+                if (!$info['num'] || $info['num'] < 0) {
+                    $info['num'] = 0;
+                }
+                $where['num'] = $info['num'] + $num;
+                $db->update($where);
+            }
+        }
+
+        return true;
+    }
+
+    # 矫正数据用的,放到计划任务中
+    public function cron()
+    {
+        
+
+        return true;
+    }
+
+    # 订阅数计数器
+    public function setCounter($id, $num = 0)
+    {
+        $key = 'journal_buy_num3_' . $id;
+        /*
+        $callback = function() use($id) {
+            $journal = Dever::db('journal/info')->one($id);
+            return $journal['num_ding'];
+        };
+        Dever::counter($key, $num, $callback);
+        */
+        Dever::cache($key, $num);
+        return true;
+    }
+
+    # 订阅数计数器
+    public function getCounter($id)
+    {
+        $key = 'journal_buy_num3_' . $id;
+        //return Dever::counter($key);
+        return Dever::cache($key);
+    }
+
+    /**
+     * 导出成excel
+     *
+     * @return mixed
+     */
+    public function out_api()
+    {
+        $id = Dever::input('id');
+        $journal = Dever::db('journal/info')->one($id);
+
+        if (!$journal) {
+            return;
+        }
+
+        $score = $this->getList($id);
+        $header = $data = array();
+        $name = $journal['name'];
+        if ($score) {
+            $i = 0;
+            foreach ($score as $k => $v) {
+                $data[$i] = array
+                (
+                    $i+1,
+                    $v['username'],
+                    $v['mobile'],
+                    $v['num'],
+                );
+                $i++;
+            }
+        }
+
+        $header = array
+        (
+            '排序', '用户名', '手机号', '本数'
+        );
+
+        $file = $name . '_排行榜';
+        if (Dever::input('test')) {
+            print_r($header);
+            print_r($data);die;
+        }
+        
+        Dever::excelExport($data, $header, $file, $sheet = 0, $sheetName = $name);
+        return;
+    }
+}

+ 272 - 0
app/act/lib/Pay.php

@@ -0,0 +1,272 @@
+<?php
+#新版本的异步支付
+namespace Act\Lib;
+
+use Dever;
+
+class Pay
+{
+    private $key = 'jmss_2018';
+
+    # 退款操作
+    public function order($id, $name, $data)
+    {
+        $status = Dever::param('status', $data);
+
+        if ($status == 5 && $id > 0) {
+            $send = array();
+            $info = Dever::db('act/order')->one($id);
+            if ($info['system'] == 1) {
+                if ($info['cate_id'] == 1) {
+                    $account_id = 1;
+                }
+                if ($info['cate_id'] == 2) {
+                    $account_id = 4;
+                }
+                if ($info['cate_id'] == 3) {
+                    $account_id = 5;
+                }
+            } elseif ($info['system'] == 2) {
+                $account_id = 2;
+            } else {
+                $account_id = 3;
+            }
+            $send['pay_project_id'] = 3;
+            $send['pay_uid'] = $info['uid'];
+            $send['pay_order_id'] = $info['order_id'] ? $info['order_id'] : Dever::load('act/order')->createOrderId($info, $info['id']);
+            $send['pay_tk_pic'] = Dever::param('tk_pic', $data);
+            $send['pay_tk_time'] = Dever::param('tk_time', $data);
+            $send['pay_tk_desc'] = Dever::param('tk_desc', $data);
+            $send['pay_account_id'] = $account_id;
+            $send['pay_cash'] = $info['cash'];
+            $send['pay_status'] = $status;
+            $send['dever_token'] = $this->key;
+            Dever::load('pay/lib/set.updateStatus', $send);
+            if ($info['buy_id'] > 0) {
+                $buy = Dever::db('journal/buy_num')->one($info['buy_id']);
+
+                if ($buy) {
+                    if ($info['buy_num'] > 0) {
+                        $num = $info['buy_num'];
+                    } else {
+                        $num = $buy['num'];
+                    }
+                    # 减少积分
+                    $score = $num * 20;
+
+                    $user = Dever::db('score/user')->one(array('uid' => $info['uid']));
+                    if ($user) {
+                        $user_id = $user['id'];
+                        $user_score = $user['score'];
+                        $user_score = $user_score - $score;
+                        if ($user_score < 0) {
+                            $user_score = 0;
+                        }
+                        Dever::db('score/user')->update(array('where_id' => $user_id, 'score' => $user_score));
+                    }
+
+                    # 减少排行榜
+                    $journal_num = Dever::db('act/journal_num')->one(array('uid' => $info['uid'], 'journal_id' => $info['product_id']));
+                    if ($journal_num) {
+                        $journal_num_id = $journal_num['id'];
+                        $journal_num = $journal_num['num'];
+                        $journal_num = $journal_num - $num;
+                        if ($journal_num < 0) {
+                            $journal_num = 0;
+                        }
+                        Dever::db('act/journal_num')->update(array('where_id' => $journal_num_id, 'num' => $journal_num));
+                    }
+
+                    # 减少订阅本数 这个定时跑就行了 不管了
+                    $journal = Dever::db('journal/info')->one($info['product_id']);
+                    if ($journal) {
+                        $journal_id = $journal['id'];
+                        $journal_num = $journal['num_ding'];
+                        $journal_num = $journal_num - $num;
+                        if ($journal_num < 0) {
+                            $journal_num = 0;
+                        }
+                        Dever::db('journal/info')->update(array('where_id' => $journal_id, 'num_ding' => $journal_num));
+                    }
+                }
+            }
+        }
+        return 'reload';
+    }
+
+    /**
+     * 支付成功后,调取的接口 这里的安全以后再升级吧,升级成和pay/lib/set.updateStatus一样的
+     *
+     * @return mixed
+     */
+    public function act($param = array())
+    {
+        $this->act_action($param);
+        return 'ok';
+
+        $send = Dever::preInput('pay_');
+        $send = $param;
+        $key = md5($this->key);
+        ksort($send);
+        $send['signature'] = md5($key . '&' . http_build_query($send));
+        $signature = Dever::input('signature');
+        if ($send['signature'] == $signature) {
+            $this->act_action($send);
+        }
+
+        return 'ok';
+    }
+
+    public function act_action($send)
+    {
+        //$product_id = $send['pay_product_id'];
+        //$uid = $send['pay_uid'];
+        //$cash = $send['pay_cash'];
+        $order_id = $send['pay_order_id'];
+        $status = $send['pay_status'];
+        $msg = $send['pay_msg'];
+
+        $temp = explode('D', $order_id);
+        $id = $temp[1];
+
+        //$order = Dever::db('act/order_temp')->one(array('order_id' => $order_id, 'uid' => $uid));
+        $order = Dever::db('act/order_temp')->one($id);
+
+        if ($send['pay_status'] == 2 && $order) {
+
+            $update = $order;
+            //$update['where_id'] = $order['id'];
+            $update['status'] = 2;
+            if ($order['type'] == 3 && !$order['code']) {
+                if ($order['system'] == 2) {
+                    $code = Dever::load('code/lib/core')->createCodeByOrder($order);
+                } else {
+                    $code = Dever::load('code/lib/core')->createCodeByOrder($order, -1);
+                }
+                
+                if ($code) {
+                    $update['code'] = $code;
+                }
+            }
+
+            Dever::db('act/order')->insert($update);
+
+            $score = false;
+            $num = false;
+            $journal = Dever::load('act/order')->getJournal($order['product_id']);
+            if ($order['buy_id'] > 0) {
+                $buy = Dever::load('act/order')->getBuy($order['buy_id']);
+                if ($buy && $buy['score'] > 0) {
+                    $score = $buy['num'] * $buy['score'];
+                } else {
+                    if ($order['type'] == 1) {
+                        # 直接购买
+                        $col = 'score';
+                    } elseif ($order['type'] == 3) {
+                        $col = 'dh_score';
+                    }
+
+                    if ($journal && $buy && $journal[$col] > 0) {
+                        $score = $buy['num'] * $journal[$col];
+                    } elseif ($journal && $buy) {
+                        $num = $buy['num'];
+                    }
+                }
+
+                if ($buy && $buy['num']) {
+
+                    $active = Dever::load('act/order')->getActive($order['product_id']);
+                    $active_state = true;
+                    if ($active && $active['status'] == 1 && time() > $active['end']) {
+                        $active_state = false;
+                    }
+                    if ($active_state) {
+                        # 增加本数
+                        Dever::load('act/lib/num')->submit($order['product_id'], $order['uid'], $buy['num']);
+                    }
+
+                    # 增加订阅数
+                    //Dever::load('act/lib/num')->setCounter($order['product_id'], $buy['num']);
+                }
+            }
+            # 积分
+            //Dever::score($order['uid'], 'buy_journal', '购买小刊', '', $score, $num);
+
+            if ($order['system'] == 2) {
+                return;
+            }
+
+            # 发消息
+            $journal['id'] = $order['product_id'];
+            $journal['name'] = $order['name'];
+            if (strstr('-', $journal['name'])) {
+                $name = explode('-', $journal['name']);
+                $journal['name'] = $name[0];
+            }
+            
+            //$journal = Dever::db('journal/info')->one($order['product_id']);
+
+            if (Dever::project('message')) {
+                Dever::load('message/lib/data')->push(-1, $order['uid'], '购买提醒', '购买成功,您获得了 '.$journal['name'].' 的阅读资格!', 11, $order['cate_id'], 1, Dever::load('act/lib/note')->push(4, $journal['id'], $journal['name']));
+            }
+
+            $user = Dever::db('passport/user')->one($order['uid']);
+
+            # 发短信
+            /*
+            if (isset($user['mobile']) && $user['mobile'] && Dever::project('sms') && $order['cate_id'] == 1) {
+                $send = array();
+                $send['name'] = $journal['name'];
+                Dever::load('sms/api.send', 'buy_journal', $user['mobile'], $send);
+            }
+            */
+
+            # 发模板消息
+            $wechat = Dever::db('passport/wechat')->one(array('uid' => $order['uid'], 'type' => 1, 'system_id' => $order['cate_id']));
+            if ($wechat && Dever::project('wechat_applet')) {
+                $send['key'] = 'buy_journal';
+                $send['project_id'] = $order['cate_id'];
+                $send['touser'] = $wechat['openid'];
+                $send['page'] = Dever::config('base')->applet_index . '?scene=' . $order['uid'] . ',' . '4,' . $order['product_id'];
+                $send['data'] = array
+                (
+                    'keyword1' => array('value' => date('Y年m月d日 H:i', $order['cdate'])),
+                    'keyword2' => array('value' => '购买成功,您获得了 '.$journal['name'].' 的阅读资格!'),
+                );
+                $send['data'] = json_encode($send['data']);
+                $send['form_id'] = Dever::load('act/lib/form')->get($order['uid'], 2, $order['cate_id']);
+
+                if ($send['form_id']) {
+                    Dever::load('wechat_applet/msg.send', $send);
+                }
+            }
+
+        } else {
+            Dever::db('act/order_temp')->update(array('where_id' => $order['id'], 'status' => 3));
+        }
+    }
+
+    public function send_api()
+    {
+        $uid = Dever::input('uid', 8);
+        # 发模板消息
+        $wechat = Dever::db('passport/wechat')->one(array('uid' => $uid));
+        if ($wechat && Dever::project('wechat_applet')) {
+            $send['key'] = 'buy_journal';
+            $send['project_id'] = 2;
+            $send['touser'] = $wechat['openid'];
+            $send['page'] = Dever::config('base')->applet_index . '?scene=' . Dever::login($uid) . ',' . '4,' . $order['product_id'];
+            $send['data'] = array
+            (
+                'keyword1' => array('value' => date('Y年m月d日 H:i', $order['cdate'])),
+                'keyword2' => array('value' => '购买成功,您获得了 '.$journal['name'].' 的阅读资格!'),
+            );
+            $send['data'] = json_encode($send['data']);
+            $send['form_id'] = Dever::load('act/lib/form')->get($uid, 2, $order['cate_id']);
+
+            if ($send['form_id']) {
+                Dever::load('wechat_applet/msg.send', $send);
+            }
+        }
+    }
+}

+ 135 - 0
app/act/lib/Score.php

@@ -0,0 +1,135 @@
+<?php
+
+namespace Act\Lib;
+
+use Dever;
+
+class Score
+{
+    # 获取我在这个小刊中的积分
+    public function get($id, $uid, $type = 4)
+    {
+        $where['uid'] = $uid;
+        $where['type'] = $type;
+        $where['data_id'] = $id;
+        $where['state'] = 1;
+        $data = Dever::db('act/score')->one($where);
+
+        if ($data) {
+            return $data['score'];
+        } else {
+            return 0;
+        }
+    }
+    
+    # 获取小刊的积分排行
+    public function getList($id, $type = 4, $uid = false)
+    {
+        $where['type'] = $type;
+        $where['data_id'] = $id;
+        if ($uid > 0) {
+            $where['uid'] = $uid;
+        }
+        $data = Dever::db('act/score')->getAll($where);
+
+        if ($data) {
+            foreach ($data as $k => $v) {
+                $user = Dever::load('passport/api')->info($v['uid']);
+                $data[$k]['username'] = $user['username'];
+                $data[$k]['avatar'] = $user['avatar'];
+                $data[$k]['mobile'] = $user['mobile'];
+            }
+        }
+        return $data;
+    }
+
+    public function submit()
+    {
+        $user_log_id = Dever::input('user_log_id');
+        $type = Dever::input('type', 4);
+        $id = Dever::input('id');
+        $method = Dever::input('method');
+
+        $user_log = Dever::db('score/user_log')->one($user_log_id);
+
+        if ($user_log) {
+            if ($method == 'share' || $method == 'pay' || $method == 'code') {
+                # 活动结束后,无法增加当前小刊积分
+                if ($type == 4) {
+                    $journal = Dever::db('journal/active')->one(array('info_id' => $id, 'state' => 1));
+                    if (!$journal) {
+                        return;
+                    }
+                    if ($journal && $journal['status'] == 2) {
+                        return;
+                    }
+                    if ($journal && time() > $journal['end']) {
+                        return;
+                    }
+                }
+            }
+            //$where['user_log_id'] = $user_log_id;
+            $where['uid'] = $user_log['uid'];
+            $where['data_id'] = $id;
+            $where['type'] = $type;
+            $table = 'act/score';
+            $info = Dever::db($table)->one($where);
+            if (!$info) {
+                $where['score'] = $user_log['num'];
+                Dever::db($table)->insert($where);
+            } else {
+                $where['where_id'] = $info['id'];
+                $where['score'] = $info['score'] + $user_log['num'];
+                Dever::db($table)->update($where);
+            }
+        }
+
+        return true;
+    }
+
+    /**
+     * 导出成excel
+     *
+     * @return mixed
+     */
+    public function out_api()
+    {
+        $id = Dever::input('id');
+        $journal = Dever::db('journal/info')->one($id);
+
+        if (!$journal) {
+            return;
+        }
+
+        $score = $this->getList($id);
+        $header = $data = array();
+        $name = $journal['name'];
+        if ($score) {
+            $i = 0;
+            foreach ($score as $k => $v) {
+                $data[$i] = array
+                (
+                    $i+1,
+                    $v['username'],
+                    $v['mobile'],
+                    $v['score'],
+                );
+                $i++;
+            }
+        }
+
+        $header = array
+        (
+            '排序', '用户名', '手机号', '积分'
+        );
+
+        $file = $name . '_邀请积分排行榜';
+        if (Dever::input('test')) {
+            print_r($header);
+            print_r($data);die;
+        }
+        
+        Dever::excelExport($data, $header, $file, $sheet = 0, $sheetName = $name);
+        return;
+    }
+}

+ 163 - 0
app/act/lib/Share.php

@@ -0,0 +1,163 @@
+<?php
+
+namespace Act\Lib;
+
+use Dever;
+
+class Share
+{
+    # 获取某个用户在某个图文的分享回流数
+    public function getRefluxNum($uid, $id, $type)
+    {
+        $where['source_uid'] = $uid;
+        $where['type'] = $type;
+        $where['data_id'] = $id;
+        return Dever::db('act/share_reflux')->total($where);
+    }
+
+    # 提交分享
+    public function submit($uid, $id, $type)
+    {
+        $where['uid'] = $uid;
+        $where['data_id'] = $id;
+        $where['type'] = $type;
+        $info = Dever::db('act/share')->one($where);
+        if (!$info) {
+            $where['num'] = 1;
+            Dever::db('act/share')->insert($where);
+        } else {
+            $where['num'] = $info['num'] + 1;
+            $where['where_id'] = $info['id'];
+            Dever::db('act/share')->update($where);
+        }
+
+        Dever::score($uid, 'share_friend', '邀请好友');
+
+        return true;
+    }
+
+    # 回流
+    public function submit_reflux($source_uid, $uid, $id, $type, $system = 1)
+    {
+        if ($source_uid == $uid) {
+            return false;
+        }
+        $where['uid'] = $source_uid;
+        //$where['uid'] = $uid;
+        $where['data_id'] = $id;
+        $where['type'] = $type;
+
+        $share = Dever::db('act/share')->one($where);
+        if ($share) {
+            $where = array();
+            $user = Dever::db('passport/user')->one($uid);
+
+            $where['user_type'] = 3;
+
+            //if ($user['temp'] == 2 || $user['bind'] == 1) {
+            if ($user) {
+                # 必须是已经绑定手机号或者授权用户才可以增加积分
+
+                # 新用户 增加邀请关系
+                if (Dever::project('invite')) {
+                    $parent = Dever::load('invite/api')->getParent($uid, $level = 1);
+                    if (!$parent) {
+                        # 新用户
+                        $where['user_type'] = 1;
+                        Dever::load('invite/api')->setRelation($uid, $source_uid);
+                    } else {
+                        # 老用户
+                        $where['user_type'] = 2;
+                        
+                    }
+                }
+                if ($type <= 4) {
+                    $method = '';
+                    $name = Dever::config('base')->type[$type];
+                    if ($type == 1) {
+                        $method = 'article';
+                    }
+                    if ($type == 2) {
+                        $method = 'vod';
+                    }
+                    if ($type == 3) {
+                        $method = 'live';
+                    }
+                    if ($type == 4) {
+                        $method = 'journal';
+                    }
+
+                    # 增加积分
+                    if ($where['user_type'] == 1) {
+                        $score = 0;
+                        if ($type == 4) {
+                            $active = Dever::db('journal/active')->one(array('id' => $id));
+                            /*
+                            if ($active && $active['status'] == 1 && time() <= $active['end']) {
+                                $score = $active['invite_score'];
+                            }
+                            */
+                            if ($active) {
+                                $score = $active['invite_score'];
+                            }
+                        }
+                        Dever::score($source_uid, 'share_'.$method.'_new_reflux', '通过'.$name.'邀请到新用户', 'act/lib/score.submit?method=share&type='.$type.'&id=' . $id, $score);
+                        # 插入到邀请列表里
+                        Dever::load('act/lib/invite')->submit($source_uid, $uid, $id, $type);
+
+                        # 小刊订阅
+                        if ($type == 4) {
+                            if (isset($active) && $active) {
+                                $num = $active['invite_num'];
+
+                                $invite_num = Dever::load('act/lib/invite')->getTotal($source_uid, $id, $type);
+
+                                if ($invite_num >= $num) {
+
+                                    # 发消息
+                                    if ($invite_num == $num) {
+                                        $journal = Dever::db('journal/info')->one($id);
+                                        if (Dever::project('message')) {
+                                            Dever::load('message/lib/data')->push(-1, $source_uid, '活动提醒', '邀请人数已达'.$invite_num.'人,您获得了 '.$journal['name'].' 的阅读资格!', 11, $journal['cate_id'], 1, Dever::load('act/lib/note')->push(4, $journal['id'], $journal['name']));
+                                        }
+
+                                        # 发送模板消息 这里没有formid 暂时先不发送模板消息,后续应该通过前端收集formid就好了
+
+                                        # 发短信
+                                        /*
+                                        if (isset($user['mobile']) && $user['mobile'] && Dever::project('sms') && $system == 1) {
+                                            $send = array();
+                                            $send['num'] = $invite_num;
+                                            $send['name'] = $journal['name'];
+                                            Dever::load('sms/api.send', 'share_journal', $user['mobile'], $send);
+                                        }
+                                        */
+                                    }
+                                    
+                                    Dever::load('act/lib/subscribe')->submit($source_uid, $id, 3);
+                                }
+                            }
+                        }
+                        
+                    } elseif ($where['user_type'] == 2) {
+                        Dever::score($source_uid, 'share_'.$method.'_reflux', '通过'.$name.'邀请到老用户');
+                    }
+                }
+            }
+
+            
+            $where['source_uid'] = $source_uid;
+            $where['uid'] = $uid;
+            $where['data_id'] = $id;
+            $where['type'] = $type;
+            $where['share_id'] = $share['id'];
+            $info = Dever::db('act/share_reflux')->one($where);
+            if (!$info) {
+                Dever::db('act/share_reflux')->insert($where);
+                return true;
+            }
+        }
+
+        return false;
+    }
+}

+ 109 - 0
app/act/lib/Subscribe.php

@@ -0,0 +1,109 @@
+<?php
+
+namespace Act\Lib;
+
+use Dever;
+
+class Subscribe
+{
+    private $key = 'use_sub_';
+
+    # 获取小刊是否被人订阅
+    public function get($id, $uid, $type = 4, $cache = false)
+    {
+        $key = $this->key . $uid . '_' . $id;
+        $data = Dever::cache($key);
+        if ($data == 1) {
+            return 1;
+        } else {
+            if (!$cache) {
+                $where['uid'] = $uid;
+                $where['type'] = $type;
+                $where['data_id'] = $id;
+                $where['state'] = 1;
+                $data = Dever::db('act/subscribe')->one($where);
+
+                if ($data) {
+                    Dever::cache($key, 1, 864000);
+                    return 1;
+                } else {
+                    return 2;
+                }
+            }
+            return 2;
+        }
+    }
+
+    public function getInfo($id, $uid, $type = 4)
+    {
+        $where['uid'] = $uid;
+        $where['type'] = $type;
+        $where['data_id'] = $id;
+        $where['state'] = 1;
+        $data = Dever::db('act/subscribe')->one($where);
+
+        return $data;
+    }
+    
+    # 获取小刊订阅列表
+    public function getList($id, $type = 4)
+    {
+        $key = 'subscribe_' . $type . '_' . $id;
+        //$data = Dever::cache($key);
+        $data = array();
+        if (!$data) {
+            $where['type'] = $type;
+            $where['data_id'] = $id;
+            $where['avatar'] = 'null';
+            $data = Dever::db('act/subscribe')->getAll($where);
+
+            if ($data) {
+                //Dever::cache($key, $data, 900);
+            }
+        }
+        
+
+        /*
+        if ($data) {
+            foreach ($data as $k => $v) {
+                $user = Dever::load('passport/api')->info($v['uid']);
+                $data[$k]['username'] = $user['username'];
+                $data[$k]['avatar'] = $user['avatar'];
+            }
+        }
+        */
+        return $data;
+    }
+
+    # 订阅
+    public function submit($uid, $id, $source = 1, $type = 4)
+    {
+        $where['uid'] = $uid;
+        $where['data_id'] = $id;
+        $where['type'] = $type;
+        $table = 'act/subscribe';
+        $info = Dever::db($table)->one($where);
+
+        $key = $this->key . $uid . '_' . $id;
+        Dever::cache($key, 1, 864000);
+
+        if (!$info) {
+            $where['source'] = $source;
+            Dever::db($table)->insert($where);
+            return true;
+        }
+
+        return false;
+
+        # 更新订阅数
+        $where = array();
+        $where['data_id'] = $id;
+        $where['type'] = $type;
+        $where['state'] = 1;
+        $total = Dever::db($table)->total($where);
+        $table = Dever::config('base')->type_table[$type];
+        Dever::db($table)->update(array('where_id' => $id, 'num_ding' => $total));
+
+        return false;
+    }
+}

+ 47 - 0
app/act/lib/Watch.php

@@ -0,0 +1,47 @@
+<?php
+
+namespace Act\Lib;
+
+use Dever;
+
+class Watch
+{
+    # 获取当前小刊的观看数
+    public function get($id, $type = 3)
+    {
+        $where['type'] = $type;
+        $where['data_id'] = $id;
+        $where['state'] = 1;
+        $info = Dever::db('act/watch')->total($where);
+
+        return $info;
+    }
+
+    # 观看
+    public function submit($uid, $id, $type = 3)
+    {
+        $where['uid'] = $uid;
+        $where['data_id'] = $id;
+        $where['type'] = $type;
+        $info = Dever::db('act/watch')->one($where);
+        if (!$info) {
+            Dever::db('act/watch')->insert($where);
+        }
+
+        if ($type == 3) {
+            # 更新观看数
+            $where = array();
+            $where['data_id'] = $id;
+            $where['type'] = $type;
+            $where['state'] = 1;
+            $total = Dever::db('act/watch')->total($where);
+            $table = Dever::config('base')->type_table[$type];
+            Dever::db($table)->update(array('where_id' => $id, 'num_user' => $total));
+
+            Dever::score($uid, 'submit_watch', '观看直播');
+        }
+        
+
+        return true;
+    }
+}

+ 504 - 0
app/act/src/Order.php

@@ -0,0 +1,504 @@
+<?php
+# 电子刊购买接口,本接口下所有接口都无需缓存 做好配置:act/order
+namespace Act\Src;
+
+use Dever;
+use Main\Lib\Core;
+
+class Order extends Core
+{
+    public function setCache($id, $type)
+    {
+        # 清空缓存,重新生成
+        if ($type == 1) {
+            $key = 'journal_infos_' . $id;
+            $journal = Dever::db('journal/info')->one($id);
+            Dever::cache($key, $journal);
+        } elseif ($type == 2) {
+            $key = 'journal_buys_' . $id;
+            $buy = Dever::db('journal/buy_num')->one($id);
+
+            if (!$buy['name']) {
+                $buy['name'] = '购买' . $buy['num'] . '本';
+            }
+            Dever::cache($key, $buy);
+        } elseif ($type == 3) {
+            $key = 'journal_actives_' . $id;
+            $active = Dever::db('journal/active')->one($id);
+            Dever::cache($key, $active);
+        } elseif ($type == 4) {
+            $key = 'journal_stars_' . $id;
+            $star = Dever::db('journal/star')->one($id);
+            Dever::cache($key, $star);
+        }
+    }
+
+    # 获取明星信息,走缓存,先不走接口
+    public function getStar($star_id = false)
+    {
+        $star_id = Dever::input('star_id', $star_id, '> 0', '请传入正确的明星ID');
+
+        $key = 'journal_stars_' . $star_id;
+
+        $star = Dever::cache($key);
+
+        if (!$star) {
+            $star = Dever::db('journal/star')->one($star_id);
+
+            Dever::cache($key, $star);
+        }
+        return $active;
+    }
+
+    # 获取电子刊信息,走缓存,先不走接口
+    public function getActive($journal_id = false)
+    {
+        $journal_id = Dever::input('journal_id', $journal_id, '> 0', '请传入正确的小刊ID');
+
+        $key = 'journal_actives_' . $journal_id;
+
+        $active = Dever::cache($key);
+
+        if (!$active) {
+            $active = Dever::db('journal/active')->one(array('info_id' => $journal_id, 'state' => 1));
+
+            Dever::cache($key, $active);
+        }
+        return $active;
+    }
+
+	# 获取电子刊信息,走缓存,先不走接口
+	public function getJournal($journal_id = false)
+	{
+        $journal_id = Dever::input('journal_id', $journal_id);
+
+        $status = false;
+        if (strstr($journal_id, 'preview_')) {
+            $journal_id = str_replace('preview_', '', $journal_id);
+            $status = true;
+        }
+
+        if (!$journal_id) {
+            Dever::alert('请传入正确的小刊ID');
+        }
+
+        $key = 'journal_infos_' . $journal_id;
+
+        $journal = Dever::cache($key);
+
+        if (!$journal) {
+        	$journal = Dever::db('journal/info')->one($journal_id);
+	        if (!$journal) {
+	            Dever::alert('请传入正确的小刊ID');
+	        }
+
+	        Dever::cache($key, $journal);
+        }
+        return $journal;
+	}
+
+	# 获取购买的信息,走缓存,先不走接口
+	public function getBuy($buy_id = false)
+	{
+        $buy_id = Dever::input('buy_id', $buy_id, '> 0', '请传入正确的支付ID');
+
+        $key = 'journal_buys_' . $buy_id;
+
+        $buy = Dever::cache($key);
+
+        if (!$buy) {
+	        $buy = Dever::db('journal/buy_num')->one($buy_id);
+
+	        if (!$buy) {
+	            Dever::alert('请传入正确的小刊ID');
+	        }
+
+	        if (!$buy['name']) {
+	            $buy['name'] = '购买' . $buy['num'] . '本';
+	        }
+
+	        Dever::cache($key, $buy);
+        }
+        return $buy;
+	}
+
+	# 根据分类获取我已订阅的小刊列表,我的订单列表,此处要修改为我的订单列表 getMyAll待增加
+    public function getMyList()
+    {
+        if (!$this->data['uid']) {
+            Dever::alert('错误的用户信息');
+        }
+
+        $cate = Dever::input('system', -1);
+
+        if (!$cate) {
+            Dever::alert('错误的信息');
+        }
+
+        # 我的订单列表
+        $where = array();
+        $where['uid'] = $this->data['uid'];
+        if ($cate > 0) {
+            $where['cate_id'] = $cate;
+        }
+        
+        $where['status'] = 2;
+        $where['type'] = 3;
+
+        $this->data['order'] = Dever::db('act/order')->getMyAll($where);
+
+        if ($this->data['order']) {
+            foreach ($this->data['order'] as $k => $v) {
+                $this->data['order'][$k]['cdate'] = date('Y年m月d日 H:i:s', $v['cdate']);
+                $name = explode('-', $v['name']);
+                $this->data['order'][$k]['name'] = $name[0];
+
+                if (isset($v['buy_num']) && $v['buy_num'] <= 0 && $v['buy_id']) {
+                    $buy = $this->getBuy($v['buy_id']);
+                    $this->data['order'][$k]['buy_num'] = $buy['num']; 
+                }
+
+                if (!$v['order_id']) {
+                    $this->data['order'][$k]['order_id'] = $v['id'];
+                }
+            }
+        }
+
+        return $this->data;
+    }
+
+    # 根据订单id获取我的兑换码列表
+    public function getMyCodeList()
+    {
+        if (!$this->data['uid']) {
+            Dever::alert('错误的用户信息');
+        }
+
+        $order_id = Dever::input('order_id');
+
+        if (!$order_id) {
+            Dever::alert('错误的信息');
+        }
+
+        if (strstr($order_id, 'D')) {
+            $temp = explode('D', $order_id);
+            $order_id = $temp[1];
+        }
+
+        # 我的订单列表
+        $order = $this->getOrder($order_id);
+
+        $where = array();
+        $where['create_uid'] = $this->data['uid'];
+        $where['order_id'] = $order['order_id'];
+        $where['type'] = 4;
+
+        Dever::setInput('set_product_id', $order['product_id']);
+
+        $this->data['code'] = Dever::db('code/info')->getMyAll($where);
+
+        if ($this->data['code']) {
+            foreach ($this->data['code'] as $k => $v) {
+                $this->data['code'][$k]['code'] = Dever::load('code/lib/core')->view($v['id'], $v['create_uid']);
+            }
+        }
+
+        return $this->data;
+    }
+
+    # 购买 改成直接购买兑换码
+    public function pay()
+    {
+        if (!$this->data['uid']) {
+            Dever::alert('错误的用户信息');
+        }
+
+        $journal = $this->getJournal();
+        $buy = $this->getBuy();
+        $star = $this->getStar();
+
+        $user = Dever::db('passport/user')->one($this->data['uid']);
+        $wechat = Dever::db('passport/wechat')->one(array('uid' => $this->data['uid'], 'type' => 1, 'system_id' => $journal['cate_id']));
+
+        $source_type = Dever::input('source_type');
+
+        if ($source_type == 'ios') {
+            $method = 'apple';
+            $order_data['system'] = 3;
+            $account_id = 3;
+            # 使用苹果内购支付
+            $receipt = Dever::input('receipt');
+            if (!$receipt) {
+                Dever::alert('苹果内购支付失败,没有receipt参数');
+            }
+        } elseif ($source_type == 'android') {
+            $method = 'app';
+            $order_data['system'] = 4;
+            $account_id = 3;
+        } else {
+            $method = 'applet';
+            $order_data['system'] = 1;
+            $account_id = 1;
+            # 根据cate_id走不同的支付id,暂时不需要
+            if ($journal['cate_id'] == 2) {
+                $account_id = 4;
+            } elseif ($journal['cate_id'] == 3) {
+                $account_id = 5;
+            }
+            //$account_id = $cate['pay_id'];
+        }
+
+        //$order_id = $this->createOrder('JP');
+        $order_data['cate_id'] = $journal['cate_id'];
+        //$order_data['order_id'] = $order_id;
+        $order_data['product_id'] = $journal['id'];
+        if ($star) {
+            $order_data['star_id'] = $star['id'];
+        }
+        
+        $order_data['buy_id'] = $buy['id'];
+        $order_data['uid'] = $this->data['uid']; 
+        $order_data['type'] = 3;
+        $order_data['status'] = 1;
+
+        $order_data['name'] = $journal['name'] . '-' . $buy['name'];
+        $order_data['buy_num'] = $buy['num'];
+
+        if (isset($buy['price']) && $buy['price'] && $buy['price'] > 0) {
+            $order_data['cash'] = $buy['price'];
+        } else {
+            $order_data['cash'] = $journal['cash'] * $order_data['buy_num'];
+        }
+
+        $source = Dever::input('source');
+        $system = Dever::input('system', 1);
+        if (!$source) {
+            $source = $system;
+        }
+        if ($source) {
+            $order_data['source'] = $source;
+        }
+        $seller = Dever::input('seller');
+        if ($seller) {
+            $order_data['seller_id'] = $seller;
+        }
+
+        $id = Dever::db('act/order_temp')->insert($order_data);
+
+        if (!$id) {
+            Dever::alert('支付失败');
+        }
+
+        $order_id = $this->createOrderId($order_data, $id);
+
+        //$param参数
+        $param = array
+        (
+            'account_id' => $account_id,
+            'project_id' => 3,
+            'uid' => $this->data['uid'],
+            'username' => $user['username'],
+            'name' => $order_data['name'],
+            'cash' => $order_data['cash'],
+            //'cash' => '0.01',
+            'openid' => $wechat['openid'],
+            'product_id' => $journal['id'] . '-' . $buy['id'],
+            'order_id' => $order_id,
+        );
+
+        if ($method == 'apple') {
+            $param['other'] = $receipt;
+        }
+
+        $this->data['pay'] = Dever::load('pay/api.' . $method, $param);
+
+        if ($order_data['system'] == 1) {
+            if (isset($this->data['pay']['prepay_id'])) {
+                Dever::load('act/lib/form')->submit($this->data['uid'], $this->data['pay']['prepay_id'], 2, $journal['cate_id']);
+            } else {
+                Dever::alert('支付失败');
+            }
+        }
+
+        $this->data['order_id'] = $order_id;
+        //$this->data['order_id'] = $id;
+
+        return $this->data;
+    }
+
+    # 开始兑换
+    public function checkCode()
+    {
+        return 'ok';
+    }
+
+    # 开始兑换
+    public function code()
+    {
+        if (!$this->data['uid']) {
+            Dever::alert('错误的用户信息');
+        }
+
+        $code = Dever::input('code');
+
+        if ($code) {
+            $code = trim($code);
+            $code = str_replace("\n", '', $code);
+
+            $journal_id = Dever::input('journal_id');
+            if (strstr($journal_id, 'preview_')) {
+                $journal_id = str_replace('preview_', '', $journal_id);
+            }
+
+            if (!$journal_id) {
+                Dever::alert('请传入正确的小刊ID');
+            }
+
+            if (strpos($code, 'M') === 0) {
+                Dever::setInput('set_product_id', $journal_id);
+                $code = substr($code, 1);
+                $code = Dever::uid($code, 'decode');
+                $code = $code / 10000000;
+                $info = Dever::db('code/info')->one($code);
+
+                /*
+                $check = true;
+                $uid = substr($code, 1, 4);
+                $code = substr($code, 1);
+                
+                
+                $info = Dever::db('code/info')->one($code);
+
+                if (!$info) {
+                    $check = false;
+                    $code = str_replace('M', '', $code);
+                    $info = Dever::db('code/info')->one($code);
+                }
+
+                if ($check) {
+                    $uid = Dever::uid($uid, 'decode');
+                    if ($info && $info['create_uid'] != $uid) {
+                        Dever::alert('请正确使用小刊兑换码');
+                    }
+                }
+                */
+                
+            } else {
+                $info = Dever::db('code/info')->one(array('code' => $code));
+            }
+
+            if (!$info) {
+                Dever::alert('兑换码不存在');
+            }
+
+            if ($info['type'] == 3) {
+                Dever::alert('兑换码已被使用');
+            }
+
+            if ($info['state'] != 1) {
+                Dever::alert('兑换码已作废');
+            }
+
+            if ($info['type'] == 4) {
+                Dever::alert('兑换码已作废');
+            }
+
+            /*
+            if ($info['type'] == 2 && $this->data['uid'] != $info['uid']) {
+                //Dever::alert('兑换码已被领取');
+            }
+            */
+
+            if ($info['product_id'] > 0 && $info['product_id'] != $journal_id) {
+                Dever::alert('请正确使用小刊兑换码');
+            }
+
+            if (isset($info['order_id']) && $info['order_id']) {
+                $order_info = $this->getOrder($info['order_id']);
+                if (!$order_info) {
+                    Dever::alert('您要使用的兑换码还未支付');
+                }
+
+                if ($order_info && $order_info['status'] != 2) {
+                    Dever::alert('您要使用的兑换码还未支付');
+                }
+            } else {
+                # 通用兑换码 只加本数
+                if ($info['product_num'] > 0) {
+                    # 增加本数 用通用码的人不多,所以直接跨库查询吧
+                    $journal = Dever::db('journal/info')->one($journal_id);
+                    if ($journal) {
+                        $num = $journal['num_up'] + $info['product_num'];
+                        Dever::db('journal/info')->update(array('where_id' => $journal_id, 'num_up' => $num));
+                    }
+                }
+            }
+
+            Dever::db('code/info')->update(array('where_id' => $info['id'], 'type' => 3, 'uid' => $this->data['uid'], 'ldate' => time()));
+
+            # 订阅
+            Dever::load('act/lib/subscribe')->submit($this->data['uid'], $journal_id, 2);
+
+        } else {
+            Dever::alert('请输入正确的兑换码');
+        }
+
+        return 'ok';
+    }
+
+    public function createOrder($prefix = 'JP')
+    {
+        $order = Dever::order($prefix);
+
+        //$order = Dever::rand(2, 2) . Dever::rand(6, 0);
+
+        $info = Dever::db('journal/order')->one(array('order_id' => $order));
+
+        if ($info) {
+            return $this->createOrder($prefix);
+        }
+
+        return $order;
+    }
+
+    public function createOrderId($data, $id)
+    {
+        # O 是 支付系统里的project_id的标识符,带有此项标识的均为无需支付系统进行订单记录
+        $order_id = 'JMO3OC' . $data['cate_id'] . 'P' . $data['product_id'] . 'B' . $data['buy_id'] . 'U' . $data['uid'] . 'D' . $id;
+
+        //$order_id = 'JM_' . $id;
+
+        return $order_id;
+    }
+
+    public function getOrderId($id)
+    {
+        if (is_numeric($id)) {
+            $info = Dever::db('act/order')->one($id);
+            if ($info['order_id']) {
+                return $info['order_id'] . '/' . $id;
+            }
+
+            return $this->createOrderId($info, $id) . '/' . $id;
+        }
+        return '';
+    }
+
+    public function getOrderTempId($id)
+    {
+        $info = Dever::db('act/order')->one($id);
+        return $this->createOrderId($info, $id) . '/' . $id;
+    }
+
+    public function getOrder($order_id)
+    {
+        if (!is_numeric($order_id)) {
+            $order = Dever::db('act/order')->one(array('order_id' => $order_id));
+        } else {
+            $order = Dever::db('act/order')->one($order_id);
+            $order['order_id'] = $order['id'];
+        }
+
+        return $order;
+    }
+}

+ 2 - 0
app/boot.php

@@ -0,0 +1,2 @@
+<?php
+include(dirname(__FILE__) . DIRECTORY_SEPARATOR . '../boot.php');

+ 112 - 0
app/code/database/config.php

@@ -0,0 +1,112 @@
+<?php
+$seller = function()
+{
+	return Dever::db('code/seller')->state();
+};
+return array
+(
+	# 表名
+	'name' => 'config',
+	# 显示给用户看的名称
+	'lang' => '新增兑换码',
+	'order' => 1,
+	'menu' => false,
+	'end' => array
+	(
+		'update' => 'code/lib/manage.create',
+		'insert' => 'code/lib/manage.create',
+	),
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '系统ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'value'		=> Dever::input('where_id'),
+		),
+
+		'product'     => array
+        (
+            'type'      => 'varchar-200',
+            'name'      => '选择小刊',
+            'default'   => '',
+            'desc'      => '选择小刊',
+            'search'	=> 'linkage',
+			'update'	=> 'linkage',//多级联动 用于搜索
+			'option'	=> Dever::url('lib/manage.search_cate_journal', 'journal'),
+        ),
+		
+		'product_id'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '选择小刊',
+            'default'   => '',
+            'desc'      => '选择小刊',
+            'match'     => 'option',
+            //'update'    => 'select',
+            //'update_search' => 'journal/lib/manage.search_journal',
+        ),
+
+        'seller_id'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '选择销售商',
+            'default'   => '1',
+            'desc'      => '选择销售商',
+            'match'     => 'option',
+            'update'    => 'select',
+          	'option'	=> $seller,
+        ),
+		
+		'num'		=> array
+		(
+			'type' 		=> 'varchar-32',
+			'name' 		=> '兑换码数量',
+			'default' 	=> '',
+			'desc' 		=> '请输入兑换码数量',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'value'		=> '',
+		),
+
+		'product_num'		=> array
+		(
+			'type' 		=> 'varchar-32',
+			'name' 		=> '兑换本数-填写0则不增加售出本数',
+			'default' 	=> '0',
+			'desc' 		=> '兑换本数',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+		),
+
+		'score'         => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => '增加积分数-直接填写积分数,设置之后,积分规则里的设置及小刊兑换码中的设置将失效,当设置为0时,直接使用积分规则中的设置。当设置为负1时,不增加积分数',
+            'default'   => '',
+            'desc'      => '增加积分数',
+            'match'     => 'is_string',
+            'update'    => 'text',
+        ),
+
+		'cdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '录入时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+			# 只有insert时才生效
+			'insert'	=> true,
+		),
+	),
+
+	'manage' => array
+	(
+		# 后台管理不要列表页
+		'list' => 'update',
+	),
+);

+ 359 - 0
app/code/database/info.php

@@ -0,0 +1,359 @@
+<?php
+
+# 定义几个常用的选项
+$type = array
+(
+	1 => '未领取',
+	2 => '已领取',
+	3 => '已使用',
+	4 => '已作废',
+);
+
+$status = array
+(
+	1 => '不可用',
+	2 => '可用',
+);
+
+$product = function()
+{
+	return Dever::load('journal/api.data');
+};
+
+$seller = function()
+{
+	return Dever::db('code/seller')->state();
+};
+
+# 获取小刊分类权限
+$auth = Dever::tops();
+$cate = function() use ($auth)
+{
+    $array = array();
+    if ($auth) {
+        $info = Dever::db('journal/cate')->getIds(array('ids' => $auth));
+    } else {
+        $info = Dever::db('journal/cate')->state();
+    }
+    if($info)
+    {
+        $array += $info;
+    }
+    return $array;
+};
+
+$name = 'info';
+$create = Dever::config('database')->create;
+$data = Dever::input('search_linkage_product');
+if (isset($data[1])) {
+	$product_id = $data[1];
+} else {
+	$product_id = Dever::input('set_product_id');
+}
+
+if ($product_id && $product_id > 0) {
+	$name .= '_' . $product_id;
+	$create = false;
+}
+
+return array
+(
+	# 表名
+	'name' => $name,
+	# 显示给用户看的名称
+	'lang' => '兑换码列表',
+	'menu' => 'stat',
+	'order' => 1,
+	'create' => $create,
+	'auto' => 10000000,
+	# 数据结构
+	'struct' => array
+	(
+	
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'search'	=> 'order',
+			'order'		=> 'desc',
+			//'list'		=> true,
+		),
+
+		'create_uid'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '创建人',
+			'default' 	=> '-1',
+			'desc' 		=> '创建人',
+			'match' 	=> 'is_numeric',
+			'search'    => array
+            (
+                'api' => 'passport/user-all',
+                'col' => 'username',
+                'result' => 'id',
+            ),
+			//'list'		=> 'Dever::load("code/lib/manage.showUserInfo", "{uid}", "{ldate}")',
+		),
+
+		'product'     => array
+        (
+            'name'      => '小刊',
+            'default'   => '',
+            'desc'      => '小刊',
+            'search'	=> 'linkage',
+            'search_col' => 'cate_id,product_id',
+			'option'	=> Dever::url('lib/manage.search_cate_journal', 'journal'),
+        ),
+
+		'cate_id'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '小刊分类',
+            'default'   => '1',
+            'desc'      => '小刊分类',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => $cate,
+            //'search'    => 'select',
+            'list'      => true,
+        ),
+
+		'product_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '小刊',
+			'default' 	=> '',
+			'desc' 		=> '小刊',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'select',
+			'option'	=> $product,
+			//'search'	=> 'select',
+			'list'		=> '{product_id} > 0 ? Dever::load("journal/info-one#name", {product_id}) : "通用"',
+		),
+
+		'code'		=> array
+		(
+			'type' 		=> 'varchar-32',
+			'name' 		=> '兑换码',
+			'default' 	=> '',
+			'desc' 		=> '兑换码',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> 'Dever::load("code/lib/manage.showCode", "{id}")',
+			//'list'		=> true,
+		),
+
+		'score'         => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => '增加积分数-直接填写积分数,设置之后,积分规则里的设置及小刊兑换码中的设置将失效,当设置为0时,直接使用积分规则中的设置。当设置为-1时,不增加积分数',
+            'default'   => '',
+            'desc'      => '增加积分数',
+            'match'     => 'is_string',
+            //'update'    => 'text',
+        ),
+
+		'product_num'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '兑换本数',
+            'default'   => '0',
+            'desc'      => '兑换本数',
+            'match'     => 'option',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+		'type'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '使用状态',
+			'default' 	=> '1',
+			'desc' 		=> '使用状态',
+			'match' 	=> 'is_numeric',
+			'option' 	=> $type,
+			'search'	=> 'select',
+			'update'	=> 'select',
+			'list'		=> true,
+			'mul'		=> array(1 => '恢复使用', 4 => '已作废'),
+		),
+
+		'seller_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '销售商',
+			'default' 	=> '1',
+			'desc' 		=> '销售商',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'select',
+			'option'	=> $seller,
+			'search'	=> 'select',
+			'list'		=> true,
+		),
+
+		'uid'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '用户信息',
+			'default' 	=> '0',
+			'desc' 		=> '用户信息',
+			'match' 	=> 'is_numeric',
+			'list'		=> 'Dever::load("code/lib/manage.showUserInfo", "{create_uid}", "{uid}", "{ldate}", "{type}")',
+		),
+
+		'order_id'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '订单表ID',
+            'default'   => '',
+            'desc'      => '订单表ID',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'	=> 'fulltext',
+            'list'        => true,
+            //'list'        => '"{order_id}" ? "{order_id}" : "{code}"',
+        ), 
+
+		'state'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '状态',
+			'default' 	=> '1',
+			'desc' 		=> '请选择状态',
+			'match' 	=> 'is_numeric',
+		),
+
+		'ldate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '领取时间',
+			'match' 	=> 'option',
+			'default' 	=> '',
+			'desc' 		=> '',
+			//'search'	=> 'date',
+		),
+		
+		'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})',
+		),
+	),
+
+	//'top' => Dever::config('base')->top,
+
+    # 增加这个,为了给当前的list增加一个option
+    'top_option' => array
+    (
+        'value' => $auth,
+        'col' => 'cate_id',
+    ),
+
+    # 更新表结构
+	'alter' => array
+	(
+		2 => array
+		(
+			array('update', 'product_num', 'product_num', 'varchar-32 0 兑换本数'),
+			//array('add', 'config', 'config', 'int-11 1 配置'),
+		),
+		'version' => 2,
+	),
+
+	# 索引
+	'index' => array
+	(
+		4 => array
+		(
+			'order_id' => 'order_id',
+		),
+		
+		# 版本号 更改版本号会更新当前表的索引
+		'version' => 4,
+	),
+
+	'manage' => array
+	(
+		'excel'	=> true,
+		'delete' => false,
+		'edit' => false,
+		'insert' => false,
+		'mul' => '{type} == 1 || {type} == 4',
+
+		# 自定义快捷新增和编辑
+        'button' => array
+        (
+            '新增兑换码' => array('fast', 1, 'config&where_id=1'),
+            '销售商列表' => array('list', 'seller&project=code&oper_parent=info&oper_project=code'),
+            '新增销售商' => array('fast', 1, 'seller'),
+        ),
+
+        'list_button' => array
+		(
+			'oper' => array('作废', 'code/lib/manage.drop?id={id}&journal_id={product_id}&code={code}', '{type} == 1'),
+
+			'oper2' => array('恢复使用', 'code/lib/manage.recovery?id={id}&journal_id={product_id}&code={code}', '{type} == 4'),
+		),
+	),
+
+	'request' => array
+    (
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'cate_id' => 'yes',
+                'create_uid' => 'yes',
+                'order_id' => 'yes',
+                'type' => array('yes', '!='),
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('type' => 'asc', 'id' => 'desc'),
+            'page' => array(30, 'list'),
+            'col' => '*',
+        ),
+
+        'getMyAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'order_id' => 'yes',
+                'create_uid' => 'yes',
+                'type' => array('yes', '!='),
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('type' => 'asc', 'id' => 'desc'),
+            'page' => array(10, 'list'),
+            'col' => 'id,code,type,create_uid',
+        ),
+
+        'getData' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'order_id' => 'yes',
+                'type' => array('yes', '!='),
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('type' => 'asc', 'id' => 'desc'),
+            'col' => '*',
+        ),
+    )
+);

+ 69 - 0
app/code/database/seller.php

@@ -0,0 +1,69 @@
+<?php
+
+return array
+(
+	# 表名
+	'name' => 'seller',
+	# 显示给用户看的名称
+	'lang' => '新增销售商',
+	'order' => 1,
+	'menu' => false,
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'list'		=> true,
+		),
+		
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-80',
+			'name' 		=> '销售商名称',
+			'default' 	=> '',
+			'desc' 		=> '销售商名称',
+			'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时才生效
+			'insert'	=> true,
+		),
+	),
+
+	'manage' => array
+	(
+		
+	),
+
+	# 默认值
+	'default' => array
+	(
+		'col' => 'name,state,cdate',
+		'value' => array
+		(
+			'"官方",1,' . time(),
+		),
+	),
+);

+ 8 - 0
app/code/index.php

@@ -0,0 +1,8 @@
+<?php
+
+define('DEVER_APP_NAME', 'code');
+define('DEVER_APP_LANG', '兑换码管理');
+define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+define('DEVER_MANAGE_ORDER', 99);
+define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-credit-card layui-icon-read');
+include(DEVER_APP_PATH . '../boot.php');

+ 138 - 0
app/code/lib/Core.php

@@ -0,0 +1,138 @@
+<?php
+
+namespace Code\Lib;
+
+use Dever;
+
+class Core
+{
+    public function create_test()
+    {
+        $order_id = Dever::input('order_id');
+        $order = Dever::db('act/order')->one(array('order_id' => $order_id));
+        print_r($order);
+        $code = $this->createCodeByOrder($order, -1);
+
+        return $code;
+    }
+	public function createCodeByOrder($order, $num = 0)
+	{
+		$code = '';
+        if ($order['type'] == 3 && !$order['code']) {
+            if (!$order['order_id']) {
+                $order['order_id'] = $order['id'];
+            }
+        	Dever::setInput('set_product_id', $order['product_id']);
+            # 购买兑换码
+            $product_num = 1;
+            $code_num = 1;
+            if ($order['buy_id'] > 0) {
+                $buy = Dever::load('act/order')->getBuy($order['buy_id']);
+                $product_num = $buy['num'];
+                $code_num = $buy['code'];
+            }
+            
+            # 检查之前有多少个兑换码,防止多发
+            $code_where['order_id'] = $order['order_id'];
+        	$total = Dever::db('code/info')->total($code_where);
+        	if ($total && $total > 0) {
+        		if ($code_num > $total) {
+        			$code_num = $code_num - $total;
+        		} else {
+        			$one = Dever::db('code/info')->one($code_where);
+        			return $one['code'];
+        		}
+        	}
+
+            if ($code_num > 1) {
+                $product_num = intval($product_num/$code_num);
+
+                if ($num < 0) {
+                    # 订阅
+                    $state = Dever::load('act/lib/subscribe')->submit($order['uid'], $order['product_id'], 1);
+                    if ($state) {
+                        $code = $this->createCode($order['cate_id'] . ',' . $order['product_id'], $order['cate_id'], $order['product_id'], $order['seller_id'], $product_num, $order['uid'], $order['order_id'], 0, 3, 1);
+                    } else {
+                        $num = 0;
+                    }
+                	
+                }
+                $result = $this->createCode($order['cate_id'] . ',' . $order['product_id'], $order['cate_id'], $order['product_id'], $order['seller_id'], $product_num, $order['uid'], $order['order_id'], 0, 1, $code_num + $num);
+                if ($num == 0) {
+                    $code = $result;
+                }
+            } else {
+                # 订阅
+                $state = false;
+                if ($num < 0) {
+                    $state = Dever::load('act/lib/subscribe')->submit($order['uid'], $order['product_id'], 1);
+                }
+                
+                if ($state) {
+                    $code = $this->createCode($order['cate_id'] . ',' . $order['product_id'], $order['cate_id'], $order['product_id'], $order['seller_id'], $product_num, $order['uid'], $order['order_id'], 0, 3);
+                } else {
+                    $code = $this->createCode($order['cate_id'] . ',' . $order['product_id'], $order['cate_id'], $order['product_id'], $order['seller_id'], $product_num, $order['uid'], $order['order_id'], 0, 1);
+                }
+            }
+        }
+
+        return $code;
+	}
+
+	public function createCode($product, $cate_id, $product_id, $seller_id, $product_num = 0, $create_uid = -1, $order_id = false, $score = 0, $type = 1, $num = 1)
+	{
+        if ($product_id > 0) {
+            Dever::setInput('set_product_id', $product_id);
+        }
+        
+		//$data['product'] = $product;
+		$data['cate_id'] = $cate_id;
+		$data['product_id'] = $product_id;
+		$data['seller_id'] = $seller_id;
+		$data['product_num'] = $product_num;
+		
+		$data['type'] = $type;
+		if ($order_id) {
+			$data['order_id'] = $order_id;
+		}
+		if ($create_uid > 0) {
+			$data['create_uid'] = $create_uid;
+            if ($type == 3) {
+                $data['ldate'] = time();
+                $data['uid'] = $create_uid;
+            }
+		}
+        $data['score'] = $score;
+
+        $db = Dever::db('code/info');
+        if ($product_id > 0) {
+            $code = $db->insert($data, $num);
+            $code = $this->view($code, true);
+            return $code;
+        } else {
+            for ($i = 0; $i < $num; $i++) {
+                $data['i'] = $i;
+                $id = $db->insert($data);
+                if ($id) {
+                    $code = $this->view($id, false);
+                    $db->update(array('code' => $code, 'where_id' => $id));
+                }
+            }
+
+            return $code;
+        }
+	}
+
+    public function view($id, $state)
+    {
+        if ($state) {
+            $code = Dever::uid($id * 10000000);
+            $code = 'M' . $code;
+        } else {
+            $code = Dever::rand(4);
+            $code = 'T' . $code . $id;
+        }
+        
+        return $code;
+    }
+}

+ 122 - 0
app/code/lib/Manage.php

@@ -0,0 +1,122 @@
+<?php
+
+namespace Code\Lib;
+
+use Dever;
+
+class Manage
+{
+	public function showCode($id)
+	{
+		$info = Dever::db('code/info')->one($id);
+
+		if ($info['code']) {
+			return $info['code'];
+		}
+		
+		/*
+		if ($info['create_uid'] > 0) {
+			return Dever::load('code/lib/core')->view($info['id'], true);
+			return '用户创建';
+		}
+		*/
+
+		if ($info['product_id'] > 0) {
+			return Dever::load('code/lib/core')->view($info['id'], true);
+		}
+
+		return 'T' . $id;
+	}
+
+	/**
+	 * 显示用户信息
+	 *
+	 * @return mixed
+	 */
+	public function showUserInfo($create_uid, $uid, $ldate = false, $type = 1)
+	{
+		$table = array();
+		if ($create_uid && $create_uid > 0) {
+			$user = Dever::load('passport/user-one', $create_uid);
+			$table['创建人'] = $user['username'] . '('.$create_uid.')';
+		}
+		if ($type == 3 && $uid && $uid > 0) {
+			$user = Dever::load('passport/user-one', $uid);
+			if ($user) {
+				$table['领取人'] = $user['username'] . '('.$uid.')';
+				$table['手机号'] = $user['mobile'];
+				$table['领取时间'] = date('Y-m-d H:i:s', $ldate);
+			}
+		}
+
+		return Dever::table($table);
+	}
+
+    /**
+	 * 创建兑换码
+	 *
+	 * @return mixed
+	 */
+	public function create($id, $name, $param)
+	{
+		$code = Dever::param('num', $param);
+		$score = Dever::param('score', $param);
+		$product_num = Dever::param('product_num', $param);
+		$product = Dever::param('product', $param);
+		//$product_id = Dever::param('product_id', $param);
+		$seller_id = Dever::param('seller_id', $param);
+
+		$cate_id = $product_id = 0;
+		if ($product && isset($product[0])) {
+			$cate_id = $product[0];
+			if (isset($product[1])) {
+				$product_id = $product[1];
+			}
+			
+			$product = implode(',', $product);
+		}
+
+		if ($cate_id <= 0){
+			Dever::alert('生成失败,请选择分类');
+		}
+
+
+		//$total = Dever::db('code/info')->total(array('product_id' => $product_id, 'type' => 1));
+		$total = 0;
+		$core = Dever::load('code/lib/core');
+		if ($code > 0 && $code > $total) {
+			$num = $code - $total;
+
+			$core->createCode($product, $cate_id, $product_id, $seller_id, $product_num, -1, false, $score, 1, $num);
+		}
+	}
+
+	/**
+	 * 作废
+	 *
+	 * @return mixed
+	 */
+	public function drop_api($id, $journal_id, $code)
+	{
+		if (!$code && $journal_id > 0) {
+			Dever::setInput('set_product_id', $journal_id);
+		}
+		
+		$update['where_id'] = $id;
+		$update['type'] = 4;
+		Dever::db('code/info')->update($update);
+		return 'ok';
+	}
+
+	public function recovery_api($id, $journal_id, $code)
+	{
+		if (!$code && $journal_id > 0) {
+			Dever::setInput('set_product_id', $journal_id);
+		}
+
+		$update['where_id'] = $id;
+		$update['type'] = 1;
+		Dever::db('code/info')->update($update);
+		return 'ok';
+	}
+}

+ 137 - 0
app/content/database/applet.php

@@ -0,0 +1,137 @@
+<?php
+
+return array
+(
+    # 表名
+    'name' => 'applet',
+    # 显示给用户看的名称
+    'lang' => '外链小程序管理',
+    # 后台菜单排序
+    'order' => 1,
+    'menu' => false,
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'list'      => true,
+            'order'     => 'desc',
+        ),
+        
+        'name'      => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => '小程序名称',
+            'default'   => '',
+            'desc'      => '小程序名称',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'appid'      => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => '小程序appid',
+            'default'   => '',
+            'desc'      => '小程序appid',
+            'match'     => 'option',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'link'      => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '小程序跳转链接-可以为空,为空则不跳转',
+            'default'   => '',
+            'desc'      => '小程序名称',
+            'match'     => 'option',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+        
+        '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})',
+        ),
+    ),
+
+    'manage' => array
+    (
+        
+    ),
+
+    'request' => array
+    (
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'ids' => array('yes-id', 'in'),
+                'name' => array('yes', 'like'),
+                'id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('reorder' => 'desc', 'id' => 'desc'),
+            'limit' => '0,1000',
+            'col' => 'name as name, id, id as value, "" as selected, "" as disabled|id',
+        ),
+
+        'search' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'ids' => array('yes-id', 'in'),
+                'name' => array('yes', 'like'),
+                'id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('reorder' => 'desc', 'id' => 'desc'),
+            'limit' => '0,1000',
+            'col' => 'name as name, id, id as value, "" as selected, "" as disabled|id',
+        ),
+    ),
+);

+ 114 - 0
app/content/database/page.php

@@ -0,0 +1,114 @@
+<?php
+
+
+$config = array
+(
+    # 表名
+    'name' => 'page',
+    # 显示给用户看的名称
+    'lang' => '单页管理',
+    # 后台菜单排序
+    'order' => 2,
+    'check' => 'key',
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            //'search'    => 'order',
+            //'list'      => true,
+            'order'     => 'desc',
+        ),
+        
+        'name'      => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => '标题',
+            'default'   => '',
+            'desc'      => '标题',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'key'      => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => '标识',
+            'default'   => '',
+            'desc'      => '标识',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            //'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'content'      => array
+        (
+            'type'      => 'text-255',
+            'name'      => '内容',
+            'default'   => '',
+            'desc'      => '内容',
+            'match'     => 'is_string',
+            'update'    => 'editor',
+            'list_name'		=> '链接',
+            'list'      => 'Dever::load("content/lib/page.link", {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' => array
+    (
+        
+    )
+);
+# 获取小刊分类权限
+$auth = Dever::tops();
+
+if ($auth && $auth != 1) {
+    $config['request']['list'] = array
+    (
+        # 匹配的正则或函数 选填项
+        'option' => array
+        (
+            'name' => array('yes', 'like'),
+            'key' => array('_' . $auth, 'like'),
+        ),
+        'type' => 'all',
+        'order' => array('id' => 'desc'),
+        'page' => array(20, 'list'),
+        'col' => '*|id',
+    );
+}
+
+return $config;

+ 136 - 0
app/content/database/product.php

@@ -0,0 +1,136 @@
+<?php
+
+return array
+(
+    # 表名
+    'name' => 'product',
+    # 显示给用户看的名称
+    'lang' => '产品管理',
+    # 后台菜单排序
+    'order' => 1,
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'list'      => true,
+            'order'     => 'desc',
+        ),
+        
+        'name'      => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => '名称',
+            'default'   => '',
+            'desc'      => '名称',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'appid'      => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => '小程序appid',
+            'default'   => '',
+            'desc'      => '小程序appid',
+            'match'     => 'option',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'link'      => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '小程序跳转链接-可以为空,为空则不跳转',
+            'default'   => '',
+            'desc'      => '小程序名称',
+            'match'     => 'option',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+        
+        '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})',
+        ),
+    ),
+
+    'manage' => array
+    (
+        
+    ),
+
+    'request' => array
+    (
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'ids' => array('yes-id', 'in'),
+                'name' => array('yes', 'like'),
+                'id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('reorder' => 'desc', 'id' => 'desc'),
+            'limit' => '0,1000',
+            'col' => 'name as name, id, id as value, "" as selected, "" as disabled|id',
+        ),
+
+        'search' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'ids' => array('yes-id', 'in'),
+                'name' => array('yes', 'like'),
+                'id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('reorder' => 'desc', 'id' => 'desc'),
+            'limit' => '0,1000',
+            'col' => 'name as name, id, id as value, "" as selected, "" as disabled|id',
+        ),
+    ),
+);

+ 8 - 0
app/content/index.php

@@ -0,0 +1,8 @@
+<?php
+
+define('DEVER_APP_NAME', 'content');
+define('DEVER_APP_LANG', '内容管理');
+define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+define('DEVER_MANAGE_ORDER', 200);
+define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-tower layui-icon-tabs');
+include(DEVER_APP_PATH . '../boot.php');

+ 61 - 0
app/content/lib/Applet.php

@@ -0,0 +1,61 @@
+<?php
+
+namespace Content\Lib;
+
+use Dever;
+
+class Applet
+{
+    # 更新数据
+    public function update_api()
+    {
+        $value = Dever::input('value');
+        if ($value) {
+            $value = explode('||', $value);
+        }
+
+        $pic = $path = $link = $applet_value = '';
+
+        if (isset($value[0])) {
+            $pic = $value[0];
+        }
+
+        if (isset($value[2])) {
+            $path = $value[2];
+        }
+
+        if (isset($value[3])) {
+            $link = $value[3];
+        }
+
+        if (isset($value[1])) {
+            $applet_value = $value[1];
+        }
+        $applet = Dever::db('content/applet')->state();
+
+        $option = '<option parent="" value="" selected>当前小程序</option>';
+        if ($applet) {
+            foreach ($applet as $k => $v) {
+                if ($applet_value == $v['appid']) {
+                    $check = 'selected';
+                } else {
+                    $check = '';
+                }
+                $option .= '<option parent="" value="'.$v['appid'].'" '.$check.'>'.$v['name'].'</option>';
+            }
+        }
+        $html = '<div class="layui-card-body">';
+
+        $html .= '<div class="layui-form-item "><div classs="layui-col-lg6"><div><label style="font-size:14px;font-weight:bold;" class="">选择小程序</label></div><div><select lay-ignore="" class="update_value form-control layui-input layui-select   validate[required]" name="editor_applet_id" id="editor_applet_id">'.$option.'</select></div></div></div>';
+
+        $html .= '<div class="layui-form-item "><div classs="layui-col-lg6"><div><label style="font-size:14px;font-weight:bold;" class="">路径</label></div><div><input type="text" class="update_value form-control layui-input validate[required]" value="'.$path.'" name="editor_applet_path" id="editor_applet_path" autocomplete="new-password" placeholder=""></div></div></div>';
+
+        $html .= '<div class="layui-form-item "><div classs="layui-col-lg6"><div><label style="font-size:14px;font-weight:bold;" class="">链接-为空则使用小程序里的链接</label></div><div><input type="text" class="update_value form-control layui-input validate[required]" value="'.$link.'" name="editor_applet_link" id="editor_applet_link" autocomplete="new-password" placeholder=""></div></div></div>';
+
+        $html .= '<div class="layui-form-item "><div classs="layui-col-lg6"><div><label style="font-size:14px;font-weight:bold;" class="">封面图<span style="font-size:12px;font-weight:normal;font-color:#bababa;margin-left:5px;">[图片宽度750px高度自适应,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式]</span></label></div><div><input type="button" style="width:100px;display:inline;padding-left:0px;" class="form-control layui-input image_upload" v="editor_applet_pic" id="file_applet_pic" key="1" value="本地上传" autocomplete="new-password">
+        <div style="margin-top:5px;">
+        <input type="text" class="update_value form-control layui-input " name="editor_applet_pic" id="editor_applet_pic" value="'.$pic.'" autocomplete="new-password"></div></div></div></div>';
+        $html .= '</div>';
+        return $html;
+    }
+}

+ 223 - 0
app/content/lib/Article.php

@@ -0,0 +1,223 @@
+<?php
+
+namespace Content\Lib;
+
+use Dever;
+
+class Article
+{
+    # 根据文章id 获取文章信息
+    public function get($data, $uid = false)
+    {
+        if (!is_array($data)) {
+            $data = Dever::db('content/article')->getOne($data);
+        }
+        
+        if (!$data) {
+            Dever::alert('错误的文章信息');
+        }
+    
+        $data = $this->getContent($data, $uid);
+
+        return $data;
+    }
+
+    public function getContent($data, $uid = false)
+    {
+        //embed
+        $data['content_array'] = array();
+
+        $data['content'] = Dever::filter($data['content']);
+
+        $content = $data['content'];
+        $replace = array();
+
+        # embed已废弃
+        if (strstr($data['content'], 'embed')) {
+            # 音频
+            preg_match_all('/<embed src="(.*?)"(.*?)\/>/i', $content, $matches);
+            if (isset($matches[1])) {
+                foreach ($matches[1] as $k => $v) {
+                    $content = str_replace($matches[0][$k], '{replace}'.count($replace).'{replace}', $content);
+
+                    if (strstr($v, '.mp4') || strstr($v, '.mov') || strstr($v, '.m3u8')) {
+                        $replace[] = array('type' => 6, 'content' => $v);
+                    } else {
+                        $replace[] = array('type' => 5, 'content' => $v);
+                    }
+                }
+            }
+        }
+
+        if (strstr($data['content'], 'data-applet')) {
+            # 小程序
+            preg_match_all('/<img(.*?)data-applet="(.*?)" \/>/', $content, $matches);
+
+            if (isset($matches[2])) {
+                foreach ($matches[2] as $k => $v) {
+                    $content = str_replace($matches[0][$k], '{replace}'.count($replace).'{replace}', $content);
+                    $temp = explode('||', $v);
+                    $pic = $temp[0];
+                    $appid = $temp[1];
+                    $path = $temp[2];
+
+                    if ($appid) {
+                        $appinfo = Dever::db('content/applet')->one(array('appid' => $appid));
+                    } else {
+                        $appinfo['name'] = '';
+                        $appinfo['link'] = '';
+                    }
+                    
+                    if (isset($temp[3]) && $temp[3]) {
+                        $appinfo['link'] = $temp[3];
+                    }
+
+                    $replace[] = array('type' => 7, 'pic_cover' => $pic, 'appid' => $appid, 'path' => $path, 'name' => $appinfo['name'], 'link' => $appinfo['link']);
+                }
+            }
+        }
+
+        if (strstr($data['content'], 'gif')) {
+            # gif
+            preg_match_all('/<img(.*?)src="(.*?)\.gif" (.*?)\/>/', $content, $matches);
+
+            if (isset($matches[2])) {
+                foreach ($matches[2] as $k => $v) {
+                    $content = str_replace($matches[0][$k], '{replace}'.count($replace).'{replace}', $content);
+                    $pic = $v;
+
+                    $replace[] = array('type' => 8, 'pic' => $pic . '.gif');
+                }
+            }
+        }
+
+        if (strstr($data['content'], 'data-file')) {
+            # 音频
+            preg_match_all('/<img src="(.*?)" style="(.*?)" data-file="(.*?)" \/>/', $content, $matches);
+
+            if (!isset($matches[1][0])) {
+                preg_match_all('/<img style="(.*?)" src="(.*?)" data-file="(.*?)" \/>/', $content, $matches);
+                $temp = array();
+                if (isset($matches[2][0])) {
+                    $temp = $matches;
+                    $matches[1] = $temp[2];
+                    unset($temp);
+                }
+            }
+
+            if (isset($matches[1])) {
+                foreach ($matches[1] as $k => $v) {
+                    if (isset($matches[3][$k])) {
+                        $content = str_replace($matches[0][$k], '{replace}'.count($replace).'{replace}', $content);
+
+                        $file = $matches[3][$k];
+                        $temp = explode('||', $file);
+                        $file = $temp[0];
+                        if (isset($temp[1])) {
+                            $name = $temp[1];
+                        } else {
+                            $name = '';
+                        }
+                        
+                        $cover = $v;
+
+                        if (strstr($v, '.mp4') || strstr($v, '.mov') || strstr($v, '.m3u8')) {
+                            $replace[] = array('type' => 6, 'content' => $file, 'cover' => $cover, 'name' => $name);
+                        } else {
+                            $replace[] = array('type' => 5, 'content' => $file, 'cover' => $cover, 'name' => $name);
+                        }
+                    }
+                }
+            }
+        }
+
+        if (strstr($data['content'], 'data-id')) {
+            # 视频+直播
+            preg_match_all('/<img(.*?)data-id="(.*?)" data-key="(.*?)" \/>/', $content, $matches);
+            
+            
+            if (!isset($matches[2][0])) {
+                preg_match_all('/<img(.*?)data-key="(.*?)" data-id="(.*?)" \/>/', $content, $matches);
+                $temp = array();
+                if (isset($matches[2][0]) && isset($matches[3][0])) {
+                    $temp = $matches;
+                    $matches[2] = $temp[3];
+                    $matches[3] = $temp[2];
+                    unset($temp);
+                }
+            }
+            
+            if (isset($matches[2][0]) && isset($matches[3][0])) {
+                foreach ($matches[2] as $k => $v) {
+                    $content = str_replace($matches[0][$k], '{replace}'.count($replace).'{replace}', $content);
+                    if ($matches[3][$k] == 'video/lib/core.vod') {
+                        $method = 'video/lib/vod';
+                        $type = 2;
+                    } else {
+                        $type = 3;
+                        $method = 'video/lib/live';
+                    }
+
+                    $info = Dever::load($method)->get($v);
+                    if (isset($info['content'])) {
+                        unset($info['content']);
+                    }
+
+                    if ($type == 3) {
+                        # 查看是否有预约
+                        if ($uid > 0) {
+                            $info['user_act']['note'] = Dever::load('act/lib/note')->get($uid, $v, $type);
+                        } else {
+                            $info['user_act']['note'] = 2;
+                        }
+                    }
+                    $replace[] = array('id' => $v, 'type' => $type, 'content' => $info);
+                }
+            }
+        }
+
+        //$data['content'] = preg_replace('/<div class="dever-drop">([\s\S]*?)<\/div>/i', '', $data['content']);
+
+        $content = explode('{replace}', $content);
+        $data['content_array'] = array();
+        //print_r($content);die;
+        foreach ($content as $k => $v) {
+            $v = trim($v);
+            if (is_numeric($v) && $v >= 0 && isset($replace[$v])) {
+                $data['content_array'][] = $replace[$v];
+            } elseif ($v) {
+                $data['content_array'][] = array
+                (
+                    'type' => 1,
+                    'content' => $v,
+                );
+            }
+        }
+
+        if (!$data['content_array']) {
+            $data['content_array'][] = array
+            (
+                'type' => 1,
+                'content' => $data['content'],
+            );
+        }
+
+        unset($data['content']);
+
+        return $data;
+    }
+
+    # 获取相关推荐
+    public function getRelation($info)
+    {
+        $where['noid'] = $info['id'];
+        $where['cate_id'] = $info['cate_id'];
+        return Dever::db('content/article')->getRelation($where);
+    }
+
+    # 增加浏览量
+    public function addView($id)
+    {
+        Dever::db('content/article')->addView($id);
+    }
+}

+ 76 - 0
app/content/lib/Author.php

@@ -0,0 +1,76 @@
+<?php
+
+namespace Content\Lib;
+
+use Dever;
+
+class Author
+{
+    # 更新数据
+    public function data($id, $name, $data)
+    {
+        $source_table = Dever::input('source_table');
+
+        $author = Dever::param('author_id', $data);
+
+        if ($author && $id > 0 && $source_table) {
+            $info = Dever::db('content/author')->one($author);
+            if (!$info) {
+                $insert['name'] = $author;
+                $author = Dever::db('content/author')->insert($insert);
+            }
+
+            Dever::db($source_table)->update(array('where_id' => $id, 'author_id' => $author));
+        }
+    }
+
+    # 搜索
+    public function search_api()
+    {
+        $keyword = Dever::input('keyword');
+
+        $yes = Dever::input('yes');
+
+        $where = array();
+
+        if ($yes) {
+            $yes = Dever::db('content/author')->getAll(array('ids' => $yes));
+        }
+        if (!$keyword) {
+            $where['limit'] = '0,50';
+            $data = Dever::db('content/author')->getAll($where);
+        } else {
+            $where['name'] = $keyword;
+            $data = Dever::db('content/author')->getAll($where);
+        }
+
+        $insert = array();
+        if (!$data && $keyword) {
+            $insert[0]['name'] = $keyword . '[新增]';
+            $insert[0]['value'] = $keyword;
+        }
+
+        $result = array();
+        if ($yes) {
+            foreach ($yes as $k => $v) {
+                if (isset($data[$k])) {
+                    unset($data[$k]);
+                }
+                $yes[$k]['selected'] = 'selected';
+            }
+            $data = $insert + $yes + $data;
+
+            $data = array_merge($data, array());
+        } else {
+            $data = $insert + $data;
+
+            $data = array_merge($data, array());
+        }
+
+        if (!$data) {
+            Dever::alert('暂无数据');
+        }
+
+        return $data;
+    }
+}

+ 19 - 0
app/content/lib/Page.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace Content\Lib;
+
+use Dever;
+
+class Page
+{
+    # 更新数据
+    public function link($id)
+    {
+    	$info = Dever::db('content/page')->one($id);
+        $url = Dever::url('page?key=' . $info['key'], 'main');
+
+        $html = '<a href="'.$url.'" target="_blank">点此查看</a>';
+
+        return $html;
+    }
+}

+ 56 - 0
app/journal/assets/manage/html/journal.html

@@ -0,0 +1,56 @@
+<style>
+.layui-col-md2
+{
+    height: 250px;
+    border:1px solid #bababa;
+    margin:5px;
+}
+.layui-col-md2 .img
+{
+    text-align: center;overflow: hidden;text-align: center;
+}
+</style>
+<div class="layui-fluid layadmin-cmdlist-fluid">
+  <ul class="layui-row layui-col-space30" id="sortable">
+    <li class="layui-col-md2 layui-col-sm4" id="data" style="">
+        <div class="cmdlist-container">
+            <div href="javascript:;" class="img" style="height: 154px;">
+              <img src="../../layuiadmin/style/res/template/portrait.png">
+            </div>
+            <a href="javascript:;" >
+              <div class="cmdlist-text" style="text-align:center;">
+                <p class="info">2018春夏季新款港味短款白色T恤+网纱中长款chic半身裙套装两件套</p>
+                <div class="price">
+                    <b></b>
+                </div>
+
+                <div class="text"></div>
+                
+
+                <div style="margin-top:10px;text-align:center;">
+                <div class="layui-table-cell"><a href="javascript:;" class="edit" onclick=""><button type="button" class="btn btn-info btn-rounded waves-effect waves-light m-b-5 layui-btn layui-btn-xs">编辑</button></a>&nbsp;&nbsp;<a href="#" class="oper_delete"><button type="button" class="btn btn-info btn-rounded waves-effect waves-light m-b-5 layui-btn layui-btn-danger layui-btn-xs"><span class="am-icon-trash-o"></span>删除</button></a>&nbsp;&nbsp;</div>
+                </div>
+              </div>
+            </a>
+        </div>
+    </li>
+  </ul>
+</div>
+
+<script id="url">var url = ""</script>
+<script>
+  $( function() {
+    var sort = $( "#sortable" ).sortable({
+        opacity: 0.7,
+        stop:function(){
+          var arr = $( "#sortable" ).sortable('toArray');
+          arr = arr.join(',');
+          $.post(url, {data:arr}, function()
+          {
+
+          })
+        }
+    });
+    $( "#sortable" ).disableSelection();
+  } );
+  </script>

+ 216 - 0
app/journal/database/active.php

@@ -0,0 +1,216 @@
+<?php
+
+$status = array
+(
+    1 => '开启',
+    2 => '关闭',
+);
+return array
+(
+    # 表名
+    'name' => 'active',
+    # 显示给用户看的名称
+    'lang' => '活动设置',
+    'menu' => false,
+    'end' => array
+    (
+        'insert' => 'journal/lib/manage.setActiveCache',
+        'update' => 'journal/lib/manage.setActiveCache',
+    ),
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'update'    => 'hidden',
+            'value'     => Dever::input('where_id')
+            //'list'        => true,
+        ),
+
+        'info_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '电子刊',
+            'default'   => '',
+            'desc'      => '电子刊',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'value'     => Dever::input('search_option_info_id')
+        ),
+
+        'status'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '活动状态',
+            'default'   => '1',
+            'desc'      => '活动状态',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $status,
+        ),
+
+        'name'      => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => '活动标题',
+            'default'   => '',
+            'desc'      => '活动标题',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'start'       => array
+        (
+            'type'      => 'int-11',
+            'default'   => '',
+            'name'      => '活动开始时间',
+            'match'     => 'is_string',
+            'desc'      => '活动开始时间',
+            'update'    => 'date',
+            'list'      => 'date("Y-m-d H:i:s", {start})',
+            'callback'  => 'maketime',
+        ),
+
+        'end'       => array
+        (
+            'type'      => 'int-11',
+            'default'   => '',
+            'name'      => '活动结束时间',
+            'match'     => 'is_string',
+            'desc'      => '活动结束时间',
+            'update'    => 'date',
+            'list'      => 'date("Y-m-d H:i:s", {end})',
+            'callback'  => 'maketime',
+        ),
+
+        'desc'      => array
+        (
+            'type'      => 'text-255',
+            'name'      => '活动描述',
+            'default'   => '',
+            'desc'      => '活动描述',
+            'match'     => 'option',
+            'update'    => 'editor',
+            'key'       => 1,
+            //'search'  => 'fulltext',
+            //'list'        => true,
+        ),
+
+        'invite_num'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '邀请多少个好友开启免费阅读',
+            'default'   => '10',
+            'desc'      => '邀请多少个好友开启免费阅读',
+            'match'     => 'option',
+            //'update'    => 'text',
+        ),
+
+        'invite_score'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '每邀请一个好友获得积分-仅支持邀请新用户,设置之后,积分规则里的设置将失效',
+            'default'   => '2',
+            'desc'      => '每邀请一个好友获得积分',
+            'match'     => 'option',
+            //'update'    => 'text',
+        ),
+
+        'invite_title'     => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => '邀请好友标题',
+            'default'   => '邀请好友获得积分',
+            'desc'      => '邀请好友标题',
+            'match'     => 'option',
+            //'update'    => 'text',
+        ),
+
+        'invite_desc'      => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '邀请好友标题介绍',
+            'default'   => '邀请10人开启免费阅读',
+            'desc'      => '邀请好友标题介绍',
+            'match'     => 'option',
+            //'update'    => 'textarea',
+        ),
+
+        'content'       => array
+        (
+            'type'      => 'text-255',
+            'name'      => '活动规则说明',
+            'default'   => '',
+            'desc'      => '活动规则说明',
+            'match'     => 'is_string',
+            'update'    => 'editor',
+            'key'       => 1,
+        ),
+        
+
+        '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})',
+        ),
+    ),
+
+    # 更新表结构
+    'alter' => array
+    (
+        2 => array
+        (
+            array('update', 'desc', 'desc', 'text-255  描述'),
+            //array('add', 'config', 'config', 'int-11 1 配置'),
+        ),
+        'version' => 2,
+    ),
+
+    'manage' => array
+    (
+
+    ),
+
+    'request' => array
+    (
+        # 获取提交订单超过12个小时
+        'getDataByTime' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'end' => array('yes', '<='),
+                'ends' => array('yes-end', '>'),
+                'state' => 1,
+                'status' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('id' => 'desc'),
+            'col' => '*',
+        ),
+    ),
+);

+ 145 - 0
app/journal/database/buy.php

@@ -0,0 +1,145 @@
+<?php
+
+return array
+(
+    # 表名
+    'name' => 'buy',
+    # 显示给用户看的名称
+    'lang' => '购买设置',
+    'menu' => false,
+    'end' => array
+    (
+        //'update' => 'service/lib/manage.feedback',
+        //'insert' => 'service/lib/manage.feedback',
+    ),
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'update'    => 'hidden',
+            'value'     => Dever::input('where_id')
+            //'list'        => true,
+        ),
+
+        'info_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '电子刊',
+            'default'   => '',
+            'desc'      => '电子刊',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'value'     => Dever::input('search_option_info_id')
+        ),
+
+        'buy_score'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '每购买一本刊获得多少积分',
+            'default'   => '20',
+            'desc'      => '每购买一本刊获得多少积分',
+            'match'     => 'is_numeric',
+            //'update'    => 'text',
+        ),
+
+        'buy_title'     => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => '购买电子刊标题',
+            'default'   => '购买电子刊获得积分',
+            'desc'      => '购买电子刊标题',
+            'match'     => 'is_string',
+            'update'    => 'text',
+        ),
+
+        'buy_applet_notice'      => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '购买提示-小程序与APP内直接购买电子刊的提示',
+            'default'   => '在此购买单本可直接阅读电子刊,购买多本,直接累计积分,不会生成兑换码。',
+            'desc'      => '购买提示',
+            'match'     => 'is_string',
+            'update'    => 'textarea',
+        ),
+
+        'buy_notice'      => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '购买一个兑换码提示-h5页面购买兑换码时的提示语',
+            'default'   => '一次购买多本将生成一个兑换码用于兑换,如需多个兑换码,请多次购买。',
+            'desc'      => '购买电子刊提示',
+            'match'     => 'is_string',
+            'update'    => 'textarea',
+        ),
+
+        'buy_notices'      => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '购买多个兑换码提示-h5页面购买兑换码时的提示语',
+            'default'   => '购买兑换码赠送好友:点击下方购买后,将生成多个兑换码。
+积分规则:使用兑换码兑换后,使用人获得积分,购买人不增加积分。',
+            'desc'      => '购买电子刊提示',
+            'match'     => 'is_string',
+            'update'    => 'textarea',
+        ),
+
+        'buy_desc'      => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '购买电子刊介绍',
+            'default'   => '每购买一本刊获得20积分',
+            'desc'      => '购买电子刊介绍',
+            'match'     => 'is_string',
+            'update'    => 'textarea',
+        ),
+
+        'buy_content'       => array
+        (
+            'type'      => 'text-255',
+            'name'      => '购买说明',
+            'default'   => "<p>1、兑换成功后可直接点击【开始阅读】查看电子刊内容;</p>
+<p>2、电子刊为虚拟商品,如无系统问题,兑换后不可退款;</p>
+<p>3、每兑换一本电子刊增加20个积分,以此类推,谁使用兑换码则积分累计在谁的账号中;</p>
+<p>4、想赠送朋友,可在下方点击【购买10本生成10个兑换码】按钮,如购买后自己使用,则需要全部兑换后方可换取积分;</p>
+<p>5、如有其它问题可咨询在线客服。</p>",
+            'desc'      => '请输入内容',
+            'match'     => 'is_string',
+            'update'    => 'editor',
+            'key'       => 1,
+        ),
+        
+        '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
+    (
+
+    ),
+);

+ 231 - 0
app/journal/database/buy_num.php

@@ -0,0 +1,231 @@
+<?php
+
+# 定义几个常用的选项
+$status = array
+(
+    1 => '在线',
+    2 => '下线',
+);
+
+return array
+(
+    # 表名
+    'name' => 'buy_num',
+    # 显示给用户看的名称
+    'lang' => '购买本数设置',
+    'order' => 100,
+    'menu' => false,
+    'end' => array
+    (
+        'insert' => 'journal/lib/manage.setBuyCache',
+        'update' => 'journal/lib/manage.setBuyCache',
+    ),
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            //'list'        => true,
+        ),
+
+        'info_id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '电子刊',
+            'default'   => '',
+            'desc'      => '电子刊',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'value'     => Dever::input('search_option_info_id')
+        ),
+
+        'num'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '购买本数-直接填写购买的电子刊本数数字即可',
+            'default'   => '1',
+            'desc'      => '购买本数',
+            'match'     => 'option',
+            'update'    => 'text',
+            //'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'name'      => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => '购买名称-一般为“购买n本”,如购买1本,如果为空,则根据购买本数自动生成如“购买n本”',
+            'default'   => '',
+            'desc'      => '购买名称',
+            'match'     => 'option',
+            'update'    => 'text',
+            //'search'    => 'fulltext',
+            'list'      => 'Dever::load("journal/lib/manage.getName", {id})',
+        ),
+
+        'price'     => array
+        (
+            'type'      => 'varchar-50',
+            'name'      => '购买时的标价-为空则自动根据电子刊的单本支付价格计算',
+            'default'   => '',
+            'desc'      => '购买时的标价',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'      => 'Dever::load("journal/lib/manage.getPrice", {id})',
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'varchar-50',
+            'name'      => '支付价格-实际支付价格,单位元,直接填写数字即可',
+            'default'   => '',
+            'desc'      => '支付价格',
+            'match'     => 'is_string',
+            //'update'    => 'text',
+        ),
+
+        'score'         => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => '增加积分数-直接填写购买当前本数设置,用户能获得的积分,设置之后,积分规则里的设置将失效',
+            'default'   => '',
+            'desc'      => '增加积分数',
+            'match'     => 'is_string',
+            //'update'    => 'text',
+        ),
+
+        'code'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '生成兑换码数量-直接填写购买当前本数所能得到的兑换码数,默认为1',
+            'default'   => '1',
+            'desc'      => '生成兑换码数量',
+            'match'     => 'option',
+            '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
+    (
+        
+    ),
+
+
+    'request' => array
+    (
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'info_id' => 'yes',
+                //'code' => 1,
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('reorder' => 'desc', 'cdate' => 'desc'),
+            'col' => '*',
+        ),
+
+        'getAlls' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'info_id' => 'yes',
+                'code' => 1,
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('reorder' => 'desc', 'cdate' => 'desc'),
+            'col' => '*',
+        ),
+
+        # 最低价格的
+        'getDataByMin' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'info_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'order' => array('cash' => 'asc','reorder' => 'desc', 'cdate' => 'desc'),
+            'col' => '*',
+        ),
+
+        'getAllCode' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'info_id' => 'yes',
+                'code' => 1,
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('reorder' => 'desc', 'cdate' => 'desc'),
+            'col' => '*',
+        ),
+
+        'getAllCodes' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'info_id' => 'yes',
+                //'code' => array(1, '>'),
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('reorder' => 'desc', 'cdate' => 'desc'),
+            'col' => '*',
+        ),
+    ),
+);

+ 294 - 0
app/journal/database/cate.php

@@ -0,0 +1,294 @@
+<?php
+# 获取电子刊分类权限
+$auth = Dever::tops();
+$status = Dever::config('base')->status;
+$type = array
+(
+    # 默认类型
+    3 => '图文内容',
+    1 => '全屏图',
+    
+    # 2019-03-27 增加两个类型
+    7 => '长图(文字)',
+    8 => '横屏图',
+
+    2 => '长图',
+    9 => '无边框图片',
+    10 => '四宫格图片',
+
+    # 2018-12-11 增加3个类型
+    4 => '全屏视频',
+    5 => '留言视频',
+    6 => '留言音频',
+
+    # 2019-03-27 增加三个类型
+    21 => '对话模板',
+
+    # 关联类型 > 10
+    //11 => '关联图文',
+    //12 => '关联视频',
+    //13 => '关联直播',
+
+    # 2019-07-26
+    31 => '试用产品',
+    32 => 'H5',
+);
+
+$list = array
+(
+    # 匹配的正则或函数 选填项
+    'option' => array
+    (
+
+        'name' => array('yes', 'like'),
+        'title' => array('yes', 'like'),
+        'id' => array($auth, 'in'),
+        'journal_id' => 'yes',
+        'state' => 'yes',
+    ),
+    'type' => 'all',
+    'order' => array('reorder' => 'desc', 'id' => 'desc'),
+    'page' => array(20, 'list'),
+    'col' => '*|id',
+);
+
+
+$id = Dever::input('where_id');
+return array
+(
+    # 表名
+    'name' => 'cate',
+    # 显示给用户看的名称
+    'lang' => '刊物设置',
+    # 后台菜单排序
+    'order' => 9,
+    'gettype' => $type,
+    'end' => array
+    (
+        'update' => array
+        (
+            'passport/lib/manage.updateSystem',
+            'manage/top.sync',
+        ),
+        'insert' => array
+        (
+            'passport/lib/manage.updateSystem',
+            '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,
+        ),
+
+        'type'     => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '内容类型-定义电子刊下的内页内容类型',
+            'default'   => '1,2,3,4,5,6',
+            'desc'      => '内容类型',
+            'match'     => 'is_numeric',
+            'update'    => 'checkbox',
+            'option'    => $type,
+        ),
+
+        'journal_id'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '主推电子刊',
+            'default'   => '',
+            'desc'      => '主推电子刊',
+            'match'     => 'is_numeric',
+            //'update'    => $id ? 'select' : 'hidden',
+            //'update_search' => 'journal/lib/manage.search_journal?cate=' . $id,
+        ),
+
+        'title'      => array
+        (
+            'type'      => 'varchar-32',
+            'name'      => '页面title-公众号支付中的页面标题',
+            'default'   => '',
+            'desc'      => '页面title',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+           // 'list'      => true,
+        ),
+
+        'desc'     => array
+        (
+            'type'      => 'text-255',
+            'name'      => '简介',
+            'default'   => '',
+            'desc'      => '简介',
+            'match'     => 'option',
+            'update'    => 'textarea',
+        ),
+
+        'cover'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '封面图-公众号支付中的封面图,图片尺寸460*759px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
+            'default'   => '',
+            'desc'      => '封面图',
+            'match'     => 'option',
+            'update'  => 'image',
+            'key'       => '1',
+            'place'     => '150',
+        ),
+
+        'logo'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => 'logo图-当前分类的logo图,图片尺寸100*100px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
+            'default'   => '',
+            'desc'      => 'logo图',
+            'match'     => 'option',
+            'update'  => 'image',
+            'key'       => '1',
+            'place'     => '150',
+        ),
+        
+        'reorder'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '排序(数值越大越靠前)',
+            'default'   => '1',
+            'desc'      => '请输入排序',
+            'match'     => 'option',
+            'update'    => 'text',
+            'search'    => 'order',
+            'list'      => true,
+            'order'     => 'desc',
+            'edit'      => true,
+        ),
+
+        'code_desc'     => array
+        (
+            'type'      => 'text-255',
+            'name'      => '兑换说明',
+            'default'   => '',
+            'desc'      => '兑换说明',
+            'match'     => 'option',
+            'update'    => 'editor',
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '上线状态',
+            'default'   => '2',
+            'desc'      => '上线状态',
+            'match'     => 'is_numeric',
+            //'update'  => 'select',
+            'option'    => $status,
+            'search'    => 'select',
+            'list'      => true,
+            '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,
+        'delete' => false,
+    ),
+
+    'top' => array
+    (
+        # 数据来源
+        'data' => 'state',
+        # 菜单名
+        'name' => '项目选择',
+        # 默认值
+        'value' => 1,
+        # 对应的字段值,设置这个之后,所有设置等于这个值的字段,都要遵循这个权限的控制
+        'key' => Dever::config('base')->top,
+        # 本表中代表名称的字段
+        'col' => 'name',
+    ),
+
+    'request' => array
+    (
+        'list' => $list,
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'state' => 1,
+                'status' => 2,
+            ),
+            'type' => 'all',
+            'order' => array('reorder' => 'desc','id' => 'desc'),
+            'col' => 'id,name,logo,journal_id',
+        ),
+
+        'getIds' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'ids' => array('yes-id', 'in'),
+                'status' => 2,
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('reorder' => 'desc','id' => 'desc'),
+            'col' => '*,id as value|id',
+        ),
+    ),
+);

+ 613 - 0
app/journal/database/content.php

@@ -0,0 +1,613 @@
+<?php
+
+$id = Dever::input('search_option_info_id');
+$cate = array();
+if ($id) {
+    $journal = Dever::db('journal/info')->one($id);
+    $cate = Dever::db('journal/cate')->one($journal['cate_id']);
+}
+$type_default = 3;
+$type_config = Dever::db('journal/cate')->config['gettype'];
+if ($cate) {
+    $type = array();
+    $cate_type = explode(',', $cate['type']);
+    $i = 0;
+    foreach ($cate_type as $k => $v) {
+        if (isset($type_config[$v])) {
+            if ($i == 0) {
+                $type_default = $v;
+            }
+            $type[$v] = $type_config[$v];
+            $i++;
+        }
+    }
+} else {
+    $type = $type_config;
+}
+
+$is_button = array
+(
+    1 => '显示',
+    2 => '不显示',
+);
+
+$text = array
+(
+    1 => '上左',
+    2 => '上中',
+    3 => '上右',
+    4 => '中左',
+    5 => '正中',
+    6 => '中右',
+    7 => '下左',
+    8 => '下中',
+    9 => '下右',
+    //10 => '自定义',
+);
+
+
+$palaces = array
+(
+    1 => '上左',
+    2 => '上右',
+    3 => '下左',
+    4 => '下右',
+);
+
+$bgcolor_type = array
+(
+    1 => '设置背景颜色',
+    2 => '不设置背景颜色',
+);
+$talk_type = array
+(
+    1 => '文字',
+    2 => '图片',
+    3 => '音频',
+);
+
+$talk_location = array
+(
+    1 => '显示在左侧',
+    2 => '显示在右侧',
+);
+
+return array
+(
+    # 表名
+    'name' => 'content',
+    # 显示给用户看的名称
+    'lang' => '内页管理',
+    'menu' => false,
+    'gettype' => $type,
+    'text' => $text,
+    'end' => array
+    (
+        'insert' => 'journal/lib/manage.addContent',
+    ),
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            //'search'    => 'order',
+            //'list'        => true,
+        ),
+
+        'info_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '电子刊',
+            'default'   => '',
+            'desc'      => '电子刊',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'value'     => Dever::input('search_option_info_id')
+        ),
+
+        'type'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '类型',
+            'default'   => $type_default,
+            'desc'      => '类型',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $type,
+            'control'   => 'type',
+        ),
+
+        'name'      => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => '标题',
+            'default'   => '',
+            'desc'      => '标题',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'list'      => true,
+            //增加预览
+            'preview'   => true,
+            'show'      => 'type=3,5,6,31,32',      
+        ),
+
+        'url'      => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '链接地址',
+            'default'   => '',
+            'desc'      => '链接地址',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'list'      => true,
+            //增加预览
+            'preview'   => true,
+            'show'      => 'type=32',      
+        ),
+
+        'video'     => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '上传视频-视频格式mp4,上传大小不能超过4G',
+            'default'   => '',
+            'desc'      => '上传点播视频',
+            'match'     => 'is_string',
+            'update'    => 'upload',
+            'key'       => '3',
+            'place'     => '150',
+            'upload'    => 'qiniu',
+            'large'     => true,
+            //不覆盖原文件,生成新文件
+            'cover'     => 2,
+            'show'      => 'type=4,5',      
+        ),
+
+        'video_info'        => array
+        (
+            'type'      => 'text-255',
+            'name'      => '视频信息',
+            'default'   => '',
+            'desc'      => '视频信息',
+            'match'     => 'is_string',
+        ),
+
+        'music'     => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '上传音频-视频格式mp3,上传大小不能超过100M',
+            'default'   => '',
+            'desc'      => '上传音频',
+            'match'     => 'is_string',
+            'update'    => 'upload',
+            'key'       => '2',
+            'place'     => '150',
+            'upload'    => 'qiniu',
+            'large'     => true,
+            //不覆盖原文件,生成新文件
+            'cover'     => 2,
+            'show'      => 'type=6',      
+        ),
+
+        'cover'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '封面图-全屏视频的封面图图片尺寸750*1386px或等比尺寸,留言视频的封面图图片尺寸750*422px或等比尺寸,留言音频的封面图图片尺寸750*422px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
+            'default'   => '',
+            'desc'      => '封面图',
+            'match'     => 'option',
+            'update'    => 'image',
+            'key'       => '1',
+            'place'     => '150',
+            'show'      => 'type=4,5,6',      
+        ),
+
+        'focus'     => array
+        (
+            'type'      => 'text-255',
+            'name'      => '焦点图',
+            'default'   => '',
+            'desc'      => '焦点图',
+            'match'     => 'option',
+            'update'    => 'image',
+            'key'       => '1',
+            'place'     => '150',
+            'show'      => 'type=3',      
+        ),
+
+        'content'       => array
+        (
+            'type'      => 'text-255',
+            'name'      => '内容',
+            'default'   => '',
+            'desc'      => '请输入内容',
+            'match'     => 'is_string',
+            'update'    => 'editor',
+            'show'      => 'type=3',
+            //自定义编辑器右侧按钮
+            'editor'    => array
+            (
+                'name' => '选择插入模块',
+                'button' => array
+                (
+                    array
+                    (
+                        # 名称
+                        'name' => '图片',
+                        # 资源库id
+                        'key' => 1,
+                        # 类型
+                        'type' => 'image',
+                    ),
+                    array
+                    (
+                        'name' => '音频',
+                        'key' => 2,
+                        'type' => 'media',
+                    ),
+                    /*
+                    array
+                    (
+                        'name' => '视频',
+                        'key' => 'video/lib/core.vod',
+                    ),
+                    array
+                    (
+                        'name' => '直播',
+                        'key' => 'video/lib/core.live',
+                    ),
+                    
+                    array
+                    (
+                        'name' => '小程序',
+                        'key' => 'journal/lib/applet.update',
+                        'type' => 'update',
+                    ),
+                    */
+                ),
+            ),
+        ),
+
+        'pic'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '图片-全屏图图片尺寸750*1386px或等比尺寸,长屏图图片尺寸750*高度不限或等比尺寸,横屏图图片尺寸宽度不限*1386px或等比尺寸,长图图片尺寸750*高度不限或等比尺寸,无边框图片尺寸长和宽均没有限制,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
+            'default'   => '',
+            'desc'      => '图片',
+            'match'     => 'option',
+            'update'  => 'image',
+            'key'       => '1',
+            'place'     => '150',
+            'show'      => 'type=1,2,7,8,9',      
+        ),
+
+        'pic_info'        => array
+        (
+            'type'      => 'varchar-500',
+            'name'      => '图片信息',
+            'default'   => '',
+            'desc'      => '图片信息',
+            'match'     => 'is_string',
+            'update'    => 'hidden',
+        ),
+
+        'is_button'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '是否显示保存按钮',
+            'default'   => '1',
+            'desc'      => '是否显示保存按钮',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $is_button,
+           // 'search'    => 'select',
+            'show'      => 'type=1,7,8',      
+            'control'   => 'is_button',
+        ),
+
+        'button_name'     => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => '保存按钮文字内容',
+            'default'   => '保存图片',
+            'desc'      => '保存按钮文字内容',
+            'match'     => 'option',
+            'update'    => 'textarea',
+            'show'      => 'type=1,7,8',      
+        ),
+
+        'button_color'     => array
+        (
+            'type'      => 'varchar-10',
+            'name'      => '保存按钮文字颜色',
+            'default'   => '#000000',
+            'desc'      => '保存按钮文字颜色',
+            'match'     => 'option',
+            'update'    => 'color',
+            'show'      => 'type=1,7,8',      
+        ),
+
+        'product_id'     => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '关联商品',
+            'default'   => '',
+            'desc'      => '关联商品',
+            'match'     => 'option',
+            'update'    => 'checkbox',
+            'show'      => 'type=31',
+            'update_search' => 'journal/lib/manage.search_product',
+        ),
+
+        'text'       => array
+        (
+            'type'      => 'text-1000',
+            'name'      => '文字设置',
+            'default'   => '',
+            'desc'      => '文字设置',
+            'match'     => 'is_string',
+            'option'    => $text,
+            'show'      => 'type=1,7,8',
+            'update'    => array
+            (
+                array
+                (
+                    'col'       => 'name',
+                    'name'      => '文字内容',
+                    'default'   => '',
+                    'desc'      => '文字内容',
+                    'match'     => 'is_string',
+                    'update'    => 'textarea',
+                ),
+
+                array
+                (
+                    'col'       => 'color',
+                    'name'      => '文字颜色',
+                    'default'   => '#000000',
+                    'desc'      => '文字颜色',
+                    'match'     => 'is_string',
+                    'update'    => 'color',
+                ),
+
+                array
+                (
+                    'col'       => 'bgcolor_type',
+                    'name'      => '是否设置背景颜色',
+                    'default'   => '2',
+                    'desc'      => '是否设置背景颜色',
+                    'match'     => 'is_string',
+                    'update'    => 'radio',
+                    'option'    => $bgcolor_type,
+                    'control'   => 'bgcolor_type',
+                ),
+
+                array
+                (
+                    'col'       => 'bgcolor',
+                    'name'      => '背景颜色',
+                    'default'   => '#000000',
+                    'desc'      => '背景颜色',
+                    'match'     => 'is_string',
+                    'update'    => 'color',
+                    'show'      => 'bgcolor_type=1'
+                ),
+
+                array
+                (
+                    'col'       => 'size',
+                    'name'      => '文字大小-直接输入像素数字',
+                    'default'   => '16',
+                    'desc'      => '结果描述',
+                    'match'     => 'is_numeric',
+                    'update'    => 'text',
+                ),
+            ),
+        ),
+
+        'palaces'       => array
+        (
+            'type'      => 'text-1000',
+            'name'      => '四宫格图片',
+            'default'   => '',
+            'desc'      => '四宫格图片',
+            'match'     => 'is_string',
+            'option'    => $palaces,
+            'show'      => 'type=10',
+            'update'    => array
+            (
+                array
+                (
+                    'col'       => 'pic',
+                    'name'      => '图片',
+                    'default'   => '',
+                    'desc'      => '图片',
+                    'match'     => 'is_string',
+                    'update'    => 'image',
+                    'key'       => 1,
+                ),
+            ),
+        ),
+
+        'talk_pic'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '置顶图片-图片尺寸750*1386px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式。为空则不显示',
+            'default'   => '',
+            'desc'      => '图片',
+            'match'     => 'option',
+            'update'    => 'image',
+            'key'       => '1',
+            'place'     => '150',
+            'show'      => 'type=21',      
+        ),
+
+        'talk'       => array
+        (
+            'type'      => 'text-1000',
+            'name'      => '对话设置',
+            'default'   => '',
+            'desc'      => '对话设置',
+            'match'     => 'is_string',
+            'show'      => 'type=21',
+            'update'    => array
+            (
+                array
+                (
+                    'col'       => 'talk_location',
+                    'name'      => '对话位置',
+                    'default'   => '1',
+                    'desc'      => '对话位置',
+                    'match'     => 'is_string',
+                    'update'    => 'radio',
+                    'option'    => $talk_location,
+                ),
+
+                array
+                (
+                    'col'       => 'avatar',
+                    'name'      => '头像-图片尺寸120*120px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式。',
+                    'default'   => '',
+                    'desc'      => '头像',
+                    'match'     => 'option',
+                    'update'    => 'image',
+                    'key'       => 1,
+                ),
+
+                array
+                (
+                    'col'       => 'talk_type',
+                    'name'      => '对话类型',
+                    'default'   => '1',
+                    'desc'      => '对话类型',
+                    'match'     => 'is_string',
+                    'update'    => 'radio',
+                    'option'    => $talk_type,
+                    'control'   => 'talk_type',
+                ),
+
+                array
+                (
+                    'col'       => 'text',
+                    'name'      => '文字内容-为空则不显示',
+                    'default'   => '',
+                    'desc'      => '文字内容',
+                    'match'     => 'option',
+                    'update'    => 'textarea',
+                    'show'      => 'talk_type=1'
+                ),
+
+                array
+                (
+                    'col'       => 'pic',
+                    'name'      => '图片-图片尺寸750*1386px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式,可以上传GIF格式。为空则不显示',
+                    'default'   => '',
+                    'desc'      => '图片',
+                    'match'     => 'option',
+                    'update'    => 'image',
+                    'key'       => 1,
+                    'show'      => 'talk_type=2'
+                ),
+
+                array
+                (
+                    'col'       => 'audio',
+                    'name'      => '音频-音频格式mp3,上传大小不能超过100M,为空则不显示',
+                    'default'   => '',
+                    'desc'      => '音频',
+                    'match'     => 'option',
+                    'update'    => 'upload',
+                    'key'       => 2,
+                    'show'      => 'talk_type=3'
+                ),
+            ),
+        ),
+
+        'reorder'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '页号',
+            'default'   => '1',
+            'desc'      => '请输入排序',
+            'match'     => 'option',
+            //'update'    => 'text',
+            'search'    => 'order',
+            'list'      => true,
+            'order'     => 'asc',
+            '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,
+        'num' => false,
+        'page_list_table' => 'journal',
+
+        # 自定义快捷新增和编辑
+        'button' => array
+        (
+            '新增内页' => array('location', 'add'),
+            '预览' => array('fast', 'main/preview.get?type=4&id=' . Dever::input('search_option_info_id')),
+        ),
+    ),
+
+    # request 请求接口定义
+    'request' => array
+    (
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'info_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('reorder' => 'asc', 'id' => 'desc'),
+            'page' => array(10, 'list'),
+            'col' => '*',
+        ),
+
+        'getAllByReorder' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'info_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'order' => array('reorder' => 'desc', 'id' => 'desc'),
+            'col' => '*',
+        ),
+    )
+);

+ 689 - 0
app/journal/database/info.php

@@ -0,0 +1,689 @@
+<?php
+$time = (7*86400);
+$audit = Dever::config('base')->audit;
+
+$status = Dever::config('base')->status;
+
+$share = function()
+{
+	$array = array();
+	$info = Dever::db('poster/template')->state();
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+# 获取电子刊分类权限
+$auth = Dever::tops();
+$cate = function() use ($auth)
+{
+	$array = array();
+	if ($auth) {
+		$info = Dever::db('journal/cate')->getIds(array('ids' => $auth));
+	} else {
+		$info = Dever::db('journal/cate')->state();
+	}
+	
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+
+$share = array
+(
+	1 => '显示',
+	2 => '不显示',
+);
+
+$top = array
+(
+	1 => '显示',
+	2 => '不显示',
+);
+
+$buy = array
+(
+	1 => '收费',
+	2 => '免费',
+	//3 => '会员',
+);
+
+$buy_type = array
+(
+	1 => '普通支付',
+	2 => '按明星支付',
+);
+
+$hot = array
+(
+	1 => '热门',
+	2 => '普通',
+);
+
+
+$page = 15;
+
+# 常用的col
+$col = 'id,name,subname,pic_cover,pic_view_cover,pic_view_bg,pdate,num_ding,num_add_ding,num_ratio_ding,num_up,buy,buy_type,share_yes,share_title,share_pic,share_content,pic_gd,cate_id,cash,bgmusic,top,hot';
+
+$config = array
+(
+	# 表名
+	'name' => 'info',
+	# 显示给用户看的名称
+	'lang' => '发刊管理',
+	'order' => 100,
+	'end' => array
+	(
+		'insert' => 'journal/lib/manage.setJournalCache',
+		'update' => 'journal/lib/manage.setJournalCache',
+	),
+
+	# 同步更新另外一个或多个表的数据 电子刊不需要同步到审核页面
+	/*
+	'syncone' => array
+	(
+		'audit/data' => array
+		(
+			# 更新另外一个表的字段 => 本表的字段
+			'where' => array('data_id' => 'id', 'type' => 4),
+			# 要更新的数据
+			'update' => array('data_id' => 'id', 'type' => 4, 'pdate' => 'pdate', 'reorder' => 'reorder', 'name' => 'name', 'audit' => 'audit', 'state' => 'state'),
+		)
+	),
+	*/
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'list'		=> true,
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-180',
+			'name' 		=> '电子刊标题',
+			'default' 	=> '',
+			'desc' 		=> '标题',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'subname'		=> array
+		(
+			'type' 		=> 'varchar-80',
+			'name' 		=> '子标题-一般为杂志的期数,如第1期',
+			'default' 	=> '',
+			'desc' 		=> '子标题',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			//'list'		=> true,
+		),
+
+		'cate_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '电子刊分类',
+			'default' 	=> '1',
+			'desc' 		=> '电子刊分类',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'select',
+			'option'	=> $cate,
+			'search'	=> 'select',
+			//'list'		=> true,
+		),
+
+  		'pic_cover'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '列表页封面图-4:3比例的图片',
+			'default' 	=> '',
+			'desc' 		=> '列表封面图',
+			'match' 	=> 'is_string',
+			//'update'	=> 'image',
+			'key' 		=> '1',
+			'place'		=> '150',
+		),
+
+		'pic_view_cover'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '封面图-图片尺寸660*660px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
+			'default' 	=> '',
+			'desc' 		=> '封面图',
+			'match' 	=> 'is_string',
+			'update'	=> 'image',
+			'key' 		=> '1',
+			'place'		=> '150',
+		),
+
+		'pic_view_bg'		=> array
+		(
+			'type' 		=> 'text-255',
+			'name' 		=> '全屏背景图-图片尺寸750*1386px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
+			'default' 	=> '',
+			'desc' 		=> '全屏背景图',
+			'match' 	=> 'is_string',
+			'update'	=> 'images',
+			'key' 		=> '1',
+			'place'		=> '150',
+		),
+
+		'pic_gd'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '电子刊推广图-图片尺寸512*688px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
+			'default' 	=> '',
+			'desc' 		=> '电子刊推广图',
+			'match' 	=> 'is_string',
+			'update'	=> 'image',
+			'key' 		=> '1',
+			'place'		=> '150',
+		),
+
+		'bgmusic'		=> array
+		(
+			'type' 		=> 'varchar-800',
+			'name' 		=> '背景音乐-音频格式mp3,上传大小不能超过100M',
+			'default' 	=> '',
+			'desc' 		=> '背景音乐',
+			'match' 	=> 'option',
+			'update'	=> 'upload',
+			'key' 		=> '2',
+			'place'		=> '150',
+			'upload'	=> 'qiniu',
+			'large' 	=> true,
+			//不覆盖原文件,生成新文件
+			'cover'		=> 2,
+		),
+
+		'num_ding'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '订阅数',
+			'default' 	=> '0',
+			'desc' 		=> '请填写订阅数',
+			'match' 	=> 'option',
+			'search'	=> 'order',
+			'list'		=> 'Dever::load("journal/lib/manage.ding?id={id}")',
+			'list_name'	=> '统计数字',
+		),
+
+		'num_up'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '阅读数',
+			'default' 	=> '0',
+			'desc' 		=> '阅读数',
+			'match' 	=> 'option',
+		),
+
+		'state'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '状态',
+			'default' 	=> '1',
+			'desc' 		=> '请选择状态',
+			'match' 	=> 'is_numeric',
+		),
+
+		'audit'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '审核',
+			'default' 	=> '1',
+			'desc' 		=> '审核',
+			'match' 	=> 'is_numeric',
+			//'update'	=> 'select',
+			'option'	=> $audit,
+			//'search'	=> 'select',
+			//'list'		=> true,
+			//'edit'		=> true,
+		),
+
+		'status'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '上线状态',
+			'default' 	=> '1',
+			'desc' 		=> '上线状态',
+			'match' 	=> 'is_numeric',
+			//'update'	=> 'select',
+			'option'	=> $status,
+			'search'	=> 'select',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+		'admin_founder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '创建人',
+			'default' 	=> '1',
+			'desc' 		=> '创建人',
+			'match' 	=> 'is_numeric',
+		),
+
+		'admin_editor'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '操作人',
+			'default' 	=> '1',
+			'desc' 		=> '操作人',
+			'match' 	=> 'is_numeric',
+		),
+
+		'pdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '发售时间',
+			'match' 	=> array('is_numeric', time()),
+			'default'	=> '',
+			'desc' 		=> '',
+			'update'	=> 'date',
+			'callback'	=> 'maketime',
+			'insert'	=> true,
+			//'list'		=> 'date("Y-m-d H:i:s", {pdate})',
+			'auth'		=> '"{pdate}" > 0',
+		),
+
+		'ydate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '预售时间',
+			'match' 	=> 'option',
+			'default'	=> '',
+			'desc' 		=> '',
+			//'update'	=> 'date',
+			'callback'	=> 'maketime',
+			//'insert'	=> true,
+			//'list'		=> 'date("Y-m-d H:i:s", {pdate})',
+			//'auth'		=> '"{ydate}" > 0',
+		),
+
+		'top'		=> array
+		(
+			'type' 		=> 'tinyint-11',
+			'name' 		=> '是否显示排行榜',
+			'default' 	=> '1',
+			'desc' 		=> '是否显示排行榜',
+			'match' 	=> 'option',
+			'update'	=> 'radio',
+			'option'	=> $top,
+			'list'		=> true,
+			'search'	=> 'select',
+			'edit'		=> true,
+		),
+
+		'buy'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '是否收费',
+			'default' 	=> '1',
+			'desc' 		=> '是否收费',
+			'match' 	=> 'option',
+			'update'	=> 'radio',
+			'option'	=> $buy,
+			'control'	=> 'buy',
+			//'list'		=> true,
+			'search'	=> 'select',
+		),
+
+		'buy_type'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '支付类型',
+			'default' 	=> '1',
+			'desc' 		=> '支付类型',
+			'match' 	=> 'option',
+			'update'	=> 'radio',
+			'option'	=> $buy_type,
+			'show'		=> 'buy=1',
+		),
+
+		'hot'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '是否热门电子刊',
+			'default' 	=> '2',
+			'desc' 		=> '是否热门电子刊',
+			'match' 	=> 'option',
+			//'update'	=> 'radio',
+			'option'	=> $hot,
+			'search'	=> 'select',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+		'cash'      => array
+        (
+            'type'      => 'varchar-50',
+            'name'      => '单本支付价格-实际的电子刊单本支付价格,单位元,直接填写数字即可',
+            'default'   => '',
+            'desc'      => '支付价格',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'show'		=> 'buy=1',
+        ),
+
+        'buy_content'       => array
+        (
+            'type'      => 'text-255',
+            'name'      => '购买说明',
+            'default'   => '',
+            'desc'      => '请输入内容',
+            'match'     => 'is_string',
+            'update'    => 'editor',
+            'key'       => 1,
+            'show'		=> 'buy=1',
+        ),
+
+        'num_ratio_ding'		=> array
+		(
+			'type' 		=> 'varchar-20',
+			'name' 		=> '订阅系数-系数不能小于等于0,支持两位小数,电子刊总订阅量=(用户当前订阅数+订阅基数)*订阅系数。注意:如果设置了明星,这里设置将失效',
+			'default' 	=> '1',
+			'desc' 		=> '手动增加订阅系数',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'show'		=> 'buy=1&buy_type=1',
+		),
+
+		'num_add_ding'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '订阅基数-注意:如果设置了明星,这里设置将失效',
+			'default' 	=> '0',
+			'desc' 		=> '手动增加阅读数',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+			'show'		=> 'buy=1&buy_type=1',
+		),
+
+		'share_yes'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '是否显示分享按钮',
+			'default' 	=> '1',
+			'desc' 		=> '是否显示分享按钮',
+			'match' 	=> 'option',
+			'update'	=> 'radio',
+			'option'	=> $share,
+			'control'	=> 'share_yes',
+		),
+
+		'share_title'		=> array
+		(
+			'type' 		=> 'varchar-100',
+			'name' 		=> '分享标题',
+			'default' 	=> '',
+			'desc' 		=> '分享标题',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+			'show'		=> 'share_yes=1',
+		),
+
+		'share_pic'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '分享图片-图片尺寸570*570px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
+			'default' 	=> '',
+			'desc' 		=> '分享图片',
+			'match' 	=> 'is_string',
+			'update'	=> 'image',
+			'key' 		=> '1',
+			'place'		=> '150',
+			'show'		=> 'share_yes=1',
+			//'upload'	=> 'qiniu',
+			//'large' 	=> true,
+		),
+
+		'share_content'		=> array
+		(
+			'type' 		=> 'varchar-200',
+			'name' 		=> '分享内容',
+			'default' 	=> '',
+			'desc' 		=> '分享内容',
+			'match' 	=> 'option',
+			'update'	=> 'textarea',
+			'show'		=> 'share_yes=1',
+		),
+
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序(数值越大越靠前)',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+			'search'	=> 'order',
+			'list'		=> true,
+			'order'		=> 'desc',
+			'edit'		=> true,
+		),
+
+		'udate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '更新时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+		),
+
+		'cdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '录入时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+			# 只有insert时才生效
+			'insert'	=> true,
+		),
+	),
+
+	'top' => Dever::config('base')->top,
+
+	# 增加这个,为了给当前的list增加一个option $admin = Dever::load('manage/auth.info');
+	'top_option' => array
+	(
+		array
+		(
+			'value' => $auth,
+			'col' => 'cate_id',
+		),
+		array
+		(
+			'value' => Dever::load('manage/auth.authData'),
+			'col' => 'id',
+		),
+	),
+	
+	# 管理功能
+	'manage' => array
+	(
+		//'insert' => false,
+		'delete' => false,
+		# 列表
+		'list_button' => array
+		(
+			'update' => '编辑电子刊',
+			'br1' => array('<br />'),
+			'edit' => array('电子刊预览', str_replace('https://api.', 'http://www.', Dever::url('main/preview.get?type=4'))),
+			'edit1' => array('活动预览', str_replace('https://api.', 'http://www.', Dever::url('main/preview.get?type=13')), '{audit} == 1 && {buy} == 1'),
+			'br2' => array('<br />'),
+			'list10' => array('排行榜', '"journal_num&project=act&search_type=4&search_option_journal_id={id}&oper_parent=info&oper_project=journal"' , '{audit} == 1 && {buy} == 1'),
+			'list' => array('内页管理', '"content&search_option_info_id={id}&oper_parent=info&page_type=1"' , '{audit} == 1'),
+			//'add' => array('购买设置', '"buy&project=journal&search_option_info_id={id}&oper_parent=info&oper_project=journal&oper_save_jump=info&where_id={id}"', '{audit} == 1 && {buy} == 1'),
+			'add1' => array('活动设置', '"active&project=journal&search_option_info_id={id}&oper_parent=info&oper_project=journal&oper_save_jump=info&where_id={id}"', '{audit} == 1 && {buy} == 1'),
+
+			'list1' => array('购买本数管理', '"buy_num&search_option_info_id={id}&oper_parent=info"' , '{audit} == 1 && {buy} == 1'),
+			'list2' => array('购买明星设置', '"star&search_option_info_id={id}&oper_parent=info"' , '{audit} == 1 && {buy} == 1 && {buy_type} == 2'),
+		),
+	),
+
+	# request 请求接口定义
+	'request' => array
+	(
+
+		'search' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'ids' => array('yes-id', 'in'),
+				'cate_id' => 'yes',
+				'name' => array('yes', 'like'),
+				'id' => 'yes',
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc', 'id' => 'desc'),
+			'limit' => '0,1000',
+			'col' => 'name as name, id, id as value, "" as selected, "" as disabled|id',
+		),
+
+		'getAll' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				//'audit' => 2,
+				'buy' => 'yes',
+				'buy_type' => 'yes',
+				'cate_id' => 'yes',
+				'status' => 2,
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc', 'id' => 'desc'),
+			//'page' => array(10, 'list'),
+			'col' => $col,
+		),
+
+		'getAllByPage' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				//'audit' => 2,
+				'cate_id_1' => array('yes-cate_id', '=', 'and('),
+				'time' => array('yes-pdate', '<=', 'or)'),
+				'buy' => 'yes',
+				'buy_type' => 'yes',
+				'cate_id' => 'yes',
+				'status' => 2,
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc', 'id' => 'desc'),
+			'page' => array(10, 'list'),
+			'col' => $col,
+		),
+
+		# 更新阅读数
+		'addDing' => array
+		(
+			'type' => 'update',
+			'where' => array
+			(
+				'id' => 'yes',
+			),
+			'set' => array
+			(
+				'num_up' => array('1', '+='),
+			),
+		),
+
+		'getIds' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'cate_id' => array('yes-cate_id', 'in'),
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('reorder' => 'desc','id' => 'desc'),
+            'col' => '*,id as value|id',
+        ),
+
+        'getOne' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'col' => $col,
+        ),
+
+        # 热门
+        'getHot' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				//'audit' => 2,
+				'hot' => 1,
+				'buy' => 'yes',
+				'buy_type' => 'yes',
+				'cate_id' => 'yes',
+				'status' => 2,
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc', 'id' => 'desc'),
+			//'page' => array(10, 'list'),
+			'col' => $col,
+		),
+
+        'getNew' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+            	'cate_id_1' => array('yes-cate_id', '=', 'and('),
+				'time' => array('yes-pdate', '<=', 'or)'),
+				'cate_id' => 'yes',
+            	'status' => 2,
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'order' => array('ssdate' => 'desc'),
+            'col' => $col . ',case when cate_id = 1 then pdate else pdate-'.$time.' end as ssdate',
+        ),
+	),
+);
+
+/* 由top_option取代
+if ($auth) {
+	$config['request']['list'] = array
+	(
+		'type' => 'all',
+        'order' => array('id' => 'desc'),
+        'col' => '*|id',
+        'page' => array(15, 'list'),
+        'option' => array
+        (
+        	'cate_id' => array($auth, 'in'),
+        ),
+	);
+}
+*/
+
+return $config;

+ 99 - 0
app/journal/database/mobile.php

@@ -0,0 +1,99 @@
+<?php
+
+$product = function()
+{
+    return Dever::db('journal/info')->state();
+};
+
+return array
+(
+    # 表名
+    'name' => 'mobile',
+    # 显示给用户看的名称
+    'lang' => '电子刊导入用户',
+    'order' => 1,
+    'menu' => false,
+
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            //'list'      => true,
+        ),
+
+        'mobile'      => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '手机号',
+            'default'   => '',
+            'desc'      => '手机号',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'        => true,
+            //'list'        => '"{order_id}" ? "{order_id}" : "{code}"',
+        ),
+
+        'product_id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '电子刊',
+            'default'   => '',
+            'desc'      => '电子刊',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => $product,
+            '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'      => '',
+            'default'   => '',
+            # 只有insert时才生效
+            'insert'    => true,
+            'search'    => 'date',
+            'list'        => 'date("Y-m-d H:i:s", {cdate})',
+            //'list'      => 'Dever::load("service/lib/manage.showOrderTime", "{id}")',
+        ),
+    ),
+
+    'manage' => array
+    (
+        //'delete' => false,
+        'edit' => false,
+        'insert' => false,
+
+        'button' => array
+        (
+            '导入用户' => array('fast', 1, 'mobile_upload&where_id=1'),
+            '下载导入模板' => array('location', 'journal/lib/manage.mobileTemplate'),
+        ),
+    ),
+
+    'request' => array
+    (
+        
+    ),
+);

+ 57 - 0
app/journal/database/mobile_upload.php

@@ -0,0 +1,57 @@
+<?php
+
+return array
+(
+	# 表名
+	'name' => 'mobile_upload',
+	# 显示给用户看的名称
+	'lang' => '导入用户',
+	'order' => 1,
+	'menu' => false,
+	'end' => array
+	(
+		'update' => 'journal/lib/manage.mobileImport',
+		'insert' => 'journal/lib/manage.mobileImport',
+	),
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '系统ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'value'		=> Dever::input('where_id'),
+		),
+
+		'file'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '导入用户-请先下载模板',
+			'default' 	=> '',
+			'desc' 		=> '导入用户',
+			'match' 	=> 'is_string',
+			'update'	=> 'upload',
+			'key' 		=> '4',
+			'value'		=> '',
+		),
+
+		'cdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '录入时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+			# 只有insert时才生效
+			'insert'	=> true,
+		),
+	),
+
+	'manage' => array
+	(
+		# 后台管理不要列表页
+		'list' => 'update',
+	),
+);

+ 151 - 0
app/journal/database/star.php

@@ -0,0 +1,151 @@
+<?php
+
+# 定义几个常用的选项
+$status = array
+(
+    1 => '在线',
+    2 => '下线',
+);
+
+return array
+(
+    # 表名
+    'name' => 'star',
+    # 显示给用户看的名称
+    'lang' => '购买明星设置',
+    'order' => 100,
+    'menu' => false,
+    'end' => array
+    (
+        'insert' => 'journal/lib/manage.setStarCache',
+        'update' => 'journal/lib/manage.setStarCache',
+    ),
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            //'list'        => true,
+        ),
+
+        'info_id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '电子刊',
+            'default'   => '',
+            'desc'      => '电子刊',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'value'     => Dever::input('search_option_info_id')
+        ),
+
+        'name'      => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => '明星姓名',
+            'default'   => '',
+            'desc'      => '明星姓名',
+            'match'     => 'option',
+            'update'    => 'text',
+            //'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'avatar'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '明星头像-图片尺寸150*150px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
+			'default' 	=> '',
+			'desc' 		=> '明星头像',
+			'match' 	=> 'is_string',
+			'update'	=> 'image',
+			'key' 		=> '1',
+			'place'		=> '150',
+		),
+
+		'num_ratio_ding'		=> array
+		(
+			'type' 		=> 'varchar-20',
+			'name' 		=> '订阅系数-系数不能小于等于0,支持两位小数,当前明星总订阅量=(用户当前订阅数+订阅基数)*订阅系数',
+			'default' 	=> '1',
+			'desc' 		=> '手动增加订阅系数',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+		),
+
+		'num_add_ding'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '订阅基数',
+			'default' 	=> '0',
+			'desc' 		=> '手动增加阅读数',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+		),
+
+		'num_ding'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '订阅数',
+			'default' 	=> '0',
+			'desc' 		=> '请填写订阅数',
+			'match' 	=> 'option',
+			'search'	=> 'order',
+			'list'		=> 'Dever::load("journal/lib/manage.starDing?id={id}")',
+		),
+
+        '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
+    (
+        
+    ),
+
+
+    'request' => array
+    (
+       
+    ),
+);

+ 8 - 0
app/journal/index.php

@@ -0,0 +1,8 @@
+<?php
+
+define('DEVER_APP_NAME', 'journal');
+define('DEVER_APP_LANG', '电子刊');
+define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+define('DEVER_MANAGE_ORDER', 190);
+define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-tower layui-icon-cellphone-fine');
+include(DEVER_APP_PATH . '../boot.php');

+ 577 - 0
app/journal/lib/Manage.php

@@ -0,0 +1,577 @@
+<?php
+
+namespace Journal\Lib;
+
+use Dever;
+
+class Manage
+{
+    public function getManageData()
+    {
+        $data = array();
+
+        $data = Dever::db('journal/cate')->state();
+
+        if ($data) {
+            foreach ($data as $k => $v) {
+                $data[$k]['child'] = Dever::db('journal/info')->state(array('cate_id' => $v['id']));
+            }
+        }
+        return $data;
+    }
+
+    public function showOrderUser($id)
+    {
+        $info = Dever::db('journal/order')->one($id);
+
+        $table = array();
+
+        $user = Dever::db('passport/user')->one($info['uid']);
+
+        $table['用户名'] = $user['username'] . '('.$info['uid'].')';
+        $table['手机号'] = $user['mobile'];
+        $table['产品名'] = $info['name'];
+        if ($info['type'] == 1) {
+            $table['支付方式'] = '购买小刊';
+            $table['支付金额'] = $info['cash'];
+        } elseif ($info['type'] == 3) {
+            $table['支付方式'] = '购买小刊兑换码';
+            $table['兑换码'] = $info['code'];
+            $table['支付金额'] = $info['cash'];
+        } elseif ($info['type'] == 2) {
+            $table['支付方式'] = '兑换小刊';
+            $table['兑换码'] = $info['code'];
+        } elseif ($info['type'] == 4) {
+            $table['支付方式'] = '使用通用兑换码';
+            $table['兑换码'] = $info['code'];
+        }
+        //$table['购买数量'] = $info['num'];
+        
+        if ($info['source_uid'] && $info['source_uid'] != $info['uid']) {
+            $user = Dever::db('passport/user')->one($info['source_uid']);
+            $table['邀请人'] = $user['username'];
+        }
+
+        return Dever::table($table);
+    }
+
+    public function showOrderUserV1($id)
+    {
+        $info = Dever::db('act/order')->one($id);
+
+        $table = array();
+
+        $user = Dever::db('passport/user')->one($info['uid']);
+
+        $table['用户名'] = $user['username'] . '('.$info['uid'].')';
+        $table['手机号'] = $user['mobile'];
+        $table['产品名'] = $info['name'];
+        if ($info['type'] == 1) {
+            $table['支付方式'] = '购买小刊';
+            $table['支付金额'] = $info['cash'];
+        } elseif ($info['type'] == 3) {
+            $table['支付方式'] = '购买小刊兑换码';
+            $table['兑换码'] = $info['code'];
+            $table['支付金额'] = $info['cash'];
+        } elseif ($info['type'] == 2) {
+            $table['支付方式'] = '兑换小刊';
+            $table['兑换码'] = $info['code'];
+        } elseif ($info['type'] == 4) {
+            $table['支付方式'] = '使用通用兑换码';
+            $table['兑换码'] = $info['code'];
+        }
+        //$table['购买数量'] = $info['num'];
+        
+        if ($info['source_uid'] && $info['source_uid'] != $info['uid']) {
+            $user = Dever::db('passport/user')->one($info['source_uid']);
+            $table['邀请人'] = $user['username'];
+        }
+
+        return Dever::table($table);
+    }
+
+    # 获取订阅本数
+    public function ding($id)
+    {
+        $data = Dever::db('journal/info')->one($id);
+        $data = Dever::load('journal/api')->ding($data);
+
+        $num_ding = $data['num_ding'];
+        $num_add_ding = $data['num_add_ding'];
+        $num_ratio_ding = $data['num_ratio_ding'];
+
+        //$num_view = $data['num_view'];
+        //$num_add_view = $data['num_add_view'];
+        //$num_comment = $data['num_comment'];
+
+        $buy_num = $data['buy_num'];
+
+        //$html = '订阅本数:('.$buy_num.'+'.$num_add_ding.')*'.$num_ratio_ding.'='.$num_ding.'<br />阅读数:'.$num_view.'+'.$num_add_view.'<br />评论数:'.$num_comment.'<br />';
+
+        $cate = Dever::db('journal/cate')->one($data['cate_id']);
+        $html = '《' . $cate['name'] . '》<br />';
+
+        if ($data['buy'] == 1) {
+            $html .= '<font style="color:red">收费电子刊</font><br />';
+            $html .= '订阅本数:('.$buy_num.'+'.$num_add_ding.')*'.$num_ratio_ding.'='.$num_ding;
+        } else {
+            $html .= '<font style="color:blue">免费电子刊</font><br />';
+            $html .= '订阅数:('.$buy_num.'+'.$num_add_ding.')*'.$num_ratio_ding.'='.$num_ding;
+        }
+        
+        return $html;
+    }
+
+    # 获取明星订阅本数
+    public function starDing($id)
+    {
+        $data = Dever::db('journal/star')->one($id);
+        $data = Dever::load('journal/api')->starDing($data);
+
+        $num_ding = $data['num_ding'];
+        $num_add_ding = $data['num_add_ding'];
+        $num_ratio_ding = $data['num_ratio_ding'];
+
+        $buy_num = $data['buy_num'];
+
+        $html .= '订阅本数:('.$buy_num.'+'.$num_add_ding.')*'.$num_ratio_ding.'='.$num_ding;
+        
+        return $html;
+    }
+
+    public function showOrderStatus($id)
+    {
+        $info = Dever::db('journal/order')->one($id);
+        if ($info) {
+            if ($info['status'] == 1) {
+                #return '*已支付';
+                return '待支付';
+            } elseif ($info['status'] == 2) {
+                return '已支付';
+            } elseif ($info['status'] == 3) {
+                return '支付失败';
+            } elseif ($info['status'] == 5) {
+                $table['状态'] = '已退款';
+                $manage = Dever::db('manage/admin')->one($info['tk_admin']);
+                $table['备注'] = $info['tk_desc'];
+                $table['截图'] = '<a><img src="'.$info['tk_pic'].'" style="width:150px" /></a>';
+                //$table['退款时间'] = date('Y-m-d H:i:s', $info['tk_time']);
+                $table['操作人'] = $manage['username'];
+                return Dever::table($table);
+            }
+        }
+    }
+
+    public function showOrderStatusV1($id)
+    {
+        $info = Dever::db('act/order')->one($id);
+        if ($info) {
+            if ($info['status'] == 1) {
+                #return '*已支付';
+                return '待支付';
+            } elseif ($info['status'] == 2) {
+                return '已支付';
+            } elseif ($info['status'] == 3) {
+                return '支付失败';
+            } elseif ($info['status'] == 5) {
+                $table['状态'] = '已退款';
+                $manage = Dever::db('manage/admin')->one($info['tk_admin']);
+                $table['备注'] = $info['tk_desc'];
+                $table['截图'] = '<a><img src="'.$info['tk_pic'].'" style="width:150px" /></a>';
+                //$table['退款时间'] = date('Y-m-d H:i:s', $info['tk_time']);
+                $table['操作人'] = $manage['username'];
+                return Dever::table($table);
+            }
+        }
+    }
+
+	private function search($table = 'content/article')
+	{
+		$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,50';
+            $data = Dever::db($table)->search($where);
+        } else {
+            $where['name'] = $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'] = 'selected';
+            }
+            $data = $yes + $data;
+
+            $data = array_merge($data, array());
+        } else {
+            $data = array_merge($data, array());
+        }
+
+        if (!$data) {
+            Dever::alert('暂无数据');
+        }
+
+        return $data;
+	}
+
+	# 搜索文章
+    public function search_article_api()
+    {
+        return $this->search('content/article');
+    }
+
+    # 搜索视频
+    public function search_vod_api()
+    {
+        return $this->search('video/vod');
+    }
+
+    # 搜索直播
+    public function search_live_api()
+    {
+        return $this->search('video/live');
+    }
+
+    # 搜索小刊
+    public function search_journal_api()
+    {
+        return $this->search('journal/info');
+    }
+
+    # 搜索专题
+    public function search_feature_api()
+    {
+        return $this->search('feature/info');
+    }
+
+    # 搜索小程序
+    public function search_applet_api()
+    {
+        return $this->search('content/applet');
+    }
+
+    # 搜索商品
+    public function search_product_api()
+    {
+        return $this->search('product/info');
+    }
+
+    # 按照分类搜索小刊
+    public function search_cate_journal_api()
+    {
+        $level_num = Dever::input('level_num');
+        $level_id = Dever::input('level_id');
+        
+        $auth = Dever::tops();
+        $where = array();
+        if ($level_num == 1) {
+            $default = array
+            (
+                'value' => -1,
+                'name' => '选择分类',
+            );
+            if ($auth) {
+                $where['ids'] = $auth;
+            }
+
+            $data = Dever::db('journal/cate')->getIds($where);
+        } elseif ($level_num == 2 && $level_id > 0) {
+            $default = array
+            (
+                'value' => -1,
+                'name' => '选择小刊',
+            );
+            if ($level_id > 0) {
+                $where['cate_id'] = $level_id;
+            } elseif ($auth) {
+                $where['cate_id'] = $auth;
+            }
+            
+            $data = Dever::db('journal/info')->getIds($where);
+        } else {
+            return array();
+        }
+
+        
+        array_unshift($data, $default);
+        $result['level_total'] = 2;
+        $result['list'] = $data;
+        return $result;
+    }
+
+    # 显示杂志内页
+    public function journalContent()
+    {
+        $where['info_id'] = Dever::input('search_option_info_id');
+        $where['state'] = Dever::input('search_option_state');
+        $data = Dever::db('journal/content')->all($where);
+
+        $database = Dever::load('manage/database');
+        $type = Dever::db('journal/content')->config['gettype'];
+        
+        if ($data) {
+            foreach ($data as $k => $v) {
+
+                $data[$k]['height'] = 'height: 154px;';
+                $data[$k]['info_height'] = 'height: auto;';
+                if ($v['type'] > 2) {
+                    $data[$k]['height'] = 'height: 104px;';
+                    $data[$k]['info_height'] = 'height: 47px;';
+                }
+                if ($v['type'] <= 2) {
+                    $data[$k]['name'] = '';
+                } elseif ($v['type'] == 3) {
+                    $data[$k]['pic'] = $v['focus'];
+                }
+
+                if ($v['type'] == 4 || $v['type'] == 5 || $v['type'] == 6) {
+                    $data[$k]['name'] = '';
+                    $data[$k]['pic'] = $v['cover'];
+                }
+
+                if ($v['type'] == 11) {
+                    # 图文
+                    $info = Dever::load('content/lib/article')->get($v['article_id']);
+                    if ($info) {
+                        $data[$k]['pic'] = $info['pic_cover'];
+                        $data[$k]['name'] = $info['name'];
+                    }
+                } elseif ($v['type'] == 12) {
+                    # 视频
+                    $info = Dever::load('video/lib/vod')->get($v['vod_id']);
+                    if ($info) {
+                        $data[$k]['pic'] = $info['pic_cover'];
+                        $data[$k]['name'] = $info['name'];
+                    }
+                } elseif ($v['type'] == 13) {
+                    # 直播
+                    $info = Dever::load('video/lib/live')->get($v['live_id']);
+                    if ($info) {
+                        $data[$k]['pic'] = $info['pic_cover'];
+                        $data[$k]['name'] = $info['name'];
+                    }
+                }
+
+                if ($v['type'] == 10) {
+                    $palaces = Dever::array_decode($v['palaces']);
+                    if (isset($palaces[0])) {
+                        $data[$k]['pic'] = $palaces[0]['pic'];
+                    }
+                }
+
+                if ($v['type'] == 21) {
+                    if ($data[$k]['talk_pic']) {
+                        $data[$k]['pic'] = $data[$k]['talk_pic'];
+                    } else {
+                        $talk = Dever::array_decode($v['talk']);
+                        if ($talk) {
+                            foreach ($talk as $tk => $tv) {
+                                if ($tv['pic']) {
+                                    $data[$k]['pic'] = $tv['pic'];
+                                    break;
+                                }
+                            }
+                        }
+                    }
+                }
+
+                $data[$k]['typename'] = $type[$v['type']];
+
+                /*
+                if ($v['type'] == 1) {
+                    $data[$k]['text'] = $this->text($database, $v['id'], $where['info_id']);
+                } else {
+                    $data[$k]['text'] = '';
+                }
+                */
+                $data[$k]['text'] = '';
+
+                $link = $database->url('edit', $v['id']) . '&search_option_info_id=' . $where['info_id'];
+
+                $data[$k]['edit'] = "fastEdit($(this), '".$link."', '编辑内页', '', 1)";
+
+                $data[$k]['editurl'] = $link;
+
+                $data[$k]['delete'] = $database->url('delete', $v['id']);
+            }
+        }
+
+        return $data;
+    }
+
+    private function text_name($link, $content_id, $info_id, $location, $name)
+    {
+        $where['info_id'] = $info_id;
+        $where['content_id'] = $content_id;
+        $where['location'] = $location;
+        $info = Dever::db('journal/content_text')->one($where);
+
+        $link .= '&search_option_info_id=' . $info_id. '&search_option_content_id=' . $content_id.'&table=content_text&search_option_location='.$location;
+
+        if ($info) {
+            $link .= '&where_id=' . $info['id'];
+        }
+
+        $html = '<a style="cursor:pointer;" href="javascript:;" onclick="fastEdit($(this), \''.$link.'\', \'编辑'.$name.'文字\', \'\')">'.$name.'</a>';
+
+        return $html;
+    }
+
+    public function text($database, $content_id, $info_id)
+    {
+        $link = $database->url('edit');
+
+        $location = Dever::db('journal/content_text')->config['location'];
+
+        $html = '<table class="layui-table"><tbody><tr>';
+        $i = 0;
+        foreach ($location as $k => $v) {
+            $name = $this->text_name($link, $content_id, $info_id, $k, $v);
+            $html .= '<td>'.$name.'</td>';
+
+            if ($i == 2 || $i == 5) {
+                $html .= '</tr><tr>';
+            }
+
+            $i++;
+        }
+
+        $html .= '</tr></tbody></table>';
+
+        return $html;
+    }
+
+    public function updateJournalContent_api()
+    {
+        $data = Dever::input('data');
+
+        if ($data) {
+            $data = explode(',', str_replace('data-', '', $data));
+            foreach ($data as $k => $v) {
+                $k = $k + 1;
+                $where['where_id'] = $v;
+                $where['reorder'] = $k;
+                Dever::db('journal/content')->update($where);
+            }
+
+        }
+
+        return $data;
+    }
+
+    public function addContent($id, $name, $data)
+    {
+        # 获取最新的reorder
+        $info_id = Dever::param('info_id', $data);
+        $data = Dever::db('journal/content')->getAllByReorder(array('info_id' => $info_id));
+
+        if ($data) {
+            $update['where_id'] = $id;
+            $update['reorder'] = $data['reorder'] + 1;
+            Dever::db('journal/content')->update($update);
+        }
+    }
+
+    public function getName($id)
+    {
+        $info = Dever::db('journal/buy_num')->one($id);
+        if ($info && $info['name']) {
+            return $info['name'];
+        } else {
+            return '购买' . $info['num'] . '本';
+        }
+    }
+
+    public function getPrice($id)
+    {
+        $info = Dever::db('journal/buy_num')->one($id);
+
+        $journal = Dever::db('journal/info')->one($info['info_id']);
+        if ($info && $info['price']) {
+            return $info['price'];
+        } else {
+            return $info['num'] * $journal['cash'] . '元';
+        }
+    }
+
+    public function mobileTemplate_api()
+    {
+        $host = 'http://' . $_SERVER['HTTP_HOST'] . '/wonderful/';
+        $file = $host . 'doc/mobile.xlsx';
+
+        Dever::location($file);
+    }
+
+    public function setJournalCache($id, $name, $param)
+    {
+        Dever::load('act/order')->setCache($id, 1);
+    }
+
+    public function setBuyCache($id, $name, $param)
+    {
+        Dever::load('act/order')->setCache($id, 2);
+    }
+
+    public function setActiveCache($id, $name, $param)
+    {
+        Dever::load('act/order')->setCache($id, 3);
+    }
+
+    public function setStarCache($id, $name, $param)
+    {
+        Dever::load('act/order')->setCache($id, 4);
+    }
+
+    /**
+     * 导入用户
+     *
+     * @return mixed
+     */
+    public function mobileImport($id, $name, $param)
+    {
+        $file = Dever::param('file', $param);
+        if ($file) {
+            $file = str_replace('wonderful', 'upload', Dever::local($file));
+            $file = str_replace('https://api.huoxingkandiqiu.com/', '/www/', $file);
+            //$file = '/www/upload/data/upload/4/2019/04/11/f730437f0b5764790baed3c96c5264b2.xlsx';
+            $data = Dever::excelImport($file);
+            if ($data) {
+                foreach ($data as $k => $v) {
+                    if ($k > 1) {
+                        if (isset($v['A']) && isset($v['B'])) {
+                            if ($v['A']) {
+                                $name = $v['A'];
+                            }
+                            
+                            $journal = Dever::db('journal/info')->one(array('name' => $name));
+                            if ($journal) {
+                                $info = Dever::db('journal/mobile')->one(array('product_id' => $journal['id'], 'mobile' => $v['B']));
+
+                                if (!$info) {
+                                    Dever::db('journal/mobile')->insert(array('product_id' => $journal['id'], 'mobile' => $v['B']));
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}

+ 224 - 0
app/journal/lib/Pay.php

@@ -0,0 +1,224 @@
+<?php
+namespace Journal\Lib;
+
+use Dever;
+
+class Pay
+{
+    private $key = 'jmss_2018';
+
+    
+    /*
+    public function go_api()
+    {
+        $where['code'] = 'null';
+        $where['type'] = 3;
+        $where['status'] = 2;
+        $data = Dever::db('act/order')->getUnCode($where);
+        echo Dever::sql();
+        if ($data) {
+            print_r($data);die;
+            foreach ($data as $k => $v) {
+                # 购买兑换码
+                $order = $v;
+                $product_num = 1;
+                $code_num = 1;
+                $uid = $order['uid'];
+                if ($order['buy_id'] > 0) {
+                    $buy = Dever::db('journal/buy_num')->one($order['buy_id']);
+                    $product_num = $buy['num'];
+                    $code_num = $buy['code'];
+                }
+                
+                if ($code_num > 1) {
+                    $product_num = intval($product_num/$code_num);
+                    for ($i = 0; $i < $code_num; $i++) {
+                        $update['code'] = Dever::load('code/lib/core')->createCode($order['cate_id'] . ',' . $order['product_id'], $order['cate_id'], $order['product_id'], $order['seller_id'], $product_num, $uid, $order['order_id']);
+                    }
+                } else {
+                    $update['code'] = Dever::load('code/lib/core')->createCode($order['cate_id'] . ',' . $order['product_id'], $order['cate_id'], $order['product_id'], $order['seller_id'], $product_num, $uid, $order['order_id']);
+                }
+
+                $update['where_id'] = $order['id'];
+                Dever::db('act/order')->update($update);
+            }
+        }
+    }
+
+
+    public function test_api()
+    {
+        $data['status'] = 1;
+        $this->order(1, 'test', $data);
+    }
+    */
+
+    # 退款操作
+    public function order($id, $name, $data)
+    {
+        $status = Dever::param('status', $data);
+
+        if ($status == 5 && $id > 0) {
+            $send = array();
+            $info = Dever::db('act/order')->one($id);
+            $send['pay_project_id'] = 1;
+            $send['pay_uid'] = $info['uid'];
+            $send['pay_order_id'] = $info['order_id'];
+            $send['pay_tk_pic'] = Dever::param('tk_pic', $data);
+            $send['pay_tk_time'] = Dever::param('tk_time', $data);
+            $send['pay_tk_desc'] = Dever::param('tk_desc', $data);
+            $send['pay_status'] = $status;
+            $send['dever_token'] = $this->key;
+
+            # 减少积分
+
+            Dever::load('pay/lib/set.updateStatus', $send);
+        }
+    }
+
+	/**
+	 * 支付成功后,调取的接口 这里的安全以后再升级吧,升级成和pay/lib/set.updateStatus一样的
+	 *
+	 * @return mixed
+	 */
+	public function act_api($param = array())
+	{
+        $send = Dever::preInput('pay_');
+        $key = md5($this->key);
+        ksort($send);
+        $send['signature'] = md5($key . '&' . http_build_query($send));
+        $signature = Dever::input('signature');
+        if ($send['signature'] == $signature) {
+            $product_id = $send['pay_product_id'];
+            $uid = $send['pay_uid'];
+            $cash = $send['pay_cash'];
+            $order_id = $send['pay_order_id'];
+            $status = $send['pay_status'];
+            $msg = $send['pay_msg'];
+
+            $order = Dever::db('act/order')->one(array('order_id' => $order_id, 'uid' => $uid));
+
+            if ($send['pay_status'] == 2 && $order) {
+                
+                $update = array();
+                $update['where_id'] = $order['id'];
+                $update['status'] = 2;
+                if ($order['type'] == 3 && !$order['code']) {
+                    $code = Dever::load('code/lib/core')->createCodeByOrder($order);
+                    if ($code) {
+                        $update['code'] = $code;
+                    }
+                }
+
+                /*
+                if ($order['type'] == 3 && !$order['code']) {
+                    # 购买兑换码
+                    $product_num = 1;
+                    $code_num = 1;
+                    if ($order['buy_id'] > 0) {
+                        $buy = Dever::db('journal/buy_num')->one($order['buy_id']);
+                        $product_num = $buy['num'];
+                        $code_num = $buy['code'];
+                    }
+                    
+                    if ($code_num > 1) {
+                        $product_num = intval($product_num/$code_num);
+                        for ($i = 0; $i < $code_num; $i++) {
+                            $update['code'] = Dever::load('code/lib/core')->createCode($order['cate_id'] . ',' . $order['product_id'], $order['cate_id'], $order['product_id'], $order['seller_id'], $product_num, $uid, $order['order_id']);
+                        }
+                    } else {
+                        $update['code'] = Dever::load('code/lib/core')->createCode($order['cate_id'] . ',' . $order['product_id'], $order['cate_id'], $order['product_id'], $order['seller_id'], $product_num, $uid, $order['order_id']);
+                    }
+                }
+                */
+
+                Dever::db('act/order')->update($update);
+
+                if ($order['type'] != 1) {
+                    return;
+                }
+
+                # 订阅
+                Dever::load('act/lib/subscribe')->submit($uid, $order['product_id'], 1);
+
+                $score = false;
+                $num = false;
+                if ($order['buy_id'] > 0) {
+                    $info = Dever::db('journal/info')->one($order['product_id']);
+                    $buy = Dever::db('journal/buy_num')->one($order['buy_id']);
+                    if ($info && $buy && $info['score'] > 0) {
+                        $score = $buy['num'] * $info['score'];
+                    } elseif ($info && $buy) {
+                        $num = $buy['num'];
+                    }
+                }
+                Dever::score($uid, 'buy_journal', '购买小刊', 'act/lib/score.submit?method=pay&type=4&id=' . $order['product_id'], $score, $num);
+
+                # 发消息
+                $journal = Dever::db('journal/info')->one($order['product_id']);
+
+                if (Dever::project('message')) {
+                    Dever::load('message/lib/data')->push(-1, $uid, '购买提醒', '购买成功,您获得了 '.$journal['name'].' 的阅读资格!', 11, $order['cate_id'], 1, Dever::load('act/lib/note')->push(4, $journal['id'], $journal['name']));
+                }
+
+                $user = Dever::db('passport/user')->one($uid);
+
+                # 发短信
+                /*
+                if (isset($user['mobile']) && $user['mobile'] && Dever::project('sms') && $order['cate_id'] == 1) {
+                    $send = array();
+                    $send['name'] = $journal['name'];
+                    Dever::load('sms/api.send', 'buy_journal', $user['mobile'], $send);
+                }
+                */
+
+                # 发模板消息
+                $wechat = Dever::db('passport/wechat')->one(array('uid' => $uid, 'type' => 1, 'system_id' => $order['cate_id']));
+                if ($wechat && Dever::project('wechat_applet')) {
+                    $send['key'] = 'buy_journal';
+                    $send['project_id'] = $order['cate_id'];
+                    $send['touser'] = $wechat['openid'];
+                    $send['page'] = Dever::config('base')->applet_index . '?scene=' . Dever::login($uid) . ',' . '4,' . $order['product_id'];
+                    $send['data'] = array
+                    (
+                        'keyword1' => array('value' => date('Y年m月d日 H:i', $order['cdate'])),
+                        'keyword2' => array('value' => '购买成功,您获得了 '.$journal['name'].' 的阅读资格!'),
+                    );
+                    $send['data'] = json_encode($send['data']);
+                    $send['form_id'] = Dever::load('act/lib/form')->get($uid, 2, $order['cate_id']);
+
+                    if ($send['form_id']) {
+                        Dever::load('wechat_applet/msg.send', $send);
+                    }
+                }
+
+            } else {
+                Dever::db('act/order')->update(array('where_id' => $order['id'], 'status' => 3));
+            }
+        }
+	}
+
+    public function send_api()
+    {
+        $uid = Dever::input('uid', 8);
+        # 发模板消息
+        $wechat = Dever::db('passport/wechat')->one(array('uid' => $uid));
+        if ($wechat && Dever::project('wechat_applet')) {
+            $send['key'] = 'buy_journal';
+            $send['project_id'] = 2;
+            $send['touser'] = $wechat['openid'];
+            $send['page'] = Dever::config('base')->applet_index . '?scene=' . Dever::login($uid) . ',' . '4,' . $order['product_id'];
+            $send['data'] = array
+            (
+                'keyword1' => array('value' => date('Y年m月d日 H:i', $order['cdate'])),
+                'keyword2' => array('value' => '购买成功,您获得了 '.$journal['name'].' 的阅读资格!'),
+            );
+            $send['data'] = json_encode($send['data']);
+            $send['form_id'] = Dever::load('act/lib/form')->get($uid, 2, $order['cate_id']);
+
+            if ($send['form_id']) {
+                Dever::load('wechat_applet/msg.send', $send);
+            }
+        }
+    }
+}

+ 76 - 0
app/journal/src/Api.php

@@ -0,0 +1,76 @@
+<?php
+
+namespace Journal\Src;
+
+use Dever;
+
+class Api
+{
+	public function data()
+	{
+		return Dever::db('journal/info')->state();
+	}
+
+	public function ding($data)
+    {
+        if (isset($data['num_add_ding']) && isset($data['num_ratio_ding'])) {
+
+            if ($data['buy'] == 1 && $data['buy_type'] == 2) {
+                # 获取明星的订阅数
+                $star = Dever::db('journal/star')->state(array('info_id' => $data['id']));
+                $data['num_ding'] = 0;
+                if ($star) {
+                    foreach ($star as $k => $v) {
+                        $data['num_ding'] += $this->starDing($v);
+                    }
+                }
+                $data['num_up'] = $data['num_add_ding'] = 0;
+                $data['num_ratio_ding'] = 1;
+
+            } elseif ($data['buy'] == 1 && $data['buy_type'] == 1) {
+                if (!$data['num_ding']) {
+                    $stat = Dever::db('stat/journal')->getNumByJournal(array('journal_id' => $data['id']));
+                    if (!$stat) {
+                        $stat['buy_num'] = 0;
+                    }
+
+                    if (!$stat['buy_num']) {
+                        $stat['buy_num'] = 0;
+                    }
+                    $data['num_ding'] = $stat['buy_num'];
+                }
+
+                $data['num_up'] = 0;
+            }
+
+            $data['num_ding'] = $data['num_ding'] + $data['num_up'];
+            $data['buy_num'] = $data['num_ding'];
+            $data['num_ding'] = round(($data['num_ding']+$data['num_add_ding'])*$data['num_ratio_ding']);
+        }
+
+        return $data;
+    }
+
+    public function starDing($data)
+    {
+        if (isset($data['num_add_ding']) && isset($data['num_ratio_ding'])) {
+
+            if (!$data['num_ding']) {
+                $stat = Dever::db('act/order')->getNumByStar(array('star_id' => $data['id'], 'product_id' => $data['info_id']));
+                if (!$stat) {
+                    $stat['buy_num'] = 0;
+                }
+
+                if (!$stat['buy_num']) {
+                    $stat['buy_num'] = 0;
+                }
+                $data['num_ding'] = $stat['buy_num'];
+            }
+            
+            $data['buy_num'] = $data['num_ding'];
+            $data['num_ding'] = round(($data['num_ding']+$data['num_add_ding'])*$data['num_ratio_ding']);
+        }
+
+        return $data;
+    }
+}

+ 71 - 0
app/journal/template/manage/journal.php

@@ -0,0 +1,71 @@
+<?php
+
+/*
+|--------------------------------------------------------------------------
+| home
+|--------------------------------------------------------------------------
+ */
+$view
+
+->fetch('.layui-fluid@test', '公告')
+
+->fetch('#url', 'var url="<{Dever::url("journal/lib/manage.updateJournalContent")}>"')
+
+->loop
+(
+    '.layui-col-md2',
+    'journal/lib/manage.journalContent',
+    array
+    (
+        'self' => array
+        (
+            'id' => 'data-<{$v.id}>',
+        ),
+        'b' => array
+        (
+            'html' => '<{date("Y/m/d", $v.cdate)}>',
+            'html' => '',
+        ),
+
+        '.img' => array
+        (
+            'style' => '<{$v.height}>',
+        ),
+
+        'img' => array
+        (
+            'src' => '<{$v.pic}>',
+            'width' => '150',
+        ),
+
+        '.info' => array
+        (
+            'html' => '<{Dever::cut($v.name, 20)}>',
+            'style' => '<{$v.info_height}>',
+        ),
+
+        '.edit' => array
+        (
+            //'onclick' => '<{$v.edit}>',
+            'href' => '<{$v.editurl}>',
+        ),
+
+        '.oper_delete' => array
+        (
+            'href' => '<{$v.delete}>',
+        ),
+
+        '.text' => array
+        (
+            'html' => '<{$v.text}>',
+        ),
+
+        'b' => array
+        (
+            'html' => '<{$v.typename}>',
+        ),
+    )
+)
+
+# display
+->display();

+ 127 - 0
app/product/database/cate.php

@@ -0,0 +1,127 @@
+<?php
+
+return array
+(
+	# 表名
+	'name' => 'cate',
+	# 显示给用户看的名称
+	'lang' => '分类设置',
+	# 后台菜单排序
+	'order' => 9,
+	# 数据结构
+	'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,
+		),
+		
+		'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('编辑'),
+		),
+	),
+
+	'request' => array
+	(
+		'state' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc','id' => 'desc'),
+			'col' => '*',
+		),
+		'getAll' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'state' => 1,
+				# 小程序去掉视频栏目
+				'id_no' => array('yes-id', '!='),
+			),
+			'type' => 'all',
+			'order' => array('reorder' => 'desc','id' => 'desc'),
+			'col' => '*',
+		),
+	),
+);

+ 178 - 0
app/product/database/info.php

@@ -0,0 +1,178 @@
+<?php
+$cate = function()
+{
+    $array = array();
+    $info = Dever::db('product/cate')->state();
+    if($info)
+    {
+        $array += $info;
+    }
+    return $array;
+};
+return array
+(
+    # 表名
+    'name' => 'info',
+    # 显示给用户看的名称
+    'lang' => '产品管理',
+    # 后台菜单排序
+    'order' => 1,
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'list'      => true,
+            'order'     => 'desc',
+        ),
+        
+        'name'      => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => '名称',
+            'default'   => '',
+            'desc'      => '名称',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'cate_id'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '所属分类',
+            'default'   => '1',
+            'desc'      => '所属分类',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => $cate,
+            'search'    => 'select',
+        ),
+
+        'price'      => array
+        (
+            'type'      => 'varchar-180',
+            'name'      => '价格',
+            'default'   => '',
+            'desc'      => '价格',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'pic'     => array
+        (
+            'type'      => 'varchar-150',
+            'name'      => '图片-图片尺寸750*750px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
+            'default'   => '',
+            'desc'      => '图片',
+            'match'     => 'option',
+            'update'  => 'image',
+            'key'       => '1',
+            'place'     => '150',
+        ),
+
+        'content'       => array
+        (
+            'type'      => 'text-255',
+            'name'      => '内容描述',
+            'default'   => '',
+            'desc'      => '内容描述',
+            'match'     => 'is_string',
+            'update'    => 'editor',
+        ),
+
+        'buy_link'      => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '购买链接-可以为空,为空则不跳转',
+            'default'   => '',
+            'desc'      => '购买链接',
+            'match'     => 'option',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+        ),
+        
+        '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})',
+        ),
+    ),
+
+    'manage' => array
+    (
+        
+    ),
+
+    'request' => array
+    (
+        'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'ids' => array('yes-id', 'in'),
+                'name' => array('yes', 'like'),
+                'id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('reorder' => 'desc', 'id' => 'desc'),
+            'limit' => '0,1000',
+            'col' => 'name as name, id, id as value, "" as selected, "" as disabled|id',
+        ),
+
+        'search' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'ids' => array('yes-id', 'in'),
+                'name' => array('yes', 'like'),
+                'id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('reorder' => 'desc', 'id' => 'desc'),
+            'limit' => '0,1000',
+            'col' => 'name as name, id, id as value, "" as selected, "" as disabled|id',
+        ),
+    ),
+);

+ 8 - 0
app/product/index.php

@@ -0,0 +1,8 @@
+<?php
+
+define('DEVER_APP_NAME', 'product');
+define('DEVER_APP_LANG', '商品管理');
+define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+define('DEVER_MANAGE_ORDER', 100);
+define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-tower layui-icon-app');
+include(DEVER_APP_PATH . '../boot.php');

+ 23 - 0
app/product/lib/Info.php

@@ -0,0 +1,23 @@
+<?php
+
+namespace Product\Lib;
+
+use Dever;
+
+class Info
+{
+    public function get($ids)
+    {
+        $data = Dever::db('product/info')->getByIds($ids);
+        
+        if (!$data) {
+            Dever::alert('错误的产品信息');
+        }
+    
+        foreach ($data as $k => $v) {
+            $data[$k]['cate'] = Dever::db('product/cate')->one($v['cate_id']);
+        }
+
+        return $data;
+    }
+}

+ 56 - 0
app/stat/assets/manage/html/journal.html

@@ -0,0 +1,56 @@
+<style>
+.layui-col-md2
+{
+    height: 250px;
+    border:1px solid #bababa;
+    margin:5px;
+}
+.layui-col-md2 .img
+{
+    text-align: center;overflow: hidden;text-align: center;
+}
+</style>
+<div class="layui-fluid layadmin-cmdlist-fluid">
+  <ul class="layui-row layui-col-space30" id="sortable">
+    <li class="layui-col-md2 layui-col-sm4" id="data" style="">
+        <div class="cmdlist-container">
+            <div href="javascript:;" class="img" style="height: 154px;">
+              <img src="../../layuiadmin/style/res/template/portrait.png">
+            </div>
+            <a href="javascript:;" >
+              <div class="cmdlist-text" style="text-align:center;">
+                <p class="info">2018春夏季新款港味短款白色T恤+网纱中长款chic半身裙套装两件套</p>
+                <div class="price">
+                    <b></b>
+                </div>
+
+                <div class="text"></div>
+                
+
+                <div style="margin-top:10px;text-align:center;">
+                <div class="layui-table-cell"><a href="javascript:;" class="edit" onclick=""><button type="button" class="btn btn-info btn-rounded waves-effect waves-light m-b-5 layui-btn layui-btn-xs">编辑</button></a>&nbsp;&nbsp;<a href="#" class="oper_delete"><button type="button" class="btn btn-info btn-rounded waves-effect waves-light m-b-5 layui-btn layui-btn-danger layui-btn-xs"><span class="am-icon-trash-o"></span>删除</button></a>&nbsp;&nbsp;</div>
+                </div>
+              </div>
+            </a>
+        </div>
+    </li>
+  </ul>
+</div>
+
+<script id="url">var url = ""</script>
+<script>
+  $( function() {
+    var sort = $( "#sortable" ).sortable({
+        opacity: 0.7,
+        stop:function(){
+          var arr = $( "#sortable" ).sortable('toArray');
+          arr = arr.join(',');
+          $.post(url, {data:arr}, function()
+          {
+
+          })
+        }
+    });
+    $( "#sortable" ).disableSelection();
+  } );
+  </script>

+ 310 - 0
app/stat/database/journal.php

@@ -0,0 +1,310 @@
+<?php
+# 获取电子刊分类权限
+$auth = Dever::tops();
+
+# 如果用linkage,那么下面这两个用不上了
+$journal = function() use ($auth)
+{
+    $array = array();
+    if ($auth) {
+        $info = Dever::db('journal/info')->getIds(array('cate_id' => $auth, 'buy' => 1));
+    } else {
+        $info = Dever::db('journal/info')->state(array('buy' => 1));
+    }
+    
+    if($info)
+    {
+        $array += $info;
+    }
+    return $array;
+};
+
+$cate = function() use ($auth)
+{
+    $array = array();
+    if ($auth) {
+        $info = Dever::db('journal/cate')->getIds(array('ids' => $auth));
+    } else {
+        $info = Dever::db('journal/cate')->state();
+    }
+    
+    if($info)
+    {
+        $array += $info;
+    }
+    return $array;
+};
+
+$zhou = Dever::input('search_zhou');
+if ($zhou) {
+    $group = 'cate_id';
+} else {
+    $group = 'day_int,cate_id';
+}
+
+$list = array
+(
+    # 匹配的正则或函数 选填项
+    'option' => array
+    (
+
+        'start_day_int' => array('yes-day_int', '>='),
+        'end_day_int' => array('yes-day_int', '<='),
+        'cate_id' => 'yes',
+        'journal_id' => 'yes',
+        'state' => 1,
+    ),
+    'type' => 'all',
+    'order' => array('day_int' => 'desc', 'id' => 'desc'),
+    'group' => $group,
+    'page' => array(20, 'list'),
+    //'col' => 'id,sum(order_num) as order_num,sum(order_yes_num) as order_yes_num,sum(order_no_num) as order_no_num,sum(buy_num) as buy_num,sum(buy_cash) as buy_cash,cdate,journal_id,day_int,day_string,cate_id',
+    'col' => 'id,sum(order_yes_num) as order_yes_num,sum(buy_num) as buy_num,sum(buy_cash) as buy_cash,cdate,journal_id,day_int,day_string,cate_id',
+);
+
+//$search = Dever::input('search_option_journal_id');
+$search = Dever::input('search_linkage_cate_journal');
+
+$groupState = false;
+if ($search) {
+    if ($search != -1 && isset($search[1]) && $search[1] > 0) {
+        $list['option']['journal_id'] = $search[1];
+        Dever::setInput('search_option_journal_id', $search[1]);
+    } elseif (isset($search[0]) && $search[0] == -1) {
+        Dever::setInput('search_option_journal_id', 0);
+        $groupState = true;
+    } else {
+        $groupState = true;
+    }
+} else {
+    $groupState = true;
+}
+
+if (!$zhou && !$groupState) {
+    unset($list['group']);
+    $list['col'] = '*';
+}
+
+
+if ($auth) {
+    $list['option']['cate_id'] = array($auth, 'in');
+}
+
+return array
+(
+    # 表名
+    'name' => 'journal',
+    # 显示给用户看的名称
+    'lang' => '电子刊订单统计',
+    'order' => '10',
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            //'list'        => true,
+        ),
+
+        'day_string'       => array
+        (
+            'type'      => 'varchar-60',
+            'name'      => '统计日期',
+            'default'   => '',
+            'desc'      => '统计日期',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            //'search'    => 'fulltext',
+            'list'      => $zhou ? false : true,
+        ),
+
+        'day_int'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '统计日期',
+            'default'   => '',
+            'desc'      => '统计日期',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            'search'    => 'time',
+            'order'     => 'desc',
+            //'list'        => true,
+        ),
+
+        'cate_journal'     => array
+        (
+            'name'      => '电子刊',
+            'default'   => '',
+            'desc'      => '电子刊',
+            'search'    => 'linkage',
+            'search_col' => 'cate_id,product_id',
+            'option'    => Dever::url('lib/manage.search_cate_journal', 'journal'),
+        ),
+
+        'cate_id'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '电子刊分类',
+            'default'   => '1',
+            'desc'      => '电子刊分类',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => $cate,
+            //'search'    => 'select',
+            'list'      => true,
+        ),
+
+        'journal_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '电子刊',
+            'default'   => '',
+            'desc'      => '电子刊',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            //'search'    => 'select',
+            'option'    => $journal,
+            'list'      => $zhou ? false : 'Dever::load("stat/lib/manage.info", {journal_id})',
+        ),
+
+        'order_num'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '总订单',
+            'default'   => '0',
+            'match'     => '总订单数',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            //'list'      => true,
+        ),
+
+        'order_yes_num'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '支付订单',
+            'default'   => '0',
+            'match'     => '支付订单数',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            'list'      => true,
+        ),
+
+        'order_no_num'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '未支付订单',
+            'default'   => '0',
+            'match'     => '未支付订单数',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            //'list'      => true,
+        ),
+
+        'buy_num'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '售出本数',
+            'default'   => '0',
+            'match'     => '售出本数',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            'list'      => true,
+        ),
+
+        'buy_cash'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '售出金额',
+            'default'   => '0',
+            'match'     => '售出金额',
+            'match'     => 'is_numeric',
+            '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", {cdate})',
+        ),
+    ),
+
+    //'top' => Dever::config('base')->top,
+    'top_option' => array
+    (
+        array
+        (
+            'value' => $auth,
+            'col' => 'cate_id',
+        ),
+        array
+        (
+            'value' => Dever::load('manage/auth.authData'),
+            'col' => 'id',
+        ),
+    ),
+
+    'manage' => array
+    (
+        'insert' => false,
+        'edit' => false,
+        'delete' => false,
+        'num' => false,
+        'excel' => true,
+
+        //'page_list' => 'journal',
+    ),
+
+    'request' => array
+    (
+        'list' => $list,
+
+        'getData' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'start' => array('yes-day_int', '>='),
+                'end' => array('yes-day_int', '<='),
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('day_int' => 'desc'),
+            //'group' => 'day_int',
+            'col' => '*',
+        ),
+
+        'getNumByJournal' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'journal_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'one',
+            //'group' => 'day_int',
+            'col' => 'sum(buy_num) as buy_num',
+        ),
+    ),
+);

+ 289 - 0
app/stat/database/seller.php

@@ -0,0 +1,289 @@
+<?php
+# 获取电子刊分类权限
+$auth = Dever::tops();
+
+# 如果用linkage,那么下面这两个用不上了
+$journal = function() use ($auth)
+{
+    $array = array();
+    if ($auth) {
+        $info = Dever::db('journal/info')->getIds(array('cate_id' => $auth, 'buy' => 1));
+    } else {
+        $info = Dever::db('journal/info')->state(array('buy' => 1));
+    }
+    if($info)
+    {
+        $array += $info;
+    }
+    return $array;
+};
+
+$cate = function() use ($auth)
+{
+    $array = array();
+    if ($auth) {
+        $info = Dever::db('journal/cate')->getIds(array('ids' => $auth));
+    } else {
+        $info = Dever::db('journal/cate')->state();
+    }
+    
+    if($info)
+    {
+        $array += $info;
+    }
+    return $array;
+};
+$seller = function()
+{
+    $array = array();
+    $info = Dever::db('code/seller')->state();
+    if($info)
+    {
+        $array += $info;
+    }
+    return $array;
+};
+
+$zhou = Dever::input('search_zhou');
+if ($zhou) {
+    $group = 'seller_id,cate_id';
+} else {
+    $group = 'day_int,seller_id,cate_id';
+}
+
+$list = array
+(
+    # 匹配的正则或函数 选填项
+    'option' => array
+    (
+
+        'start_day_int' => array('yes-day_int', '>='),
+        'end_day_int' => array('yes-day_int', '<='),
+        'seller_id' => 'yes',
+        'cate_id' => 'yes',
+        'journal_id' => 'yes',
+        'state' => 1,
+    ),
+    'type' => 'all',
+    'order' => array('day_int' => 'desc', 'id' => 'desc'),
+    'group' => $group,
+    'page' => array(20, 'list'),
+    'col' => 'id,sum(code_num) as code_num,sum(code_yes_num) as code_yes_num,sum(code_no_num) as code_no_num,sum(code_drop_num) as code_drop_num,cdate,journal_id,seller_id,day_int,day_string,cate_id',
+);
+
+//$search = Dever::input('search_option_journal_id');
+$search = Dever::input('search_linkage_cate_journal');
+if ($search && $search != -1 && isset($search[1]) && $search[1] > 0) {
+    $list['option']['journal_id'] = $search[1];
+    Dever::setInput('search_option_journal_id', $search[1]);
+}
+if (!$zhou) {
+    unset($list['group']);
+    $list['col'] = 'id,code_num,code_yes_num,code_no_num,code_drop_num,cdate,journal_id,seller_id,day_int,day_string,cate_id';
+}
+
+if ($auth) {
+    $list['option']['cate_id'] = array($auth, 'in');
+}
+
+$config = array
+(
+    # 表名
+    'name' => 'seller',
+    # 显示给用户看的名称
+    'lang' => '销售商订单统计',
+    'order' => '8',
+    'menu' => false,
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            //'list'        => true,
+        ),
+
+        'day_string'       => array
+        (
+            'type'      => 'varchar-60',
+            'name'      => '统计日期',
+            'default'   => '',
+            'desc'      => '统计日期',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            //'search'    => 'fulltext',
+            'list'      => $zhou ? false : true,
+        ),
+
+        'day_int'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '统计日期',
+            'default'   => '',
+            'desc'      => '统计日期',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            'search'    => 'time',
+            'order'     => 'desc',
+            //'list'        => true,
+        ),
+
+        'seller_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '销售商',
+            'default'   => '',
+            'desc'      => '销售商',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'search'    => 'select',
+            'option'    => $seller,
+            'list'      => true,
+        ),
+
+        'cate_journal'     => array
+        (
+            'name'      => '电子刊',
+            'default'   => '',
+            'desc'      => '电子刊',
+            'search'    => 'linkage',
+            'search_col' => 'cate_id,product_id',
+            'option'    => Dever::url('lib/manage.search_cate_journal', 'journal'),
+        ),
+
+        'cate_id'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '电子刊分类',
+            'default'   => '1',
+            'desc'      => '电子刊分类',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => $cate,
+            //'search'    => 'select',
+            'list'      => true,
+        ),
+
+        'journal_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '电子刊',
+            'default'   => '',
+            'desc'      => '电子刊',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            //'search'    => 'select',
+            'option'    => $journal,
+            'list'      => $zhou ? false : 'Dever::load("stat/lib/manage.info", {journal_id}, true)',
+        ),
+
+        'code_num'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '兑换码总数量',
+            'default'   => '0',
+            'match'     => '兑换码总数量',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            //'list'      => true,
+        ),
+
+        'code_yes_num'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '兑换码已用数',
+            'default'   => '0',
+            'match'     => '兑换码已用数',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            'list'      => true,
+        ),
+
+        'code_no_num'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '兑换码未用数',
+            'default'   => '0',
+            'match'     => '兑换码未用数',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            'list'      => true,
+        ),
+
+        'code_drop_num'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '兑换码作废数',
+            'default'   => '0',
+            'match'     => '兑换码作废数',
+            'match'     => 'is_numeric',
+            '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", {cdate})',
+        ),
+    ),
+
+    'top' => Dever::config('base')->top,
+
+    'manage' => array
+    (
+        'insert' => false,
+        'edit' => false,
+        'delete' => false,
+        'num' => false,
+        'excel' => true,
+
+        //'page_list' => 'journal',
+    ),
+
+    'request' => array
+    (
+        'list' => $list,
+
+        'getData' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'start' => array('yes-day_int', '>='),
+                'end' => array('yes-day_int', '<='),
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('day_int' => 'desc'),
+            //'group' => 'day_int',
+            'col' => '*',
+        ),
+    ),
+);
+
+
+if ($search && $search > 0) {
+	
+}
+return $config;

+ 8 - 0
app/stat/index.php

@@ -0,0 +1,8 @@
+<?php
+
+define('DEVER_APP_NAME', 'stat');
+define('DEVER_APP_LANG', '运营管理');
+define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+define('DEVER_MANAGE_ORDER', 100);
+define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-tower layui-icon-chart-screen');
+include(DEVER_APP_PATH . '../boot.php');

+ 135 - 0
app/stat/lib/Journal.php

@@ -0,0 +1,135 @@
+<?php
+
+namespace Stat\Lib;
+
+use Dever;
+
+class Journal
+{
+    const NUM = 3;
+
+    public function data_api()
+    {
+
+    }
+    /**
+     * 获取数据-可以放到cron里
+     *
+     * @return mixed
+     */
+    public function data()
+    {
+        # 获取最近self::NUM天的数据
+        $num = Dever::input('num', self::NUM);
+
+        $day = Dever::input('day');
+        if ($day) {
+            $day = Dever::maketime($day);
+        } else {
+            $day = time();
+        }
+        $start = date('Y-m-d 00:00:00', $day);
+        $option = array
+        (
+            'state' => 1,
+            'start' => array('yes-cdate', '>'),
+            'end' => array('yes-cdate', '<'),
+        );
+        $where['option'] = $option;
+
+        $info_where['buy'] = 1;
+        $hot = Dever::input('hot');
+        if ($hot) {
+            $info_where['hot'] = $hot;
+        }
+        
+        $journal = Dever::db('journal/info')->state($info_where);
+
+        if ($journal) {
+            for ($i = 0; $i < $num; $i++) {
+                $where['start'] = strtotime("$start -$i day");
+                $where['end'] = $where['start'] + 86399;
+                foreach ($journal as $k => $v) {
+                    $this->total($v, $where);
+                }
+            }
+        }
+        return true;
+    }
+
+    private function total($info, $where)
+    {
+        # 这里就是为了做下sql的实现方式,其实用dever自带的功能完全可以实现。
+        $day = date('Y-m-d', $where['start']);
+        $order_num = $order_yes_num = $order_no_num = $buy_num = $buy_cash = 0;
+
+        $sql = 'select * from mars_act_order where type = 3 and product_id = '.$info['id'].' and status = 2 and state = 1 and cdate >= '.$where['start'].' and cdate <= '.$where['end'];
+        $order = Dever::db('act/order')->fetchAll($sql);
+        if ($order) {
+            
+            foreach ($order as $k => $v) {
+                $order_num++;
+                if ($v['status'] == 1) {
+                    # 待支付
+                    $order_no_num++;
+                } elseif ($v['status'] == 2) {
+                    # 已支付
+                    $order_yes_num++;
+
+                    if ($v['buy_num'] > 0) {
+                        $buy_num += $v['buy_num'];
+                    } elseif ($v['buy_id'] && $v['buy_id'] > 0) {
+                        $buy = Dever::db('journal/buy_num')->one($v['buy_id']);
+                        if ($buy['num']) {
+                            $buy_num += $buy['num'];
+                        }
+                    }
+
+                    if ($v['cash']) {
+                        $buy_cash += $v['cash'];
+                    }
+                }
+            }
+        }
+
+        $this->update($info['cate_id'], $info['id'], $day, $order_num, $order_yes_num, $order_no_num, $buy_num, $buy_cash);
+    }
+
+    public function update($cate_id, $info_id, $day, $order_num, $order_yes_num, $order_no_num, $buy_num, $buy_cash)
+    {
+        $update = array();
+        $update['day_string'] = $day;
+        $update['day_int'] = Dever::maketime($day);
+        //$update['order_num'] = $order_num;
+        $update['order_yes_num'] = $order_yes_num;
+        //$update['order_no_num'] = $order_no_num;
+        $update['buy_num'] = $buy_num;
+        $update['buy_cash'] = $buy_cash;
+        $update['cate_id'] = $cate_id;
+        $update['journal_id'] = $info_id;
+        $update['cdate'] = time();
+
+        $where = array();
+        $where['day_int'] = $update['day_int'];
+        $where['journal_id'] = $update['journal_id'];
+
+        $info = Dever::db('stat/journal')->one($where);
+        if (!$info) {
+            $id = Dever::db('stat/journal')->insert($update);
+        } else {
+            $id = $info['id'];
+            $update['where_id'] = $id;
+            Dever::db('stat/journal')->update($update);
+        }
+
+        $stat = Dever::db('stat/journal')->getNumByJournal(array('journal_id' => $where['journal_id']));
+        if ($stat && $stat['buy_num']) {
+            Dever::config('base')->after = 1;
+            $set['num_ding'] = $stat['buy_num'];
+            $set['where_id'] = $where['journal_id'];
+            Dever::db('journal/info')->update($set);
+
+            Dever::load('act/lib/num')->setCounter($set['where_id'], $set['num_ding']);
+        }
+    }
+}

+ 22 - 0
app/stat/lib/Manage.php

@@ -0,0 +1,22 @@
+<?php
+
+namespace Stat\Lib;
+
+use Dever;
+
+class Manage
+{
+    public function info($id, $state = false)
+    {
+    	$input_id = Dever::input('search_option_journal_id');
+        if ($input_id > 0 || $state) {
+            if (!$input_id) {
+                $input_id = $id;
+            }
+        	$info = Dever::db('journal/info')->one($input_id);
+        	return $info['name'];
+        } else {
+        	return '合计';
+        }
+    }
+}

+ 112 - 0
app/stat/lib/Seller.php

@@ -0,0 +1,112 @@
+<?php
+
+namespace Stat\Lib;
+
+use Dever;
+
+class Seller
+{
+    const NUM = 3;
+
+    public function data_api()
+    {
+
+    }
+    /**
+     * 获取数据-可以放到cron里
+     *
+     * @return mixed
+     */
+    public function data()
+    {
+        # 获取最近self::NUM天的数据
+        $num = Dever::input('num', self::NUM);
+
+        $day = Dever::input('day');
+        if ($day) {
+            $day = Dever::maketime($day);
+        } else {
+            $day = time();
+        }
+        $start = date('Y-m-d 00:00:00', $day);
+        $option = array
+        (
+            'state' => 1,
+            'start' => array('yes-cdate', '>'),
+            'end' => array('yes-cdate', '<'),
+        );
+        $where['option'] = $option;
+
+        $seller = Dever::db('code/seller')->state();
+        $journal = Dever::db('journal/info')->state(array('buy' => 1));
+
+        if ($seller && $journal) {
+        	foreach ($seller as $sk => $sv) {
+        		for ($i = 0; $i < $num; $i++) {
+        			$where['start'] = strtotime("$start -$i day");
+	                $where['end'] = $where['start'] + 86399;
+        			foreach ($journal as $k => $v) {
+	                    $this->total($sv, $v, $where);
+		            }
+                }
+            }
+        }
+        return true;
+    }
+
+    private function total($seller, $info, $where)
+    {
+    	$day = date('Y-m-d', $where['start']);
+        $sql = 'select * from mars_code_info where seller_id = '.$seller['id'].' and product_id = '.$info['id'].' and state = 1 and cdate >= '.$where['start'].' and cdate <= '.$where['end'];
+        $code = Dever::db('code/info')->fetchAll($sql);
+
+        $code_num = $code_yes_num = $code_no_num = $code_drop_num = 0;
+
+        if ($code) {
+            foreach ($code as $k => $v) {
+                $code_num++;
+                if ($v['type'] <= 2) {
+                    # 未使用
+                    $code_no_num++;
+                } elseif ($v['type'] == 3) {
+                    # 已使用
+                    $code_yes_num++;
+                } elseif ($v['type'] == 4) {
+                    # 已作废
+                    $code_drop_num++;
+                }
+            }
+        }
+
+        $this->update($seller['id'], $info['cate_id'], $info['id'], $day, $code_num, $code_yes_num, $code_no_num, $code_drop_num);
+    }
+
+    public function update($seller_id, $cate_id, $info_id, $day, $code_num, $code_yes_num, $code_no_num, $code_drop_num)
+    {
+        $update = array();
+        $update['day_string'] = $day;
+        $update['day_int'] = Dever::maketime($day);
+        $update['code_num'] = $code_num;
+        $update['code_yes_num'] = $code_yes_num;
+        $update['code_no_num'] = $code_no_num;
+        $update['code_drop_num'] = $code_drop_num;
+        $update['seller_id'] = $seller_id;
+        $update['cate_id'] = $cate_id;
+        $update['journal_id'] = $info_id;
+        $update['cdate'] = time();
+
+        $where = array();
+        $where['day_int'] = $update['day_int'];
+        $where['seller_id'] = $update['seller_id'];
+        $where['journal_id'] = $update['journal_id'];
+
+        $info = Dever::db('stat/seller')->one($where);
+        if (!$info) {
+            $id = Dever::db('stat/seller')->insert($update);
+        } else {
+            $id = $info['id'];
+            $update['where_id'] = $id;
+            Dever::db('stat/seller')->update($update);
+        }
+    }
+}

+ 71 - 0
app/stat/template/manage/journal.php

@@ -0,0 +1,71 @@
+<?php
+
+/*
+|--------------------------------------------------------------------------
+| home
+|--------------------------------------------------------------------------
+ */
+$view
+
+->fetch('.layui-fluid@test', '公告')
+
+->fetch('#url', 'var url="<{Dever::url("journal/lib/manage.updateJournalContent")}>"')
+
+->loop
+(
+    '.layui-col-md2',
+    'journal/lib/manage.journalContent',
+    array
+    (
+        'self' => array
+        (
+            'id' => 'data-<{$v.id}>',
+        ),
+        'b' => array
+        (
+            'html' => '<{date("Y/m/d", $v.cdate)}>',
+            'html' => '',
+        ),
+
+        '.img' => array
+        (
+            'style' => '<{$v.height}>',
+        ),
+
+        'img' => array
+        (
+            'src' => '<{$v.pic}>',
+            'width' => '150',
+        ),
+
+        '.info' => array
+        (
+            'html' => '<{Dever::cut($v.name, 20)}>',
+            'style' => '<{$v.info_height}>',
+        ),
+
+        '.edit' => array
+        (
+            //'onclick' => '<{$v.edit}>',
+            'href' => '<{$v.editurl}>',
+        ),
+
+        '.oper_delete' => array
+        (
+            'href' => '<{$v.delete}>',
+        ),
+
+        '.text' => array
+        (
+            'html' => '<{$v.text}>',
+        ),
+
+        'b' => array
+        (
+            'html' => '<{$v.typename}>',
+        ),
+    )
+)
+
+# display
+->display();

+ 24 - 70
config/env/localhost/default.php

@@ -45,7 +45,7 @@ $config['database'] = array
 		'charset' => 'utf8mb4',
 	),
 
-    'session' => array
+    'sessions' => array
     (
         'type' => 'redis',
         'host' => isset($dc['redis']) ? $dc['redis'][0]['host'] : 'server-redis',
@@ -62,40 +62,10 @@ $config['database'] = array
     )
 );
 
-/*
-$dc['mysql_user'] = array
-(
-    'host' => array
-    (
-        'read' => 'web-mysql:3306',
-        'update' => 'web-mysql:3306',
-    ),
-    'database' => 'wonderful',
-    'username' => 'root',
-    'password' => '123456',
-);
-*/
-
-
-# 设置哪些项目需要切换到弹性数据库
-if (isset($dc['mysql_user'])) {
-    $dc['mysql_user']['charset'] = 'utf8';
-    $dc['mysql_user']['database'] = 'wonderful_act';
-    $dc['mysql_user']['type'] = 'pdo';
-    $config['database']['code'] = $dc['mysql_user'];
-    $config['database']['act'] = $dc['mysql_user'];
-    $config['database']['passport'] = $dc['mysql_user'];
-    $config['database']['pay'] = $dc['mysql_user'];
-    $config['database']['score'] = $dc['mysql_user'];
-    $config['database']['message'] = $dc['mysql_user'];
-    $config['database']['oauth'] = $dc['mysql_user'];
-    $config['database']['wechat'] = $dc['mysql_user'];
-}
-
 if (DEVER_APP_NAME == 'tests' && isset($dc['mysql_test'])) {
     # 测试
     $dc['mysql_test']['charset'] = 'utf8';
-    $dc['mysql_test']['database'] = 'wonderful_test';
+    $dc['mysql_test']['database'] = 'mars_test';
     $dc['mysql_test']['type'] = 'pdo';
     $config['database']['default'] = $dc['mysql_test'];
     $config['database']['code'] = $dc['mysql_test'];
@@ -142,13 +112,11 @@ $config['cache'] = array
         'buy_my_code' => 0,
         'buy_codedetail' => 0,
         'buy.pay' => 0,
-        'journal_v1.top' => 600,
-        'journal_v1.subscribe' => 0,
-        'journal_v1.getView' => 0,
-        //'journal_v1.getList' => 0,
-        'journal_v1.view' => 0,
-        'tests_api.user' => 0,
-        'tests_api.buy' => 0,
+        'journal.top' => 600,
+        'journal.subscribe' => 0,
+        'journal.getView' => 0,
+        //'journal.getList' => 0,
+        'journal.view' => 0,
         'stat_' => 0,
         'buy_' => 0,
         'order_' => 0,
@@ -166,14 +134,12 @@ $config['cache'] = array
             'content.ad',
             'journal.home',
             'journal.getList',
-            'journal_v1.home',
-            'journal_v1.getList',
-            'journal_v1.top',
-            'journal_v1.buy',
-            'journal_v1.read',
-            'journal_v1.getAppList',
-            'journal_v1.getView',
-            'journal_v1.getAppView',
+            'journal.top',
+            'journal.buy',
+            'journal.read',
+            'journal.getAppList',
+            'journal.getView',
+            'journal.getAppView',
             'buy_list',
             'buy_pay',
         ),
@@ -186,14 +152,12 @@ $config['cache'] = array
             'content.ad',
             'journal.home',
             'journal.getList',
-            'journal_v1.home',
-            'journal_v1.getList',
-            'journal_v1.top',
-            'journal_v1.buy',
-            'journal_v1.read',
-            'journal_v1.getAppList',
-            'journal_v1.getView',
-            'journal_v1.getAppView',
+            'journal.top',
+            'journal.buy',
+            'journal.read',
+            'journal.getAppList',
+            'journal.getView',
+            'journal.getAppView',
             'buy_list',
             'buy_pay',
         ),
@@ -211,6 +175,7 @@ $config['cache'] = array
     # 缓存保存方式,支持多个数据源、多台缓存服务器
     'store' => array
     (
+        /*
         array
         (
             'host' => 'server-redis',
@@ -218,6 +183,7 @@ $config['cache'] = array
             'weight' => 100,
             'password' => 'dm_redis_123',
         ),
+        */
     ),
 );
 
@@ -242,8 +208,8 @@ if (DEVER_APP_NAME == 'source') {
 
 $host = 'http://'.$local . '/';
 
-$upload = $host . 'upload/';
-$uploadcdn = $host . 'upload/data/';
+$upload = $host . 'mars/package/';
+$uploadcdn = $host . 'mars/data/';
 
 $config['host'] = array
 (
@@ -251,22 +217,10 @@ $config['host'] = array
     'uploadRes'     => isset($dc['res']) && $dc['res'] ? $dc['res'] : $uploadcdn . 'upload/',
     'project' => array
     (
-        'upload' => array
-        (
-            'path' => $host. 'upload/upload/?',
-        ),
-        'pays' => array
-        (
-            'path' => $host. 'pay/pay/?',
-        ),
-        'wechat_applet' => array
+        'wechat_applets' => array
         (
             'path' => $host. 'wechat/wechat_applet/?',
         ),
-        'jingpin' => array
-        (
-            'path' => 'http://192.168.33.10/jingpin/content/?'
-        ),
     ),
 );
 

+ 116 - 80
doc/apidoc.php

@@ -33,7 +33,7 @@
  * @apiDescription 类型设置说明
  *
  * @apiParam {String} source_type 请在header中定义,ios:ios | android:android | 移动h5:h5  | 小程序:applet | 公众号:service | pc网站:pc
- * @apiParam {Number} type 图文:1 | 视频:2 | 直播:3 | 小刊:4 | 小刊音视频:5 | 专题:6 | 小程序:7 | 商品:8 | 链接:10 | 评论: 11 || 直播评论:12 | 刊活动页:13
+ * @apiParam {Number} type 图文:1 | 视频:2 | 直播:3 | 电子刊:4 | 电子刊音视频:5 | 专题:6 | 小程序:7 | 商品:8 | 链接:10 | 评论: 11 || 直播评论:12 | 电子刊活动页:13
  * @apiParam {Number} push_ 所有带push_开头的返回参数,返回字典都是一样的,参考获取首页数据中的push_focus
  */
 
@@ -73,7 +73,7 @@
  */
 
 /**
- * @api {get} wonderful/passport/?l=applet.update 更新用户信息
+ * @api {get} mars/passport/?l=applet.update 更新用户信息
  * @apiVersion 1.0.0
  * @apiName applet.update
  * @apiGroup AppletPassport
@@ -100,7 +100,7 @@
 
 
 /**
- * @api {get} wonderful/passport/?l=applet.mobile 更新用户手机号-微信绑定
+ * @api {get} mars/passport/?l=applet.mobile 更新用户手机号-微信绑定
  * @apiVersion 1.0.0
  * @apiName applet.mobile
  * @apiGroup AppletPassport
@@ -120,7 +120,7 @@
  */
 
 /**
- * @api {get} wonderful/passport/?l=applet.bind_mobile 更新用户手机号-验证码绑定
+ * @api {get} mars/passport/?l=applet.bind_mobile 更新用户手机号-验证码绑定
  * @apiVersion 1.0.0
  * @apiName applet.bind_mobile
  * @apiGroup AppletPassport
@@ -138,7 +138,7 @@
  */
 
 /**
- * @api {get} wonderful/passport/?l=reg.getMCode 获取手机验证码
+ * @api {get} mars/passport/?l=reg.getMCode 获取手机验证码
  * @apiVersion 1.0.0
  * @apiName reg.getMCode
  * @apiGroup AppletPassport
@@ -151,7 +151,7 @@
  */
 
 /**
- * @api {get} wonderful/passport/?l=reg.getMCode 获取手机验证码,未登录状态
+ * @api {get} mars/passport/?l=reg.getMCode 获取手机验证码,未登录状态
  * @apiVersion 1.0.0
  * @apiName reg.getMCode
  * @apiGroup AppPassport
@@ -164,7 +164,7 @@
  */
 
 /**
- * @api {get} wonderful/passport/?l=reg.getMCodeLogin 获取手机验证码,已登录状态
+ * @api {get} mars/passport/?l=reg.getMCodeLogin 获取手机验证码,已登录状态
  * @apiVersion 1.0.0
  * @apiName reg.getMCode
  * @apiGroup AppPassport
@@ -178,7 +178,7 @@
  */
 
 /**
- * @api {get} wonderful/passport/?l=app.login 登录与注册
+ * @api {get} mars/passport/?l=app.login 登录与注册
  * @apiVersion 1.0.0
  * @apiName app.login
  * @apiGroup AppPassport
@@ -193,7 +193,7 @@
  */
 
 /**
- * @api {get} wonderful/passport/?l=app.login_uuid UUID登录
+ * @api {get} mars/passport/?l=app.login_uuid UUID登录
  * @apiVersion 1.0.0
  * @apiName app.login_uuid
  * @apiGroup AppPassport
@@ -207,7 +207,7 @@
  */
 
 /**
- * @api {get} wonderful/passport/?l=app.bind_mobile 更新用户手机号-验证码绑定
+ * @api {get} mars/passport/?l=app.bind_mobile 更新用户手机号-验证码绑定
  * @apiVersion 1.0.0
  * @apiName app.bind_mobile
  * @apiGroup AppPassport
@@ -225,7 +225,7 @@
  */
 
 /**
- * @api {get} wonderful/passport/?l=app.wechat_reg 第三方登录-已经拥有openid
+ * @api {get} mars/passport/?l=app.wechat_reg 第三方登录-已经拥有openid
  * @apiVersion 1.0.0
  * @apiName app.wechat_reg
  * @apiGroup AppPassport
@@ -250,7 +250,7 @@
  */
 
 /**
- * @api {get} wonderful/oauth/?l=request.callback 第三方登录
+ * @api {get} mars/oauth/?l=request.callback 第三方登录
  * @apiVersion 1.0.0
  * @apiName request.callback
  * @apiGroup AppPassport
@@ -270,7 +270,7 @@
  */
 
 /**
- * @api {get} wonderful/passport/?l=app.update 更新用户信息
+ * @api {get} mars/passport/?l=app.update 更新用户信息
  * @apiVersion 1.0.0
  * @apiName app.update
  * @apiGroup AppPassport
@@ -290,7 +290,7 @@
  */
 
 /**
- * @api {get} wonderful/main/?l=view.getHtml 获取富文本内容
+ * @api {get} mars/main/?l=view.getHtml 获取富文本内容
  * @apiVersion 1.0.0
  * @apiName view.getHtml
  * @apiGroup App
@@ -298,8 +298,8 @@
  * @apiDescription 获取富文本内容
  *
  * @apiParam {Number} signature 用户signature
- * @apiParam {String} type 类型1为图文、2为视频、3为直播、4刊内容,6为专题
- * @apiParam {String} id 图文等内容id,如果为4,则为小刊的内容id,而非小刊id
+ * @apiParam {String} type 类型1为图文、2为视频、3为直播、4电子刊内容,6为专题
+ * @apiParam {String} id 图文等内容id,如果为4,则为电子刊的内容id,而非电子刊id
  *
  * @apiSuccess {String}   html 直接返回html的信息,请注意里面的协议:jstyle://live_note?id=0&live_id=1&file=test
 
@@ -315,7 +315,7 @@
  */
 
 /**
- * @api {get} wonderful/main/?l=user.submit_comment 提交评论
+ * @api {get} mars/main/?l=user.submit_comment 提交评论
  * @apiVersion 1.0.0
  * @apiName user.submit_comment
  * @apiGroup UserAction
@@ -331,28 +331,38 @@
  */
 
 /**
- * @api {get} mars/main/?l=journal.getList 小程序刊列表
+ * @api {get} mars/main/?l=journal.getList 小程序电子刊列表
  * @apiVersion 2.0.0
  * @apiName journal.getList
  * @apiGroup Journal
  *
- * @apiDescription 小刊列表,按照分类读取,根据获取的信息,可以直接进入到小刊详情页,无需再次请求接口。
+ * @apiDescription 电子刊列表,按照分类读取,根据获取的信息,可以直接进入到电子刊详情页,无需再次请求接口。
  *
  * @apiParam {String} signature signature
  * @apiParam {String} system 分类id,默认为1,传入-1就是获取全部
  *
- * @apiSuccess {Object[]} journal 小刊数据列表
- * @apiSuccess {String}   journal.id 小刊id
+ * @apiSuccess {Number}   uid  用户id 所有接口中都有该项
+ * @apiSuccess {Object[]} config 基本配置 所有接口中都有该项
+ * @apiSuccess {String}   config.name 系统名称 请将小程序和app头部名称替换为该字段
+ * @apiSuccess {String}   config.info 系统介绍
+ * @apiSuccess {String}   config.logo 系统logo
+ * @apiSuccess {String}   config.ios_pay ios支付设置 1为不开启小程序支付,将所有购买按钮都隐藏掉,2为开启公众号支付,3开始小程序支付
+ * @apiSuccess {String}   config.ios_pay_pic ios里公众号支付引导图
+ * @apiSuccess {String}   config.try_desc 试用的说明 
+
+ * @apiSuccess {Object[]} journal 电子刊数据列表
+ * @apiSuccess {String}   journal.id 电子刊id
  * @apiSuccess {String}   journal.name 名称
  * @apiSuccess {String}   journal.subname 期号
  * @apiSuccess {String}   journal.pic_cover 列表封面图片 暂时无效
- * @apiSuccess {String}   journal.pic_view_cover 小刊封面图片 封面图都用这个
+ * @apiSuccess {String}   journal.pic_view_cover 电子刊封面图片 封面图都用这个
  * @apiSuccess {String}   journal.pic_view_bg 全屏背景图,多张图片,这是一个数组
- * @apiSuccess {String}   journal.pic_gd 小刊推广图
+ * @apiSuccess {String}   journal.pic_gd 电子刊推广图
  * @apiSuccess {String}   journal.pdate 时间
  * @apiSuccess {String}   journal.num_ding 订阅数
- * @apiSuccess {String}   journal.buy 小刊是否收费 1收费 2免费 3会员
- * @apiSuccess {String}   journal.bgmusic 小刊背景音乐
+ * @apiSuccess {String}   journal.buy 电子刊是否收费 1收费 2免费
+ * @apiSuccess {String}   journal.buy_type 电子刊支付类型,1为普通支付,2为明星支付(读取明星列表)
+ * @apiSuccess {String}   journal.bgmusic 电子刊背景音乐
  * @apiSuccess {Object[]}   journal.button 按钮判断 如果不需要这个,可以不用
  * @apiSuccess {Object[]}   journal.button.read 第一个按钮 阅读按钮
  * @apiSuccess {String}   journal.button.read.status 状态 -1不显示 1为进入阅读 2为兑换 3为预售,注意,当值为2时,必须在阅读按钮上,当用户点击按钮时,绑定一个事件,该事件的接口为journal.subscribe
@@ -364,10 +374,7 @@
  * @apiSuccess {String}   journal.button.share.status 状态 -1不显示 1为排行榜
  * @apiSuccess {String}   journal.button.share.name 按钮上的名字
  *
- * @apiSuccess {Object[]} push 主推小刊
- * @apiSuccess {String}   push.id 小刊id
- * @apiSuccess {String}   push.name 名称
- * @apiSuccess {String}   push.num_ding 订阅数
+ * @apiSuccess {Object[]} push 主推电子刊列表 字段参考电子刊数据列表
 
  * @apiSuccess {Object[]} cate 当前分类
  * @apiSuccess {String}   cate.id 分类id
@@ -375,28 +382,29 @@
  */
 
 /**
- * @api {get} mars/main/?l=journal.getAppList APP刊列表
+ * @api {get} mars/main/?l=journal.getAppList APP电子刊列表
  * @apiVersion 2.0.0
  * @apiName journal.getAppList
  * @apiGroup Journal
  *
- * @apiDescription 小刊列表,按照分类读取,根据获取的信息,可以直接进入到小刊详情页,无需再次请求接口。
+ * @apiDescription 电子刊列表,按照分类读取,根据获取的信息,可以直接进入到电子刊详情页,无需再次请求接口。
  *
  * @apiParam {String} signature signature
  * @apiParam {String} system 分类id,默认为1,传入-1就是获取全部
  *
- * @apiSuccess {Object[]} journal 刊数据列表
- * @apiSuccess {String}   journal.id 刊id
+ * @apiSuccess {Object[]} journal 电子刊数据列表
+ * @apiSuccess {String}   journal.id 电子刊id
  * @apiSuccess {String}   journal.name 名称
  * @apiSuccess {String}   journal.subname 期号
  * @apiSuccess {String}   journal.pic_cover 列表封面图片 暂时无效
- * @apiSuccess {String}   journal.pic_view_cover 刊封面图片 封面图都用这个
+ * @apiSuccess {String}   journal.pic_view_cover 电子刊封面图片 封面图都用这个
  * @apiSuccess {String}   journal.pic_view_bg 全屏背景图,多张图片,这是一个数组
- * @apiSuccess {String}   journal.pic_gd 刊推广图
+ * @apiSuccess {String}   journal.pic_gd 电子刊推广图
  * @apiSuccess {String}   journal.pdate 时间
  * @apiSuccess {String}   journal.num_ding 订阅数
- * @apiSuccess {String}   journal.buy 小刊是否收费 1收费 2免费 3会员
- * @apiSuccess {String}   journal.bgmusic 小刊背景音乐
+ * @apiSuccess {String}   journal.buy 电子刊是否收费 1收费 2免费
+ * @apiSuccess {String}   journal.buy_type 电子刊支付类型,1为普通支付,2为明星支付(读取明星列表)
+ * @apiSuccess {String}   journal.bgmusic 电子刊背景音乐
  * @apiSuccess {Object[]}   journal.button 按钮判断 如果不需要这个,可以不用
  * @apiSuccess {Object[]}   journal.button.read 第一个按钮 阅读按钮
  * @apiSuccess {String}   journal.button.read.status 状态 -1不显示 1为进入阅读 2为兑换 3为预售,注意,当值为2时,必须在阅读按钮上,当用户点击按钮时,绑定一个事件,该事件的接口为journal.subscribe
@@ -408,11 +416,8 @@
  * @apiSuccess {String}   journal.button.share.status 状态 -1不显示 1为排行榜
  * @apiSuccess {String}   journal.button.share.name 按钮上的名字
  *
- * @apiSuccess {Object[]} push 主推小刊
- * @apiSuccess {String}   push.id 小刊id
- * @apiSuccess {String}   push.name 名称
- * @apiSuccess {String}   push.num_ding 订阅数
-
+ * @apiSuccess {Object[]} push 主推电子刊列表 字段参考电子刊数据列表
+ *
  * @apiSuccess {Object[]} cate 当前分类
  * @apiSuccess {String}   cate.id 分类id
  * @apiSuccess {String}   cate.name 名称
@@ -457,19 +462,19 @@
  */
 
 /**
- * @api {get} mars/main/?l=journal.read 刊阅读页
+ * @api {get} mars/main/?l=journal.read 电子刊阅读页
  * @apiVersion 2.0.0
  * @apiName journal.read
  * @apiGroup Journal
  *
- * @apiDescription 刊阅读页
+ * @apiDescription 电子刊阅读页
  *
  * @apiParam {String} signature signature
- * @apiParam {Number} id 刊id
+ * @apiParam {Number} id 电子刊id
  *
  * @apiSuccess {Object[]} content 内容数据列表,每页显示10条,请在翻到第7或者第8条时,请求第2
  * @apiSuccess {String}   content.id 内容id
- * @apiSuccess {String}   content.type 内容类型1全屏图、2长图、3图文内容、11关联图文、12关联视频、13关联直播、4全屏视频、5留言视频、6留言音频|||新增:7长屏图、8横屏图、9无边框图片、10四宫格图片、21对话模板
+ * @apiSuccess {String}   content.type 内容类型1全屏图、2长图、3图文内容、11关联图文、12关联视频、13关联直播、4全屏视频、5留言视频、6留言音频|||新增:7长屏图、8横屏图、9无边框图片、10四宫格图片、21对话模板31试用产品、32是h5的url地址(独立h5)
  * @apiSuccess {String}   content.name 标题。type=5,6时有效
  * @apiSuccess {String}   content.cover 音频或者视频的封面图,type=4,5,6时有效
  * @apiSuccess {String}   content.video 视频地址。type=4,5时有效
@@ -494,6 +499,13 @@
  * @apiSuccess {String}   content.info.content_array 数组内容
  * @apiSuccess {Object[]}   content.info.author 作者
 
+  * @apiSuccess {Object[]}   content.product type=31时有效
+ * @apiSuccess {String}   content.product.name 产品标题
+ * @apiSuccess {String}   content.product.pic 产品图片
+ * @apiSuccess {String}   content.product.content 内容
+ * @apiSuccess {String}   content.product.cate 产品分类信息
+ * @apiSuccess {Object[]}   content.product.price 产品价格
+
  * @apiSuccess {Object[]}   content.palaces 四宫格图片的四个图片,type=10时有效
  * @apiSuccess {String}   content.palaces.palaces 图片位置,1上左2上右3下左4下右
  * @apiSuccess {String}   content.palaces.pic 图片
@@ -509,29 +521,30 @@
  */
 
 /**
- * @api {get} mars/main/?l=journal.getView 刊详情页
+ * @api {get} mars/main/?l=journal.getView 电子刊详情页
  * @apiVersion 2.0.0
  * @apiName journal.getView
  * @apiGroup Journal
  *
- * @apiDescription 刊详情页,如果是分享进来的,请求这个接口来获取按钮
+ * @apiDescription 电子刊详情页,如果是分享进来的,请求这个接口来获取按钮
  *
  * @apiParam {String} signature signature
- * @apiParam {Number} id 刊id
+ * @apiParam {Number} id 电子刊id
  *
- * @apiSuccess {Object[]} info 刊详情
- * @apiSuccess {String}   info.id 刊id
+ * @apiSuccess {Object[]} info 电子刊详情
+ * @apiSuccess {String}   info.id 电子刊id
  * @apiSuccess {String}   info.name 名称
  * @apiSuccess {String}   journal.subname 期号
  * @apiSuccess {String}   info.pic_cover 列表封面图片 暂时无效
- * @apiSuccess {String}   info.pic_view_cover 刊封面图片 封面图都用这个
+ * @apiSuccess {String}   info.pic_view_cover 电子刊封面图片 封面图都用这个
  * @apiSuccess {String}   info.pic_view_bg 全屏背景图,多张图片,这是一个数组
- * @apiSuccess {String}   info.pic_gd 刊推广图
+ * @apiSuccess {String}   info.pic_gd 电子刊推广图
  * @apiSuccess {String}   info.pdate 时间
  * @apiSuccess {String}   info.ydate 预售时间
  * @apiSuccess {String}   info.ytype 预售状态,1为可以阅读2显示预售弹窗,如果用button就不用判断该字段了
  * @apiSuccess {String}   info.num_ding 订阅数
- * @apiSuccess {String}   info.buy 小刊是否收费 1收费 2不收费
+ * @apiSuccess {String}   info.buy 电子刊是否收费 1收费 2免费
+ * @apiSuccess {String}   info.buy_type 电子刊支付类型,1为普通支付,2为明星支付(读取明星列表)
  * @apiSuccess {String}   info.subscribe 是否订阅,1为已订阅2为未订阅
  * @apiSuccess {String}   info.active 是否有活动,1为有2为没有,有则显示排行榜按钮
 
@@ -548,29 +561,30 @@
  */
 
 /**
- * @api {get} mars/main/?l=journal.getAppView APP刊详情页
+ * @api {get} mars/main/?l=journal.getAppView APP电子刊详情页
  * @apiVersion 2.0.0
  * @apiName journal.getAppView
  * @apiGroup Journal
  *
- * @apiDescription APP刊详情页,如果是分享进来的,请求这个接口来获取按钮
+ * @apiDescription APP电子刊详情页,如果是分享进来的,请求这个接口来获取按钮
  *
  * @apiParam {String} signature signature
- * @apiParam {Number} id 刊id
+ * @apiParam {Number} id 电子刊id
  *
- * @apiSuccess {Object[]} info 刊详情
- * @apiSuccess {String}   info.id 刊id
+ * @apiSuccess {Object[]} info 电子刊详情
+ * @apiSuccess {String}   info.id 电子刊id
  * @apiSuccess {String}   info.name 名称
  * @apiSuccess {String}   journal.subname 期号
  * @apiSuccess {String}   info.pic_cover 列表封面图片 暂时无效
- * @apiSuccess {String}   info.pic_view_cover 刊封面图片 封面图都用这个
+ * @apiSuccess {String}   info.pic_view_cover 电子刊封面图片 封面图都用这个
  * @apiSuccess {String}   info.pic_view_bg 全屏背景图,多张图片,这是一个数组
- * @apiSuccess {String}   info.pic_gd 刊推广图
+ * @apiSuccess {String}   info.pic_gd 电子刊推广图
  * @apiSuccess {String}   info.pdate 时间
  * @apiSuccess {String}   info.ydate 预售时间
  * @apiSuccess {String}   info.ytype 预售状态,1为可以阅读2显示预售弹窗,如果用button就不用判断该字段了
  * @apiSuccess {String}   info.num_ding 订阅数
- * @apiSuccess {String}   info.buy 小刊是否收费 1收费 2不收费
+ * @apiSuccess {String}   info.buy 电子刊是否收费 1收费 2免费
+ * @apiSuccess {String}   info.buy_type 电子刊支付类型,1为普通支付,2为明星支付(读取明星列表)
  * @apiSuccess {String}   info.subscribe 是否订阅,1为已订阅2为未订阅
  * @apiSuccess {String}   info.active 是否有活动,1为有2为没有,有则显示排行榜按钮
 
@@ -587,32 +601,32 @@
  */
 
 /**
- * @api {get} mars/main/?l=journal.subscribe 检测刊是否可以阅读
+ * @api {get} mars/main/?l=journal.subscribe 检测电子刊是否可以阅读
  * @apiVersion 2.0.0
  * @apiName journal.subscribe
  * @apiGroup Journal
  *
- * @apiDescription 检测刊是否可以阅读
+ * @apiDescription 检测电子刊是否可以阅读
  *
  * @apiParam {String} signature signature
- * @apiParam {Number} id 刊id
+ * @apiParam {Number} id 电子刊id
  *
  * @apiSuccess {String}   subscribe 1为已订阅可以阅读,2为未订阅不能阅读,弹出兑换码
  */
 
 /**
- * @api {get} mars/main/?l=journal.buy 刊购买页
+ * @api {get} mars/main/?l=journal.buy 电子刊购买页
  * @apiVersion 2.0.0
  * @apiName journal.buy
  * @apiGroup Journal
  *
- * @apiDescription 刊购买页
+ * @apiDescription 电子刊购买页
  *
  * @apiParam {String} signature signature
- * @apiParam {Number} id 刊id
+ * @apiParam {Number} id 电子刊id
  *
- * @apiSuccess {Object[]} info 刊详情
- * @apiSuccess {String}   info.id 刊id
+ * @apiSuccess {Object[]} info 电子刊详情
+ * @apiSuccess {String}   info.id 电子刊id
  * @apiSuccess {String}   info.name 名称
  *
  * @apiSuccess {String} buy_desc 购买说明
@@ -623,6 +637,27 @@
  * @apiSuccess {String}   buy_list.cash 实际支付价格
  */
 
+/**
+ * @api {get} mars/main/?l=journal.star 电子刊明星列表页
+ * @apiVersion 2.0.0
+ * @apiName journal.star
+ * @apiGroup Journal
+ *
+ * @apiDescription 电子刊明星列表页,当buy_type==2时读取本接口
+ *
+ * @apiParam {String} signature signature
+ * @apiParam {Number} id 电子刊id
+ *
+ * @apiSuccess {Object[]} info 电子刊详情
+ * @apiSuccess {String}   info.id 电子刊id
+ * @apiSuccess {String}   info.name 名称
+ * @apiSuccess {Object[]}   star 明星列表
+ * @apiSuccess {String}   star.id 明星id 支付时使用
+ * @apiSuccess {String}   star.name 明星名称
+ * @apiSuccess {String}   star.avatar 明星头像
+ * @apiSuccess {String}   star.num_ding 明星订阅数
+ */
+
 /**
  * @api {get} mars/act/?l=order.pay 发起支付
  * @apiVersion 2.0.0
@@ -632,8 +667,9 @@
  * @apiDescription 发起支付:请注意,如果是苹果支付,请在发起苹果支付之后,将苹果返回的验证数据,传入该接口
  *
  * @apiParam {String} signature signature
- * @apiParam {String} journal_id 刊id
+ * @apiParam {String} journal_id 电子刊id
  * @apiParam {String} buy_id 购买本数id
+ * @apiParam {String} star_id 明星id
  * @apiParam {String} receipt 当header中的source_type为ios时,请传入该参数,参数的值为苹果支付后返回的参数,即可发起支付验证。
 *
  * @apiSuccess {Object[]} pay 微信支付返回的数据
@@ -655,25 +691,25 @@
  * @apiDescription 兑换码兑换
  *
  * @apiParam {String} signature signature
- * @apiParam {String} journal_id 刊id
+ * @apiParam {String} journal_id 电子刊id
  * @apiParam {String} code 兑换码
  *
  * @apiSuccess {String}   ok 兑换成功
  */
 
 /**
- * @api {get} mars/main/?l=journal.top 刊本数排行榜
+ * @api {get} mars/main/?l=journal.top 电子刊本数排行榜
  * @apiVersion 2.0.0
  * @apiName journal.top
  * @apiGroup Journal
  *
- * @apiDescription 刊本数排行榜
+ * @apiDescription 电子刊本数排行榜
  *
  * @apiParam {String} signature signature
- * @apiParam {Number} id 刊id
+ * @apiParam {Number} id 电子刊id
  *
- * @apiSuccess {Object[]} info 刊详情
- * @apiSuccess {String}   info.id 刊id
+ * @apiSuccess {Object[]} info 电子刊详情
+ * @apiSuccess {String}   info.id 电子刊id
  * @apiSuccess {String}   info.name 名称
  *
  * @apiSuccess {Object[]}   top 本数排行
@@ -692,7 +728,7 @@
  */
 
 /**
- * @api {get} wonderful/main/?l=user.my 获取用户信息
+ * @api {get} mars/main/?l=user.my 获取用户信息
  * @apiVersion 1.0.0
  * @apiName user.my
  * @apiGroup User
@@ -715,7 +751,7 @@
  */
 
 /**
- * @api {get} wonderful/main/?l=user.my_msg 获取我的消息
+ * @api {get} mars/main/?l=user.my_msg 获取我的消息
  * @apiVersion 1.0.0
  * @apiName user.my_msg
  * @apiGroup User
@@ -737,7 +773,7 @@
  */
 
 /**
- * @api {get} wonderful/main/?l=user.my_comment 获取我评论的信息
+ * @api {get} mars/main/?l=user.my_comment 获取我评论的信息
  * @apiVersion 1.0.0
  * @apiName user.my_comment
  * @apiGroup User

+ 9 - 65
main/database/config.php

@@ -73,43 +73,6 @@ return array
 			'place'		=> '150',
 		),
 
-		'hr2'		=> array
-		(
-			'name' 		=> '分享设置',
-			'class'		=> '',//本项必须填写
-			'attr'		=> '',
-		),
-
-		'article_share_name'		=> array
-		(
-			'type' 		=> 'varchar-100',
-			'name' 		=> '图文详情页分享文字设置',
-			'default' 	=> '喜欢就邀请好友一起阅读',
-			'desc' 		=> '图文详情页分享文字设置',
-			'match' 	=> 'is_string',
-			'update'	=> 'text',
-		),
-
-		'vod_share_name'		=> array
-		(
-			'type' 		=> 'varchar-100',
-			'name' 		=> '视频详情页分享文字设置',
-			'default' 	=> '喜欢就邀请好友一起阅读',
-			'desc' 		=> '视频详情页分享文字设置',
-			'match' 	=> 'is_string',
-			'update'	=> 'text',
-		),
-
-		'live_share_name'		=> array
-		(
-			'type' 		=> 'varchar-100',
-			'name' 		=> '直播详情页分享文字设置',
-			'default' 	=> '喜欢就邀请好友一起阅读',
-			'desc' 		=> '直播详情页分享文字设置',
-			'match' 	=> 'is_string',
-			'update'	=> 'text',
-		),
-
 		'hr3'		=> array
 		(
 			'name' 		=> '小程序支付设置',
@@ -201,39 +164,20 @@ return array
 
 		'hr6'		=> array
 		(
-			'name' 		=> 'APP分享内容',
+			'name' 		=> '试用设置',
 			'class'		=> '',//本项必须填写
 			'attr'		=> '',
 		),
 
-		'share_content'		=> array
-		(
-			'type' 		=> 'varchar-400',
-			'name' 		=> 'APP固定分享内容-内容中可以设置变量,{link}为下载链接',
-			'default' 	=> '',
-			'desc' 		=> 'APP固定分享内容',
-			'match' 	=> 'is_string',
-			'update'	=> 'textarea',
-		),
-
-		'ios_link'		=> array
+		'try_desc'		=> array
 		(
-			'type' 		=> 'varchar-200',
-			'name' 		=> 'IOS下载链接',
-			'default' 	=> '',
-			'desc' 		=> 'IOS下载链接',
-			'match' 	=> 'is_string',
-			'update'	=> 'textarea',
-		),
-
-		'android_link'		=> array
-		(
-			'type' 		=> 'varchar-200',
-			'name' 		=> 'android下载链接',
+			'type' 		=> 'text-255',
+			'name' 		=> '试用说明',
 			'default' 	=> '',
-			'desc' 		=> 'android下载链接',
-			'match' 	=> 'is_string',
-			'update'	=> 'textarea',
+			'desc' 		=> '试用说明',
+			'match' 	=> 'option',
+			'update'	=> 'editor',
+			'key'		=> 1,
 		),
 
 		'cdate'		=> array
@@ -252,7 +196,7 @@ return array
 		'col' => 'name,info,cdate',
 		'value' => array
 		(
-			'"精美时尚内容平台","精美时尚内容平台",' . time(),
+			'"火星电子刊内容平台","火星电子刊内容平台",' . time(),
 		),
 	),
 

+ 1 - 1
main/database/version.php

@@ -49,7 +49,7 @@ return array
 	'lang' => '版本管理',
 	# 后台菜单排序
 	'order' => 1,
-	'menu' => 'stat',
+	'menu' => false,
 	# 数据结构
 	'struct' => array
 	(

+ 0 - 2
main/lib/Journal.php

@@ -14,9 +14,7 @@ class Journal
 
         if (isset($param['uid']) && $param['uid'] > 0 && isset($param['id']) && $param['id'] > 0 && isset($param['add_num']) && $param['add_num']) {
 
-            //Dever::score($param['uid'], 'read_journal', '阅读小刊');
             Dever::load('act/lib/subscribe')->submit($param['uid'], $param['id'], 4);
-        	//Dever::db('journal/info')->addView($param['id']);
             Dever::db('journal/info')->addDing($param['id']);
         }
     }

+ 50 - 45
main/src/Journal.php

@@ -39,17 +39,17 @@ class Journal extends Core
         if (isset($cate['id'])) {
             $where['cate_id'] = $cate['id'];
         }
-        if (isset($cate['journal_id'])) {
-            $this->data['push'] = Dever::db('journal/info')->getOne($cate['journal_id']);
-        } else {
-            # 获取最新的小刊
-            $this->data['push'] = Dever::db('journal/info')->getNew();
-        }
-
-        $this->data['push'] = $this->info($this->data['push']);
         $this->data['button'] = array();
-        $this->data['push'] = $this->getButton($this->data['push']);
 
+        # 热门电子刊
+        $this->data['push'] = Dever::db('journal/info')->getHot($where);
+
+        if ($this->data['push']) {
+            foreach ($this->data['push'] as $k => $v) {
+                $this->data['push'][$k] = $this->info($v);
+                $this->data['push'][$k] = $this->getButton($this->data['push'][$k]);
+            }
+        }
         
         $data = Dever::db('journal/info')->getAllByPage($where);
 
@@ -64,7 +64,7 @@ class Journal extends Core
             $this->data['journal'] = array();
         }
 
-        $this->data['end']['call'] = 'main/journal_v1.getList_noCache';
+        $this->data['end']['call'] = 'main/journal.getList_noCache';
 
         $this->data['code'] = 1;
         if (checkVersion()->journal_buy == 2) {
@@ -76,11 +76,13 @@ class Journal extends Core
 
     public function getList_noCache($data)
     {
-        if ($data['push'] && $data['push']['hot'] == 1) {
-            $num_ding = Dever::load('act/lib/num')->getCounter($data['push']['id']);
-            if ($num_ding && $num_ding >= $data['push']['num_ding']) {
-                $data['push']['num_ding'] = $num_ding;
-                $data['push'] = $this->ding($data['push']);
+        if ($data['push']) {
+            foreach ($data['push'] as $k => $v) {
+                $num_ding = Dever::load('act/lib/num')->getCounter($v['id']);
+                if ($num_ding && $num_ding >= $v['num_ding']) {
+                    $data['push'][$k]['num_ding'] = $num_ding;
+                    $data['push'][$k] = $this->ding($data['push'][$k]);
+                }
             }
         }
 
@@ -124,14 +126,17 @@ class Journal extends Core
         $where['cate_id_1'] = 1;
         $where['time'] = $time - $day;
 
-        # 获取最新的小刊
-        $this->data['push'] = Dever::db('journal/info')->getNew($where);
-
-        $this->data['push'] = $this->ding($this->data['push']);
-
         $this->data['button'] = array();
-        //$this->data['push'] = $this->getButton($this->data['push']);
-        //$this->data['push'] = $this->getAppSet($this->data['push']);
+        # 热门电子刊
+        $this->data['push'] = Dever::db('journal/info')->getHot($where);
+
+        if ($this->data['push']) {
+            foreach ($this->data['push'] as $k => $v) {
+                $this->data['push'][$k] = $this->info($v);
+                //$this->data['push'][$k] = $this->getButton($this->data['push'][$k]);
+                //$this->data['push'][$k] = $this->getAppSet($this->data['push'][$k]);
+            }
+        }
 
         
         $data = Dever::db('journal/info')->getAllByPage($where);
@@ -529,17 +534,9 @@ class Journal extends Core
         $id = $this->check();
 
         # 获取购买说明
-        $buy = Dever::db('journal/buy')->one(array('id' => $id));
+        //$buy = Dever::db('journal/buy')->one(array('id' => $id));
 
-        $this->data['buy_desc'] = '';
-        if ($buy) {
-            $this->data['buy_desc'] = $buy['buy_content'];
-        }
-
-        $this->data['buy_applet_notice'] = '在此购买单本可直接阅读电子刊,购买多本,直接累计积分,不会生成兑换码。';
-        if ($buy && isset($buy['buy_applet_notice']) && $buy['buy_applet_notice']) {
-            $this->data['buy_applet_notice'] = $buy['buy_applet_notice'];
-        }
+        $this->data['buy_desc'] = $this->data['info']['buy_content'];
 
         if ($this->data['info']['buy'] == 2) {
             $this->data['buy_list'] = array();
@@ -569,6 +566,25 @@ class Journal extends Core
         return $this->data;
     }
 
+    # 明星列表页
+    public function star()
+    {
+        if (!$this->data['uid']) {
+            Dever::alert('错误的用户信息');
+        }
+        $id = $this->check();
+
+        $this->data['star'] = Dever::db('journal/star')->state(array('info_id' => $id));
+
+        if ($this->data['star']) {
+            foreach ($this->data['star'] as $k => $v) {
+                $this->data['star'][$k] = Dever::load('journal/api')->starDing($v);
+            }
+        }
+
+        return $this->data;
+    }
+
     # 修改为本数排行榜
     public function top()
     {
@@ -590,19 +606,6 @@ class Journal extends Core
             return $this->data;
         }
 
-        /*
-        $time = time();
-        if ($this->data['active'] && $time >= $this->data['active']['start'] && $time < $this->data['active']['end']) {
-            $this->data['active']['status'] = 1;
-        } else {
-            $this->data['active']['status'] = 2;
-        }
-
-        if ($time < $this->data['active']['start']) {
-            $this->data['active']['status'] = 3;
-        }
-        */
-
         return $this->data;
     }
 
@@ -750,6 +753,8 @@ class Journal extends Core
             } else {
                 $info['info']['note'] = 2;
             }
+        } elseif ($info['type'] == 31) {
+            $info['info'] = Dever::load('product/lib/info')->get($info['product_id']);
         }
 
         if (isset($info['info']['author_id']) && $info['info']['author_id']) {