allen 3 年之前
父節點
當前提交
f49e4d136e
共有 1 個文件被更改,包括 52 次插入1 次删除
  1. 52 1
      app/index/controller/Index.php

+ 52 - 1
app/index/controller/Index.php

@@ -116,13 +116,21 @@ class Index extends Controller
             'uid' => $user['uid'],
         ];
 
+        $activity = Db::table('awards_activity')->where('begin_at', '<=', time())
+            ->where('end_at', '>=', time())->find();
+
+        $isBeginActivity = 1;
+        if (empty($activity)) {
+            $isBeginActivity = 0;
+        }
         // 缓存用户信息1天
         Cache::set('u:' . $token, json_encode($cacheUser), 86400);
         return $this->successResponse([
             'user' => $user,
             'token' => $token,
             'isShare' => $isShare,
-            'count' => $count
+            'count' => $count,
+            'isBeginActivity' => $isBeginActivity
         ]);
     }
 
@@ -134,6 +142,12 @@ class Index extends Controller
      */
     public function checkRole()
     {
+        $activity = Db::table('awards_activity')->where('begin_at', '<=', time())
+            ->where('end_at', '>=', time())->find();
+        if (empty($activity)) {
+            return $this->response(5002, '活动末开始');
+        }
+
         $userInfo = Db::table('awards_user_info')->where('uid', Safe::$user['uid'])->find();
         $count = Db::table('awards_user_task_log')->where('uid', Safe::$user['uid'])->count('id');
         return $this->successResponse([
@@ -153,6 +167,12 @@ class Index extends Controller
      */
     public function submitTask()
     {
+        $activity = Db::table('awards_activity')->where('begin_at', '<=', time())
+            ->where('end_at', '>=', time())->find();
+        if (empty($activity)) {
+            return $this->response(5002, '活动末开始');
+        }
+
 //        if (empty(Safe::$body)) {
 //            return $this->response(5003, '参数有误');
 //        }
@@ -207,6 +227,12 @@ class Index extends Controller
      */
     public function submitShare()
     {
+        $activity = Db::table('awards_activity')->where('begin_at', '<=', time())
+            ->where('end_at', '>=', time())->find();
+        if (empty($activity)) {
+            return $this->response(5002, '活动末开始');
+        }
+
         $userInfo = Db::table('awards_user_info')->where('uid', Safe::$user['uid'])->find();
         if (empty($userInfo)) {
             return $this->response(403, '没有登录');
@@ -241,6 +267,12 @@ class Index extends Controller
      */
     public function ranking()
     {
+        $activity = Db::table('awards_activity')->where('begin_at', '<=', time())
+            ->where('end_at', '>=', time())->find();
+        if (empty($activity)) {
+            return $this->response(5002, '活动末开始');
+        }
+
         $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'])
@@ -275,6 +307,12 @@ class Index extends Controller
      */
     public function newRanking()
     {
+        $activity = Db::table('awards_activity')->where('begin_at', '<=', time())
+            ->where('end_at', '>=', time())->find();
+        if (empty($activity)) {
+            return $this->response(5002, '活动末开始');
+        }
+
         $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'])
@@ -310,6 +348,12 @@ class Index extends Controller
      */
     public function submitReceive()
     {
+        $activity = Db::table('awards_activity')->where('begin_at', '<=', time())
+            ->where('end_at', '>=', time())->find();
+        if (empty($activity)) {
+            return $this->response(5002, '活动末开始');
+        }
+
         $name = trim(Request::post("name"));
         $mobile = trim(Request::post("mobile"));
         $address = trim(Request::post("address"));
@@ -339,6 +383,7 @@ class Index extends Controller
             'mobile' => $mobile,
             'address' => $address,
             'gift_at' => $giftId,
+            'type' => $type,
             'create_at' => time(),
         ];
         if (0 == Db::table('awards_order')->insert($order)) {
@@ -359,6 +404,12 @@ class Index extends Controller
      */
     public function getWinAward() {
 
+        $activity = Db::table('awards_activity')->where('begin_at', '<=', time())
+            ->where('end_at', '>=', time())->find();
+        if (empty($activity)) {
+            return $this->response(5002, '活动末开始');
+        }
+
         $orders = Db::table('awards_order')->alias('o')
             ->leftJoin('awards_user_info u', 'o.uid = u.uid')
             ->leftJoin('awards_gift g', 'o.gift_id = g.id')