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

1.优化后台配置默认值

2.后台增加返回顶部功能
3.精简优化逻辑
This commit is contained in:
xiaochong0302 2025-05-20 18:06:11 +08:00
parent 1d94aef0aa
commit d74ed0c4b1
8 changed files with 66 additions and 97 deletions

View File

@ -13,12 +13,12 @@ use GuzzleHttp\Client;
class SyncAppInfoTask extends Task
{
const API_BASE_URL = 'https://www.koogua.com/api';
public function mainAction()
{
echo '------ start sync app info ------' . PHP_EOL;
$url = 'https://www.koogua.com/api/instance/collect';
$site = $this->getSettings('site');
$serverHost = parse_url($site['url'], PHP_URL_HOST);
@ -38,6 +38,8 @@ class SyncAppInfoTask extends Task
$client = new Client();
$url = sprintf('%s/instance/collect', self::API_BASE_URL);
$client->request('POST', $url, ['form_params' => $params]);
echo '------ end sync app info ------' . PHP_EOL;

View File

@ -20,6 +20,7 @@
{{ js_include('lib/layui/layui.js') }}
{{ js_include('admin/js/common.js') }}
{{ js_include('admin/js/fixbar.js') }}
{% block include_js %}{% endblock %}
{% block inline_js %}{% endblock %}
@ -33,4 +34,4 @@
{% endif %}
</body>
</html>
</html>

View File

@ -120,19 +120,16 @@ class ConnectController extends Controller
$service = new ConnectService();
$openUser = $service->getOpenUserInfo($code, $state, $provider);
$connect = $service->getConnectRelation($openUser['id'], $openUser['provider']);
if ($this->authUser->id > 0) {
if ($openUser) {
$service->bindUser($openUser);
return $this->response->redirect(['for' => 'home.uc.account']);
}
} else {
if ($connect) {
$service->authConnectLogin($connect);
return $this->response->redirect(['for' => 'home.index']);
}
if ($this->authUser->id > 0 && $openUser) {
$service->bindUser($openUser);
return $this->response->redirect(['for' => 'home.uc.account']);
}
if ($this->authUser->id == 0 && $connect) {
$service->authConnectLogin($connect);
return $this->response->redirect(['for' => 'home.index']);
}
$this->seo->prependTitle('绑定帐号');

View File

@ -11,10 +11,7 @@ use App\Exceptions\BadRequest as BadRequestException;
use App\Models\Order as OrderModel;
use App\Models\Refund as RefundModel;
use App\Models\Trade as TradeModel;
use App\Repos\Course as CourseRepo;
use App\Repos\Order as OrderRepo;
use App\Repos\Package as PackageRepo;
use App\Repos\Vip as VipRepo;
class Order extends Validator
{
@ -50,54 +47,36 @@ class Order extends Validator
return $order;
}
public function checkItemType($itemType)
public function checkItemType($type)
{
$list = OrderModel::itemTypes();
$types = OrderModel::itemTypes();
if (!array_key_exists($itemType, $list)) {
if (!array_key_exists($type, $types)) {
throw new BadRequestException('order.invalid_item_type');
}
return $itemType;
return $type;
}
public function checkCourse($itemId)
public function checkCourse($id)
{
$courseRepo = new CourseRepo();
$validator = new Course();
$course = $courseRepo->findById($itemId);
if (!$course || $course->published == 0) {
throw new BadRequestException('order.item_not_found');
}
return $course;
return $validator->checkCourse($id);
}
public function checkPackage($itemId)
public function checkPackage($id)
{
$packageRepo = new PackageRepo();
$validator = new Package();
$package = $packageRepo->findById($itemId);
if (!$package || $package->published == 0) {
throw new BadRequestException('order.item_not_found');
}
return $package;
return $validator->checkPackage($id);
}
public function checkVip($itemId)
public function checkVip($id)
{
$vipRepo = new VipRepo();
$validator = new Vip();
$vip = $vipRepo->findById($itemId);
if (!$vip || $vip->deleted == 1) {
throw new BadRequestException('order.item_not_found');
}
return $vip;
return $validator->checkVip($id);
}
public function checkAmount($amount)
@ -105,7 +84,7 @@ class Order extends Validator
$value = $this->filter->sanitize($amount, ['trim', 'float']);
if ($value < 0.01 || $value > 100000) {
throw new BadRequestException('order.invalid_pay_amount');
throw new BadRequestException('order.invalid_amount');
}
return $value;
@ -148,7 +127,7 @@ class Order extends Validator
];
if (!in_array($order->item_type, $types)) {
throw new BadRequestException('order.refund_item_unsupported');
throw new BadRequestException('order.refund_not_supported');
}
$orderRepo = new OrderRepo();
@ -167,7 +146,7 @@ class Order extends Validator
];
if ($refund && in_array($refund->status, $scopes)) {
throw new BadRequestException('order.refund_apply_existed');
throw new BadRequestException('order.refund_request_existed');
}
}

View File

@ -91,7 +91,7 @@ class Trade extends Validator
];
if ($refund && in_array($refund->status, $scopes)) {
throw new BadRequestException('trade.refund_apply_existed');
throw new BadRequestException('trade.refund_request_existed');
}
}

View File

