dever 5 лет назад
Родитель
Сommit
f4f460b771

+ 37 - 2
app/collection/database/cate.php

@@ -21,6 +21,32 @@ $list = array
 );
 
 
+$pay_type = array
+(
+    1 => '上左',
+    2 => '上中',
+    3 => '上右',
+    4 => '中左',
+    5 => '正中',
+    6 => '中右',
+    7 => '下左',
+    8 => '下中',
+    9 => '下右',
+    //10 => '自定义',
+);
+
+$pay_channel = function()
+{
+    $array = array();
+    $info = Dever::load('pay/api.channel');
+    
+    if($info)
+    {
+        $array += $info;
+    }
+    return $array;
+};
+
 $id = Dever::input('where_id');
 return array
 (
@@ -35,12 +61,10 @@ return array
     (
         'update' => array
         (
-            'passport/lib/manage.updateSystem',
             'manage/top.sync',
         ),
         'insert' => array
         (
-            'passport/lib/manage.updateSystem',
             'manage/top.sync',
         )
     ),
@@ -82,6 +106,17 @@ return array
             'option'    => $type,
         ),
 
+        'pay_channel'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '支付渠道',
+            'default'   => '1',
+            'desc'      => '支付渠道',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => $pay_channel,
+        ),
+
         'logo'     => array
         (
             'type'      => 'varchar-150',

+ 0 - 115
app/collection/database/user_car.php

@@ -1,115 +0,0 @@
-<?php
-
-return array
-(
-    # 表名
-    'name' => 'user_car',
-    # 显示给用户看的名称
-    'lang' => '用户购买记录',
-    'menu' => false,
-    # 数据结构
-    'struct' => array
-    (
-    
-        'id'        => array
-        (
-            'type'      => 'int-11',
-            'name'      => 'ID',
-            'default'   => '',
-            'desc'      => '',
-            'match'     => 'is_numeric',
-            'search'    => 'order',
-            'update'    => 'hidden',
-            //'list'        => true,
-        ),
-
-        'uid'       => array
-        (
-            'type'      => 'int-11',
-            'name'      => '用户名',
-            'default'   => '0',
-            'desc'      => '请选择用户',
-            'match'     => 'is_numeric',
-            'update'    => 'text',
-            //'search'  => 'select',
-            'search'    => array
-            (
-                'api' => 'passport/user-all',
-                'col' => 'username',
-                'result' => 'id',
-            ),
-            'list'      => '{uid} > 0 ? Dever::load("passport/user-one#username", {uid}) : "匿名用户"',
-        ),
-
-        'info_id'      => array
-        (
-            'type'      => 'int-11',
-            'name'      => '合集',
-            'default'   => '',
-            'desc'      => '合集',
-            'match'     => 'is_numeric',
-            'update'    => 'text',
-        ),
-
-        'product_id'      => array
-        (
-            'type'      => 'int-11',
-            'name'      => '父级章节id',
-            'default'   => '',
-            'desc'      => '章节id',
-            'match'     => 'is_numeric',
-            'update'    => 'text',
-        ),
-
-        'goods_id'      => array
-        (
-            'type'      => 'int-11',
-            'name'      => '章节id',
-            'default'   => '',
-            'desc'      => '章节id',
-            'match'     => 'is_numeric',
-            'update'    => 'text',
-        ),
-
-        'content_id'      => array
-        (
-            'type'      => 'int-11',
-            'name'      => '内容id',
-            'default'   => '',
-            'desc'      => '内容id',
-            'match'     => 'is_numeric',
-            'update'    => 'text',
-        ),
-
-        'state'     => array
-        (
-            'type'      => 'tinyint-1',
-            'name'      => '状态',
-            'default'   => '1',
-            'desc'      => '请选择状态',
-            'match'     => 'is_numeric',
-        ),
-        
-        'cdate'     => array
-        (
-            'type'      => 'int-11',
-            'name'      => '操作时间',
-            'match'     => array('is_numeric', time()),
-            'desc'      => '',
-            # 只有insert时才生效
-            //'insert'    => true,
-            'search'    => 'date',
-            'list'      => 'date("Y-m-d H:i:s", {cdate})',
-        ),
-    ),
-
-    'manage' => array
-    (
-        
-    ),
-
-    'request' => array
-    (
-        
-    ),
-);

+ 2 - 2
app/collection/lib/Content.php

@@ -38,7 +38,7 @@ class Content
                 $info = Dever::db('collection/info')->one($info_id);
                 if ($info && $info['uid'] > 0) {
                     $page['author_name'] = $info['author_name'] . ':';
-                    $user = Dever::load('passport/api')->info($info['uid']);
+                    $user = Dever::load('user/lib/info')->get($info['uid'], $info_id);
                     $page['username'] = $user['username'];
 
                     $page['copyright'] = '如不慎侵害您的权益,请告知,我们将第一时间修改';
@@ -297,7 +297,7 @@ class Content
                     if ($type == 3) {
                         # 查看是否有预约
                         if ($uid > 0) {
-                            $info['user_act']['note'] = Dever::load('act/lib/note')->get($uid, $v, $type);
+                            $info['user_act']['note'] = Dever::load('user/lib/note')->get($uid, $v, $type);
                         } else {
                             $info['user_act']['note'] = 2;
                         }

+ 9 - 2
app/collection/lib/Core.php

@@ -16,6 +16,7 @@ class Core
     protected $parent_page_id;
     protected $page_id;
     protected $key = 'dreamland1985';
+    protected $source = 1;//来源1是h5、2安卓、3ios、4微信小程序
 
     public function __construct()
     {
@@ -23,8 +24,14 @@ class Core
     	# 获取当前的用户信息
         $this->token = Dever::input('token');
         $this->uid = 1;
-        $this->user = Dever::load('collection/lib/user')->get($this->uid, $this->id);
+        $this->user = $this->getUser($this->uid, $this->id);
         $this->user['id'] = $this->uid;
+        $this->source = Dever::input('source');
+    }
+
+    protected function getUser($uid, $collection_id)
+    {
+        return Dever::load('user/lib/info')->get($uid, $collection_id);
     }
 
     protected function checkInfo()
@@ -88,7 +95,7 @@ class Core
         # 获取最新的用户记录
         $where['info_id'] = $this->id;
         $where['uid'] = $this->uid;
-        $record = Dever::db('collection/user_record')->one($where);
+        $record = Dever::db('user/record')->one($where);
         if ($record) {
             $parent_page_id = $record['parent_page_id'];
             $page_id = $record['page_id'];

+ 0 - 51
app/collection/lib/User.php

@@ -1,51 +0,0 @@
-<?php
-
-namespace Collection\Lib;
-
-use Dever;
-
-class User
-{
-	private $user = array();
-
-	# 获取用户信息
-	public function get($user, $id)
-	{
-		if (is_numeric($user)) {
-			if (isset($this->user[$user])) {
-				return $this->user[$user];
-			}
-			$user = Dever::load('passport/api')->info($user);
-		} else {
-			if (isset($this->user[$user['id']])) {
-				return $this->user[$user['id']];
-			}
-		}
-		$result = array();
-		if ($user) {
-			if ($id) {
-				# 获取合集扩展信息
-		        $result = Dever::db('collection/user')->one(array('uid' => $user['id'], 'info_id' => $id));
-		        if (!$result) {
-		        	$result['uid'] = $user['id'];
-		            $result['username'] = $user['username'];
-		            $result['avatar'] = $user['avatar'];
-		            $result['info'] = $user['info'];
-		            $result['sex'] = $user['sex'];
-		            $result['title'] = '';
-		        } else {
-		        	!$result['username'] && $result['username'] = $user['username'];
-		        	!$result['avatar'] && $result['avatar'] = $user['avatar'];
-		        	!$result['info'] && $result['info'] = $user['info'];
-		        	!$result['sex'] && $result['sex'] = $user['sex'];
-		        }
-			} else {
-				$result = $user;
-			}
-		}
-
-		$this->user[$user['id']] = $result;
-		
-		return $result;
-	}
-}

+ 5 - 74
app/collection/src/Api.php

@@ -175,7 +175,7 @@ class Api extends Core
         if ($data['info']) {
             $data['info']['user'] = array();
             if ($data['info']['uid'] > 0) {
-                $data['info']['user'] = Dever::load('passport/api')->info($data['info']['uid']);
+                $data['info']['user'] = $this->getUser($data['info']['uid'], $data['info']['id']);
             }
             $data['info']['pic_bg'] = explode(',', $data['info']['pic_bg']);
 
@@ -288,7 +288,7 @@ class Api extends Core
 
             if ($data['ranking_data']) {
                 foreach ($data['ranking_data'] as $k => $v) {
-                    $data['ranking_data'][$k]['user'] = Dever::load('passport/api')->info($v['uid']);
+                    $data['ranking_data'][$k]['user'] = $this->getUser($v['uid'], $this->id);
                 }
             }
         }
@@ -343,7 +343,7 @@ class Api extends Core
         $data['times'] = Dever::db('collection/times')->main($where);
         if ($data['times']) {
             $where['uid'] = $this->uid;
-            $data['user_times'] = Dever::db('collection/user_times')->getData($where);
+            $data['user_times'] = Dever::load('user/lib/times')->getData($this->id, $this->uid);
             foreach ($data['times'] as $k => $v) {
                 $where['times_id'] = $v['id'];
                 $data['times'][$k]['child'] = Dever::db('collection/times')->child($where);
@@ -365,60 +365,12 @@ class Api extends Core
             $data['code'] = $this->getCode($this->id, $page['page_id'], $page['id'], 0, $page['times_id'], $day);
 
             # 记录选择的时光id和日期
-            $this->recordTimes($page['times_id'], $day);
+            Dever::load('user/lib/times')->up($this->id, $this->uid, $page['times_id'], $day);
             
             return $data;
         }
-        Dever::alert('error');
-    }
 
-    # 记录用户操作
-    public function record()
-    {
-        $where['info_id'] = $this->id;
-        $where['uid'] = $this->uid;
-        $record = Dever::db('collection/user_record')->one($where);
-        $where['parent_page_id'] = $this->parent_page_id;
-        $where['page_id'] = $this->page_id;
-        $where['times_id'] = $this->times;
-        if (!$this->day) {
-            $where['day'] = 0;
-        } else {
-            $where['day'] = $this->day;
-        }
-        $where['content_id'] = Dever::input('content_id');
-        $where['index'] = Dever::input('index', 0);
-        if ($record) {
-            $where['where_id'] = $record['id'];
-            Dever::db('collection/user_record')->update($where);
-        } else {
-            Dever::db('collection/user_record')->insert($where);
-        }
-
-        return 'yes';
-    }
-
-    # 记录用户时光选择操作
-    public function recordTimes($times_id, $day)
-    {
-        $where['info_id'] = $this->id;
-        $where['uid'] = $this->uid;
-        $where['times_id'] = $times_id;
-        $record = Dever::db('collection/user_times')->one($where);
-        if (!$day) {
-            $where['day'] = 0;
-        } else {
-            $where['day'] = $day;
-        }
-        
-        if ($record) {
-            $where['where_id'] = $record['id'];
-            Dever::db('collection/user_times')->update($where);
-        } else {
-            Dever::db('collection/user_times')->insert($where);
-        }
-
-        return 'yes';
+        Dever::alert('error');
     }
 
     public function ding($data)
@@ -426,20 +378,6 @@ class Api extends Core
         if (isset($data['num_add_buy']) && isset($data['num_ratio_buy'])) {
 
             if ($data['buy'] == 1) {
-            	/*
-                if (!$data['num_buy']) {
-                    $stat = Dever::db('stat/collection')->getNumBycollection(array('collection_id' => $data['id']));
-                    if (!$stat) {
-                        $stat['buy_num'] = 0;
-                    }
-
-                    if (!$stat['buy_num']) {
-                        $stat['buy_num'] = 0;
-                    }
-                    $data['num_buy'] = $stat['buy_num'];
-                }
-                */
-
                 $data['num_up'] = 0;
             } else {
                 $data['num_up'] = 0;
@@ -489,11 +427,4 @@ class Api extends Core
 
         return $result;
     }
-
-    public function video()
-    {
-        $link = Dever::input('link');
-
-        return Dever::qqvideo($link);
-    }
 }

+ 0 - 42
app/collection/src/Pay.php

@@ -1,42 +0,0 @@
-<?php
-
-namespace Collection\Src;
-
-use Dever;
-use Collection\Lib\Core;
-
-class Pay extends Core
-{
-    # 购买产品 下单
-    public function product()
-    {
-        if (!$this->user) {
-            Dever::alert('用户信息错误');
-        }
-
-        $uid = $this->user['id'];
-
-        $content_id = Dever::input('content_id');
-        $goods_id = Dever::input('goods_id');
-        $num = Dever::input('num');
-        $sku = Dever::input('sku');
-        $source = Dever::input('source');
-
-        if (!$goods_id) {
-            Dever::alert('请传入正确的产品ID');
-        }
-
-        $pay = Dever::load('goods/lib/pay')->action($this->share_uid, $uid, $goods_id, $sku, $num, $source, 'collection/info', $this->id);
-
-        //return $pay;
-
-        # 直接支付成功 测试用
-        $send['pay_order_id'] = $pay['order_id'];
-        $send['pay_status'] = 2;
-        $send['pay_msg'] = 'yes';
-        $send['dever_token'] = 'goods_dever_2020';
-        Dever::load('goods/lib/pay.success', $send);
-
-        return $send;
-    }
-}

+ 3 - 3
app/community/lib/Chat.php

@@ -50,7 +50,7 @@ class Chat
 				$where['uid'] = $v['uid'];
 				$where['collection_id'] = $collection_id;
 				$chat = Dever::db('community/chat_info')->getNew($where);
-				$user[$k]['user'] = Dever::load('collection/lib/user')->get($v['uid'], $collection_id);
+				$user[$k]['user'] = Dever::load('user/lib/info')->get($v['uid'], $collection_id);
 
 				if ($chat) {
 					if ($chat['pic'] && !$chat['text']) {
@@ -80,8 +80,8 @@ class Chat
 		$data['chat'] = Dever::db('community/chat_info')->getAll($where);
 
 		if ($data['chat']) {
-			$data['user'][$uid] = Dever::load('collection/lib/user')->get($uid, $collection_id);
-			$data['user'][$to_uid] = Dever::load('collection/lib/user')->get($to_uid, $collection_id);
+			$data['user'][$uid] = Dever::load('user/lib/info')->get($uid, $collection_id);
+			$data['user'][$to_uid] = Dever::load('user/lib/info')->get($to_uid, $collection_id);
 			$data['title'] = $data['user'][$to_uid]['username'];
 			foreach ($data['chat'] as $k => $v) {
 				$data['chat'][$k]['date'] = Dever::load('collection/lib/times')->getDate($v['day'], $v['cdate'], $times);

+ 1 - 1
app/community/lib/Comment.php

@@ -22,7 +22,7 @@ class Comment
                     $data['info'][$k]['pic'] = explode(',', $v['pic']);
                 }
                 if ($user) {
-                    $data['info'][$k]['user'] = Dever::load('collection/lib/user')->get($v['uid'], $collection_id);
+                    $data['info'][$k]['user'] = Dever::load('user/lib/info')->get($v['uid'], $collection_id);
                     $data['info'][$k]['cdate_string'] = Dever::mdate($v['cdate'], 2);
                 }
             }

+ 2 - 2
app/community/lib/Info.php

@@ -125,7 +125,7 @@ class Info
     private function one($uid, $info, $times = false, $collection_id = false)
     {
         $info['pic'] = explode(',', $info['pic']);
-        $info['user'] = Dever::load('collection/lib/user')->get($info['uid'], $collection_id);
+        $info['user'] = Dever::load('user/lib/info')->get($info['uid'], $collection_id);
         
         $info['cdate_string'] = Dever::load('collection/lib/times')->getDate($info['day'], $info['cdate'], $times);
 
@@ -151,7 +151,7 @@ class Info
         # 获取引用的数据
         $info['to_user'] = array();
         if ($info['to_uid']) {
-            $info['to_user'] = Dever::load('collection/lib/user')->get($info['to_uid'], $collection_id);
+            $info['to_user'] = Dever::load('user/lib/info')->get($info['to_uid'], $collection_id);
         }
 
         # 获取热门的子信息

+ 1 - 1
app/community/lib/Tips.php

@@ -24,7 +24,7 @@ class Tips
                     $temp['pic'] = explode(',', $v['pic']);
                 }
                 if ($user) {
-                    $temp['user'] = Dever::load('collection/lib/user')->get($v['uid'], $collection_id);
+                    $temp['user'] = Dever::load('user/lib/info')->get($v['uid'], $collection_id);
                     $temp['cdate_string'] = Dever::mdate($v['cdate'], 2);
                 }
 

+ 1 - 1
app/community/src/Api.php

@@ -113,7 +113,7 @@ class Api extends Core
         if (!$type) {
             Dever::alert('错误的信息');
         }
-        $seat = Dever::db('collection/user_seat')->one($type_id);
+        $seat = Dever::db('user/seat')->one($type_id);
         if (!$seat || $seat['uid'] != $this->uid) {
             Dever::alert('这不是您的座位');
         }

+ 1 - 1
app/collection/database/user.php → app/user/database/info.php

@@ -10,7 +10,7 @@ $sex = array
 return array
 (
     # 表名
-    'name' => 'user',
+    'name' => 'info',
     # 显示给用户看的名称
     'lang' => '用户扩展信息表',
     'menu' => false,

+ 1 - 1
app/collection/database/user_record.php → app/user/database/record.php

@@ -3,7 +3,7 @@
 return array
 (
     # 表名
-    'name' => 'user_record',
+    'name' => 'record',
     # 显示给用户看的名称
     'lang' => '用户操作记录',
     'menu' => false,

+ 1 - 1
app/collection/database/user_seat.php → app/user/database/seat.php

@@ -3,7 +3,7 @@
 return array
 (
     # 表名
-    'name' => 'user_seat',
+    'name' => 'seat',
     # 显示给用户看的名称
     'lang' => '用户座位购买记录',
     'menu' => false,

+ 518 - 0
app/user/database/ticket_order.php

@@ -0,0 +1,518 @@
+<?php
+
+$type = array
+(
+    1 => '购买兑换码',
+);
+
+# 系统
+$system = array
+(
+    1 => '小程序',
+    2 => 'H5',
+    3 => 'ios',
+    4 => '安卓',
+);
+
+$status = Dever::config('base', 'pay')->pay['status'];
+
+$info = function()
+{
+    return Dever::db('collection/info')->state();
+};
+
+$buy = function()
+{
+    return Dever::db('collection/buy')->state();
+};
+# 获取分类权限
+$auth = Dever::tops();
+$cate = function() use ($auth)
+{
+    $array = array();
+    if ($auth) {
+        $info = Dever::db('collection/cate')->getIds(array('ids' => $auth));
+    } else {
+        $info = Dever::db('collection/cate')->state();
+    }
+    if($info)
+    {
+        $array += $info;
+    }
+    return $array;
+};
+
+return array
+(
+    # 表名
+    'name' => 'ticket_order',
+    # 显示给用户看的名称
+    'lang' => '门票订单',
+    'order' => 1,
+
+    'end' => array
+    (
+        'update' => 'user/lib/manage.refund',
+    ),
+
+    # 数据结构
+    '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("user/lib/ticket.getOrderId", "{order_id}", {id})',
+        ), 
+
+        # 仅用于搜索
+        'cate_info_search'        => array
+        (
+            'name'      => '合集',
+            'default'   => '',
+            'desc'      => '合集',
+            'search'    => 'linkage',
+            'search_col' => 'cate_id,info_id',
+            'option'    => Dever::url('lib/manage.search_cate_journal', 'collection'),
+        ),
+
+        'cate_id'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '合集分类',
+            'default'   => '1',
+            'desc'      => '合集分类',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => $cate,
+            //'search'    => 'select',
+            'list'      => true,
+        ),
+
+        'info_id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '合集ID',
+            'default'   => '',
+            'desc'      => '合集ID',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => $info,
+            //'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'      => '购买本数ID',
+            'default'   => '',
+            'desc'      => '购买本数ID',
+            '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,
+        ),
+
+        'name'      => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => '订单名称',
+            'default'   => '',
+            'desc'      => '订单名称',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list_name' => '订单信息',
+            'list'      => 'Dever::load("user/lib/manage.showOrderUser", "{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',
+        ),
+
+        '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,
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'varchar-50',
+            'name'      => '支付金额',
+            'default'   => '',
+            'desc'      => '支付金额',
+            'match'     => 'option',
+            'update'    => 'text',
+            //'list'        => true,
+            'show'      => 'type=1',
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '订单状态',
+            'default'   => '1',
+            'desc'      => '请选择订单状态',
+            'match'     => 'is_numeric',
+            'option'    => $status,
+            'search'    => 'select',
+            'update'    => 'radio',
+            'list'      => true,
+            'list'      => 'Dever::load("user/lib/manage.showOrderStatus", "{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',
+        ),
+
+        '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',//本表的字段,默认为当前的字段
+            ),
+        ),
+
+        'note'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '是否发送状态提醒-1未发送,2已发送',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
+
+        'notice'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '模板消息提醒次数',
+            'default'   => '0',
+            'desc'      => '模板消息提醒次数',
+            'match'     => 'is_numeric',
+        ),
+
+        '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}")',
+        ),
+    ),
+
+    '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',
+                'uid' => 'yes',
+                'status' => array('1', '!='),
+                'uid' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('cdate' => 'desc'),
+            'page' => array(10, 'list'),
+            'col' => '*',
+        ),
+
+        'getYes' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'info_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' => '*',
+        ),
+
+        # 获取1,2
+        'getBuy' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'status' => 'yes',
+                'type' => array('yes', 'in'),
+                'info_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,info_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',
+        ),
+
+        'getNum' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'star_id' => 'yes',
+                'info_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'col' => 'sum(buy_num) as buy_num',
+        ),
+    ),
+);

