dever před 5 roky
rodič
revize
4586c98a04

+ 95 - 0
app/user/database/collection.php

@@ -0,0 +1,95 @@
+<?php
+
+return array
+(
+    # 表名
+    'name' => 'collection',
+    # 显示给用户看的名称
+    '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',
+        ),
+
+        'num'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '拥有数量',
+            'default'   => '0',
+            'desc'      => '拥有数量',
+            '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
+    (
+        
+    ),
+);

+ 35 - 0
app/user/lib/Collection.php

@@ -0,0 +1,35 @@
+<?php
+
+namespace User\Lib;
+
+use Dever;
+
+class Collection
+{
+    # 保存信息
+    public function up($uid, $info_id, $num = 1)
+    {
+        $where['uid'] = $uid;
+        $where['info_id'] = $info_id;
+        $info = Dever::db('user/collection')->one($where);
+        if (!$info) {
+            $where['num'] = $num;
+            Dever::db('user/collection')->insert($update);
+        } else {
+            $update['where_id'] = $info['id'];
+            $update['num'] = $info['num'] + $num;
+            Dever::db('user/collection')->update($update);
+        }
+        return true;
+    }
+
+    # 获取信息
+    public function one($uid, $info_id)
+    {
+        $where['uid'] = $uid;
+        $where['info_id'] = $info_id;
+        $info = Dever::db('user/collection')->one($where);
+
+        return $info;
+    }
+}

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

@@ -110,6 +110,8 @@ class Ticket
         if ($order && $order['status'] == 1) {
             if ($status == 2) {
 
+                # 更新购买数量
+                Dever::load('user/lib/collection')->up($order['uid'], $order['info_id'], $order['buy_num']);
                 # 增加积分
                 if ($order['parent_uid'] > 0) {
                     $uid = $order['parent_uid'] . '_' . $order['uid'];