1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-21 11:18:10 +08:00

优化代码

This commit is contained in:
xiaochong0302 2020-08-13 21:28:08 +08:00
parent 1e2398388a
commit aa58ba4243
26 changed files with 434 additions and 354 deletions

View File

@ -54,7 +54,8 @@ class CloseTradeTask extends Task
$allowClosed = false; $allowClosed = false;
} elseif ($alipayTrade->trade_status == 'WAIT_BUYER_PAY') { } elseif ($alipayTrade->trade_status == 'WAIT_BUYER_PAY') {
$alipay->close($trade->sn);
$allowClosed = $alipay->close($trade->sn);
} }
} }
@ -90,7 +91,8 @@ class CloseTradeTask extends Task
$allowClosed = false; $allowClosed = false;
} elseif ($wxpayTrade->trade_state == 'NOTPAY') { } elseif ($wxpayTrade->trade_state == 'NOTPAY') {
$wxpay->close($trade->sn);
$allowClosed = $wxpay->close($trade->sn);
} }
} }
@ -107,7 +109,7 @@ class CloseTradeTask extends Task
* @param int $limit * @param int $limit
* @return ResultsetInterface|Resultset|TradeModel[] * @return ResultsetInterface|Resultset|TradeModel[]
*/ */
protected function findTrades($limit = 5) protected function findTrades($limit = 15)
{ {
$status = TradeModel::STATUS_PENDING; $status = TradeModel::STATUS_PENDING;

View File

@ -4,7 +4,7 @@ namespace App\Console\Tasks;
use App\Models\Chapter as ChapterModel; use App\Models\Chapter as ChapterModel;
use App\Repos\Chapter as ChapterRepo; use App\Repos\Chapter as ChapterRepo;
use App\Services\CourseStats as CourseStatsService; use App\Services\CourseStat as CourseStatService;
use App\Services\Vod as VodService; use App\Services\Vod as VodService;
use Phalcon\Cli\Task; use Phalcon\Cli\Task;
@ -146,7 +146,7 @@ class VodEventTask extends Task
protected function updateVodAttrs($courseId) protected function updateVodAttrs($courseId)
{ {
$courseStats = new CourseStatsService(); $courseStats = new CourseStatService();
$courseStats->updateVodAttrs($courseId); $courseStats->updateVodAttrs($courseId);
} }

View File

@ -158,8 +158,13 @@ class SettingController extends Controller
} else { } else {
$alipay = $settingService->getSectionSettings('pay.alipay'); $alipay = $settingService->getSectionSettings('pay.alipay');
$alipay->notify_url = $alipay->notify_url ?: kg_full_url(['for' => 'web.alipay_notify']);
$wxpay = $settingService->getSectionSettings('pay.wxpay'); $wxpay = $settingService->getSectionSettings('pay.wxpay');
$wxpay->notify_url = $wxpay->notify_url ?: kg_full_url(['for' => 'web.wxpay_notify']);
$this->view->setVar('alipay', $alipay); $this->view->setVar('alipay', $alipay);
$this->view->setVar('wxpay', $wxpay); $this->view->setVar('wxpay', $wxpay);
} }

View File

@ -471,12 +471,6 @@ class AuthNode extends Service
'type' => 'button', 'type' => 'button',
'route' => 'admin.order.show', 'route' => 'admin.order.show',
], ],
[
'id' => '3-1-4',
'title' => '关闭订单',
'type' => 'button',
'route' => 'admin.order.close',
],
], ],
], ],
[ [
@ -486,7 +480,7 @@ class AuthNode extends Service
'children' => [ 'children' => [
[ [
'id' => '3-2-1', 'id' => '3-2-1',
'title' => '交易记录', 'title' => '交易列表',
'type' => 'menu', 'type' => 'menu',
'route' => 'admin.trade.list', 'route' => 'admin.trade.list',
], ],
@ -498,12 +492,6 @@ class AuthNode extends Service
], ],
[ [
'id' => '3-2-3', 'id' => '3-2-3',
'title' => '关闭交易',
'type' => 'button',
'route' => 'admin.trade.close',
],
[
'id' => '3-2-4',
'title' => '交易退款', 'title' => '交易退款',
'type' => 'button', 'type' => 'button',
'route' => 'admin.trade.refund', 'route' => 'admin.trade.refund',

View File

@ -11,7 +11,7 @@ use App\Models\ChapterVod as ChapterVodModel;
use App\Models\Course as CourseModel; use App\Models\Course as CourseModel;
use App\Repos\Chapter as ChapterRepo; use App\Repos\Chapter as ChapterRepo;
use App\Repos\Course as CourseRepo; use App\Repos\Course as CourseRepo;
use App\Services\CourseStats as CourseStatsService; use App\Services\CourseStat as CourseStatService;
use App\Validators\Chapter as ChapterValidator; use App\Validators\Chapter as ChapterValidator;
class Chapter extends Service class Chapter extends Service
@ -107,7 +107,7 @@ class Chapter extends Service
$this->updateChapterStats($chapter); $this->updateChapterStats($chapter);
$this->updateCourseStats($chapter); $this->updateCourseStat($chapter);
return $chapter; return $chapter;
@ -164,7 +164,7 @@ class Chapter extends Service
$this->updateChapterStats($chapter); $this->updateChapterStats($chapter);
$this->updateCourseStats($chapter); $this->updateCourseStat($chapter);
$this->rebuildCatalogCache($chapter); $this->rebuildCatalogCache($chapter);
@ -185,7 +185,7 @@ class Chapter extends Service
$this->updateChapterStats($chapter); $this->updateChapterStats($chapter);
$this->updateCourseStats($chapter); $this->updateCourseStat($chapter);
$this->rebuildCatalogCache($chapter); $this->rebuildCatalogCache($chapter);
@ -202,7 +202,7 @@ class Chapter extends Service
$this->updateChapterStats($chapter); $this->updateChapterStats($chapter);
$this->updateCourseStats($chapter); $this->updateCourseStat($chapter);
$this->rebuildCatalogCache($chapter); $this->rebuildCatalogCache($chapter);
@ -222,13 +222,13 @@ class Chapter extends Service
$chapter->update(); $chapter->update();
} }
protected function updateCourseStats(ChapterModel $chapter) protected function updateCourseStat(ChapterModel $chapter)
{ {
$courseRepo = new CourseRepo(); $courseRepo = new CourseRepo();
$course = $courseRepo->findById($chapter->course_id); $course = $courseRepo->findById($chapter->course_id);
$courseStats = new CourseStatsService(); $courseStats = new CourseStatService();
$courseStats->updateLessonCount($course->id); $courseStats->updateLessonCount($course->id);

View File

@ -8,7 +8,7 @@ use App\Models\Course as CourseModel;
use App\Repos\Chapter as ChapterRepo; use App\Repos\Chapter as ChapterRepo;
use App\Repos\Course as CourseRepo; use App\Repos\Course as CourseRepo;
use App\Services\ChapterVod as ChapterVodService; use App\Services\ChapterVod as ChapterVodService;
use App\Services\CourseStats as CourseStatsService; use App\Services\CourseStat as CourseStatService;
use App\Validators\ChapterLive as ChapterLiveValidator; use App\Validators\ChapterLive as ChapterLiveValidator;
use App\Validators\ChapterRead as ChapterReadValidator; use App\Validators\ChapterRead as ChapterReadValidator;
use App\Validators\ChapterVod as ChapterVodValidator; use App\Validators\ChapterVod as ChapterVodValidator;
@ -97,7 +97,7 @@ class ChapterContent extends Service
$chapter->update(['attrs' => $attrs]); $chapter->update(['attrs' => $attrs]);
$courseStats = new CourseStatsService(); $courseStats = new CourseStatService();
$courseStats->updateVodAttrs($chapter->course_id); $courseStats->updateVodAttrs($chapter->course_id);
} }
@ -132,7 +132,7 @@ class ChapterContent extends Service
$chapter->update(['attrs' => $attrs]); $chapter->update(['attrs' => $attrs]);
$courseStats = new CourseStatsService(); $courseStats = new CourseStatService();
$courseStats->updateLiveAttrs($chapter->course_id); $courseStats->updateLiveAttrs($chapter->course_id);
} }
@ -161,7 +161,7 @@ class ChapterContent extends Service
$chapter->update(['attrs' => $attrs]); $chapter->update(['attrs' => $attrs]);
$courseStats = new CourseStatsService(); $courseStats = new CourseStatService();
$courseStats->updateReadAttrs($chapter->course_id); $courseStats->updateReadAttrs($chapter->course_id);
} }

View File