+ 526 - 0
app/user/database/ticket_order_temp.php

@@ -0,0 +1,526 @@
+<?php
+
+$type = array
+(
+    1 => '购买兑换码',
+);
+
+# 系统
+$system = array
+(
+    1 => '小程序',
+    2 => 'H5',
+    3 => 'ios',
+    4 => '安卓',
+);
+
+$status = array
+(
+    1 => '待支付',
+    2 => '已支付',
+    3 => '支付失败',
+    4 => '申请退款',
+    5 => '已退款',
+);
+
+$info = function()
+{
+    return Dever::db('collection/info')->state();
+};
+
+$buy = function()
+{
+    return Dever::db('collection/buy')->state();
+};
+# 获取分类权限
+$auth = Dever::tops();
+$cate = function() use ($auth)
+{
+    $array = array();
+    if ($auth) {
+        $info = Dever::db('collection/cate')->getIds(array('ids' => $auth));
+    } else {
+        $info = Dever::db('collection/cate')->state();
+    }
+    if($info)
+    {
+        $array += $info;
+    }
+    return $array;
+};
+
+return array
+(
+    # 表名
+    'name' => 'ticket_order_temp',
+    # 显示给用户看的名称
+    'lang' => '临时订单管理',
+    'order' => 1,
+    'menu' => false,
+
+    'end' => array
+    (
+        'update' => 'user/lib/manage.refund',
+    ),
+
+    # 数据结构
+    '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("user/lib/ticket.getOrderId", "{order_id}", {id})',
+        ), 
+
+        # 仅用于搜索
+        'cate_info_search'        => array
+        (
+            'name'      => '合集',
+            'default'   => '',
+            'desc'      => '合集',
+            'search'    => 'linkage',
+            'search_col' => 'cate_id,info_id',
+            'option'    => Dever::url('lib/manage.search_cate_journal', 'collection'),
+        ),
+
+        'cate_id'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '合集分类',
+            'default'   => '1',
+            'desc'      => '合集分类',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => $cate,
+            //'search'    => 'select',
+            'list'      => true,
+        ),
+
+        'info_id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '合集ID',
+            'default'   => '',
+            'desc'      => '合集ID',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => $info,
+            //'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'      => '购买本数ID',
+            'default'   => '',
+            'desc'      => '购买本数ID',
+            '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,
+        ),
+
+        'name'      => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => '订单名称',
+            'default'   => '',
+            'desc'      => '订单名称',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list_name' => '订单信息',
+            'list'      => 'Dever::load("user/lib/manage.showOrderUser", "{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',
+        ),
+
+        '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,
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'varchar-50',
+            'name'      => '支付金额',
+            'default'   => '',
+            'desc'      => '支付金额',
+            'match'     => 'option',
+            'update'    => 'text',
+            //'list'        => true,
+            'show'      => 'type=1',
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '订单状态',
+            'default'   => '1',
+            'desc'      => '请选择订单状态',
+            'match'     => 'is_numeric',
+            'option'    => $status,
+            'search'    => 'select',
+            'update'    => 'radio',
+            'list'		=> true,
+            //'list'      => 'Dever::load("user/lib/manage.showOrderStatus", "{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',
+        ),
+
+        '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',//本表的字段,默认为当前的字段
+            ),
+        ),
+
+        'note'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '是否发送状态提醒-1未发送,2已发送',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
+
+        'notice'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '模板消息提醒次数',
+            'default'   => '0',
+            'desc'      => '模板消息提醒次数',
+            'match'     => 'is_numeric',
+        ),
+
+        '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}")',
+        ),
+    ),
+
+    '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',
+                'uid' => 'yes',
+                'status' => array('1', '!='),
+                'uid' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('cdate' => 'desc'),
+            'page' => array(10, 'list'),
+            'col' => '*',
+        ),
+
+        'getYes' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'info_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' => '*',
+        ),
+
+        # 获取1,2
+        'getBuy' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'status' => 'yes',
+                'type' => array('yes', 'in'),
+                'info_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,info_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',
+        ),
+
+        'getNum' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'star_id' => 'yes',
+                'info_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'col' => 'sum(buy_num) as buy_num',
+        ),
+    ),
+);

