diff --git a/app/Console/Tasks/RefundTask.php b/app/Console/Tasks/RefundTask.php index 64453494..22b3f265 100644 --- a/app/Console/Tasks/RefundTask.php +++ b/app/Console/Tasks/RefundTask.php @@ -179,7 +179,9 @@ class RefundTask extends Task $courseUser = $courseUserRepo->findCourseStudent($order->item_id, $order->user_id); if ($courseUser) { + $courseUser->deleted = 1; + if ($courseUser->update() === false) { throw new \RuntimeException('Delete Course User Failed'); } @@ -205,7 +207,9 @@ class RefundTask extends Task $courseUser = $courseUserRepo->findCourseStudent($course['id'], $order->user_id); if ($courseUser) { + $courseUser->deleted = 1; + if ($courseUser->update() === false) { throw new \RuntimeException('Delete Course User Failed'); } diff --git a/app/Http/Admin/Services/Refund.php b/app/Http/Admin/Services/Refund.php index 85dd0b22..d4c8c16c 100644 --- a/app/Http/Admin/Services/Refund.php +++ b/app/Http/Admin/Services/Refund.php @@ -94,7 +94,7 @@ class Refund extends Service $data = []; - $validator->checkReviewAction($refund); + $validator->checkIfAllowReview($refund); $data['status'] = $validator->checkReviewStatus($post['status']); $data['review_note'] = $validator->checkReviewNote($post['review_note']); diff --git a/app/Http/Home/Controllers/CourseController.php b/app/Http/Home/Controllers/CourseController.php index bd2df268..9a815fd2 100644 --- a/app/Http/Home/Controllers/CourseController.php +++ b/app/Http/Home/Controllers/CourseController.php @@ -3,10 +3,10 @@ namespace App\Http\Home\Controllers; use App\Services\Frontend\Course as CourseService; -use App\Services\Frontend\CourseFavorite as CourseFavoriteService; use App\Services\Frontend\CourseList as CourseListService; use App\Services\Frontend\CourseRelated as CourseRelatedService; -use App\Services\Frontend\CourseReview as CourseReviewService; +use App\Services\Frontend\Favorite as CourseFavoriteService; +use App\Services\Frontend\ReviewCreate as CourseReviewService; /** * @RoutePrefix("/course") diff --git a/app/Http/Home/Controllers/IndexController.php b/app/Http/Home/Controllers/IndexController.php index f2c6bfd9..3216c8e7 100644 --- a/app/Http/Home/Controllers/IndexController.php +++ b/app/Http/Home/Controllers/IndexController.php @@ -13,12 +13,4 @@ class IndexController extends Controller } - /** - * @Get("/phpinfo", name="home.phpinfo") - */ - public function phpinfoAction() - { - echo phpinfo(); exit; - } - } diff --git a/app/Listeners/ChapterAdmin.php b/app/Listeners/ChapterAdmin.php index 54f69bbb..9bcb4054 100644 --- a/app/Listeners/ChapterAdmin.php +++ b/app/Listeners/ChapterAdmin.php @@ -2,9 +2,9 @@ namespace App\Listeners; +use App\Caches\Chapter as ChapterCache; use App\Caches\MaxChapterId as MaxChapterIdCache; use App\Models\Chapter as ChapterModel; -use App\Services\ChapterCacheSyncer; use Phalcon\Events\Event; class ChapterAdmin extends Listener @@ -76,9 +76,9 @@ class ChapterAdmin extends Listener protected function syncCache(ChapterModel $chapter) { - $cacheSyncer = new ChapterCacheSyncer(); + $chapterCache = new ChapterCache(); - $cacheSyncer->addItem($chapter->id); + $chapterCache->rebuild($chapter->id); } } \ No newline at end of file diff --git a/app/Listeners/CourseAdmin.php b/app/Listeners/CourseAdmin.php index 72d91c2f..94eefc02 100644 --- a/app/Listeners/CourseAdmin.php +++ b/app/Listeners/CourseAdmin.php @@ -2,9 +2,9 @@ namespace App\Listeners; +use App\Caches\Course as CourseCache; use App\Caches\MaxCourseId as MaxCourseIdCache; use App\Models\Course as CourseModel; -use App\Services\CourseCacheSyncer; use App\Services\CourseIndexSyncer; use Phalcon\Events\Event; @@ -84,9 +84,9 @@ class CourseAdmin extends Listener protected function syncCache(CourseModel $course) { - $cacheSyncer = new CourseCacheSyncer(); + $courseCache = new CourseCache(); - $cacheSyncer->addItem($course->id); + $courseCache->rebuild($course->id); } protected function syncIndex(CourseModel $course) diff --git a/app/Models/Category.php b/app/Models/Category.php index 5dd8f674..514876fc 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -133,14 +133,17 @@ class Category extends Model public function rebuildCache() { - $categoryCache = new CategoryCache(); - $categoryCache->rebuild($this->id); + $cache = new CategoryCache(); - $categoryListCache = new CategoryListCache(); - $categoryListCache->rebuild(); + $cache->rebuild($this->id); - $categoryTreeListCache = new CategoryTreeListCache(); - $categoryTreeListCache->rebuild(); + $listCache = new CategoryListCache(); + + $listCache->rebuild(); + + $treeListCache = new CategoryTreeListCache(); + + $treeListCache->rebuild(); } } diff --git a/app/Models/ChapterVod.php b/app/Models/ChapterVod.php index 40d1d4b3..bf8fcb78 100644 --- a/app/Models/ChapterVod.php +++ b/app/Models/ChapterVod.php @@ -103,7 +103,7 @@ class ChapterVod extends Model $this->update(); /** - * afterUpdate事件会序列化属性,需再次重设属性 + * afterUpdate事件触发序列化,故重设属性 */ $this->file_transcode = $transcode; } diff --git a/app/Models/Nav.php b/app/Models/Nav.php index d7e17047..30affc89 100644 --- a/app/Models/Nav.php +++ b/app/Models/Nav.php @@ -158,6 +158,7 @@ class Nav extends Model public function rebuildCache() { $cache = new NavTreeListCache(); + $cache->rebuild(); } diff --git a/app/Models/User.php b/app/Models/User.php index 1fd80392..409e62c9 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -177,6 +177,7 @@ class User extends Model public function afterCreate() { $maxUserIdCache = new MaxUserIdCache(); + $maxUserIdCache->rebuild(); } @@ -201,16 +202,4 @@ class User extends Model return $list; } - public static function vipTypes() - { - $list = [ - 1 => '1个月', - 3 => '3个月', - 6 => '6个月', - 12 => '12个月', - ]; - - return $list; - } - } diff --git a/app/Repos/Order.php b/app/Repos/Order.php index e842b35a..5e369c26 100644 --- a/app/Repos/Order.php +++ b/app/Repos/Order.php @@ -125,7 +125,7 @@ class Order extends Repository * @param string $itemType * @return OrderModel|Model|bool */ - public function findLastUserItem($userId, $itemId, $itemType) + public function findLastUserOrder($userId, $itemId, $itemType) { $result = OrderModel::findFirst([ 'conditions' => 'user_id = ?1 AND item_id = ?2 AND item_type = ?3', diff --git a/app/Services/Frontend/Account.php b/app/Services/Frontend/Account.php deleted file mode 100644 index 296a9e72..00000000 --- a/app/Services/Frontend/Account.php +++ /dev/null @@ -1,143 +0,0 @@ -request->getPost(); - - $securityValidator = new SecurityValidator(); - - $securityValidator->checkVerifyCode($post['phone'], $post['verify_code']); - - $accountValidator = new AccountValidator(); - - $data = []; - - $data['phone'] = $accountValidator->checkPhone($post['phone']); - $data['password'] = $accountValidator->checkPassword($post['password']); - - $accountValidator->checkIfPhoneTaken($post['phone']); - - $account = new AccountModel(); - - $account->create($data); - - return $account; - } - - public function updateEmail() - { - $post = $this->request->getPost(); - - $user = $this->getLoginUser(); - - $accountRepo = new AccountRepo(); - - $account = $accountRepo->findById($user->id); - - $accountValidator = new AccountValidator(); - - $email = $accountValidator->checkEmail($post['email']); - - if ($email != $account->email) { - $accountValidator->checkIfEmailTaken($post['email']); - } - - $accountValidator->checkOriginPassword($account, $post['origin_password']); - - $securityValidator = new SecurityValidator(); - - $securityValidator->checkVerifyCode($post['email'], $post['verify_code']); - - $account->email = $email; - - $account->update(); - - return $account; - } - - public function updatePhone() - { - $post = $this->request->getPost(); - - $user = $this->getLoginUser(); - - $accountRepo = new AccountRepo(); - - $account = $accountRepo->findById($user->id); - - $accountValidator = new AccountValidator(); - - $phone = $accountValidator->checkPhone($post['phone']); - - if ($phone != $account->phone) { - $accountValidator->checkIfPhoneTaken($post['phone']); - } - - $accountValidator->checkOriginPassword($account, $post['origin_password']); - - $securityValidator = new SecurityValidator(); - - $securityValidator->checkVerifyCode($post['phone'], $post['verify_code']); - - $account->phone = $phone; - - $account->update(); - - return $account; - } - - public function updatePassword() - { - $post = $this->request->getPost(); - - $user = $this->getLoginUser(); - - $accountRepo = new AccountRepo(); - - $account = $accountRepo->findById($user->id); - - $accountValidator = new AccountValidator(); - - $accountValidator->checkOriginPassword($account, $post['origin_password']); - - $newPassword = $accountValidator->checkPassword($post['new_password']); - - $account->password = $newPassword; - - $account->update(); - - return $account; - } - - public function resetPassword() - { - $post = $this->request->getPost(); - - $accountValidator = new AccountValidator(); - - $account = $accountValidator->checkLoginAccount($post['account']); - - $accountValidator->checkPassword($post['new_password']); - - $securityValidator = new SecurityValidator(); - - $securityValidator->checkVerifyCode($post['account'], $post['verify_code']); - - $account->password = $post['new_password']; - - $account->update(); - - return $account; - } - -} diff --git a/app/Services/Frontend/Account/AccountCreate.php b/app/Services/Frontend/Account/AccountCreate.php new file mode 100644 index 00000000..b851bc44 --- /dev/null +++ b/app/Services/Frontend/Account/AccountCreate.php @@ -0,0 +1,37 @@ +request->getPost(); + + $securityValidator = new SecurityValidator(); + + $securityValidator->checkVerifyCode($post['phone'], $post['verify_code']); + + $accountValidator = new AccountValidator(); + + $data = []; + + $data['phone'] = $accountValidator->checkPhone($post['phone']); + $data['password'] = $accountValidator->checkPassword($post['password']); + + $accountValidator->checkIfPhoneTaken($post['phone']); + + $account = new AccountModel(); + + $account->create($data); + + return $account; + } + +} diff --git a/app/Services/Frontend/Account/EmailUpdate.php b/app/Services/Frontend/Account/EmailUpdate.php new file mode 100644 index 00000000..1adedb11 --- /dev/null +++ b/app/Services/Frontend/Account/EmailUpdate.php @@ -0,0 +1,43 @@ +request->getPost(); + + $user = $this->getLoginUser(); + + $accountRepo = new AccountRepo(); + + $account = $accountRepo->findById($user->id); + + $accountValidator = new AccountValidator(); + + $email = $accountValidator->checkEmail($post['email']); + + if ($email != $account->email) { + $accountValidator->checkIfEmailTaken($post['email']); + } + + $accountValidator->checkOriginPassword($account, $post['origin_password']); + + $securityValidator = new SecurityValidator(); + + $securityValidator->checkVerifyCode($post['email'], $post['verify_code']); + + $account->email = $email; + + $account->update(); + + return $account; + } + +} diff --git a/app/Services/Frontend/Account/PasswordReset.php b/app/Services/Frontend/Account/PasswordReset.php new file mode 100644 index 00000000..70f9c341 --- /dev/null +++ b/app/Services/Frontend/Account/PasswordReset.php @@ -0,0 +1,33 @@ +request->getPost(); + + $accountValidator = new AccountValidator(); + + $account = $accountValidator->checkLoginAccount($post['account']); + + $accountValidator->checkPassword($post['new_password']); + + $securityValidator = new SecurityValidator(); + + $securityValidator->checkVerifyCode($post['account'], $post['verify_code']); + + $account->password = $post['new_password']; + + $account->update(); + + return $account; + } + +} diff --git a/app/Services/Frontend/Account/PasswordUpdate.php b/app/Services/Frontend/Account/PasswordUpdate.php new file mode 100644 index 00000000..a1eae84b --- /dev/null +++ b/app/Services/Frontend/Account/PasswordUpdate.php @@ -0,0 +1,35 @@ +request->getPost(); + + $user = $this->getLoginUser(); + + $accountRepo = new AccountRepo(); + + $account = $accountRepo->findById($user->id); + + $accountValidator = new AccountValidator(); + + $accountValidator->checkOriginPassword($account, $post['origin_password']); + + $newPassword = $accountValidator->checkPassword($post['new_password']); + + $account->password = $newPassword; + + $account->update(); + + return $account; + } + +} diff --git a/app/Services/Frontend/Account/PhoneUpdate.php b/app/Services/Frontend/Account/PhoneUpdate.php new file mode 100644 index 00000000..c92d85f2 --- /dev/null +++ b/app/Services/Frontend/Account/PhoneUpdate.php @@ -0,0 +1,44 @@ +request->getPost(); + + $user = $this->getLoginUser(); + + $accountRepo = new AccountRepo(); + + $account = $accountRepo->findById($user->id); + + $accountValidator = new AccountValidator(); + + $phone = $accountValidator->checkPhone($post['phone']); + + if ($phone != $account->phone) { + $accountValidator->checkIfPhoneTaken($post['phone']); + } + + $accountValidator->checkOriginPassword($account, $post['origin_password']); + + $securityValidator = new SecurityValidator(); + + $securityValidator->checkVerifyCode($post['phone'], $post['verify_code']); + + $account->phone = $phone; + + $account->update(); + + return $account; + } + +} diff --git a/app/Services/Frontend/Chapter.php b/app/Services/Frontend/Chapter/ChapterInfo.php similarity index 71% rename from app/Services/Frontend/Chapter.php rename to app/Services/Frontend/Chapter/ChapterInfo.php index 0526f259..fa23c757 100644 --- a/app/Services/Frontend/Chapter.php +++ b/app/Services/Frontend/Chapter/ChapterInfo.php @@ -1,19 +1,23 @@ checkChapter($id); - $this->course = $this->checkCourse($chapter->course_id); + $course = $this->checkCourse($chapter->course_id); - $this->user = $this->getCurrentUser(); + $this->course = $course; - $this->setCourseUser($this->course, $this->user); + $user = $this->getCurrentUser(); - $this->setChapterUser($chapter, $this->user); + $this->user = $user; - $this->handleChapterUser($chapter); + $this->setCourseUser($course, $user); - return $this->handleChapter($chapter); + $this->setChapterUser($chapter, $user); + + $this->handleCourseUser($course, $user); + + $this->handleChapterUser($chapter, $user); + + return $this->handleChapter($chapter, $user); } /** * @param ChapterModel $chapter + * @param UserModel $user * @return array */ - protected function handleChapter(ChapterModel $chapter) + protected function handleChapter(ChapterModel $chapter, UserModel $user) { $result = $this->formatChapter($chapter); @@ -60,11 +71,11 @@ class Chapter extends Service $me['owned'] = $this->ownedChapter; - if ($this->user->id > 0) { + if ($user->id > 0) { $chapterVoteRepo = new ChapterVoteRepo(); - $chapterVote = $chapterVoteRepo->findChapterVote($chapter->id, $this->user->id); + $chapterVote = $chapterVoteRepo->findChapterVote($chapter->id, $user->id); if ($chapterVote) { $me['agreed'] = $chapterVote->type == ChapterVoteModel::TYPE_AGREE; @@ -210,28 +221,56 @@ class Chapter extends Service } /** - * @param ChapterModel $chapter + * @param CourseModel $course + * @param UserModel $user */ - protected function handleChapterUser(ChapterModel $chapter) + protected function handleCourseUser(CourseModel $course, UserModel $user) { - if ($this->user->id == 0) return; + if ($user->id == 0) return; - if (!$this->courseUser) return; + if ($this->joinedCourse) return; - if ($this->ownedChapter && !$this->joinedChapter) { + if (!$this->ownedCourse) return; - $chapterUser = new ChapterUserModel(); + $courseUser = new CourseUserModel(); - $chapterUser->course_id = $this->course->id; - $chapterUser->chapter_id = $chapter->id; - $chapterUser->user_id = $this->user->id; + $courseUser->course_id = $course->id; + $courseUser->user_id = $user->id; + $courseUser->source_type = CourseUserModel::SOURCE_FREE; + $courseUser->role_type = CourseUserModel::ROLE_STUDENT; + $courseUser->expiry_time = strtotime('+3 years'); - $chapterUser->create(); + $courseUser->create(); - $chapter->user_count += 1; + $course->user_count += 1; - $chapter->update(); - } + $course->update(); } + /** + * @param ChapterModel $chapter + * @param UserModel $user + */ + protected function handleChapterUser(ChapterModel $chapter, UserModel $user) + { + if ($user->id == 0) return; + + if ($this->joinedChapter) return; + + if (!$this->ownedChapter) return; + + $chapterUser = new ChapterUserModel(); + + $chapterUser->course_id = $chapter->course_id; + $chapterUser->chapter_id = $chapter->id; + $chapterUser->user_id = $user->id; + + $chapterUser->create(); + + $chapter->user_count += 1; + + $chapter->update(); + } + + } diff --git a/app/Services/Frontend/ChapterVote.php b/app/Services/Frontend/Chapter/ChapterVote.php similarity index 92% rename from app/Services/Frontend/ChapterVote.php rename to app/Services/Frontend/Chapter/ChapterVote.php index db81827e..f55f7f6b 100644 --- a/app/Services/Frontend/ChapterVote.php +++ b/app/Services/Frontend/Chapter/ChapterVote.php @@ -1,10 +1,12 @@ checkChapterVoteLimit($user->id); + $validator->checkChapterVoteLimit($user); $chapterVoteRepo = new ChapterVoteRepo(); @@ -76,6 +78,10 @@ class ChapterVote extends Service $user = $this->getLoginUser(); + $validator = new UserDailyLimitValidator(); + + $validator->checkChapterVoteLimit($user); + $chapterVoteRepo = new ChapterVoteRepo(); $chapterVote = $chapterVoteRepo->findChapterVote($chapter->id, $user->id); diff --git a/app/Services/Frontend/ChapterCommentList.php b/app/Services/Frontend/Chapter/CommentList.php similarity index 95% rename from app/Services/Frontend/ChapterCommentList.php rename to app/Services/Frontend/Chapter/CommentList.php index 7e93b923..2d5d483d 100644 --- a/app/Services/Frontend/ChapterCommentList.php +++ b/app/Services/Frontend/Chapter/CommentList.php @@ -1,6 +1,6 @@ findChapters($id); return $this->handleChapters($chapters); @@ -86,9 +85,6 @@ class CourseChapterList extends Service $courseRepo = new CourseRepo(); - /** - * @var Resultset $userLearnings - */ $userLearnings = $courseRepo->findUserLearnings($course->id, $user->id); if ($userLearnings->count() == 0) { diff --git a/app/Services/Frontend/CourseConsultList.php b/app/Services/Frontend/Course/ConsultList.php similarity index 95% rename from app/Services/Frontend/CourseConsultList.php rename to app/Services/Frontend/Course/ConsultList.php index 2835eae5..3230caa2 100644 --- a/app/Services/Frontend/CourseConsultList.php +++ b/app/Services/Frontend/Course/ConsultList.php @@ -1,6 +1,6 @@ checkCourse($id); - $crListCache = new CourseRelatedListCache(); + $listCache = new CourseRelatedListCache(); - $relatedCourses = $crListCache->get($course->id); + $courses = $listCache->get($course->id); - if (!$relatedCourses) { + if (!$courses) { return []; } $imgBaseUrl = kg_img_base_url(); - foreach ($relatedCourses as &$course) { + foreach ($courses as &$course) { $course['cover'] = $imgBaseUrl . $course['cover']; } - return $relatedCourses; + return $courses; } } diff --git a/app/Services/Frontend/CoursePackageList.php b/app/Services/Frontend/Course/PackageList.php similarity index 88% rename from app/Services/Frontend/CoursePackageList.php rename to app/Services/Frontend/Course/PackageList.php index f0767d9b..9c3cd28e 100644 --- a/app/Services/Frontend/CoursePackageList.php +++ b/app/Services/Frontend/Course/PackageList.php @@ -1,13 +1,14 @@ findPackages($course->id); return $this->handlePackages($packages); @@ -58,9 +56,6 @@ class CoursePackageList extends Service { $packageRepo = new PackageRepo(); - /** - * @var CourseModel[] $courses - */ $courses = $packageRepo->findCourses($packageId); $result = []; diff --git a/app/Services/Frontend/CourseReviewList.php b/app/Services/Frontend/Course/ReviewList.php similarity index 94% rename from app/Services/Frontend/CourseReviewList.php rename to app/Services/Frontend/Course/ReviewList.php index a5f1ab31..cb8ba96d 100644 --- a/app/Services/Frontend/CourseReviewList.php +++ b/app/Services/Frontend/Course/ReviewList.php @@ -1,6 +1,6 @@ findUserReviewVotes($courseId, $userId); if ($votes->count() == 0) { diff --git a/app/Services/Frontend/CourseTeacherList.php b/app/Services/Frontend/Course/TeacherList.php similarity index 62% rename from app/Services/Frontend/CourseTeacherList.php rename to app/Services/Frontend/Course/TeacherList.php index 1eecb7fe..0426b15e 100644 --- a/app/Services/Frontend/CourseTeacherList.php +++ b/app/Services/Frontend/Course/TeacherList.php @@ -1,10 +1,12 @@ checkCourse($id); - $ctListCache = new CourseTeacherListCache(); + $listCache = new CourseTeacherListCache(); - $teachers = $ctListCache->get($course->id); + $teachers = $listCache->get($course->id); if (!$teachers) return []; diff --git a/app/Services/Frontend/CourseUser.php b/app/Services/Frontend/CourseUser.php deleted file mode 100644 index e5a23c14..00000000 --- a/app/Services/Frontend/CourseUser.php +++ /dev/null @@ -1,40 +0,0 @@ -checkCourse($id); - - $user = $this->getLoginUser(); - - $validator = new CourseUserValidator(); - - $validator->checkIfAllowApply($course, $user); - - $validator->checkIfJoined($course->id, $user->id); - - $courseUser = new CourseUserModel(); - - $courseUser->course_id = $course->id; - $courseUser->user_id = $user->id; - $courseUser->source_type = CourseUserModel::SOURCE_FREE; - $courseUser->role_type = CourseUserModel::ROLE_STUDENT; - $courseUser->expiry_time = strtotime('+3 years'); - - $courseUser->create(); - - $course->user_count += 1; - - $course->update(); - } - -} diff --git a/app/Services/Frontend/MyConsultList.php b/app/Services/Frontend/My/ConsultList.php similarity index 91% rename from app/Services/Frontend/MyConsultList.php rename to app/Services/Frontend/My/ConsultList.php index cd7180ac..307d4ba4 100644 --- a/app/Services/Frontend/MyConsultList.php +++ b/app/Services/Frontend/My/ConsultList.php @@ -1,12 +1,14 @@ findLastUserItem($user->id, $post['item_id'], $post['item_type']); + $order = $orderRepo->findLastUserOrder($user->id, $post['item_id'], $post['item_type']); /** * 存在新鲜的未支付订单直接返回(减少订单记录) diff --git a/app/Services/Frontend/OrderInfo.php b/app/Services/Frontend/Order/OrderInfo.php similarity index 100% rename from app/Services/Frontend/OrderInfo.php rename to app/Services/Frontend/Order/OrderInfo.php diff --git a/app/Services/Frontend/OrderTrade.php b/app/Services/Frontend/Order/OrderTrade.php similarity index 100% rename from app/Services/Frontend/OrderTrade.php rename to app/Services/Frontend/Order/OrderTrade.php diff --git a/app/Services/Frontend/CourseReview.php b/app/Services/Frontend/Review/ReviewCreate.php similarity index 89% rename from app/Services/Frontend/CourseReview.php rename to app/Services/Frontend/Review/ReviewCreate.php index fad9bfda..c1e23b4d 100644 --- a/app/Services/Frontend/CourseReview.php +++ b/app/Services/Frontend/Review/ReviewCreate.php @@ -1,13 +1,15 @@ market_price > 0; - $caseB = $user->vip == 0 && $course->vip_price > 0; - - if ($caseA || $caseB) { - throw new BadRequestException('course_user.apply_not_allowed'); - } - } - public function checkIfJoined($courseId, $userId) { $repo = new CourseUserRepo(); diff --git a/app/Validators/Order.php b/app/Validators/Order.php index d2d913c1..0ad46aa5 100644 --- a/app/Validators/Order.php +++ b/app/Validators/Order.php @@ -84,6 +84,7 @@ class Order extends Validator if (!$item) { throw new BadRequestException('order.item_not_found'); } + return $item; } @@ -101,7 +102,7 @@ class Order extends Validator public function checkIfAllowCancel($order) { if ($order->status != OrderModel::STATUS_PENDING) { - throw new BadRequestException('order.invalid_status_action'); + throw new BadRequestException('order.cancel_not_allowed'); } } diff --git a/app/Validators/Refund.php b/app/Validators/Refund.php index f7bd8915..87bdee7a 100644 --- a/app/Validators/Refund.php +++ b/app/Validators/Refund.php @@ -22,13 +22,6 @@ class Refund extends Validator return $trade; } - public function checkReviewAction($refund) - { - if ($refund->status != RefundModel::STATUS_PENDING) { - throw new BadRequestException('refund.invalid_review_action'); - } - } - public function checkReviewStatus($status) { $list = [RefundModel::STATUS_APPROVED, RefundModel::STATUS_REFUSED]; @@ -74,4 +67,11 @@ class Refund extends Validator return $value; } + public function checkIfAllowReview($refund) + { + if ($refund->status != RefundModel::STATUS_PENDING) { + throw new BadRequestException('refund.review_not_allowed'); + } + } + } diff --git a/config/errors.php b/config/errors.php index f20a89c8..3a711668 100644 --- a/config/errors.php +++ b/config/errors.php @@ -259,7 +259,7 @@ $error['refund.apply_note_too_short'] = '退款原因太短(少于2个字符 $error['refund.apply_note_too_long'] = '退款原因太长(多于255个字符)'; $error['refund.review_note_too_short'] = '审核备注太短(少于2个字符)'; $error['refund.review_note_too_long'] = '审核备注太长(多于255个字符)'; -$error['refund.invalid_review_action'] = '无效的审核操作'; +$error['refund.review_not_allowed'] = '当前不允许审核退款'; $error['refund.invalid_review_status'] = '无效的审核状态'; /** diff --git a/scheduler.php b/scheduler.php index d350b86e..f08d5dcf 100644 --- a/scheduler.php +++ b/scheduler.php @@ -13,7 +13,7 @@ $bin = '/usr/bin/php'; $scheduler->php($script, $bin, ['--task' => 'learning', '--action' => 'main']) ->at('*/3 * * * *'); -$scheduler->php($script, $bin, ['--task' => 'process_order', '--action' => 'main']) +$scheduler->php($script, $bin, ['--task' => 'order', '--action' => 'main']) ->at('*/5 * * * *'); $scheduler->php($script, $bin, ['--task' => 'vod_event', '--action' => 'main'])