@ -6,6 +6,7 @@ use App\Builders\ReviewList as ReviewListBuilder;
use App\Library\Paginator\Query as PagerQuery; use App\Library\Paginator\Query as PagerQuery;
use App\Repos\Course as CourseRepo; use App\Repos\Course as CourseRepo;
use App\Repos\Review as ReviewRepo; use App\Repos\Review as ReviewRepo;
use App\Services\CourseStat as CourseStatService;
use App\Validators\Review as ReviewValidator; use App\Validators\Review as ReviewValidator;
class Review extends Service class Review extends Service
@ -56,8 +57,16 @@ class Review extends Service
$data['content'] = $validator->checkContent($post['content']); $data['content'] = $validator->checkContent($post['content']);
} }
if (isset($post['rating'])) { if (isset($post['rating1'])) {
$data['rating'] = $validator->checkRating($post['rating']); $data['rating1'] = $validator->checkRating($post['rating1']);
}
if (isset($post['rating2'])) {
$data['rating2'] = $validator->checkRating($post['rating2']);
}
if (isset($post['rating3'])) {
$data['rating3'] = $validator->checkRating($post['rating3']);
} }
if (isset($post['published'])) { if (isset($post['published'])) {
@ -66,6 +75,8 @@ class Review extends Service
$review->update($data); $review->update($data);
$this->updateCourseRating($review->course_id);
return $review; return $review;
} }
@ -77,13 +88,7 @@ class Review extends Service
$review->update(); $review->update();
$courseRepo = new CourseRepo(); $this->decrCourseReviewCount($review->course_id);
$course = $courseRepo->findById($review->course_id);
$course->review_count -= 1;
$course->update();
} }
public function restoreReview($id) public function restoreReview($id)
@ -94,13 +99,7 @@ class Review extends Service
$review->update(); $review->update();
$courseRepo = new CourseRepo(); $this->incrCourseReviewCount($review->course_id);
$course = $courseRepo->findById($review->course_id);
$course->review_count += 1;
$course->update();
} }
protected function findOrFail($id) protected function findOrFail($id)
@ -110,6 +109,35 @@ class Review extends Service
return $validator->checkReview($id); return $validator->checkReview($id);
} }
protected function incrCourseReviewCount($courseId)
{
$courseRepo = new CourseRepo();
$course = $courseRepo->findById($courseId);
$course->review_count -= 1;
$course->update();
}
protected function decrCourseReviewCount($courseId)
{
$courseRepo = new CourseRepo();
$course = $courseRepo->findById($courseId);
$course->review_count += 1;
$course->update();
}
protected function updateCourseRating($courseId)
{
$service = new CourseStatService();
$service->updateRating($courseId);
}
protected function handleReviews($pager) protected function handleReviews($pager)
{ {
if ($pager->total_items > 0) { if ($pager->total_items > 0) {

View File

@ -4,7 +4,7 @@
{%- macro private_info(value) %} {%- macro private_info(value) %}
{% if value == 1 %} {% if value == 1 %}
<span class="layui-badge layui-bg-red">密</span> <span class="layui-badge">密</span>
{% endif %} {% endif %}
{%- endmacro %} {%- endmacro %}
@ -39,29 +39,28 @@
</thead> </thead>
<tbody> <tbody>
{% for item in pager.items %} {% for item in pager.items %}
{% set list_url = url({'for':'admin.consult.list'},{'course_id':item.course.id}) %} {% set item.answer = item.answer ? item.answer : '等待回复ING...' %}
{% set list_by_course_url = url({'for':'admin.consult.list'},{'course_id':item.course.id}) %}
{% set list_by_user_url = url({'for':'admin.consult.list'},{'owner_id':item.owner.id}) %}
{% set edit_url = url({'for':'admin.consult.edit','id':item.id}) %} {% set edit_url = url({'for':'admin.consult.edit','id':item.id}) %}
{% set update_url = url({'for':'admin.consult.update','id':item.id}) %} {% set update_url = url({'for':'admin.consult.update','id':item.id}) %}
{% set delete_url = url({'for':'admin.consult.delete','id':item.id}) %} {% set delete_url = url({'for':'admin.consult.delete','id':item.id}) %}
{% set restore_url = url({'for':'admin.consult.restore','id':item.id}) %} {% set restore_url = url({'for':'admin.consult.restore','id':item.id}) %}
<tr> <tr>
<td> <td>
<p>课程:<a href="{{ list_url }}">{{ item.course.title }}</a>{{ private_info(item.private) }}</p> <p>课程:<a href="{{ list_by_course_url }}">{{ item.course.title }}</a>{{ private_info(item.private) }}</p>
<p>提问:<a href="javascript:" title="{{ item.question }}">{{ substr(item.question,0,30) }}</a></p> <p class="layui-elip kg-item-elip" title="{{ item.question }}">提问:{{ item.question }}</p>
{% if item.answer %} <p class="layui-elip kg-item-elip" title="{{ item.answer }}">回复:{{ item.answer }}</p>
<p>回复:<a href="javascript:" title="{{ item.answer }}">{{ substr(item.answer,0,30) }}</a></p>
{% endif %}
</td> </td>
<td> <td>
<p>昵称:{{ item.owner.name }}</p> <p>昵称:<a href="{{ list_by_user_url }}">{{ item.owner.name }}</a></p>
<p>编号:{{ item.owner.id }}</p> <p>编号:{{ item.owner.id }}</p>
</td> </td>
<td>{{ date('Y-m-d H:i:s',item.create_time) }}</td> <td>{{ date('Y-m-d H:i:s',item.create_time) }}</td>
<td><input type="checkbox" name="published" value="1" lay-skin="switch" lay-text="是|否" lay-filter="published" data-url="{{ update_url }}" {% if item.published == 1 %}checked{% endif %}></td> <td><input type="checkbox" name="published" value="1" lay-skin="switch" lay-text="是|否" lay-filter="published" data-url="{{ update_url }}" {% if item.published == 1 %}checked{% endif %}></td>
<td class="center"> <td class="center">
<div class="layui-dropdown"> <div class="layui-dropdown">
<button class="layui-btn layui-btn-sm">操作 <i class="layui-icon layui-icon-triangle-d"></i> <button class="layui-btn layui-btn-sm">操作 <i class="layui-icon layui-icon-triangle-d"></i></button>
</button>
<ul> <ul>
<li><a href="{{ edit_url }}">编辑</a></li> <li><a href="{{ edit_url }}">编辑</a></li>
{% if item.deleted == 0 %} {% if item.deleted == 0 %}

View File

@ -7,16 +7,30 @@
<legend>编辑评价</legend> <legend>编辑评价</legend>
</fieldset> </fieldset>
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">评分</label> <label class="layui-form-label">内容实用</label>
<div class="layui-input-block"> <div class="layui-input-block">
<div id="rating">{{ review.rating }}</div> <div id="rating1" class="kg-rating"></div>
<input type="hidden" name="rating" value="{{ review.rating }}"/> <input type="hidden" name="rating1" value="{{ review.rating1 }}"/>
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">评价</label> <label class="layui-form-label">通俗易懂</label>
<div class="layui-input-block"> <div class="layui-input-block">
<textarea name="content" class="layui-textarea" lay-verify="required">{{ review.content }}</textarea> <div id="rating2" class="kg-rating"></div>
<input type="hidden" name="rating2" value="{{ review.rating2 }}"/>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">逻辑清晰</label>
<div class="layui-input-block">
<div id="rating3" class="kg-rating"></div>
<input type="hidden" name="rating3" value="{{ review.rating3 }}"/>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label" for="content">评价</label>
<div class="layui-input-block">
<textarea name="content" id="content" class="layui-textarea" lay-verify="required">{{ review.content }}</textarea>
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
@ -46,11 +60,31 @@
var $ = layui.jquery; var $ = layui.jquery;
var rate = layui.rate; var rate = layui.rate;
var $rating1 = $('input[name=rating1]');
var $rating2 = $('input[name=rating2]');
var $rating3 = $('input[name=rating3]');
rate.render({ rate.render({
elem: '#rating', elem: '#rating1',
value: $('#rating').text(), value: $rating1.val(),
choose: function (value) { choose: function (value) {
$('input[name=rating]').val(value); $rating1.val(value);
}
});
rate.render({
elem: '#rating2',
value: $rating2.val(),
choose: function (value) {
$rating2.val(value);
}
});
rate.render({
elem: '#rating3',
value: $rating3.val(),
choose: function (value) {
$rating3.val(value);
} }
}); });

View File

@ -42,7 +42,7 @@
<tr> <tr>
<td> <td>
<p>课程:<a href="{{ list_by_course_url }}">{{ item.course.title }}</a></p> <p>课程:<a href="{{ list_by_course_url }}">{{ item.course.title }}</a></p>
<p>评价:<a href="javascript:" title="{{ item.content }}">{{ substr(item.content,0,30) }}</a></p> <p class="layui-elip kg-item-elip" title="{{ item.content }}">评价:{{ item.content }}</p>
<p>时间:{{ date('Y-m-d H:i:s',item.create_time) }}</p> <p>时间:{{ date('Y-m-d H:i:s',item.create_time) }}</p>
</td> </td>
<td> <td>

View File

@ -88,8 +88,6 @@
layer.msg(json.msg, {icon: 2}); layer.msg(json.msg, {icon: 2});
} }
}); });
}, function () {
}); });
}); });

