mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-07-16 05:12:19 +08:00
设计直播回调
This commit is contained in:
parent
737ca424d0
commit
065b910b33
@ -71,7 +71,7 @@ class VodEventTask extends Task
|
||||
|
||||
$chapter->update(['attrs' => $attrs]);
|
||||
|
||||
$this->updateVodAttrs($chapter->course_id);
|
||||
$this->updateVodAttrs($chapter);
|
||||
}
|
||||
|
||||
protected function handleProcedureStateChangedEvent($event)
|
||||
@ -144,11 +144,11 @@ class VodEventTask extends Task
|
||||
return in_array(strtolower($format), $formats);
|
||||
}
|
||||
|
||||
protected function updateVodAttrs($courseId)
|
||||
protected function updateVodAttrs(ChapterModel $chapter)
|
||||
{
|
||||
$courseStats = new CourseStatService();
|
||||
|
||||
$courseStats->updateVodAttrs($courseId);
|
||||
$courseStats->updateVodAttrs($chapter->course_id);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ class SettingController extends Controller
|
||||
|
||||
} else {
|
||||
|
||||
$live = $settingService->getSectionSettings($section);
|
||||
$live = $settingService->getLiveSettings();
|
||||
|
||||
$ptt = json_decode($live->pull_trans_template);
|
||||
|
||||
|
@ -195,20 +195,6 @@ class TestController extends Controller
|
||||
return $this->jsonSuccess(['status' => $status]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Post("/alipay/cancel", name="admin.test.alipay_cancel")
|
||||
*/
|
||||
public function alipayCancelAction()
|
||||
{
|
||||
$sn = $this->request->getPost('sn');
|
||||
|
||||
$alipayTestService = new AlipayTestService();
|
||||
|
||||
$alipayTestService->cancel($sn);
|
||||
|
||||
return $this->jsonSuccess(['msg' => '取消订单成功']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Get("/wxpay", name="admin.test.wxpay")
|
||||
*/
|
||||
@ -247,18 +233,4 @@ class TestController extends Controller
|
||||
return $this->jsonSuccess(['status' => $status]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Post("/wxpay/cancel", name="admin.test.wxpay_cancel")
|
||||
*/
|
||||
public function wxpayCancelAction()
|
||||
{
|
||||
$sn = $this->request->getPost('sn');
|
||||
|
||||
$wxpayTestService = new WxpayTestService();
|
||||
|
||||
$wxpayTestService->cancel($sn);
|
||||
|
||||
return $this->jsonSuccess(['msg' => '取消订单成功']);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -2,10 +2,7 @@
|
||||
|
||||
namespace App\Http\Admin\Services;
|
||||
|
||||
use App\Models\Order as OrderModel;
|
||||
use App\Models\Trade as TradeModel;
|
||||
use App\Repos\Order as OrderRepo;
|
||||
use App\Repos\Trade as TradeRepo;
|
||||
use App\Services\Pay\Alipay as AlipayService;
|
||||
|
||||
class AlipayTest extends PayTest
|
||||
@ -38,30 +35,4 @@ class AlipayTest extends PayTest
|
||||
return $alipayService->status($tradeNo);
|
||||
}
|
||||
|
||||
public function cancel($tradeNo)
|
||||
{
|
||||
$tradeRepo = new TradeRepo();
|
||||
|
||||
$trade = $tradeRepo->findBySn($tradeNo);
|
||||
|
||||
$orderRepo = new OrderRepo();
|
||||
|
||||
$order = $orderRepo->findById($trade->order_id);
|
||||
|
||||
$alipayService = new AlipayService();
|
||||
|
||||
$response = $alipayService->cancel($trade->sn);
|
||||
|
||||
if ($response) {
|
||||
|
||||
$trade->status = TradeModel::STATUS_CLOSED;
|
||||
$trade->update();
|
||||
|
||||
if ($order->status != OrderModel::STATUS_PENDING) {
|
||||
$order->status = OrderModel::STATUS_PENDING;
|
||||
$order->update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -77,12 +77,4 @@ abstract class PayTest extends Service
|
||||
*/
|
||||
abstract public function scan(TradeModel $trade);
|
||||
|
||||
/**
|
||||
* 取消交易
|
||||
*
|
||||
* @param string $tradeNo
|
||||
* @return bool
|
||||
*/
|
||||
abstract public function cancel($tradeNo);
|
||||
|
||||
}
|
||||
|
@ -132,4 +132,17 @@ class Setting extends Service
|
||||
}
|
||||
}
|
||||
|
||||
public function getLiveSettings()
|
||||
{
|
||||
$live = $this->getSectionSettings('live');
|
||||
|
||||
$live->notify_stream_begin_url = $live->notify_stream_begin_url ?: kg_full_url(['for' => 'desktop.live_notify'], ['action' => 'streamBegin']);
|
||||
$live->notify_stream_end_url = $live->notify_stream_end_url ?: kg_full_url(['for' => 'desktop.live_notify'], ['action' => 'streamEnd']);
|
||||
$live->notify_record_url = $live->notify_record_url ?: kg_full_url(['for' => 'desktop.live_notify'], ['action' => 'record']);
|
||||
$live->notify_snapshot_url = $live->notify_snapshot_url ?: kg_full_url(['for' => 'desktop.live_notify'], ['action' => 'snapshot']);
|
||||
$live->notify_porn_url = $live->notify_porn_url ?: kg_full_url(['for' => 'desktop.live_notify'], ['action' => 'porn']);
|
||||
|
||||
return $live;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -26,11 +26,4 @@ class WxpayTest extends PayTest
|
||||
return $wxpayService->status($tradeNo);
|
||||
}
|
||||
|
||||
public function cancel($tradeNo)
|
||||
{
|
||||
$wxpayService = new WxpayService();
|
||||
|
||||
return $wxpayService->close($tradeNo);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
<ul class="layui-tab-title kg-tab-title">
|
||||
<li class="layui-this">推流配置</li>
|
||||
<li>拉流配置</li>
|
||||
<li>回调配置</li>
|
||||
</ul>
|
||||
<div class="layui-tab-content">
|
||||
<div class="layui-tab-item layui-show">
|
||||
@ -14,6 +15,9 @@
|
||||
<div class="layui-tab-item">
|
||||
{{ partial('setting/live_pull') }}
|
||||
</div>
|
||||
<div class="layui-tab-item">
|
||||
{{ partial('setting/live_callback') }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
45
app/Http/Admin/Views/setting/live_callback.volt
Normal file
45
app/Http/Admin/Views/setting/live_callback.volt
Normal file
@ -0,0 +1,45 @@
|
||||
<form class="layui-form kg-form" method="POST" action="{{ url({'for':'admin.setting.live'}) }}">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">回调密钥</label>
|
||||
<div class="layui-input-block">
|
||||
<input class="layui-input" type="text" name="notify_auth_key" value="{{ live.notify_auth_key }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">推流回调</label>
|
||||
<div class="layui-input-block">
|
||||
<input class="layui-input" type="text" name="notify_stream_begin_url" value="{{ live.notify_stream_begin_url }}" layui-verify="required">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">断流回调</label>
|
||||
<div class="layui-input-block">
|
||||
<input class="layui-input" type="text" name="notify_stream_end_url" value="{{ live.notify_stream_end_url }}" layui-verify="required">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">录制回调</label>
|
||||
<div class="layui-input-block">
|
||||
<input class="layui-input" type="text" name="notify_record_url" value="{{ live.notify_record_url }}" layui-verify="required">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">截图回调</label>
|
||||
<div class="layui-input-block">
|
||||
<input class="layui-input" type="text" name="notify_snapshot_url" value="{{ live.notify_snapshot_url }}" layui-verify="required">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">鉴黄回调</label>
|
||||
<div class="layui-input-block">
|
||||
<input class="layui-input" type="text" name="notify_porn_url" value="{{ live.notify_porn_url }}" layui-verify="required">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"></label>
|
||||
<div class="layui-input-block">
|
||||
<button class="layui-btn" lay-submit="true" lay-filter="go">提交</button>
|
||||
<button type="button" class="kg-back layui-btn layui-btn-primary">返回</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
@ -27,7 +27,7 @@
|
||||
|
||||
{% block inline_js %}
|
||||
|
||||
{% if Code %}
|
||||
{% if qrcode %}
|
||||
<script>
|
||||
|
||||
layui.use(['jquery'], function () {
|
||||
@ -40,7 +40,7 @@
|
||||
url: '/admin/test/alipay/status',
|
||||
data: {sn: sn},
|
||||
success: function (res) {
|
||||
if (res.status === 'finished') {
|
||||
if ($.inArray(res.status, [2, 3]) > -1) {
|
||||
$('#success-tips').removeClass('layui-hide');
|
||||
$('#qrcode').addClass('layui-hide');
|
||||
clearInterval(interval);
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
{% block inline_js %}
|
||||
|
||||
{% if Code %}
|
||||
{% if qrcode %}
|
||||
<script>
|
||||
|
||||
layui.use(['jquery'], function () {
|
||||
@ -38,7 +38,7 @@
|
||||
url: '/admin/test/wxpay/status',
|
||||
data: {sn: sn},
|
||||
success: function (res) {
|
||||
if (res.status === 'finished') {
|
||||
if ($.inArray(res.status, [2, 3]) > -1) {
|
||||
$('#success-tips').removeClass('layui-hide');
|
||||
$('#qrcode').addClass('layui-hide');
|
||||
clearInterval(interval);
|
||||
|
@ -4,6 +4,7 @@ namespace App\Http\Desktop\Controllers;
|
||||
|
||||
use App\Library\CsrfToken as CsrfTokenService;
|
||||
use App\Repos\Upload as UploadRepo;
|
||||
use App\Services\LiveNotify as LiveNotifyService;
|
||||
use App\Services\Pay\Alipay as AlipayService;
|
||||
use App\Services\Pay\Wxpay as WxpayService;
|
||||
use App\Services\Storage as StorageService;
|
||||
@ -80,9 +81,9 @@ class PublicController extends \Phalcon\Mvc\Controller
|
||||
*/
|
||||
public function alipayNotifyAction()
|
||||
{
|
||||
$alipayService = new AlipayService();
|
||||
$service = new AlipayService();
|
||||
|
||||
$response = $alipayService->notify();
|
||||
$response = $service->notify();
|
||||
|
||||
if (!$response) exit;
|
||||
|
||||
@ -96,9 +97,9 @@ class PublicController extends \Phalcon\Mvc\Controller
|
||||
*/
|
||||
public function wxpayNotifyAction()
|
||||
{
|
||||
$wxpayService = new WxpayService();
|
||||
$service = new WxpayService();
|
||||
|
||||
$response = $wxpayService->notify();
|
||||
$response = $service->notify();
|
||||
|
||||
if (!$response) exit;
|
||||
|
||||
@ -112,7 +113,13 @@ class PublicController extends \Phalcon\Mvc\Controller
|
||||
*/
|
||||
public function liveNotifyAction()
|
||||
{
|
||||
$service = new LiveNotifyService();
|
||||
|
||||
if ($service->handle()) {
|
||||
return $this->jsonSuccess();
|
||||
} else {
|
||||
$this->response->setStatusCode(403);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,8 +16,8 @@
|
||||
<div class="channel">
|
||||
{% set create_url = url({'for':'desktop.trade.create'}) %}
|
||||
{% set status_url = url({'for':'desktop.trade.status'}) %}
|
||||
<a class="alipay btn-pay" href="javascript:" data-channel="alipay"></a>
|
||||
<a class="wxpay btn-pay" href="javascript:" data-channel="wxpay"></a>
|
||||
<a class="alipay btn-pay" href="javascript:" data-channel="1"></a>
|
||||
<a class="wxpay btn-pay" href="javascript:" data-channel="2"></a>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<span class="tips">友情提示:请在12小时内完成支付,有问题请联系客服</span>
|
||||
|
@ -27,25 +27,22 @@ class ChapterVod extends Service
|
||||
$result = [];
|
||||
|
||||
foreach ($transcode as $key => $file) {
|
||||
|
||||
$file['url'] = $vod->getPlayUrl($file['url']);
|
||||
|
||||
$definition = $this->getDefinitionType($file['height'], $file['rate']);
|
||||
|
||||
$result[$definition] = $file;
|
||||
$type = $this->getDefinitionType($file['height']);
|
||||
$result[$type] = $file;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function getDefinitionType($height, $rate)
|
||||
protected function getDefinitionType($height)
|
||||
{
|
||||
$default = 'od';
|
||||
|
||||
$vodTemplates = $this->getVodTemplates();
|
||||
|
||||
foreach ($vodTemplates as $key => $template) {
|
||||
if ($height >= $template['height'] || $rate >= $template['rate']) {
|
||||
if ($height >= $template['height']) {
|
||||
return $key;
|
||||
}
|
||||
}
|
||||
|
@ -6,12 +6,12 @@ use App\Services\Frontend\ChapterTrait;
|
||||
use App\Services\Frontend\CourseTrait;
|
||||
use App\Services\Frontend\Service as FrontendService;
|
||||
|
||||
class ChapterBasicInfo extends FrontendService
|
||||
class BasicInfo extends FrontendService
|
||||
{
|
||||
|
||||
use CourseTrait;
|
||||
use ChapterTrait;
|
||||
use ChapterBasicInfoTrait;
|
||||
use BasicInfoTrait;
|
||||
|
||||
public function handle($id)
|
||||
{
|
@ -9,7 +9,7 @@ use App\Services\ChapterVod as ChapterVodService;
|
||||
use App\Services\Live as LiveService;
|
||||
use WhichBrowser\Parser as BrowserParser;
|
||||
|
||||
trait ChapterBasicInfoTrait
|
||||
trait BasicInfoTrait
|
||||
{
|
||||
|
||||
use ChapterLiveTrait;
|
@ -27,7 +27,7 @@ class ChapterInfo extends FrontendService
|
||||
|
||||
use CourseTrait;
|
||||
use ChapterTrait;
|
||||
use ChapterBasicInfoTrait;
|
||||
use BasicInfoTrait;
|
||||
|
||||
public function handle($id)
|
||||
{
|
||||
|
105
app/Services/LiveNotify.php
Normal file
105
app/Services/LiveNotify.php
Normal file
@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
class LiveNotify extends Service
|
||||
{
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$time = $this->request->getPost('t');
|
||||
$sign = $this->request->getPost('sign');
|
||||
$type = $this->request->getQuery('action');
|
||||
|
||||
if (!$this->checkSign($time, $sign)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'streamBegin':
|
||||
$result = $this->streamBegin();
|
||||
break;
|
||||
case 'streamEnd':
|
||||
$result = $this->streamEnd();
|
||||
break;
|
||||
case 'record':
|
||||
$result = $this->record();
|
||||
break;
|
||||
case 'snapshot':
|
||||
$result = $this->snapshot();
|
||||
break;
|
||||
case 'porn':
|
||||
$result = $this->porn();
|
||||
break;
|
||||
default:
|
||||
$result = false;
|
||||
break;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 推流
|
||||
*/
|
||||
protected function streamBegin()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 断流
|
||||
*/
|
||||
protected function streamEnd()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 断流
|
||||
*/
|
||||
protected function record()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 断流
|
||||
*/
|
||||
protected function snapshot()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 断流
|
||||
*/
|
||||
protected function porn()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查签名
|
||||
* @param string $sign
|
||||
* @param int $time
|
||||
* @return bool
|
||||
*/
|
||||
protected function checkSign($sign, $time)
|
||||
{
|
||||
if (empty($sign) || empty($time)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($time < time() + 600) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$live = $this->getSectionSettings('live');
|
||||
|
||||
$mySign = md5($live['notify_auth_key'] . $time);
|
||||
|
||||
return $sign == $mySign;
|
||||
}
|
||||
|
||||
}
|
@ -13,7 +13,7 @@ abstract class Pay extends Service
|
||||
* 交易状态
|
||||
*
|
||||
* @param string $tradeNo
|
||||
* @return string
|
||||
* @return int
|
||||
*/
|
||||
public function status($tradeNo)
|
||||
{
|
||||
|
@ -90,12 +90,12 @@ $config['cache']['db'] = 0;
|
||||
/**
|
||||
* 有效期(秒)
|
||||
*/
|
||||
$config['cache']['lifetime'] = 2 * 3600;
|
||||
$config['cache']['lifetime'] = 24 * 3600;
|
||||
|
||||
/**
|
||||
* redis库编号
|
||||
*/
|
||||
$config['session']['db'] = 0;
|
||||
$config['session']['db'] = 1;
|
||||
|
||||
/**
|
||||
* 有效期(秒)
|
||||
@ -112,6 +112,26 @@ $config['metadata']['db'] = 2;
|
||||
*/
|
||||
$config['metadata']['lifetime'] = 7 * 86400;
|
||||
|
||||
/**
|
||||
* statsKey
|
||||
*/
|
||||
$config['metadata']['statsKey'] = '_PH_METADATA_';
|
||||
|
||||
/**
|
||||
* redis库编号
|
||||
*/
|
||||
$config['annotation']['db'] = 2;
|
||||
|
||||
/**
|
||||
* 有效期(秒)
|
||||
*/
|
||||
$config['annotation']['lifetime'] = 7 * 86400;
|
||||
|
||||
/**
|
||||
* statsKey
|
||||
*/
|
||||
$config['annotation']['statsKey'] = '_PH_ANNOTATION_';
|
||||
|
||||
/**
|
||||
* 密钥
|
||||
*/
|
||||
|
10334
public/sitemap.xml
10334
public/sitemap.xml
File diff suppressed because it is too large
Load Diff
@ -209,8 +209,8 @@ img.kg-avatar {
|
||||
}
|
||||
|
||||
img.kg-qrcode {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
width: 140px;
|
||||
height: 140px;
|
||||
border: 3px dashed #ccc;
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ layui.use(['jquery', 'layer'], function () {
|
||||
var interval = setInterval(function () {
|
||||
var queryData = {sn: res.sn};
|
||||
$.get(statusUrl, queryData, function (res) {
|
||||
if (res.status === 'finished') {
|
||||
if ($.inArray(res.status, [2, 3]) > -1) {
|
||||
clearInterval(interval);
|
||||
$('#pay-layer').html('<div class="success-tips">支付成功</div>');
|
||||
setTimeout(function () {
|
||||
|
Loading…
x
Reference in New Issue
Block a user