+ 1 - 1
app/collection/database/user_times.php → app/user/database/times.php

@@ -3,7 +3,7 @@
 return array
 (
     # 表名
-    'name' => 'user_times',
+    'name' => 'times',
     # 显示给用户看的名称
     'lang' => '用户时光选择记录',
     'menu' => false,

+ 8 - 0
app/user/index.php

@@ -0,0 +1,8 @@
+<?php
+
+define('DEVER_APP_NAME', 'user');
+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');

+ 91 - 0
app/user/lib/Info.php

@@ -0,0 +1,91 @@
+<?php
+
+namespace User\Lib;
+
+use Dever;
+
+class Info
+{
+	private $user = array();
+
+	# 保存用户信息
+    public function up($uid, $info_id, $username, $title, $info)
+    {
+    	$update['username'] = $username;
+    	if (!$update['username']) {
+    		Dever::alert('昵称不能为空');
+    	}
+    	$update['title'] = $title;
+    	$update['info'] = $info;
+    	$update['info_id'] = $info_id;
+    	$user = Dever::db('user/info')->one(array('uid' => $uid));
+        if (!$user) {
+        	$update['uid'] = $uid;
+            Dever::db('user/info')->insert($update);
+        } else {
+        	$update['where_id'] = $user['id'];
+        	Dever::db('user/info')->update($update);
+        }
+        return true;
+    }
+
+    # 保存头像
+    public function upAvatar($uid, $info_id, $avatar)
+    {
+    	$update['avatar'] = $avatar;
+    	if (!$update['avatar']) {
+    		Dever::alert('头像不能为空');
+    	}
+    	$update['info_id'] = $info_id;
+    	$user = Dever::db('user/info')->one(array('uid' => $this->uid));
+        if (!$user) {
+        	$update['uid'] = $uid;
+            Dever::db('user/info')->insert($update);
+        } else {
+        	$update['where_id'] = $user['id'];
+        	Dever::db('user/info')->update($update);
+        }
+        return 'ok';
+    }
+
+	# 获取用户信息
+	public function get($user, $id)
+	{
+		if (is_numeric($user)) {
+			if (isset($this->user[$user])) {
+				return $this->user[$user];
+			}
+			$user = Dever::load('passport/api')->info($user);
+		} else {
+			if (isset($this->user[$user['id']])) {
+				return $this->user[$user['id']];
+			}
+		}
+		$result = array();
+		if ($user) {
+			if ($id) {
+				# 获取合集扩展信息
+		        $result = Dever::db('user/info')->one(array('uid' => $user['id'], 'info_id' => $id));
+		        if (!$result) {
+		        	$result['uid'] = $user['id'];
+		            $result['username'] = $user['username'];
+		            $result['avatar'] = $user['avatar'];
+		            $result['info'] = $user['info'];
+		            $result['sex'] = $user['sex'];
+		            $result['title'] = '';
+		        } else {
+		        	!$result['username'] && $result['username'] = $user['username'];
+		        	!$result['avatar'] && $result['avatar'] = $user['avatar'];
+		        	!$result['info'] && $result['info'] = $user['info'];
+		        	!$result['sex'] && $result['sex'] = $user['sex'];
+		        }
+			} else {
+				$result = $user;
+			}
+		}
+
+		$this->user[$user['id']] = $result;
+		
+		return $result;
+	}
+}

+ 160 - 0
app/user/lib/Manage.php

@@ -0,0 +1,160 @@
+<?php
+
+namespace User\Lib;
+
+use Dever;
+
+class Manage
+{
+	public function showOrderUser($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'];
+        }
+
+        if ($info['star_id']) {
+            $star = Dever::db('journal/star')->one($info['star_id']);
+            $table['明星'] = $star['name'];
+        }
+
+        return Dever::table($table);
+    }
+
+    public function showOrderStatus($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);
+            }
+        }
+    }
+
+    # 退款操作
+    public function refund($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;
+                if ($info['cate_id'] == 2) {
+                    $account_id = 7;
+                }
+            } 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';
+    }
+}