View File

@ -27,14 +27,14 @@
</thead> </thead>
<tbody> <tbody>
{% for item in pager.items %} {% for item in pager.items %}
{% set answer = item.answer ? item.answer : '请耐心等待回复吧' %} {% set item.answer = item.answer ? item.answer : '请耐心等待回复吧' %}
{% set show_url = url({'for':'web.consult.show','id':item.id}) %} {% set show_url = url({'for':'web.consult.show','id':item.id}) %}
{% set edit_url = url({'for':'web.consult.edit','id':item.id}) %} {% set edit_url = url({'for':'web.consult.edit','id':item.id}) %}
{% set delete_url = url({'for':'web.consult.delete','id':item.id}) %} {% set delete_url = url({'for':'web.consult.delete','id':item.id}) %}
<tr> <tr>
<td> <td>
<p class="question layui-elip" title="{{ item.question }}">提问:{{ item.question }}</p> <p class="layui-elip item-elip" title="{{ item.question }}">提问:{{ item.question }}</p>
<p class="answer layui-elip" title="{{ item.answer }}">回复:{{ answer }}</p> <p class="layui-elip item-elip" title="{{ item.answer }}">回复:{{ item.answer }}</p>
</td> </td>
<td>{{ date('Y-m-d',item.create_time) }}</td> <td>{{ date('Y-m-d',item.create_time) }}</td>
<td> <td>

View File

@ -32,7 +32,7 @@
<div class="column price">{{ '¥%0.2f'|format(item.amount) }}</div> <div class="column price">{{ '¥%0.2f'|format(item.amount) }}</div>
<div class="column status">{{ order_status(item.status) }}</div> <div class="column status">{{ order_status(item.status) }}</div>
<div class="column action"> <div class="column action">
<button class="layui-btn layui-btn-xs btn-order-info" data-url="{{ order_info_url }}">详情</button> <button class="layui-btn layui-btn-sm btn-order-info" data-url="{{ order_info_url }}">详情</button>
</div> </div>
</div> </div>
</div> </div>

View File

@ -32,7 +32,7 @@
<div class="column price">{{ '¥%0.2f'|format(item.amount) }}</div> <div class="column price">{{ '¥%0.2f'|format(item.amount) }}</div>
<div class="column status">{{ refund_status(item.status) }}</div> <div class="column status">{{ refund_status(item.status) }}</div>
<div class="column action"> <div class="column action">
<button class="layui-btn layui-btn-xs btn-refund-info" data-url="{{ refund_info_url }}">详情</button> <button class="layui-btn layui-btn-sm btn-refund-info" data-url="{{ refund_info_url }}">详情</button>
</div> </div>
</div> </div>
</div> </div>

View File

@ -21,7 +21,6 @@
</table> </table>
<br> <br>
<div class="text-center"> <div class="text-center">
<button class="layui-btn layui-bg-gray btn-close">关闭窗口</button>
{% if refund.status == 'approved' %} {% if refund.status == 'approved' %}
<button class="kg-refund layui-btn" data-sn="{{ refund.sn }}" data-url="{{ cancel_url }}">取消退款</button> <button class="kg-refund layui-btn" data-sn="{{ refund.sn }}" data-url="{{ cancel_url }}">取消退款</button>
{% endif %} {% endif %}
@ -53,8 +52,6 @@
}, 1500); }, 1500);
} }
}); });
}, function () {
}); });
}); });
}); });

View File

