dever 6 years ago
parent
commit
58747c2eee
2 changed files with 17 additions and 0 deletions
  1. 1 0
      doc/apidoc.php
  2. 16 0
      main/src/Journal.php

+ 1 - 0
doc/apidoc.php

@@ -769,6 +769,7 @@
  *
  * @apiSuccess {Object[]}   active 活动说明表
  * @apiSuccess {String}   active.name 名称
+ * @apiSuccess {String}   active.status 活动状态 1活动进行中 2活动已结束
  * @apiSuccess {String}   active.desc 描述
  * @apiSuccess {String}   active.buy_title 购买标题
  * @apiSuccess {String}   active.buy_desc 购买描述

+ 16 - 0
main/src/Journal.php

@@ -209,6 +209,22 @@ class Journal extends Core
         # 获取活动说明
         $this->data['active'] = Dever::db('journal/active')->one(array('id' => $id));
 
+
+        if (!$this->data['active']) {
+            return $this->data;
+        }
+
+        $time = time();
+        if ($this->data['active'] && $time >= $this->data['active']['start'] && $time < $this->data['active']['end']) {
+            $this->data['active']['status'] = 1;
+        } else {
+            $this->data['active']['status'] = 2;
+        }
+
+        if ($time < $this->data['active']['start']) {
+            $this->data['active']['status'] = 3;
+        }
+
         $this->data['active']['buy_title'] = '';
         $this->data['active']['buy_desc'] = '';
         if ($buy) {