diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a8daee1..b2af237b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,28 @@ +### [v1.6.5](https://gitee.com/koogua/course-tencent-cloud/releases/v1.6.5)(2023-07-15) + +- 升级layui-v2.8.8 +- 使用本地图像验证码 +- 优化计划任务脚本 +- 优化日志清理脚本 +- 优化钉钉webhook +- 修正图文分享参数问题 + +### [v1.6.4](https://gitee.com/koogua/course-tencent-cloud/releases/v1.6.4)(2023-06-15) + +- 增加推荐课程等Widget +- 更新Composer包 +- 修正验证空口令问题 +- 优化订单确认页样式 +- 优化课程等Me相关信息 +- 优化分享URL +- 优化用户课程查找 +- 优化通知相关 +- 优化Providers +- 优化课程章节权限 +- 优化钉钉机器人 + ### [v1.6.3](https://gitee.com/koogua/course-tencent-cloud/releases/v1.6.3)(2023-05-08) + - 强化文章|提问|课程列表参数检查 - 优化HtmlPurifier内容过滤 - 优化排序条件和分页重复问题 diff --git a/README.md b/README.md index 05d3b71d..07882628 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ Tips: 请用手机注册一个新账号,用户中心 -> 关注订阅,扫码 ### 项目组件 - 后台框架:[phalcon 3.4.5](https://phalcon.io) -- 前端框架:[layui 2.7.6](https://layui.com) +- 前端框架:[layui 2.8.8](https://layui.com) - 全文检索:[xunsearch 1.4.9](http://www.xunsearch.com) - 即时通讯:[workerman 3.5.22](https://workerman.net) - 基础依赖:[php7.3](https://php.net), [mysql5.7](https://mysql.com), [redis5.0](https://redis.io) diff --git a/app/Caches/Article.php b/app/Caches/Article.php index 3bca7d22..18baa434 100644 --- a/app/Caches/Article.php +++ b/app/Caches/Article.php @@ -12,7 +12,7 @@ use App\Repos\Article as ArticleRepo; class Article extends Cache { - protected $lifetime = 1 * 86400; + protected $lifetime = 86400; public function getLifetime() { diff --git a/app/Caches/Chapter.php b/app/Caches/Chapter.php index 5f237013..b2a0fe16 100644 --- a/app/Caches/Chapter.php +++ b/app/Caches/Chapter.php @@ -12,7 +12,7 @@ use App\Repos\Chapter as ChapterRepo; class Chapter extends Cache { - protected $lifetime = 1 * 86400; + protected $lifetime = 86400; public function getLifetime() { diff --git a/app/Caches/Course.php b/app/Caches/Course.php index 872343c0..4479466d 100644 --- a/app/Caches/Course.php +++ b/app/Caches/Course.php @@ -12,7 +12,7 @@ use App\Repos\Course as CourseRepo; class Course extends Cache { - protected $lifetime = 1 * 86400; + protected $lifetime = 86400; public function getLifetime() { diff --git a/app/Caches/CourseCategoryList.php b/app/Caches/CourseCategoryList.php index 0634ffc7..12681a06 100644 --- a/app/Caches/CourseCategoryList.php +++ b/app/Caches/CourseCategoryList.php @@ -13,7 +13,7 @@ use App\Repos\Course as CourseRepo; class CourseCategoryList extends Cache { - protected $lifetime = 1 * 86400; + protected $lifetime = 86400; public function getLifetime() { diff --git a/app/Caches/CoursePackageList.php b/app/Caches/CoursePackageList.php index c251e2e9..6c27dd1e 100644 --- a/app/Caches/CoursePackageList.php +++ b/app/Caches/CoursePackageList.php @@ -13,7 +13,7 @@ use App\Repos\Course as CourseRepo; class CoursePackageList extends Cache { - protected $lifetime = 1 * 86400; + protected $lifetime = 86400; public function getLifetime() { diff --git a/app/Caches/CourseRecommendedList.php b/app/Caches/CourseRecommendedList.php index fb6c5d17..c810082f 100644 --- a/app/Caches/CourseRecommendedList.php +++ b/app/Caches/CourseRecommendedList.php @@ -14,7 +14,7 @@ use Phalcon\Mvc\Model\ResultsetInterface; class CourseRecommendedList extends Cache { - protected $lifetime = 1 * 86400; + protected $lifetime = 86400; public function getLifetime() { diff --git a/app/Caches/CourseRelatedList.php b/app/Caches/CourseRelatedList.php index 46274fc1..d8d8f58c 100644 --- a/app/Caches/CourseRelatedList.php +++ b/app/Caches/CourseRelatedList.php @@ -13,7 +13,7 @@ use App\Repos\Course as CourseRepo; class CourseRelatedList extends Cache { - protected $lifetime = 1 * 86400; + protected $lifetime = 86400; public function getLifetime() { diff --git a/app/Caches/CourseTeacherList.php b/app/Caches/CourseTeacherList.php index 70314edc..1c676f1a 100644 --- a/app/Caches/CourseTeacherList.php +++ b/app/Caches/CourseTeacherList.php @@ -13,7 +13,7 @@ use App\Repos\Course as CourseRepo; class CourseTeacherList extends Cache { - protected $lifetime = 1 * 86400; + protected $lifetime = 86400; public function getLifetime() { diff --git a/app/Caches/CourseTopicList.php b/app/Caches/CourseTopicList.php index 0d9e95aa..580d7d09 100644 --- a/app/Caches/CourseTopicList.php +++ b/app/Caches/CourseTopicList.php @@ -14,7 +14,7 @@ use Phalcon\Mvc\Model\ResultsetInterface; class CourseTopicList extends Cache { - protected $lifetime = 1 * 86400; + protected $lifetime = 86400; public function getLifetime() { diff --git a/app/Caches/FeaturedArticleList.php b/app/Caches/FeaturedArticleList.php new file mode 100644 index 00000000..bd5fc0f2 --- /dev/null +++ b/app/Caches/FeaturedArticleList.php @@ -0,0 +1,83 @@ +findArticles($limit); + + if ($articles->count() == 0) { + return []; + } + + $result = []; + + foreach ($articles as $article) { + + $userCount = $article->user_count; + + if ($article->fake_user_count > $article->user_count) { + $userCount = $article->fake_user_count; + } + + $result[] = [ + 'id' => $article->id, + 'title' => $article->title, + 'cover' => $article->cover, + 'market_price' => (float)$article->market_price, + 'vip_price' => (float)$article->vip_price, + 'user_count' => $userCount, + 'favorite_count' => $article->favorite_count, + 'comment_count' => $article->comment_count, + 'view_count' => $article->view_count, + 'like_count' => $article->like_count, + ]; + } + + return $result; + } + + /** + * @param int $limit + * @return ResultsetInterface|Resultset|ArticleModel[] + */ + protected function findArticles($limit = 8) + { + return ArticleModel::query() + ->where('featured = 1') + ->andWhere('published = 1') + ->andWhere('deleted = 0') + ->orderBy('id DESC') + ->limit($limit) + ->execute(); + } + +} diff --git a/app/Caches/FeaturedCourseList.php b/app/Caches/FeaturedCourseList.php new file mode 100644 index 00000000..cb2817a8 --- /dev/null +++ b/app/Caches/FeaturedCourseList.php @@ -0,0 +1,85 @@ +findCourses($limit); + + if ($courses->count() == 0) { + return []; + } + + $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, + 'cover' => $course->cover, + 'model' => $course->model, + 'level' => $course->level, + 'rating' => round($course->rating, 1), + 'market_price' => (float)$course->market_price, + 'vip_price' => (float)$course->vip_price, + 'user_count' => $userCount, + 'lesson_count' => $course->lesson_count, + 'review_count' => $course->review_count, + 'favorite_count' => $course->favorite_count, + ]; + } + + return $result; + } + + /** + * @param int $limit + * @return ResultsetInterface|Resultset|CourseModel[] + */ + protected function findCourses($limit = 8) + { + return CourseModel::query() + ->where('featured = 1') + ->andWhere('published = 1') + ->andWhere('deleted = 0') + ->orderBy('id DESC') + ->limit($limit) + ->execute(); + } + +} diff --git a/app/Caches/FlashSale.php b/app/Caches/FlashSale.php index 8062e03a..d8b89f43 100644 --- a/app/Caches/FlashSale.php +++ b/app/Caches/FlashSale.php @@ -12,7 +12,7 @@ use App\Repos\FlashSale as FlashSaleRepo; class FlashSale extends Cache { - protected $lifetime = 1 * 86400; + protected $lifetime = 86400; public function getLifetime() { diff --git a/app/Caches/HotQuestionList.php b/app/Caches/HotQuestionList.php index f557a688..64220fd8 100644 --- a/app/Caches/HotQuestionList.php +++ b/app/Caches/HotQuestionList.php @@ -14,7 +14,7 @@ use Phalcon\Mvc\Model\ResultsetInterface; class HotQuestionList extends Cache { - protected $lifetime = 1 * 86400; + protected $lifetime = 86400; public function getLifetime() { diff --git a/app/Caches/IndexFeaturedCourseList.php b/app/Caches/IndexFeaturedCourseList.php index 54b44f4d..f7d0e6ae 100644 --- a/app/Caches/IndexFeaturedCourseList.php +++ b/app/Caches/IndexFeaturedCourseList.php @@ -19,7 +19,7 @@ use Phalcon\Mvc\Model\ResultsetInterface; class IndexFeaturedCourseList extends Cache { - protected $lifetime = 1 * 86400; + protected $lifetime = 86400; public function getLifetime() { diff --git a/app/Caches/IndexFlashSaleList.php b/app/Caches/IndexFlashSaleList.php index 587da335..7fd379b6 100644 --- a/app/Caches/IndexFlashSaleList.php +++ b/app/Caches/IndexFlashSaleList.php @@ -12,7 +12,7 @@ use App\Services\Logic\FlashSale\SaleList; class IndexFlashSaleList extends Cache { - protected $lifetime = 1 * 86400; + protected $lifetime = 86400; public function getLifetime() { diff --git a/app/Caches/IndexFreeCourseList.php b/app/Caches/IndexFreeCourseList.php index d96847c0..bc20a9dc 100644 --- a/app/Caches/IndexFreeCourseList.php +++ b/app/Caches/IndexFreeCourseList.php @@ -19,7 +19,7 @@ use Phalcon\Mvc\Model\ResultsetInterface; class IndexFreeCourseList extends Cache { - protected $lifetime = 1 * 86400; + protected $lifetime = 86400; public function getLifetime() { diff --git a/app/Caches/IndexLiveList.php b/app/Caches/IndexLiveList.php index 6d5d0836..734150a1 100644 --- a/app/Caches/IndexLiveList.php +++ b/app/Caches/IndexLiveList.php @@ -18,7 +18,7 @@ use Phalcon\Mvc\Model\ResultsetInterface; class IndexLiveList extends Cache { - protected $lifetime = 1 * 86400; + protected $lifetime = 86400; public function getLifetime() { diff --git a/app/Caches/IndexNewCourseList.php b/app/Caches/IndexNewCourseList.php index 27d83172..4975cb27 100644 --- a/app/Caches/IndexNewCourseList.php +++ b/app/Caches/IndexNewCourseList.php @@ -19,7 +19,7 @@ use Phalcon\Mvc\Model\ResultsetInterface; class IndexNewCourseList extends Cache { - protected $lifetime = 1 * 86400; + protected $lifetime = 86400; public function getLifetime() { diff --git a/app/Caches/IndexSimpleFeaturedCourseList.php b/app/Caches/IndexSimpleFeaturedCourseList.php index 1ea87812..b5433216 100644 --- a/app/Caches/IndexSimpleFeaturedCourseList.php +++ b/app/Caches/IndexSimpleFeaturedCourseList.php @@ -17,7 +17,7 @@ use Phalcon\Mvc\Model\ResultsetInterface; class IndexSimpleFeaturedCourseList extends Cache { - protected $lifetime = 1 * 86400; + protected $lifetime = 86400; public function getLifetime() { diff --git a/app/Caches/IndexSimpleFreeCourseList.php b/app/Caches/IndexSimpleFreeCourseList.php index 065c6066..34a6d4f7 100644 --- a/app/Caches/IndexSimpleFreeCourseList.php +++ b/app/Caches/IndexSimpleFreeCourseList.php @@ -17,7 +17,7 @@ use Phalcon\Mvc\Model\ResultsetInterface; class IndexSimpleFreeCourseList extends Cache { - protected $lifetime = 1 * 86400; + protected $lifetime = 86400; public function getLifetime() { diff --git a/app/Caches/IndexSimpleNewCourseList.php b/app/Caches/IndexSimpleNewCourseList.php index b6e0b6b9..7dffa5af 100644 --- a/app/Caches/IndexSimpleNewCourseList.php +++ b/app/Caches/IndexSimpleNewCourseList.php @@ -17,7 +17,7 @@ use Phalcon\Mvc\Model\ResultsetInterface; class IndexSimpleNewCourseList extends Cache { - protected $lifetime = 1 * 86400; + protected $lifetime = 86400; public function getLifetime() { diff --git a/app/Caches/IndexSimpleVipCourseList.php b/app/Caches/IndexSimpleVipCourseList.php index bb073985..6756b39e 100644 --- a/app/Caches/IndexSimpleVipCourseList.php +++ b/app/Caches/IndexSimpleVipCourseList.php @@ -17,7 +17,7 @@ use Phalcon\Mvc\Model\ResultsetInterface; class IndexSimpleVipCourseList extends Cache { - protected $lifetime = 1 * 86400; + protected $lifetime = 86400; public function getLifetime() { diff --git a/app/Caches/IndexTeacherList.php b/app/Caches/IndexTeacherList.php index df9d2056..0946f126 100644 --- a/app/Caches/IndexTeacherList.php +++ b/app/Caches/IndexTeacherList.php @@ -14,7 +14,7 @@ use Phalcon\Mvc\Model\ResultsetInterface; class IndexTeacherList extends Cache { - protected $lifetime = 1 * 3600; + protected $lifetime = 3600; public function getLifetime() { diff --git a/app/Caches/IndexVipCourseList.php b/app/Caches/IndexVipCourseList.php index db09222a..6b268160 100644 --- a/app/Caches/IndexVipCourseList.php +++ b/app/Caches/IndexVipCourseList.php @@ -19,7 +19,7 @@ use Phalcon\Mvc\Model\ResultsetInterface; class IndexVipCourseList extends Cache { - protected $lifetime = 1 * 86400; + protected $lifetime = 86400; public function getLifetime() { diff --git a/app/Caches/PackageCourseList.php b/app/Caches/PackageCourseList.php index 2843cd71..90de701b 100644 --- a/app/Caches/PackageCourseList.php +++ b/app/Caches/PackageCourseList.php @@ -13,7 +13,7 @@ use App\Repos\Package as PackageRepo; class PackageCourseList extends Cache { - protected $lifetime = 1 * 86400; + protected $lifetime = 86400; public function getLifetime() { diff --git a/app/Caches/PointGift.php b/app/Caches/PointGift.php index e9adc52e..07f5afa0 100644 --- a/app/Caches/PointGift.php +++ b/app/Caches/PointGift.php @@ -12,7 +12,7 @@ use App\Repos\PointGift as PointGiftRepo; class PointGift extends Cache { - protected $lifetime = 1 * 86400; + protected $lifetime = 86400; public function getLifetime() { diff --git a/app/Caches/PointHotGiftList.php b/app/Caches/PointHotGiftList.php index 5fe9213a..529c479c 100644 --- a/app/Caches/PointHotGiftList.php +++ b/app/Caches/PointHotGiftList.php @@ -19,7 +19,7 @@ class PointHotGiftList extends Cache * * @var int */ - protected $lifetime = 1 * 86400; + protected $lifetime = 86400; /** * 显示个数 diff --git a/app/Caches/Question.php b/app/Caches/Question.php index f350f6cc..b832fa1f 100644 --- a/app/Caches/Question.php +++ b/app/Caches/Question.php @@ -12,7 +12,7 @@ use App\Repos\Question as QuestionRepo; class Question extends Cache { - protected $lifetime = 1 * 86400; + protected $lifetime = 86400; public function getLifetime() { diff --git a/app/Caches/TaggedArticleList.php b/app/Caches/TaggedArticleList.php index 8113b4f8..d57faf7b 100644 --- a/app/Caches/TaggedArticleList.php +++ b/app/Caches/TaggedArticleList.php @@ -15,7 +15,7 @@ class TaggedArticleList extends Cache protected $limit = 5; - protected $lifetime = 1 * 86400; + protected $lifetime = 86400; public function getLifetime() { diff --git a/app/Caches/TaggedQuestionList.php b/app/Caches/TaggedQuestionList.php index d563dabe..7495823b 100644 --- a/app/Caches/TaggedQuestionList.php +++ b/app/Caches/TaggedQuestionList.php @@ -15,7 +15,7 @@ class TaggedQuestionList extends Cache protected $limit = 5; - protected $lifetime = 1 * 86400; + protected $lifetime = 86400; public function getLifetime() { diff --git a/app/Caches/TopAnswererList.php b/app/Caches/TopAnswererList.php index fe881f5d..37991604 100644 --- a/app/Caches/TopAnswererList.php +++ b/app/Caches/TopAnswererList.php @@ -16,7 +16,7 @@ use Phalcon\Mvc\Model\ResultsetInterface; class TopAnswererList extends Cache { - protected $lifetime = 1 * 86400; + protected $lifetime = 86400; public function getLifetime() { diff --git a/app/Caches/TopAuthorList.php b/app/Caches/TopAuthorList.php index 48153879..882e4cab 100644 --- a/app/Caches/TopAuthorList.php +++ b/app/Caches/TopAuthorList.php @@ -16,7 +16,7 @@ use Phalcon\Mvc\Model\ResultsetInterface; class TopAuthorList extends Cache { - protected $lifetime = 1 * 86400; + protected $lifetime = 86400; public function getLifetime() { diff --git a/app/Caches/User.php b/app/Caches/User.php index 9e0825d3..9f8ece22 100644 --- a/app/Caches/User.php +++ b/app/Caches/User.php @@ -12,7 +12,7 @@ use App\Repos\User as UserRepo; class User extends Cache { - protected $lifetime = 1 * 86400; + protected $lifetime = 86400; public function getLifetime() { diff --git a/app/Caches/UserDailyCounter.php b/app/Caches/UserDailyCounter.php index afda376e..19f59830 100644 --- a/app/Caches/UserDailyCounter.php +++ b/app/Caches/UserDailyCounter.php @@ -10,7 +10,7 @@ namespace App\Caches; class UserDailyCounter extends Counter { - protected $lifetime = 1 * 86400; + protected $lifetime = 86400; public function getLifetime() { diff --git a/app/Console/Tasks/CleanLogTask.php b/app/Console/Tasks/CleanLogTask.php index 2a874bf6..c5d62424 100644 --- a/app/Console/Tasks/CleanLogTask.php +++ b/app/Console/Tasks/CleanLogTask.php @@ -19,7 +19,6 @@ class CleanLogTask extends Task $this->cleanHttpLog(); $this->cleanSqlLog(); $this->cleanListenLog(); - $this->cleanCaptchaLog(); $this->cleanWeChatLog(); $this->cleanMailLog(); $this->cleanSmsLog(); @@ -96,18 +95,6 @@ class CleanLogTask extends Task $this->whitelist[] = $type; } - /** - * 清理验证码服务日志 - */ - protected function cleanCaptchaLog() - { - $type = 'captcha'; - - $this->cleanLog($type, 7); - - $this->whitelist[] = $type; - } - /** * 清理点播服务日志 */ @@ -268,13 +255,12 @@ class CleanLogTask extends Task * 清理其它日志 * * @param int $keepDays - * @return mixed */ protected function cleanOtherLog($keepDays = 7) { $files = glob(log_path() . "/*.log"); - if (!$files) return false; + if (!$files) return; foreach ($files as $file) { $name = str_replace(log_path() . '/', '', $file); @@ -287,9 +273,9 @@ class CleanLogTask extends Task if (strtotime($today) - strtotime($date) >= $keepDays * 86400) { $deleted = unlink($file); if ($deleted) { - echo "delete {$file} success" . PHP_EOL; + $this->successPrint("remove {$file} success"); } else { - echo "delete {$file} failed" . PHP_EOL; + $this->errorPrint("remove {$file} failed"); } } } @@ -300,13 +286,12 @@ class CleanLogTask extends Task * * @param string $prefix * @param int $keepDays 保留天数 - * @return mixed */ protected function cleanLog($prefix, $keepDays) { $files = glob(log_path() . "/{$prefix}-*.log"); - if (!$files) return false; + if (!$files) return; foreach ($files as $file) { $date = substr($file, -14, 10); @@ -314,9 +299,9 @@ class CleanLogTask extends Task if (strtotime($today) - strtotime($date) >= $keepDays * 86400) { $deleted = unlink($file); if ($deleted) { - echo "------ delete {$file} success ------" . PHP_EOL; + $this->successPrint("remove {$file} success"); } else { - echo "------ delete {$file} failed -------" . PHP_EOL; + $this->errorPrint("remove {$file} failed"); } } } diff --git a/app/Console/Tasks/Task.php b/app/Console/Tasks/Task.php index a4cf06fd..59a9b853 100644 --- a/app/Console/Tasks/Task.php +++ b/app/Console/Tasks/Task.php @@ -11,5 +11,17 @@ use App\Traits\Service as ServiceTrait; class Task extends \Phalcon\Cli\Task { + use ServiceTrait; + + protected function successPrint($text) + { + echo "\033[32m {$text} \033[0m" . PHP_EOL; + } + + protected function errorPrint($text) + { + echo "\033[31m {$text} \033[0m" . PHP_EOL; + } + } diff --git a/app/Http/Admin/Controllers/SettingController.php b/app/Http/Admin/Controllers/SettingController.php index 03489cc3..b0d9e840 100644 --- a/app/Http/Admin/Controllers/SettingController.php +++ b/app/Http/Admin/Controllers/SettingController.php @@ -223,36 +223,6 @@ class SettingController extends Controller } } - /** - * @Route("/captcha", name="admin.setting.captcha") - */ - public function captchaAction() - { - $section = 'captcha'; - - $settingService = new SettingService(); - - if ($this->request->isPost()) { - - $data = $this->request->getPost(); - - $settingService->updateSettings($section, $data); - - $content = [ - 'location' => $this->request->getHTTPReferer(), - 'msg' => '更新配置成功', - ]; - - return $this->jsonSuccess($content); - - } else { - - $captcha = $settingService->getSettings($section); - - $this->view->setVar('captcha', $captcha); - } - } - /** * @Route("/point", name="admin.setting.point") */ diff --git a/app/Http/Admin/Controllers/StudentController.php b/app/Http/Admin/Controllers/StudentController.php index b846002f..324c6943 100644 --- a/app/Http/Admin/Controllers/StudentController.php +++ b/app/Http/Admin/Controllers/StudentController.php @@ -20,11 +20,13 @@ class StudentController extends Controller */ public function searchAction() { + $courseId = $this->request->getQuery('course_id', 'int', 0); + $studentService = new StudentService(); $sourceTypes = $studentService->getSourceTypes(); - $xmCourses = $studentService->getXmCourses('all'); + $xmCourses = $studentService->getXmCourses('all', $courseId); $this->view->setVar('source_types', $sourceTypes); $this->view->setVar('xm_courses', $xmCourses); @@ -56,9 +58,11 @@ class StudentController extends Controller */ public function addAction() { + $courseId = $this->request->getQuery('course_id', 'int', 0); + $studentService = new StudentService(); - $xmCourses = $studentService->getXmCourses('charge'); + $xmCourses = $studentService->getXmCourses('all', $courseId); $this->view->setVar('xm_courses', $xmCourses); } diff --git a/app/Http/Admin/Services/AuthNode.php b/app/Http/Admin/Services/AuthNode.php index 6df40868..35c59e85 100644 --- a/app/Http/Admin/Services/AuthNode.php +++ b/app/Http/Admin/Services/AuthNode.php @@ -1200,12 +1200,6 @@ class AuthNode extends Service 'type' => 'menu', 'route' => 'admin.setting.sms', ], - [ - 'id' => '5-2-3', - 'title' => '验证码设置', - 'type' => 'menu', - 'route' => 'admin.setting.captcha', - ], [ 'id' => '5-2-4', 'title' => '存储设置', diff --git a/app/Http/Admin/Services/Student.php b/app/Http/Admin/Services/Student.php index d583d320..1743e513 100644 --- a/app/Http/Admin/Services/Student.php +++ b/app/Http/Admin/Services/Student.php @@ -20,7 +20,7 @@ use App\Validators\CourseUser as CourseUserValidator; class Student extends Service { - public function getXmCourses($scope = 'all') + public function getXmCourses($scope = 'all', $courseId = 0) { $courseRepo = new CourseRepo(); @@ -46,6 +46,7 @@ class Student extends Service $result[] = [ 'name' => sprintf('%s - %s(¥%0.2f)', $item->id, $item->title, $item->market_price), 'value' => $item->id, + 'selected' => $item->id == $courseId, ]; } diff --git a/app/Http/Admin/Views/refund/macro.volt b/app/Http/Admin/Views/refund/macro.volt index 6320281f..0208de49 100644 --- a/app/Http/Admin/Views/refund/macro.volt +++ b/app/Http/Admin/Views/refund/macro.volt @@ -12,22 +12,4 @@ {% elseif value == 6 %} 已失败 {% endif %} -{%- endmacro %} - -{%- macro refund_status_history(items) %} - {% for item in items %} - {% if item.status == 1 %} -

