From 7052e7c0d57a339721057787efe7de4a4ff1faac Mon Sep 17 00:00:00 2001 From: xiaochong0302 Date: Sat, 16 May 2020 19:49:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...{LearningTask.php => SyncLearningTask.php} | 23 ++--- app/Http/Admin/Controllers/TestController.php | 12 +-- app/Http/Admin/Controllers/VodController.php | 25 +----- app/Http/Admin/Views/public/vod_player.volt | 10 +-- app/Http/Admin/Views/student/learning.volt | 10 +-- app/Http/Admin/Views/student/list.volt | 2 +- .../Web/Controllers/AccountController.php | 89 +++++++------------ .../Web/Controllers/ChapterController.php | 13 +++ app/Models/Learning.php | 2 + app/Models/Order.php | 29 +++--- app/Services/Frontend/Account/EmailUpdate.php | 4 +- .../Frontend/Account/PasswordReset.php | 4 +- .../Frontend/Account/PasswordResetByEmail.php | 4 +- .../Frontend/Account/PasswordResetByPhone.php | 4 +- .../Frontend/Account/PasswordUpdate.php | 4 +- app/Services/Frontend/Account/PhoneUpdate.php | 4 +- .../Frontend/Account/RegisterByEmail.php | 4 +- .../Frontend/Account/RegisterByPhone.php | 4 +- app/Services/Frontend/Chapter/AgreeVote.php | 4 +- app/Services/Frontend/Chapter/ChapterInfo.php | 4 +- app/Services/Frontend/Chapter/CommentList.php | 4 +- app/Services/Frontend/Chapter/Learning.php | 54 +++++++++++ app/Services/Frontend/Chapter/OpposeVote.php | 4 +- app/Services/Frontend/Comment/AgreeVote.php | 4 +- .../Frontend/Comment/CommentCreate.php | 4 +- .../Frontend/Comment/CommentDelete.php | 4 +- app/Services/Frontend/Comment/CommentInfo.php | 4 +- .../Frontend/Comment/CommentUpdate.php | 4 +- app/Services/Frontend/Comment/OpposeVote.php | 4 +- app/Services/Frontend/Consult/AgreeVote.php | 4 +- .../Frontend/Consult/ConsultCreate.php | 4 +- .../Frontend/Consult/ConsultDelete.php | 4 +- app/Services/Frontend/Consult/ConsultInfo.php | 4 +- .../Frontend/Consult/ConsultUpdate.php | 4 +- app/Services/Frontend/Consult/OpposeVote.php | 4 +- app/Services/Frontend/Course/ChapterList.php | 4 +- app/Services/Frontend/Course/ConsultList.php | 4 +- app/Services/Frontend/Course/CourseInfo.php | 4 +- app/Services/Frontend/Course/CourseList.php | 4 +- app/Services/Frontend/Course/Favorite.php | 4 +- app/Services/Frontend/Course/PackageList.php | 4 +- .../Frontend/Course/RecommendedList.php | 4 +- app/Services/Frontend/Course/RelatedList.php | 4 +- app/Services/Frontend/Course/ReviewList.php | 4 +- app/Services/Frontend/Course/TeacherList.php | 4 +- app/Services/Frontend/Course/TopicList.php | 4 +- app/Services/Frontend/My/ConsultList.php | 4 +- app/Services/Frontend/My/CourseList.php | 4 +- app/Services/Frontend/My/FavoriteList.php | 4 +- app/Services/Frontend/My/OrderList.php | 4 +- app/Services/Frontend/My/RefundList.php | 4 +- app/Services/Frontend/My/ReviewList.php | 4 +- app/Services/Frontend/My/UserInfo.php | 4 +- app/Services/Frontend/Order/OrderCancel.php | 4 +- app/Services/Frontend/Order/OrderConfirm.php | 4 +- app/Services/Frontend/Order/OrderCreate.php | 4 +- app/Services/Frontend/Order/OrderInfo.php | 4 +- app/Services/Frontend/Package/CourseList.php | 4 +- app/Services/Frontend/Package/PackageInfo.php | 4 +- app/Services/Frontend/Refund/RefundCancel.php | 4 +- .../Frontend/Refund/RefundConfirm.php | 4 +- app/Services/Frontend/Refund/RefundCreate.php | 4 +- app/Services/Frontend/Refund/RefundInfo.php | 4 +- app/Services/Frontend/Review/AgreeVote.php | 4 +- app/Services/Frontend/Review/OpposeVote.php | 4 +- app/Services/Frontend/Review/ReviewCreate.php | 4 +- app/Services/Frontend/Review/ReviewDelete.php | 4 +- app/Services/Frontend/Review/ReviewInfo.php | 4 +- app/Services/Frontend/Review/ReviewUpdate.php | 4 +- app/Services/Frontend/Teacher/CourseList.php | 4 +- app/Services/Frontend/Teacher/TeacherInfo.php | 4 +- app/Services/Frontend/Topic/CourseList.php | 4 +- app/Services/Frontend/Topic/TopicInfo.php | 4 +- app/Services/Frontend/Trade/TradeCancel.php | 4 +- app/Services/Frontend/Trade/TradeCreate.php | 4 +- app/Services/Frontend/Trade/TradeInfo.php | 4 +- app/Services/Frontend/User/CourseList.php | 4 +- app/Services/Frontend/User/UserInfo.php | 4 +- app/Services/Frontend/Verify/EmailCode.php | 4 +- app/Services/Frontend/Verify/SmsCode.php | 4 +- app/Services/Syncer/Learning.php | 16 ++-- app/Validators/Learning.php | 62 +++++++++++++ config/errors.php | 8 ++ scheduler.php | 2 +- 84 files changed, 360 insertions(+), 273 deletions(-) rename app/Console/Tasks/{LearningTask.php => SyncLearningTask.php} (93%) create mode 100644 app/Services/Frontend/Chapter/Learning.php create mode 100644 app/Validators/Learning.php diff --git a/app/Console/Tasks/LearningTask.php b/app/Console/Tasks/SyncLearningTask.php similarity index 93% rename from app/Console/Tasks/LearningTask.php rename to app/Console/Tasks/SyncLearningTask.php index 0079b2a8..b9e79800 100644 --- a/app/Console/Tasks/LearningTask.php +++ b/app/Console/Tasks/SyncLearningTask.php @@ -13,7 +13,7 @@ use App\Repos\Learning as LearningRepo; use App\Services\Syncer\Learning as LearningSyncer; use Phalcon\Cli\Task; -class LearningTask extends Task +class SyncLearningTask extends Task { /** @@ -69,7 +69,8 @@ class LearningTask extends Task if (!$dbLearning) { $cacheLearning->create(); } else { - $dbLearning->duration += $cacheLearning->duration; + $dbLearning->duration = $cacheLearning->duration; + $dbLearning->position = $cacheLearning->position; $dbLearning->update(); } @@ -138,6 +139,12 @@ class LearningTask extends Task */ protected function updateCourseUser($courseId, $userId) { + $courseUserRepo = new CourseUserRepo(); + + $courseUser = $courseUserRepo->findCourseUser($courseId, $userId); + + if (!$courseUser) return; + $courseRepo = new CourseRepo(); $courseLessons = $courseRepo->findLessons($courseId); @@ -166,15 +173,9 @@ class LearningTask extends Task $consumedCount = count($consumedLessonIds); $progress = intval(100 * $consumedCount / $totalCount); - $courseUserRepo = new CourseUserRepo(); - - $courseUser = $courseUserRepo->findCourseUser($courseId, $userId); - - if ($courseUser) { - $courseUser->progress = $progress; - $courseUser->duration = $duration; - $courseUser->update(); - } + $courseUser->progress = $progress; + $courseUser->duration = $duration; + $courseUser->update(); } } diff --git a/app/Http/Admin/Controllers/TestController.php b/app/Http/Admin/Controllers/TestController.php index 474545c6..19bc59e2 100644 --- a/app/Http/Admin/Controllers/TestController.php +++ b/app/Http/Admin/Controllers/TestController.php @@ -64,7 +64,7 @@ class TestController extends Controller } /** - * @Get("/live/push", name="admin.test.live.push") + * @Get("/live/push", name="admin.test.live_push") */ public function livePushAction() { @@ -89,7 +89,7 @@ class TestController extends Controller } /** - * @Get("/live/pull", name="admin.test.live.pull") + * @Get("/live/pull", name="admin.test.live_pull") */ public function livePullAction() { @@ -190,7 +190,7 @@ class TestController extends Controller } /** - * @Post("/alipay/status", name="admin.test.alipay.status") + * @Post("/alipay/status", name="admin.test.alipay_status") */ public function alipayStatusAction() { @@ -204,7 +204,7 @@ class TestController extends Controller } /** - * @Post("/alipay/cancel", name="admin.test.alipay.cancel") + * @Post("/alipay/cancel", name="admin.test.alipay_cancel") */ public function alipayCancelAction() { @@ -242,7 +242,7 @@ class TestController extends Controller } /** - * @Post("/wxpay/status", name="admin.test.wxpay.status") + * @Post("/wxpay/status", name="admin.test.wxpay_status") */ public function wxpayStatusAction() { @@ -256,7 +256,7 @@ class TestController extends Controller } /** - * @Post("/wxpay/cancel", name="admin.test.wxpay.cancel") + * @Post("/wxpay/cancel", name="admin.test.wxpay_cancel") */ public function wxpayCancelAction() { diff --git a/app/Http/Admin/Controllers/VodController.php b/app/Http/Admin/Controllers/VodController.php index a2da513d..0a81bbf9 100644 --- a/app/Http/Admin/Controllers/VodController.php +++ b/app/Http/Admin/Controllers/VodController.php @@ -2,8 +2,6 @@ namespace App\Http\Admin\Controllers; -use App\Models\Learning as LearningModel; -use App\Services\LearningSyncer as LearningSyncerService; use App\Services\Vod as VodService; use Phalcon\Mvc\View; @@ -14,7 +12,7 @@ class VodController extends Controller { /** - * @Post("/upload/signature", name="admin.vod.upload.signature") + * @Post("/upload/signature", name="admin.vod.upload_signature") */ public function uploadSignatureAction() { @@ -39,25 +37,4 @@ class VodController extends Controller $this->view->setVar('play_url', urldecode($playUrl)); } - /** - * @Get("/learning", name="admin.vod.learning") - */ - public function learningAction() - { - $query = $this->request->getQuery(); - - $learning = new LearningModel(); - - $learning->user_id = $this->authUser->id; - $learning->request_id = $query['request_id']; - $learning->chapter_id = $query['chapter_id']; - $learning->position = $query['position']; - - $syncerService = new LearningSyncerService(); - - $syncerService->addItem($learning, $query['timeout']); - - return $this->jsonSuccess(); - } - } diff --git a/app/Http/Admin/Views/public/vod_player.volt b/app/Http/Admin/Views/public/vod_player.volt index b44d0f9e..4a793e8a 100644 --- a/app/Http/Admin/Views/public/vod_player.volt +++ b/app/Http/Admin/Views/public/vod_player.volt @@ -22,8 +22,8 @@