From 3fbb68f713020bb161082fba04991ead084912f1 Mon Sep 17 00:00:00 2001 From: koogua Date: Mon, 18 Oct 2021 18:56:53 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E7=BC=93=E5=AD=98=E8=99=9A=E6=8B=9F=E7=94=A8=E6=88=B7=E6=95=B0?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Caches/IndexFeaturedCourseList.php | 9 ++++++++- app/Caches/IndexFreeCourseList.php | 9 ++++++++- app/Caches/IndexNewCourseList.php | 9 ++++++++- app/Caches/IndexSimpleFeaturedCourseList.php | 9 ++++++++- app/Caches/IndexSimpleFreeCourseList.php | 9 ++++++++- app/Caches/IndexSimpleNewCourseList.php | 9 ++++++++- app/Caches/IndexSimpleVipCourseList.php | 9 ++++++++- app/Caches/IndexVipCourseList.php | 9 ++++++++- 8 files changed, 64 insertions(+), 8 deletions(-) diff --git a/app/Caches/IndexFeaturedCourseList.php b/app/Caches/IndexFeaturedCourseList.php index 9ef38676..db32e861 100644 --- a/app/Caches/IndexFeaturedCourseList.php +++ b/app/Caches/IndexFeaturedCourseList.php @@ -65,6 +65,13 @@ class IndexFeaturedCourseList extends Cache $categoryCourses = []; foreach ($courses as $course) { + + $userCount = $course->user_count; + + if ($course->fake_user_count > $course->user_count) { + $userCount = $course->fake_user_count; + } + $categoryCourses[] = [ 'id' => $course->id, 'title' => $course->title, @@ -73,7 +80,7 @@ class IndexFeaturedCourseList extends Cache 'vip_price' => $course->vip_price, 'model' => $course->model, 'level' => $course->level, - 'user_count' => $course->user_count, + 'user_count' => $userCount, 'lesson_count' => $course->lesson_count, ]; } diff --git a/app/Caches/IndexFreeCourseList.php b/app/Caches/IndexFreeCourseList.php index ecd23215..23e1c41e 100644 --- a/app/Caches/IndexFreeCourseList.php +++ b/app/Caches/IndexFreeCourseList.php @@ -65,6 +65,13 @@ class IndexFreeCourseList extends Cache $categoryCourses = []; foreach ($courses as $course) { + + $userCount = $course->user_count; + + if ($course->fake_user_count > $course->user_count) { + $userCount = $course->fake_user_count; + } + $categoryCourses[] = [ 'id' => $course->id, 'title' => $course->title, @@ -73,7 +80,7 @@ class IndexFreeCourseList extends Cache 'vip_price' => $course->vip_price, 'model' => $course->model, 'level' => $course->level, - 'user_count' => $course->user_count, + 'user_count' => $userCount, 'lesson_count' => $course->lesson_count, ]; } diff --git a/app/Caches/IndexNewCourseList.php b/app/Caches/IndexNewCourseList.php index 1049d2c2..33bb9b32 100644 --- a/app/Caches/IndexNewCourseList.php +++ b/app/Caches/IndexNewCourseList.php @@ -65,6 +65,13 @@ class IndexNewCourseList extends Cache $categoryCourses = []; foreach ($courses as $course) { + + $userCount = $course->user_count; + + if ($course->fake_user_count > $course->user_count) { + $userCount = $course->fake_user_count; + } + $categoryCourses[] = [ 'id' => $course->id, 'title' => $course->title, @@ -73,7 +80,7 @@ class IndexNewCourseList extends Cache 'vip_price' => $course->vip_price, 'model' => $course->model, 'level' => $course->level, - 'user_count' => $course->user_count, + 'user_count' => $userCount, 'lesson_count' => $course->lesson_count, ]; } diff --git a/app/Caches/IndexSimpleFeaturedCourseList.php b/app/Caches/IndexSimpleFeaturedCourseList.php index f3588fed..32801d99 100644 --- a/app/Caches/IndexSimpleFeaturedCourseList.php +++ b/app/Caches/IndexSimpleFeaturedCourseList.php @@ -42,6 +42,13 @@ class IndexSimpleFeaturedCourseList extends Cache $result = []; foreach ($courses as $course) { + + $userCount = $course->user_count; + + if ($course->fake_user_count > $course->user_count) { + $userCount = $course->fake_user_count; + } + $result[] = [ 'id' => $course->id, 'title' => $course->title, @@ -50,7 +57,7 @@ class IndexSimpleFeaturedCourseList extends Cache 'vip_price' => $course->vip_price, 'model' => $course->model, 'level' => $course->level, - 'user_count' => $course->user_count, + 'user_count' => $userCount, 'lesson_count' => $course->lesson_count, ]; } diff --git a/app/Caches/IndexSimpleFreeCourseList.php b/app/Caches/IndexSimpleFreeCourseList.php index a37e8779..9a71dbb7 100644 --- a/app/Caches/IndexSimpleFreeCourseList.php +++ b/app/Caches/IndexSimpleFreeCourseList.php @@ -42,6 +42,13 @@ class IndexSimpleFreeCourseList extends Cache $result = []; foreach ($courses as $course) { + + $userCount = $course->user_count; + + if ($course->fake_user_count > $course->user_count) { + $userCount = $course->fake_user_count; + } + $result[] = [ 'id' => $course->id, 'title' => $course->title, @@ -50,7 +57,7 @@ class IndexSimpleFreeCourseList extends Cache 'vip_price' => $course->vip_price, 'model' => $course->model, 'level' => $course->level, - 'user_count' => $course->user_count, + 'user_count' => $userCount, 'lesson_count' => $course->lesson_count, ]; } diff --git a/app/Caches/IndexSimpleNewCourseList.php b/app/Caches/IndexSimpleNewCourseList.php index b43166a9..a498fac7 100644 --- a/app/Caches/IndexSimpleNewCourseList.php +++ b/app/Caches/IndexSimpleNewCourseList.php @@ -42,6 +42,13 @@ class IndexSimpleNewCourseList extends Cache $result = []; foreach ($courses as $course) { + + $userCount = $course->user_count; + + if ($course->fake_user_count > $course->user_count) { + $userCount = $course->fake_user_count; + } + $result[] = [ 'id' => $course->id, 'title' => $course->title, @@ -50,7 +57,7 @@ class IndexSimpleNewCourseList extends Cache 'vip_price' => $course->vip_price, 'model' => $course->model, 'level' => $course->level, - 'user_count' => $course->user_count, + 'user_count' => $userCount, 'lesson_count' => $course->lesson_count, ]; } diff --git a/app/Caches/IndexSimpleVipCourseList.php b/app/Caches/IndexSimpleVipCourseList.php index d4474287..7162d431 100644 --- a/app/Caches/IndexSimpleVipCourseList.php +++ b/app/Caches/IndexSimpleVipCourseList.php @@ -42,6 +42,13 @@ class IndexSimpleVipCourseList extends Cache $result = []; foreach ($courses as $course) { + + $userCount = $course->user_count; + + if ($course->fake_user_count > $course->user_count) { + $userCount = $course->fake_user_count; + } + $result[] = [ 'id' => $course->id, 'title' => $course->title, @@ -50,7 +57,7 @@ class IndexSimpleVipCourseList extends Cache 'vip_price' => $course->vip_price, 'model' => $course->model, 'level' => $course->level, - 'user_count' => $course->user_count, + 'user_count' => $userCount, 'lesson_count' => $course->lesson_count, ]; } diff --git a/app/Caches/IndexVipCourseList.php b/app/Caches/IndexVipCourseList.php index 163bff1f..4d8d78a6 100644 --- a/app/Caches/IndexVipCourseList.php +++ b/app/Caches/IndexVipCourseList.php @@ -65,6 +65,13 @@ class IndexVipCourseList extends Cache $categoryCourses = []; foreach ($courses as $course) { + + $userCount = $course->user_count; + + if ($course->fake_user_count > $course->user_count) { + $userCount = $course->fake_user_count; + } + $categoryCourses[] = [ 'id' => $course->id, 'title' => $course->title, @@ -73,7 +80,7 @@ class IndexVipCourseList extends Cache 'vip_price' => $course->vip_price, 'model' => $course->model, 'level' => $course->level, - 'user_count' => $course->user_count, + 'user_count' => $userCount, 'lesson_count' => $course->lesson_count, ]; } From 725e6fc2611705dd433a56aa375181ccff9a700a Mon Sep 17 00:00:00 2001 From: koogua Date: Tue, 19 Oct 2021 20:21:04 +0800 Subject: [PATCH 2/3] =?UTF-8?q?1.=E6=B8=85=E7=90=86=E5=88=86=E4=BA=AB?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E5=8F=82=E6=95=B0=202.=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E8=B4=A6=E5=8F=B7=E6=B3=9B=E6=BB=A5=E7=99=BB=E5=BD=95=E6=A3=80?= =?UTF-8?q?=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Home/Views/article/show.volt | 2 +- app/Http/Home/Views/chapter/live/active.volt | 2 +- app/Http/Home/Views/chapter/read.volt | 2 +- app/Http/Home/Views/chapter/vod.volt | 2 +- app/Http/Home/Views/course/show.volt | 2 +- app/Http/Home/Views/question/show.volt | 2 +- app/Http/Home/Views/user/show.volt | 2 +- app/Library/AppInfo.php | 2 +- app/Models/UserSession.php | 21 +++++++++ app/Models/UserToken.php | 21 +++++++++ app/Repos/UserSession.php | 18 +++++++- app/Repos/UserToken.php | 17 +++++++- app/Services/Auth/Api.php | 2 +- app/Services/Auth/Home.php | 2 +- app/Validators/Account.php | 34 +++++++++++++++ config/errors.php | 1 + db/migrations/20211019093522.php | 46 ++++++++++++++++++++ 17 files changed, 166 insertions(+), 12 deletions(-) create mode 100644 db/migrations/20211019093522.php diff --git a/app/Http/Home/Views/article/show.volt b/app/Http/Home/Views/article/show.volt index 62fa935f..9941b176 100644 --- a/app/Http/Home/Views/article/show.volt +++ b/app/Http/Home/Views/article/show.volt @@ -97,7 +97,7 @@ - {% set share_url = full_url({'for':'home.share'},{'id':article.id,'type':'article','referer':auth_user.id}) %} + {% set share_url = full_url({'for':'home.share'},{'id':article.id,'type':'article'}) %} {% set qrcode_url = url({'for':'home.qrcode'},{'text':share_url}) %}
diff --git a/app/Http/Home/Views/chapter/live/active.volt b/app/Http/Home/Views/chapter/live/active.volt index 82cd87ee..663240e9 100644 --- a/app/Http/Home/Views/chapter/live/active.volt +++ b/app/Http/Home/Views/chapter/live/active.volt @@ -57,7 +57,7 @@
- {% set share_url = full_url({'for':'home.share'},{'id':chapter.id,'type':'chapter','referer':auth_user.id}) %} + {% set share_url = full_url({'for':'home.share'},{'id':chapter.id,'type':'chapter'}) %} {% set qrcode_url = url({'for':'home.qrcode'},{'text':share_url}) %}
diff --git a/app/Http/Home/Views/chapter/read.volt b/app/Http/Home/Views/chapter/read.volt index 746a7bb0..0813b106 100644 --- a/app/Http/Home/Views/chapter/read.volt +++ b/app/Http/Home/Views/chapter/read.volt @@ -43,7 +43,7 @@
- {% set share_url = full_url({'for':'home.share'},{'id':chapter.id,'type':'chapter','referer':auth_user.id}) %} + {% set share_url = full_url({'for':'home.share'},{'id':chapter.id,'type':'chapter'}) %} {% set qrcode_url = url({'for':'home.qrcode'},{'text':share_url}) %}
diff --git a/app/Http/Home/Views/chapter/vod.volt b/app/Http/Home/Views/chapter/vod.volt index 5c5953f1..1b054626 100644 --- a/app/Http/Home/Views/chapter/vod.volt +++ b/app/Http/Home/Views/chapter/vod.volt @@ -43,7 +43,7 @@
- {% set share_url = full_url({'for':'home.share'},{'id':chapter.id,'type':'chapter','referer':auth_user.id}) %} + {% set share_url = full_url({'for':'home.share'},{'id':chapter.id,'type':'chapter'}) %} {% set qrcode_url = url({'for':'home.qrcode'},{'text':share_url}) %}
diff --git a/app/Http/Home/Views/course/show.volt b/app/Http/Home/Views/course/show.volt index 5f6ee021..a9472cb7 100644 --- a/app/Http/Home/Views/course/show.volt +++ b/app/Http/Home/Views/course/show.volt @@ -94,7 +94,7 @@
- {% set share_url = full_url({'for':'home.share'},{'id':course.id,'type':'course','referer':auth_user.id}) %} + {% set share_url = full_url({'for':'home.share'},{'id':course.id,'type':'course'}) %} {% set qrcode_url = url({'for':'home.qrcode'},{'text':share_url}) %}
diff --git a/app/Http/Home/Views/question/show.volt b/app/Http/Home/Views/question/show.volt index e7d9f36b..d8b3bbc1 100644 --- a/app/Http/Home/Views/question/show.volt +++ b/app/Http/Home/Views/question/show.volt @@ -97,7 +97,7 @@
- {% set share_url = full_url({'for':'home.share'},{'id':question.id,'type':'question','referer':auth_user.id}) %} + {% set share_url = full_url({'for':'home.share'},{'id':question.id,'type':'question'}) %} {% set qrcode_url = url({'for':'home.qrcode'},{'text':share_url}) %}
diff --git a/app/Http/Home/Views/user/show.volt b/app/Http/Home/Views/user/show.volt index f39aa5ff..599caf83 100644 --- a/app/Http/Home/Views/user/show.volt +++ b/app/Http/Home/Views/user/show.volt @@ -96,7 +96,7 @@
- {% set share_url = full_url({'for':'home.share'},{'id':user.id,'type':'user','referer':auth_user.id}) %} + {% set share_url = full_url({'for':'home.share'},{'id':user.id,'type':'user'}) %} {% set qrcode_url = url({'for':'home.qrcode'},{'text':share_url}) %}
diff --git a/app/Library/AppInfo.php b/app/Library/AppInfo.php index fed579d7..184af632 100644 --- a/app/Library/AppInfo.php +++ b/app/Library/AppInfo.php @@ -16,7 +16,7 @@ class AppInfo protected $link = 'https://koogua.com'; - protected $version = '1.4.6'; + protected $version = '1.4.7'; public function __get($name) { diff --git a/app/Models/UserSession.php b/app/Models/UserSession.php index 5b6074a5..7b55481d 100644 --- a/app/Models/UserSession.php +++ b/app/Models/UserSession.php @@ -7,6 +7,8 @@ namespace App\Models; +use Phalcon\Mvc\Model\Behavior\SoftDelete; + class UserSession extends Model { @@ -45,6 +47,13 @@ class UserSession extends Model */ public $client_ip = ''; + /** + * 删除标识 + * + * @var int + */ + public $deleted = 0; + /** * 过期时间 * @@ -71,6 +80,18 @@ class UserSession extends Model return 'kg_user_session'; } + public function initialize() + { + parent::initialize(); + + $this->addBehavior( + new SoftDelete([ + 'field' => 'deleted', + 'value' => 1, + ]) + ); + } + public function beforeCreate() { $this->create_time = time(); diff --git a/app/Models/UserToken.php b/app/Models/UserToken.php index aad991e6..5ddda172 100644 --- a/app/Models/UserToken.php +++ b/app/Models/UserToken.php @@ -7,6 +7,8 @@ namespace App\Models; +use Phalcon\Mvc\Model\Behavior\SoftDelete; + class UserToken extends Model { @@ -45,6 +47,13 @@ class UserToken extends Model */ public $client_ip = ''; + /** + * 删除标识 + * + * @var int + */ + public $deleted = 0; + /** * 过期时间 * @@ -71,6 +80,18 @@ class UserToken extends Model return 'kg_user_token'; } + public function initialize() + { + parent::initialize(); + + $this->addBehavior( + new SoftDelete([ + 'field' => 'deleted', + 'value' => 1, + ]) + ); + } + public function beforeCreate() { $this->create_time = time(); diff --git a/app/Repos/UserSession.php b/app/Repos/UserSession.php index 2ea25a8d..26f1b542 100644 --- a/app/Repos/UserSession.php +++ b/app/Repos/UserSession.php @@ -18,10 +18,26 @@ class UserSession extends Repository * @param int $userId * @return ResultsetInterface|Resultset|UserSessionModel[] */ - public function findByUserId($userId) + public function findUserActiveSessions($userId) { return UserSessionModel::query() ->where('user_id = :user_id:', ['user_id' => $userId]) + ->andWhere('deleted = 0') + ->execute(); + } + + /** + * @param int $userId + * @param int $minutes + * @return ResultsetInterface|Resultset|UserSessionModel[] + */ + public function findUserRecentSessions($userId, $minutes = 10) + { + $createTime = time() - $minutes * 60; + + return UserSessionModel::query() + ->where('user_id = :user_id:', ['user_id' => $userId]) + ->andWhere('create_time > :create_time:', ['create_time' => $createTime]) ->execute(); } diff --git a/app/Repos/UserToken.php b/app/Repos/UserToken.php index d6730027..056d8358 100644 --- a/app/Repos/UserToken.php +++ b/app/Repos/UserToken.php @@ -18,11 +18,26 @@ class UserToken extends Repository * @param int $userId * @return ResultsetInterface|Resultset|UserTokenModel[] */ - public function findByUserId($userId) + public function findUserActiveTokens($userId) { return UserTokenModel::query() ->where('user_id = :user_id:', ['user_id' => $userId]) ->execute(); } + /** + * @param int $userId + * @param int $minutes + * @return ResultsetInterface|Resultset|UserTokenModel[] + */ + public function findUserRecentTokens($userId, $minutes = 10) + { + $createTime = time() - $minutes * 60; + + return UserTokenModel::query() + ->where('user_id = :user_id:', ['user_id' => $userId]) + ->andWhere('create_time > :create_time:', ['create_time' => $createTime]) + ->execute(); + } + } diff --git a/app/Services/Auth/Api.php b/app/Services/Auth/Api.php index afd99c84..71084950 100644 --- a/app/Services/Auth/Api.php +++ b/app/Services/Auth/Api.php @@ -76,7 +76,7 @@ class Api extends AuthService { $repo = new UserTokenRepo(); - $records = $repo->findByUserId($userId); + $records = $repo->findUserActiveTokens($userId); if ($records->count() == 0) return; diff --git a/app/Services/Auth/Home.php b/app/Services/Auth/Home.php index 0cc50cc9..9db3e691 100644 --- a/app/Services/Auth/Home.php +++ b/app/Services/Auth/Home.php @@ -65,7 +65,7 @@ class Home extends AuthService $repo = new UserSessionRepo(); - $records = $repo->findByUserId($userId); + $records = $repo->findUserActiveSessions($userId); if ($records->count() == 0) return; diff --git a/app/Validators/Account.php b/app/Validators/Account.php index 095bcdfa..91a7b9de 100644 --- a/app/Validators/Account.php +++ b/app/Validators/Account.php @@ -12,13 +12,19 @@ use App\Exceptions\Forbidden as ForbiddenException; use App\Library\Utils\Password as PasswordUtil; use App\Library\Validators\Common as CommonValidator; use App\Models\Account as AccountModel; +use App\Models\Client as ClientModel; use App\Models\User as UserModel; use App\Repos\Account as AccountRepo; use App\Repos\User as UserRepo; +use App\Repos\UserSession as UserSessionRepo; +use App\Repos\UserToken as UserTokenRepo; +use App\Traits\Client as ClientTrait; class Account extends Validator { + use ClientTrait; + public function checkAccount($name) { $account = null; @@ -175,6 +181,34 @@ class Account extends Validator if ($locked && !$expired) { throw new ForbiddenException('account.locked'); } + + $this->checkFloodLogin($user->id); + } + + public function checkFloodLogin($userId) + { + $clientIp = $this->getClientIp(); + $clientType = $this->getClientType(); + + if ($clientType == ClientModel::TYPE_PC) { + $repo = new UserSessionRepo(); + $records = $repo->findUserRecentSessions($userId, 10); + } else { + $repo = new UserTokenRepo(); + $records = $repo->findUserRecentTokens($userId, 10); + } + + if ($records->count() == 0) return; + + $clientIps = array_column($records->toArray(), 'client_ip'); + + $countValues = array_count_values($clientIps); + + foreach ($countValues as $ip => $count) { + if ($clientIp == $ip && $count > 4) { + throw new ForbiddenException('account.flood_login'); + } + } } } diff --git a/config/errors.php b/config/errors.php index 53a22bf1..35aa2658 100644 --- a/config/errors.php +++ b/config/errors.php @@ -47,6 +47,7 @@ $error['captcha.invalid_code'] = '无效的验证码'; */ $error['account.not_found'] = '账号不存在'; $error['account.locked'] = '账号被锁定,无法登录'; +$error['account.flood_login'] = '帐号泛滥登录'; $error['account.login_pwd_incorrect'] = '登录密码不正确'; $error['account.invalid_login_name'] = '无效的登录名'; $error['account.invalid_email'] = '无效的电子邮箱'; diff --git a/db/migrations/20211019093522.php b/db/migrations/20211019093522.php new file mode 100644 index 00000000..5946d094 --- /dev/null +++ b/db/migrations/20211019093522.php @@ -0,0 +1,46 @@ +alterUserSessionTable(); + $this->alterUserTokenTable(); + } + + protected function alterUserSessionTable() + { + $this->table('kg_user_session') + ->addColumn('deleted', 'integer', [ + 'null' => false, + 'default' => '0', + 'limit' => MysqlAdapter::INT_REGULAR, + 'signed' => false, + 'comment' => '删除标识', + 'after' => 'client_ip', + ])->save(); + } + + protected function alterUserTokenTable() + { + $this->table('kg_user_token') + ->addColumn('deleted', 'integer', [ + 'null' => false, + 'default' => '0', + 'limit' => MysqlAdapter::INT_REGULAR, + 'signed' => false, + 'comment' => '删除标识', + 'after' => 'client_ip', + ])->save(); + } + +} From e7abda6daf9dc0077eb1223d0887a95e6db29ee6 Mon Sep 17 00:00:00 2001 From: koogua Date: Sun, 28 Nov 2021 17:24:03 +0800 Subject: [PATCH 3/3] v1.4.8 --- CHANGELOG.md | 9 +++++++++ app/Console/Tasks/DeliverTask.php | 14 ++++++++++++++ app/Http/Admin/Controllers/HelpController.php | 2 +- app/Http/Admin/Services/Refund.php | 8 +++----- app/Http/Admin/Services/Session.php | 6 ------ app/Http/Admin/Views/chapter/resources.volt | 3 +-- app/Http/Api/Services/Trade.php | 13 +++++++++++++ app/Library/AppInfo.php | 2 +- app/Listeners/Trade.php | 8 +++----- app/Services/Logic/Trade/TradeCreate.php | 5 +++++ app/Validators/Order.php | 7 +++++++ public/static/home/css/common.css | 2 +- 12 files changed, 58 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 23e7c7ce..40fb45fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +### [v1.4.8](https://gitee.com/koogua/course-tencent-cloud/releases/v1.4.8)(2021-11-28) + +- 修正后台下载课程附件问题 +- 修正后台登录检查跳转地址 +- 修正公众号关注二维码样式问题 +- 优化发货失败自动退款逻辑 +- 创建交易时增加订单支付检查 +- H5增加底部tab图标 + ### [v1.4.7](https://gitee.com/koogua/course-tencent-cloud/releases/v1.4.7)(2021-10-28) - 更新README.md diff --git a/app/Console/Tasks/DeliverTask.php b/app/Console/Tasks/DeliverTask.php index dd741203..091790bc 100644 --- a/app/Console/Tasks/DeliverTask.php +++ b/app/Console/Tasks/DeliverTask.php @@ -272,6 +272,20 @@ class DeliverTask extends Task $refund->review_note = '自动操作'; $refund->create(); + + $task = new TaskModel(); + + $itemInfo = [ + 'refund' => ['id' => $refund->id], + ]; + + $task->item_id = $refund->id; + $task->item_info = $itemInfo; + $task->item_type = TaskModel::TYPE_REFUND; + $task->priority = TaskModel::PRIORITY_HIGH; + $task->status = TaskModel::STATUS_PENDING; + + $task->create(); } /** diff --git a/app/Http/Admin/Controllers/HelpController.php b/app/Http/Admin/Controllers/HelpController.php index d81cb9e3..8dcb3915 100644 --- a/app/Http/Admin/Controllers/HelpController.php +++ b/app/Http/Admin/Controllers/HelpController.php @@ -77,7 +77,7 @@ class HelpController extends Controller */ public function editAction($id) { - $helpService = new HelpService; + $helpService = new HelpService(); $categories = $helpService->getCategories(); diff --git a/app/Http/Admin/Services/Refund.php b/app/Http/Admin/Services/Refund.php index 55216185..6c21711a 100644 --- a/app/Http/Admin/Services/Refund.php +++ b/app/Http/Admin/Services/Refund.php @@ -32,6 +32,8 @@ class Refund extends Service $params = $pageQuery->getParams(); + $params['deleted'] = $params['deleted'] ?? 0; + /** * 兼容订单编号或订单序号查询 */ @@ -114,11 +116,7 @@ class Refund extends Service $task = new TaskModel(); $itemInfo = [ - 'refund' => [ - 'id' => $refund->id, - 'order_id' => $refund->order_id, - 'trade_id' => $refund->trade_id, - ], + 'refund' => ['id' => $refund->id], ]; $task->item_id = $refund->id; diff --git a/app/Http/Admin/Services/Session.php b/app/Http/Admin/Services/Session.php index cdffacd7..48f318de 100644 --- a/app/Http/Admin/Services/Session.php +++ b/app/Http/Admin/Services/Session.php @@ -26,12 +26,6 @@ class Session extends Service public function login() { - $user = $this->getCurrentUser(); - - if ($user->id > 0) { - return $this->response->redirect(['for' => 'home.index']); - } - $post = $this->request->getPost(); $validator = new AccountValidator(); diff --git a/app/Http/Admin/Views/chapter/resources.volt b/app/Http/Admin/Views/chapter/resources.volt index afcc606d..4bfc0552 100644 --- a/app/Http/Admin/Views/chapter/resources.volt +++ b/app/Http/Admin/Views/chapter/resources.volt @@ -10,7 +10,6 @@ {% for item in resources %} {% set update_url = url({'for':'admin.resource.update','id':item.id}) %} {% set delete_url = url({'for':'admin.resource.delete','id':item.id}) %} - {% set download_url = url({'for':'home.download','md5':item.upload.md5}) %} {{ item.upload.mime }} @@ -18,7 +17,7 @@ {{ date('Y-m-d H:i:s',item.create_time) }} 删除 - 下载 + 下载 {% endfor %} diff --git a/app/Http/Api/Services/Trade.php b/app/Http/Api/Services/Trade.php index 36946153..d10d98bf 100644 --- a/app/Http/Api/Services/Trade.php +++ b/app/Http/Api/Services/Trade.php @@ -15,6 +15,7 @@ use App\Services\Logic\TradeTrait; use App\Services\Pay\Alipay; use App\Services\Pay\Wxpay; use App\Validators\Client as ClientValidator; +use App\Validators\Order as OrderValidator; use App\Validators\Trade as TradeValidator; class Trade extends Service @@ -35,6 +36,10 @@ class Trade extends Service $order = $this->checkOrderBySn($post['order_sn']); + $validator = new OrderValidator(); + + $validator->checkIfAllowPay($order); + $user = $this->getLoginUser(); $validator = new TradeValidator(); @@ -77,6 +82,10 @@ class Trade extends Service $order = $this->checkOrderBySn($post['order_sn']); + $validator = new OrderValidator(); + + $validator->checkIfAllowPay($order); + $user = $this->getLoginUser(); $channel = TradeModel::CHANNEL_WXPAY; @@ -122,6 +131,10 @@ class Trade extends Service $order = $this->checkOrderBySn($post['order_sn']); + $validator = new OrderValidator(); + + $validator->checkIfAllowPay($order); + $user = $this->getLoginUser(); $channel = TradeModel::CHANNEL_WXPAY; diff --git a/app/Library/AppInfo.php b/app/Library/AppInfo.php index 184af632..c760089c 100644 --- a/app/Library/AppInfo.php +++ b/app/Library/AppInfo.php @@ -16,7 +16,7 @@ class AppInfo protected $link = 'https://koogua.com'; - protected $version = '1.4.7'; + protected $version = '1.4.8'; public function __get($name) { diff --git a/app/Listeners/Trade.php b/app/Listeners/Trade.php index 2c51653d..bcbefea3 100644 --- a/app/Listeners/Trade.php +++ b/app/Listeners/Trade.php @@ -52,11 +52,7 @@ class Trade extends Listener $task = new TaskModel(); $itemInfo = [ - 'order' => [ - 'id' => $order->id, - 'item_id' => $order->item_id, - 'item_type' => $order->item_type, - ] + 'order' => ['id' => $order->id] ]; $task->item_id = $order->id; @@ -74,6 +70,8 @@ class Trade extends Listener $this->db->rollback(); $this->logger->error('After Pay Event Error ' . kg_json_encode([ + 'file' => $e->getFile(), + 'line' => $e->getLine(), 'code' => $e->getCode(), 'message' => $e->getMessage(), ])); diff --git a/app/Services/Logic/Trade/TradeCreate.php b/app/Services/Logic/Trade/TradeCreate.php index d81fcc61..b0207bdb 100644 --- a/app/Services/Logic/Trade/TradeCreate.php +++ b/app/Services/Logic/Trade/TradeCreate.php @@ -10,6 +10,7 @@ namespace App\Services\Logic\Trade; use App\Models\Trade as TradeModel; use App\Services\Logic\OrderTrait; use App\Services\Logic\Service as LogicService; +use App\Validators\Order as OrderValidator; use App\Validators\Trade as TradeValidator; class TradeCreate extends LogicService @@ -23,6 +24,10 @@ class TradeCreate extends LogicService $order = $this->checkOrderBySn($post['order_sn']); + $validator = new OrderValidator(); + + $validator->checkIfAllowPay($order); + $user = $this->getLoginUser(); $validator = new TradeValidator(); diff --git a/app/Validators/Order.php b/app/Validators/Order.php index 42eb135f..fc82ac2f 100644 --- a/app/Validators/Order.php +++ b/app/Validators/Order.php @@ -136,6 +136,13 @@ class Order extends Validator return $status; } + public function checkIfAllowPay(OrderModel $order) + { + if ($order->status != OrderModel::STATUS_PENDING) { + throw new BadRequestException('order.pay_not_allowed'); + } + } + public function checkIfAllowCancel(OrderModel $order) { if ($order->status != OrderModel::STATUS_PENDING) { diff --git a/public/static/home/css/common.css b/public/static/home/css/common.css index d43d5451..38800013 100644 --- a/public/static/home/css/common.css +++ b/public/static/home/css/common.css @@ -2086,7 +2086,7 @@ } .my-subscribe .qrcode { - broder: 3px dashed #666; + border: 3px dashed #666; margin: 30px auto; width: 160px; height: 160px;