创建时间:{{ date('Y-m-d H:i:s',item.create_time) }}

- {% elseif item.status == 2 %} -

取消时间:{{ date('Y-m-d H:i:s',item.create_time) }}

- {% elseif item.status == 3 %} -

过审时间:{{ date('Y-m-d H:i:s',item.create_time) }}

- {% elseif item.status == 4 %} -

拒绝时间:{{ date('Y-m-d H:i:s',item.create_time) }}

- {% elseif item.status == 5 %} -

完成时间:{{ date('Y-m-d H:i:s',item.create_time) }}

- {% elseif item.status == 6 %} -

失败时间:{{ date('Y-m-d H:i:s',item.create_time) }}

- {% endif %} - {% endfor %} {%- endmacro %} \ No newline at end of file diff --git a/app/Http/Admin/Views/setting/captcha.volt b/app/Http/Admin/Views/setting/captcha.volt deleted file mode 100644 index 1b05a222..00000000 --- a/app/Http/Admin/Views/setting/captcha.volt +++ /dev/null @@ -1,124 +0,0 @@ -{% extends 'templates/main.volt' %} - -{% block content %} - - {% set captcha_display = captcha.enabled == 1 ? 'display:block' : 'display:none' %} - -
-
- 验证码配置 -
-
- -
- - -
-
-
-
- -
- -
-
-
- -
- -
-
-
-
- -
- - -
-
-
- -
-
- 验证码测试 -
-
- -
- - -
-
-
- -
- - - - -
-
-
- -{% endblock %} - -{% block inline_js %} - - - - - -{% endblock %} \ No newline at end of file diff --git a/app/Http/Admin/Views/setting/dingtalk_robot.volt b/app/Http/Admin/Views/setting/dingtalk_robot.volt index 64bbb80e..e624dd70 100644 --- a/app/Http/Admin/Views/setting/dingtalk_robot.volt +++ b/app/Http/Admin/Views/setting/dingtalk_robot.volt @@ -14,15 +14,15 @@
- +
- +
- +
- +
diff --git a/app/Http/Admin/Views/student/list.volt b/app/Http/Admin/Views/student/list.volt index 2be6a8c1..7f3dfd71 100644 --- a/app/Http/Admin/Views/student/list.volt +++ b/app/Http/Admin/Views/student/list.volt @@ -18,8 +18,13 @@ {% endif %} {%- endmacro %} - {% set add_url = url({'for':'admin.student.add'}) %} - {% set search_url = url({'for':'admin.student.search'}) %} + {% if course %} + {% set add_url = url({'for':'admin.student.add'},{'course_id':course.id}) %} + {% set search_url = url({'for':'admin.student.search'},{'course_id':course.id}) %} + {% else %} + {% set add_url = url({'for':'admin.student.add'}) %} + {% set search_url = url({'for':'admin.student.search'}) %} + {% endif %}
diff --git a/app/Http/Admin/Views/trade/macro.volt b/app/Http/Admin/Views/trade/macro.volt index 331f7ad3..38ec2095 100644 --- a/app/Http/Admin/Views/trade/macro.volt +++ b/app/Http/Admin/Views/trade/macro.volt @@ -16,18 +16,4 @@ {% elseif value == 4 %} 已退款 {% endif %} -{%- endmacro %} - -{%- macro trade_status_history(items) %} - {% for item in items %} - {% if item.status == 1 %} -

创建时间:{{ date('Y-m-d H:i:s',item.create_time) }}

- {% elseif item.status == 2 %} -

完成时间:{{ date('Y-m-d H:i:s',item.create_time) }}

- {% elseif item.status == 3 %} -

关闭时间:{{ date('Y-m-d H:i:s',item.create_time) }}

- {% elseif item.status == 4 %} -

退款时间:{{ date('Y-m-d H:i:s',item.create_time) }}

- {% endif %} - {% endfor %} {%- endmacro %} \ No newline at end of file diff --git a/app/Http/Api/Controllers/PublicController.php b/app/Http/Api/Controllers/PublicController.php index c350a69c..05158ea4 100644 --- a/app/Http/Api/Controllers/PublicController.php +++ b/app/Http/Api/Controllers/PublicController.php @@ -76,20 +76,6 @@ class PublicController extends Controller return $this->jsonSuccess(['site' => $site]); } - /** - * @Get("/captcha/info", name="api.public.captcha_info") - */ - public function captchaInfoAction() - { - $service = new AppService(); - - $captcha = $service->getSettings('captcha'); - - unset($captcha['secret_key']); - - return $this->jsonSuccess(['captcha' => $captcha]); - } - /** * @Get("/payment/info", name="api.public.payment_info") */ diff --git a/app/Http/Api/Controllers/VerifyController.php b/app/Http/Api/Controllers/VerifyController.php index 3f0c8b8c..533ad1bd 100644 --- a/app/Http/Api/Controllers/VerifyController.php +++ b/app/Http/Api/Controllers/VerifyController.php @@ -7,9 +7,10 @@ namespace App\Http\Api\Controllers; -use App\Services\Logic\Verify\MailCode as MailCodeService; -use App\Services\Logic\Verify\SmsCode as SmsCodeService; -use App\Services\Logic\Verify\Ticket as TicketService; +use App\Services\Logic\Verify\Captcha as VerifyCaptchaService; +use App\Services\Logic\Verify\Code as VerifyCodeService; +use App\Services\Logic\Verify\MailCode as VerifyMailCodeService; +use App\Services\Logic\Verify\SmsCode as VerifySmsCodeService; /** * @RoutePrefix("/api/verify") @@ -18,15 +19,27 @@ class VerifyController extends Controller { /** - * @Post("/ticket", name="api.verify.ticket") + * @Get("/captcha", name="api.verify.captcha") */ - public function ticketAction() + public function captchaAction() { - $service = new TicketService(); + $service = new VerifyCaptchaService(); - $ticket = $service->handle(); + $captcha = $service->handle(); - return $this->jsonSuccess(['ticket' => $ticket]); + return $this->jsonSuccess(['captcha' => $captcha]); + } + + /** + * @Post("/code", name="api.verify.code") + */ + public function codeAction() + { + $service = new VerifyCodeService(); + + $service->handle(); + + return $this->jsonSuccess(); } /** @@ -34,7 +47,7 @@ class VerifyController extends Controller */ public function smsCodeAction() { - $service = new SmsCodeService(); + $service = new VerifySmsCodeService(); $service->handle(); @@ -46,7 +59,7 @@ class VerifyController extends Controller */ public function mailCodeAction() { - $service = new MailCodeService(); + $service = new VerifyMailCodeService(); $service->handle(); diff --git a/app/Http/Home/Controllers/AccountController.php b/app/Http/Home/Controllers/AccountController.php index 819e6520..093fbea1 100644 --- a/app/Http/Home/Controllers/AccountController.php +++ b/app/Http/Home/Controllers/AccountController.php @@ -15,6 +15,9 @@ use App\Services\Logic\Account\PasswordReset as PasswordResetService; use App\Services\Logic\Account\PasswordUpdate as PasswordUpdateService; use App\Services\Logic\Account\PhoneUpdate as PhoneUpdateService; +/** + * @RoutePrefix("/account") + */ class AccountController extends Controller { @@ -40,15 +43,10 @@ class AccountController extends Controller $oauthProvider = $service->handle(); - $service = new AccountService(); - - $captcha = $service->getSettings('captcha'); - $this->seo->prependTitle('用户注册'); $this->view->setVar('return_url', $returnUrl); $this->view->setVar('local_oauth', $oauthProvider['local']); - $this->view->setVar('captcha', $captcha); } /** @@ -67,10 +65,6 @@ class AccountController extends Controller return $this->response->redirect('/'); } - $service = new AccountService(); - - $captcha = $service->getSettings('captcha'); - $service = new OAuthProviderService(); $oauthProvider = $service->handle(); @@ -81,7 +75,6 @@ class AccountController extends Controller $this->view->setVar('oauth_provider', $oauthProvider); $this->view->setVar('return_url', $returnUrl); - $this->view->setVar('captcha', $captcha); } /** @@ -112,13 +105,7 @@ class AccountController extends Controller return $this->response->redirect(['for' => 'home.index']); } - $service = new AccountService(); - - $captcha = $service->getSettings('captcha'); - $this->seo->prependTitle('重置密码'); - - $this->view->setVar('captcha', $captcha); } /** diff --git a/app/Http/Home/Controllers/HelpController.php b/app/Http/Home/Controllers/HelpController.php index 6ea78c31..2de44d92 100644 --- a/app/Http/Home/Controllers/HelpController.php +++ b/app/Http/Home/Controllers/HelpController.php @@ -8,7 +8,6 @@ namespace App\Http\Home\Controllers; use App\Http\Home\Services\FullH5Url as FullH5UrlService; -use App\Http\Home\Services\Index as IndexService; use App\Services\Logic\Help\HelpInfo as HelpInfoService; use App\Services\Logic\Help\HelpList as HelpListService; @@ -63,19 +62,9 @@ class HelpController extends Controller $this->notFound(); } - $featuredCourses = $this->getFeaturedCourses(); - $this->seo->prependTitle(['帮助', $help['title']]); $this->view->setVar('help', $help); - $this->view->setVar('featured_courses', $featuredCourses); - } - - protected function getFeaturedCourses() - { - $service = new IndexService(); - - return $service->getSimpleFeaturedCourses(); } } diff --git a/app/Http/Home/Controllers/VerifyController.php b/app/Http/Home/Controllers/VerifyController.php index f494fed8..9a6c1f37 100644 --- a/app/Http/Home/Controllers/VerifyController.php +++ b/app/Http/Home/Controllers/VerifyController.php @@ -7,40 +7,22 @@ namespace App\Http\Home\Controllers; -use App\Services\Logic\Verify\MailCode as MailCodeService; -use App\Services\Logic\Verify\SmsCode as SmsCodeService; use App\Traits\Response as ResponseTrait; /** * @RoutePrefix("/verify") */ -class VerifyController extends \Phalcon\Mvc\Controller +class VerifyController extends Controller { use ResponseTrait; /** - * @Post("/sms/code", name="home.verify.sms_code") + * @Get("/captcha", name="home.verify.captcha") */ - public function smsCodeAction() + public function captchaAction() { - $service = new SmsCodeService(); - - $service->handle(); - - return $this->jsonSuccess(); - } - - /** - * @Post("/mail/code", name="home.verify.mail_code") - */ - public function mailCodeAction() - { - $service = new MailCodeService(); - - $service->handle(); - - return $this->jsonSuccess(); + $this->view->pick('verify/captcha'); } } diff --git a/app/Http/Home/Controllers/WidgetController.php b/app/Http/Home/Controllers/WidgetController.php index 1df05810..1d558745 100644 --- a/app/Http/Home/Controllers/WidgetController.php +++ b/app/Http/Home/Controllers/WidgetController.php @@ -7,6 +7,8 @@ namespace App\Http\Home\Controllers; +use App\Caches\FeaturedArticleList as FeaturedArticleListCache; +use App\Caches\FeaturedCourseList as FeaturedCourseListCache; use App\Services\Logic\Article\TopAuthorList as TopAuthorListService; use App\Services\Logic\Question\HotQuestionList as HotQuestionListService; use App\Services\Logic\Question\TopAnswererList as TopAnswererListService; @@ -33,6 +35,34 @@ class WidgetController extends Controller $this->view->setVar('tags', $pager->items); } + /** + * @Get("/featured/courses", name="home.widget.featured_courses") + */ + public function featuredCoursesAction() + { + $cache = new FeaturedCourseListCache(); + + $courses = $cache->get(); + + $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); + $this->view->pick('widget/featured_courses'); + $this->view->setVar('courses', $courses); + } + + /** + * @Get("/featured/articles", name="home.widget.featured_articles") + */ + public function featuredArticlesAction() + { + $cache = new FeaturedArticleListCache(); + + $articles = $cache->get(); + + $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); + $this->view->pick('widget/featured_articles'); + $this->view->setVar('articles', $articles); + } + /** * @Get("/hot/questions", name="home.widget.hot_questions") */ diff --git a/app/Http/Home/Services/Account.php b/app/Http/Home/Services/Account.php index 02e771db..50bbe9dd 100644 --- a/app/Http/Home/Services/Account.php +++ b/app/Http/Home/Services/Account.php @@ -62,18 +62,6 @@ class Account extends Service $validator->checkIfAllowLogin($user); - $captcha = $this->getSettings('captcha'); - - /** - * 验证码是一次性的,放到最后检查,减少第三方调用 - */ - if ($captcha['enabled'] == 1) { - - $validator = new CaptchaValidator(); - - $validator->checkCode($post['captcha']['ticket'], $post['captcha']['rand']); - } - $this->auth->saveAuthInfo($user); $this->eventsManager->fire('Account:afterLogin', $this, $user); diff --git a/app/Http/Home/Views/account/forget.volt b/app/Http/Home/Views/account/forget.volt index 78c3b2eb..8ee30fee 100644 --- a/app/Http/Home/Views/account/forget.volt +++ b/app/Http/Home/Views/account/forget.volt @@ -35,7 +35,6 @@ {% block include_js %} - {{ js_include('https://ssl.captcha.qq.com/TCaptcha.js',false) }} {{ js_include('home/js/captcha.verify.phone.js') }} {{ js_include('home/js/captcha.verify.email.js') }} diff --git a/app/Http/Home/Views/account/forget_by_email.volt b/app/Http/Home/Views/account/forget_by_email.volt index c203d6bd..58e7427f 100644 --- a/app/Http/Home/Views/account/forget_by_email.volt +++ b/app/Http/Home/Views/account/forget_by_email.volt @@ -5,7 +5,7 @@
- +
@@ -19,8 +19,6 @@
- -
diff --git a/app/Http/Home/Views/account/forget_by_phone.volt b/app/Http/Home/Views/account/forget_by_phone.volt index f70b6c69..da10f212 100644 --- a/app/Http/Home/Views/account/forget_by_phone.volt +++ b/app/Http/Home/Views/account/forget_by_phone.volt @@ -5,7 +5,7 @@
- +
@@ -19,8 +19,6 @@
- -
diff --git a/app/Http/Home/Views/account/login.volt b/app/Http/Home/Views/account/login.volt index 5bbcc1f1..cb277348 100644 --- a/app/Http/Home/Views/account/login.volt +++ b/app/Http/Home/Views/account/login.volt @@ -44,8 +44,6 @@ {% block include_js %} - {{ js_include('https://ssl.captcha.qq.com/TCaptcha.js',false) }} - {{ js_include('home/js/captcha.login.js') }} {{ js_include('home/js/captcha.verify.js') }} {% endblock %} diff --git a/app/Http/Home/Views/account/login_by_password.volt b/app/Http/Home/Views/account/login_by_password.volt index 2de28228..2f88eb57 100644 --- a/app/Http/Home/Views/account/login_by_password.volt +++ b/app/Http/Home/Views/account/login_by_password.volt @@ -1,6 +1,3 @@ -{% set disabled_submit = captcha.enabled == 1 ? 'disabled="disabled"' : '' %} -{% set disabled_class = captcha.enabled == 1 ? 'layui-btn-disabled' : '' %} - \ No newline at end of file diff --git a/app/Http/Home/Views/account/login_by_verify.volt b/app/Http/Home/Views/account/login_by_verify.volt index fe00dcb3..feb750ad 100644 --- a/app/Http/Home/Views/account/login_by_verify.volt +++ b/app/Http/Home/Views/account/login_by_verify.volt @@ -15,11 +15,9 @@
- - - +
\ No newline at end of file diff --git a/app/Http/Home/Views/account/register.volt b/app/Http/Home/Views/account/register.volt index 390ab9b4..c2bf9264 100644 --- a/app/Http/Home/Views/account/register.volt +++ b/app/Http/Home/Views/account/register.volt @@ -39,7 +39,6 @@ {% block include_js %} - {{ js_include('https://ssl.captcha.qq.com/TCaptcha.js',false) }} {{ js_include('home/js/account.register.js') }} {{ js_include('home/js/captcha.verify.phone.js') }} {{ js_include('home/js/captcha.verify.email.js') }} diff --git a/app/Http/Home/Views/account/register_by_email.volt b/app/Http/Home/Views/account/register_by_email.volt index b1cf9832..f6c486d9 100644 --- a/app/Http/Home/Views/account/register_by_email.volt +++ b/app/Http/Home/Views/account/register_by_email.volt @@ -2,11 +2,11 @@