dever 4 rokov pred
rodič
commit
799ae1fa45

+ 17 - 0
app/community/database/comment.php

@@ -150,5 +150,22 @@ return array
 			'page' => array(1000, 'list'),
 			'col' => '*',
 		),
+
+		'getData' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'uid' => 'yes',
+				'type' => 'yes',
+				'type_id' => 'yes',
+				'noid' => array('yes-id', '!='),
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('id' => 'desc'),
+			'page' => array(10, 'list'),
+			'col' => '*',
+		),
 	)
 );

+ 13 - 0
app/community/database/up.php

@@ -131,5 +131,18 @@ return array
 			'limit' => '0,10',
 			'col' => '*',
 		),
+
+		'getTotal' => array
+		(
+			# 匹配的正则或函数 选填项
+			'option' => array
+			(
+				'uid' => 'yes',
+				'type' => 'yes',
+				'type_id' => 'yes',
+				'state' => 1,
+			),
+			'type' => 'count',
+		),
 	)
 );

+ 14 - 8
app/community/lib/Core.php

@@ -39,10 +39,12 @@ class Core
         $info = Dever::db($this->table)->getHot($where);
         
         $result = array();
+        $result['user'] = array();
+        $result['total'] = 0;
         if ($info) {
             foreach ($info as $k => $v) {
                 $user = Dever::load('user/lib/info')->get($v['uid'], $collection_id, true);
-                $result[] = array
+                $result['user']['user_' . $user['id']] = array
                 (
                     'id' => $user['id'],
                     'username' => $user['username'],
@@ -51,6 +53,15 @@ class Core
             }
         }
 
+        $max = 1;
+        $total = count($info);
+        if ($total >= $max) {
+            $all = Dever::db($this->table)->getTotal($where);
+            if ($all > $total) {
+                $result['total'] = $all - $total;
+            }
+        }
+
         return $result;
     }
 
@@ -74,13 +85,8 @@ class Core
             $up = 1;
             Dever::db($this->table)->insert($where);
         } else {
-            if ($info['state'] == 1) {
-                $up = 2;
-                Dever::db($this->table)->update(array('where_id' => $info['id'], 'state' => 2));
-            } else {
-                $up = 1;
-                Dever::db($this->table)->update(array('where_id' => $info['id'], 'state' => 1));
-            }
+            $up = 2;
+            Dever::db($this->table)->delete($info['id']);
         }
 
         # 更新点赞数

+ 34 - 3
app/community/lib/Moment.php

@@ -14,6 +14,19 @@ class Moment
         return $table;
     }
 
+    public function del($uid, $id, $state = 2)
+    {
+        $where['id'] = $id;
+        $where['uid'] = $uid;
+        $info = Dever::db($this->table)->one($where);
+        if ($info) {
+            $update['where_id'] = $id;
+            $update['state'] = $state;
+            Dever::db($this->table)->update($update);
+        }
+        return true;
+    }
+
     public function getData($method = 'getAll', $uid, $type = false, $type_id = false, $total = false, $id = false, $times = false, $day = false, $collection_id = false)
     {
         $where['type'] = $type;
@@ -68,10 +81,16 @@ class Moment
         $where['uid'] = $uid;
         $where['type_id'] = $id;
         $where['type'] = $type;
-        $where['content'] = $content;
+        $where['state'] = 1;
         $table = $this->table;
-        //$info = Dever::db($table)->one($where);
-        $info = false;
+        $info = Dever::db($table)->one($where);
+
+        $where['content'] = $content;
+
+        if ($info) {
+            Dever::alert('已发布过动态,仅能发布一次,可删除旧动态后再添加');
+        }
+        //$info = false;
         if ($pic) {
             $where['pic'] = $pic;
         }
@@ -107,6 +126,14 @@ class Moment
 
     private function one($uid, $info, $times = false, $collection_id = false)
     {
+        # 验证消息是否是自己的
+        $info['me'] = 2;
+        $info['del'] = '';
+        if ($uid == $info['uid']) {
+            $info['me'] = 1;
+            $info['del'] = '删除';
+            $info['del_state'] = 2;
+        }
         $key = 30;
         $info['pic'] = explode(',', $info['pic']);
         $info['user'] = Dever::load('user/lib/info')->get($info['uid'], $collection_id, true);
@@ -116,9 +143,13 @@ class Moment
         # 点赞数
         $info['num_up'] = $info['num_up'] + 0;
         $info['up_list'] = array();
+        $info['up_list']['user'] = (object) array();
+        $info['up_list']['total'] = 0;
+        $info['up_list_total'] = 0;
         if ($info['num_up'] > 0) {
             # 批量获取最新的点赞名单
             $info['up_list'] = Dever::load('community/lib/up')->getData($info['id'], $key, $collection_id);
+            $info['up_list_total'] = count($info['up_list']['user']);
         }
 
         # 反对数

+ 13 - 2
app/community/src/Api.php

@@ -64,11 +64,11 @@ class Api extends Core
         return $data;
     }
 
-    # 获取弹幕、评论
+    # 获取评论
     public function comment()
     {
         $user = Dever::input('user', false);
-        $data = Dever::load('community/lib/comment')->getData('getAll', $this->uid, $this->type, $this->type_id, $user, $this->id);
+        $data = Dever::load('community/lib/comment')->getData('getData', $this->uid, $this->type, $this->type_id, $user, $this->id);
         return $data;
     }
 
@@ -197,6 +197,17 @@ class Api extends Core
         return 'yes';
     }
 
+    # 删除朋友圈帖子
+    public function delMoment()
+    {
+        $id = Dever::input('moment_id');
+        $state = Dever::input('state');
+
+        Dever::load('community/lib/moment')->del($this->uid, $id, $state);
+
+        return 'yes';
+    }
+
     # 点赞
     public function up()
     {

+ 16 - 2
app/user/src/Api.php

@@ -89,9 +89,21 @@ class Api extends Core
     }
 
     # 查看我的商品订单
+    public function my_goods_order()
+    {
+        $data['order'] = Dever::load('goods/lib/order')->getMyList($this->uid, 'collection/info', $this->id);
+        return $data;
+    }
+
+    # 获取某个商品的所有订单
     public function goods_order()
     {
-        $data['order'] = Dever::load('goods/lib/order')->getList($this->uid, 'collection/info', $this->id);
+        $id = Dever::input('info_id');
+        $callback = function($order) {
+            $order['user'] = Dever::load('user/lib/info')->get($order['uid'], $this->id, true);
+            return $order;
+        };
+        $data['order'] = Dever::load('goods/lib/order')->getList($id, 'collection/info', $this->id, $callback);
         return $data;
     }
 
@@ -151,7 +163,9 @@ class Api extends Core
             Dever::db('user/record')->insert($where);
         }
 
-        return 'ok';
+        $data['code'] = $this->getCode($this->id, $this->parent_page_id, $this->page_id, $where['index'], $this->times, $this->day, $this->share_uid, $this->ticket_id);
+
+        return $data;
     }
 
     # 保存门票说明信息

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

@@ -32,6 +32,10 @@ class Pay extends Core
             Dever::alert('请传入正确的产品ID');
         }
 
+        if ($num <= 0) {
+            Dever::alert('请传入购买数量');
+        }
+
         $pay = Dever::load('goods/lib/pay')->action($this->share_uid, $this->user, $goods_id, $sku, $num, $mode, $store_id, $this->system_source, 'collection/info', $this->id, $refer);
 
         return $pay;