+ 5 - 5
app/collection/lib/Seat.php → app/user/lib/Seat.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace Collection\Lib;
+namespace User\Lib;
 
 use Dever;
 
@@ -19,13 +19,13 @@ class Seat
             $where['day'] = -1;
         }
         $where['hall'] = $hall;
-		$my = Dever::db('collection/user_seat')->getMyData($where);
+		$my = Dever::db('user/seat')->getMyData($where);
 
 		$data = array();
 		if ($my) {
 			foreach ($my as $k => $v) {
 				$key = $v['hall'] . '_' . $v['seat_row'] . '_' . $v['seat_column'];
-				$v['user'] = Dever::load('collection/lib/user')->get($v['uid'], $info_id);
+				$v['user'] = Dever::load('user/lib/info')->get($v['uid'], $info_id);
 				$data[$key] = $v;
 			}
 		}
@@ -57,10 +57,10 @@ class Seat
         	$where['hall'] = $v[1];
         	$where['seat_row'] = $v[2];
 	        $where['seat_column'] = $v[3];
-			$info = Dever::db('collection/user_seat')->one($where);
+			$info = Dever::db('user/seat')->one($where);
 			if (!$info) {
 				$where['uid'] = $uid;
-				Dever::db('collection/user_seat')->insert($where);
+				Dever::db('user/seat')->insert($where);
 			}
         }
 		return true;

