1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-24 20:06:09 +08:00

Merge branch 'koogua/v1.4.9'

This commit is contained in:
koogua 2021-12-30 20:07:56 +08:00
commit a50889df71
19 changed files with 993 additions and 900 deletions

View File

@ -1,3 +1,16 @@
### [v1.4.9](https://gitee.com/koogua/course-tencent-cloud/releases/v1.4.9)(2022-01-01)
- 修正订单消费未奖励积分问题
- 修正前台课程分类排序无效问题
- 修正后台点播防盗链配置显隐藏状态问题
- 修正分享链接非h5环境也会跳转到h5问题
- 修正后台钉钉配置调用错误
- 使用腾讯云新SDK发送短信
- 优化show400错误输出页
- 优化下单时产品检查逻辑
- 优化上传文件筛选限制
- 优化后台配置更新
### [v1.4.8](https://gitee.com/koogua/course-tencent-cloud/releases/v1.4.8)(2021-11-28)
- 修正后台下载课程附件问题

View File

@ -39,6 +39,7 @@ class CategoryList extends Cache
->where('type = :type:', ['type' => $type])
->andWhere('published = 1')
->andWhere('deleted = 0')
->orderBy('level ASC, priority ASC')
->execute();
if ($categories->count() == 0) {

View File

@ -105,7 +105,7 @@ class SettingController extends Controller
$data = $this->request->getPost();
$settingService->updateVodSettings($section, $data);
$settingService->updateSettings($section, $data);
return $this->jsonSuccess(['msg' => '更新配置成功']);
@ -186,7 +186,7 @@ class SettingController extends Controller
$data = $this->request->getPost();
$settingService->updateSmsSettings($section, $data);
$settingService->updateSettings($section, $data);
return $this->jsonSuccess(['msg' => '更新配置成功']);
@ -266,7 +266,7 @@ class SettingController extends Controller
$data = $this->request->getPost();
$settingService->updatePointSettings($section, $data);
$settingService->updateSettings($section, $data);
return $this->jsonSuccess(['msg' => '更新配置成功']);
@ -398,7 +398,7 @@ class SettingController extends Controller
$data = $this->request->getPost();
$settingService->updatePointSettings($section, $data);
$settingService->updateSettings($section, $data);
return $this->jsonSuccess(['msg' => '更新配置成功']);

File diff suppressed because it is too large Load Diff

View File

@ -141,9 +141,17 @@ class Setting extends Service
$settingsRepo = new SettingRepo();
foreach ($settings as $key => $value) {
if (is_array($value)) {
array_walk_recursive($value, function (&$item) {
$item = trim($item);
});
$itemValue = kg_json_encode($value);
} else {
$itemValue = trim($value);
}
$item = $settingsRepo->findItem($section, $key);
if ($item) {
$item->item_value = trim($value);
$item->item_value = $itemValue;
$item->update();
}
}
@ -164,16 +172,6 @@ class Setting extends Service
$this->updateSettings($section, $settings);
}
public function updateVodSettings($section, $settings)
{
if (isset($settings['video_quality'])) {
$data = array_values($settings['video_quality']);
$settings['video_quality'] = kg_json_encode($data);
}
$this->updateSettings($section, $settings);
}
public function updateLiveSettings($section, $settings)
{
$protocol = ['http://', 'https://'];
@ -187,28 +185,6 @@ class Setting extends Service
$this->updateSettings($section, $settings);
}
public function updateSmsSettings($section, $settings)
{
if (isset($settings['template'])) {
$settings['template'] = kg_json_encode($settings['template']);
}
$this->updateSettings($section, $settings);
}
public function updatePointSettings($section, $settings)
{
if (isset($settings['event_rule'])) {
$settings['event_rule'] = kg_json_encode($settings['event_rule']);
}
if (isset($settings['consume_rule'])) {
$settings['consume_rule'] = kg_json_encode($settings['consume_rule']);
}
$this->updateSettings($section, $settings);
}
public function updateVipSettings($items)
{
$vipRepo = new VipRepo();

View File

@ -164,7 +164,8 @@
upload.render({
elem: '#upload-logo',
url: '/admin/upload/icon/img',
exts: 'gif|jpg|png',
accept: 'images',
acceptMime: 'image/*',
before: function () {
layer.load();
},
@ -180,7 +181,8 @@
upload.render({
elem: '#upload-favicon',
url: '/admin/upload/icon/img',
exts: 'gif|jpg|png|ico',
accept: 'images',
acceptMime: 'image/*',
before: function () {
layer.load();
},

View File

@ -92,7 +92,7 @@
<input type="radio" name="key_anti_enabled" value="0" title="否" lay-filter="key_anti_enabled" {% if vod.key_anti_enabled == 0 %}checked="checked"{% endif %}>
</div>
</div>
<div id="key-anti-block" {{ key_anti_display }}>
<div id="key-anti-block" style="{{ key_anti_display }}">
<div class="layui-form-item">
<label class="layui-form-label">防盗链Key</label>
<div class="layui-input-block">
@ -100,7 +100,7 @@
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">有效(秒)</label>
<label class="layui-form-label">有效时间(秒)</label>
<div class="layui-input-block">
<input class="layui-input" type="text" name="key_anti_expiry" value="{{ vod.key_anti_expiry }}" lay-verify="required">
</div>

View File

@ -45,6 +45,12 @@ class ErrorController extends \Phalcon\Mvc\Controller
public function show400Action()
{
$this->response->setStatusCode(400);
$messages = $this->flashSession->getMessages('error');
$message = array_pop($messages);
$this->view->setVar('message', $message);
}
/**

View File

@ -52,7 +52,9 @@ class ShareUrl extends Service
$result = $this->getHomeUrl();
}
return $this->h5Enabled() ? $result['h5'] : $result['web'];
$gotoH5 = $this->h5Enabled() && $this->isMobileBrowser();
return $gotoH5 ? $result['h5'] : $result['web'];
}
public function getHomeUrl()

View File

@ -5,7 +5,7 @@
<div class="layui-fluid">
<div class="kg-tips">
<i class="layui-icon layui-icon-face-surprised"></i>
<div class="message">{{ flashSession.output() }}</div>
<div class="message">{{ message }}</div>
<div class="layui-text">
<h1>
<span class="layui-anim layui-anim-loop">4</span>

View File

@ -16,7 +16,7 @@ class AppInfo
protected $link = 'https://koogua.com';
protected $version = '1.4.8';
protected $version = '1.4.9';
public function __get($name)
{

View File

@ -108,15 +108,11 @@ class Order extends Repository
* @param string $itemType
* @return OrderModel|Model|bool
*/
public function findUserLastFinishedOrder($userId, $itemId, $itemType)
public function findUserLastPendingOrder($userId, $itemId, $itemType)
{
$status = OrderModel::STATUS_FINISHED;
$status = OrderModel::STATUS_PENDING;
return OrderModel::findFirst([
'conditions' => 'owner_id = ?1 AND item_id = ?2 AND item_type = ?3 AND status = ?4',
'bind' => [1 => $userId, 2 => $itemId, 3 => $itemType, 4 => $status],
'order' => 'id DESC',
]);
return $this->findUserLastStatusOrder($userId, $itemId, $itemType, $status);
}
/**
@ -125,12 +121,37 @@ class Order extends Repository
* @param string $itemType
* @return OrderModel|Model|bool
*/
public function findUserLastPendingOrder($userId, $itemId, $itemType)
public function findUserLastDeliveringOrder($userId, $itemId, $itemType)
{
$status = OrderModel::STATUS_PENDING;
$status = OrderModel::STATUS_DELIVERING;
return $this->findUserLastStatusOrder($userId, $itemId, $itemType, $status);
}
/**
* @param int $userId
* @param string $itemId
* @param string $itemType
* @return OrderModel|Model|bool
*/
public function findUserLastFinishedOrder($userId, $itemId, $itemType)
{
$status = OrderModel::STATUS_FINISHED;
return $this->findUserLastStatusOrder($userId, $itemId, $itemType, $status);
}
/**
* @param int $userId
* @param string $itemId
* @param string $itemType
* @param int $status
* @return OrderModel|Model|bool
*/
public function findUserLastStatusOrder($userId, $itemId, $itemType, $status)
{
return OrderModel::findFirst([
'conditions' => 'owner_id = ?1 AND item_id = ?2 AND item_type = ?3 AND status= ?4',
'conditions' => 'owner_id = ?1 AND item_id = ?2 AND item_type = ?3 AND status = ?4',
'bind' => [1 => $userId, 2 => $itemId, 3 => $itemType, 4 => $status],
'order' => 'id DESC',
]);

View File

@ -24,11 +24,13 @@ class OrderConsume extends PointHistory
if ($pointEnabled == 0) return;
$ruleEnabled = $setting['consume_rule']['enabled'] ?? 0;
$consumeRule = json_decode($setting['consume_rule'], true);
$ruleEnabled = $consumeRule['enabled'] ?? 0;
if ($ruleEnabled == 0) return;
$ruleRate = $setting['consume_rule']['rate'] ?? 0;
$ruleRate = $consumeRule['rate'] ?? 0;
if ($ruleRate <= 0) return;

View File

@ -8,9 +8,15 @@
namespace App\Services;
use Phalcon\Logger\Adapter\File as FileLogger;
use Qcloud\Sms\SmsSingleSender;
use TencentCloud\Common\Credential;
use TencentCloud\Common\Exception\TencentCloudSDKException;
use TencentCloud\Common\Profile\ClientProfile;
use TencentCloud\Common\Profile\HttpProfile;
use TencentCloud\Sms\V20210111\Models\SendSmsRequest;
use TencentCloud\Sms\V20210111\Models\SendStatus;
use TencentCloud\Sms\V20210111\SmsClient;
Abstract class Smser extends Service
abstract class Smser extends Service
{
/**
@ -40,31 +46,57 @@ Abstract class Smser extends Service
*/
public function send($phoneNumber, $templateId, $params)
{
$sender = $this->createSingleSender();
$secret = $this->getSettings('secret');
$params = $this->formatParams($params);
$region = $this->settings['region'] ?: 'ap-guangzhou';
$signature = $this->getSignature();
$templateParams = $this->formatTemplateParams($params);
try {
$response = $sender->sendWithParam('86', $phoneNumber, $templateId, $params, $signature);
$credential = new Credential($secret['secret_id'], $secret['secret_key']);
$this->logger->debug('Send Message Response ' . $response);
$httpProfile = new HttpProfile();
$content = json_decode($response, true);
$httpProfile->setEndpoint('sms.tencentcloudapi.com');
$result = $content['result'] == 0;
$clientProfile = new ClientProfile();
if ($result == false) {
$this->logger->error('Send Message Failed ' . $response);
}
$clientProfile->setHttpProfile($httpProfile);
} catch (\Exception $e) {
$client = new SmsClient($credential, $region, $clientProfile);
$request = new SendSmsRequest();
$params = json_encode([
'SmsSdkAppId' => $this->settings['app_id'],
'SignName' => $this->settings['signature'],
'TemplateId' => $templateId,
'TemplateParamSet' => $templateParams,
'PhoneNumberSet' => [$phoneNumber],
]);
$request->fromJsonString($params);
$this->logger->debug('Send Message Request ' . $params);
$response = $client->SendSms($request);
$this->logger->debug('Send Message Response ' . $response->toJsonString());
/**
* @var $sendStatus SendStatus
*/
$sendStatus = $response->getSendStatusSet()[0];
$result = $sendStatus->getCode() == 'Ok';
} catch (TencentCloudSDKException $e) {
$this->logger->error('Send Message Exception ' . kg_json_encode([
'code' => $e->getCode(),
'message' => $e->getMessage(),
'requestId' => $e->getRequestId(),
]));
$result = false;
@ -73,12 +105,7 @@ Abstract class Smser extends Service
return $result;
}
protected function createSingleSender()
{
return new SmsSingleSender($this->settings['app_id'], $this->settings['app_key']);
}
protected function formatParams($params)
protected function formatTemplateParams($params)
{
if (!empty($params)) {
$params = array_map(function ($value) {
@ -96,9 +123,4 @@ Abstract class Smser extends Service
return $template[$code]['id'] ?? null;
}
protected function getSignature()
{
return $this->settings['signature'];
}
}

View File

@ -191,6 +191,12 @@ class Order extends Validator
$itemType = OrderModel::ITEM_COURSE;
$order = $orderRepo->findUserLastDeliveringOrder($userId, $courseId, $itemType);
if ($order) {
throw new BadRequestException('order.is_delivering');
}
$order = $orderRepo->findUserLastFinishedOrder($userId, $courseId, $itemType);
if ($order && $order->item_info['course']['study_expiry_time'] > time()) {
@ -204,6 +210,12 @@ class Order extends Validator
$itemType = OrderModel::ITEM_PACKAGE;
$order = $orderRepo->findUserLastDeliveringOrder($userId, $packageId, $itemType);
if ($order) {
throw new BadRequestException('order.is_delivering');
}
$order = $orderRepo->findUserLastFinishedOrder($userId, $packageId, $itemType);
if ($order) {

View File

@ -11,7 +11,6 @@
"peppeocchi/php-cron-scheduler": "^3.0",
"yansongda/pay": "^2.9",
"tencentcloud/tencentcloud-sdk-php": "^3.0",
"qcloudsms/qcloudsms_php": "^0.1",
"qcloud/cos-sdk-v5": "^2.0",
"workerman/gateway-worker": "^3.0",
"workerman/gatewayclient": "^3.0",

63
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "e715dca0b2629f1a9c59a984206adf9f",
"content-hash": "08aae4a9db4b38cc2a4b8b6b4fa9868e",
"packages": [
{
"name": "bacon/bacon-qr-code",
@ -2255,52 +2255,6 @@
},
"time": "2020-09-27T03:57:55+00:00"
},
{
"name": "qcloudsms/qcloudsms_php",
"version": "v0.1.4",
"source": {
"type": "git",
"url": "https://github.com/qcloudsms/qcloudsms_php.git",
"reference": "48822045772d343b93c3d505d8a187cd51153c5a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/qcloudsms/qcloudsms_php/zipball/48822045772d343b93c3d505d8a187cd51153c5a",
"reference": "48822045772d343b93c3d505d8a187cd51153c5a",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require-dev": {
"sami/sami": "dev-master"
},
"type": "library",
"autoload": {
"psr-4": {
"Qcloud\\Sms\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "qcloud sms php sdk",
"keywords": [
"php",
"qcloud",
"sdk",
"sms"
],
"support": {
"issues": "https://github.com/qcloudsms/qcloudsms_php/issues",
"source": "https://github.com/qcloudsms/qcloudsms_php/tree/master"
},
"time": "2018-09-19T07:19:17+00:00"
},
{
"name": "ralouphie/getallheaders",
"version": "3.0.3",
@ -4677,16 +4631,16 @@
},
{
"name": "tencentcloud/tencentcloud-sdk-php",
"version": "3.0.321",
"version": "3.0.551",
"source": {
"type": "git",
"url": "https://github.com/TencentCloud/tencentcloud-sdk-php.git",
"reference": "6d8d68f8076ab986c211f3be573987ea66ff0435"
"reference": "dc5fca27258258e4b8df9f0f0996d4d3358c1d37"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/TencentCloud/tencentcloud-sdk-php/zipball/6d8d68f8076ab986c211f3be573987ea66ff0435",
"reference": "6d8d68f8076ab986c211f3be573987ea66ff0435",
"url": "https://api.github.com/repos/TencentCloud/tencentcloud-sdk-php/zipball/dc5fca27258258e4b8df9f0f0996d4d3358c1d37",
"reference": "dc5fca27258258e4b8df9f0f0996d4d3358c1d37",
"shasum": "",
"mirrors": [
{
@ -4696,8 +4650,7 @@
]
},
"require": {
"guzzlehttp/guzzle": "^6.3 || ^7.0.1",
"guzzlehttp/psr7": "^1.4",
"guzzlehttp/guzzle": "^6.3 || ^7.0",
"php": ">=5.6.0"
},
"type": "library",
@ -4725,9 +4678,9 @@
"homepage": "https://github.com/TencentCloud/tencentcloud-sdk-php",
"support": {
"issues": "https://github.com/TencentCloud/tencentcloud-sdk-php/issues",
"source": "https://github.com/TencentCloud/tencentcloud-sdk-php/tree/3.0.321"
"source": "https://github.com/TencentCloud/tencentcloud-sdk-php/tree/3.0.551"
},
"time": "2021-01-19T06:29:14+00:00"
"time": "2021-12-30T00:37:24+00:00"
},
{
"name": "webmozart/assert",

View File

@ -369,6 +369,7 @@ $error['order.not_found'] = '订单不存在';
$error['order.invalid_status'] = '无效的状态类型';
$error['order.item_not_found'] = '商品不存在';
$error['order.trade_expired'] = '交易已过期';
$error['order.is_delivering'] = '已经下过单了,正在准备发货中';
$error['order.has_bought_course'] = '已经购买过该课程';
$error['order.has_bought_package'] = '已经购买过该套餐';
$error['order.cancel_not_allowed'] = '当前不允许取消订单';

View File

@ -22,7 +22,6 @@ layui.use(['jquery', 'element', 'layer'], function () {
bucket: options.Bucket,
region: options.Region,
}, function (data) {
console.log(data);
var credentials = data && data.credentials;
if (!data || !credentials) {
layer.msg('获取临时凭证失败', {icon: 2});
@ -49,6 +48,7 @@ layui.use(['jquery', 'element', 'layer'], function () {
var file = this.files[0];
var keyName = getKeyName(file.name);
cos.putObject({
ContentDisposition: 'attachment',
StorageClass: myConfig.storageClass,
Bucket: myConfig.bucket,
Region: myConfig.region,
@ -59,7 +59,6 @@ layui.use(['jquery', 'element', 'layer'], function () {
var percent = Math.ceil(100 * info.percent);
element.progress('res-upload-progress', percent + '%');
}
console.log(info);
}
}, function (err, data) {
if (data && data.statusCode === 200) {