@ -3,8 +3,9 @@
namespace App\Services; namespace App\Services;
use App\Repos\Course as CourseRepo; use App\Repos\Course as CourseRepo;
use App\Repos\CourseRating as CourseRatingRepo;
class CourseStats extends Service class CourseStat extends Service
{ {
public function updateLessonCount($courseId) public function updateLessonCount($courseId)
@ -39,9 +40,18 @@ class CourseStats extends Service
$course = $courseRepo->findById($courseId); $course = $courseRepo->findById($courseId);
$rating = $courseRepo->averageRating($courseId); $courseRatingRepo = new CourseRatingRepo();
$course->rating = $rating; $courseRating = $courseRatingRepo->findByCourseId($course->id);
$courseRating->rating = $courseRatingRepo->averageRating($course->id);
$courseRating->rating1 = $courseRatingRepo->averageRating1($course->id);
$courseRating->rating2 = $courseRatingRepo->averageRating2($course->id);
$courseRating->rating3 = $courseRatingRepo->averageRating3($course->id);
$courseRating->update();
$course->rating = $courseRating->rating;
$course->update(); $course->update();
} }

View File

@ -79,12 +79,14 @@ class ConsultCreate extends FrontendService
protected function incrCourseConsultCount(CourseModel $course) protected function incrCourseConsultCount(CourseModel $course)
{ {
$course->consult_count += 1; $course->consult_count += 1;
$course->update(); $course->update();
} }
protected function incrChapterConsultCount(ChapterModel $chapter) protected function incrChapterConsultCount(ChapterModel $chapter)
{ {
$chapter->consult_count += 1; $chapter->consult_count += 1;
$chapter->update(); $chapter->update();
} }

View File

@ -4,6 +4,7 @@ namespace App\Services\Frontend\Review;
use App\Models\Course as CourseModel; use App\Models\Course as CourseModel;
use App\Models\Review as ReviewModel; use App\Models\Review as ReviewModel;
use App\Services\CourseStat as CourseStatService;
use App\Services\Frontend\CourseTrait; use App\Services\Frontend\CourseTrait;
use App\Services\Frontend\ReviewTrait; use App\Services\Frontend\ReviewTrait;
use App\Services\Frontend\Service as FrontendService; use App\Services\Frontend\Service as FrontendService;
@ -45,17 +46,25 @@ class ReviewCreate extends FrontendService
$review->create($data); $review->create($data);
$this->updateCourseRating($course);
$this->incrCourseReviewCount($course); $this->incrCourseReviewCount($course);
$this->updateCourseRating($course->id);
return $review; return $review;
} }
protected function incrCourseReviewCount(CourseModel $course) protected function incrCourseReviewCount(CourseModel $course)
{ {
$course->review_count += 1; $course->review_count += 1;
$course->update(); $course->update();
} }
public function updateCourseRating($courseId)
{
$service = new CourseStatService();
$service->updateRating($courseId);
}
} }

View File

@ -3,6 +3,7 @@
namespace App\Services\Frontend\Review; namespace App\Services\Frontend\Review;
use App\Models\Course as CourseModel; use App\Models\Course as CourseModel;
use App\Services\CourseStat as CourseStatService;
use App\Services\Frontend\CourseTrait; use App\Services\Frontend\CourseTrait;
use App\Services\Frontend\ReviewTrait; use App\Services\Frontend\ReviewTrait;
use App\Services\Frontend\Service as FrontendService; use App\Services\Frontend\Service as FrontendService;
@ -30,7 +31,7 @@ class ReviewDelete extends FrontendService
$this->decrCourseReviewCount($course); $this->decrCourseReviewCount($course);
$this->updateCourseRating($course); $this->updateCourseRating($course->id);
} }
protected function decrCourseReviewCount(CourseModel $course) protected function decrCourseReviewCount(CourseModel $course)
@ -41,4 +42,11 @@ class ReviewDelete extends FrontendService
} }
} }
protected function updateCourseRating($courseId)
{
$service = new CourseStatService();
$service->updateRating($courseId);
}
} }

View File

@ -2,6 +2,7 @@
namespace App\Services\Frontend\Review; namespace App\Services\Frontend\Review;
use App\Services\CourseStat as CourseStatService;
use App\Services\Frontend\CourseTrait; use App\Services\Frontend\CourseTrait;
use App\Services\Frontend\ReviewTrait; use App\Services\Frontend\ReviewTrait;
use App\Services\Frontend\Service as FrontendService; use App\Services\Frontend\Service as FrontendService;
@ -38,7 +39,14 @@ class ReviewUpdate extends FrontendService
$review->update($data); $review->update($data);
$this->updateCourseRating($course); $this->updateCourseRating($course->id);
}
protected function updateCourseRating($courseId)
{
$service = new CourseStatService();
$service->updateRating($courseId);
} }
} }

View File

@ -2,8 +2,6 @@
namespace App\Services\Frontend; namespace App\Services\Frontend;
use App\Models\Course as CourseModel;
use App\Repos\CourseRating as CourseRatingRepo;
use App\Validators\Review as ReviewValidator; use App\Validators\Review as ReviewValidator;
trait ReviewTrait trait ReviewTrait
@ -16,22 +14,4 @@ trait ReviewTrait
return $validator->checkReview($id); return $validator->checkReview($id);
} }
public function updateCourseRating(CourseModel $course)
{
$repo = new CourseRatingRepo();
$courseRating = $repo->findByCourseId($course->id);
$courseRating->rating = $repo->averageRating($course->id);
$courseRating->rating1 = $repo->averageRating1($course->id);
$courseRating->rating2 = $repo->averageRating2($course->id);
$courseRating->rating3 = $repo->averageRating3($course->id);
$courseRating->update();
$course->rating = $courseRating->rating;
$course->update();
}
} }

View File

@ -20,7 +20,7 @@
"hightman/xunsearch": "^1.4.14", "hightman/xunsearch": "^1.4.14",
"aferrandini/phpqrcode": "1.0.1", "aferrandini/phpqrcode": "1.0.1",
"xiaochong0302/ip2region": "^1.0", "xiaochong0302/ip2region": "^1.0",
"joyqi/hyper-down": "dev-master" "samdark/sitemap": "^2.2"
}, },
"require-dev": { "require-dev": {
"odan/phinx-migrations-generator": "^4.6", "odan/phinx-migrations-generator": "^4.6",

441
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "d95c023895ee3acc72bcd13024da3eb3", "content-hash": "c572e75b0438b57f01c4b4a6ff65f174",
"packages": [ "packages": [
{ {
"name": "aferrandini/phpqrcode", "name": "aferrandini/phpqrcode",
@ -87,16 +87,16 @@
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.1.x-dev" "dev-master": "1.1.x-dev"
} }
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Doctrine\\Common\\Lexer\\": "lib/Doctrine/Common/Lexer" "Doctrine\\Common\\Lexer\\": "lib/Doctrine/Common/Lexer"
} }
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
@ -564,16 +564,16 @@
}, },
"notification-url": "https://packagist.jp/downloads/", "notification-url": "https://packagist.jp/downloads/",
"license": [ "license": [
"GPL-2.0+" "GPL-2.0+"
], ],
"authors": [ "authors": [
{ {
"name": "hightman", "name": "hightman",
"email": "hightman@twomice.net", "email": "hightman@twomice.net",
"role": "Founder and project leader" "role": "Founder and project leader"
} }
], ],
"description": "xunsearch php sdk, include yii, yii2 supports", "description": "xunsearch php sdk, include yii, yii2 supports",
"homepage": "http://www.xunsearch.com/", "homepage": "http://www.xunsearch.com/",
"keywords": [ "keywords": [
"search engine", "search engine",
@ -583,48 +583,6 @@
], ],
"time": "2019-11-01T02:17:32+00:00" "time": "2019-11-01T02:17:32+00:00"
}, },
{
"name": "joyqi/hyper-down",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/SegmentFault/HyperDown.git",
"reference": "e9bf808ff8cc1736b15a669e46f1d81f77ce026b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/SegmentFault/HyperDown/zipball/e9bf808ff8cc1736b15a669e46f1d81f77ce026b",
"reference": "e9bf808ff8cc1736b15a669e46f1d81f77ce026b",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.4.0"
},
"type": "library",
"autoload": {
"psr-4": {
"HyperDown\\": "./"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD"
],
"authors": [
{
"name": "joyqi",
"email": "joyqi@segmentfault.com"
}
],
"description": "A light weight markdown parser library",
"time": "2019-11-18T09:50:06+00:00"
},
{ {
"name": "monolog/monolog", "name": "monolog/monolog",
"version": "2.0.0", "version": "2.0.0",
@ -645,16 +603,16 @@
} }
] ]
}, },
"require": { "require": {
"php": "^7.2", "php": "^7.2",
"psr/log": "^1.0.1" "psr/log": "^1.0.1"
}, },
"provide": { "provide": {
"psr/log-implementation": "1.0.0" "psr/log-implementation": "1.0.0"
}, },
"require-dev": { "require-dev": {
"aws/aws-sdk-php": "^2.4.9 || ^3.0", "aws/aws-sdk-php": "^2.4.9 || ^3.0",
"doctrine/couchdb": "~1.0@dev", "doctrine/couchdb": "~1.0@dev",
"elasticsearch/elasticsearch": "^6.0", "elasticsearch/elasticsearch": "^6.0",
"graylog2/gelf-php": "^1.4.2", "graylog2/gelf-php": "^1.4.2",
"jakub-onderka/php-parallel-lint": "^0.9", "jakub-onderka/php-parallel-lint": "^0.9",
@ -732,9 +690,9 @@
} }
] ]
}, },
"require": { "require": {
"php": ">=5.3.2" "php": ">=5.3.2"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "~4.0|~5.0" "phpunit/phpunit": "~4.0|~5.0"
}, },
@ -1192,35 +1150,86 @@
"license": [ "license": [
"MIT" "MIT"
], ],
"authors": [ "authors": [
{ {
"name": "Ralph Khattar", "name": "Ralph Khattar",
"email": "ralph.khattar@gmail.com" "email": "ralph.khattar@gmail.com"
} }
], ],
"description": "A polyfill for getallheaders.", "description": "A polyfill for getallheaders.",
"time": "2019-03-08T08:55:37+00:00" "time": "2019-03-08T08:55:37+00:00"
}, },
{
"name": "samdark/sitemap",
"version": "2.2.1",
"source": {
"type": "git",
"url": "https://github.com/samdark/sitemap.git",
"reference": "dcfef471e79abca9d3c4d83dd6a7861cec1a596a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/samdark/sitemap/zipball/dcfef471e79abca9d3c4d83dd6a7861cec1a596a",
"reference": "dcfef471e79abca9d3c4d83dd6a7861cec1a596a",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"ext-xmlwriter": "*",
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "~4.4"
},
"type": "library",
"autoload": {
"psr-4": {
"samdark\\sitemap\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{ {
"name": "swiftmailer/swiftmailer", "name": "Alexander Makarov",
"version": "v6.2.1", "email": "sam@rmcreative.ru",
"source": { "homepage": "http://rmcreative.ru/"
"type": "git", }
"url": "https://github.com/swiftmailer/swiftmailer.git", ],
"reference": "5397cd05b0a0f7937c47b0adcb4c60e5ab936b6a" "description": "Sitemap and sitemap index builder",
}, "homepage": "https://github.com/samdark/sitemap",
"dist": { "keywords": [
"type": "zip", "Sitemap"
"url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/5397cd05b0a0f7937c47b0adcb4c60e5ab936b6a", ],
"reference": "5397cd05b0a0f7937c47b0adcb4c60e5ab936b6a", "time": "2019-03-27T09:31:20+00:00"
"shasum": "", },
"mirrors": [ {
{ "name": "swiftmailer/swiftmailer",
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", "version": "v6.2.1",
"preferred": true "source": {
} "type": "git",
] "url": "https://github.com/swiftmailer/swiftmailer.git",
}, "reference": "5397cd05b0a0f7937c47b0adcb4c60e5ab936b6a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/5397cd05b0a0f7937c47b0adcb4c60e5ab936b6a",
"reference": "5397cd05b0a0f7937c47b0adcb4c60e5ab936b6a",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": { "require": {
"egulias/email-validator": "~2.0", "egulias/email-validator": "~2.0",
"php": ">=7.0.0", "php": ">=7.0.0",
@ -1929,9 +1938,9 @@
} }
] ]
}, },
"require": { "require": {
"workerman/workerman": ">=3.1.8" "workerman/workerman": ">=3.1.8"
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
"psr-4": { "psr-4": {
@ -2012,12 +2021,12 @@
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Workerman\\": "./" "Workerman\\": "./"
} }
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
"authors": [ "authors": [
{ {
"name": "walkor", "name": "walkor",
@ -2074,16 +2083,16 @@
} }
], ],
"description": "ip2region扩展包", "description": "ip2region扩展包",
"keywords": [ "keywords": [
"Ip2Region" "Ip2Region"
], ],
"time": "2019-08-18T14:57:02+00:00" "time": "2019-08-18T14:57:02+00:00"
}, },
{ {
"name": "yansongda/pay", "name": "yansongda/pay",
"version": "v2.8.6", "version": "v2.8.6",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/yansongda/pay.git", "url": "https://github.com/yansongda/pay.git",
"reference": "841999b65f97466ed1b405c52400c0c73aeaa3b5" "reference": "841999b65f97466ed1b405c52400c0c73aeaa3b5"
}, },
@ -2109,34 +2118,34 @@
"symfony/http-foundation": "^4.0", "symfony/http-foundation": "^4.0",
"yansongda/supports": "^2.0" "yansongda/supports": "^2.0"
}, },
"require-dev": { "require-dev": {
"mockery/mockery": "^1.2", "mockery/mockery": "^1.2",
"phpunit/phpunit": "^7.5" "phpunit/phpunit": "^7.5"
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Yansongda\\Pay\\": "src" "Yansongda\\Pay\\": "src"
} }
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
"authors": [ "authors": [
{ {
"name": "yansongda", "name": "yansongda",
"email": "me@yansongda.cn" "email": "me@yansongda.cn"
} }
], ],
"description": "专注 Alipay 和 WeChat 的支付扩展包", "description": "专注 Alipay 和 WeChat 的支付扩展包",
"keywords": [ "keywords": [
"alipay", "alipay",
"pay", "pay",
"wechat" "wechat"
], ],
"time": "2019-09-21T15:05:57+00:00" "time": "2019-09-21T15:05:57+00:00"
}, },
{ {
"name": "yansongda/supports", "name": "yansongda/supports",
"version": "v2.1.3", "version": "v2.1.3",
@ -2177,16 +2186,16 @@
} }
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
"authors": [ "authors": [
{ {
"name": "yansongda", "name": "yansongda",
"email": "me@yansongda.cn" "email": "me@yansongda.cn"
} }
], ],
"description": "common components", "description": "common components",
"keywords": [ "keywords": [
"Guzzle", "Guzzle",
"array", "array",
@ -2442,16 +2451,16 @@
"name": "CakePHP Community", "name": "CakePHP Community",
"homepage": "https://github.com/cakephp/cache/graphs/contributors" "homepage": "https://github.com/cakephp/cache/graphs/contributors"
} }
], ],
"description": "Easy to use Caching library with support for multiple caching backends", "description": "Easy to use Caching library with support for multiple caching backends",
"homepage": "https://cakephp.org", "homepage": "https://cakephp.org",
"keywords": [ "keywords": [
"cache", "cache",
"caching", "caching",
"cakephp" "cakephp"
], ],
"time": "2019-11-20T00:00:46+00:00" "time": "2019-11-20T00:00:46+00:00"
}, },
{ {
"name": "cakephp/collection", "name": "cakephp/collection",
"version": "3.8.7", "version": "3.8.7",
@ -2752,16 +2761,16 @@
"type": "library", "type": "library",
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Cake\\Utility\\": "." "Cake\\Utility\\": "."
}, },
"files": [ "files": [
"bootstrap.php" "bootstrap.php"
] ]
}, },
"notification-url": "https://packagist.jp/downloads/", "notification-url": "https://packagist.jp/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
"authors": [ "authors": [
{ {
"name": "CakePHP Community", "name": "CakePHP Community",
@ -3158,16 +3167,16 @@
} }
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Psr\\Container\\": "src/" "Psr\\Container\\": "src/"
} }
}, },
"notification-url": "https://packagist.jp/downloads/", "notification-url": "https://packagist.jp/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
"authors": [ "authors": [
{ {
"name": "PHP-FIG", "name": "PHP-FIG",
"homepage": "http://www.php-fig.org/" "homepage": "http://www.php-fig.org/"
} }
@ -3755,16 +3764,16 @@
"license": [ "license": [
"MIT" "MIT"
], ],
"authors": [ "authors": [
{ {
"name": "Nicolas Grekas", "name": "Nicolas Grekas",
"email": "p@tchwork.com" "email": "p@tchwork.com"
}, },
{ {
"name": "Symfony Community", "name": "Symfony Community",
"homepage": "https://symfony.com/contributors" "homepage": "https://symfony.com/contributors"
} }
], ],
"description": "Generic abstractions related to writing services", "description": "Generic abstractions related to writing services",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"keywords": [ "keywords": [
@ -3889,23 +3898,23 @@
"require-dev": { "require-dev": {
"symfony/console": "^4.4|^5.0" "symfony/console": "^4.4|^5.0"
}, },
"suggest": { "suggest": {
"symfony/console": "For validating YAML files using the lint command" "symfony/console": "For validating YAML files using the lint command"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "5.0-dev" "dev-master": "5.0-dev"
} }
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Symfony\\Component\\Yaml\\": "" "Symfony\\Component\\Yaml\\": ""
}, },
"exclude-from-classmap": [ "exclude-from-classmap": [
"/Tests/" "/Tests/"
] ]
}, },
"notification-url": "https://packagist.jp/downloads/", "notification-url": "https://packagist.jp/downloads/",
"license": [ "license": [
"MIT" "MIT"
@ -3983,9 +3992,7 @@
], ],
"aliases": [], "aliases": [],
"minimum-stability": "stable", "minimum-stability": "stable",
"stability-flags": { "stability-flags": [],
"joyqi/hyper-down": 20
},
"prefer-stable": false, "prefer-stable": false,
"prefer-lowest": false, "prefer-lowest": false,
"platform": { "platform": {

View File

@ -116,6 +116,18 @@
text-align: center; text-align: center;
} }
.kg-item-elip {
width: 400px;
}
.layui-form .kg-rating {
margin-bottom: 0;
}
.kg-rating .layui-rate {
padding: 5px 0 0 0;
}
input.kg-priority { input.kg-priority {
width: 60px; width: 60px;
} }

