allen 3 жил өмнө
parent
commit
86b17e587b

+ 2 - 0
.example.env

@@ -20,6 +20,8 @@ HOST=
 PORT= 6379
 # REDIS 服务器密码
 PASS=
+# DB 服务器数据库
+DB=
 
 [LANG]
 default_lang = zh-cn

+ 67 - 3
app/index/controller/Index.php

@@ -319,7 +319,7 @@ class Index extends Controller
             ->order('l.create_at', 'desc')
             ->order('l.number', 'desc')
             ->order('l.duration', 'asc')
-            ->limit(15)
+            ->limit(50)
             ->select();
 
         $userInfo = Db::table('awards_user_task_log')->alias('l')
@@ -394,7 +394,7 @@ class Index extends Controller
     }
 
     /**
-     * 获取中奖信息接口
+     * 获取轮播中奖接口
      * @throws FuncNotFoundException
      * @throws ClassNotFoundException
      * @throws DbException
@@ -402,7 +402,7 @@ class Index extends Controller
      * @throws DataNotFoundException
      * @return mixed
      */
-    public function getWinAward() {
+    public function getRotationAward() {
 
         $activity = Db::table('awards_activity')->where('begin_at', '<=', time())
             ->where('end_at', '>=', time())->find();
@@ -420,6 +420,70 @@ class Index extends Controller
         return $this->successResponse($orders);
     }
 
+    /**
+     * 排行中奖接口
+     * @throws FuncNotFoundException
+     * @throws ClassNotFoundException
+     * @throws DbException
+     * @throws ModelNotFoundException
+     * @throws DataNotFoundException
+     * @return mixed
+     */
+    public function getRankingWinAward() {
+
+        $ranking = Db::table('awards_user_task_log')->alias("l")
+            ->leftJoin('awards_user_info u', 'l.uid = u.uid')
+            ->field(['u.nickname', 'u.portrait', 'u.uid', 'l.duration', 'l.number'])
+            ->order('l.number', 'desc')
+            ->order('l.duration', 'asc')
+            ->limit(50)
+            ->select();
+
+        $isWinAward = 0;
+        foreach ($ranking as $val) {
+            if ($val['uid'] == Safe::$user['uid']) {
+                $isWinAward = 1;
+            }
+        }
+
+        return $this->successResponse([
+            'isWinAward' => $isWinAward,
+            'giftId' => 0
+        ]);
+    }
+
+    /**
+     * 抽奖接口
+     * @throws FuncNotFoundException
+     * @throws ClassNotFoundException
+     * @throws DbException
+     * @throws ModelNotFoundException
+     * @throws DataNotFoundException
+     * @return mixed
+     */
+    public function getLuckDraw()
+    {
+        $ranking = Db::table('awards_user_task_log')->alias("l")
+            ->leftJoin('awards_user_info u', 'l.uid = u.uid')
+            ->field(['u.nickname', 'u.portrait', 'u.uid', 'l.duration', 'l.number'])
+            ->order('l.number', 'desc')
+            ->order('l.duration', 'asc')
+            ->limit(50)
+            ->select();
+
+        $isWinAward = 0;
+        foreach ($ranking as $val) {
+            if ($val['uid'] == Safe::$user['uid']) {
+                $isWinAward = 1;
+            }
+        }
+
+        return $this->successResponse([
+            'isWinAward' => $isWinAward,
+            'giftId' => 0
+        ]);
+    }
+
     /**
      * 品牌任务关注接口
      * @throws FuncNotFoundException

+ 1 - 1
config/cache.php

@@ -24,7 +24,7 @@ return [
             'host'     => env('redis.host', '127.0.0.1'),
             'port'     => env('redis.port', '6379'),
             'password' => env('redis.pass', ''),
-            'select'   => '0',
+            'select'   => env('redis.db', '0'),
             // 全局缓存有效期(0为永久有效)
             'expire'   => 15552000,
             // 缓存前缀