+ 201 - 0
app/user/lib/Ticket.php

@@ -0,0 +1,201 @@
+<?php
+
+namespace Collection\Lib;
+
+use Dever;
+
+class Ticket
+{
+    # 发起支付
+    public function action($parent_uid, $uid, $buy_id, $source = 'android', $type = false, $type_id = false)
+    {
+        if (!$uid) {
+            Dever::alert('错误的用户信息');
+        }
+
+        $buy = Dever::db('collection/buy')->one($buy_id);
+        if (!$buy) {
+        	Dever::alert('购买失败');
+        }
+        $info = Dever::db('collection/info')->one($buy['info_id']);
+        if (!$info) {
+        	Dever::alert('购买失败');
+        }
+
+        $user = Dever::db('passport/user')->one($uid);
+        $wechat = Dever::db('passport/wechat')->one(array('uid' => $uid, 'type' => 1, 'system_id' => 1));
+
+        if ($source == 'ios') {
+            $method = 'app';
+            $account_id = 3;
+        } elseif ($source == 'android') {
+            $method = 'app';
+            $account_id = 3;
+        } elseif ($source == 'applet') {
+            # 小程序支付
+            $method = 'applet';
+            $account_id = 2;
+        } else {
+            # 网页支付
+            $method = 'page';
+            $account_id = 1;
+        }
+        
+        if ($parent_uid) {
+            $order_data['parent_uid'] = $parent_uid;
+        }
+
+        if ($type) {
+            $order_data['type'] = $type;
+        }
+
+        if ($type_id) {
+            $order_data['type_id'] = $type_id;
+        }
+        
+        $order_data['uid'] = $uid;
+        $order_data['status'] = 1;
+        $order_data['info_id'] = $goods['id'];
+        $order_data['sku_id'] = $sku;
+        $order_data['name'] = $goods['name'];
+        $order_data['cash'] = $goods['price'];
+        $order_data['num'] = $num;
+        $order_data['source'] = $source;
+        $order_data['order_id'] = $this->getOrderId();
+        $id = Dever::db('goods/order')->insert($order_data);
+
+        if (!$id) {
+            Dever::alert('支付失败');
+        }
+
+        $refer = 'test';
+
+        //$param参数
+        $param = array
+        (
+            'account_id' => $account_id,
+            'project_id' => 1,
+            'uid' => $uid,
+            'username' => $user['username'],
+            'name' => $order_data['name'],
+            'cash' => $order_data['cash'] * $order_data['num'],
+            //'cash' => '0.01',
+            'openid' => isset($wechat['openid']) ? $wechat['openid'] : '',
+            'product_id' => $goods['id'],
+            'order_id' => $order_data['order_id'],
+            'refer' => $refer
+        );
+
+        if ($method == 'apple') {
+            $param['other'] = $receipt;
+        }
+
+        $result['pay'] = Dever::load('pay/api.' . $method, $param);
+
+        $result['order_id'] = $order_data['order_id'];
+
+        return $result;
+    }
+
+    # 支付成功回调 安全加密 设置token
+    public function success_secure_api_token()
+    {
+        $project_id = Dever::input('pay_project_id');
+        $info = Dever::db('pay/project')->one($project_id);
+        if ($info) {
+            return $info['key'];
+        }
+        return 'goods_dever_2020';
+    }
+
+    # 支付成功回调 安全加密
+    public function success_secure_api($param = array())
+    {
+        $this->success($param);
+    }
+
+    # 支付成功回调
+    public function success($param = array())
+    {
+        $send = $param ? $param : Dever::preInput('pay_');
+        $order_id = $send['pay_order_id'];
+        $status = $send['pay_status'];
+        $msg = $send['pay_msg'];
+
+        $order = Dever::db('goods/order')->one(array('order_id' => $order_id));
+
+        if ($order && $order['status'] == 1) {
+
+            if ($status == 2) {
+                # 减少库存 增加销量
+                $update['where_id'] = $order['info_id'];
+                $update['sell_num'] = $order['num'];
+                Dever::db('goods/info')->updateSell($update);
+
+                if ($order['sku_id'] > 0) {
+                    $update['where_id'] = $order['sku_id'];
+                    $update['sell_num'] = $order['num'];
+                    Dever::db('goods/info_sku')->updateSell($update);
+                }
+
+                # 增加积分
+                if ($order['parent_uid'] > 0) {
+                    $uid = $order['parent_uid'] . '_' . $order['uid'];
+                } else {
+                    $uid = $order['uid'];
+                }
+                Dever::score($uid, 'buy_my_goods', '购买自营商品', false, false, false, $order['type'], $order['type_id']);
+
+                # 发消息
+                if (Dever::project('message')) {
+                    Dever::load('message/lib/data')->push(-1, $order['uid'], '购买提醒', '购买成功', 11);
+                }
+            }
+
+
+            $update['status'] = $status;
+            $update['where_id'] = $order['id'];
+            Dever::db('goods/order')->update($update);
+        }
+
+        return 'ok';
+    }
+
+    # 生成订单号
+    public function getOrderId()
+    {
+        $where['order_id'] = $this->createOrderId();
+        $state = Dever::db('goods/order')->one($where);
+        if (!$state) {
+            return $where['order_id'];
+        } else {
+            return $this->getOrderId();
+        }
+    }
+
+    # 生成订单号
+    public function createOrderId()
+    {   
+        if (function_exists('session_create_id')) {
+            return strtoupper(session_create_id());
+        } else {
+            $charid = strtoupper(md5(uniqid(mt_rand(), true)));
+            return substr($charid, 0, 8) . substr($charid, 8, 4) . substr($charid, 12, 4) . substr($charid, 16, 4) . substr($charid, 20, 12);
+        }
+    }
+
+    # 临时订单号 无用
+    public function createTmpOrderId($prefix = '')
+    {
+        return $prefix . (strtotime(date('YmdHis', time()))) . substr(microtime(), 2, 6) . sprintf('%03d', rand(0, 999));
+    }
+
+    public function getOrderId($order_id, $id)
+    {
+    	if ($order_id) {
+    		return $order_id . '/' . $id;
+    	} else {
+    		return '无' . '/' . $id;
+    	}
+    }
+}

+ 38 - 0
app/user/lib/Times.php

@@ -0,0 +1,38 @@
+<?php
+
+namespace User\Lib;
+
+use Dever;
+
+class Times
+{
+	public function getData($uid, $id)
+	{
+		$where['info_id'] = $id;
+		$where['uid'] = $uid;
+		return Dever::db('user/times')->getData($where);
+	}
+
+	# 记录用户时光选择操作
+    public function up($uid, $id, $times_id, $day)
+    {
+        $where['info_id'] = $id;
+        $where['uid'] = $uid;
+        $where['times_id'] = $times_id;
+        $record = Dever::db('user/times')->one($where);
+        if (!$day) {
+            $where['day'] = 0;
+        } else {
+            $where['day'] = $day;
+        }
+        
+        if ($record) {
+            $where['where_id'] = $record['id'];
+            Dever::db('user/times')->update($where);
+        } else {
+            Dever::db('user/times')->insert($where);
+        }
+
+        return 'yes';
+    }
+}

+ 40 - 35
app/collection/src/User.php → app/user/src/Api.php

@@ -1,11 +1,11 @@
 <?php
 
-namespace Collection\Src;
+namespace User\Src;
 
 use Dever;
 use Collection\Lib\Core;
 
-class User extends Core
+class Api extends Core
 {
     public function __construct()
     {
@@ -18,7 +18,7 @@ class User extends Core
         $info = $this->checkInfo();
 
         # 获取合集扩展信息
-        $data['user'] = Dever::load('collection/lib/user')->get($this->uid, $this->id);
+        $data['user'] = $this->getUser($this->uid, $this->id);
 
         $score = Dever::load('score/lib/core')->getUserScore($this->uid);
         if ($score) {
@@ -38,45 +38,24 @@ class User extends Core
     # 保存用户信息
     public function up()
     {
-    	$update['username'] = Dever::input('name');
-    	if (!$update['username']) {
-    		Dever::alert('昵称不能为空');
-    	}
-    	$update['title'] = Dever::input('title');
-    	$update['info'] = Dever::input('info');
-    	$update['info_id'] = $this->id;
-    	$user = Dever::db('collection/user')->one(array('uid' => $this->uid));
-        if (!$user) {
-        	$update['uid'] = $this->uid;
-            Dever::db('collection/user')->insert($update);
-        } else {
-        	$update['where_id'] = $user['id'];
-        	Dever::db('collection/user')->update($update);
-        }
+        $username = Dever::input('name');
+        $title = Dever::input('title');
+        $info = Dever::input('info');
+
+        Dever::load('user/lib/info')->up($this->uid, $this->id, $username, $title, $info);
         return 'ok';
     }
 
     # 保存头像
     public function upAvatar()
     {
-    	$update['avatar'] = Dever::input('avatar');
-    	if (!$update['avatar']) {
-    		Dever::alert('头像不能为空');
-    	}
-    	$update['info_id'] = $this->id;
-    	$user = Dever::db('collection/user')->one(array('uid' => $this->uid));
-        if (!$user) {
-        	$update['uid'] = $this->uid;
-            Dever::db('collection/user')->insert($update);
-        } else {
-        	$update['where_id'] = $user['id'];
-        	Dever::db('collection/user')->update($update);
-        }
+    	$avatar = Dever::input('avatar');
+    	Dever::load('user/lib/info')->up($this->uid, $this->id, $avatar);
         return 'ok';
     }
 
-    # 查看我的订单
-    public function order()
+    # 查看我的商品订单
+    public function goods_order()
     {
         $data['order'] = Dever::load('goods/lib/order')->getList($this->uid, 'collection/info', $this->id);
         return $data;
@@ -95,7 +74,7 @@ class User extends Core
         $content_id = Dever::input('content_id');
         $hall = Dever::input('hall', 1);
 
-        $data = Dever::load('collection/lib/seat')->get($this->uid, $this->id, $this->parent_page_id, $this->page_id, $this->times, $this->day, $content_id, $this->index, $hall);
+        $data = Dever::load('user/lib/seat')->get($this->uid, $this->id, $this->parent_page_id, $this->page_id, $this->times, $this->day, $content_id, $this->index, $hall);
 
         $data['user'] = $this->user;
         $data['hall'] = $hall;
@@ -108,8 +87,34 @@ class User extends Core
         $content_id = Dever::input('content_id');
         $seat = Dever::input('seat');
 
-        $data = Dever::load('collection/lib/seat')->save($this->uid, $this->id, $this->parent_page_id, $this->page_id, $this->times, $this->day, $content_id, $this->index, $seat);
+        $data = Dever::load('user/lib/seat')->save($this->uid, $this->id, $this->parent_page_id, $this->page_id, $this->times, $this->day, $content_id, $this->index, $seat);
 
         return 'ok';
     }
+
+    # 记录用户操作
+    public function record()
+    {
+        $where['info_id'] = $this->id;
+        $where['uid'] = $this->uid;
+        $record = Dever::db('user/record')->one($where);
+        $where['parent_page_id'] = $this->parent_page_id;
+        $where['page_id'] = $this->page_id;
+        $where['times_id'] = $this->times;
+        if (!$this->day) {
+            $where['day'] = 0;
+        } else {
+            $where['day'] = $this->day;
+        }
+        $where['content_id'] = Dever::input('content_id');
+        $where['index'] = Dever::input('index', 0);
+        if ($record) {
+            $where['where_id'] = $record['id'];
+            Dever::db('user/record')->update($where);
+        } else {
+            Dever::db('user/record')->insert($where);
+        }
+
+        return 'yes';
+    }
 }

+ 71 - 0
app/user/src/Pay.php

@@ -0,0 +1,71 @@
+<?php
+
+namespace User\Src;
+
+use Dever;
+use Collection\Lib\Core;
+
+class Pay extends Core
+{
+    # 购买产品 下单
+    public function product()
+    {
+        if (!$this->user) {
+            Dever::alert('用户信息错误');
+        }
+
+        $uid = $this->uid;
+
+        $content_id = Dever::input('content_id');
+        $goods_id = Dever::input('goods_id');
+        $num = Dever::input('num');
+        $sku = Dever::input('sku');
+
+        if (!$goods_id) {
+            Dever::alert('请传入正确的产品ID');
+        }
+
+        $pay = Dever::load('goods/lib/pay')->action($this->share_uid, $uid, $goods_id, $sku, $num, $this->source, 'collection/info', $this->id);
+
+        //return $pay;
+
+        # 直接支付成功 测试用
+        $send['pay_order_id'] = $pay['order_id'];
+        $send['pay_status'] = 2;
+        $send['pay_msg'] = 'yes';
+        $send['dever_token'] = 'goods_dever_2020';
+        Dever::load('goods/lib/pay.success', $send);
+
+        return $send;
+    }
+
+    # 购买门票 下单
+    public function ticket()
+    {
+        if (!$this->user) {
+            Dever::alert('用户信息错误');
+        }
+
+        $uid = $this->uid;
+
+        $buy_id = Dever::input('buy_id');
+
+        if (!$buy_id) {
+            Dever::alert('请选择正确的门票');
+        }
+
+        $pay = Dever::load('user/lib/ticket')->action($this->share_uid, $uid, $buy_id, 'collection/info', $this->id);
+        print_r($pay);die;
+
+        //return $pay;
+
+        # 直接支付成功 测试用
+        $send['pay_order_id'] = $pay['order_id'];
+        $send['pay_status'] = 2;
+        $send['pay_msg'] = 'yes';
+        $send['dever_token'] = 'ticket_dever_2020';
+        Dever::load('collection/lib/buy.success', $send);
+
+        return $send;
+    }
+}