Skip to content

Commit

Permalink
Merge pull request #118 from Qsnh/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Qsnh authored Jun 9, 2020
2 parents ff7c553 + 2487649 commit 0bbbfbf
Show file tree
Hide file tree
Showing 112 changed files with 2,967 additions and 1,307 deletions.
3 changes: 0 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=

# 阿里云的视频secret配置中的key
ALIYUN_VIDEO_AUTH_PRIVATE_KEY=

SMS_YUNPIAN_API_KEY=

# Github登录配置
Expand Down
3 changes: 0 additions & 3 deletions .env.install
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=

# 阿里云的视频secret配置中的key
ALIYUN_VIDEO_AUTH_PRIVATE_KEY=

SMS_YUNPIAN_API_KEY=

# Github登录配置
Expand Down
16 changes: 8 additions & 8 deletions app/Businesses/BusinessState.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class BusinessState
public function canSeeVideo(array $user, array $course, array $video): bool
{
/**
* @var $userService UserService
* @var UserService $userService
*/
$userService = app()->make(UserServiceInterface::class);
// 如果video的价格为0那么可以直接观看
Expand All @@ -52,7 +52,7 @@ public function canSeeVideo(array $user, array $course, array $video): bool
return true;
}
// 如果用户买了会员可以直接观看
if ($user['role_id'] && Carbon::now()->lt($user['role_expired_at'])) {
if ($this->isRole($user)) {
return true;
}
return false;
Expand Down Expand Up @@ -197,20 +197,20 @@ public function calculateOrderNeedPaidSum(array $order): int
/**
* 是否购买了课程
*
* @param int $courseId
* @return bool
* @throws \Illuminate\Contracts\Container\BindingResolutionException
* @param integer $userId
* @param integer $courseId
* @return boolean
*/
public function isBuyCourse(int $courseId): bool
public function isBuyCourse(int $userId, int $courseId): bool
{
if (!Auth::check()) {
if (!$userId) {
return false;
}
/**
* @var $userService UserService
*/
$userService = app()->make(UserServiceInterface::class);
$user = $userService->find(Auth::id(), ['role']);
$user = $userService->find($userId, ['role']);
if ($this->isRole($user)) {
return true;
}
Expand Down
10 changes: 0 additions & 10 deletions app/Console/Commands/ApplicationInstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,4 @@ public function actionRole()

$this->info('数据初始化成功');
}

// 后台菜单
public function actionBackendMenu()
{
$seeder = new class() extends Seeder {
};
$seeder->call(\BackendMenuSeeder::class);

$this->info('数据初始化成功');
}
}
58 changes: 58 additions & 0 deletions app/Console/Commands/UserRoleExpireHandlerCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

/*
* This file is part of the Qsnh/meedu.
*
* (c) XiaoTeng <616896861@qq.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace App\Console\Commands;

use Illuminate\Console\Command;
use App\Services\Member\Services\UserService;
use App\Services\Member\Interfaces\UserServiceInterface;

class UserRoleExpireHandlerCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'member:role:expired';

/**
* The console command description.
*
* @var string
*/
protected $description = '用户会员过期处理';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
/**
* @var UserService $userService
*/
$userService = app()->make(UserServiceInterface::class);
$count = $userService->resetRoleExpiredUsers();
$this->line(sprintf('本次处理%d位过期用户', $count));
}
}
12 changes: 8 additions & 4 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,24 @@ class Kernel extends ConsoleKernel
*/
protected function schedule(Schedule $schedule)
{
// 每30分钟
// 订单超时处理
$schedule->command('order:pay:timeout')
->onOneServer()
->everyThirtyMinutes()
->appendOutputTo(storage_path('logs/order_pay_timeout'));

// 会员过期处理
$schedule->command('member:role:expired')
->onOneServer()
->hourly()
->appendOutputTo(storage_path('logs/user_role_expired'));
}

/**
* Register the commands for the application.
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');

require base_path('routes/console.php');
$this->load(__DIR__ . '/Commands');
}
}
41 changes: 37 additions & 4 deletions app/Constant/ApiV2Constant.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,13 @@ class ApiV2Constant
* @OA\Property(property="seo_keywords",type="integer",description="seo_keywords"),
* @OA\Property(property="seo_description",type="integer",description="seo_description"),
* @OA\Property(property="chapter_id",type="integer",description="章节id"),
* @OA\Property(property="is_ban_sell",type="integer",description="禁止销售,1是,0否"),
* ),
* )
*/
public const MODEL_VIDEO_FIELD = [
'id', 'course_id', 'title', 'slug', 'view_num', 'short_description', 'render_desc', 'seo_keywords',
'seo_description', 'published_at', 'charge', 'chapter_id', 'duration',
'seo_description', 'published_at', 'charge', 'chapter_id', 'duration', 'is_ban_sell',
];
/**
* @OpenApi\Annotations\Schemas(
Expand Down Expand Up @@ -144,9 +145,25 @@ class ApiV2Constant
public const MODEL_COURSE_CHAPTER_FIELD = [
'id', 'course_id', 'title',
];


/**
* @OpenApi\Annotations\Schemas(
* @OA\Schema(
* schema="CourseCategory",
* type="object",
* title="课程分类",
* @OA\Property(property="id",type="integer",description="id"),
* @OA\Property(property="name",type="string",description="分类名"),
* @OA\Property(property="parent_id",type="integer",description="父id"),
* ),
* )
*/
public const MODEL_COURSE_CATEGORY_FIELD = [
'id', 'name', 'parent_id',
];