View File

@ -182,6 +182,31 @@ body {
margin-bottom: 15px; margin-bottom: 15px;
} }
.topic-title {
margin-bottom: 30px;
padding-bottom: 15px;
border-bottom: 2px solid #e6e6e6;
text-align: center;
font-size: 18px;
}
.page-info {
padding: 20px 50px;
min-height: 500px;
}
.page-title {
margin-bottom: 30px;
padding-bottom: 15px;
border-bottom: 1px solid #e6e6e6;
text-align: center;
font-size: 18px;
}
.help-list li {
line-height: 30px;
}
.index-wrap .layui-tab { .index-wrap .layui-tab {
margin-bottom: 0; margin-bottom: 0;
} }
@ -307,31 +332,6 @@ body {
margin-bottom: 5px; margin-bottom: 5px;
} }
.topic-title {
margin-bottom: 30px;
padding-bottom: 15px;
border-bottom: 2px solid #e6e6e6;
text-align: center;
font-size: 18px;
}
.page-info {
padding: 20px 50px;
min-height: 500px;
}
.page-title {
margin-bottom: 30px;
padding-bottom: 15px;
border-bottom: 1px solid #e6e6e6;
text-align: center;
font-size: 18px;
}
.help-list li {
line-height: 30px;
}
.course-list { .course-list {
margin-bottom: 20px; margin-bottom: 20px;
} }
@ -1426,11 +1426,7 @@ body {
text-align: center; text-align: center;
} }
.consult-table .question { .consult-table .item-elip {
width: 450px;
}
.consult-table .answer {
width: 450px; width: 450px;
} }

View File

@ -43,13 +43,10 @@ $scheduler->php($script, $bin, ['--task' => 'unlock_user', '--action' => 'main']
$scheduler->php($script, $bin, ['--task' => 'revoke_vip', '--action' => 'main']) $scheduler->php($script, $bin, ['--task' => 'revoke_vip', '--action' => 'main'])
->daily(3, 11); ->daily(3, 11);
$scheduler->php($script, $bin, ['--task' => 'count_course', '--action' => 'main']) $scheduler->php($script, $bin, ['--task' => 'live_notice_provider', '--action' => 'main'])
->daily(3, 17); ->daily(3, 17);
$scheduler->php($script, $bin, ['--task' => 'live_notice_provider', '--action' => 'main']) $scheduler->php($script, $bin, ['--task' => 'clean_token', '--action' => 'main'])
->daily(3, 23); ->daily(3, 23);
$scheduler->php($script, $bin, ['--task' => 'clean_token', '--action' => 'main'])
->daily(3, 31);
$scheduler->run(); $scheduler->run();