1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-28 05:11:39 +08:00

优化代码,测试微信支付

This commit is contained in:
xiaochong0302 2020-09-13 18:19:20 +08:00
parent d9016669e3
commit 502fbe9583
35 changed files with 147 additions and 111 deletions

View File

@ -7,7 +7,7 @@ use App\Models\Course as CourseModel;
use Phalcon\Mvc\Model\Resultset; use Phalcon\Mvc\Model\Resultset;
use Phalcon\Mvc\Model\ResultsetInterface; use Phalcon\Mvc\Model\ResultsetInterface;
class CourseCatalog extends Builder class CourseChapterList extends Builder
{ {
/** /**

View File

@ -2,9 +2,9 @@
namespace App\Caches; 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; protected $lifetime = 7 * 86400;
@ -16,12 +16,12 @@ class CourseCatalog extends Cache
public function getKey($id = null) public function getKey($id = null)
{ {
return "course_catalog:{$id}"; return "course_chapter_list:{$id}";
} }
public function getContent($id = null) public function getContent($id = null)
{ {
$builder = new CourseCatalogBuilder(); $builder = new CourseChapterListBuilder();
$list = $builder->handle($id); $list = $builder->handle($id);

View File

@ -35,9 +35,9 @@ class ChapterController extends Controller
*/ */
public function addAction() public function addAction()
{ {
$courseId = $this->request->getQuery('course_id'); $courseId = $this->request->getQuery('course_id', 'int');
$parentId = $this->request->getQuery('parent_id'); $parentId = $this->request->getQuery('parent_id', 'int');
$type = $this->request->getQuery('type'); $type = $this->request->getQuery('type', 'string', 'chapter');
$courseService = new CourseService(); $courseService = new CourseService();

View File

@ -43,7 +43,7 @@ class PublicController extends \Phalcon\Mvc\Controller
*/ */
public function ip2regionAction() public function ip2regionAction()
{ {
$ip = $this->request->getQuery('ip', 'trim'); $ip = $this->request->getQuery('ip', 'string');
$region = kg_ip2region($ip); $region = kg_ip2region($ip);

View File

@ -121,7 +121,7 @@ class SettingController extends Controller
if ($this->request->isPost()) { if ($this->request->isPost()) {
$section = $this->request->getPost('section'); $section = $this->request->getPost('section', 'string');
$data = $this->request->getPost(); $data = $this->request->getPost();
@ -150,7 +150,7 @@ class SettingController extends Controller
if ($this->request->isPost()) { if ($this->request->isPost()) {
$section = $this->request->getPost('section'); $section = $this->request->getPost('section', 'string');
$data = $this->request->getPost(); $data = $this->request->getPost();
@ -257,7 +257,7 @@ class SettingController extends Controller
if ($this->request->isPost()) { if ($this->request->isPost()) {
$data = $this->request->getPost('vip'); $data = $this->request->getPost('vip', 'string');
$settingService->updateVipSettings($data); $settingService->updateVipSettings($data);
@ -280,7 +280,7 @@ class SettingController extends Controller
if ($this->request->isPost()) { if ($this->request->isPost()) {
$section = $this->request->getPost('section'); $section = $this->request->getPost('section', 'string');
$data = $this->request->getPost(); $data = $this->request->getPost();

View File

@ -84,7 +84,7 @@ class StudentController extends Controller
*/ */
public function editAction() public function editAction()
{ {
$relationId = $this->request->getQuery('relation_id'); $relationId = $this->request->getQuery('relation_id', 'int');
$studentService = new StudentService(); $studentService = new StudentService();

View File

@ -60,7 +60,7 @@ class TestController extends Controller
*/ */
public function livePushAction() public function livePushAction()
{ {
$streamName = $this->request->getQuery('stream'); $streamName = $this->request->getQuery('stream', 'string');
$liveService = new LiveService(); $liveService = new LiveService();
@ -102,7 +102,7 @@ class TestController extends Controller
*/ */
public function smserAction() public function smserAction()
{ {
$phone = $this->request->getPost('phone'); $phone = $this->request->getPost('phone', 'string');
$smserService = new TestSmserService(); $smserService = new TestSmserService();
@ -120,7 +120,7 @@ class TestController extends Controller
*/ */
public function mailerAction() public function mailerAction()
{ {
$email = $this->request->getPost('email'); $email = $this->request->getPost('email', 'string');
$mailerService = new TestMailerService(); $mailerService = new TestMailerService();
@ -166,7 +166,7 @@ class TestController extends Controller
$this->db->begin(); $this->db->begin();
$order = $alipayTestService->createOrder(); $order = $alipayTestService->createAlipayOrder();
$trade = $alipayTestService->createTrade($order); $trade = $alipayTestService->createTrade($order);
$qrcode = $alipayTestService->scan($trade); $qrcode = $alipayTestService->scan($trade);
@ -190,7 +190,7 @@ class TestController extends Controller
$this->db->begin(); $this->db->begin();
$order = $wxpayTestService->createOrder(); $order = $wxpayTestService->createWxpayOrder();
$trade = $wxpayTestService->createTrade($order); $trade = $wxpayTestService->createTrade($order);
$qrcode = $wxpayTestService->scan($trade); $qrcode = $wxpayTestService->scan($trade);
@ -210,7 +210,7 @@ class TestController extends Controller
*/ */
public function alipayStatusAction() public function alipayStatusAction()
{ {
$sn = $this->request->getQuery('sn'); $sn = $this->request->getQuery('sn', 'string');
$alipayTestService = new AlipayTestService(); $alipayTestService = new AlipayTestService();
@ -224,7 +224,7 @@ class TestController extends Controller
*/ */
public function wxpayStatusAction() public function wxpayStatusAction()
{ {
$sn = $this->request->getQuery('sn'); $sn = $this->request->getQuery('sn', 'string');
$wxpayTestService = new WxpayTestService(); $wxpayTestService = new WxpayTestService();

View File

@ -28,8 +28,8 @@ class VodController extends Controller
*/ */
public function playerAction() public function playerAction()
{ {
$chapterId = $this->request->getQuery('chapter_id'); $chapterId = $this->request->getQuery('chapter_id', 'int');
$playUrl = $this->request->getQuery('play_url'); $playUrl = $this->request->getQuery('play_url', 'string');
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
$this->view->pick('public/vod_player'); $this->view->pick('public/vod_player');

View File

@ -3,7 +3,7 @@
namespace App\Http\Admin\Services; namespace App\Http\Admin\Services;
use App\Caches\Chapter as ChapterCache; use App\Caches\Chapter as ChapterCache;
use App\Caches\CourseCatalog as CourseCatalogCache; use App\Caches\CourseChapterList as CourseCatalogCache;
use App\Models\Chapter as ChapterModel; use App\Models\Chapter as ChapterModel;
use App\Models\ChapterLive as ChapterLiveModel; use App\Models\ChapterLive as ChapterLiveModel;
use App\Models\ChapterRead as ChapterReadModel; use App\Models\ChapterRead as ChapterReadModel;

View File

@ -15,11 +15,11 @@ abstract class PayTest extends Service
protected $channel; protected $channel;
/** /**
* 创建订单 * 创建支付宝订单
* *
* @return OrderModel * @return OrderModel
*/ */
public function createOrder() public function createAlipayOrder()
{ {
/** /**
* @var AdminAuth $auth * @var AdminAuth $auth
@ -30,8 +30,45 @@ abstract class PayTest extends Service
$order = new OrderModel(); $order = new OrderModel();
$order->subject = '测试 - 支付测试0.01元'; $order->subject = '测试 - 支付测试3.01元';
$order->amount = 0.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->owner_id = $authUser['id'];
$order->item_type = OrderModel::ITEM_TEST; $order->item_type = OrderModel::ITEM_TEST;

View File

@ -9,17 +9,17 @@
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">公众号ID</label> <label class="layui-form-label">公众号ID</label>
<div class="layui-input-block"> <div class="layui-input-block">
<input class="layui-input" type="text" name="app_id" value="{{ wxpay.mp_app_id }}" lay-verify="required"> <input class="layui-input" type="text" name="mp_app_id" value="{{ wxpay.mp_app_id }}" lay-verify="required">
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">商户ID</label> <label class="layui-form-label">商户ID</label>
<div class="layui-input-block"> <div class="layui-input-block">
<input class="layui-input" type="text" name="mch_id" value="{{ wxpay.mch_id }}" lay-verify="required"> <input class="layui-input" type="text" name="mch_id" value="{{ wxpay.mch_id }}" lay-verify="required">
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">支付Key</label> <label class="layui-form-label">API密钥</label>
<div class="layui-input-block"> <div class="layui-input-block">
<input class="layui-input" type="text" name="key" value="{{ wxpay.key }}" lay-verify="required"> <input class="layui-input" type="text" name="key" value="{{ wxpay.key }}" lay-verify="required">
</div> </div>
@ -40,6 +40,9 @@
</div> </div>
</form> </form>
{% set subject = config.get('env') == 'dev' ? '支付测试3.01元' : '支付测试0.01元' %}
{% set total_amount = config.get('env') == 'dev' ? 3.01 : 0.01 %}
<form class="layui-form kg-form"> <form class="layui-form kg-form">
<fieldset class="layui-elem-field layui-field-title"> <fieldset class="layui-elem-field layui-field-title">
<legend>支付测试</legend> <legend>支付测试</legend>
@ -47,13 +50,13 @@
<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">
<input class="layui-input" type="text" name="subject" value="支付测试0.01元" readonly="readonly"> <input class="layui-input" type="text" name="subject" value="{{ subject }}" readonly="readonly">
</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">
<input class="layui-input" type="text" name="total_amount" value="0.01" readonly="readonly"> <input class="layui-input" type="text" name="total_amount" value="{{ total_amount }}" readonly="readonly">
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">

View File

@ -43,7 +43,7 @@ class AccountController extends Controller
$service->register(); $service->register();
$returnUrl = $this->request->getPost('return_url'); $returnUrl = $this->request->getPost('return_url', 'string');
$content = [ $content = [
'location' => $returnUrl ?: '/', 'location' => $returnUrl ?: '/',
@ -81,7 +81,7 @@ class AccountController extends Controller
$service->loginByPassword(); $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' => 'desktop.index']);
@ -99,7 +99,7 @@ class AccountController extends Controller
$service->loginByVerify(); $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' => 'desktop.index']);

View File

@ -8,7 +8,7 @@ use App\Services\Frontend\Chapter\ChapterInfo as ChapterInfoService;
use App\Services\Frontend\Chapter\ChapterLike as ChapterLikeService; use App\Services\Frontend\Chapter\ChapterLike as ChapterLikeService;
use App\Services\Frontend\Chapter\DanmuList as ChapterDanmuListService; use App\Services\Frontend\Chapter\DanmuList as ChapterDanmuListService;
use App\Services\Frontend\Chapter\Learning as ChapterLearningService; use App\Services\Frontend\Chapter\Learning as ChapterLearningService;
use App\Services\Frontend\Course\ChapterList as CourseCatalogService; use App\Services\Frontend\Course\ChapterList as CourseChapterListService;
/** /**
* @RoutePrefix("/chapter") * @RoutePrefix("/chapter")
@ -34,7 +34,7 @@ class ChapterController extends Controller
]); ]);
} }
$service = new CourseCatalogService(); $service = new CourseChapterListService();
$catalog = $service->handle($chapter['course']['id']); $catalog = $service->handle($chapter['course']['id']);
@ -46,6 +46,8 @@ class ChapterController extends Controller
if ($chapter['model'] == CourseModel::MODEL_VOD) { if ($chapter['model'] == CourseModel::MODEL_VOD) {
$this->view->pick('chapter/vod'); $this->view->pick('chapter/vod');
} elseif ($chapter['model'] == CourseModel::MODEL_READ) {
$this->view->pick('chapter/read');
} elseif ($chapter['model'] == CourseModel::MODEL_LIVE) { } elseif ($chapter['model'] == CourseModel::MODEL_LIVE) {
if ($chapter['status'] == LiveModel::STATUS_ACTIVE) { if ($chapter['status'] == LiveModel::STATUS_ACTIVE) {
$this->view->pick('chapter/live_active'); $this->view->pick('chapter/live_active');
@ -54,8 +56,6 @@ class ChapterController extends Controller
} elseif ($chapter['status'] == LiveModel::STATUS_FORBID) { } elseif ($chapter['status'] == LiveModel::STATUS_FORBID) {
$this->view->pick('chapter/live_forbid'); $this->view->pick('chapter/live_forbid');
} }
} elseif ($chapter['model'] == CourseModel::MODEL_READ) {
$this->view->pick('chapter/read');
} }
$this->view->setVar('chapter', $chapter); $this->view->setVar('chapter', $chapter);

View File

@ -3,7 +3,7 @@
namespace App\Http\Desktop\Controllers; namespace App\Http\Desktop\Controllers;
use App\Http\Desktop\Services\CourseQuery as CourseQueryService; use App\Http\Desktop\Services\CourseQuery as CourseQueryService;
use App\Services\Frontend\Course\ChapterList as CourseCatalogService; use App\Services\Frontend\Course\ChapterList as CourseChapterListService;
use App\Services\Frontend\Course\ConsultList as CourseConsultListService; use App\Services\Frontend\Course\ConsultList as CourseConsultListService;
use App\Services\Frontend\Course\CourseInfo as CourseInfoService; use App\Services\Frontend\Course\CourseInfo as CourseInfoService;
use App\Services\Frontend\Course\CourseList as CourseListService; use App\Services\Frontend\Course\CourseList as CourseListService;
@ -72,7 +72,7 @@ class CourseController extends Controller
$course = $service->handle($id); $course = $service->handle($id);
$service = new CourseCatalogService(); $service = new CourseChapterListService();
$chapters = $service->handle($id); $chapters = $service->handle($id);

View File

@ -113,7 +113,7 @@ class ImController extends Controller
{ {
$service = new ImService(); $service = new ImService();
$id = $this->request->getQuery('id'); $id = $this->request->getQuery('id', 'int');
$service->pullUnreadFriendMessages($id); $service->pullUnreadFriendMessages($id);
@ -197,8 +197,8 @@ class ImController extends Controller
*/ */
public function sendChatMessageAction() public function sendChatMessageAction()
{ {
$from = $this->request->getPost('from'); $from = $this->request->getPost('from', 'string');
$to = $this->request->getPost('to'); $to = $this->request->getPost('to', 'string');
$service = new ImService(); $service = new ImService();
@ -212,8 +212,8 @@ class ImController extends Controller
*/ */
public function sendCsMessageAction() public function sendCsMessageAction()
{ {
$from = $this->request->getPost('from'); $from = $this->request->getPost('from', 'string');
$to = $this->request->getPost('to'); $to = $this->request->getPost('to', 'string');
$service = new ImService(); $service = new ImService();

View File

@ -14,20 +14,6 @@ class LiveController extends Controller
use ResponseTrait; use ResponseTrait;
/**
* @Get("/{id:[0-9]+}/preview", name="desktop.live.preview")
*/
public function previewAction($id)
{
$service = new LiveService();
$stats = $service->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="desktop.live.chats")
*/ */

View File

@ -151,7 +151,7 @@ class MyController extends Controller
*/ */
public function groupsAction() public function groupsAction()
{ {
$scope = $this->request->getQuery('scope', 'trim', 'joined'); $scope = $this->request->getQuery('scope', 'string', 'joined');
$service = new MyGroupListService(); $service = new MyGroupListService();

View File

@ -20,7 +20,7 @@ class OrderController extends Controller
*/ */
public function infoAction() public function infoAction()
{ {
$sn = $this->request->getQuery('sn'); $sn = $this->request->getQuery('sn', 'string');
$service = new OrderInfoService(); $service = new OrderInfoService();
@ -35,8 +35,8 @@ class OrderController extends Controller
*/ */
public function confirmAction() public function confirmAction()
{ {
$itemId = $this->request->getQuery('item_id'); $itemId = $this->request->getQuery('item_id', 'int');
$itemType = $this->request->getQuery('item_type'); $itemType = $this->request->getQuery('item_type', 'int');
$service = new OrderConfirmService(); $service = new OrderConfirmService();
@ -64,7 +64,7 @@ class OrderController extends Controller
*/ */
public function payAction() public function payAction()
{ {
$sn = $this->request->getQuery('sn'); $sn = $this->request->getQuery('sn', 'string');
$service = new OrderInfoService(); $service = new OrderInfoService();
@ -82,7 +82,7 @@ class OrderController extends Controller
*/ */
public function cancelAction() public function cancelAction()
{ {
$sn = $this->request->getPost('sn'); $sn = $this->request->getPost('sn', 'string');
$service = new OrderCancelService(); $service = new OrderCancelService();

View File

@ -49,7 +49,7 @@ class PublicController extends \Phalcon\Mvc\Controller
*/ */
public function qrcodeAction() public function qrcodeAction()
{ {
$text = $this->request->getQuery('text'); $text = $this->request->getQuery('text', 'string');
$level = $this->request->getQuery('level', 'int', 0); $level = $this->request->getQuery('level', 'int', 0);
$size = $this->request->getQuery('size', 'int', 5); $size = $this->request->getQuery('size', 'int', 5);

View File

@ -20,7 +20,7 @@ class RefundController extends Controller
*/ */
public function confirmAction() public function confirmAction()
{ {
$sn = $this->request->getQuery('sn'); $sn = $this->request->getQuery('sn', 'string');
$service = new OrderInfoService(); $service = new OrderInfoService();
@ -57,7 +57,7 @@ class RefundController extends Controller
*/ */
public function infoAction() public function infoAction()
{ {
$sn = $this->request->getQuery('sn'); $sn = $this->request->getQuery('sn', 'string');
$service = new RefundInfoService(); $service = new RefundInfoService();
@ -72,7 +72,7 @@ class RefundController extends Controller
*/ */
public function cancelAction() public function cancelAction()
{ {
$sn = $this->request->getPost('sn'); $sn = $this->request->getPost('sn', 'string');
$service = new RefundCancelService(); $service = new RefundCancelService();

View File

@ -28,7 +28,7 @@ class TradeController extends Controller
*/ */
public function statusAction() public function statusAction()
{ {
$sn = $this->request->getQuery('sn'); $sn = $this->request->getQuery('sn', 'string');
$service = new TradeInfoService(); $service = new TradeInfoService();

View File

@ -32,7 +32,7 @@ class VipController extends Controller
*/ */
public function coursesAction() public function coursesAction()
{ {
$type = $this->request->getQuery('type', 'trim', 'discount'); $type = $this->request->getQuery('type', 'string', 'discount');
$service = new VipCourseListService(); $service = new VipCourseListService();

View File

@ -45,7 +45,7 @@ class Im extends Service
public function getGroupUsers() public function getGroupUsers()
{ {
$id = $this->request->getQuery('id'); $id = $this->request->getQuery('id', 'int');
$validator = new ImGroupValidator(); $validator = new ImGroupValidator();
@ -82,7 +82,7 @@ class Im extends Service
public function getFriendStatus() public function getFriendStatus()
{ {
$id = $this->request->getQuery('id'); $id = $this->request->getQuery('id', 'int');
$validator = new ImUserValidator(); $validator = new ImUserValidator();
@ -106,7 +106,7 @@ class Im extends Service
$user = $this->getImUser($loginUser->id); $user = $this->getImUser($loginUser->id);
$clientId = $this->request->getPost('client_id'); $clientId = $this->request->getPost('client_id', 'string');
Gateway::$registerAddress = $this->getRegisterAddress(); Gateway::$registerAddress = $this->getRegisterAddress();
@ -131,7 +131,7 @@ class Im extends Service
$user = $this->getImUser($loginUser->id); $user = $this->getImUser($loginUser->id);
$status = $this->request->getPost('status'); $status = $this->request->getPost('status', 'string');
$validator = new ImUserValidator(); $validator = new ImUserValidator();
@ -148,7 +148,7 @@ class Im extends Service
$user = $this->getImUser($loginUser->id); $user = $this->getImUser($loginUser->id);
$sign = $this->request->getPost('sign'); $sign = $this->request->getPost('sign', 'string');
$validator = new ImUserValidator(); $validator = new ImUserValidator();
@ -165,7 +165,7 @@ class Im extends Service
$user = $this->getImUser($loginUser->id); $user = $this->getImUser($loginUser->id);
$skin = $this->request->getPost('skin'); $skin = $this->request->getPost('skin', 'string');
$validator = new ImUserValidator(); $validator = new ImUserValidator();

View File

@ -41,7 +41,7 @@ Trait ImGroupTrait
$user = $this->getImUser($loginUser->id); $user = $this->getImUser($loginUser->id);
$noticeId = $this->request->getPost('notice_id'); $noticeId = $this->request->getPost('notice_id', 'int');
$validator = new ImNoticeValidator(); $validator = new ImNoticeValidator();
@ -96,7 +96,7 @@ Trait ImGroupTrait
$user = $this->getImUser($loginUser->id); $user = $this->getImUser($loginUser->id);
$noticeId = $this->request->getPost('notice_id'); $noticeId = $this->request->getPost('notice_id', 'int');
$validator = new ImNoticeValidator(); $validator = new ImNoticeValidator();

View File

@ -59,7 +59,7 @@ class Live extends Service
public function bindUser($id) public function bindUser($id)
{ {
$clientId = $this->request->getPost('client_id'); $clientId = $this->request->getPost('client_id', 'string');
$chapter = $this->checkChapter($id); $chapter = $this->checkChapter($id);

View File

@ -2,27 +2,23 @@
{% block content %} {% block content %}
{% set course_url = url({'for':'desktop.course.show','id':chapter.course.id}) %}
{% set live_status_url = url({'for':'desktop.live.status','id':chapter.id}) %} {% set live_status_url = url({'for':'desktop.live.status','id':chapter.id}) %}
{% set show_countdown = time() < chapter.start_time ? 1 : 0 %}
<div class="breadcrumb"> {% if time() < chapter.start_time %}
<span class="layui-breadcrumb">
<a href="{{ course_url }}"><i class="layui-icon layui-icon-return"></i> 返回课程</a>
<a><cite>{{ chapter.course.title }}</cite></a>
<a><cite>{{ chapter.title }}</cite></a>
</span>
</div>
{% if show_countdown == 1 %}
<div class="countdown"> <div class="countdown">
<div class="icon"><i class="layui-icon layui-icon-time"></i></div> <div class="icon"><i class="layui-icon layui-icon-time"></i></div>
<div class="timer"></div> <div class="timer"></div>
<div class="tips">开播倒计时开始啦,敬请关注!</div> <div class="tips">直播倒计时开始啦,敬请关注!</div>
</div>
{% elseif chapter.start_time < time() and chapter.end_time > time() %}
<div class="countdown">
<div class="icon"><i class="layui-icon layui-icon-face-surprised"></i></div>
<div class="timer"></div>
<div class="tips">直播时间到了,主播去哪了?</div>
</div> </div>
{% else %} {% else %}
<div class="countdown"> <div class="countdown">
<div class="icon"><i class="layui-icon layui-icon-face-surprised"></i></div> <div class="icon"><i class="layui-icon layui-icon-tree"></i></div>
<div class="tips">直播已结束,谢谢关注!</div> <div class="tips">直播已结束,谢谢关注!</div>
</div> </div>
{% endif %} {% endif %}

View File

@ -69,7 +69,6 @@ class Pay extends Listener
$this->db->rollback(); $this->db->rollback();
$this->logger->error('After Pay Event Error ' . kg_json_encode([ $this->logger->error('After Pay Event Error ' . kg_json_encode([
'line' => $e->getLine(),
'code' => $e->getCode(), 'code' => $e->getCode(),
'message' => $e->getMessage(), 'message' => $e->getMessage(),
])); ]));

View File

@ -9,7 +9,7 @@ class ChapterLive extends Model
* 状态类型 * 状态类型
*/ */
const STATUS_ACTIVE = 1; // 活跃 const STATUS_ACTIVE = 1; // 活跃
const STATUS_INACTIVE = 2; // 非活跃 const STATUS_INACTIVE = 2; // 静默
const STATUS_FORBID = 3; // 禁播 const STATUS_FORBID = 3; // 禁播
/** /**
@ -82,6 +82,8 @@ class ChapterLive extends Model
public function beforeCreate() public function beforeCreate()
{ {
$this->status = self::STATUS_INACTIVE;
$this->create_time = time(); $this->create_time = time();
} }

View File

@ -2,7 +2,7 @@
namespace App\Services\Frontend\Course; namespace App\Services\Frontend\Course;
use App\Caches\CourseCatalog as CourseCatalogCache; use App\Caches\CourseChapterList as CourseChapterListCache;
use App\Models\Course as CourseModel; use App\Models\Course as CourseModel;
use App\Models\User as UserModel; use App\Models\User as UserModel;
use App\Repos\Course as CourseRepo; use App\Repos\Course as CourseRepo;
@ -27,7 +27,7 @@ class ChapterList extends FrontendService
protected function getChapters(CourseModel $course, UserModel $user) protected function getChapters(CourseModel $course, UserModel $user)
{ {
$cache = new CourseCatalogCache(); $cache = new CourseChapterListCache();
$chapters = $cache->get($course->id); $chapters = $cache->get($course->id);

View File

@ -15,7 +15,7 @@ class LivePushUrl extends FrontendService
public function handle() public function handle()
{ {
$chapterId = $this->request->getQuery('chapter_id'); $chapterId = $this->request->getQuery('chapter_id', 'int');
$chapter = $this->checkChapter($chapterId); $chapter = $this->checkChapter($chapterId);

View File

@ -11,9 +11,9 @@ class LiveNotify extends Service
public function handle() public function handle()
{ {
$time = $this->request->getPost('t'); $time = $this->request->getPost('t', 'int');
$sign = $this->request->getPost('sign'); $sign = $this->request->getPost('sign', 'string');
$action = $this->request->getQuery('action'); $action = $this->request->getQuery('action', 'string');
if (!$this->checkSign($sign, $time)) { if (!$this->checkSign($sign, $time)) {
return false; return false;
@ -57,7 +57,7 @@ class LiveNotify extends Service
*/ */
protected function handleStreamBegin() protected function handleStreamBegin()
{ {
$streamId = $this->request->getPost('stream_id'); $streamId = $this->request->getPost('stream_id', 'string');
$chapter = $this->getChapter($streamId); $chapter = $this->getChapter($streamId);
@ -83,7 +83,7 @@ class LiveNotify extends Service
*/ */
protected function handleStreamEnd() protected function handleStreamEnd()
{ {
$streamId = $this->request->getPost('stream_id'); $streamId = $this->request->getPost('stream_id', 'string');
$chapter = $this->getChapter($streamId); $chapter = $this->getChapter($streamId);

View File

@ -129,7 +129,13 @@ class Alipay extends PayService
$this->eventsManager->fire('pay:afterPay', $this, $trade); $this->eventsManager->fire('pay:afterPay', $this, $trade);
return $this->gateway->success(); $trade = $tradeRepo->findById($trade->id);
if ($trade->status == TradeModel::STATUS_FINISHED) {
return $this->gateway->success();
}
return false;
} }
/** /**

View File

@ -131,7 +131,13 @@ class Wxpay extends PayService
$this->eventsManager->fire('pay:afterPay', $this, $trade); $this->eventsManager->fire('pay:afterPay', $this, $trade);
return $this->gateway->success(); $trade = $tradeRepo->findById($trade->id);
if ($trade->status == TradeModel::STATUS_FINISHED) {
return $this->gateway->success();
}
return false;
} }
/** /**

View File

@ -47,8 +47,8 @@ class WxpayGateway extends Service
'mch_id' => $this->settings['mch_id'], 'mch_id' => $this->settings['mch_id'],
'key' => $this->settings['key'], 'key' => $this->settings['key'],
'notify_url' => $this->settings['notify_url'], 'notify_url' => $this->settings['notify_url'],
'cert_client' => config_path('wxpay/client_cert.pem'), 'cert_client' => config_path('wxpay/apiclient_cert.pem'),
'cert_key' => config_path('wxpay/client_key.pem'), 'cert_key' => config_path('wxpay/apiclient_key.pem'),
'log' => [ 'log' => [
'file' => log_path('wxpay.log'), 'file' => log_path('wxpay.log'),
'level' => $level, 'level' => $level,

View File

@ -911,7 +911,7 @@ body {
.countdown { .countdown {
color: #666; color: #666;
margin-top: 50px; margin-top: 30px;
text-align: center; text-align: center;
} }
@ -924,7 +924,7 @@ body {
} }
.countdown .tips { .countdown .tips {
font-size: 18px; font-size: 16px;
margin: 20px 0; margin: 20px 0;
} }
@ -934,6 +934,7 @@ body {
.countdown .timer span { .countdown .timer span {
color: green; color: green;
font-size: 36px;
padding: 10px; padding: 10px;
} }