dever %!s(int64=4) %!d(string=hai) anos
pai
achega
c34b155bd1

+ 6 - 31
app/collection/database/buy.php

@@ -50,8 +50,9 @@ return array
             'desc'      => '购买数量',
             'match'     => 'option',
             'update'    => 'text',
-            //'search'    => 'fulltext',
+            'search'    => 'order',
             'list'      => true,
+            'order'     => 'asc',
         ),
 
         'name'      => array
@@ -63,7 +64,7 @@ return array
             'match'     => 'option',
             'update'    => 'text',
             //'search'    => 'fulltext',
-            'list'      => 'Dever::load("collection/lib/manage.getName", {id})',
+            'list'      => 'Dever::load("collection/lib/buy.getName", {id})',
         ),
 
         'price'     => array
@@ -74,34 +75,7 @@ return array
             'desc'      => '购买时的标价',
             'match'     => 'option',
             'update'    => 'text',
-            'list'      => 'Dever::load("collection/lib/manage.getPrice", {id})',
-        ),
-
-        '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,
+            'list'      => 'Dever::load("collection/lib/buy.getPriceName", {id})',
         ),
 
         'state'     => array
@@ -143,8 +117,9 @@ return array
                 'state' => 1,
             ),
             'type' => 'all',
-            'order' => array('reorder' => 'desc', 'cdate' => 'desc'),
+            'order' => array('num' => 'asc', 'cdate' => 'desc'),
             'col' => '*',
+            'call' => 'collection/lib/buy.getInfo',
         ),
     ),
 );

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 472 - 608
app/collection/database/info.php


+ 54 - 0
app/collection/lib/Buy.php

@@ -0,0 +1,54 @@
+<?php
+
+namespace Collection\Lib;
+
+use Dever;
+
+class Buy
+{
+
+    private function getOne($info)
+    {
+        if (!is_array($info)) {
+            $info = Dever::db('collection/buy')->one($info);
+        }
+
+        return $info;
+    }
+
+    public function getInfo($info)
+    {
+        $info['name'] = $this->getName($info);
+        $info['price'] = $this->getPrice($info);
+        return $info;
+    }
+
+    public function getName($info)
+    {
+        $info = $this->getOne($info);
+        if ($info && $info['name']) {
+            return $info['name'];
+        } else {
+            return '购买' . $info['num'] . '张';
+        }
+    }
+
+    public function getPrice($info)
+    {
+        $info = $this->getOne($info);
+
+        $collection = Dever::db('collection/info')->one($info['info_id']);
+        if ($info['price'] > 0) {
+            return $info['price'];
+        } else {
+            return $info['num'] * $collection['buy_price'];
+        }
+    }
+
+    public function getPriceName($info)
+    {
+        $price = $this->getPrice($info);
+
+        return $price . '元';
+    }
+}

+ 14 - 0
app/collection/lib/Core.php

@@ -0,0 +1,14 @@
+<?php
+
+namespace Collection\Lib;
+
+use Dever;
+
+class Core
+{
+    public function __construct()
+    {
+        $this->token = Dever::input('token');
+        $this->uid = 1;
+    }
+}

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

@@ -307,28 +307,6 @@ class Manage
         }
     }
 
-    public function getName($id)
-    {
-        $info = Dever::db('collection/buy')->one($id);
-        if ($info && $info['name']) {
-            return $info['name'];
-        } else {
-            return '购买' . $info['num'] . '张';
-        }
-    }
-
-    public function getPrice($id)
-    {
-        $info = Dever::db('collection/buy')->one($id);
-
-        $collection = Dever::db('collection/info')->one($info['info_id']);
-        if ($info && $info['price']) {
-            return $info['price'];
-        } else {
-            return $info['num'] * $collection['cash'] . '元';
-        }
-    }
-
     public function setJournalCache($id, $name, $param)
     {
         Dever::load('act/order')->setCache($id, 1);

+ 47 - 1
app/collection/src/Api.php

@@ -3,8 +3,9 @@
 namespace Collection\Src;
 
 use Dever;
+use Collection\Lib\Core;
 
-class Api
+class Api extends Core
 {
     public function test1()
     {
@@ -23,6 +24,51 @@ class Api
         return Dever::db('collection/info')->state();
     }
 
+    # 获取合集内容
+    public function getInfo()
+    {
+        $id = Dever::input('id');
+        # 是否已经购买
+        $data['is_buy'] = false;
+        $data['button'] = array(
+            'style' => 'background: linear-gradient(to right, #000000,#000000) !important;',
+            'color' => '#fff',
+            'name' => array('入口', '排行榜')
+        );
+        $data['info'] = Dever::db('collection/info')->one($id);
+        if ($data['info']) {
+            $data['info']['pic_bg'] = explode(',', $data['info']['pic_bg']);
+
+            if ($data['info']['buy'] == 1) {
+                # 收费 从订单中读取是否已经购买
+                $data['is_buy'] = false;
+            } else {
+                # 免费
+                $data['is_buy'] = true;
+            }
+
+            $data['button']['name'] = explode(',', $data['info']['button']);
+            if ($data['info']['button_bgcolor'] && $data['info']['button_bgjcolor']) {
+                $data['button']['style'] = 'background: linear-gradient(to right, '.$data['info']['button_bgcolor'].','.$data['info']['button_bgjcolor'].') !important;';
+            }
+            if ($data['info']['button_ftcolor']) {
+                $data['button']['color'] = 'color:' . $data['info']['button_ftcolor'];
+            }
+        }
+
+        return $data;
+    }
+
+    # 获取合集下的购买内容
+    public function getBuy()
+    {
+        $id = Dever::input('id');
+        $where['info_id'] = $id;
+        $data['buy'] = Dever::db('collection/buy')->getAll($where);
+
+        return $data;
+    }
+
     # 获取合集下的内容
     public function getContent()
     {

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio