diff --git a/.gitignore b/.gitignore index c1687295..2f894c4f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,8 @@ /config/xs.course.ini /config/xs.group.ini /config/xs.user.ini +/config/alipay/*.crt +/config/wxpay/*.pem /public/robots.txt /public/sitemap.xml *KgTest* diff --git a/README.md b/README.md index 1a478c4f..a97005b5 100644 --- a/README.md +++ b/README.md @@ -4,22 +4,28 @@ 酷瓜云课堂,依托腾讯云基础服务架构,采用 C 扩展框架 Phalcon 开发,致力网络教育软件。 +#### 系统功能 + 都有些什么功能?我也不想写一大堆,自己体验吧! -帐号:100015@163.com / 123456 (前后台通用) - -PS:**系统后台已禁止提交并隐藏私人配置** - - [前台演示](https://ctc.koogua.com) - [后台演示](https://ctc.koogua.com/admin) +帐号:100015@163.com / 123456 (前后台通用,请不要修改密码) + +友情提示: + +- 系统配置低(1核 1G 1M 跑多个容器),手下留情 +- 课程数据来源于网络(无实质内容),切莫购买 +- 管理后台已禁止提交(私密配置已过滤) + #### 项目组件 - 后台框架:[phalcon 3.4.5](https://phalcon.io) - 前端框架:[layui 2.5.6](https://layui.com), [layim 3.9.5](https://www.layui.com/layim)(已授权) - 全文检索:[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) +- 基础依赖:[php7.3](https://php.net), [mysql5.7](https://mysql.com), [redis5.0](https://redis.io) #### 使用协议 @@ -32,32 +38,7 @@ PS:**系统后台已禁止提交并隐藏私人配置** #### 安装指南 - [运行环境搭建](https://gitee.com/koogua/course-tencent-cloud-docker) -- [系统服务配置](https://gitee.com/koogua/course-tencent-cloud/wikis/服务配置) - -#### 会推出商业服务吗? - -- 如果不符合您对“开源”的认知,请移步其它同类产品,毕竟同类“免费”产品也很多。 -- 如果“开源”版本不能满足您的需求,或者您希望有更好的支持,商业服务是不错的选择。 - -我们为用户提供的服务包括: - -- 系统安装 -- 系统定制 -- 企业会员 - -#### 会有阿里云版吗? - -阿里云版规划中,之前阿里云服务过期未续费,所以腾讯云版本先出。 - -#### 代码有加密吗? - -所有代码都公开(授权代码除外,例如layim),没有所谓的商业版和付费插件。 - -#### 通过这个项目能学到什么? - -1. 项目规划,phalcon实战,缓存,JWT,即时通讯,全文检索 -2. docker操作,docker服务编排,supervisor,devops -3. git,linux,php,mysql,redis,nginx +- [系统服务配置](https://gitee.com/koogua/course-tencent-cloud/wikis) #### 开发计划 @@ -73,7 +54,29 @@ PS:**系统后台已禁止提交并隐藏私人配置** #### 加入我们 -这是我的创业项目,个人能力和精力有限,要兼顾产品规划以及开发,还要处理除报税记账之外的所有琐碎事情。 -目前在南山科技园某个众创空间,希望有能独挡一面的**深圳前端同学**加入我们。 +这是一个创业项目,个人能力和精力有限,要兼顾产品规划以及开发,还要处理很多琐碎事情。目前在南山科技园某个众创空间,希望有 **深圳前端同学** 加入我们。 联系邮箱:76632555@qq.com + +#### 通过这个项目能学到什么? + +- 项目规划,phalcon,缓存,JWT,即时通讯,全文检索 +- docker,supervisor,devops +- git,linux,php,mysql,redis,nginx + +#### 有阿里云版吗? + +阿里云版规划中,之前阿里云服务过期未续费,所以腾讯云版本先出。 + +#### 代码有加密吗? + +所有代码都公开(授权代码除外,例如layim),没有所谓的商业版和付费插件。 + +#### 有商业服务吗? + +生存是一个问题,生存才能发展,我们为用户提供的服务包括: + +- 系统安装 +- 系统定制 +- 企业授权 + diff --git a/app/Builders/CourseCatalog.php b/app/Builders/CourseChapterList.php similarity index 98% rename from app/Builders/CourseCatalog.php rename to app/Builders/CourseChapterList.php index 5415dae2..bd544a4b 100644 --- a/app/Builders/CourseCatalog.php +++ b/app/Builders/CourseChapterList.php @@ -7,7 +7,7 @@ use App\Models\Course as CourseModel; use Phalcon\Mvc\Model\Resultset; use Phalcon\Mvc\Model\ResultsetInterface; -class CourseCatalog extends Builder +class CourseChapterList extends Builder { /** diff --git a/app/Caches/Cache.php b/app/Caches/Cache.php index c832247c..f0b2cee4 100644 --- a/app/Caches/Cache.php +++ b/app/Caches/Cache.php @@ -15,7 +15,7 @@ abstract class Cache extends Component public function __construct() { - $this->cache = $this->getDI()->get('cache'); + $this->cache = $this->getDI()->getShared('cache'); } /** diff --git a/app/Caches/Counter.php b/app/Caches/Counter.php index 7c2dcbca..ad52c178 100644 --- a/app/Caches/Counter.php +++ b/app/Caches/Counter.php @@ -20,7 +20,7 @@ abstract class Counter extends Component public function __construct() { - $this->cache = $this->getDI()->get('cache'); + $this->cache = $this->getDI()->getShared('cache'); $this->redis = $this->cache->getRedis(); } diff --git a/app/Caches/CourseCatalog.php b/app/Caches/CourseChapterList.php similarity index 62% rename from app/Caches/CourseCatalog.php rename to app/Caches/CourseChapterList.php index 687a50ab..512dec28 100644 --- a/app/Caches/CourseCatalog.php +++ b/app/Caches/CourseChapterList.php @@ -2,9 +2,9 @@ namespace App\Caches; -use App\Builders\CourseCatalog as CourseCatalogBuilder; +use App\Builders\CourseChapterList as CourseChapterListBuilder; -class CourseCatalog extends Cache +class CourseChapterList extends Cache { protected $lifetime = 7 * 86400; @@ -16,12 +16,12 @@ class CourseCatalog extends Cache public function getKey($id = null) { - return "course_catalog:{$id}"; + return "course_chapter_list:{$id}"; } public function getContent($id = null) { - $builder = new CourseCatalogBuilder(); + $builder = new CourseChapterListBuilder(); $list = $builder->handle($id); diff --git a/app/Caches/IndexCarouselList.php b/app/Caches/IndexCarouselList.php deleted file mode 100644 index 94ccde8c..00000000 --- a/app/Caches/IndexCarouselList.php +++ /dev/null @@ -1,72 +0,0 @@ -lifetime; - } - - public function getKey($id = null) - { - return 'index_carousel_list'; - } - - public function getContent($id = null) - { - $limit = 5; - - $carousels = $this->findCarousels($limit); - - if ($carousels->count() == 0) { - return []; - } - - return $this->handleContent($carousels); - } - - /** - * @param CarouselModel[] $carousels - * @return array - */ - protected function handleContent($carousels) - { - $result = []; - - foreach ($carousels as $carousel) { - $result[] = [ - 'id' => $carousel->id, - 'title' => $carousel->title, - 'cover' => $carousel->cover, - 'style' => $carousel->style, - 'target' => $carousel->target, - 'content' => $carousel->content, - ]; - } - - return $result; - } - - /** - * @param int $limit - * @return ResultsetInterface|Resultset|CarouselModel[] - */ - public function findCarousels($limit = 5) - { - return CarouselModel::query() - ->where('published = 1') - ->orderBy('priority ASC') - ->limit($limit) - ->execute(); - } - -} diff --git a/app/Caches/IndexFreeCourseList.php b/app/Caches/IndexFreeCourseList.php index b6c69d67..2783b4ce 100644 --- a/app/Caches/IndexFreeCourseList.php +++ b/app/Caches/IndexFreeCourseList.php @@ -30,7 +30,7 @@ class IndexFreeCourseList extends Cache { $categoryLimit = 5; - $courseLimit = 10; + $courseLimit = 8; $categories = $this->findCategories($categoryLimit); @@ -100,7 +100,7 @@ class IndexFreeCourseList extends Cache * @param int $limit * @return ResultsetInterface|Resultset|CourseModel[] */ - protected function findCategoryCourses($categoryId, $limit = 10) + protected function findCategoryCourses($categoryId, $limit = 8) { $categoryService = new CategoryService(); diff --git a/app/Caches/IndexNewCourseList.php b/app/Caches/IndexNewCourseList.php index 7cb627cf..9a2a89b6 100644 --- a/app/Caches/IndexNewCourseList.php +++ b/app/Caches/IndexNewCourseList.php @@ -30,7 +30,7 @@ class IndexNewCourseList extends Cache { $categoryLimit = 5; - $courseLimit = 10; + $courseLimit = 8; $categories = $this->findCategories($categoryLimit); @@ -100,7 +100,7 @@ class IndexNewCourseList extends Cache * @param int $limit * @return ResultsetInterface|Resultset|CourseModel[] */ - protected function findCategoryCourses($categoryId, $limit = 10) + protected function findCategoryCourses($categoryId, $limit = 8) { $categoryService = new CategoryService(); diff --git a/app/Caches/IndexSimpleFreeCourseList.php b/app/Caches/IndexSimpleFreeCourseList.php new file mode 100644 index 00000000..a91174a4 --- /dev/null +++ b/app/Caches/IndexSimpleFreeCourseList.php @@ -0,0 +1,70 @@ +lifetime; + } + + public function getKey($id = null) + { + return 'index_simple_free_course_list'; + } + + public function getContent($id = null) + { + $limit = 8; + + $courses = $this->findCourses($limit); + + if ($courses->count() == 0) { + return []; + } + + $result = []; + + foreach ($courses as $course) { + $result[] = [ + 'id' => $course->id, + 'title' => $course->title, + 'cover' => $course->cover, + 'market_price' => $course->market_price, + 'vip_price' => $course->vip_price, + 'model' => $course->model, + 'level' => $course->level, + 'user_count' => $course->user_count, + 'lesson_count' => $course->lesson_count, + ]; + } + + return $result; + } + + /** + * @param int $limit + * @return ResultsetInterface|Resultset|CourseModel[] + */ + protected function findCourses($limit = 8) + { + return CourseModel::query() + ->where('published = 1') + ->andWhere('market_price = 0') + ->orderBy('score DESC') + ->limit($limit) + ->execute(); + } + +} diff --git a/app/Caches/IndexSimpleNewCourseList.php b/app/Caches/IndexSimpleNewCourseList.php new file mode 100644 index 00000000..4d9dcd89 --- /dev/null +++ b/app/Caches/IndexSimpleNewCourseList.php @@ -0,0 +1,69 @@ +lifetime; + } + + public function getKey($id = null) + { + return 'index_simple_new_course_list'; + } + + public function getContent($id = null) + { + $limit = 8; + + $courses = $this->findCourses($limit); + + if ($courses->count() == 0) { + return []; + } + + $result = []; + + foreach ($courses as $course) { + $result[] = [ + 'id' => $course->id, + 'title' => $course->title, + 'cover' => $course->cover, + 'market_price' => $course->market_price, + 'vip_price' => $course->vip_price, + 'model' => $course->model, + 'level' => $course->level, + 'user_count' => $course->user_count, + 'lesson_count' => $course->lesson_count, + ]; + } + + return $result; + } + + /** + * @param int $limit + * @return ResultsetInterface|Resultset|CourseModel[] + */ + protected function findCourses($limit = 8) + { + return CourseModel::query() + ->where('published = 1') + ->orderBy('id DESC') + ->limit($limit) + ->execute(); + } + +} diff --git a/app/Caches/IndexSimpleVipCourseList.php b/app/Caches/IndexSimpleVipCourseList.php new file mode 100644 index 00000000..bfb10e59 --- /dev/null +++ b/app/Caches/IndexSimpleVipCourseList.php @@ -0,0 +1,70 @@ +lifetime; + } + + public function getKey($id = null) + { + return 'index_simple_vip_course_list'; + } + + public function getContent($id = null) + { + $limit = 8; + + $courses = $this->findCourses($limit); + + if ($courses->count() == 0) { + return []; + } + + $result = []; + + foreach ($courses as $course) { + $result[] = [ + 'id' => $course->id, + 'title' => $course->title, + 'cover' => $course->cover, + 'market_price' => $course->market_price, + 'vip_price' => $course->vip_price, + 'model' => $course->model, + 'level' => $course->level, + 'user_count' => $course->user_count, + 'lesson_count' => $course->lesson_count, + ]; + } + + return $result; + } + + /** + * @param int $limit + * @return ResultsetInterface|Resultset|CourseModel[] + */ + protected function findCourses($limit = 8) + { + return CourseModel::query() + ->where('published = 1') + ->andWhere('vip_price >= 0') + ->orderBy('score DESC') + ->limit($limit) + ->execute(); + } + +} diff --git a/app/Caches/IndexSlideList.php b/app/Caches/IndexSlideList.php new file mode 100644 index 00000000..72899070 --- /dev/null +++ b/app/Caches/IndexSlideList.php @@ -0,0 +1,71 @@ +lifetime; + } + + public function getKey($id = null) + { + return 'index_slide_list'; + } + + public function getContent($id = null) + { + $limit = 5; + + $slides = $this->findSlides($limit); + + if ($slides->count() == 0) { + return []; + } + + return $this->handleContent($slides); + } + + /** + * @param SlideModel[] $slides + * @return array + */ + protected function handleContent($slides) + { + $result = []; + + foreach ($slides as $slide) { + $result[] = [ + 'id' => $slide->id, + 'title' => $slide->title, + 'cover' => $slide->cover, + 'target' => $slide->target, + 'content' => $slide->content, + ]; + } + + return $result; + } + + /** + * @param int $limit + * @return ResultsetInterface|Resultset|SlideModel[] + */ + public function findSlides($limit = 5) + { + return SlideModel::query() + ->where('published = 1') + ->orderBy('priority ASC') + ->limit($limit) + ->execute(); + } + +} diff --git a/app/Caches/IndexVipCourseList.php b/app/Caches/IndexVipCourseList.php index ab869db0..36fe1d0a 100644 --- a/app/Caches/IndexVipCourseList.php +++ b/app/Caches/IndexVipCourseList.php @@ -30,7 +30,7 @@ class IndexVipCourseList extends Cache { $categoryLimit = 5; - $courseLimit = 10; + $courseLimit = 8; $categories = $this->findCategories($categoryLimit); @@ -100,7 +100,7 @@ class IndexVipCourseList extends Cache * @param int $limit * @return ResultsetInterface|Resultset|CourseModel[] */ - protected function findCategoryCourses($categoryId, $limit = 10) + protected function findCategoryCourses($categoryId, $limit = 8) { $categoryService = new CategoryService(); diff --git a/app/Console/Tasks/CleanLogTask.php b/app/Console/Tasks/CleanLogTask.php index 4e171edb..2b242985 100644 --- a/app/Console/Tasks/CleanLogTask.php +++ b/app/Console/Tasks/CleanLogTask.php @@ -2,8 +2,6 @@ namespace App\Console\Tasks; -use Phalcon\Cli\Task; - class CleanLogTask extends Task { @@ -15,8 +13,8 @@ class CleanLogTask extends Task $this->cleanSqlLog(); $this->cleanListenerLog(); $this->cleanCaptchaLog(); - $this->cleanMailerLog(); - $this->cleanSmserLog(); + $this->cleanMailLog(); + $this->cleanSmsLog(); $this->cleanVodLog(); $this->cleanLiveLog(); $this->cleanStorageLog(); @@ -101,17 +99,17 @@ class CleanLogTask extends Task /** * 清理短信服务日志 */ - protected function cleanSmserLog() + protected function cleanSmsLog() { - $this->cleanLog('smser', 7); + $this->cleanLog('sms', 7); } /** * 清理邮件服务日志 */ - protected function cleanMailerLog() + protected function cleanMailLog() { - $this->cleanLog('mailer', 7); + $this->cleanLog('mail', 7); } /** @@ -165,9 +163,9 @@ class CleanLogTask extends Task if (strtotime($today) - strtotime($date) >= $keepDays * 86400) { $deleted = unlink($file); if ($deleted) { - echo "Delete {$file} success" . PHP_EOL; + echo "delete {$file} success" . PHP_EOL; } else { - echo "Delete {$file} failed" . PHP_EOL; + echo "delete {$file} failed" . PHP_EOL; } } } diff --git a/app/Console/Tasks/CleanSessionTask.php b/app/Console/Tasks/CleanSessionTask.php index 2be57e51..fb27ddef 100644 --- a/app/Console/Tasks/CleanSessionTask.php +++ b/app/Console/Tasks/CleanSessionTask.php @@ -2,20 +2,14 @@ namespace App\Console\Tasks; -use App\Library\Cache\Backend\Redis as RedisCache; -use Phalcon\Cli\Task; -use Phalcon\Config; - class CleanSessionTask extends Task { public function mainAction() { $config = $this->getConfig(); - $cache = $this->getCache(); - - $redis = $cache->getRedis(); + $redis = $this->getRedis(); $redis->select($config->path('session.db')); @@ -47,24 +41,4 @@ class CleanSessionTask extends Task return $cache->queryKeys('_PHCR', $limit); } - protected function getConfig() - { - /** - * @var Config $config - */ - $config = $this->getDI()->get('config'); - - return $config; - } - - protected function getCache() - { - /** - * @var RedisCache $cache - */ - $cache = $this->getDI()->get('cache'); - - return $cache; - } - } diff --git a/app/Console/Tasks/CloseOrderTask.php b/app/Console/Tasks/CloseOrderTask.php index b6818ba7..713d225c 100644 --- a/app/Console/Tasks/CloseOrderTask.php +++ b/app/Console/Tasks/CloseOrderTask.php @@ -3,7 +3,6 @@ namespace App\Console\Tasks; use App\Models\Order as OrderModel; -use Phalcon\Cli\Task; use Phalcon\Mvc\Model\Resultset; use Phalcon\Mvc\Model\ResultsetInterface; diff --git a/app/Console/Tasks/CloseTradeTask.php b/app/Console/Tasks/CloseTradeTask.php index 28665b6e..3918d40c 100644 --- a/app/Console/Tasks/CloseTradeTask.php +++ b/app/Console/Tasks/CloseTradeTask.php @@ -5,7 +5,6 @@ namespace App\Console\Tasks; use App\Models\Trade as TradeModel; use App\Services\Pay\Alipay as AlipayService; use App\Services\Pay\Wxpay as WxpayService; -use Phalcon\Cli\Task; use Phalcon\Mvc\Model\Resultset; use Phalcon\Mvc\Model\ResultsetInterface; diff --git a/app/Console/Tasks/CourseIndexTask.php b/app/Console/Tasks/CourseIndexTask.php index 050e50b5..23a148cc 100644 --- a/app/Console/Tasks/CourseIndexTask.php +++ b/app/Console/Tasks/CourseIndexTask.php @@ -5,7 +5,6 @@ namespace App\Console\Tasks; use App\Models\Course as CourseModel; use App\Services\Search\CourseDocument; use App\Services\Search\CourseSearcher; -use Phalcon\Cli\Task; use Phalcon\Mvc\Model\Resultset; use Phalcon\Mvc\Model\ResultsetInterface; @@ -24,7 +23,7 @@ class CourseIndexTask extends Task $query = $params[0] ?? null; if (!$query) { - exit("please special a query word" . PHP_EOL); + exit('please special a query word' . PHP_EOL); } $result = $this->searchCourses($query); @@ -61,11 +60,11 @@ class CourseIndexTask extends Task $index = $handler->getXS()->getIndex(); - echo "start clean index" . PHP_EOL; + echo 'start clean index' . PHP_EOL; $index->clean(); - echo "end clean index" . PHP_EOL; + echo 'end clean index' . PHP_EOL; } /** @@ -75,9 +74,7 @@ class CourseIndexTask extends Task { $courses = $this->findCourses(); - if ($courses->count() == 0) { - return; - } + if ($courses->count() == 0) return; $handler = new CourseSearcher(); @@ -85,7 +82,7 @@ class CourseIndexTask extends Task $index = $handler->getXS()->getIndex(); - echo "start rebuild index" . PHP_EOL; + echo 'start rebuild index' . PHP_EOL; $index->beginRebuild(); @@ -96,7 +93,7 @@ class CourseIndexTask extends Task $index->endRebuild(); - echo "end rebuild index" . PHP_EOL; + echo 'end rebuild index' . PHP_EOL; } /** diff --git a/app/Console/Tasks/DeliverTask.php b/app/Console/Tasks/DeliverTask.php index 5c39371d..9b9ddebd 100644 --- a/app/Console/Tasks/DeliverTask.php +++ b/app/Console/Tasks/DeliverTask.php @@ -9,7 +9,7 @@ use App\Models\Task as TaskModel; use App\Models\Trade as TradeModel; use App\Repos\Order as OrderRepo; use App\Repos\User as UserRepo; -use App\Services\Smser\Order as OrderSmser; +use App\Services\Sms\Order as OrderSms; use Phalcon\Mvc\Model; use Phalcon\Mvc\Model\Resultset; use Phalcon\Mvc\Model\ResultsetInterface; @@ -74,7 +74,6 @@ class DeliverTask extends Task $task->update(); $logger->info('Order Process Exception ' . kg_json_encode([ - 'line' => $e->getLine(), 'code' => $e->getCode(), 'message' => $e->getMessage(), 'task' => $task->toArray(), @@ -165,9 +164,9 @@ class DeliverTask extends Task protected function handleOrderNotice(OrderModel $order) { - $smser = new OrderSmser(); + $sms = new OrderSms(); - $smser->handle($order); + $sms->handle($order); } protected function handleOrderRefund(OrderModel $order) diff --git a/app/Console/Tasks/GroupIndexTask.php b/app/Console/Tasks/GroupIndexTask.php index 2cd79419..4e9c2918 100644 --- a/app/Console/Tasks/GroupIndexTask.php +++ b/app/Console/Tasks/GroupIndexTask.php @@ -5,7 +5,6 @@ namespace App\Console\Tasks; use App\Models\ImGroup as GroupModel; use App\Services\Search\GroupDocument; use App\Services\Search\GroupSearcher; -use Phalcon\Cli\Task; use Phalcon\Mvc\Model\Resultset; use Phalcon\Mvc\Model\ResultsetInterface; @@ -24,7 +23,7 @@ class GroupIndexTask extends Task $query = $params[0] ?? null; if (!$query) { - exit("please special a query word" . PHP_EOL); + exit('please special a query word' . PHP_EOL); } $result = $this->searchGroups($query); @@ -61,11 +60,11 @@ class GroupIndexTask extends Task $index = $handler->getXS()->getIndex(); - echo "start clean index" . PHP_EOL; + echo 'start clean index' . PHP_EOL; $index->clean(); - echo "end clean index" . PHP_EOL; + echo 'end clean index' . PHP_EOL; } /** @@ -75,9 +74,7 @@ class GroupIndexTask extends Task { $groups = $this->findGroups(); - if ($groups->count() == 0) { - return; - } + if ($groups->count() == 0) return; $handler = new GroupSearcher(); @@ -85,7 +82,7 @@ class GroupIndexTask extends Task $index = $handler->getXS()->getIndex(); - echo "start rebuild index" . PHP_EOL; + echo 'start rebuild index' . PHP_EOL; $index->beginRebuild(); @@ -96,7 +93,7 @@ class GroupIndexTask extends Task $index->endRebuild(); - echo "end rebuild index" . PHP_EOL; + echo 'end rebuild index' . PHP_EOL; } /** diff --git a/app/Console/Tasks/LiveNotifyTask.php b/app/Console/Tasks/LiveNotifyTask.php index b2f792c4..a36c3cf7 100644 --- a/app/Console/Tasks/LiveNotifyTask.php +++ b/app/Console/Tasks/LiveNotifyTask.php @@ -2,54 +2,42 @@ namespace App\Console\Tasks; -use App\Library\Cache\Backend\Redis as RedisCache; use App\Models\CourseUser as CourseUserModel; use App\Repos\Chapter as ChapterRepo; use App\Services\LiveNotify as LiveNotifyService; -use App\Services\Smser\Live as LiveSmser; -use Phalcon\Cli\Task; +use App\Services\Sms\Live as LiveSms; class LiveNotifyTask extends Task { - /** - * @var RedisCache - */ - protected $cache; - - /** - * @var \Redis - */ - protected $redis; - public function mainAction() { - $this->cache = $this->getDI()->get('cache'); + $cache = $this->getCache(); - $this->redis = $this->cache->getRedis(); + $redis = $this->getRedis(); $service = new LiveNotifyService(); $key = $service->getNotifyKey(); - $chapterIds = $this->redis->sMembers($key); + $chapterIds = $redis->sMembers($key); if (!$chapterIds) return; $sentKey = $service->getSentNotifyKey(); - $sentChapterIds = $this->redis->sMembers($sentKey); + $sentChapterIds = $redis->sMembers($sentKey); foreach ($chapterIds as $chapterId) { if (!in_array($chapterId, $sentChapterIds)) { $this->sendNotification($chapterId); } else { - $this->redis->sAdd($sentKey, $chapterId); + $redis->sAdd($sentKey, $chapterId); } } - if ($this->redis->sCard($sentKey) == 1) { - $this->redis->expire($sentKey, 86400); + if ($redis->sCard($sentKey) == 1) { + $redis->expire($sentKey, 86400); } } @@ -65,18 +53,15 @@ class LiveNotifyTask extends Task if (!$targetUserIds) return; - $smser = new LiveSmser(); + $sms = new LiveSms(); foreach ($targetUserIds as $userId) { - $smser->handle($chapterId, $userId, $chapterLive->start_time); + $sms->handle($chapterId, $userId, $chapterLive->start_time); } } protected function findTargetUserIds($courseId) { - /** - * 只给付费和vip用户发通知 - */ $sourceTypes = [ CourseUserModel::SOURCE_CHARGE, CourseUserModel::SOURCE_VIP, @@ -88,11 +73,11 @@ class LiveNotifyTask extends Task ->inWhere('source_type', $sourceTypes) ->execute(); - if ($rows->count() > 0) { - return kg_array_column($rows->toArray(), 'user_id'); + if ($rows->count() == 0) { + return []; } - return []; + return kg_array_column($rows->toArray(), 'user_id'); } } diff --git a/app/Console/Tasks/MaintainTask.php b/app/Console/Tasks/MaintainTask.php index f8b1d1e6..4b526448 100644 --- a/app/Console/Tasks/MaintainTask.php +++ b/app/Console/Tasks/MaintainTask.php @@ -2,149 +2,31 @@ namespace App\Console\Tasks; -use App\Caches\Setting as SettingCache; -use App\Library\Cache\Backend\Redis as RedisCache; -use App\Models\Setting as SettingModel; -use Phalcon\Cli\Task; -use Phalcon\Config; +use App\Caches\IndexFreeCourseList as IndexFreeCourseListCache; +use App\Caches\IndexNewCourseList as IndexNewCourseListCache; +use App\Caches\IndexVipCourseList as IndexVipCourseListCache; class MaintainTask extends Task { - public function mainAction() + public function rebuildIndexCourseCacheAction($params) { - $this->resetSettingAction(); - $this->resetAnnotationAction(); - $this->resetMetadataAction(); - $this->resetVoltAction(); - } + $section = $params[0] ?? null; - /** - * 重置设置 - * - * @command: php console.php maintain reset_setting - */ - public function resetSettingAction() - { - echo "start reset setting..." . PHP_EOL; - - $rows = SettingModel::query()->columns('section')->distinct(true)->execute(); - - foreach ($rows as $row) { - $cache = new SettingCache(); - $cache->rebuild($row->section); + if (!$section || $section == 'new_course') { + $cache = new IndexNewCourseListCache(); + $cache->rebuild(); } - echo "end reset setting..." . PHP_EOL; - } - - /** - * 重置注解 - * - * @command: php console.php maintain reset_annotation - */ - public function resetAnnotationAction() - { - $config = $this->getConfig(); - $cache = $this->getCache(); - $redis = $cache->getRedis(); - - $dbIndex = $config->path('annotation.db'); - $statsKey = $config->path('annotation.statsKey'); - - $redis->select($dbIndex); - - $keys = $redis->sMembers($statsKey); - - echo "start reset annotation..." . PHP_EOL; - - if (count($keys) > 0) { - - $keys = $this->handlePhKeys($keys); - - $redis->del(...$keys); - $redis->del($statsKey); + if (!$section || $section == 'free_course') { + $cache = new IndexFreeCourseListCache(); + $cache->rebuild(); } - echo "end reset annotation..." . PHP_EOL; - } - - /** - * 重置元数据 - * - * @command: php console.php maintain reset_metadata - */ - public function resetMetadataAction() - { - $config = $this->getConfig(); - $cache = $this->getCache(); - $redis = $cache->getRedis(); - - $dbIndex = $config->path('metadata.db'); - $statsKey = $config->path('metadata.statsKey'); - - $redis->select($dbIndex); - - $keys = $redis->sMembers($statsKey); - - echo "start reset metadata..." . PHP_EOL; - - if (count($keys) > 0) { - - $keys = $this->handlePhKeys($keys); - - $redis->del(...$keys); - $redis->del($statsKey); + if (!$section || $section == 'vip_course') { + $cache = new IndexVipCourseListCache(); + $cache->rebuild(); } - - echo "start reset metadata..." . PHP_EOL; - } - - /** - * 重置模板 - * - * @command: php console.php maintain reset_volt - */ - public function resetVoltAction() - { - echo "start reset volt..." . PHP_EOL; - - $dir = cache_path('volt'); - - foreach (scandir($dir) as $file) { - if (strpos($file, '.php')) { - unlink($dir . '/' . $file); - } - } - - echo "end reset volt..." . PHP_EOL; - } - - protected function getConfig() - { - /** - * @var Config $config - */ - $config = $this->getDI()->get('config'); - - return $config; - } - - protected function getCache() - { - /** - * @var RedisCache $cache - */ - $cache = $this->getDI()->get('cache'); - - return $cache; - } - - protected function handlePhKeys($keys) - { - return array_map(function ($key) { - return "_PHCR{$key}"; - }, $keys); } } diff --git a/app/Console/Tasks/RefundTask.php b/app/Console/Tasks/RefundTask.php index 0af0a715..0edf1a67 100644 --- a/app/Console/Tasks/RefundTask.php +++ b/app/Console/Tasks/RefundTask.php @@ -13,7 +13,7 @@ use App\Repos\Trade as TradeRepo; use App\Repos\User as UserRepo; use App\Services\Pay\Alipay as AlipayService; use App\Services\Pay\Wxpay as WxpayService; -use App\Services\Smser\Refund as RefundSmser; +use App\Services\Sms\Refund as RefundSms; use Phalcon\Mvc\Model\Resultset; use Phalcon\Mvc\Model\ResultsetInterface; @@ -111,7 +111,6 @@ class RefundTask extends Task $task->update(); $logger->info('Refund Task Exception ' . kg_json_encode([ - 'line' => $e->getLine(), 'code' => $e->getCode(), 'message' => $e->getMessage(), 'task' => $task->toArray(), @@ -284,9 +283,9 @@ class RefundTask extends Task */ protected function handleRefundNotice(RefundModel $refund) { - $smser = new RefundSmser(); + $sms = new RefundSms(); - $smser->handle($refund); + $sms->handle($refund); } /** diff --git a/app/Console/Tasks/RevokeVipTask.php b/app/Console/Tasks/RevokeVipTask.php index 56a11e1d..58380c4b 100644 --- a/app/Console/Tasks/RevokeVipTask.php +++ b/app/Console/Tasks/RevokeVipTask.php @@ -3,7 +3,6 @@ namespace App\Console\Tasks; use App\Models\User as UserModel; -use Phalcon\Cli\Task; use Phalcon\Mvc\Model\Resultset; use Phalcon\Mvc\Model\ResultsetInterface; diff --git a/app/Console/Tasks/SiteMapTask.php b/app/Console/Tasks/SiteMapTask.php index b698b533..d78ce46d 100644 --- a/app/Console/Tasks/SiteMapTask.php +++ b/app/Console/Tasks/SiteMapTask.php @@ -49,9 +49,9 @@ class SiteMapTask extends Task { $service = new AppService(); - $settings = $service->getSectionSettings('site'); + $settings = $service->getSettings('site'); - return $settings['base_url'] ?? ''; + return $settings['url'] ?? ''; } protected function addIndex() @@ -62,7 +62,7 @@ class SiteMapTask extends Task protected function addCourses() { /** - * @var Resultset $courses + * @var Resultset|CourseModel[] $courses */ $courses = CourseModel::query()->where('published = 1')->execute(); diff --git a/app/Console/Tasks/SyncCourseIndexTask.php b/app/Console/Tasks/SyncCourseIndexTask.php index 8911734d..1578f036 100644 --- a/app/Console/Tasks/SyncCourseIndexTask.php +++ b/app/Console/Tasks/SyncCourseIndexTask.php @@ -2,39 +2,23 @@ namespace App\Console\Tasks; -use App\Library\Cache\Backend\Redis as RedisCache; use App\Repos\Course as CourseRepo; use App\Services\Search\CourseDocument; use App\Services\Search\CourseSearcher; -use App\Services\Syncer\CourseIndex as CourseIndexSyncer; +use App\Services\Sync\CourseIndex as CourseIndexSync; class SyncCourseIndexTask extends Task { - /** - * @var RedisCache - */ - protected $cache; - - /** - * @var \Redis - */ - protected $redis; - public function mainAction() { - $this->cache = $this->getDI()->get('cache'); + $cache = $this->getCache(); - $this->redis = $this->cache->getRedis(); + $redis = $this->getRedis(); - $this->rebuild(); - } - - protected function rebuild() - { $key = $this->getSyncKey(); - $courseIds = $this->redis->sRandMember($key, 1000); + $courseIds = $redis->sRandMember($key, 1000); if (!$courseIds) return; @@ -42,9 +26,7 @@ class SyncCourseIndexTask extends Task $courses = $courseRepo->findByIds($courseIds); - if ($courses->count() == 0) { - return; - } + if ($courses->count() == 0) return; $document = new CourseDocument(); @@ -67,14 +49,14 @@ class SyncCourseIndexTask extends Task $index->closeBuffer(); - $this->redis->sRem($key, ...$courseIds); + $redis->sRem($key, ...$courseIds); } protected function getSyncKey() { - $syncer = new CourseIndexSyncer(); + $sync = new CourseIndexSync(); - return $syncer->getSyncKey(); + return $sync->getSyncKey(); } } diff --git a/app/Console/Tasks/SyncGroupIndexTask.php b/app/Console/Tasks/SyncGroupIndexTask.php index ebb81e2f..d48223de 100644 --- a/app/Console/Tasks/SyncGroupIndexTask.php +++ b/app/Console/Tasks/SyncGroupIndexTask.php @@ -2,39 +2,23 @@ namespace App\Console\Tasks; -use App\Library\Cache\Backend\Redis as RedisCache; use App\Repos\ImGroup as GroupRepo; use App\Services\Search\GroupDocument; use App\Services\Search\GroupSearcher; -use App\Services\Syncer\GroupIndex as GroupIndexSyncer; +use App\Services\Sync\GroupIndex as GroupIndexSync; class SyncGroupIndexTask extends Task { - /** - * @var RedisCache - */ - protected $cache; - - /** - * @var \Redis - */ - protected $redis; - public function mainAction() { - $this->cache = $this->getDI()->get('cache'); + $cache = $this->getCache(); - $this->redis = $this->cache->getRedis(); + $redis = $this->getRedis(); - $this->rebuild(); - } - - protected function rebuild() - { $key = $this->getSyncKey(); - $groupIds = $this->redis->sRandMember($key, 1000); + $groupIds = $redis->sRandMember($key, 1000); if (!$groupIds) return; @@ -42,9 +26,7 @@ class SyncGroupIndexTask extends Task $groups = $groupRepo->findByIds($groupIds); - if ($groups->count() == 0) { - return; - } + if ($groups->count() == 0) return; $document = new GroupDocument(); @@ -67,14 +49,14 @@ class SyncGroupIndexTask extends Task $index->closeBuffer(); - $this->redis->sRem($key, ...$groupIds); + $redis->sRem($key, ...$groupIds); } protected function getSyncKey() { - $syncer = new GroupIndexSyncer(); + $sync = new GroupIndexSync(); - return $syncer->getSyncKey(); + return $sync->getSyncKey(); } } diff --git a/app/Console/Tasks/SyncLearningTask.php b/app/Console/Tasks/SyncLearningTask.php index d44006c5..8adbc36e 100644 --- a/app/Console/Tasks/SyncLearningTask.php +++ b/app/Console/Tasks/SyncLearningTask.php @@ -2,7 +2,6 @@ namespace App\Console\Tasks; -use App\Library\Cache\Backend\Redis as RedisCache; use App\Models\Course as CourseModel; use App\Models\Learning as LearningModel; use App\Repos\Chapter as ChapterRepo; @@ -10,43 +9,32 @@ use App\Repos\ChapterUser as ChapterUserRepo; use App\Repos\Course as CourseRepo; use App\Repos\CourseUser as CourseUserRepo; use App\Repos\Learning as LearningRepo; -use App\Services\Syncer\Learning as LearningSyncer; -use Phalcon\Cli\Task; +use App\Services\Sync\Learning as LearningSync; class SyncLearningTask extends Task { - /** - * @var RedisCache - */ - protected $cache; - - /** - * @var \Redis - */ - protected $redis; - public function mainAction() { - $this->cache = $this->getDI()->get('cache'); + $cache = $this->getCache(); - $this->redis = $this->cache->getRedis(); + $redis = $this->getRedis(); - $syncer = new LearningSyncer(); + $sync = new LearningSync(); - $syncKey = $syncer->getSyncKey(); + $syncKey = $sync->getSyncKey(); - $requestIds = $this->redis->sMembers($syncKey); + $requestIds = $redis->sMembers($syncKey); if (!$requestIds) return; foreach ($requestIds as $requestId) { - $itemKey = $syncer->getItemKey($requestId); + $itemKey = $sync->getItemKey($requestId); $this->handleLearning($itemKey); - $this->redis->sRem($syncKey, $requestId); + $redis->sRem($syncKey, $requestId); } } @@ -153,15 +141,11 @@ class SyncLearningTask extends Task $courseLessons = $courseRepo->findLessons($learning->course_id); - if ($courseLessons->count() == 0) { - return; - } + if ($courseLessons->count() == 0) return; $userLearnings = $courseRepo->findUserLearnings($learning->course_id, $learning->user_id, $learning->plan_id); - if ($userLearnings->count() == 0) { - return; - } + if ($userLearnings->count() == 0) return; $consumedUserLearnings = []; @@ -171,9 +155,7 @@ class SyncLearningTask extends Task } } - if (count($consumedUserLearnings) == 0) { - return; - } + if (count($consumedUserLearnings) == 0) return; $duration = 0; diff --git a/app/Console/Tasks/SyncUserIndexTask.php b/app/Console/Tasks/SyncUserIndexTask.php index bd7c8aea..7e55f3da 100644 --- a/app/Console/Tasks/SyncUserIndexTask.php +++ b/app/Console/Tasks/SyncUserIndexTask.php @@ -2,39 +2,23 @@ namespace App\Console\Tasks; -use App\Library\Cache\Backend\Redis as RedisCache; use App\Repos\User as UserRepo; use App\Services\Search\UserDocument; use App\Services\Search\UserSearcher; -use App\Services\Syncer\UserIndex as UserIndexSyncer; +use App\Services\Sync\UserIndex as UserIndexSync; class SyncUserIndexTask extends Task { - /** - * @var RedisCache - */ - protected $cache; - - /** - * @var \Redis - */ - protected $redis; - public function mainAction() { - $this->cache = $this->getDI()->get('cache'); + $cache = $this->getCache(); - $this->redis = $this->cache->getRedis(); + $redis = $this->getRedis(); - $this->rebuild(); - } - - protected function rebuild() - { $key = $this->getSyncKey(); - $userIds = $this->redis->sRandMember($key, 1000); + $userIds = $redis->sRandMember($key, 1000); if (!$userIds) return; @@ -42,9 +26,7 @@ class SyncUserIndexTask extends Task $users = $userRepo->findByIds($userIds); - if ($users->count() == 0) { - return; - } + if ($users->count() == 0) return; $document = new UserDocument(); @@ -67,14 +49,14 @@ class SyncUserIndexTask extends Task $index->closeBuffer(); - $this->redis->sRem($key, ...$userIds); + $redis->sRem($key, ...$userIds); } protected function getSyncKey() { - $syncer = new UserIndexSyncer(); + $sync = new UserIndexSync(); - return $syncer->getSyncKey(); + return $sync->getSyncKey(); } } diff --git a/app/Console/Tasks/Task.php b/app/Console/Tasks/Task.php index dc875cd1..44f9e1d4 100644 --- a/app/Console/Tasks/Task.php +++ b/app/Console/Tasks/Task.php @@ -2,14 +2,46 @@ namespace App\Console\Tasks; -use App\Library\Logger; +use App\Library\Cache\Backend\Redis as RedisCache; +use App\Library\Logger as AppLogger; +use Phalcon\Config as PhConfig; +use Phalcon\Logger\Adapter\File as PhLogger; + class Task extends \Phalcon\Cli\Task { + /** + * @return PhConfig + */ + public function getConfig() + { + return $this->getDI()->getShared('config'); + } + + /** + * @return RedisCache + */ + public function getCache() + { + return $this->getDI()->getShared('cache'); + } + + /** + * @return \Redis + */ + public function getRedis() + { + return $this->getCache()->getRedis(); + } + + /** + * @param null $channel + * @return PhLogger + */ public function getLogger($channel = null) { - $logger = new Logger(); + $logger = new AppLogger(); return $logger->getInstance($channel); } diff --git a/app/Console/Tasks/UnlockUserTask.php b/app/Console/Tasks/UnlockUserTask.php index 0f21f6a0..d499c8f8 100644 --- a/app/Console/Tasks/UnlockUserTask.php +++ b/app/Console/Tasks/UnlockUserTask.php @@ -3,7 +3,6 @@ namespace App\Console\Tasks; use App\Models\User as UserModel; -use Phalcon\Cli\Task; use Phalcon\Mvc\Model\Resultset; use Phalcon\Mvc\Model\ResultsetInterface; @@ -14,13 +13,10 @@ class UnlockUserTask extends Task { $users = $this->findUsers(); - if ($users->count() == 0) { - return; - } + if ($users->count() == 0) return; foreach ($users as $user) { - $user->locked = 0; - $user->update(); + $user->update(['locked' => 0]); } } diff --git a/app/Console/Tasks/UpgradeTask.php b/app/Console/Tasks/UpgradeTask.php new file mode 100644 index 00000000..a8600332 --- /dev/null +++ b/app/Console/Tasks/UpgradeTask.php @@ -0,0 +1,127 @@ +resetSettingAction(); + $this->resetAnnotationAction(); + $this->resetMetadataAction(); + $this->resetVoltAction(); + } + + /** + * 重置系统设置 + * + * @command: php console.php upgrade reset_setting + */ + public function resetSettingAction() + { + echo "start reset setting..." . PHP_EOL; + + $rows = SettingModel::query()->columns('section')->distinct(true)->execute(); + + foreach ($rows as $row) { + $cache = new SettingCache(); + $cache->rebuild($row->section); + } + + echo "end reset setting..." . PHP_EOL; + } + + /** + * 重置注解 + * + * @command: php console.php upgrade reset_annotation + */ + public function resetAnnotationAction() + { + $config = $this->getConfig(); + $cache = $this->getCache(); + $redis = $this->getRedis(); + + $dbIndex = $config->path('annotation.db'); + $statsKey = $config->path('annotation.statsKey'); + + $redis->select($dbIndex); + + $keys = $redis->sMembers($statsKey); + + echo "start reset annotation..." . PHP_EOL; + + if (count($keys) > 0) { + + $keys = $this->handlePhKeys($keys); + + $redis->del(...$keys); + $redis->del($statsKey); + } + + echo "end reset annotation..." . PHP_EOL; + } + + /** + * 重置元数据 + * + * @command: php console.php upgrade reset_metadata + */ + public function resetMetadataAction() + { + $config = $this->getConfig(); + $cache = $this->getCache(); + $redis = $this->getRedis(); + + $dbIndex = $config->path('metadata.db'); + $statsKey = $config->path('metadata.statsKey'); + + $redis->select($dbIndex); + + $keys = $redis->sMembers($statsKey); + + echo "start reset metadata..." . PHP_EOL; + + if (count($keys) > 0) { + + $keys = $this->handlePhKeys($keys); + + $redis->del(...$keys); + $redis->del($statsKey); + } + + echo "start reset metadata..." . PHP_EOL; + } + + /** + * 重置模板 + * + * @command: php console.php upgrade reset_volt + */ + public function resetVoltAction() + { + echo "start reset volt..." . PHP_EOL; + + $dir = cache_path('volt'); + + foreach (scandir($dir) as $file) { + if (strpos($file, '.php')) { + unlink($dir . '/' . $file); + } + } + + echo "end reset volt..." . PHP_EOL; + } + + protected function handlePhKeys($keys) + { + return array_map(function ($key) { + return "_PHCR{$key}"; + }, $keys); + } + +} diff --git a/app/Console/Tasks/UserIndexTask.php b/app/Console/Tasks/UserIndexTask.php index 3ec4ce51..6ce9c7d6 100644 --- a/app/Console/Tasks/UserIndexTask.php +++ b/app/Console/Tasks/UserIndexTask.php @@ -5,7 +5,6 @@ namespace App\Console\Tasks; use App\Models\User as UserModel; use App\Services\Search\UserDocument; use App\Services\Search\UserSearcher; -use Phalcon\Cli\Task; use Phalcon\Mvc\Model\Resultset; use Phalcon\Mvc\Model\ResultsetInterface; @@ -24,7 +23,7 @@ class UserIndexTask extends Task $query = $params[0] ?? null; if (!$query) { - exit("please special a query word" . PHP_EOL); + exit('please special a query word' . PHP_EOL); } $result = $this->searchUsers($query); @@ -61,11 +60,11 @@ class UserIndexTask extends Task $index = $handler->getXS()->getIndex(); - echo "start clean index" . PHP_EOL; + echo 'start clean index' . PHP_EOL; $index->clean(); - echo "end clean index" . PHP_EOL; + echo 'end clean index' . PHP_EOL; } /** @@ -75,9 +74,7 @@ class UserIndexTask extends Task { $users = $this->findUsers(); - if ($users->count() == 0) { - return; - } + if ($users->count() == 0) return; $handler = new UserSearcher(); @@ -85,7 +82,7 @@ class UserIndexTask extends Task $index = $handler->getXS()->getIndex(); - echo "start rebuild index" . PHP_EOL; + echo 'start rebuild index' . PHP_EOL; $index->beginRebuild(); @@ -96,7 +93,7 @@ class UserIndexTask extends Task $index->endRebuild(); - echo "end rebuild index" . PHP_EOL; + echo 'end rebuild index' . PHP_EOL; } /** diff --git a/app/Console/Tasks/VodEventTask.php b/app/Console/Tasks/VodEventTask.php index 07795c5b..c51e0c1d 100644 --- a/app/Console/Tasks/VodEventTask.php +++ b/app/Console/Tasks/VodEventTask.php @@ -6,7 +6,6 @@ use App\Models\Chapter as ChapterModel; use App\Repos\Chapter as ChapterRepo; use App\Services\CourseStat as CourseStatService; use App\Services\Vod as VodService; -use Phalcon\Cli\Task; class VodEventTask extends Task { diff --git a/app/Http/Admin/Controllers/ChapterController.php b/app/Http/Admin/Controllers/ChapterController.php index bbef2879..6cfc8e7c 100644 --- a/app/Http/Admin/Controllers/ChapterController.php +++ b/app/Http/Admin/Controllers/ChapterController.php @@ -35,24 +35,24 @@ class ChapterController extends Controller */ public function addAction() { - $courseId = $this->request->getQuery('course_id'); - $parentId = $this->request->getQuery('parent_id'); - $type = $this->request->getQuery('type'); + $courseId = $this->request->getQuery('course_id', 'int'); + $parentId = $this->request->getQuery('parent_id', 'int'); + $type = $this->request->getQuery('type', 'string', 'chapter'); $courseService = new CourseService(); $course = $courseService->getCourse($courseId); $chapters = $courseService->getChapters($courseId); + $this->view->pick('chapter/add_chapter'); + + if ($type == 'lesson') { + $this->view->pick('chapter/add_lesson'); + } + $this->view->setVar('course', $course); $this->view->setVar('parent_id', $parentId); $this->view->setVar('chapters', $chapters); - - if ($type == 'chapter') { - $this->view->pick('chapter/add_chapter'); - } else { - $this->view->pick('chapter/add_lesson'); - } } /** @@ -89,11 +89,12 @@ class ChapterController extends Controller $chapter = $chapterService->getChapter($id); $course = $courseService->getCourse($chapter->course_id); - $this->view->setVar('chapter', $chapter); - $this->view->setVar('course', $course); + $this->view->pick('chapter/edit_chapter'); if ($chapter->parent_id > 0) { + $this->view->pick('chapter/edit_lesson'); + switch ($course->model) { case CourseModel::MODEL_VOD: $vod = $contentService->getChapterVod($chapter->id); @@ -110,12 +111,10 @@ class ChapterController extends Controller $this->view->setVar('read', $read); break; } - - $this->view->pick('chapter/edit_lesson'); - - } else { - $this->view->pick('chapter/edit_chapter'); } + + $this->view->setVar('chapter', $chapter); + $this->view->setVar('course', $course); } /** diff --git a/app/Http/Admin/Controllers/PublicController.php b/app/Http/Admin/Controllers/PublicController.php index 5e0a1ab4..e5b84bbc 100644 --- a/app/Http/Admin/Controllers/PublicController.php +++ b/app/Http/Admin/Controllers/PublicController.php @@ -43,7 +43,7 @@ class PublicController extends \Phalcon\Mvc\Controller */ public function ip2regionAction() { - $ip = $this->request->getQuery('ip', 'trim'); + $ip = $this->request->getQuery('ip', 'string'); $region = kg_ip2region($ip); diff --git a/app/Http/Admin/Controllers/SessionController.php b/app/Http/Admin/Controllers/SessionController.php index d868f531..3c67806f 100644 --- a/app/Http/Admin/Controllers/SessionController.php +++ b/app/Http/Admin/Controllers/SessionController.php @@ -48,7 +48,7 @@ class SessionController extends \Phalcon\Mvc\Controller $settingService = new SettingService(); - $captcha = $settingService->getSectionSettings('captcha'); + $captcha = $settingService->getSettings('captcha'); $this->view->pick('public/login'); $this->view->setVar('app_info', $appInfo); diff --git a/app/Http/Admin/Controllers/SettingController.php b/app/Http/Admin/Controllers/SettingController.php index 1531065b..820b0ac0 100644 --- a/app/Http/Admin/Controllers/SettingController.php +++ b/app/Http/Admin/Controllers/SettingController.php @@ -29,7 +29,7 @@ class SettingController extends Controller } else { - $site = $settingService->getSectionSettings($section); + $site = $settingService->getSettings($section); $site['url'] = $site['url'] ?: kg_site_url(); @@ -56,7 +56,7 @@ class SettingController extends Controller } else { - $secret = $settingService->getSectionSettings($section); + $secret = $settingService->getSettings($section); $this->view->setVar('secret', $secret); } @@ -81,7 +81,7 @@ class SettingController extends Controller } else { - $cos = $settingService->getSectionSettings($section); + $cos = $settingService->getSettings($section); $this->view->setVar('cos', $cos); } @@ -106,7 +106,7 @@ class SettingController extends Controller } else { - $vod = $settingService->getSectionSettings($section); + $vod = $settingService->getSettings($section); $this->view->setVar('vod', $vod); } @@ -121,7 +121,7 @@ class SettingController extends Controller if ($this->request->isPost()) { - $section = $this->request->getPost('section'); + $section = $this->request->getPost('section', 'string'); $data = $this->request->getPost(); @@ -150,7 +150,7 @@ class SettingController extends Controller if ($this->request->isPost()) { - $section = $this->request->getPost('section'); + $section = $this->request->getPost('section', 'string'); $data = $this->request->getPost(); @@ -169,11 +169,11 @@ class SettingController extends Controller } /** - * @Route("/smser", name="admin.setting.smser") + * @Route("/sms", name="admin.setting.sms") */ - public function smserAction() + public function smsAction() { - $section = 'smser'; + $section = 'sms'; $settingService = new SettingService(); @@ -181,24 +181,24 @@ class SettingController extends Controller $data = $this->request->getPost(); - $settingService->updateSmserSettings($section, $data); + $settingService->updateSmsSettings($section, $data); return $this->jsonSuccess(['msg' => '更新配置成功']); } else { - $smser = $settingService->getSectionSettings($section); + $sms = $settingService->getSettings($section); - $this->view->setVar('smser', $smser); + $this->view->setVar('sms', $sms); } } /** - * @Route("/mailer", name="admin.setting.mailer") + * @Route("/mail", name="admin.setting.mail") */ - public function mailerAction() + public function mailAction() { - $section = 'mailer'; + $section = 'mail'; $settingService = new SettingService(); @@ -212,9 +212,9 @@ class SettingController extends Controller } else { - $mailer = $settingService->getSectionSettings($section); + $mail = $settingService->getSettings($section); - $this->view->setVar('mailer', $mailer); + $this->view->setVar('mail', $mail); } } @@ -242,7 +242,7 @@ class SettingController extends Controller } else { - $captcha = $settingService->getSectionSettings($section); + $captcha = $settingService->getSettings($section); $this->view->setVar('captcha', $captcha); } @@ -257,7 +257,7 @@ class SettingController extends Controller if ($this->request->isPost()) { - $data = $this->request->getPost('vip'); + $data = $this->request->getPost('vip', 'string'); $settingService->updateVipSettings($data); @@ -280,7 +280,7 @@ class SettingController extends Controller if ($this->request->isPost()) { - $section = $this->request->getPost('section'); + $section = $this->request->getPost('section', 'string'); $data = $this->request->getPost(); @@ -290,8 +290,8 @@ class SettingController extends Controller } else { - $main = $settingService->getSectionSettings('im.main'); - $cs = $settingService->getSectionSettings('im.cs'); + $main = $settingService->getSettings('im.main'); + $cs = $settingService->getSettings('im.cs'); $this->view->setVar('main', $main); $this->view->setVar('cs', $cs); diff --git a/app/Http/Admin/Controllers/CarouselController.php b/app/Http/Admin/Controllers/SlideController.php similarity index 50% rename from app/Http/Admin/Controllers/CarouselController.php rename to app/Http/Admin/Controllers/SlideController.php index 2d2472b5..8369c875 100644 --- a/app/Http/Admin/Controllers/CarouselController.php +++ b/app/Http/Admin/Controllers/SlideController.php @@ -2,28 +2,28 @@ namespace App\Http\Admin\Controllers; -use App\Http\Admin\Services\Carousel as CarouselService; +use App\Http\Admin\Services\Slide as SlideService; /** - * @RoutePrefix("/admin/carousel") + * @RoutePrefix("/admin/slide") */ -class CarouselController extends Controller +class SlideController extends Controller { /** - * @Get("/list", name="admin.carousel.list") + * @Get("/list", name="admin.slide.list") */ public function listAction() { - $carouselService = new CarouselService(); + $slideService = new SlideService(); - $pager = $carouselService->getCarousels(); + $pager = $slideService->getSlides(); $this->view->setVar('pager', $pager); } /** - * @Get("/add", name="admin.carousel.add") + * @Get("/add", name="admin.slide.add") */ public function addAction() { @@ -31,17 +31,17 @@ class CarouselController extends Controller } /** - * @Post("/create", name="admin.carousel.create") + * @Post("/create", name="admin.slide.create") */ public function createAction() { - $carouselService = new CarouselService(); + $slideService = new SlideService(); - $carousel = $carouselService->createCarousel(); + $slide = $slideService->createSlide(); $location = $this->url->get([ - 'for' => 'admin.carousel.edit', - 'id' => $carousel->id, + 'for' => 'admin.slide.edit', + 'id' => $slide->id, ]); $content = [ @@ -53,27 +53,27 @@ class CarouselController extends Controller } /** - * @Get("/{id:[0-9]+}/edit", name="admin.carousel.edit") + * @Get("/{id:[0-9]+}/edit", name="admin.slide.edit") */ public function editAction($id) { - $carouselService = new CarouselService(); + $slideService = new SlideService(); - $carousel = $carouselService->getCarousel($id); + $slide = $slideService->getSlide($id); - $this->view->setVar('carousel', $carousel); + $this->view->setVar('slide', $slide); } /** - * @Post("/{id:[0-9]+}/update", name="admin.carousel.update") + * @Post("/{id:[0-9]+}/update", name="admin.slide.update") */ public function updateAction($id) { - $carouselService = new CarouselService(); + $slideService = new SlideService(); - $carouselService->updateCarousel($id); + $slideService->updateSlide($id); - $location = $this->url->get(['for' => 'admin.carousel.list']); + $location = $this->url->get(['for' => 'admin.slide.list']); $content = [ 'location' => $location, @@ -84,13 +84,13 @@ class CarouselController extends Controller } /** - * @Post("/{id:[0-9]+}/delete", name="admin.carousel.delete") + * @Post("/{id:[0-9]+}/delete", name="admin.slide.delete") */ public function deleteAction($id) { - $carouselService = new CarouselService(); + $slideService = new SlideService(); - $carouselService->deleteCarousel($id); + $slideService->deleteSlide($id); $location = $this->request->getHTTPReferer(); @@ -103,13 +103,13 @@ class CarouselController extends Controller } /** - * @Post("/{id:[0-9]+}/restore", name="admin.carousel.restore") + * @Post("/{id:[0-9]+}/restore", name="admin.slide.restore") */ public function restoreAction($id) { - $carouselService = new CarouselService(); + $slideService = new SlideService(); - $carouselService->restoreCarousel($id); + $slideService->restoreSlide($id); $location = $this->request->getHTTPReferer(); diff --git a/app/Http/Admin/Controllers/StudentController.php b/app/Http/Admin/Controllers/StudentController.php index 5ef6e5d2..9b2707fb 100644 --- a/app/Http/Admin/Controllers/StudentController.php +++ b/app/Http/Admin/Controllers/StudentController.php @@ -84,7 +84,7 @@ class StudentController extends Controller */ public function editAction() { - $relationId = $this->request->getQuery('relation_id'); + $relationId = $this->request->getQuery('relation_id', 'int'); $studentService = new StudentService(); diff --git a/app/Http/Admin/Controllers/TestController.php b/app/Http/Admin/Controllers/TestController.php index fa017431..ec650dc8 100644 --- a/app/Http/Admin/Controllers/TestController.php +++ b/app/Http/Admin/Controllers/TestController.php @@ -7,11 +7,10 @@ use App\Http\Admin\Services\Setting as SettingService; use App\Http\Admin\Services\WxpayTest as WxpayTestService; use App\Services\Captcha as CaptchaService; use App\Services\Live as LiveService; -use App\Services\Mailer\Test as TestMailerService; +use App\Services\Mail\Test as TestMailService; use App\Services\MyStorage as StorageService; -use App\Services\Smser\Test as TestSmserService; +use App\Services\Sms\Test as TestSmsService; use App\Services\Vod as VodService; -use Phalcon\Mvc\View; /** * @RoutePrefix("/admin/test") @@ -60,14 +59,14 @@ class TestController extends Controller */ public function livePushAction() { - $streamName = $this->request->getQuery('stream'); + $streamName = $this->request->getQuery('stream', 'string'); $liveService = new LiveService(); $pushUrl = $liveService->getPushUrl($streamName); $qrcode = $this->url->get( - ['for' => 'desktop.qrcode'], + ['for' => 'home.qrcode'], ['text' => urlencode($pushUrl)] ); @@ -92,21 +91,20 @@ class TestController extends Controller $pullUrls = $liveService->getPullUrls('test'); - $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); $this->view->pick('public/live_player'); $this->view->setVar('pull_urls', $pullUrls); } /** - * @Post("/smser", name="admin.test.smser") + * @Post("/sms", name="admin.test.sms") */ - public function smserAction() + public function smsAction() { - $phone = $this->request->getPost('phone'); + $phone = $this->request->getPost('phone', 'string'); - $smserService = new TestSmserService(); + $smsService = new TestSmsService(); - $response = $smserService->handle($phone); + $response = $smsService->handle($phone); if ($response) { return $this->jsonSuccess(['msg' => '发送短信成功,请到收件箱确认']); @@ -116,15 +114,15 @@ class TestController extends Controller } /** - * @Post("/mailer", name="admin.test.mailer") + * @Post("/mail", name="admin.test.mail") */ - public function mailerAction() + public function mailAction() { - $email = $this->request->getPost('email'); + $email = $this->request->getPost('email', 'string'); - $mailerService = new TestMailerService(); + $mailService = new TestMailService(); - $result = $mailerService->handle($email); + $result = $mailService->handle($email); if ($result) { return $this->jsonSuccess(['msg' => '发送邮件成功,请到收件箱确认']); @@ -166,7 +164,7 @@ class TestController extends Controller $this->db->begin(); - $order = $alipayTestService->createOrder(); + $order = $alipayTestService->createAlipayOrder(); $trade = $alipayTestService->createTrade($order); $qrcode = $alipayTestService->scan($trade); @@ -190,7 +188,7 @@ class TestController extends Controller $this->db->begin(); - $order = $wxpayTestService->createOrder(); + $order = $wxpayTestService->createWxpayOrder(); $trade = $wxpayTestService->createTrade($order); $qrcode = $wxpayTestService->scan($trade); @@ -210,7 +208,7 @@ class TestController extends Controller */ public function alipayStatusAction() { - $sn = $this->request->getQuery('sn'); + $sn = $this->request->getQuery('sn', 'string'); $alipayTestService = new AlipayTestService(); @@ -224,7 +222,7 @@ class TestController extends Controller */ public function wxpayStatusAction() { - $sn = $this->request->getQuery('sn'); + $sn = $this->request->getQuery('sn', 'string'); $wxpayTestService = new WxpayTestService(); diff --git a/app/Http/Admin/Controllers/TradeController.php b/app/Http/Admin/Controllers/TradeController.php index 0eb539ce..b4781320 100644 --- a/app/Http/Admin/Controllers/TradeController.php +++ b/app/Http/Admin/Controllers/TradeController.php @@ -70,13 +70,16 @@ class TradeController extends Controller { $tradeService = new TradeService(); - $tradeService->refundTrade($id); + $refund = $tradeService->refundTrade($id); - $location = $this->request->getHTTPReferer(); + $location = $this->url->get([ + 'for' => 'admin.refund.show', + 'id' => $refund->id, + ]); $content = [ 'location' => $location, - 'msg' => '申请退款成功,请到退款管理中审核确认', + 'msg' => '申请退款成功', ]; return $this->jsonSuccess($content); diff --git a/app/Http/Admin/Controllers/UploadController.php b/app/Http/Admin/Controllers/UploadController.php index eb251179..86709468 100644 --- a/app/Http/Admin/Controllers/UploadController.php +++ b/app/Http/Admin/Controllers/UploadController.php @@ -53,13 +53,13 @@ class UploadController extends Controller } /** - * @Post("/editor/img", name="admin.upload.editor_img") + * @Post("/content/img", name="admin.upload.content_img") */ - public function uploadEditorImageAction() + public function uploadContentImageAction() { $service = new StorageService(); - $file = $service->uploadEditorImage(); + $file = $service->uploadContentImage(); if ($file) { return $this->jsonSuccess([ diff --git a/app/Http/Admin/Controllers/VodController.php b/app/Http/Admin/Controllers/VodController.php index 72f4c35f..d2ffdfa5 100644 --- a/app/Http/Admin/Controllers/VodController.php +++ b/app/Http/Admin/Controllers/VodController.php @@ -3,7 +3,6 @@ namespace App\Http\Admin\Controllers; use App\Services\Vod as VodService; -use Phalcon\Mvc\View; /** * @RoutePrefix("/admin/vod") @@ -28,13 +27,12 @@ class VodController extends Controller */ public function playerAction() { - $chapterId = $this->request->getQuery('chapter_id'); - $playUrl = $this->request->getQuery('play_url'); + $chapterId = $this->request->getQuery('chapter_id', 'int'); + $playUrl = $this->request->getQuery('play_url', 'string'); - $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); $this->view->pick('public/vod_player'); $this->view->setVar('chapter_id', $chapterId); - $this->view->setVar('play_url', urldecode($playUrl)); + $this->view->setVar('play_url', $playUrl); } } diff --git a/app/Http/Admin/Services/AlipayTest.php b/app/Http/Admin/Services/AlipayTest.php index 832f0514..dfc9269f 100644 --- a/app/Http/Admin/Services/AlipayTest.php +++ b/app/Http/Admin/Services/AlipayTest.php @@ -20,7 +20,7 @@ class AlipayTest extends PayTest if ($code) { $codeUrl = $this->url->get( - ['for' => 'desktop.qrcode'], + ['for' => 'home.qrcode'], ['text' => urlencode($code)] ); } diff --git a/app/Http/Admin/Services/AuthNode.php b/app/Http/Admin/Services/AuthNode.php index c30d4d0f..44482bb0 100644 --- a/app/Http/Admin/Services/AuthNode.php +++ b/app/Http/Admin/Services/AuthNode.php @@ -385,25 +385,25 @@ class AuthNode extends Service 'id' => '2-5-1', 'title' => '轮播列表', 'type' => 'menu', - 'route' => 'admin.carousel.list', + 'route' => 'admin.slide.list', ], [ 'id' => '2-5-2', 'title' => '添加轮播', 'type' => 'menu', - 'route' => 'admin.carousel.add', + 'route' => 'admin.slide.add', ], [ 'id' => '2-5-3', 'title' => '编辑轮播', 'type' => 'button', - 'route' => 'admin.carousel.edit', + 'route' => 'admin.slide.edit', ], [ 'id' => '2-5-4', 'title' => '删除轮播', 'type' => 'button', - 'route' => 'admin.carousel.delete', + 'route' => 'admin.slide.delete', ], ], ], @@ -675,13 +675,13 @@ class AuthNode extends Service 'id' => '5-1-6', 'title' => '短信设置', 'type' => 'menu', - 'route' => 'admin.setting.smser', + 'route' => 'admin.setting.sms', ], [ 'id' => '5-1-7', 'title' => '邮件设置', 'type' => 'menu', - 'route' => 'admin.setting.mailer', + 'route' => 'admin.setting.mail', ], [ 'id' => '5-1-8', diff --git a/app/Http/Admin/Services/Chapter.php b/app/Http/Admin/Services/Chapter.php index 6071a2f4..4eeb8264 100644 --- a/app/Http/Admin/Services/Chapter.php +++ b/app/Http/Admin/Services/Chapter.php @@ -3,7 +3,7 @@ namespace App\Http\Admin\Services; use App\Caches\Chapter as ChapterCache; -use App\Caches\CourseCatalog as CourseCatalogCache; +use App\Caches\CourseChapterList as CatalogCache; use App\Models\Chapter as ChapterModel; use App\Models\ChapterLive as ChapterLiveModel; use App\Models\ChapterRead as ChapterReadModel; @@ -249,7 +249,7 @@ class Chapter extends Service protected function rebuildCatalogCache(ChapterModel $chapter) { - $cache = new CourseCatalogCache(); + $cache = new CatalogCache(); $cache->rebuild($chapter->course_id); } diff --git a/app/Http/Admin/Services/ChapterContent.php b/app/Http/Admin/Services/ChapterContent.php index 1fbc24c6..665992bf 100644 --- a/app/Http/Admin/Services/ChapterContent.php +++ b/app/Http/Admin/Services/ChapterContent.php @@ -2,6 +2,7 @@ namespace App\Http\Admin\Services; +use App\Caches\CourseChapterList as CatalogCache; use App\Library\Utils\Word as WordUtil; use App\Models\Chapter as ChapterModel; use App\Models\Course as CourseModel; @@ -63,6 +64,8 @@ class ChapterContent extends Service $this->updateChapterRead($chapter); break; } + + $this->rebuildCatalogCache($chapter); } protected function updateChapterVod(ChapterModel $chapter) @@ -166,4 +169,11 @@ class ChapterContent extends Service $courseStats->updateReadAttrs($chapter->course_id); } + protected function rebuildCatalogCache(ChapterModel $chapter) + { + $cache = new CatalogCache(); + + $cache->rebuild($chapter->course_id); + } + } diff --git a/app/Http/Admin/Services/Course.php b/app/Http/Admin/Services/Course.php index 503e96b2..9dba1d7c 100644 --- a/app/Http/Admin/Services/Course.php +++ b/app/Http/Admin/Services/Course.php @@ -21,7 +21,7 @@ use App\Repos\CourseCategory as CourseCategoryRepo; use App\Repos\CourseRelated as CourseRelatedRepo; use App\Repos\CourseUser as CourseUserRepo; use App\Repos\User as UserRepo; -use App\Services\Syncer\CourseIndex as CourseIndexSyncer; +use App\Services\Sync\CourseIndex as CourseIndexSync; use App\Validators\Course as CourseValidator; class Course extends Service @@ -363,9 +363,9 @@ class Course extends Service protected function rebuildCourseIndex(CourseModel $course) { - $syncer = new CourseIndexSyncer(); + $sync = new CourseIndexSync(); - $syncer->addItem($course->id); + $sync->addItem($course->id); } protected function saveTeachers(CourseModel $course, $teacherIds) diff --git a/app/Http/Admin/Services/PayTest.php b/app/Http/Admin/Services/PayTest.php index 6aa3134d..ea563b0c 100644 --- a/app/Http/Admin/Services/PayTest.php +++ b/app/Http/Admin/Services/PayTest.php @@ -15,11 +15,11 @@ abstract class PayTest extends Service protected $channel; /** - * 创建订单 + * 创建支付宝订单 * * @return OrderModel */ - public function createOrder() + public function createAlipayOrder() { /** * @var AdminAuth $auth @@ -30,8 +30,45 @@ abstract class PayTest extends Service $order = new OrderModel(); - $order->subject = '测试 - 支付测试0.01元'; - $order->amount = 0.01; + $order->subject = '测试 - 支付测试3.01元'; + $order->amount = 3.01; + $order->owner_id = $authUser['id']; + $order->item_type = OrderModel::ITEM_TEST; + + $order->create(); + + return $order; + } + + /** + * 创建微信订单 + * + * @return OrderModel + */ + public function createWxpayOrder() + { + /** + * @var AdminAuth $auth + */ + $auth = $this->getDI()->get('auth'); + + $authUser = $auth->getAuthInfo(); + + $config = $this->getConfig(); + + $order = new OrderModel(); + + /** + * 微信沙箱环境金额不能自定义,只能是测试用例值(沙吊的不行) + */ + if ($config->get('env') == ENV_DEV) { + $order->subject = '测试 - 支付测试3.01元'; + $order->amount = 3.01; + } else { + $order->subject = '测试 - 支付测试0.01元'; + $order->amount = 0.01; + } + $order->owner_id = $authUser['id']; $order->item_type = OrderModel::ITEM_TEST; diff --git a/app/Http/Admin/Services/Session.php b/app/Http/Admin/Services/Session.php index 41064122..9ce79803 100644 --- a/app/Http/Admin/Services/Session.php +++ b/app/Http/Admin/Services/Session.php @@ -24,7 +24,7 @@ class Session extends Service $currentUser = $this->getCurrentUser(); if ($currentUser->id > 0) { - $this->response->redirect(['for' => 'desktop.index']); + $this->response->redirect(['for' => 'home.index']); } $post = $this->request->getPost(); @@ -33,7 +33,7 @@ class Session extends Service $user = $accountValidator->checkAdminLogin($post['account'], $post['password']); - $captchaSettings = $this->getSectionSettings('captcha'); + $captchaSettings = $this->getSettings('captcha'); /** * 验证码是一次性的,放到最后检查,减少第三方调用 diff --git a/app/Http/Admin/Services/Setting.php b/app/Http/Admin/Services/Setting.php index 0899b47f..a11be838 100644 --- a/app/Http/Admin/Services/Setting.php +++ b/app/Http/Admin/Services/Setting.php @@ -11,18 +11,18 @@ class Setting extends Service public function getAlipaySettings() { - $alipay = $this->getSectionSettings('pay.alipay'); + $alipay = $this->getSettings('pay.alipay'); - $alipay['notify_url'] = $alipay['notify_url'] ?: kg_full_url(['for' => 'desktop.alipay_notify']); + $alipay['notify_url'] = $alipay['notify_url'] ?: kg_full_url(['for' => 'home.alipay_notify']); return $alipay; } public function getWxpaySettings() { - $wxpay = $this->getSectionSettings('pay.wxpay'); + $wxpay = $this->getSettings('pay.wxpay'); - $wxpay['notify_url'] = $wxpay['notify_url'] ?: kg_full_url(['for' => 'desktop.wxpay_notify']); + $wxpay['notify_url'] = $wxpay['notify_url'] ?: kg_full_url(['for' => 'home.wxpay_notify']); return $wxpay; } @@ -36,20 +36,20 @@ class Setting extends Service public function getLiveSettings($section) { - $result = $this->getSectionSettings($section); + $result = $this->getSettings($section); if ($section == 'live.notify') { - $result['stream_begin_url'] = $result['stream_begin_url'] ?: kg_full_url(['for' => 'desktop.live_notify'], ['action' => 'streamBegin']); - $result['stream_end_url'] = $result['stream_end_url'] ?: kg_full_url(['for' => 'desktop.live_notify'], ['action' => 'streamEnd']); - $result['record_url'] = $result['record_url'] ?: kg_full_url(['for' => 'desktop.live_notify'], ['action' => 'record']); - $result['snapshot_url'] = $result['snapshot_url'] ?: kg_full_url(['for' => 'desktop.live_notify'], ['action' => 'snapshot']); - $result['porn_url'] = $result['porn_url'] ?: kg_full_url(['for' => 'desktop.live_notify'], ['action' => 'porn']); + $result['stream_begin_url'] = $result['stream_begin_url'] ?: kg_full_url(['for' => 'home.live_notify'], ['action' => 'streamBegin']); + $result['stream_end_url'] = $result['stream_end_url'] ?: kg_full_url(['for' => 'home.live_notify'], ['action' => 'streamEnd']); + $result['record_url'] = $result['record_url'] ?: kg_full_url(['for' => 'home.live_notify'], ['action' => 'record']); + $result['snapshot_url'] = $result['snapshot_url'] ?: kg_full_url(['for' => 'home.live_notify'], ['action' => 'snapshot']); + $result['porn_url'] = $result['porn_url'] ?: kg_full_url(['for' => 'home.live_notify'], ['action' => 'porn']); } return $result; } - public function getSectionSettings($section) + public function getSettings($section) { $settingsRepo = new SettingRepo(); @@ -119,7 +119,7 @@ class Setting extends Service $this->updateSectionSettings($section, $settings); } - public function updateSmserSettings($section, $settings) + public function updateSmsSettings($section, $settings) { $settings['template'] = kg_json_encode($settings['template']); diff --git a/app/Http/Admin/Services/Carousel.php b/app/Http/Admin/Services/Slide.php similarity index 52% rename from app/Http/Admin/Services/Carousel.php rename to app/Http/Admin/Services/Slide.php index cd746de6..54c7895b 100644 --- a/app/Http/Admin/Services/Carousel.php +++ b/app/Http/Admin/Services/Slide.php @@ -2,16 +2,16 @@ namespace App\Http\Admin\Services; -use App\Caches\IndexCarouselList as IndexCarouselListCache; +use App\Caches\IndexSlideList as IndexSlideListCache; use App\Library\Paginator\Query as PagerQuery; -use App\Models\Carousel as CarouselModel; -use App\Repos\Carousel as CarouselRepo; -use App\Validators\Carousel as CarouselValidator; +use App\Models\Slide as SlideModel; +use App\Repos\Slide as SlideRepo; +use App\Validators\Slide as SlideValidator; -class Carousel extends Service +class Slide extends Service { - public function getCarousels() + public function getSlides() { $pagerQuery = new PagerQuery(); @@ -23,55 +23,55 @@ class Carousel extends Service $page = $pagerQuery->getPage(); $limit = $pagerQuery->getLimit(); - $carouselRepo = new CarouselRepo(); + $slideRepo = new SlideRepo(); - return $carouselRepo->paginate($params, $sort, $page, $limit); + return $slideRepo->paginate($params, $sort, $page, $limit); } - public function getCarousel($id) + public function getSlide($id) { return $this->findOrFail($id); } - public function createCarousel() + public function createSlide() { $post = $this->request->getPost(); - $validator = new CarouselValidator(); + $validator = new SlideValidator(); $data['title'] = $validator->checkTitle($post['title']); $data['target'] = $validator->checkTarget($post['target']); - if ($post['target'] == CarouselModel::TARGET_COURSE) { + if ($post['target'] == SlideModel::TARGET_COURSE) { $course = $validator->checkCourse($post['content']); $data['content'] = $course->id; $data['cover'] = $course->cover; $data['summary'] = $course->summary; - } elseif ($post['target'] == CarouselModel::TARGET_PAGE) { + } elseif ($post['target'] == SlideModel::TARGET_PAGE) { $page = $validator->checkPage($post['content']); $data['content'] = $page->id; - } elseif ($post['target'] == CarouselModel::TARGET_LINK) { + } elseif ($post['target'] == SlideModel::TARGET_LINK) { $data['content'] = $validator->checkLink($post['content']); } $data['priority'] = 20; - $carousel = new CarouselModel(); + $slide = new SlideModel(); - $carousel->create($data); + $slide->create($data); - $this->rebuildCarouselCache(); + $this->rebuildSlideCache(); - return $carousel; + return $slide; } - public function updateCarousel($id) + public function updateSlide($id) { - $carousel = $this->findOrFail($id); + $slide = $this->findOrFail($id); $post = $this->request->getPost(); - $validator = new CarouselValidator(); + $validator = new SlideValidator(); $data = []; @@ -87,18 +87,14 @@ class Carousel extends Service $data['cover'] = $validator->checkCover($post['cover']); } - if (isset($post['style']['bg_color'])) { - $data['style']['bg_color'] = $validator->checkBgColor($post['style']['bg_color']); - } - if (isset($post['content'])) { - if ($carousel->target == CarouselModel::TARGET_COURSE) { + if ($slide->target == SlideModel::TARGET_COURSE) { $course = $validator->checkCourse($post['content']); $data['content'] = $course->id; - } elseif ($carousel->target == CarouselModel::TARGET_PAGE) { + } elseif ($slide->target == SlideModel::TARGET_PAGE) { $page = $validator->checkPage($post['content']); $data['content'] = $page->id; - } elseif ($carousel->target == CarouselModel::TARGET_LINK) { + } elseif ($slide->target == SlideModel::TARGET_LINK) { $data['content'] = $validator->checkLink($post['content']); } } @@ -111,51 +107,51 @@ class Carousel extends Service $data['published'] = $validator->checkPublishStatus($post['published']); } - $carousel->update($data); + $slide->update($data); - $this->rebuildCarouselCache(); + $this->rebuildSlideCache(); - return $carousel; + return $slide; } - public function deleteCarousel($id) + public function deleteSlide($id) { - $carousel = $this->findOrFail($id); + $slide = $this->findOrFail($id); - $carousel->deleted = 1; + $slide->deleted = 1; - $carousel->update(); + $slide->update(); - $this->rebuildCarouselCache(); + $this->rebuildSlideCache(); - return $carousel; + return $slide; } - public function restoreCarousel($id) + public function restoreSlide($id) { - $carousel = $this->findOrFail($id); + $slide = $this->findOrFail($id); - $carousel->deleted = 0; + $slide->deleted = 0; - $carousel->update(); + $slide->update(); - $this->rebuildCarouselCache(); + $this->rebuildSlideCache(); - return $carousel; + return $slide; } - protected function rebuildCarouselCache() + protected function rebuildSlideCache() { - $cache = new IndexCarouselListCache(); + $cache = new IndexSlideListCache(); $cache->rebuild(); } protected function findOrFail($id) { - $validator = new CarouselValidator(); + $validator = new SlideValidator(); - return $validator->checkCarousel($id); + return $validator->checkSlide($id); } } diff --git a/app/Http/Admin/Services/Trade.php b/app/Http/Admin/Services/Trade.php index b471c9c0..7205ce6c 100644 --- a/app/Http/Admin/Services/Trade.php +++ b/app/Http/Admin/Services/Trade.php @@ -101,7 +101,7 @@ class Trade extends Service $refund->create(); - return $trade; + return $refund; } protected function findOrFail($id) diff --git a/app/Http/Admin/Views/carousel/add.volt b/app/Http/Admin/Views/carousel/add.volt index a1a7e1e2..ba0cb7f9 100644 --- a/app/Http/Admin/Views/carousel/add.volt +++ b/app/Http/Admin/Views/carousel/add.volt @@ -2,7 +2,7 @@ {% block content %} -
+
添加轮播
@@ -15,9 +15,9 @@
- - - + + +
diff --git a/app/Http/Admin/Views/carousel/edit.volt b/app/Http/Admin/Views/carousel/edit.volt index b2381874..03c453bd 100644 --- a/app/Http/Admin/Views/carousel/edit.volt +++ b/app/Http/Admin/Views/carousel/edit.volt @@ -3,67 +3,58 @@ {% block content %} {%- macro content_label(target) %} - {% if target == 'course' %} + {% if target == 1 %} 课程编号 - {% elseif target == 'page' %} + {% elseif target == 2 %} 单页编号 - {% elseif target == 'link' %} + {% elseif target == 3 %} 链接地址 {% endif %} {%- endmacro %} - +
编辑轮播
- - + +
-
- -
- -
-
-
-
-
- +
- +
- +
- +
- +
- - + +
@@ -81,28 +72,4 @@ {{ js_include('admin/js/cover.upload.js') }} -{% endblock %} - -{% block inline_js %} - - - {% endblock %} \ No newline at end of file diff --git a/app/Http/Admin/Views/carousel/list.volt b/app/Http/Admin/Views/carousel/list.volt index c60351b5..fb832a23 100644 --- a/app/Http/Admin/Views/carousel/list.volt +++ b/app/Http/Admin/Views/carousel/list.volt @@ -3,17 +3,15 @@ {% block content %} {%- macro target_info(value) %} - {% if value == 'course' %} + {% if value == 1 %} 课程 - {% elseif value == 'page' %} + {% elseif value == 2 %} 单页 - {% elseif value == 'link' %} - 链接 + {% elseif value == 3 %} + 链接 {% endif %} {%- endmacro %} - {% set add_url = url({'for':'admin.carousel.add'}) %} -
@@ -43,16 +41,16 @@ {% for item in pager.items %} - {% set edit_url = url({'for':'admin.carousel.edit','id':item.id}) %} - {% set update_url = url({'for':'admin.carousel.update','id':item.id}) %} - {% set delete_url = url({'for':'admin.carousel.delete','id':item.id}) %} - {% set restore_url = url({'for':'admin.carousel.restore','id':item.id}) %} + {% set edit_url = url({'for':'admin.slide.edit','id':item.id}) %} + {% set update_url = url({'for':'admin.slide.update','id':item.id}) %} + {% set delete_url = url({'for':'admin.slide.delete','id':item.id}) %} + {% set restore_url = url({'for':'admin.slide.restore','id':item.id}) %} {{ item.id }} - {{ item.title }} + {{ item.title }} {{ target_info(item.target) }} - +
diff --git a/app/Http/Admin/Views/category/edit.volt b/app/Http/Admin/Views/category/edit.volt index 0d12f1eb..13bc5302 100644 --- a/app/Http/Admin/Views/category/edit.volt +++ b/app/Http/Admin/Views/category/edit.volt @@ -21,8 +21,8 @@
- - + +
diff --git a/app/Http/Admin/Views/category/list.volt b/app/Http/Admin/Views/category/list.volt index 840af593..6a2e9b04 100644 --- a/app/Http/Admin/Views/category/list.volt +++ b/app/Http/Admin/Views/category/list.volt @@ -61,7 +61,7 @@ {{ item.level }} {{ item.child_count }} - +
diff --git a/app/Http/Admin/Views/chapter/edit_lesson.volt b/app/Http/Admin/Views/chapter/edit_lesson.volt index 802c973e..69bfd8d1 100644 --- a/app/Http/Admin/Views/chapter/edit_lesson.volt +++ b/app/Http/Admin/Views/chapter/edit_lesson.volt @@ -41,7 +41,7 @@ {% block link_css %} - {% if chapter.model == '3' %} + {% if chapter.model == 3 %} {{ css_link('https://cdn.jsdelivr.net/npm/vditor/dist/index.css', false) }} {% endif %} @@ -49,12 +49,12 @@ {% block include_js %} - {% if chapter.model == '3' %} + {% if chapter.model == 3 %} {{ js_include('https://cdn.jsdelivr.net/npm/vditor/dist/index.min.js', false) }} {{ js_include('admin/js/vditor.js') }} - {% elseif chapter.model == '1' %} + {% elseif chapter.model == 1 %} {{ js_include('lib/vod-js-sdk-v6.min.js') }} {{ js_include('lib/clipboard.min.js') }} diff --git a/app/Http/Admin/Views/chapter/lessons_live.volt b/app/Http/Admin/Views/chapter/lessons_live.volt index 649374af..8ecd0f97 100644 --- a/app/Http/Admin/Views/chapter/lessons_live.volt +++ b/app/Http/Admin/Views/chapter/lessons_live.volt @@ -42,7 +42,7 @@ {% for item in lessons %} - {% set preview_url = url({'for':'desktop.chapter.show','id':item.id}) %} + {% set preview_url = url({'for':'home.chapter.show','id':item.id}) %} {% set edit_url = url({'for':'admin.chapter.edit','id':item.id}) %} {% set update_url = url({'for':'admin.chapter.update','id':item.id}) %} {% set delete_url = url({'for':'admin.chapter.delete','id':item.id}) %} @@ -56,8 +56,8 @@ {{ live_time_info(item.attrs) }} {{ live_status_info(item.attrs['stream']['status']) }} - - + +
diff --git a/app/Http/Admin/Views/chapter/lessons_read.volt b/app/Http/Admin/Views/chapter/lessons_read.volt index af794cbf..e5fdacb0 100644 --- a/app/Http/Admin/Views/chapter/lessons_read.volt +++ b/app/Http/Admin/Views/chapter/lessons_read.volt @@ -21,7 +21,7 @@ {% for item in lessons %} - {% set preview_url = url({'for':'desktop.chapter.show','id':item.id}) %} + {% set preview_url = url({'for':'home.chapter.show','id':item.id}) %} {% set edit_url = url({'for':'admin.chapter.edit','id':item.id}) %} {% set update_url = url({'for':'admin.chapter.update','id':item.id}) %} {% set delete_url = url({'for':'admin.chapter.delete','id':item.id}) %} @@ -34,8 +34,8 @@ {{ item.attrs['word_count'] }} - - + +
diff --git a/app/Http/Admin/Views/chapter/lessons_vod.volt b/app/Http/Admin/Views/chapter/lessons_vod.volt index 93777824..838017da 100644 --- a/app/Http/Admin/Views/chapter/lessons_vod.volt +++ b/app/Http/Admin/Views/chapter/lessons_vod.volt @@ -37,7 +37,7 @@ {% for item in lessons %} - {% set preview_url = url({'for':'desktop.chapter.show','id':item.id}) %} + {% set preview_url = url({'for':'home.chapter.show','id':item.id}) %} {% set edit_url = url({'for':'admin.chapter.edit','id':item.id}) %} {% set update_url = url({'for':'admin.chapter.update','id':item.id}) %} {% set delete_url = url({'for':'admin.chapter.delete','id':item.id}) %} @@ -51,8 +51,8 @@ {{ file_status(item.attrs['file']['status']) }} {{ item.attrs['duration']|duration }} - - + +
diff --git a/app/Http/Admin/Views/consult/list.volt b/app/Http/Admin/Views/consult/list.volt index 2ab73896..21a74f8d 100644 --- a/app/Http/Admin/Views/consult/list.volt +++ b/app/Http/Admin/Views/consult/list.volt @@ -57,7 +57,7 @@

编号:{{ item.owner.id }}

{{ date('Y-m-d H:i:s',item.create_time) }} - +
diff --git a/app/Http/Admin/Views/course/edit_basic.volt b/app/Http/Admin/Views/course/edit_basic.volt index 7d3d5703..e28afa78 100644 --- a/app/Http/Admin/Views/course/edit_basic.volt +++ b/app/Http/Admin/Views/course/edit_basic.volt @@ -30,10 +30,10 @@
- - - - + + + +
diff --git a/app/Http/Admin/Views/course/list.volt b/app/Http/Admin/Views/course/list.volt index 7022c87d..9580510d 100644 --- a/app/Http/Admin/Views/course/list.volt +++ b/app/Http/Admin/Views/course/list.volt @@ -69,7 +69,7 @@ {% for item in pager.items %} - {% set preview_url = url({'for':'desktop.course.show','id':item.id}) %} + {% set preview_url = url({'for':'home.course.show','id':item.id}) %} {% set edit_url = url({'for':'admin.course.edit','id':item.id}) %} {% set update_url = url({'for':'admin.course.update','id':item.id}) %} {% set delete_url = url({'for':'admin.course.delete','id':item.id}) %} @@ -97,7 +97,7 @@

市场:{{ '¥%0.2f'|format(item.market_price) }}

会员:{{ '¥%0.2f'|format(item.vip_price) }}

- +
diff --git a/app/Http/Admin/Views/help/edit.volt b/app/Http/Admin/Views/help/edit.volt index 4d9ab1d4..72cf83dd 100644 --- a/app/Http/Admin/Views/help/edit.volt +++ b/app/Http/Admin/Views/help/edit.volt @@ -39,8 +39,8 @@
- - + +
diff --git a/app/Http/Admin/Views/help/list.volt b/app/Http/Admin/Views/help/list.volt index c930b3db..f7926df5 100644 --- a/app/Http/Admin/Views/help/list.volt +++ b/app/Http/Admin/Views/help/list.volt @@ -32,7 +32,7 @@ {% for item in helps %} {% set list_url = url({'for':'admin.help.list'},{'category_id':item.category.id}) %} - {% set preview_url = url({'for':'desktop.help.show','id':item.id}) %} + {% set preview_url = url({'for':'home.help.show','id':item.id}) %} {% set edit_url = url({'for':'admin.help.edit','id':item.id}) %} {% set update_url = url({'for':'admin.help.update','id':item.id}) %} {% set delete_url = url({'for':'admin.help.delete','id':item.id}) %} @@ -42,7 +42,7 @@ {{ item.title }} {{ item.category.name }} - +
diff --git a/app/Http/Admin/Views/im/group/edit.volt b/app/Http/Admin/Views/im/group/edit.volt index 10be069f..1a3b7cb1 100644 --- a/app/Http/Admin/Views/im/group/edit.volt +++ b/app/Http/Admin/Views/im/group/edit.volt @@ -37,8 +37,8 @@
- - + +
diff --git a/app/Http/Admin/Views/im/group/list.volt b/app/Http/Admin/Views/im/group/list.volt index d304bba3..6570f894 100644 --- a/app/Http/Admin/Views/im/group/list.volt +++ b/app/Http/Admin/Views/im/group/list.volt @@ -49,7 +49,7 @@ {% for item in pager.items %} - {% set preview_url = url({'for':'desktop.group.show','id':item.id}) %} + {% set preview_url = url({'for':'home.group.show','id':item.id}) %} {% set edit_url = url({'for':'admin.group.edit','id':item.id}) %} {% set update_url = url({'for':'admin.group.update','id':item.id}) %} {% set delete_url = url({'for':'admin.group.delete','id':item.id}) %} @@ -59,7 +59,7 @@ {{ item.name }} {{ type_info(item.type) }} {{ owner_info(item.owner) }} {{ item.user_count }} - +
diff --git a/app/Http/Admin/Views/index/index.volt b/app/Http/Admin/Views/index/index.volt index c14f300f..e0973609 100644 --- a/app/Http/Admin/Views/index/index.volt +++ b/app/Http/Admin/Views/index/index.volt @@ -28,13 +28,13 @@
  • {{ auth_user.name }}
    -
    基本资料
    -
    安全设置
    +
    基本资料
    +
    安全设置
    退出登录
  • - 前台 + 前台
  • diff --git a/app/Http/Admin/Views/index/main_app_info.volt b/app/Http/Admin/Views/index/main_app_info.volt index 33661931..e5199d2e 100644 --- a/app/Http/Admin/Views/index/main_app_info.volt +++ b/app/Http/Admin/Views/index/main_app_info.volt @@ -19,7 +19,7 @@ 获取渠道 Gitee  - Github + Github diff --git a/app/Http/Admin/Views/nav/edit.volt b/app/Http/Admin/Views/nav/edit.volt index cd970355..fd7673e3 100644 --- a/app/Http/Admin/Views/nav/edit.volt +++ b/app/Http/Admin/Views/nav/edit.volt @@ -27,22 +27,22 @@
    - - + +
    - - + +
    - - + +
    diff --git a/app/Http/Admin/Views/nav/list.volt b/app/Http/Admin/Views/nav/list.volt index 2e6a65ab..669a1eed 100644 --- a/app/Http/Admin/Views/nav/list.volt +++ b/app/Http/Admin/Views/nav/list.volt @@ -82,7 +82,7 @@ {{ position_info(item.position) }} {{ target_info(item.target) }} - +
    diff --git a/app/Http/Admin/Views/order/macro.volt b/app/Http/Admin/Views/order/macro.volt index 4fcbf361..f6ef13a7 100644 --- a/app/Http/Admin/Views/order/macro.volt +++ b/app/Http/Admin/Views/order/macro.volt @@ -1,12 +1,12 @@ {%- macro item_info(order) %} - {% if order.item_type == '1' %} + {% if order.item_type == 1 %} {% set course = order.item_info['course'] %}

    课程名称:{{ course['title'] }}

    市场价格:{{ '¥%0.2f'|format(course['market_price']) }},会员价格:{{ '¥%0.2f'|format(course['vip_price']) }}

    学习期限:{{ date('Y-m-d H:i:s',course['study_expiry_time']) }},退款期限:{{ date('Y-m-d H:i:s',course['refund_expiry_time']) }}

    - {% elseif order.item_type == '2' %} + {% elseif order.item_type == 2 %} {% set courses = order.item_info['courses'] %} {% for course in courses %}
    @@ -15,20 +15,20 @@

    学习期限:{{ date('Y-m-d H:i:s',course['study_expiry_time']) }},退款期限:{{ date('Y-m-d H:i:s',course['refund_expiry_time']) }}

    {% endfor %} - {% elseif order.item_type == '3' %} + {% elseif order.item_type == 3 %} {% set course = order.item_info['course'] %} {% set reward = order.item_info['reward'] %}

    商品名称:{{ order.subject }}

    商品价格:{{ '¥%0.2f'|format(order.amount) }}

    - {% elseif order.item_type == '4' %} + {% elseif order.item_type == 4 %} {% set vip = order.item_info['vip'] %}

    商品名称:{{ order.subject }}

    商品价格:{{ '¥%0.2f'|format(order.amount) }}

    - {% elseif order.item_type == '99' %} + {% elseif order.item_type == 99 %}

    商品名称:{{ order.subject }}

    商品价格:{{ '¥%0.2f'|format(order.amount) }}

    diff --git a/app/Http/Admin/Views/order/user_info.volt b/app/Http/Admin/Views/order/user_info.volt index e5fcfc92..822b7e25 100644 --- a/app/Http/Admin/Views/order/user_info.volt +++ b/app/Http/Admin/Views/order/user_info.volt @@ -12,7 +12,7 @@ {{ user.id }} {{ user.name }} - {% if account.phone %} {{ account.phone }} {% else %} 未知 {% endif %} - {% if account.email %} {{ account.email }} {% else %} 未知 {% endif %} + {{ account.phone }} + {{ account.email }} \ No newline at end of file diff --git a/app/Http/Admin/Views/package/list.volt b/app/Http/Admin/Views/package/list.volt index 49940aee..e319bd11 100644 --- a/app/Http/Admin/Views/package/list.volt +++ b/app/Http/Admin/Views/package/list.volt @@ -43,7 +43,7 @@ {{ item.course_count }} {{ '¥%0.2f'|format(item.market_price) }} {{ '¥%0.2f'|format(item.vip_price) }} - +
    diff --git a/app/Http/Admin/Views/page/edit.volt b/app/Http/Admin/Views/page/edit.volt index cc4d7232..d7eaca4e 100644 --- a/app/Http/Admin/Views/page/edit.volt +++ b/app/Http/Admin/Views/page/edit.volt @@ -22,8 +22,8 @@
    - - + +
    diff --git a/app/Http/Admin/Views/page/list.volt b/app/Http/Admin/Views/page/list.volt index 99e8a4c2..5e7a5062 100644 --- a/app/Http/Admin/Views/page/list.volt +++ b/app/Http/Admin/Views/page/list.volt @@ -31,7 +31,7 @@ {% for item in pager.items %} - {% set preview_url = url({'for':'desktop.page.show','id':item.id}) %} + {% set preview_url = url({'for':'home.page.show','id':item.id}) %} {% set edit_url = url({'for':'admin.page.edit','id':item.id}) %} {% set update_url = url({'for':'admin.page.update','id':item.id}) %} {% set delete_url = url({'for':'admin.page.delete','id':item.id}) %} @@ -40,7 +40,7 @@ {{ item.title }} {{ date('Y-m-d H:i',item.create_time) }} {{ date('Y-m-d H:i',item.update_time) }} - +
    diff --git a/app/Http/Admin/Views/public/forbidden.volt b/app/Http/Admin/Views/public/forbidden.volt index 35cf5cd1..28975e59 100644 --- a/app/Http/Admin/Views/public/forbidden.volt +++ b/app/Http/Admin/Views/public/forbidden.volt @@ -19,6 +19,6 @@ {% block link_css %} - {{ css_link("desktop/css/error.css") }} + {{ css_link("home/css/error.css") }} {% endblock %} \ No newline at end of file diff --git a/app/Http/Admin/Views/public/live_player.volt b/app/Http/Admin/Views/public/live_player.volt index 8bb5f7b8..334eb6e5 100644 --- a/app/Http/Admin/Views/public/live_player.volt +++ b/app/Http/Admin/Views/public/live_player.volt @@ -1,70 +1,56 @@ - - - - - - 视频直播 - +{% extends 'templates/main.volt' %} + +{% block content %} + +
    + +{% endblock %} + +{% block inline_css %} + - - -
    - - - - if (playUrls.rtmp && playUrls.rtmp.od) { - options.rtmp = playUrls.rtmp.od; - } + - var player = new TcPlayer('player', options); - - +{% endblock %} \ No newline at end of file diff --git a/app/Http/Admin/Views/public/login.volt b/app/Http/Admin/Views/public/login.volt index 5e583d7d..d2afecea 100644 --- a/app/Http/Admin/Views/public/login.volt +++ b/app/Http/Admin/Views/public/login.volt @@ -26,7 +26,7 @@ {% endif %}
    - {% set disabled = captcha.enabled ? 'disabled' : '' %} + {% set disabled = captcha.enabled ? 'disabled="disabled"' : '' %} @@ -71,7 +71,7 @@ var $ = layui.jquery; - var captcha = new TencentCaptcha( + new TencentCaptcha( $('#captcha-btn')[0], $('#captcha-btn').data('app-id'), function (res) { diff --git a/app/Http/Admin/Views/public/vod_player.volt b/app/Http/Admin/Views/public/vod_player.volt index 63c1c400..12489974 100644 --- a/app/Http/Admin/Views/public/vod_player.volt +++ b/app/Http/Admin/Views/public/vod_player.volt @@ -1,31 +1,38 @@ - - - - - - 视频点播 - +{% extends 'templates/main.volt' %} + +{% block content %} + +
    + +{% endblock %} + +{% block inline_css %} + - - -
    - - - - \ No newline at end of file + + +{% endblock %} \ No newline at end of file diff --git a/app/Http/Admin/Views/refund/search.volt b/app/Http/Admin/Views/refund/search.volt index 73489a4b..0db3df64 100644 --- a/app/Http/Admin/Views/refund/search.volt +++ b/app/Http/Admin/Views/refund/search.volt @@ -26,6 +26,7 @@ +
    diff --git a/app/Http/Admin/Views/refund/show.volt b/app/Http/Admin/Views/refund/show.volt index fbaaaa9e..48ddd254 100644 --- a/app/Http/Admin/Views/refund/show.volt +++ b/app/Http/Admin/Views/refund/show.volt @@ -39,7 +39,7 @@
    - {% if refund.status == 'pending' %} + {% if refund.status == 1 %}
    审核退款 diff --git a/app/Http/Admin/Views/review/list.volt b/app/Http/Admin/Views/review/list.volt index 30ae9ef3..3e61817e 100644 --- a/app/Http/Admin/Views/review/list.volt +++ b/app/Http/Admin/Views/review/list.volt @@ -54,7 +54,7 @@

    昵称:{{ item.owner.name }}

    编号:{{ item.owner.id }}

    - +
    diff --git a/app/Http/Admin/Views/role/edit.volt b/app/Http/Admin/Views/role/edit.volt index 23afcd58..d54835c6 100644 --- a/app/Http/Admin/Views/role/edit.volt +++ b/app/Http/Admin/Views/role/edit.volt @@ -31,7 +31,7 @@ {{ level2.title }} {% for level3 in level2.children %} - + {% endfor %} diff --git a/app/Http/Admin/Views/setting/im_cs.volt b/app/Http/Admin/Views/setting/im_cs.volt index b21920dc..156633c5 100644 --- a/app/Http/Admin/Views/setting/im_cs.volt +++ b/app/Http/Admin/Views/setting/im_cs.volt @@ -2,8 +2,8 @@
    - - + +
    diff --git a/app/Http/Admin/Views/setting/im_main.volt b/app/Http/Admin/Views/setting/im_main.volt index 7776e094..3e392a17 100644 --- a/app/Http/Admin/Views/setting/im_main.volt +++ b/app/Http/Admin/Views/setting/im_main.volt @@ -14,29 +14,29 @@
    - - + +
    - - + +
    - - + +
    - - + +
    diff --git a/app/Http/Admin/Views/setting/live_notify.volt b/app/Http/Admin/Views/setting/live_notify.volt index ae93063d..bb973c3f 100644 --- a/app/Http/Admin/Views/setting/live_notify.volt +++ b/app/Http/Admin/Views/setting/live_notify.volt @@ -40,7 +40,7 @@
    - +
    \ No newline at end of file diff --git a/app/Http/Admin/Views/setting/live_pull.volt b/app/Http/Admin/Views/setting/live_pull.volt index 3dd4ec32..d8cc833c 100644 --- a/app/Http/Admin/Views/setting/live_pull.volt +++ b/app/Http/Admin/Views/setting/live_pull.volt @@ -8,8 +8,8 @@
    - - + +
    @@ -24,8 +24,8 @@
    - - + +
    @@ -48,8 +48,8 @@
    - - + +
    @@ -97,7 +97,7 @@
    - +
    diff --git a/app/Http/Admin/Views/setting/live_push.volt b/app/Http/Admin/Views/setting/live_push.volt index 3c1955c3..6550b759 100644 --- a/app/Http/Admin/Views/setting/live_push.volt +++ b/app/Http/Admin/Views/setting/live_push.volt @@ -16,8 +16,8 @@
    - - + +
    @@ -39,7 +39,7 @@
    - +
    diff --git a/app/Http/Admin/Views/setting/live_push_test.volt b/app/Http/Admin/Views/setting/live_push_test.volt index 45430f41..969c162f 100644 --- a/app/Http/Admin/Views/setting/live_push_test.volt +++ b/app/Http/Admin/Views/setting/live_push_test.volt @@ -17,7 +17,7 @@
    - +
    复制 diff --git a/app/Http/Admin/Views/setting/mailer.volt b/app/Http/Admin/Views/setting/mail.volt similarity index 79% rename from app/Http/Admin/Views/setting/mailer.volt rename to app/Http/Admin/Views/setting/mail.volt index 651114e9..440c3fe9 100644 --- a/app/Http/Admin/Views/setting/mailer.volt +++ b/app/Http/Admin/Views/setting/mail.volt @@ -2,60 +2,60 @@ {% block content %} -
    +
    邮件配置
    - +
    - +
    - +
    - +
    - - - + + +
    - - + +
    - +
    - +
    @@ -68,7 +68,7 @@
    -
    +
    邮件测试
    @@ -98,7 +98,7 @@ var $ = layui.jquery; var form = layui.form; - form.on('radio(smtp_auth)', function (data) { + form.on('radio(smtp_auth_enabled)', function (data) { var block = $('#smtp-auth-block'); if (data.value === '1') { block.show(); diff --git a/app/Http/Admin/Views/setting/pay_alipay.volt b/app/Http/Admin/Views/setting/pay_alipay.volt index b99f0581..3a773750 100644 --- a/app/Http/Admin/Views/setting/pay_alipay.volt +++ b/app/Http/Admin/Views/setting/pay_alipay.volt @@ -2,8 +2,8 @@
    - - + +
    diff --git a/app/Http/Admin/Views/setting/pay_wxpay.volt b/app/Http/Admin/Views/setting/pay_wxpay.volt index 57cca245..14e7bf66 100644 --- a/app/Http/Admin/Views/setting/pay_wxpay.volt +++ b/app/Http/Admin/Views/setting/pay_wxpay.volt @@ -2,24 +2,24 @@
    - - + +
    - +
    - +
    - +
    - +
    @@ -40,6 +40,9 @@
    +{% set subject = config.get('env') == 'dev' ? '支付测试3.01元' : '支付测试0.01元' %} +{% set total_amount = config.get('env') == 'dev' ? 3.01 : 0.01 %} +
    支付测试 @@ -47,13 +50,13 @@
    - +
    - +
    diff --git a/app/Http/Admin/Views/setting/site.volt b/app/Http/Admin/Views/setting/site.volt index a8e1ffb1..7d51d8b5 100644 --- a/app/Http/Admin/Views/setting/site.volt +++ b/app/Http/Admin/Views/setting/site.volt @@ -2,7 +2,8 @@ {% block content %} - {% set closed_tips_display = site.enabled == 0 ? 'display:block' : 'display:none' %} + {% set closed_tips_display = site.status == 'closed' ? 'display:block' : 'display:none' %} + {% set analytics_script_display = site.analytics_enabled == 1 ? 'display:block' : 'display:none' %}
    @@ -11,8 +12,8 @@
    - - + +
    @@ -23,6 +24,13 @@
    +
    + +
    + + +
    +
    @@ -82,9 +90,18 @@
    - +
    - + + +
    +
    +
    +
    + +
    + +
    @@ -110,7 +127,16 @@ form.on('radio(status)', function (data) { var block = $('#closed-tips-block'); - if (data.value === '0') { + if (data.value === 'closed') { + block.show(); + } else { + block.hide(); + } + }); + + form.on('radio(analytics_enabled)', function (data) { + var block = $('#analytics-script-block'); + if (data.value === '1') { block.show(); } else { block.hide(); diff --git a/app/Http/Admin/Views/setting/smser.volt b/app/Http/Admin/Views/setting/sms.volt similarity index 94% rename from app/Http/Admin/Views/setting/smser.volt rename to app/Http/Admin/Views/setting/sms.volt index a9ba080c..dbddfc49 100644 --- a/app/Http/Admin/Views/setting/smser.volt +++ b/app/Http/Admin/Views/setting/sms.volt @@ -2,28 +2,28 @@ {% block content %} - {% set template = smser.template|json_decode %} + {% set template = sms.template|json_decode %} - +
    基础配置
    - +
    - +
    - +
    @@ -80,7 +80,7 @@
    -
    +
    短信测试
    diff --git a/app/Http/Admin/Views/setting/storage.volt b/app/Http/Admin/Views/setting/storage.volt index ced0f8ca..34ab1e62 100644 --- a/app/Http/Admin/Views/setting/storage.volt +++ b/app/Http/Admin/Views/setting/storage.volt @@ -21,8 +21,8 @@
    - - + +
    @@ -56,7 +56,7 @@ mageMogr2/thumbnail/270x/interlace/0 - carousel_1100 + slide_1100 imageMogr2/thumbnail/1100x/interlace/0 diff --git a/app/Http/Admin/Views/setting/vod.volt b/app/Http/Admin/Views/setting/vod.volt index c173a3ae..fc8b7d55 100644 --- a/app/Http/Admin/Views/setting/vod.volt +++ b/app/Http/Admin/Views/setting/vod.volt @@ -3,7 +3,7 @@ {% block content %} {% set storage_region_display = vod.storage_type == 'fixed' ? 'display:block' : 'display:none' %} - {% set watermark_template_display = vod.watermark_enabled == 1 ? 'display:block' : 'display:none' %} + {% set wmk_tpl_display = vod.wmk_enabled == 1 ? 'display:block' : 'display:none' %} {% set key_anti_display = vod.key_anti_enabled == 1 ? 'display:block': 'display:none' %} @@ -13,8 +13,8 @@
    - - + +
    @@ -31,29 +31,29 @@
    - - + +
    - - + +
    - - + +
    -
    +
    - +
    @@ -63,8 +63,8 @@
    - - + +
    @@ -79,8 +79,8 @@
    - - + +
    @@ -145,8 +145,8 @@ } }); - form.on('radio(watermark_enabled)', function (data) { - var block = $('#watermark-template-block'); + form.on('radio(wmk_enabled)', function (data) { + var block = $('#wmk-tpl-block'); if (data.value === '1') { block.show(); } else { diff --git a/app/Http/Admin/Views/topic/list.volt b/app/Http/Admin/Views/topic/list.volt index 029bcf84..295d1484 100644 --- a/app/Http/Admin/Views/topic/list.volt +++ b/app/Http/Admin/Views/topic/list.volt @@ -33,7 +33,7 @@ {% for item in pager.items %} - {% set preview_url = url({'for':'desktop.topic.show','id':item.id}) %} + {% set preview_url = url({'for':'home.topic.show','id':item.id}) %} {% set edit_url = url({'for':'admin.topic.edit','id':item.id}) %} {% set update_url = url({'for':'admin.topic.update','id':item.id}) %} {% set delete_url = url({'for':'admin.topic.delete','id':item.id}) %} @@ -44,7 +44,7 @@ {{ item.course_count }} {{ date('Y-m-d H:i',item.create_time) }} {{ date('Y-m-d H:i',item.update_time) }} - +
    diff --git a/app/Http/Admin/Views/trade/macro.volt b/app/Http/Admin/Views/trade/macro.volt index 3f5ecf2a..df25e586 100644 --- a/app/Http/Admin/Views/trade/macro.volt +++ b/app/Http/Admin/Views/trade/macro.volt @@ -1,7 +1,7 @@ {%- macro channel_type(value) %} - {% if value == '1' %} + {% if value == 1 %} 支付宝 - {% elseif value == '2' %} + {% elseif value == 2 %} 微信 {% endif %} {%- endmacro %} diff --git a/app/Http/Admin/Views/trade/show.volt b/app/Http/Admin/Views/trade/show.volt index 06aa8fc4..d544e590 100644 --- a/app/Http/Admin/Views/trade/show.volt +++ b/app/Http/Admin/Views/trade/show.volt @@ -12,7 +12,7 @@ {% set trade_refund_url = url({'for':'admin.trade.refund','id':trade.id}) %}
    - {% if trade.status == 'finished' %} + {% if trade.status == 2 %} {% endif %} @@ -38,7 +38,7 @@ {{ item.sn }} {{ '¥%0.2f'|format(item.amount) }} {{ substr(item.apply_note,0,15) }} - {{ refund_status(item) }} + {{ refund_status(item.status) }} {{ date('Y-m-d H:i:s',item.create_time) }} 详情 @@ -80,8 +80,8 @@ success: function (res) { layer.msg(res.msg, {icon: 1}); setTimeout(function () { - window.location.reload(); - }, 1500); + window.location.href = res.location; + }, 3000); }, error: function (xhr) { var json = JSON.parse(xhr.responseText); diff --git a/app/Http/Admin/Views/user/edit.volt b/app/Http/Admin/Views/user/edit.volt index f10cb96c..7a0fb973 100644 --- a/app/Http/Admin/Views/user/edit.volt +++ b/app/Http/Admin/Views/user/edit.volt @@ -29,18 +29,18 @@
    - - + +
    {% if auth_user.root == 1 %}
    - + {% for role in roles %} {% if role.id > 1 %} - + {% endif %} {% endfor %}
    diff --git a/app/Http/Admin/Views/user/list.volt b/app/Http/Admin/Views/user/list.volt index 15fde050..837e94cb 100644 --- a/app/Http/Admin/Views/user/list.volt +++ b/app/Http/Admin/Views/user/list.volt @@ -68,7 +68,7 @@ {% for item in pager.items %} - {% set preview_url = url({'for':'desktop.user.show','id':item.id}) %} + {% set preview_url = url({'for':'home.user.show','id':item.id}) %} {% set edit_url = url({'for':'admin.user.edit','id':item.id}) %} {{ item.id }} diff --git a/app/Http/Desktop/Controllers/IndexController.php b/app/Http/Desktop/Controllers/IndexController.php deleted file mode 100644 index 96324570..00000000 --- a/app/Http/Desktop/Controllers/IndexController.php +++ /dev/null @@ -1,27 +0,0 @@ -seo->setKeywords($this->siteInfo['keywords']); - $this->seo->setDescription($this->siteInfo['description']); - - $indexService = new IndexService(); - - $this->view->setVar('lives', $indexService->getLives()); - $this->view->setVar('carousels', $indexService->getCarousels()); - $this->view->setVar('new_courses', $indexService->getNewCourses()); - $this->view->setVar('free_courses', $indexService->getFreeCourses()); - $this->view->setVar('vip_courses', $indexService->getVipCourses()); - } - -} diff --git a/app/Http/Desktop/Controllers/MyController.php b/app/Http/Desktop/Controllers/MyController.php deleted file mode 100644 index 8334d646..00000000 --- a/app/Http/Desktop/Controllers/MyController.php +++ /dev/null @@ -1,182 +0,0 @@ -authUser->id == 0) { - $this->response->redirect(['for' => 'desktop.account.login']); - } - } - - /** - * @Get("/", name="desktop.my.index") - */ - public function indexAction() - { - return $this->dispatcher->forward(['action' => 'courses']); - } - - /** - * @Get("/profile", name="desktop.my.profile") - */ - public function profileAction() - { - $service = new ProfileInfoService(); - - $user = $service->handle(); - - $this->view->setVar('user', $user); - } - - /** - * @Get("/account", name="desktop.my.account") - */ - public function accountAction() - { - $service = new AccountInfoService(); - - $account = $service->handle(); - - $this->view->setVar('account', $account); - } - - /** - * @Get("/courses", name="desktop.my.courses") - */ - public function coursesAction() - { - $service = new MyCourseListService(); - - $pager = $service->handle(); - - $this->view->setVar('pager', $pager); - } - - /** - * @Get("/favorites", name="desktop.my.favorites") - */ - public function favoritesAction() - { - $service = new MyFavoriteListService(); - - $pager = $service->handle(); - - $this->view->setVar('pager', $pager); - } - - /** - * @Get("/consults", name="desktop.my.consults") - */ - public function consultsAction() - { - $service = new MyConsultListService(); - - $pager = $service->handle(); - - $this->view->setVar('pager', $pager); - } - - /** - * @Get("/reviews", name="desktop.my.reviews") - */ - public function reviewsAction() - { - $service = new MyReviewListService(); - - $pager = $service->handle(); - - $this->view->setVar('pager', $pager); - } - - /** - * @Get("/orders", name="desktop.my.orders") - */ - public function ordersAction() - { - $service = new MyOrderListService(); - - $pager = $service->handle(); - - $this->view->setVar('pager', $pager); - } - - /** - * @Get("/refunds", name="desktop.my.refunds") - */ - public function refundsAction() - { - $service = new MyRefundListService(); - - $pager = $service->handle(); - - $this->view->setVar('pager', $pager); - } - - /** - * @Get("/friends", name="desktop.my.friends") - */ - public function friendsAction() - { - $service = new MyFriendListService(); - - $pager = $service->handle(); - - $this->view->pick('my/friends'); - $this->view->setVar('pager', $pager); - } - - /** - * @Get("/groups", name="desktop.my.groups") - */ - public function groupsAction() - { - $scope = $this->request->getQuery('scope', 'trim', 'joined'); - - $service = new MyGroupListService(); - - $pager = $service->handle($scope); - - $this->view->pick('my/groups'); - $this->view->setVar('scope', $scope); - $this->view->setVar('pager', $pager); - } - - /** - * @Post("/profile/update", name="desktop.my.update_profile") - */ - public function updateProfileAction() - { - $service = new ProfileUpdateService(); - - $service->handle(); - - $content = [ - 'location' => $this->request->getHTTPReferer(), - 'msg' => '更新资料成功', - ]; - - return $this->jsonSuccess($content); - } - -} diff --git a/app/Http/Desktop/Controllers/TeachingController.php b/app/Http/Desktop/Controllers/TeachingController.php deleted file mode 100644 index c29bab8a..00000000 --- a/app/Http/Desktop/Controllers/TeachingController.php +++ /dev/null @@ -1,94 +0,0 @@ -dispatcher->forward(['action' => 'courses']); - } - - /** - * @Get("/courses", name="desktop.teaching.courses") - */ - public function coursesAction() - { - $service = new CourseListService(); - - $pager = $service->handle(); - - $pager->items = kg_array_object($pager->items); - - $this->view->setVar('pager', $pager); - } - - /** - * @Get("/lives", name="desktop.teaching.lives") - */ - public function livesAction() - { - $service = new LiveListService(); - - $pager = $service->handle(); - - $pager->items = kg_array_object($pager->items); - - $this->view->setVar('pager', $pager); - } - - /** - * @Get("/consults", name="desktop.teaching.consults") - */ - public function consultsAction() - { - $service = new ConsultListService(); - - $pager = $service->handle(); - - $pager->items = kg_array_object($pager->items); - - $this->view->setVar('pager', $pager); - } - - /** - * @Get("/live/push", name="desktop.teaching.live_push") - */ - public function livePushAction() - { - $service = new LivePushUrlService(); - - $pushUrl = $service->handle(); - - $qrcode = $this->url->get( - ['for' => 'desktop.qrcode'], - ['text' => urlencode($pushUrl)] - ); - - $pos = strrpos($pushUrl, '/'); - - $obs = [ - 'fms_url' => substr($pushUrl, 0, $pos + 1), - 'stream_code' => substr($pushUrl, $pos + 1), - ]; - - $this->view->pick('teaching/live_push'); - $this->view->setVar('qrcode', $qrcode); - $this->view->setVar('obs', $obs); - } - -} \ No newline at end of file diff --git a/app/Http/Desktop/Services/Index.php b/app/Http/Desktop/Services/Index.php deleted file mode 100644 index 71e93eb2..00000000 --- a/app/Http/Desktop/Services/Index.php +++ /dev/null @@ -1,101 +0,0 @@ -get(); - - if (!$carousels) return []; - - foreach ($carousels as $key => $carousel) { - - $carousels[$key]['style'] = CarouselModel::htmlStyle($carousel['style']); - - switch ($carousel['target']) { - case CarouselModel::TARGET_COURSE: - $carousels[$key]['url'] = $this->url->get([ - 'for' => 'desktop.course.show', - 'id' => $carousel['content'], - ]); - break; - case CarouselModel::TARGET_PAGE: - $carousels[$key]['url'] = $this->url->get([ - 'for' => 'desktop.page.show', - 'id' => $carousel['content'], - ]); - break; - case CarouselModel::TARGET_LINK: - $carousels[$key]['url'] = $carousel['content']; - break; - default: - break; - } - } - - return $carousels; - } - - public function getLives() - { - $cache = new IndexLiveListCache(); - - return $cache->get(); - } - - public function getNewCourses() - { - $cache = new IndexNewCourseListCache(); - - $courses = $cache->get(); - - return $this->handleCategoryCourses($courses); - } - - public function getFreeCourses() - { - $cache = new IndexFreeCourseListCache(); - - $courses = $cache->get(); - - return $this->handleCategoryCourses($courses); - } - - public function getVipCourses() - { - $cache = new IndexVipCourseListCache(); - - $courses = $cache->get(); - - return $this->handleCategoryCourses($courses); - } - - protected function handleCategoryCourses($items, $limit = 8) - { - if (count($items) == 0) { - return []; - } - - foreach ($items as &$item) { - $item['courses'] = array_slice($item['courses'], 0, $limit); - } - - return $items; - } - -} diff --git a/app/Http/Desktop/Views/course/show_meta.volt b/app/Http/Desktop/Views/course/show_meta.volt deleted file mode 100644 index 45d73bdf..00000000 --- a/app/Http/Desktop/Views/course/show_meta.volt +++ /dev/null @@ -1,56 +0,0 @@ -
    -
    - {{ course.title|e }} -
    -
    - {% if course.model == '1' %} -

    - 课程时长{{ course.attrs.duration|duration }} -

    - {% elseif course.model == '2' %} -

    - 直播时间{{ course.attrs.start_date }} ~ {{ course.attrs.end_date }} -

    - {% endif %} - {% if course.market_price > 0 %} -

    - 学习期限{{ course.study_expiry }}个月 - 退款期限{{ course.refund_expiry }}天 -

    - {% endif %} -

    - {% if course.market_price > 0 %} - 市场价格{{ '¥%0.2f'|format(course.market_price) }} - {% else %} - 市场价格免费 - {% endif %} - {% if course.vip_price > 0 %} - 会员价格{{ '¥%0.2f'|format(course.vip_price) }} - {% else %} - 会员价格免费 - {% endif %} -

    -

    - 难度级别{{ level_info(course.level) }} - 学习人次{{ course.user_count }} - 综合评分{{ "%0.1f"|format(course.ratings.rating) }} -

    -
    -
    -

    - 内容实用 - {{ star_info(course.ratings.rating1) }} - {{ "%0.1f"|format(course.ratings.rating1) }}分 -

    -

    - 简洁易懂 - {{ star_info(course.ratings.rating2) }} - {{ "%0.1f"|format(course.ratings.rating2) }}分 -

    -

    - 逻辑清晰 - {{ star_info(course.ratings.rating3) }} - {{ "%0.1f"|format(course.ratings.rating3) }}分 -

    -
    -
    \ No newline at end of file diff --git a/app/Http/Desktop/Views/teaching/menu.volt b/app/Http/Desktop/Views/teaching/menu.volt deleted file mode 100644 index 5ab72115..00000000 --- a/app/Http/Desktop/Views/teaching/menu.volt +++ /dev/null @@ -1,10 +0,0 @@ -
    -
    教学中心
    - -
    diff --git a/app/Http/Desktop/Views/topic/show.volt b/app/Http/Desktop/Views/topic/show.volt deleted file mode 100644 index 9d953fb7..00000000 --- a/app/Http/Desktop/Views/topic/show.volt +++ /dev/null @@ -1,19 +0,0 @@ -{% extends 'templates/main.volt' %} - -{% block content %} - - {% set courses_url = url({'for':'desktop.topic.courses','id':topic.id}) %} - -
    -
    {{ topic.title }}
    -
    - -
    - -{% endblock %} - -{% block include_js %} - - {{ js_include('desktop/js/topic.show.js') }} - -{% endblock %} \ No newline at end of file diff --git a/app/Http/Desktop/Controllers/AccountController.php b/app/Http/Home/Controllers/AccountController.php similarity index 62% rename from app/Http/Desktop/Controllers/AccountController.php rename to app/Http/Home/Controllers/AccountController.php index 65790af7..92969579 100644 --- a/app/Http/Desktop/Controllers/AccountController.php +++ b/app/Http/Home/Controllers/AccountController.php @@ -1,12 +1,12 @@ authUser->id > 0) { - $this->response->redirect('/'); + return $this->response->redirect('/'); } $service = new AccountService(); - $captcha = $service->getSectionSettings('captcha'); + $captcha = $service->getSettings('captcha'); $returnUrl = $this->request->getHTTPReferer(); @@ -35,7 +35,7 @@ class AccountController extends Controller } /** - * @Post("/register", name="desktop.account.do_register") + * @Post("/register", name="home.account.do_register") */ public function doRegisterAction() { @@ -43,7 +43,7 @@ class AccountController extends Controller $service->register(); - $returnUrl = $this->request->getPost('return_url'); + $returnUrl = $this->request->getPost('return_url', 'string'); $content = [ 'location' => $returnUrl ?: '/', @@ -54,7 +54,7 @@ class AccountController extends Controller } /** - * @Get("/login", name="desktop.account.login") + * @Get("/login", name="home.account.login") */ public function loginAction() { @@ -64,7 +64,7 @@ class AccountController extends Controller $service = new AccountService(); - $captcha = $service->getSectionSettings('captcha'); + $captcha = $service->getSettings('captcha'); $returnUrl = $this->request->getHTTPReferer(); @@ -73,7 +73,7 @@ class AccountController extends Controller } /** - * @Post("/password/login", name="desktop.account.pwd_login") + * @Post("/password/login", name="home.account.pwd_login") */ public function loginByPasswordAction() { @@ -81,9 +81,9 @@ class AccountController extends Controller $service->loginByPassword(); - $returnUrl = $this->request->getPost('return_url'); + $returnUrl = $this->request->getPost('return_url', 'string'); - $location = $returnUrl ?: $this->url->get(['for' => 'desktop.index']); + $location = $returnUrl ?: $this->url->get(['for' => 'home.index']); $content = ['location' => $location]; @@ -91,7 +91,7 @@ class AccountController extends Controller } /** - * @Post("/verify/login", name="desktop.account.verify_login") + * @Post("/verify/login", name="home.account.verify_login") */ public function loginByVerifyAction() { @@ -99,9 +99,9 @@ class AccountController extends Controller $service->loginByVerify(); - $returnUrl = $this->request->getPost('return_url'); + $returnUrl = $this->request->getPost('return_url', 'string'); - $location = $returnUrl ?: $this->url->get(['for' => 'desktop.index']); + $location = $returnUrl ?: $this->url->get(['for' => 'home.index']); $content = ['location' => $location]; @@ -109,7 +109,7 @@ class AccountController extends Controller } /** - * @Get("/logout", name="desktop.account.logout") + * @Get("/logout", name="home.account.logout") */ public function logoutAction() { @@ -117,38 +117,38 @@ class AccountController extends Controller $service->logout(); - $this->response->redirect(['for' => 'desktop.index']); + $this->response->redirect(['for' => 'home.index']); } /** - * @Get("/password/forget", name="desktop.account.forget_pwd") + * @Get("/password/forget", name="home.account.forget_pwd") */ public function forgetPasswordAction() { if ($this->authUser->id > 0) { - $this->response->redirect(['for' => 'desktop.index']); + $this->response->redirect(['for' => 'home.index']); } $service = new AccountService(); - $captcha = $service->getSectionSettings('captcha'); + $captcha = $service->getSettings('captcha'); $this->view->pick('account/forget_password'); $this->view->setVar('captcha', $captcha); } /** - * @Get("/password/edit", name="desktop.account.edit_pwd") + * @Get("/password/edit", name="home.account.edit_pwd") */ public function editPasswordAction() { if ($this->authUser->id == 0) { - $this->response->redirect(['for' => 'desktop.account.login']); + $this->response->redirect(['for' => 'home.account.login']); } $service = new AccountService(); - $captcha = $service->getSectionSettings('captcha'); + $captcha = $service->getSettings('captcha'); $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); $this->view->pick('account/edit_password'); @@ -156,17 +156,17 @@ class AccountController extends Controller } /** - * @Get("/phone/edit", name="desktop.account.edit_phone") + * @Get("/phone/edit", name="home.account.edit_phone") */ public function editPhoneAction() { if ($this->authUser->id == 0) { - $this->response->redirect(['for' => 'desktop.account.login']); + $this->response->redirect(['for' => 'home.account.login']); } $service = new AccountService(); - $captcha = $service->getSectionSettings('captcha'); + $captcha = $service->getSettings('captcha'); $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); $this->view->pick('account/edit_phone'); @@ -174,17 +174,17 @@ class AccountController extends Controller } /** - * @Get("/email/edit", name="desktop.account.edit_email") + * @Get("/email/edit", name="home.account.edit_email") */ public function editEmailAction() { if ($this->authUser->id == 0) { - $this->response->redirect(['for' => 'desktop.account.login']); + $this->response->redirect(['for' => 'home.account.login']); } $service = new AccountService(); - $captcha = $service->getSectionSettings('captcha'); + $captcha = $service->getSettings('captcha'); $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); $this->view->pick('account/edit_email'); @@ -192,7 +192,7 @@ class AccountController extends Controller } /** - * @Post("/password/reset", name="desktop.account.reset_pwd") + * @Post("/password/reset", name="home.account.reset_pwd") */ public function resetPasswordAction() { @@ -200,7 +200,7 @@ class AccountController extends Controller $service->handle(); - $loginUrl = $this->url->get(['for' => 'desktop.account.login']); + $loginUrl = $this->url->get(['for' => 'home.account.login']); $content = [ 'location' => $loginUrl, @@ -211,7 +211,7 @@ class AccountController extends Controller } /** - * @Post("/phone/update", name="desktop.account.update_phone") + * @Post("/phone/update", name="home.account.update_phone") */ public function updatePhoneAction() { @@ -225,7 +225,7 @@ class AccountController extends Controller } /** - * @Post("/email/update", name="desktop.account.update_email") + * @Post("/email/update", name="home.account.update_email") */ public function updateEmailAction() { @@ -239,7 +239,7 @@ class AccountController extends Controller } /** - * @Post("/password/update", name="desktop.account.update_pwd") + * @Post("/password/update", name="home.account.update_pwd") */ public function updatePasswordAction() { diff --git a/app/Http/Desktop/Controllers/ChapterController.php b/app/Http/Home/Controllers/ChapterController.php similarity index 56% rename from app/Http/Desktop/Controllers/ChapterController.php rename to app/Http/Home/Controllers/ChapterController.php index b575881a..1db71e31 100644 --- a/app/Http/Desktop/Controllers/ChapterController.php +++ b/app/Http/Home/Controllers/ChapterController.php @@ -1,13 +1,14 @@ response->redirect([ - 'for' => 'desktop.course.show', + return $this->response->redirect([ + 'for' => 'home.course.show', 'id' => $chapter['course']['id'], ]); } - $service = new CourseCatalogService(); + $service = new CourseChapterListService(); $catalog = $service->handle($chapter['course']['id']); $this->seo->prependTitle(['章节', $chapter['title'], $chapter['course']['title']]); - $this->seo->setDescription($chapter['summary']); + + if (!empty($chapter['summary'])) { + $this->seo->setDescription($chapter['summary']); + } if ($chapter['model'] == CourseModel::MODEL_VOD) { $this->view->pick('chapter/vod'); - } elseif ($chapter['model'] == CourseModel::MODEL_LIVE) { - $this->view->pick('chapter/live'); } elseif ($chapter['model'] == CourseModel::MODEL_READ) { $this->view->pick('chapter/read'); + } elseif ($chapter['model'] == CourseModel::MODEL_LIVE) { + if ($chapter['status'] == LiveModel::STATUS_ACTIVE) { + $this->view->pick('chapter/live_active'); + } elseif ($chapter['status'] == LiveModel::STATUS_INACTIVE) { + $this->view->pick('chapter/live_inactive'); + } elseif ($chapter['status'] == LiveModel::STATUS_FORBID) { + $this->view->pick('chapter/live_forbid'); + } } $this->view->setVar('chapter', $chapter); @@ -53,7 +63,7 @@ class ChapterController extends Controller } /** - * @Get("/{id:[0-9]+}/danmu", name="desktop.chapter.danmu") + * @Get("/{id:[0-9]+}/danmu", name="home.chapter.danmu") */ public function danmuAction($id) { @@ -65,7 +75,7 @@ class ChapterController extends Controller } /** - * @Post("/{id:[0-9]+}/like", name="desktop.chapter.like") + * @Post("/{id:[0-9]+}/like", name="home.chapter.like") */ public function likeAction($id) { @@ -81,7 +91,7 @@ class ChapterController extends Controller } /** - * @Post("/{id:[0-9]+}/learning", name="desktop.chapter.learning") + * @Post("/{id:[0-9]+}/learning", name="home.chapter.learning") */ public function learningAction($id) { diff --git a/app/Http/Desktop/Controllers/ConsultController.php b/app/Http/Home/Controllers/ConsultController.php similarity index 69% rename from app/Http/Desktop/Controllers/ConsultController.php rename to app/Http/Home/Controllers/ConsultController.php index e1d2078f..e31c1f32 100644 --- a/app/Http/Desktop/Controllers/ConsultController.php +++ b/app/Http/Home/Controllers/ConsultController.php @@ -1,13 +1,13 @@ siteInfo = $this->getSiteInfo(); + $this->authUser = $this->getAuthUser(); $this->checkSiteStatus(); @@ -59,7 +61,11 @@ class Controller extends \Phalcon\Mvc\Controller $this->checkCsrfToken(); } - $this->checkRateLimit(); + $config = $this->getConfig(); + + if ($config->path('throttle.enabled')) { + $this->checkRateLimit(); + } return true; } @@ -68,7 +74,6 @@ class Controller extends \Phalcon\Mvc\Controller { $this->seo = $this->getSeo(); $this->navs = $this->getNavs(); - $this->authUser = $this->getAuthUser(); $this->appInfo = $this->getAppInfo(); $this->imInfo = $this->getImInfo(); @@ -85,7 +90,7 @@ class Controller extends \Phalcon\Mvc\Controller protected function getAuthUser() { /** - * @var DesktopAuth $auth + * @var HomeAuth $auth */ $auth = $this->getDI()->get('auth'); @@ -120,16 +125,35 @@ class Controller extends \Phalcon\Mvc\Controller { $cache = new SettingCache(); + $websocket = $this->getConfig()->get('websocket'); + + /** + * ssl通过nginx转发实现 + */ + if ($this->request->isSecure()) { + $websocket->connect_url = sprintf('wss://%s/wss', $this->request->getHttpHost()); + } else { + $websocket->connect_url = sprintf('ws://%s', $websocket->connect_address); + } + return [ 'main' => $cache->get('im.main'), 'cs' => $cache->get('im.cs'), - 'websocket' => $this->config->websocket, + 'ws' => $websocket, ]; } + /** + * @return Config + */ + protected function getConfig() + { + return $this->getDI()->get('config'); + } + protected function checkSiteStatus() { - if ($this->siteInfo['enabled'] == 0) { + if ($this->siteInfo['status'] == 'closed') { $this->dispatcher->forward([ 'controller' => 'error', 'action' => 'maintain', diff --git a/app/Http/Desktop/Controllers/CourseController.php b/app/Http/Home/Controllers/CourseController.php similarity index 67% rename from app/Http/Desktop/Controllers/CourseController.php rename to app/Http/Home/Controllers/CourseController.php index 06019814..c06fba43 100644 --- a/app/Http/Desktop/Controllers/CourseController.php +++ b/app/Http/Home/Controllers/CourseController.php @@ -1,19 +1,19 @@ handle($id); - $service = new CourseCatalogService(); + $service = new CourseChapterListService(); $chapters = $service->handle($id); @@ -90,7 +90,7 @@ class CourseController extends Controller } /** - * @Get("/{id:[0-9]+}/packages", name="desktop.course.packages") + * @Get("/{id:[0-9]+}/packages", name="home.course.packages") */ public function packagesAction($id) { @@ -99,12 +99,11 @@ class CourseController extends Controller $packages = $service->handle($id); $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); - $this->view->pick('course/packages'); $this->view->setVar('packages', $packages); } /** - * @Get("/{id:[0-9]+}/consults", name="desktop.course.consults") + * @Get("/{id:[0-9]+}/consults", name="home.course.consults") */ public function consultsAction($id) { @@ -115,12 +114,11 @@ class CourseController extends Controller $pager->target = 'tab-consults'; $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); - $this->view->pick('course/consults'); $this->view->setVar('pager', $pager); } /** - * @Get("/{id:[0-9]+}/reviews", name="desktop.course.reviews") + * @Get("/{id:[0-9]+}/reviews", name="home.course.reviews") */ public function reviewsAction($id) { @@ -131,12 +129,11 @@ class CourseController extends Controller $pager->target = 'tab-reviews'; $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); - $this->view->pick('course/reviews'); $this->view->setVar('pager', $pager); } /** - * @Get("/{id:[0-9]+}/recommended", name="desktop.course.recommended") + * @Get("/{id:[0-9]+}/recommended", name="home.course.recommended") */ public function recommendedAction($id) { @@ -145,12 +142,11 @@ class CourseController extends Controller $courses = $service->handle($id); $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); - $this->view->pick('course/recommended'); $this->view->setVar('courses', $courses); } /** - * @Get("/{id:[0-9]+}/related", name="desktop.course.related") + * @Get("/{id:[0-9]+}/related", name="home.course.related") */ public function relatedAction($id) { @@ -159,12 +155,11 @@ class CourseController extends Controller $courses = $service->handle($id); $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); - $this->view->pick('course/related'); $this->view->setVar('courses', $courses); } /** - * @Get("/{id:[0-9]+}/topics", name="desktop.course.topics") + * @Get("/{id:[0-9]+}/topics", name="home.course.topics") */ public function topicsAction($id) { @@ -173,12 +168,11 @@ class CourseController extends Controller $topics = $service->handle($id); $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); - $this->view->pick('course/topics'); $this->view->setVar('topics', $topics); } /** - * @Post("/{id:[0-9]+}/favorite", name="desktop.course.favorite") + * @Post("/{id:[0-9]+}/favorite", name="home.course.favorite") */ public function favoriteAction($id) { diff --git a/app/Http/Desktop/Controllers/DanmuController.php b/app/Http/Home/Controllers/DanmuController.php similarity index 63% rename from app/Http/Desktop/Controllers/DanmuController.php rename to app/Http/Home/Controllers/DanmuController.php index 5897614c..908b5290 100644 --- a/app/Http/Desktop/Controllers/DanmuController.php +++ b/app/Http/Home/Controllers/DanmuController.php @@ -1,9 +1,9 @@ authUser->id == 0) { - return $this->response->redirect(['for' => 'desktop.account.login']); + return $this->response->redirect(['for' => 'home.account.login']); } } /** - * @Get("/", name="desktop.im.index") + * @Get("/", name="home.im.index") */ public function indexAction() { @@ -44,7 +44,7 @@ class ImController extends Controller } /** - * @Get("/cs", name="desktop.im.cs") + * @Get("/cs", name="home.im.cs") */ public function csAction() { @@ -56,7 +56,7 @@ class ImController extends Controller } /** - * @Get("/init", name="desktop.im.init") + * @Get("/init", name="home.im.init") */ public function initAction() { @@ -68,7 +68,7 @@ class ImController extends Controller } /** - * @Get("/group/users", name="desktop.im.group_users") + * @Get("/group/users", name="home.im.group_users") */ public function groupUsersAction() { @@ -80,7 +80,7 @@ class ImController extends Controller } /** - * @Get("/msgbox", name="desktop.im.msgbox") + * @Get("/msgbox", name="home.im.msgbox") */ public function msgboxAction() { @@ -88,12 +88,11 @@ class ImController extends Controller $pager = $service->getNotices(); - $this->view->pick('im/msgbox'); $this->view->setVar('pager', $pager); } /** - * @Get("/chatlog", name="desktop.im.chatlog") + * @Get("/chatlog", name="home.im.chatlog") */ public function chatlogAction() { @@ -102,18 +101,17 @@ class ImController extends Controller $pager = $service->getChatMessages(); $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); - $this->view->pick('im/chatlog'); $this->view->setVar('pager', $pager); } /** - * @Get("/friend/msg/unread", name="desktop.im.unread_friend_msg") + * @Get("/friend/msg/unread", name="home.im.unread_friend_msg") */ public function unreadFriendMessageAction() { $service = new ImService(); - $id = $this->request->getQuery('id'); + $id = $this->request->getQuery('id', 'int'); $service->pullUnreadFriendMessages($id); @@ -121,7 +119,7 @@ class ImController extends Controller } /** - * @Get("/notice/unread", name="desktop.im.unread_notice") + * @Get("/notice/unread", name="home.im.unread_notice") */ public function unreadNoticeAction() { @@ -133,7 +131,7 @@ class ImController extends Controller } /** - * @Get("/notice", name="desktop.im.notice") + * @Get("/notice", name="home.im.notice") */ public function noticeAction() { @@ -145,7 +143,7 @@ class ImController extends Controller } /** - * @Post("/notice/read", name="desktop.im.read_notice") + * @Post("/notice/read", name="home.im.read_notice") */ public function readNoticeAction() { @@ -157,7 +155,7 @@ class ImController extends Controller } /** - * @Get("/friend/status", name="desktop.im.friend_status") + * @Get("/friend/status", name="home.im.friend_status") */ public function friendStatusAction() { @@ -169,7 +167,7 @@ class ImController extends Controller } /** - * @Get("/chat/history", name="desktop.im.chat_history") + * @Get("/chat/history", name="home.im.chat_history") */ public function chatHistoryAction() { @@ -181,7 +179,7 @@ class ImController extends Controller } /** - * @Post("/user/bind", name="desktop.im.bind_user") + * @Post("/user/bind", name="home.im.bind_user") */ public function bindUserAction() { @@ -193,12 +191,12 @@ class ImController extends Controller } /** - * @Post("/msg/chat/send", name="desktop.im.send_chat_msg") + * @Post("/msg/chat/send", name="home.im.send_chat_msg") */ public function sendChatMessageAction() { - $from = $this->request->getPost('from'); - $to = $this->request->getPost('to'); + $from = $this->request->getPost('from', 'string'); + $to = $this->request->getPost('to', 'string'); $service = new ImService(); @@ -208,12 +206,12 @@ class ImController extends Controller } /** - * @Post("/msg/cs/send", name="desktop.im.send_cs_msg") + * @Post("/msg/cs/send", name="home.im.send_cs_msg") */ public function sendCsMessageAction() { - $from = $this->request->getPost('from'); - $to = $this->request->getPost('to'); + $from = $this->request->getPost('from', 'string'); + $to = $this->request->getPost('to', 'string'); $service = new ImService(); @@ -223,7 +221,7 @@ class ImController extends Controller } /** - * @Post("/status/update", name="desktop.im.update_status") + * @Post("/status/update", name="home.im.update_status") */ public function updateStatusAction() { @@ -235,7 +233,7 @@ class ImController extends Controller } /** - * @Post("/sign/update", name="desktop.desktop.im.update_sign") + * @Post("/sign/update", name="home.home.im.update_sign") */ public function updateSignatureAction() { @@ -247,7 +245,7 @@ class ImController extends Controller } /** - * @Post("/skin/update", name="desktop.desktop.im.update_skin") + * @Post("/skin/update", name="home.home.im.update_skin") */ public function updateSKinAction() { @@ -259,7 +257,7 @@ class ImController extends Controller } /** - * @Post("/friend/apply", name="desktop.im.apply_friend") + * @Post("/friend/apply", name="home.im.apply_friend") */ public function applyFriendAction() { @@ -273,7 +271,7 @@ class ImController extends Controller } /** - * @Post("/friend/accept", name="desktop.im.accept_friend") + * @Post("/friend/accept", name="home.im.accept_friend") */ public function acceptFriendAction() { @@ -285,7 +283,7 @@ class ImController extends Controller } /** - * @Post("/friend/refuse", name="desktop.im.refuse_friend") + * @Post("/friend/refuse", name="home.im.refuse_friend") */ public function refuseFriendAction() { @@ -297,7 +295,7 @@ class ImController extends Controller } /** - * @Post("/group/apply", name="desktop.im.apply_group") + * @Post("/group/apply", name="home.im.apply_group") */ public function applyGroupAction() { @@ -311,7 +309,7 @@ class ImController extends Controller } /** - * @Post("/group/accept", name="desktop.desktop.im.accept_group") + * @Post("/group/accept", name="home.home.im.accept_group") */ public function acceptGroupAction() { @@ -323,7 +321,7 @@ class ImController extends Controller } /** - * @Post("/group/refuse", name="desktop.desktop.im.refuse_group") + * @Post("/group/refuse", name="home.home.im.refuse_group") */ public function refuseGroupAction() { @@ -335,7 +333,7 @@ class ImController extends Controller } /** - * @Post("/friend/{id:[0-9]+}/quit", name="desktop.im.quit_friend") + * @Post("/friend/{id:[0-9]+}/quit", name="home.im.quit_friend") */ public function quitFriendAction($id) { @@ -349,7 +347,7 @@ class ImController extends Controller } /** - * @Post("/group/{id:[0-9]+}/quit", name="desktop.im.quit_group") + * @Post("/group/{id:[0-9]+}/quit", name="home.im.quit_group") */ public function quitGroupAction($id) { diff --git a/app/Http/Desktop/Controllers/ImGroupController.php b/app/Http/Home/Controllers/ImGroupController.php similarity index 80% rename from app/Http/Desktop/Controllers/ImGroupController.php rename to app/Http/Home/Controllers/ImGroupController.php index 12329885..bde92ad8 100644 --- a/app/Http/Desktop/Controllers/ImGroupController.php +++ b/app/Http/Home/Controllers/ImGroupController.php @@ -1,8 +1,8 @@ seo->setKeywords($this->siteInfo['keywords']); + $this->seo->setDescription($this->siteInfo['description']); + + $template = $this->siteInfo['index_tpl'] ?? 'full'; + + if ($template == 'full') { + $this->fullIndex(); + } else { + $this->simpleIndex(); + } + } + + protected function fullIndex() + { + $service = new IndexService(); + + $this->view->pick('index/full'); + $this->view->setVar('lives', $service->getLives()); + $this->view->setVar('slides', $service->getSlides()); + $this->view->setVar('new_courses', $service->getNewCourses()); + $this->view->setVar('free_courses', $service->getFreeCourses()); + $this->view->setVar('vip_courses', $service->getVipCourses()); + } + + protected function simpleIndex() + { + $service = new IndexService(); + + $this->view->pick('index/simple'); + $this->view->setVar('lives', $service->getLives()); + $this->view->setVar('slides', $service->getSlides()); + $this->view->setVar('new_courses', $service->getSimpleNewCourses()); + $this->view->setVar('free_courses', $service->getSimpleFreeCourses()); + $this->view->setVar('vip_courses', $service->getSimpleVipCourses()); + } + +} diff --git a/app/Http/Desktop/Controllers/LayerController.php b/app/Http/Home/Controllers/LayerController.php similarity index 88% rename from app/Http/Desktop/Controllers/LayerController.php rename to app/Http/Home/Controllers/LayerController.php index c0c420c3..2d15d84b 100644 --- a/app/Http/Desktop/Controllers/LayerController.php +++ b/app/Http/Home/Controllers/LayerController.php @@ -1,9 +1,9 @@ getDI()->get('auth'); diff --git a/app/Http/Desktop/Controllers/LiveController.php b/app/Http/Home/Controllers/LiveController.php similarity index 63% rename from app/Http/Desktop/Controllers/LiveController.php rename to app/Http/Home/Controllers/LiveController.php index dbfb011c..9f205c26 100644 --- a/app/Http/Desktop/Controllers/LiveController.php +++ b/app/Http/Home/Controllers/LiveController.php @@ -1,8 +1,8 @@ getStats($id); - - $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); - $this->view->pick('chapter/live_stats'); - $this->view->setVar('stats', $stats); - } - - /** - * @Get("/{id:[0-9]+}/chats", name="desktop.live.chats") + * @Get("/{id:[0-9]+}/chats", name="home.live.chats") */ public function chatsAction($id) { @@ -43,7 +29,7 @@ class LiveController extends Controller } /** - * @Get("/{id:[0-9]+}/stats", name="desktop.live.stats") + * @Get("/{id:[0-9]+}/stats", name="home.live.stats") */ public function statsAction($id) { @@ -55,7 +41,19 @@ class LiveController extends Controller } /** - * @Post("/{id:[0-9]+}/user/bind", name="desktop.live.bind_user") + * @Get("/{id:[0-9]+}/status", name="home.live.status") + */ + public function statusAction($id) + { + $service = new LiveService(); + + $status = $service->getStatus($id); + + return $this->jsonSuccess(['status' => $status]); + } + + /** + * @Post("/{id:[0-9]+}/user/bind", name="home.live.bind_user") */ public function bindUserAction($id) { @@ -67,7 +65,7 @@ class LiveController extends Controller } /** - * @Post("/{id:[0-9]+}/msg/send", name="desktop.live.send_msg") + * @Post("/{id:[0-9]+}/msg/send", name="home.live.send_msg") */ public function sendMessageAction($id) { diff --git a/app/Http/Desktop/Controllers/OrderController.php b/app/Http/Home/Controllers/OrderController.php similarity index 50% rename from app/Http/Desktop/Controllers/OrderController.php rename to app/Http/Home/Controllers/OrderController.php index 8e2c066d..9f4550cb 100644 --- a/app/Http/Desktop/Controllers/OrderController.php +++ b/app/Http/Home/Controllers/OrderController.php @@ -1,12 +1,13 @@ authUser->id == 0) { + $this->response->redirect(['for' => 'home.account.login']); + return false; + } + + return true; + } + /** - * @Get("/info", name="desktop.order.info") + * @Get("/info", name="home.order.info") */ public function infoAction() { - $sn = $this->request->getQuery('sn'); + $sn = $this->request->getQuery('sn', 'string'); $service = new OrderInfoService(); @@ -31,12 +44,12 @@ class OrderController extends Controller } /** - * @Get("/confirm", name="desktop.order.confirm") + * @Get("/confirm", name="home.order.confirm") */ public function confirmAction() { - $itemId = $this->request->getQuery('item_id'); - $itemType = $this->request->getQuery('item_type'); + $itemId = $this->request->getQuery('item_id', 'int'); + $itemType = $this->request->getQuery('item_type', 'int'); $service = new OrderConfirmService(); @@ -46,7 +59,7 @@ class OrderController extends Controller } /** - * @Post("/create", name="desktop.order.create") + * @Post("/create", name="home.order.create") */ public function createAction() { @@ -54,35 +67,35 @@ class OrderController extends Controller $order = $service->handle(); - $location = $this->url->get(['for' => 'desktop.order.pay'], ['sn' => $order->sn]); + $location = $this->url->get(['for' => 'home.order.pay'], ['sn' => $order->sn]); return $this->jsonSuccess(['location' => $location]); } /** - * @Get("/pay", name="desktop.order.pay") + * @Get("/pay", name="home.order.pay") */ public function payAction() { - $sn = $this->request->getQuery('sn'); + $sn = $this->request->getQuery('sn', 'string'); $service = new OrderInfoService(); $order = $service->handle($sn); if ($order['status'] != OrderModel::STATUS_PENDING) { - $this->response->redirect(['for' => 'desktop.my.orders']); + $this->response->redirect(['for' => 'home.my.orders']); } $this->view->setVar('order', $order); } /** - * @Post("/cancel", name="desktop.order.cancel") + * @Post("/cancel", name="home.order.cancel") */ public function cancelAction() { - $sn = $this->request->getPost('sn'); + $sn = $this->request->getPost('sn', 'string'); $service = new OrderCancelService(); diff --git a/app/Http/Desktop/Controllers/PackageController.php b/app/Http/Home/Controllers/PackageController.php similarity index 62% rename from app/Http/Desktop/Controllers/PackageController.php rename to app/Http/Home/Controllers/PackageController.php index a57f684f..261cbb47 100644 --- a/app/Http/Desktop/Controllers/PackageController.php +++ b/app/Http/Home/Controllers/PackageController.php @@ -1,9 +1,9 @@ request->getQuery('text'); + $text = $this->request->getQuery('text', 'string'); $level = $this->request->getQuery('level', 'int', 0); $size = $this->request->getQuery('size', 'int', 5); @@ -63,7 +63,7 @@ class PublicController extends \Phalcon\Mvc\Controller } /** - * @Post("/token/refresh", name="desktop.refresh_token") + * @Post("/token/refresh", name="home.refresh_token") */ public function refreshTokenAction() { @@ -77,7 +77,7 @@ class PublicController extends \Phalcon\Mvc\Controller } /** - * @Post("/alipay/notify", name="desktop.alipay_notify") + * @Post("/alipay/notify", name="home.alipay_notify") */ public function alipayNotifyAction() { @@ -93,7 +93,7 @@ class PublicController extends \Phalcon\Mvc\Controller } /** - * @Post("/wxpay/notify", name="desktop.wxpay_notify") + * @Post("/wxpay/notify", name="home.wxpay_notify") */ public function wxpayNotifyAction() { @@ -109,7 +109,7 @@ class PublicController extends \Phalcon\Mvc\Controller } /** - * @Post("/live/notify", name="desktop.live_notify") + * @Post("/live/notify", name="home.live_notify") */ public function liveNotifyAction() { diff --git a/app/Http/Desktop/Controllers/RefundController.php b/app/Http/Home/Controllers/RefundController.php similarity index 59% rename from app/Http/Desktop/Controllers/RefundController.php rename to app/Http/Home/Controllers/RefundController.php index cec1661e..327cc361 100644 --- a/app/Http/Desktop/Controllers/RefundController.php +++ b/app/Http/Home/Controllers/RefundController.php @@ -1,12 +1,12 @@ request->getQuery('sn'); + $sn = $this->request->getQuery('sn', 'string'); $service = new OrderInfoService(); @@ -36,7 +36,7 @@ class RefundController extends Controller } /** - * @Post("/create", name="desktop.refund.create") + * @Post("/create", name="home.refund.create") */ public function createAction() { @@ -45,7 +45,7 @@ class RefundController extends Controller $service->handle(); $content = [ - 'location' => $this->url->get(['for' => 'desktop.my.refunds']), + 'location' => $this->url->get(['for' => 'home.my.refunds']), 'msg' => '申请退款成功', ]; @@ -53,11 +53,11 @@ class RefundController extends Controller } /** - * @Get("/info", name="desktop.refund.info") + * @Get("/info", name="home.refund.info") */ public function infoAction() { - $sn = $this->request->getQuery('sn'); + $sn = $this->request->getQuery('sn', 'string'); $service = new RefundInfoService(); @@ -68,18 +68,18 @@ class RefundController extends Controller } /** - * @Post("/cancel", name="desktop.refund.cancel") + * @Post("/cancel", name="home.refund.cancel") */ public function cancelAction() { - $sn = $this->request->getPost('sn'); + $sn = $this->request->getPost('sn', 'string'); $service = new RefundCancelService(); $service->handle($sn); $content = [ - 'location' => $this->url->get(['for' => 'desktop.my.refunds']), + 'location' => $this->url->get(['for' => 'home.my.refunds']), 'msg' => '取消退款成功', ]; diff --git a/app/Http/Desktop/Controllers/ReviewController.php b/app/Http/Home/Controllers/ReviewController.php similarity index 71% rename from app/Http/Desktop/Controllers/ReviewController.php rename to app/Http/Home/Controllers/ReviewController.php index d49a2a58..48b09a67 100644 --- a/app/Http/Desktop/Controllers/ReviewController.php +++ b/app/Http/Home/Controllers/ReviewController.php @@ -1,12 +1,12 @@ request->get('query', ['trim', 'string']); - $type = $this->request->get('type', ['trim'], 'course'); + $type = $this->request->get('type', ['trim', 'string'], 'course'); if (empty($query)) { - return $this->response->redirect(['for' => 'desktop.course.list']); + return $this->response->redirect(['for' => 'home.course.list']); } $this->seo->prependTitle(['搜索', $query]); $service = $this->getSearchService($type); - $hotQueries = $service->hotQuery(); + $hotQueries = $service->getHotQuery(); - $relatedQueries = $service->relatedQuery($query); + $relatedQueries = $service->getRelatedQuery($query); $pager = $service->search(); @@ -43,7 +43,7 @@ class SearchController extends Controller } /** - * @Get("/form", name="desktop.search.form") + * @Get("/form", name="home.search.form") */ public function formAction() { diff --git a/app/Http/Home/Controllers/TeacherConsoleController.php b/app/Http/Home/Controllers/TeacherConsoleController.php new file mode 100644 index 00000000..d98b46c7 --- /dev/null +++ b/app/Http/Home/Controllers/TeacherConsoleController.php @@ -0,0 +1,103 @@ +authUser->id == 0) { + $this->response->redirect(['for' => 'home.account.login']); + return false; + } + + return true; + } + + /** + * @Get("/index", name="home.tc.index") + */ + public function indexAction() + { + $this->dispatcher->forward(['action' => 'courses']); + } + + /** + * @Get("/courses", name="home.tc.courses") + */ + public function coursesAction() + { + $service = new CourseListService(); + + $pager = $service->handle(); + + $this->view->pick('teacher/console/courses'); + $this->view->setVar('pager', $pager); + } + + /** + * @Get("/lives", name="home.tc.lives") + */ + public function livesAction() + { + $service = new LiveListService(); + + $pager = $service->handle(); + + $this->view->pick('teacher/console/lives'); + $this->view->setVar('pager', $pager); + } + + /** + * @Get("/consults", name="home.tc.consults") + */ + public function consultsAction() + { + $service = new ConsultListService(); + + $pager = $service->handle(); + + $this->view->pick('teacher/console/consults'); + $this->view->setVar('pager', $pager); + } + + /** + * @Get("/live/{id:[0-9]+}", name="home.tc.live") + */ + public function liveAction($id) + { + $service = new LivePushUrlService(); + + $pushUrl = $service->handle($id); + + $qrcode = $this->url->get( + ['for' => 'home.qrcode'], + ['text' => urlencode($pushUrl)] + ); + + $pos = strrpos($pushUrl, '/'); + + $obs = [ + 'fms_url' => substr($pushUrl, 0, $pos + 1), + 'stream_code' => substr($pushUrl, $pos + 1), + ]; + + $this->view->pick('teacher/console/live_push'); + $this->view->setVar('qrcode', $qrcode); + $this->view->setVar('obs', $obs); + } + +} \ No newline at end of file diff --git a/app/Http/Desktop/Controllers/TeacherController.php b/app/Http/Home/Controllers/TeacherController.php similarity index 70% rename from app/Http/Desktop/Controllers/TeacherController.php rename to app/Http/Home/Controllers/TeacherController.php index ea6275e4..a6f2f2ce 100644 --- a/app/Http/Desktop/Controllers/TeacherController.php +++ b/app/Http/Home/Controllers/TeacherController.php @@ -1,8 +1,8 @@ target = 'teacher-list'; $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); - $this->view->pick('teacher/pager'); $this->view->setVar('pager', $pager); } /** - * @Get("/{id:[0-9]+}", name="desktop.teacher.show") + * @Get("/{id:[0-9]+}", name="home.teacher.show") */ public function showAction($id) { diff --git a/app/Http/Desktop/Controllers/TopicController.php b/app/Http/Home/Controllers/TopicController.php similarity index 63% rename from app/Http/Desktop/Controllers/TopicController.php rename to app/Http/Home/Controllers/TopicController.php index 349cd128..bd0375e9 100644 --- a/app/Http/Desktop/Controllers/TopicController.php +++ b/app/Http/Home/Controllers/TopicController.php @@ -1,9 +1,9 @@ handle($id); - $this->seo->prependTitle($topic['title']); + $this->seo->prependTitle(['专题', $topic['title']]); $this->seo->setDescription($topic['summary']); $this->view->setVar('topic', $topic); } /** - * @Get("/{id:[0-9]+}/courses", name="desktop.topic.courses") + * @Get("/{id:[0-9]+}/courses", name="home.topic.courses") */ public function coursesAction($id) { @@ -39,7 +39,6 @@ class TopicController extends Controller $pager->target = 'course-list'; $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); - $this->view->pick('topic/courses'); $this->view->setVar('pager', $pager); } diff --git a/app/Http/Desktop/Controllers/TradeController.php b/app/Http/Home/Controllers/TradeController.php similarity index 61% rename from app/Http/Desktop/Controllers/TradeController.php rename to app/Http/Home/Controllers/TradeController.php index 29af171c..6e1c7ad5 100644 --- a/app/Http/Desktop/Controllers/TradeController.php +++ b/app/Http/Home/Controllers/TradeController.php @@ -1,9 +1,9 @@ request->getQuery('sn'); + $sn = $this->request->getQuery('sn', 'string'); $service = new TradeInfoService(); diff --git a/app/Http/Desktop/Controllers/UploadController.php b/app/Http/Home/Controllers/UploadController.php similarity index 78% rename from app/Http/Desktop/Controllers/UploadController.php rename to app/Http/Home/Controllers/UploadController.php index d1d3453f..73da70f8 100644 --- a/app/Http/Desktop/Controllers/UploadController.php +++ b/app/Http/Home/Controllers/UploadController.php @@ -1,7 +1,7 @@ authUser->id == 0) { + $this->response->redirect(['for' => 'home.account.login']); + return false; + } + + return true; + } + + /** + * @Get("/index", name="home.uc.index") + */ + public function indexAction() + { + return $this->dispatcher->forward(['action' => 'courses']); + } + + /** + * @Get("/profile", name="home.uc.profile") + */ + public function profileAction() + { + $service = new ProfileInfoService(); + + $user = $service->handle(); + + $this->view->pick('user/console/profile'); + $this->view->setVar('user', $user); + } + + /** + * @Get("/account", name="home.uc.account") + */ + public function accountAction() + { + $service = new AccountInfoService(); + + $account = $service->handle(); + + $this->view->pick('user/console/account'); + $this->view->setVar('account', $account); + } + + /** + * @Get("/courses", name="home.uc.courses") + */ + public function coursesAction() + { + $service = new CourseListService(); + + $pager = $service->handle(); + + $this->view->pick('user/console/courses'); + $this->view->setVar('pager', $pager); + } + + /** + * @Get("/favorites", name="home.uc.favorites") + */ + public function favoritesAction() + { + $service = new FavoriteListService(); + + $pager = $service->handle(); + + $this->view->pick('user/console/favorites'); + $this->view->setVar('pager', $pager); + } + + /** + * @Get("/consults", name="home.uc.consults") + */ + public function consultsAction() + { + $service = new ConsultListService(); + + $pager = $service->handle(); + + $this->view->pick('user/console/consults'); + $this->view->setVar('pager', $pager); + } + + /** + * @Get("/reviews", name="home.uc.reviews") + */ + public function reviewsAction() + { + $service = new ReviewListService(); + + $pager = $service->handle(); + + $this->view->pick('user/console/reviews'); + $this->view->setVar('pager', $pager); + } + + /** + * @Get("/orders", name="home.uc.orders") + */ + public function ordersAction() + { + $service = new OrderListService(); + + $pager = $service->handle(); + + $this->view->pick('user/console/orders'); + $this->view->setVar('pager', $pager); + } + + /** + * @Get("/refunds", name="home.uc.refunds") + */ + public function refundsAction() + { + $service = new RefundListService(); + + $pager = $service->handle(); + + $this->view->pick('user/console/refunds'); + $this->view->setVar('pager', $pager); + } + + /** + * @Get("/friends", name="home.uc.friends") + */ + public function friendsAction() + { + $service = new FriendListService(); + + $pager = $service->handle(); + + $this->view->pick('user/console/friends'); + $this->view->setVar('pager', $pager); + } + + /** + * @Get("/groups", name="home.uc.groups") + */ + public function groupsAction() + { + $scope = $this->request->getQuery('scope', 'string', 'joined'); + + $service = new GroupListService(); + + $pager = $service->handle($scope); + + $this->view->pick('user/console/groups'); + $this->view->setVar('scope', $scope); + $this->view->setVar('pager', $pager); + } + + /** + * @Post("/profile/update", name="home.uc.update_profile") + */ + public function updateProfileAction() + { + $service = new ProfileUpdateService(); + + $service->handle(); + + $content = [ + 'location' => $this->request->getHTTPReferer(), + 'msg' => '更新资料成功', + ]; + + return $this->jsonSuccess($content); + } + +} diff --git a/app/Http/Desktop/Controllers/UserController.php b/app/Http/Home/Controllers/UserController.php similarity index 72% rename from app/Http/Desktop/Controllers/UserController.php rename to app/Http/Home/Controllers/UserController.php index 4ea12c97..d547a2b2 100644 --- a/app/Http/Desktop/Controllers/UserController.php +++ b/app/Http/Home/Controllers/UserController.php @@ -1,12 +1,12 @@ request->getQuery('type', 'trim', 'discount'); + $type = $this->request->getQuery('type', 'string', 'discount'); $service = new VipCourseListService(); @@ -45,7 +45,7 @@ class VipController extends Controller } /** - * @Get("/users", name="desktop.vip.users") + * @Get("/users", name="home.vip.users") */ public function usersAction() { diff --git a/app/Http/Desktop/Module.php b/app/Http/Home/Module.php similarity index 84% rename from app/Http/Desktop/Module.php rename to app/Http/Home/Module.php index ef1ae657..6409b508 100644 --- a/app/Http/Desktop/Module.php +++ b/app/Http/Home/Module.php @@ -1,9 +1,9 @@ setShared('auth', function () { - return new DesktopAuth(); + return new HomeAuth(); }); } diff --git a/app/Http/Desktop/Services/Account.php b/app/Http/Home/Services/Account.php similarity index 93% rename from app/Http/Desktop/Services/Account.php rename to app/Http/Home/Services/Account.php index 1005fe93..4858213d 100644 --- a/app/Http/Desktop/Services/Account.php +++ b/app/Http/Home/Services/Account.php @@ -1,10 +1,10 @@ baseUrl = $this->url->get(['for' => 'desktop.course.list']); + $this->baseUrl = $this->url->get(['for' => 'home.course.list']); } public function handleTopCategories() @@ -30,7 +30,7 @@ class CourseQuery extends Service unset($params['sc']); } - $baseUrl = $this->url->get(['for' => 'desktop.course.list']); + $baseUrl = $this->url->get(['for' => 'home.course.list']); $defaultItem = [ 'id' => 'all', @@ -78,7 +78,7 @@ class CourseQuery extends Service unset($params['sc']); } - $baseUrl = $this->url->get(['for' => 'desktop.course.list']); + $baseUrl = $this->url->get(['for' => 'home.course.list']); $defaultItem = [ 'id' => 'all', diff --git a/app/Http/Desktop/Services/Im.php b/app/Http/Home/Services/Im.php similarity index 91% rename from app/Http/Desktop/Services/Im.php rename to app/Http/Home/Services/Im.php index 3e848b1d..b988473e 100644 --- a/app/Http/Desktop/Services/Im.php +++ b/app/Http/Home/Services/Im.php @@ -1,6 +1,6 @@ request->getQuery('id'); + $id = $this->request->getQuery('id', 'int'); $validator = new ImGroupValidator(); $group = $validator->checkGroup($id); - $groupRepo = new ImGroupRepo(); + Gateway::$registerAddress = $this->getRegisterAddress(); - $users = $groupRepo->findUsers($group->id); + $userIds = Gateway::getUidListByGroup($this->getGroupName($group->id)); - if ($users->count() == 0) { + if (count($userIds) == 0) { return []; } + $userRepo = new ImUserRepo(); + + $users = $userRepo->findByIds($userIds); + $baseUrl = kg_cos_url(); $result = []; @@ -78,7 +82,7 @@ class Im extends Service public function getFriendStatus() { - $id = $this->request->getQuery('id'); + $id = $this->request->getQuery('id', 'int'); $validator = new ImUserValidator(); @@ -102,7 +106,7 @@ class Im extends Service $user = $this->getImUser($loginUser->id); - $clientId = $this->request->getPost('client_id'); + $clientId = $this->request->getPost('client_id', 'string'); Gateway::$registerAddress = $this->getRegisterAddress(); @@ -127,7 +131,7 @@ class Im extends Service $user = $this->getImUser($loginUser->id); - $status = $this->request->getPost('status'); + $status = $this->request->getPost('status', 'string'); $validator = new ImUserValidator(); @@ -144,7 +148,7 @@ class Im extends Service $user = $this->getImUser($loginUser->id); - $sign = $this->request->getPost('sign'); + $sign = $this->request->getPost('sign', 'string'); $validator = new ImUserValidator(); @@ -161,7 +165,7 @@ class Im extends Service $user = $this->getImUser($loginUser->id); - $skin = $this->request->getPost('skin'); + $skin = $this->request->getPost('skin', 'string'); $validator = new ImUserValidator(); @@ -211,7 +215,6 @@ class Im extends Service 'name' => $user->name, 'avatar' => $user->avatar, ], - 'status' => $user->status == 'online' ? 'online' : 'offline', ]); Gateway::sendToUid($friendUser->friend_id, $content); } @@ -338,9 +341,9 @@ class Im extends Service protected function getRegisterAddress() { - $config = $this->getDI()->get('config'); + $config = $this->getConfig(); - return $config->websocket->register_address; + return $config->path('websocket.register_address'); } } diff --git a/app/Http/Desktop/Services/ImCsTrait.php b/app/Http/Home/Services/ImCsTrait.php similarity index 97% rename from app/Http/Desktop/Services/ImCsTrait.php rename to app/Http/Home/Services/ImCsTrait.php index 6258971e..a86a3dc5 100644 --- a/app/Http/Desktop/Services/ImCsTrait.php +++ b/app/Http/Home/Services/ImCsTrait.php @@ -1,6 +1,6 @@ getImUser($loginUser->id); - $noticeId = $this->request->getPost('notice_id'); + $noticeId = $this->request->getPost('notice_id', 'int'); $validator = new ImNoticeValidator(); @@ -96,7 +96,7 @@ Trait ImGroupTrait $user = $this->getImUser($loginUser->id); - $noticeId = $this->request->getPost('notice_id'); + $noticeId = $this->request->getPost('notice_id', 'int'); $validator = new ImNoticeValidator(); diff --git a/app/Http/Desktop/Services/ImMessageTrait.php b/app/Http/Home/Services/ImMessageTrait.php similarity index 99% rename from app/Http/Desktop/Services/ImMessageTrait.php rename to app/Http/Home/Services/ImMessageTrait.php index d7d0dc28..c0d99dbe 100644 --- a/app/Http/Desktop/Services/ImMessageTrait.php +++ b/app/Http/Home/Services/ImMessageTrait.php @@ -1,6 +1,6 @@ get(); + + if (!$slides) return []; + + foreach ($slides as $key => $slide) { + + switch ($slide['target']) { + case SlideModel::TARGET_COURSE: + $slides[$key]['url'] = $this->url->get([ + 'for' => 'home.course.show', + 'id' => $slide['content'], + ]); + break; + case SlideModel::TARGET_PAGE: + $slides[$key]['url'] = $this->url->get([ + 'for' => 'home.page.show', + 'id' => $slide['content'], + ]); + break; + case SlideModel::TARGET_LINK: + $slides[$key]['url'] = $slide['content']; + break; + default: + break; + } + } + + return $slides; + } + + public function getLives() + { + $cache = new IndexLiveList(); + + return $cache->get(); + } + + public function getNewCourses() + { + $cache = new IndexNewCourseList(); + + $courses = $cache->get(); + + return $this->handleCategoryCourses($courses); + } + + public function getFreeCourses() + { + $cache = new IndexFreeCourseList(); + + $courses = $cache->get(); + + return $this->handleCategoryCourses($courses); + } + + public function getVipCourses() + { + $cache = new IndexVipCourseList(); + + $courses = $cache->get(); + + return $this->handleCategoryCourses($courses); + } + + public function getSimpleNewCourses() + { + $cache = new IndexSimpleNewCourseList(); + + return $cache->get(); + } + + public function getSimpleFreeCourses() + { + $cache = new IndexSimpleFreeCourseList(); + + return $cache->get(); + } + + public function getSimpleVipCourses() + { + $cache = new IndexSimpleVipCourseList(); + + return $cache->get(); + } + + protected function handleCategoryCourses($items, $limit = 8) + { + if (count($items) == 0) { + return []; + } + + foreach ($items as &$item) { + $item['courses'] = array_slice($item['courses'], 0, $limit); + } + + return $items; + } + +} diff --git a/app/Http/Desktop/Services/Live.php b/app/Http/Home/Services/Live.php similarity index 80% rename from app/Http/Desktop/Services/Live.php rename to app/Http/Home/Services/Live.php index c5ba0c10..686c9ba6 100644 --- a/app/Http/Desktop/Services/Live.php +++ b/app/Http/Home/Services/Live.php @@ -1,9 +1,8 @@ getRedis(); - $key = $this->getRedisListKey($id); + $key = $this->getRecentChatKey($id); $redis->expire($key, 3 * 3600); @@ -32,6 +31,13 @@ class Live extends Service return $result; } + public function getStatus($id) + { + $chapterLive = $this->checkChapterLive($id); + + return $chapterLive->status; + } + public function getStats($id) { $chapter = $this->checkChapter($id); @@ -53,7 +59,7 @@ class Live extends Service public function bindUser($id) { - $clientId = $this->request->getPost('client_id'); + $clientId = $this->request->getPost('client_id', 'string'); $chapter = $this->checkChapter($id); @@ -84,7 +90,7 @@ class Live extends Service public function sendMessage($id) { - $chapter = $this->checkChapterCache($id); + $chapter = $this->checkChapter($id); $user = $this->getLoginUser(); @@ -114,7 +120,7 @@ class Live extends Service $redis = $this->getRedis(); - $key = $this->getRedisListKey($id); + $key = $this->getRecentChatKey($id); $redis->lPush($key, $encodeMessage); @@ -125,31 +131,21 @@ class Live extends Service return $message; } - protected function getGroupName($id) - { - return "live_{$id}"; - } - protected function getRegisterAddress() { - $config = $this->getDI()->get('config'); + $config = $this->getConfig(); - return $config->websocket->register_address; + return $config->path('websocket.register_address'); } - protected function getRedisListKey($id) + protected function getRecentChatKey($id) { - return "live_recent_chat:{$id}"; + return "chapter_recent_chat:{$id}"; } - protected function getRedis() + protected function getGroupName($id) { - /** - * @var RedisCache $cache - */ - $cache = $this->getDI()->get('cache'); - - return $cache->getRedis(); + return "chapter_{$id}"; } } diff --git a/app/Http/Desktop/Services/Service.php b/app/Http/Home/Services/Service.php similarity index 60% rename from app/Http/Desktop/Services/Service.php rename to app/Http/Home/Services/Service.php index 04fae273..dbfe7c3b 100644 --- a/app/Http/Desktop/Services/Service.php +++ b/app/Http/Home/Services/Service.php @@ -1,6 +1,6 @@ url->get( - ['for' => 'desktop.qrcode'], + ['for' => 'home.qrcode'], ['text' => urlencode($text)] ); } diff --git a/app/Http/Desktop/Views/account/edit_email.volt b/app/Http/Home/Views/account/edit_email.volt similarity index 93% rename from app/Http/Desktop/Views/account/edit_email.volt rename to app/Http/Home/Views/account/edit_email.volt index 3c09146b..9a9b1b09 100644 --- a/app/Http/Desktop/Views/account/edit_email.volt +++ b/app/Http/Home/Views/account/edit_email.volt @@ -2,7 +2,7 @@ {% block content %} - +

    @@ -37,6 +37,6 @@ {% block include_js %} {{ js_include('https://ssl.captcha.qq.com/TCaptcha.js',false) }} - {{ js_include('desktop/js/captcha.verify.js') }} + {{ js_include('home/js/captcha.verify.js') }} {% endblock %} \ No newline at end of file diff --git a/app/Http/Desktop/Views/account/edit_password.volt b/app/Http/Home/Views/account/edit_password.volt similarity index 94% rename from app/Http/Desktop/Views/account/edit_password.volt rename to app/Http/Home/Views/account/edit_password.volt index b5ea7b28..b13a77d8 100644 --- a/app/Http/Desktop/Views/account/edit_password.volt +++ b/app/Http/Home/Views/account/edit_password.volt @@ -2,7 +2,7 @@ {% block content %} - +
    diff --git a/app/Http/Desktop/Views/account/edit_phone.volt b/app/Http/Home/Views/account/edit_phone.volt similarity index 93% rename from app/Http/Desktop/Views/account/edit_phone.volt rename to app/Http/Home/Views/account/edit_phone.volt index c4257703..d24685ca 100644 --- a/app/Http/Desktop/Views/account/edit_phone.volt +++ b/app/Http/Home/Views/account/edit_phone.volt @@ -2,7 +2,7 @@ {% block content %} - +

    @@ -37,6 +37,6 @@ {% block include_js %} {{ js_include('https://ssl.captcha.qq.com/TCaptcha.js',false) }} - {{ js_include('desktop/js/captcha.verify.js') }} + {{ js_include('home/js/captcha.verify.js') }} {% endblock %} \ No newline at end of file diff --git a/app/Http/Desktop/Views/account/forget_password.volt b/app/Http/Home/Views/account/forget_password.volt similarity index 92% rename from app/Http/Desktop/Views/account/forget_password.volt rename to app/Http/Home/Views/account/forget_password.volt index 8a2dcf16..d72ccd9d 100644 --- a/app/Http/Desktop/Views/account/forget_password.volt +++ b/app/Http/Home/Views/account/forget_password.volt @@ -4,11 +4,11 @@ @@ -34,8 +34,8 @@ {% block include_js %} {{ js_include('https://ssl.captcha.qq.com/TCaptcha.js',false) }} - {{ js_include('desktop/js/captcha.login.js') }} - {{ js_include('desktop/js/captcha.verify.js') }} + {{ js_include('home/js/captcha.login.js') }} + {{ js_include('home/js/captcha.verify.js') }} {% endblock %} diff --git a/app/Http/Desktop/Views/account/login_by_password.volt b/app/Http/Home/Views/account/login_by_password.volt similarity index 96% rename from app/Http/Desktop/Views/account/login_by_password.volt rename to app/Http/Home/Views/account/login_by_password.volt index a896cd2d..53b31fab 100644 --- a/app/Http/Desktop/Views/account/login_by_password.volt +++ b/app/Http/Home/Views/account/login_by_password.volt @@ -1,4 +1,4 @@ - +
    diff --git a/app/Http/Desktop/Views/account/login_by_verify.volt b/app/Http/Home/Views/account/login_by_verify.volt similarity index 95% rename from app/Http/Desktop/Views/account/login_by_verify.volt rename to app/Http/Home/Views/account/login_by_verify.volt index b49b5b6b..adee53ed 100644 --- a/app/Http/Desktop/Views/account/login_by_verify.volt +++ b/app/Http/Home/Views/account/login_by_verify.volt @@ -1,4 +1,4 @@ - +
    diff --git a/app/Http/Desktop/Views/account/register.volt b/app/Http/Home/Views/account/register.volt similarity index 95% rename from app/Http/Desktop/Views/account/register.volt rename to app/Http/Home/Views/account/register.volt index 5a009a17..25d65749 100644 --- a/app/Http/Desktop/Views/account/register.volt +++ b/app/Http/Home/Views/account/register.volt @@ -8,7 +8,7 @@