@ -363,17 +363,15 @@ $error['slide.invalid_publish_status'] = '无效的发布状态';
* 订单相关
*/
$error['order.not_found'] = '订单不存在';
$error['order.invalid_amount'] = '无效的支付金额';
$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'] = '当前不允许取消订单';
$error['order.close_not_allowed'] = '当前不允许关闭订单';
$error['order.refund_not_allowed'] = '当前不允许申请退款';
$error['order.refund_item_unsupported'] = '该品类不支持退款';
$error['order.refund_apply_existed'] = '退款申请已经存在';
$error['order.refund_not_supported'] = '该品类不支持退款';
$error['order.refund_request_existed'] = '退款申请已经存在';
/**
* 交易相关
@ -384,7 +382,7 @@ $error['trade.invalid_channel'] = '无效的平台类型';
$error['trade.invalid_status'] = '无效的状态类型';
$error['trade.close_not_allowed'] = '当前不允许关闭交易';
$error['trade.refund_not_allowed'] = '当前不允许交易退款';
$error['trade.refund_apply_existed'] = '退款申请已经存在,请等待处理结果';
$error['trade.refund_request_existed'] = '退款申请已经存在,请等待处理结果';
/**
* 退款相关

View File

@ -294,21 +294,6 @@ final class V20210403184518 extends AbstractMigration
protected function initSettingData()
{
$rows = [
[
'section' => 'captcha',
'item_key' => 'enabled',
'item_value' => '0',
],
[
'section' => 'captcha',
'item_key' => 'app_id',
'item_value' => '',
],
[
'section' => 'captcha',
'item_key' => 'secret_key',
'item_value' => '',
],
[
'section' => 'live.push',
'item_key' => 'domain',
@ -392,7 +377,7 @@ final class V20210403184518 extends AbstractMigration
[
'section' => 'mail',
'item_key' => 'smtp_host',
'item_value' => 'smtp.163.com',
'item_value' => '',
],
[
'section' => 'mail',
@ -412,22 +397,22 @@ final class V20210403184518 extends AbstractMigration
[
'section' => 'mail',
'item_key' => 'smtp_username',
'item_value' => 'xxx@163.com',
'item_value' => '',
],
[
'section' => 'mail',
'item_key' => 'smtp_password',
'item_value' => 'xxx',
'item_value' => '',
],
[
'section' => 'mail',
'item_key' => 'smtp_from_email',
'item_value' => 'xxx@163.com',
'item_value' => '',
],
[
'section' => 'mail',
'item_key' => 'smtp_from_name',
'item_value' => 'XXX有限公司',
'item_value' => '',
],
[
'section' => 'pay.alipay',
@ -512,17 +497,17 @@ final class V20210403184518 extends AbstractMigration
[
'section' => 'secret',
'item_key' => 'secret_key',
'item_value' => 'xxx',
'item_value' => '',
],
[
'section' => 'secret',
'item_key' => 'secret_id',
'item_value' => 'xxx',
'item_value' => '',
],
[
'section' => 'secret',
'item_key' => 'app_id',
'item_value' => 'xxx',
'item_value' => '',
],
[
'section' => 'site',
@ -617,29 +602,29 @@ final class V20210403184518 extends AbstractMigration
[
'section' => 'sms',
'item_key' => 'signature',
'item_value' => '酷瓜云课堂',
'item_value' => '',
],
[
'section' => 'sms',
'item_key' => 'template',
'item_value' => json_encode([
'verify' => ['enabled' => 1, 'id' => ''],
'order_finish' => ['enabled' => 1, 'id' => ''],
'refund_finish' => ['enabled' => 1, 'id' => ''],
'live_begin' => ['enabled' => 1, 'id' => ''],
'consult_reply' => ['enabled' => 1, 'id' => ''],
'goods_deliver' => ['enabled' => 1, 'id' => ''],
'verify' => ['enabled' => 1, 'id' => 0],
'order_finish' => ['enabled' => 0, 'id' => 0],
'refund_finish' => ['enabled' => 0, 'id' => 0],
'live_begin' => ['enabled' => 0, 'id' => 0],
'consult_reply' => ['enabled' => 0, 'id' => 0],
'goods_deliver' => ['enabled' => 0, 'id' => 0],
]),
],
[
'section' => 'cos',
'item_key' => 'bucket',
'item_value' => 'course-1255691183',
'item_value' => '',
],
[
'section' => 'cos',
'item_key' => 'region',
'item_value' => 'ap-guangzhou',
'item_value' => '',
],
[
'section' => 'cos',
@ -649,7 +634,7 @@ final class V20210403184518 extends AbstractMigration
[
'section' => 'cos',
'item_key' => 'domain',
'item_value' => 'course-1255691183.file.myqcloud.com',
'item_value' => '',
],
[
'section' => 'vod',
@ -835,12 +820,12 @@ final class V20210403184518 extends AbstractMigration
'section' => 'wechat.oa',
'item_key' => 'notice_template',
'item_value' => json_encode([
'account_login' => ['enabled' => 1, 'id' => ''],
'order_finish' => ['enabled' => 1, 'id' => ''],
'refund_finish' => ['enabled' => 1, 'id' => ''],
'goods_deliver' => ['enabled' => 1, 'id' => ''],
'consult_reply' => ['enabled' => 1, 'id' => ''],
'live_begin' => ['enabled' => 1, 'id' => ''],
'account_login' => ['enabled' => 0, 'id' => 0],
'order_finish' => ['enabled' => 0, 'id' => 0],
'refund_finish' => ['enabled' => 0, 'id' => 0],
'goods_deliver' => ['enabled' => 0, 'id' => 0],
'consult_reply' => ['enabled' => 0, 'id' => 0],
'live_begin' => ['enabled' => 0, 'id' => 0],
]),
],
[

View File

@ -0,0 +1,7 @@
layui.use(['util'], function () {
var util = layui.util;
util.fixbar();
});