diff --git a/CHANGELOG.md b/CHANGELOG.md index a884b950..903b5edc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,19 @@ +### [v1.4.5](https://gitee.com/koogua/course-tencent-cloud/releases/v1.4.5)(2021-09-27) + +- 修正点击内容分享到微信会额外出现公众号二维码的问题 +- 修正后台首页提问和回答的数量统计 +- 调整登录限制(邮箱|手机)为注册限制 +- 调整订单发货为每一分钟执行一次 +- 增强课时安全性,无权限时不返回播放地址或内容 +- 抽离出文章关闭,仅我可见操作 +- 增加退出群组和解除好友接口 +- 增加删除文章和提问接口 +- 增加首页推荐教师接口 +- 增加微信公众号支付处理 +- 增加取消订单功能 +- 优化订单API结构 +- 优化计划任务 + ### [v1.4.4](https://gitee.com/koogua/course-tencent-cloud/releases/v1.4.4)(2021-09-17) - 后台增加邮件手机登录选择配置 diff --git a/app/Builders/AnswerList.php b/app/Builders/AnswerList.php index 7e47e5b4..0c3b0b99 100644 --- a/app/Builders/AnswerList.php +++ b/app/Builders/AnswerList.php @@ -58,7 +58,7 @@ class AnswerList extends Builder $userRepo = new UserRepo(); - $users = $userRepo->findByIds($ids, ['id', 'name', 'avatar']); + $users = $userRepo->findShallowUserByIds($ids); $baseUrl = kg_cos_url(); diff --git a/app/Builders/ArticleList.php b/app/Builders/ArticleList.php index 7edf86f8..7ef8ca46 100644 --- a/app/Builders/ArticleList.php +++ b/app/Builders/ArticleList.php @@ -71,7 +71,7 @@ class ArticleList extends Builder $userRepo = new UserRepo(); - $users = $userRepo->findByIds($ids, ['id', 'name', 'avatar']); + $users = $userRepo->findShallowUserByIds($ids); $baseUrl = kg_cos_url(); diff --git a/app/Builders/CategoryTreeList.php b/app/Builders/CategoryTreeList.php index ab23e991..6944aea8 100644 --- a/app/Builders/CategoryTreeList.php +++ b/app/Builders/CategoryTreeList.php @@ -69,6 +69,7 @@ class CategoryTreeList extends Builder $query->where('parent_id = 0'); $query->andWhere('published = 1'); + $query->andWhere('deleted = 0'); $query->andWhere('type = :type:', ['type' => $type]); $query->orderBy('priority ASC'); @@ -84,6 +85,7 @@ class CategoryTreeList extends Builder $query = CategoryModel::query(); $query->where('published = 1'); + $query->where('deleted = 0'); $query->andWhere('parent_id = :parent_id:', ['parent_id' => $parentId]); $query->orderBy('priority ASC'); diff --git a/app/Builders/CommentList.php b/app/Builders/CommentList.php index f300ecda..e0eb0059 100644 --- a/app/Builders/CommentList.php +++ b/app/Builders/CommentList.php @@ -32,7 +32,7 @@ class CommentList extends Builder $userRepo = new UserRepo(); - $users = $userRepo->findByIds($ids, ['id', 'name', 'avatar']); + $users = $userRepo->findShallowUserByIds($ids); $baseUrl = kg_cos_url(); diff --git a/app/Builders/ConsultList.php b/app/Builders/ConsultList.php index b356276b..a06e667c 100644 --- a/app/Builders/ConsultList.php +++ b/app/Builders/ConsultList.php @@ -79,7 +79,7 @@ class ConsultList extends Builder $userRepo = new UserRepo(); - $users = $userRepo->findByIds($ids, ['id', 'name', 'avatar']); + $users = $userRepo->findShallowUserByIds($ids); $baseUrl = kg_cos_url(); diff --git a/app/Builders/CourseList.php b/app/Builders/CourseList.php index 25c821e4..e5a3c383 100644 --- a/app/Builders/CourseList.php +++ b/app/Builders/CourseList.php @@ -62,7 +62,7 @@ class CourseList extends Builder $userRepo = new UserRepo(); - $users = $userRepo->findByIds($ids, ['id', 'name', 'avatar']); + $users = $userRepo->findShallowUserByIds($ids); $baseUrl = kg_cos_url(); diff --git a/app/Builders/DanmuList.php b/app/Builders/DanmuList.php index 8adf3c09..2ee29569 100644 --- a/app/Builders/DanmuList.php +++ b/app/Builders/DanmuList.php @@ -87,7 +87,7 @@ class DanmuList extends Builder $userRepo = new UserRepo(); - $users = $userRepo->findByIds($ids, ['id', 'name', 'avatar']); + $users = $userRepo->findShallowUserByIds($ids); $baseUrl = kg_cos_url(); diff --git a/app/Builders/ImMessageList.php b/app/Builders/ImMessageList.php index 0026bfbc..03fce797 100644 --- a/app/Builders/ImMessageList.php +++ b/app/Builders/ImMessageList.php @@ -29,7 +29,7 @@ class ImMessageList extends Builder $userRepo = new UserRepo(); - $users = $userRepo->findByIds($ids, ['id', 'name', 'avatar']); + $users = $userRepo->findShallowUserByIds($ids); $baseUrl = kg_cos_url(); diff --git a/app/Builders/LiveList.php b/app/Builders/LiveList.php index 734e4d2d..8f8102e2 100644 --- a/app/Builders/LiveList.php +++ b/app/Builders/LiveList.php @@ -48,7 +48,7 @@ class LiveList extends Builder $userRepo = new UserRepo(); - $users = $userRepo->findByIds($teacherIds, ['id', 'name', 'title', 'avatar', 'about']); + $users = $userRepo->findShallowUserByIds($teacherIds); $baseUrl = kg_cos_url(); diff --git a/app/Builders/NavTreeList.php b/app/Builders/NavTreeList.php index 185e3fa7..6801c2a5 100644 --- a/app/Builders/NavTreeList.php +++ b/app/Builders/NavTreeList.php @@ -68,6 +68,7 @@ class NavTreeList extends Builder return NavModel::query() ->where('parent_id = :parent_id:', ['parent_id' => $navId]) ->andWhere('published = 1') + ->andWhere('deleted = 0') ->orderBy('priority ASC') ->execute(); } @@ -80,7 +81,9 @@ class NavTreeList extends Builder { return NavModel::query() ->where('position = :position:', ['position' => $position]) - ->andWhere('level = 1 AND published = 1') + ->andWhere('level = 1') + ->andWhere('published = 1') + ->andWhere('deleted = 0') ->orderBy('priority ASC') ->execute(); } diff --git a/app/Builders/NotificationList.php b/app/Builders/NotificationList.php index 73067c4a..6670553d 100644 --- a/app/Builders/NotificationList.php +++ b/app/Builders/NotificationList.php @@ -32,7 +32,7 @@ class NotificationList extends Builder $userRepo = new UserRepo(); - $users = $userRepo->findByIds($ids, ['id', 'name', 'avatar']); + $users = $userRepo->findShallowUserByIds($ids); $baseUrl = kg_cos_url(); diff --git a/app/Builders/OrderList.php b/app/Builders/OrderList.php index d46f0ae6..d317d604 100644 --- a/app/Builders/OrderList.php +++ b/app/Builders/OrderList.php @@ -7,6 +7,7 @@ namespace App\Builders; +use App\Models\Course as CourseModel; use App\Models\Order as OrderModel; use App\Repos\User as UserRepo; @@ -42,7 +43,7 @@ class OrderList extends Builder public function handleItems(array $orders) { foreach ($orders as $key => $order) { - $itemInfo = $this->handleItem($order); + $itemInfo = $this->handleItemInfo($order); $orders[$key]['item_info'] = $itemInfo; } @@ -53,7 +54,7 @@ class OrderList extends Builder * @param array $order * @return array|mixed */ - public function handleItem(array $order) + public function handleItemInfo(array $order) { $itemInfo = []; @@ -72,6 +73,52 @@ class OrderList extends Builder return $itemInfo; } + /** + * @param array $order + * @return array|mixed + */ + public function handleMeInfo(array $order) + { + $me = [ + 'allow_pay' => 0, + 'allow_cancel' => 0, + 'allow_refund' => 0, + ]; + + $payStatusOk = $order['status'] == OrderModel::STATUS_PENDING ? 1 : 0; + $cancelStatusOk = $order['status'] == OrderModel::STATUS_PENDING ? 1 : 0; + $refundStatusOk = $order['status'] == OrderModel::STATUS_FINISHED ? 1 : 0; + + if ($order['item_type'] == OrderModel::ITEM_COURSE) { + + $course = $order['item_info']['course']; + + $courseModelOk = $course['model'] != CourseModel::MODEL_OFFLINE; + $refundTimeOk = $course['refund_expiry_time'] > time(); + + $me['allow_refund'] = $courseModelOk && $refundStatusOk && $refundTimeOk ? 1 : 0; + + } elseif ($order['item_type'] == OrderModel::ITEM_PACKAGE) { + + $courses = $order['item_info']['courses']; + + $refundTimeOk = false; + + foreach ($courses as $course) { + if ($course['refund_expiry_time'] > time()) { + $refundTimeOk = true; + } + } + + $me['allow_refund'] = $refundStatusOk && $refundTimeOk ? 1 : 0; + } + + $me['allow_pay'] = $payStatusOk; + $me['allow_cancel'] = $cancelStatusOk; + + return $me; + } + /** * @param string $itemInfo * @return mixed @@ -139,7 +186,7 @@ class OrderList extends Builder $userRepo = new UserRepo(); - $users = $userRepo->findByIds($ids, ['id', 'name']); + $users = $userRepo->findShallowUserByIds($ids); $result = []; diff --git a/app/Builders/QuestionFavoriteList.php b/app/Builders/QuestionFavoriteList.php index c7675389..7d5185de 100644 --- a/app/Builders/QuestionFavoriteList.php +++ b/app/Builders/QuestionFavoriteList.php @@ -72,7 +72,7 @@ class QuestionFavoriteList extends Builder $userRepo = new UserRepo(); - $users = $userRepo->findByIds($ids, ['id', 'name', 'avatar']); + $users = $userRepo->findShallowUserByIds($ids); $baseUrl = kg_cos_url(); diff --git a/app/Builders/QuestionList.php b/app/Builders/QuestionList.php index 3cb04d76..10a40a3c 100644 --- a/app/Builders/QuestionList.php +++ b/app/Builders/QuestionList.php @@ -74,7 +74,7 @@ class QuestionList extends Builder $userRepo = new UserRepo(); - $users = $userRepo->findByIds($ids, ['id', 'name', 'avatar']); + $users = $userRepo->findShallowUserByIds($ids); $baseUrl = kg_cos_url(); diff --git a/app/Builders/RefundList.php b/app/Builders/RefundList.php index 4328431d..6452288d 100644 --- a/app/Builders/RefundList.php +++ b/app/Builders/RefundList.php @@ -7,6 +7,7 @@ namespace App\Builders; +use App\Models\Refund as RefundModel; use App\Repos\Order as OrderRepo; use App\Repos\User as UserRepo; @@ -35,6 +36,24 @@ class RefundList extends Builder return $refunds; } + public function handleMeInfo(array $refund) + { + $me = [ + 'allow_cancel' => 0, + ]; + + $statusTypes = [ + RefundModel::STATUS_PENDING, + RefundModel::STATUS_APPROVED, + ]; + + if (in_array($refund['status'], $statusTypes)) { + $me['allow_cancel'] = 1; + } + + return $me; + } + public function getOrders(array $trades) { $ids = kg_array_column($trades, 'order_id'); @@ -58,11 +77,14 @@ class RefundList extends Builder $userRepo = new UserRepo(); - $users = $userRepo->findByIds($ids, ['id', 'name']); + $users = $userRepo->findShallowUserByIds($ids); + + $baseUrl = kg_cos_url(); $result = []; foreach ($users->toArray() as $user) { + $user['avatar'] = $baseUrl . $user['avatar']; $result[$user['id']] = $user; } diff --git a/app/Builders/ReportList.php b/app/Builders/ReportList.php index f858ede8..89c67218 100644 --- a/app/Builders/ReportList.php +++ b/app/Builders/ReportList.php @@ -29,7 +29,7 @@ class ReportList extends Builder $userRepo = new UserRepo(); - $users = $userRepo->findByIds($ids, ['id', 'name', 'avatar']); + $users = $userRepo->findShallowUserByIds($ids); $baseUrl = kg_cos_url(); diff --git a/app/Builders/ReviewList.php b/app/Builders/ReviewList.php index 2cbb354a..5a931902 100644 --- a/app/Builders/ReviewList.php +++ b/app/Builders/ReviewList.php @@ -58,7 +58,7 @@ class ReviewList extends Builder $userRepo = new UserRepo(); - $users = $userRepo->findByIds($ids, ['id', 'name', 'avatar']); + $users = $userRepo->findShallowUserByIds($ids); $baseUrl = kg_cos_url(); diff --git a/app/Builders/TradeList.php b/app/Builders/TradeList.php index aa62d73d..40d17a92 100644 --- a/app/Builders/TradeList.php +++ b/app/Builders/TradeList.php @@ -58,11 +58,14 @@ class TradeList extends Builder $userRepo = new UserRepo(); - $users = $userRepo->findByIds($ids, ['id', 'name']); + $users = $userRepo->findShallowUserByIds($ids); + + $baseUrl = kg_cos_url(); $result = []; foreach ($users->toArray() as $user) { + $user['avatar'] = $baseUrl . $user['avatar']; $result[$user['id']] = $user; } diff --git a/app/Caches/CategoryList.php b/app/Caches/CategoryList.php index 8f7b6b59..5d436aa8 100644 --- a/app/Caches/CategoryList.php +++ b/app/Caches/CategoryList.php @@ -38,6 +38,7 @@ class CategoryList extends Cache ->columns(['id', 'parent_id', 'name', 'priority', 'level', 'path']) ->where('type = :type:', ['type' => $type]) ->andWhere('published = 1') + ->andWhere('deleted = 0') ->execute(); if ($categories->count() == 0) { diff --git a/app/Caches/CourseRecommendedList.php b/app/Caches/CourseRecommendedList.php index b9c27f20..51ed746d 100644 --- a/app/Caches/CourseRecommendedList.php +++ b/app/Caches/CourseRecommendedList.php @@ -70,7 +70,9 @@ class CourseRecommendedList extends Cache public function findCourses($limit = 5) { return CourseModel::query() - ->where('published = 1 AND market_price > 0') + ->where('market_price > 0') + ->andWhere('published = 1') + ->andWhere('deleted = 0') ->orderBy('RAND()') ->limit($limit) ->execute(); diff --git a/app/Caches/CourseTeacherList.php b/app/Caches/CourseTeacherList.php index f6a3c583..70314edc 100644 --- a/app/Caches/CourseTeacherList.php +++ b/app/Caches/CourseTeacherList.php @@ -51,6 +51,7 @@ class CourseTeacherList extends Cache 'id' => $user->id, 'name' => $user->name, 'avatar' => $user->avatar, + 'vip' => $user->vip, 'title' => $user->title, 'about' => $user->about, ]; diff --git a/app/Caches/HelpList.php b/app/Caches/HelpList.php index a253c3d5..2899bbd8 100644 --- a/app/Caches/HelpList.php +++ b/app/Caches/HelpList.php @@ -73,7 +73,9 @@ class HelpList extends Cache { return CategoryModel::query() ->where('type = :type:', ['type' => CategoryModel::TYPE_HELP]) - ->andWhere('level = 1 AND published = 1') + ->andWhere('level = 1') + ->andWhere('published = 1') + ->andWhere('deleted = 0') ->orderBy('priority ASC') ->execute(); } @@ -87,6 +89,7 @@ class HelpList extends Cache return HelpModel::query() ->where('category_id = :category_id:', ['category_id' => $categoryId]) ->andWhere('published = 1') + ->andWhere('deleted = 0') ->orderBy('priority ASC') ->execute(); } diff --git a/app/Caches/HotQuestionList.php b/app/Caches/HotQuestionList.php index e09b517d..dea5c8a4 100644 --- a/app/Caches/HotQuestionList.php +++ b/app/Caches/HotQuestionList.php @@ -111,7 +111,8 @@ class HotQuestionList extends Cache { return QuestionModel::query() ->where('create_time > :create_time:', ['create_time' => $createTime]) - ->andWhere('published = 1 AND deleted = 0') + ->andWhere('published = :published:', ['published' => QuestionModel::PUBLISH_APPROVED]) + ->andWhere('deleted = 0') ->orderBy('score DESC') ->limit($limit) ->execute(); diff --git a/app/Caches/ImActiveGroupList.php b/app/Caches/ImActiveGroupList.php index 24a0759d..581d3044 100644 --- a/app/Caches/ImActiveGroupList.php +++ b/app/Caches/ImActiveGroupList.php @@ -72,6 +72,8 @@ class ImActiveGroupList extends Cache ->orderBy('total_count DESC') ->where('receiver_type = :type:', ['type' => ImMessageModel::TYPE_GROUP]) ->betweenWhere('create_time', $startTime, $endTime) + ->andWhere('published = 1') + ->andWhere('deleted = 0') ->limit($limit) ->execute(); diff --git a/app/Caches/ImNewGroupList.php b/app/Caches/ImNewGroupList.php index 03cb1f5f..b76e0495 100644 --- a/app/Caches/ImNewGroupList.php +++ b/app/Caches/ImNewGroupList.php @@ -70,6 +70,7 @@ class ImNewGroupList extends Cache { return ImGroupModel::query() ->where('published = 1') + ->andWhere('deleted = 0') ->orderBy('id DESC') ->limit($limit) ->execute(); diff --git a/app/Caches/IndexArticleList.php b/app/Caches/IndexArticleList.php index 0348b0a4..6b6f20cc 100644 --- a/app/Caches/IndexArticleList.php +++ b/app/Caches/IndexArticleList.php @@ -14,7 +14,7 @@ use App\Services\Logic\Article\ArticleList as ArticleListService; class IndexArticleList extends Cache { - protected $lifetime = 1 * 86400; + protected $lifetime = 15 * 60; public function getLifetime() { @@ -30,7 +30,10 @@ class IndexArticleList extends Cache { $articleRepo = new ArticleRepo(); - $where = ['published' => ArticleModel::PUBLISH_APPROVED]; + $where = [ + 'published' => ArticleModel::PUBLISH_APPROVED, + 'deleted' => 0, + ]; $pager = $articleRepo->paginate($where, 'latest', 1, 10); diff --git a/app/Caches/IndexFeaturedCourseList.php b/app/Caches/IndexFeaturedCourseList.php index 7fe31e94..9ef38676 100644 --- a/app/Caches/IndexFeaturedCourseList.php +++ b/app/Caches/IndexFeaturedCourseList.php @@ -94,7 +94,9 @@ class IndexFeaturedCourseList extends Cache { return CategoryModel::query() ->where('type = :type:', ['type' => CategoryModel::TYPE_COURSE]) - ->andWhere('level = 1 AND published = 1') + ->andWhere('level = 1') + ->andWhere('published = 1') + ->andWhere('deleted = 0') ->orderBy('priority ASC') ->limit($limit) ->execute(); @@ -113,8 +115,9 @@ class IndexFeaturedCourseList extends Cache return CourseModel::query() ->inWhere('category_id', $categoryIds) - ->andWhere('published = 1') ->andWhere('featured = 1') + ->andWhere('published = 1') + ->andWhere('deleted = 0') ->orderBy('id DESC') ->limit($limit) ->execute(); diff --git a/app/Caches/IndexFlashSaleList.php b/app/Caches/IndexFlashSaleList.php new file mode 100644 index 00000000..587da335 --- /dev/null +++ b/app/Caches/IndexFlashSaleList.php @@ -0,0 +1,36 @@ +handle(); + + return $sales[0]['items'] ?? []; + } + +} diff --git a/app/Caches/IndexFreeCourseList.php b/app/Caches/IndexFreeCourseList.php index 071ba74c..ecd23215 100644 --- a/app/Caches/IndexFreeCourseList.php +++ b/app/Caches/IndexFreeCourseList.php @@ -94,7 +94,9 @@ class IndexFreeCourseList extends Cache { return CategoryModel::query() ->where('type = :type:', ['type' => CategoryModel::TYPE_COURSE]) - ->andWhere('level = 1 AND published = 1') + ->andWhere('level = 1') + ->andWhere('published = 1') + ->andWhere('deleted = 0') ->orderBy('priority ASC') ->limit($limit) ->execute(); @@ -113,8 +115,9 @@ class IndexFreeCourseList extends Cache return CourseModel::query() ->inWhere('category_id', $categoryIds) - ->andWhere('published = 1') ->andWhere('market_price = 0') + ->andWhere('published = 1') + ->andWhere('deleted = 0') ->orderBy('score DESC') ->limit($limit) ->execute(); diff --git a/app/Caches/IndexLiveList.php b/app/Caches/IndexLiveList.php index 6eaab7bf..6d5d0836 100644 --- a/app/Caches/IndexLiveList.php +++ b/app/Caches/IndexLiveList.php @@ -132,6 +132,8 @@ class IndexLiveList extends Cache ->addFrom(ChapterLiveModel::class, 'cl') ->join(ChapterModel::class, 'cl.chapter_id = c.id', 'c') ->betweenWhere('start_time', $startTime, $endTime) + ->andWhere('published = 1') + ->andWhere('deleted = 0') ->orderBy('start_time ASC') ->getQuery() ->execute(); diff --git a/app/Caches/IndexNewCourseList.php b/app/Caches/IndexNewCourseList.php index 6f4c9f50..1049d2c2 100644 --- a/app/Caches/IndexNewCourseList.php +++ b/app/Caches/IndexNewCourseList.php @@ -94,7 +94,9 @@ class IndexNewCourseList extends Cache { return CategoryModel::query() ->where('type = :type:', ['type' => CategoryModel::TYPE_COURSE]) - ->andWhere('level = 1 AND published = 1') + ->andWhere('level = 1') + ->andWhere('published = 1') + ->andWhere('deleted = 0') ->orderBy('priority ASC') ->limit($limit) ->execute(); @@ -114,6 +116,7 @@ class IndexNewCourseList extends Cache return CourseModel::query() ->inWhere('category_id', $categoryIds) ->andWhere('published = 1') + ->andWhere('deleted = 0') ->orderBy('id DESC') ->limit($limit) ->execute(); diff --git a/app/Caches/IndexQuestionList.php b/app/Caches/IndexQuestionList.php index db028c91..b79db98b 100644 --- a/app/Caches/IndexQuestionList.php +++ b/app/Caches/IndexQuestionList.php @@ -14,7 +14,7 @@ use App\Services\Logic\Question\QuestionList as QuestionListService; class IndexQuestionList extends Cache { - protected $lifetime = 1 * 86400; + protected $lifetime = 15 * 60; public function getLifetime() { @@ -30,7 +30,10 @@ class IndexQuestionList extends Cache { $questionRepo = new QuestionRepo(); - $where = ['published' => QuestionModel::PUBLISH_APPROVED]; + $where = [ + 'published' => QuestionModel::PUBLISH_APPROVED, + 'deleted' => 0, + ]; $pager = $questionRepo->paginate($where, 'latest', 1, 10); diff --git a/app/Caches/IndexSimpleFeaturedCourseList.php b/app/Caches/IndexSimpleFeaturedCourseList.php index a933b7cc..f3588fed 100644 --- a/app/Caches/IndexSimpleFeaturedCourseList.php +++ b/app/Caches/IndexSimpleFeaturedCourseList.php @@ -65,8 +65,9 @@ class IndexSimpleFeaturedCourseList extends Cache protected function findCourses($limit = 8) { return CourseModel::query() - ->where('published = 1') - ->andWhere('featured = 1') + ->where('featured = 1') + ->andWhere('published = 1') + ->andWhere('deleted = 0') ->orderBy('id DESC') ->limit($limit) ->execute(); diff --git a/app/Caches/IndexSimpleFreeCourseList.php b/app/Caches/IndexSimpleFreeCourseList.php index b7f187ea..a37e8779 100644 --- a/app/Caches/IndexSimpleFreeCourseList.php +++ b/app/Caches/IndexSimpleFreeCourseList.php @@ -65,8 +65,9 @@ class IndexSimpleFreeCourseList extends Cache protected function findCourses($limit = 8) { return CourseModel::query() - ->where('published = 1') - ->andWhere('market_price = 0') + ->where('market_price = 0') + ->andWhere('published = 1') + ->andWhere('deleted = 0') ->orderBy('score DESC') ->limit($limit) ->execute(); diff --git a/app/Caches/IndexSimpleNewCourseList.php b/app/Caches/IndexSimpleNewCourseList.php index 94c0b5e2..b43166a9 100644 --- a/app/Caches/IndexSimpleNewCourseList.php +++ b/app/Caches/IndexSimpleNewCourseList.php @@ -66,6 +66,7 @@ class IndexSimpleNewCourseList extends Cache { return CourseModel::query() ->where('published = 1') + ->andWhere('deleted = 0') ->orderBy('id DESC') ->limit($limit) ->execute(); diff --git a/app/Caches/IndexSimpleVipCourseList.php b/app/Caches/IndexSimpleVipCourseList.php index cda3478f..d4474287 100644 --- a/app/Caches/IndexSimpleVipCourseList.php +++ b/app/Caches/IndexSimpleVipCourseList.php @@ -65,9 +65,10 @@ class IndexSimpleVipCourseList extends Cache protected function findCourses($limit = 8) { return CourseModel::query() - ->where('published = 1') - ->andWhere('market_price > vip_price') + ->where('market_price > vip_price') ->andWhere('vip_price >= 0') + ->andWhere('published = 1') + ->andWhere('deleted = 0') ->orderBy('score DESC') ->limit($limit) ->execute(); diff --git a/app/Caches/IndexSlideList.php b/app/Caches/IndexSlideList.php index e8ca5e71..abc7d28c 100644 --- a/app/Caches/IndexSlideList.php +++ b/app/Caches/IndexSlideList.php @@ -68,6 +68,7 @@ class IndexSlideList extends Cache { return SlideModel::query() ->where('published = 1') + ->andWhere('deleted = 0') ->orderBy('priority ASC') ->limit($limit) ->execute(); diff --git a/app/Caches/IndexTeacherList.php b/app/Caches/IndexTeacherList.php new file mode 100644 index 00000000..df9d2056 --- /dev/null +++ b/app/Caches/IndexTeacherList.php @@ -0,0 +1,69 @@ +lifetime; + } + + public function getKey($id = null) + { + return 'index_teacher_list'; + } + + public function getContent($id = null) + { + $teachers = $this->findTeachers(); + + if ($teachers->count() == 0) return []; + + $result = []; + + $baseUrl = kg_cos_url(); + + foreach ($teachers->toArray() as $teacher) { + + $teacher['avatar'] = $baseUrl . $teacher['avatar']; + + $result[] = [ + 'id' => $teacher['id'], + 'name' => $teacher['name'], + 'title' => $teacher['title'], + 'avatar' => $teacher['avatar'], + 'about' => $teacher['about'], + ]; + } + + return $result; + } + + /** + * @param int $limit + * @return ResultsetInterface|Resultset|UserModel[] + */ + protected function findTeachers($limit = 8) + { + return UserModel::query() + ->where('edu_role = :edu_role:', ['edu_role' => UserModel::EDU_ROLE_TEACHER]) + ->andWhere('deleted = 0') + ->orderBy('RAND()') + ->limit($limit) + ->execute(); + } + +} diff --git a/app/Caches/IndexVipCourseList.php b/app/Caches/IndexVipCourseList.php index 201edb71..163bff1f 100644 --- a/app/Caches/IndexVipCourseList.php +++ b/app/Caches/IndexVipCourseList.php @@ -94,7 +94,9 @@ class IndexVipCourseList extends Cache { return CategoryModel::query() ->where('type = :type:', ['type' => CategoryModel::TYPE_COURSE]) - ->andWhere('level = 1 AND published = 1') + ->andWhere('level = 1') + ->andWhere('published = 1') + ->andWhere('deleted = 0') ->orderBy('priority ASC') ->limit($limit) ->execute(); @@ -113,9 +115,10 @@ class IndexVipCourseList extends Cache return CourseModel::query() ->inWhere('category_id', $categoryIds) - ->andWhere('published = 1') ->andWhere('market_price > vip_price') ->andWhere('vip_price >= 0') + ->andWhere('published = 1') + ->andWhere('deleted = 0') ->orderBy('score DESC') ->limit($limit) ->execute(); diff --git a/app/Caches/PointHotGiftList.php b/app/Caches/PointHotGiftList.php index 7b89f3cf..5fe9213a 100644 --- a/app/Caches/PointHotGiftList.php +++ b/app/Caches/PointHotGiftList.php @@ -76,6 +76,7 @@ class PointHotGiftList extends Cache { return PointGiftModel::query() ->where('published = 1') + ->andWhere('deleted = 0') ->orderBy('redeem_count DESC') ->limit($limit) ->execute(); diff --git a/app/Caches/SaleTrend.php b/app/Caches/SaleTrend.php deleted file mode 100644 index c5c7454d..00000000 --- a/app/Caches/SaleTrend.php +++ /dev/null @@ -1,70 +0,0 @@ -lifetime; - } - - public function getKey($id = null) - { - return 'sale_trend'; - } - - public function getContent($id = null) - { - - } - - /** - * @param OrderModel[] $sales - * @param int $days - * @return array - */ - protected function handleSales($sales, $days = 7) - { - $result = []; - - foreach (array_reverse(range(1, $days)) as $num) { - $date = date('Y-m-d', strtotime("-{$num} days")); - $result[$date] = 0; - } - - foreach ($sales as $sale) { - $date = date('Y-m-d', $sale->create_time); - $result[$date] += $sale->amount; - } - - return $result; - } - - /** - * @param int $days - * @return ResultsetInterface|Resultset|OrderModel[] - */ - protected function findSales($days = 7) - { - $time = strtotime("-{$days} days"); - - return OrderModel::query() - ->where('status = :status:', ['status' => OrderModel::STATUS_FINISHED]) - ->andWhere('create_time > :time:', ['time' => $time]) - ->execute(); - } - -} diff --git a/app/Caches/SiteGlobalStat.php b/app/Caches/SiteGlobalStat.php index 99cb45d3..2e93c8a4 100644 --- a/app/Caches/SiteGlobalStat.php +++ b/app/Caches/SiteGlobalStat.php @@ -7,12 +7,14 @@ namespace App\Caches; +use App\Repos\Answer as AnswerRepo; use App\Repos\Article as ArticleRepo; use App\Repos\Comment as CommentRepo; use App\Repos\Consult as ConsultRepo; use App\Repos\Course as CourseRepo; use App\Repos\ImGroup as GroupRepo; use App\Repos\Package as PackageRepo; +use App\Repos\Question as QuestionRepo; use App\Repos\Review as ReviewRepo; use App\Repos\Topic as TopicRepo; use App\Repos\User as UserRepo; @@ -36,6 +38,8 @@ class SiteGlobalStat extends Cache { $courseRepo = new CourseRepo(); $articleRepo = new ArticleRepo(); + $questionRepo = new QuestionRepo(); + $answerRepo = new AnswerRepo(); $commentRepo = new CommentRepo(); $consultRepo = new ConsultRepo(); $groupRepo = new GroupRepo(); @@ -47,6 +51,8 @@ class SiteGlobalStat extends Cache return [ 'course_count' => $courseRepo->countCourses(), 'article_count' => $articleRepo->countArticles(), + 'question_count' => $questionRepo->countQuestions(), + 'answer_count' => $answerRepo->countAnswers(), 'comment_count' => $commentRepo->countComments(), 'consult_count' => $consultRepo->countConsults(), 'group_count' => $groupRepo->countGroups(), diff --git a/app/Caches/TaggedArticleList.php b/app/Caches/TaggedArticleList.php index 88ad3f5d..8113b4f8 100644 --- a/app/Caches/TaggedArticleList.php +++ b/app/Caches/TaggedArticleList.php @@ -34,6 +34,7 @@ class TaggedArticleList extends Cache $where = [ 'tag_id' => $id, 'published' => ArticleModel::PUBLISH_APPROVED, + 'deleted' => 0, ]; $pager = $articleRepo->paginate($where); diff --git a/app/Caches/TaggedQuestionList.php b/app/Caches/TaggedQuestionList.php index ee7ef9c9..d563dabe 100644 --- a/app/Caches/TaggedQuestionList.php +++ b/app/Caches/TaggedQuestionList.php @@ -35,6 +35,7 @@ class TaggedQuestionList extends Cache $where = [ 'tag_id' => $id, 'published' => QuestionModel::PUBLISH_APPROVED, + 'deleted' => 0, ]; $pager = $questionRepo->paginate($where); diff --git a/app/Console/Tasks/ArticleIndexTask.php b/app/Console/Tasks/ArticleIndexTask.php index 77b5ff2d..017a2577 100644 --- a/app/Console/Tasks/ArticleIndexTask.php +++ b/app/Console/Tasks/ArticleIndexTask.php @@ -124,6 +124,7 @@ class ArticleIndexTask extends Task { return ArticleModel::query() ->where('published = :published:', ['published' => ArticleModel::PUBLISH_APPROVED]) + ->andWhere('deleted = 0') ->execute(); } diff --git a/app/Console/Tasks/CourseIndexTask.php b/app/Console/Tasks/CourseIndexTask.php index f757883b..ed568faf 100644 --- a/app/Console/Tasks/CourseIndexTask.php +++ b/app/Console/Tasks/CourseIndexTask.php @@ -124,6 +124,7 @@ class CourseIndexTask extends Task { return CourseModel::query() ->where('published = 1') + ->where('deleted = 0') ->execute(); } diff --git a/app/Console/Tasks/DeliverTask.php b/app/Console/Tasks/DeliverTask.php index fd868471..dd741203 100644 --- a/app/Console/Tasks/DeliverTask.php +++ b/app/Console/Tasks/DeliverTask.php @@ -293,11 +293,11 @@ class DeliverTask extends Task * @param int $limit * @return ResultsetInterface|Resultset|TaskModel[] */ - protected function findTasks($limit = 30) + protected function findTasks($limit = 100) { $itemType = TaskModel::TYPE_DELIVER; $status = TaskModel::STATUS_PENDING; - $createTime = strtotime('-3 days'); + $createTime = strtotime('-1 days'); return TaskModel::query() ->where('item_type = :item_type:', ['item_type' => $itemType]) diff --git a/app/Console/Tasks/GroupIndexTask.php b/app/Console/Tasks/GroupIndexTask.php index 8147ef37..cad23dbf 100644 --- a/app/Console/Tasks/GroupIndexTask.php +++ b/app/Console/Tasks/GroupIndexTask.php @@ -124,6 +124,7 @@ class GroupIndexTask extends Task { return GroupModel::query() ->where('published = 1') + ->andWhere('deleted = 0') ->execute(); } diff --git a/app/Console/Tasks/NoticeTask.php b/app/Console/Tasks/NoticeTask.php index bfe774d5..1f8eac73 100644 --- a/app/Console/Tasks/NoticeTask.php +++ b/app/Console/Tasks/NoticeTask.php @@ -84,7 +84,7 @@ class NoticeTask extends Task $task->update(); - $logger->info('Notice Process Exception ' . kg_json_encode([ + $logger->error('Notice Process Exception ' . kg_json_encode([ 'file' => $e->getFile(), 'line' => $e->getLine(), 'message' => $e->getMessage(), diff --git a/app/Console/Tasks/QuestionIndexTask.php b/app/Console/Tasks/QuestionIndexTask.php index 6594881c..886d0aea 100644 --- a/app/Console/Tasks/QuestionIndexTask.php +++ b/app/Console/Tasks/QuestionIndexTask.php @@ -124,6 +124,7 @@ class QuestionIndexTask extends Task { return QuestionModel::query() ->where('published = :published:', ['published' => QuestionModel::PUBLISH_APPROVED]) + ->andWhere('deleted = 0') ->execute(); } diff --git a/app/Console/Tasks/UserIndexTask.php b/app/Console/Tasks/UserIndexTask.php index 674d12ee..77b0db5d 100644 --- a/app/Console/Tasks/UserIndexTask.php +++ b/app/Console/Tasks/UserIndexTask.php @@ -139,6 +139,7 @@ class UserIndexTask extends Task protected function findUsers($limit, $offset) { return UserModel::query() + ->where('deleted = 0') ->limit($limit, $offset) ->execute(); } diff --git a/app/Http/Admin/Services/AuthNode.php b/app/Http/Admin/Services/AuthNode.php index 2ff1ef67..69450293 100644 --- a/app/Http/Admin/Services/AuthNode.php +++ b/app/Http/Admin/Services/AuthNode.php @@ -1205,7 +1205,7 @@ class AuthNode extends Service ], [ 'id' => '5-1-12', - 'title' => '登录设置', + 'title' => '注册登录', 'type' => 'menu', 'route' => 'admin.setting.oauth', ], diff --git a/app/Http/Admin/Views/index/main_global_stat.volt b/app/Http/Admin/Views/index/main_global_stat.volt index f4198c5a..1e9738d2 100644 --- a/app/Http/Admin/Views/index/main_global_stat.volt +++ b/app/Http/Admin/Views/index/main_global_stat.volt @@ -59,13 +59,13 @@