/**
* @OpenApi\Annotations\Schemas(
* @OA\Schema(
Expand All @@ -163,6 +180,7 @@ class ApiV2Constant
public const MODEL_COURSE_COMMENT_FIELD = [
'id', 'user_id', 'render_content', 'created_at',
];

/**
* @OpenApi\Annotations\Schemas(
* @OA\Schema(
Expand All @@ -179,12 +197,13 @@ class ApiV2Constant
public const MODEL_VIDEO_COMMENT_FIELD = [
'id', 'user_id', 'render_content', 'created_at',
];

/**
* @OpenApi\Annotations\Schemas(
* @OA\Schema(
* schema="Order",
* type="object",
* title="订单商品",
* title="订单",
* @OA\Property(property="id",type="integer",description="id"),
* @OA\Property(property="user_id",type="integer",description="用户id"),
* @OA\Property(property="charge",type="integer",description="总价"),
Expand Down Expand Up @@ -218,6 +237,20 @@ class ApiV2Constant
public const MODEL_ORDER_GOODS_FIELD = [
'num', 'goods_text', 'charge', 'goods_type',
];

/**
* @OpenApi\Annotations\Schemas(
* @OA\Schema(
* schema="PromoCode",
* type="object",
* title="优惠码",
* @OA\Property(property="id",type="integer",description="id"),
* @OA\Property(property="code",type="string",description="优惠码"),
* @OA\Property(property="expired_at",type="string",description="过期时间"),
* @OA\Property(property="invited_user_reward",type="integer",description="被邀请奖励"),
* ),
* )
*/
public const MODEL_PROMO_CODE_FIELD = [
'id', 'code', 'expired_at', 'invited_user_reward',
];
Expand All @@ -227,7 +260,7 @@ class ApiV2Constant
* @OA\Schema(
* schema="Slider",
* type="object",
* title="订单商品",
* title="幻灯片",
* @OA\Property(property="thumb",type="string",description="图片"),
* @OA\Property(property="url",type="string",description="url"),
* @OA\Property(property="sort",type="integer",description="升序"),
Expand All @@ -243,7 +276,7 @@ class ApiV2Constant
* @OA\Schema(
* schema="Notification",
* type="object",
* title="订单商品",
* title="消息",
* @OA\Property(property="id",type="string",description="消息id"),
* @OA\Property(property="notifiable_id",type="integer",description="notifiable_id"),
* @OA\Property(property="read_at",type="string",description="read_at"),
Expand Down
14 changes: 14 additions & 0 deletions app/Constant/BackendApiConstant.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,18 @@ class BackendApiConstant
public const NO_AUTH_CODE = 401;

public const LOCAL_PUBLIC_DISK = 'public';

public const PERMISSION_WHITE_LIST = [
'user' => true,
'menus' => true,
'login' => true,
'dashboard' => true,
'dashboard/system/info' => true,
'dashboard/check' => true,
'role/all' => true,
'administrator/password' => true,
'administrator_permission' => true,
'course/all' => true,
'upload/image/tinymce' => true,
];
}
2 changes: 2 additions & 0 deletions app/Constant/FrontendConstant.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,6 @@ class FrontendConstant
const ORDER_GOODS_TYPE_VIDEO = 'VIDEO';
const ORDER_GOODS_TYPE_ROLE = 'ROLE';
const ORDER_GOODS_TYPE_BOOK = 'BOOK';

const API_GUARD = 'apiv2';
}
10 changes: 10 additions & 0 deletions app/Http/Controllers/Api/V2/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ protected function checkImageCaptcha()
}
}

/**
* 检测是否登录
*
* @return boolean
*/
protected function check():bool
{
return Auth::guard($this->guard)->check();
}

/**
* @return mixed
*/
Expand Down
12 changes: 0 additions & 12 deletions app/Http/Controllers/Api/V2/CourseCategoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,6 @@
use App\Services\Course\Services\CourseCategoryService;
use App\Services\Course\Interfaces\CourseCategoryServiceInterface;

/**
* @OpenApi\Annotations\Schemas(
* @OA\Schema(
* schema="CourseCategory",
* type="object",
* title="课程分类",
* @OA\Property(property="name",type="string",description="分类名"),
* @OA\Property(property="sort",type="integer",description="升序"),
* ),
* )
*/

/**
* Class CourseCategoryController
* @package App\Http\Controllers\Api\V2
Expand Down
Loading

0 comments on commit 0bbbfbf

Please sign in to comment.