From ab5e815b1d9e34874e8a6e66123f59d5a567fac1 Mon Sep 17 00:00:00 2001 From: xiaochong0302 Date: Mon, 25 Dec 2023 20:18:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E7=94=A8=E6=88=B7active=5Fti?= =?UTF-8?q?me=E6=90=9C=E7=B4=A2=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Caches/Counter.php | 23 ++++------------------- app/Caches/UserDailyCounter.php | 2 -- app/Http/Admin/Views/user/search.volt | 2 +- app/Http/Home/Views/order/confirm.volt | 12 ++++++------ app/Library/Paginator/Query.php | 4 ++-- 5 files changed, 13 insertions(+), 30 deletions(-) diff --git a/app/Caches/Counter.php b/app/Caches/Counter.php index 7d985e02..14ece69f 100644 --- a/app/Caches/Counter.php +++ b/app/Caches/Counter.php @@ -9,6 +9,7 @@ namespace App\Caches; use App\Library\Cache\Backend\Redis as RedisCache; use Phalcon\Di\Injectable; +use Redis; abstract class Counter extends Injectable { @@ -19,7 +20,7 @@ abstract class Counter extends Injectable protected $cache; /** - * @var \Redis + * @var Redis */ protected $redis; @@ -30,19 +31,13 @@ abstract class Counter extends Injectable $this->redis = $this->cache->getRedis(); } - /** - * 获取缓存内容 - * - * @param mixed $id - * @return array - */ public function get($id = null) { $key = $this->getKey($id); $content = $this->redis->hGetAll($key); - if (!$this->cache->exists($key)) { + if (!$this->redis->exists($key)) { $content = $this->getContent($id); $lifetime = $this->getLifetime(); @@ -54,23 +49,13 @@ abstract class Counter extends Injectable return $content; } - /** - * 删除缓存内容 - * - * @param mixed $id - */ public function delete($id = null) { $key = $this->getKey($id); - $this->cache->delete($key); + $this->redis->del($key); } - /** - * 重建缓存内容 - * - * @param mixed $id - */ public function rebuild($id = null) { $this->delete($id); diff --git a/app/Caches/UserDailyCounter.php b/app/Caches/UserDailyCounter.php index 19f59830..9497d1c7 100644 --- a/app/Caches/UserDailyCounter.php +++ b/app/Caches/UserDailyCounter.php @@ -10,8 +10,6 @@ namespace App\Caches; class UserDailyCounter extends Counter { - protected $lifetime = 86400; - public function getLifetime() { $tomorrow = strtotime('tomorrow'); diff --git a/app/Http/Admin/Views/user/search.volt b/app/Http/Admin/Views/user/search.volt index 0d88f3c3..df41dc26 100644 --- a/app/Http/Admin/Views/user/search.volt +++ b/app/Http/Admin/Views/user/search.volt @@ -35,7 +35,7 @@
-
- +
diff --git a/app/Http/Home/Views/order/confirm.volt b/app/Http/Home/Views/order/confirm.volt index 0da3b7c8..d9e18393 100644 --- a/app/Http/Home/Views/order/confirm.volt +++ b/app/Http/Home/Views/order/confirm.volt @@ -4,7 +4,7 @@ {{ partial('macros/course') }} - {%- macro cart_course_card(course, user) %} + {%- macro cart_course_card(course) %} {% set course_url = url({'for':'home.course.show','id':course.id}) %}
@@ -21,10 +21,10 @@ {% if course.model in [1,2,3] %}

学习期限 - {{ course.study_expiry }}个月 + {{ course.study_expiry }} 个月 {% if course.refund_expiry > 0 %} 退款期限 - {{ course.refund_expiry }}天 + {{ course.refund_expiry }} 天 {% else %} 退款期限 不支持 @@ -82,7 +82,7 @@

期限 - {{ vip.expiry }}个月 + {{ vip.expiry }} 个月

@@ -96,11 +96,11 @@
{% if confirm.item_type == 1 %} {% set course = confirm.item_info.course %} - {{ cart_course_card(course, auth_user) }} + {{ cart_course_card(course) }} {% elseif confirm.item_type == 2 %} {% set package = confirm.item_info.package %} {% for course in package.courses %} - {{ cart_course_card(course, auth_user) }} + {{ cart_course_card(course) }} {% endfor %} {% elseif confirm.item_type == 3 %} {{ cart_reward_card(confirm.item_info) }} diff --git a/app/Library/Paginator/Query.php b/app/Library/Paginator/Query.php index 66f2d839..560512cb 100644 --- a/app/Library/Paginator/Query.php +++ b/app/Library/Paginator/Query.php @@ -35,14 +35,14 @@ class Query { $page = $this->request->getQuery('page', ['trim', 'int'], 1); - return $page > 100 ? 100 : $page; + return min($page, 100); } public function getLimit() { $limit = $this->request->getQuery('limit', ['trim', 'int'], 12); - return $limit > 100 ? 100 : $limit; + return min($limit, 100); } public function getSort()