Skip to content

Commit

Permalink
Merge pull request #121 from Qsnh/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Qsnh authored Jun 22, 2020
2 parents 0bbbfbf + 991d588 commit c89b882
Show file tree
Hide file tree
Showing 315 changed files with 4,186 additions and 872 deletions.
14 changes: 13 additions & 1 deletion .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ return PhpCsFixer\Config::create()
'not_operator_with_successor_space' => false,
'no_useless_else' => true,
'no_useless_return' => true,
'no_unused_imports' => true,
'yoda_style' => false,
'single_quote' => true,
'increment_style' => ['style' => 'post'],
// 三元运算符的空格
'ternary_operator_spaces' => true,
Expand All @@ -30,5 +32,15 @@ return PhpCsFixer\Config::create()
])
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__ . '/app')
->exclude('addons')
->exclude('docker')
->exclude('docs')
->exclude('library')
->exclude('node_modules')
->exclude('public')
->exclude('resources')
->exclude('storage')
->exclude('templates')
->exclude('vendor')
->in(__DIR__)
);
38 changes: 36 additions & 2 deletions app/Constant/ApiV2Constant.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class ApiV2Constant
* @OA\Property(property="avatar",type="string",description="头像"),
* @OA\Property(property="nick_name",type="string",description="昵称"),
* @OA\Property(property="mobile",type="string",description="手机号"),
* @OA\Property(property="credit1",type="int",description="积分"),
* @OA\Property(property="role_id",type="integer",description="会员套餐id"),
* @OA\Property(property="role_expired_at",type="string",description="会员套餐到期时间"),
* @OA\Property(property="role",type="object",ref="#/components/schemas/Role"),
Expand All @@ -111,7 +112,7 @@ class ApiV2Constant
*/
public const MODEL_MEMBER_FIELD = [
'id', 'avatar', 'nick_name', 'mobile', 'is_lock', 'is_active', 'role_id', 'role_expired_at',
'invite_balance', 'role', 'is_password_set', 'is_set_nickname',
'invite_balance', 'role', 'is_password_set', 'is_set_nickname', 'credit1',
];
/**
* @OpenApi\Annotations\Schemas(
Expand Down Expand Up @@ -252,7 +253,7 @@ class ApiV2Constant
* )
*/
public const MODEL_PROMO_CODE_FIELD = [
'id', 'code', 'expired_at', 'invited_user_reward',
'id', 'code', 'expired_at', 'invited_user_reward', 'invite_user_reward',
];

/**
Expand Down Expand Up @@ -288,4 +289,37 @@ class ApiV2Constant
public const MODEL_NOTIFICATON_FIELD = [
'id', 'notifiable_id', 'data', 'read_at', 'created_at',
];

/**
* @OpenApi\Annotations\Schemas(
* @OA\Schema(
* schema="UserCredit1Record",
* type="object",
* title="积分明细",
* @OA\Property(property="sum",type="integer",description="变动"),
* @OA\Property(property="remark",type="string",description="说明"),
* @OA\Property(property="created_at",type="integer",description="时间"),
* ),
* )
*/
public const MODEL_CREDIT1_RECORD_FIELD = [
'sum', 'remark', 'created_at',
];

/**
* @OpenApi\Annotations\Schemas(
* @OA\Schema(
* schema="CourseAttach",
* type="object",
* title="课程附件",
* @OA\Property(property="id",type="integer",description="id"),
* @OA\Property(property="name",type="string",description="附件名"),
* @OA\Property(property="size",type="integer",description="附件大小,单位:字节"),
* @OA\Property(property="extension",type="string",description="附件扩展"),
* ),
* )
*/
public const MODEL_COURSE_ATTACH_FIELD = [
'id', 'name', 'size', 'extension',
];
}
7 changes: 7 additions & 0 deletions app/Constant/FrontendConstant.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,11 @@ class FrontendConstant
const ORDER_GOODS_TYPE_BOOK = 'BOOK';

const API_GUARD = 'apiv2';

public const CREDIT1_REMARK_REGISTER = 'credit1_remark_register';
public const CREDIT1_REMARK_WATCHED_COURSE = 'credit1_remark_watched_course';
public const CREDIT1_REMARK_WATCHED_VIDEO = 'credit1_remark_watched_video';
public const CREDIT1_REMARK_WATCHED_ORDER = 'credit1_remark_order';
public const CREDIT1_REMARK_WATCHED_INVITE = 'credit1_remark_invite';
public const CREDIT1_REMARK_WATCHED_OTHER = 'credit1_remark_other';
}
3 changes: 0 additions & 3 deletions app/Events/UserLoginEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@

namespace App\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;

class UserLoginEvent
{
Expand Down
33 changes: 32 additions & 1 deletion app/Http/Controllers/Api/V2/CourseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ public function detail($id)
// 课程视频观看进度
$videoWatchedProgress = [];

// 课程附件
$attach = $this->courseService->getCourseAttach($course['id']);
$attach = arr2_clear($attach, ApiV2Constant::MODEL_COURSE_ATTACH_FIELD);

if ($this->check()) {
$isBuy = $this->businessState->isBuyCourse($this->id(), $course['id']);
$isCollect = $this->userService->likeCourseStatus($this->id(), $course['id']);
Expand All @@ -173,7 +177,7 @@ public function detail($id)
$videoWatchedProgress = array_column($userVideoWatchRecords, null, 'video_id');
}

return $this->data(compact('course', 'chapters', 'videos', 'isBuy', 'isCollect', 'videoWatchedProgress'));
return $this->data(compact('course', 'chapters', 'videos', 'isBuy', 'isCollect', 'videoWatchedProgress', 'attach'));
}

/**
Expand Down Expand Up @@ -266,4 +270,31 @@ public function like($id)
$status = $this->userService->likeACourse($this->id(), $course['id']);
return $this->data($status);
}

/**
* @OA\Get(
* path="/course/attach/{id}/download",
* @OA\Parameter(in="path",name="id",description="课程附件id",required=true,@OA\Schema(type="integer")),
* summary="课程附件下载",
* tags={"课程"},
* @OA\Response(
* description="",response=200,
* @OA\JsonContent(
* @OA\Property(property="code",type="integer",description="状态码"),
* @OA\Property(property="message",type="string",description="消息"),
* @OA\Property(property="data",type="object",description=""),
* )
* )
* )
* @param $id
*/
public function attachDownload($id)
{
$courseAttach = $this->courseService->getAttach($id);
if (!$this->businessState->isBuyCourse($this->id(), $courseAttach['course_id'])) {
return $this->error(__('please buy course'));
}
$this->courseService->courseAttachDownloadTimesInc($courseAttach['id']);
return response()->download(storage_path('app/attach/' . $courseAttach['path']));
}
}
2 changes: 0 additions & 2 deletions app/Http/Controllers/Api/V2/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

namespace App\Http\Controllers\Api\V2;

use Socialite;
use Illuminate\Support\Str;
use Illuminate\Http\Request;
use App\Events\UserLoginEvent;
use App\Constant\ApiV2Constant;
Expand Down
97 changes: 67 additions & 30 deletions app/Http/Controllers/Api/V2/MemberController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use Illuminate\Http\Request;
use App\Constant\ApiV2Constant;
use App\Businesses\BusinessState;
use App\Constant\FrontendConstant;
use App\Exceptions\ApiV2Exception;
use Illuminate\Support\Facades\Auth;
use App\Services\Base\Services\ConfigService;
Expand All @@ -24,6 +23,7 @@
use App\Services\Order\Services\OrderService;
use App\Services\Course\Services\VideoService;
use App\Services\Course\Services\CourseService;
use App\Services\Member\Services\CreditService;
use App\Http\Requests\ApiV2\AvatarChangeRequest;
use App\Http\Requests\ApiV2\MobileChangeRequest;
use App\Services\Order\Services\PromoCodeService;
Expand All @@ -37,6 +37,7 @@
use App\Http\Requests\ApiV2\InviteBalanceWithdrawRequest;
use App\Services\Course\Interfaces\VideoServiceInterface;
use App\Services\Course\Interfaces\CourseServiceInterface;
use App\Services\Member\Interfaces\CreditServiceInterface;
use App\Services\Member\Services\UserInviteBalanceService;
use App\Services\Order\Interfaces\PromoCodeServiceInterface;
use App\Services\Member\Interfaces\SocialiteServiceInterface;
Expand Down Expand Up @@ -788,15 +789,15 @@ public function inviteUsers(Request $request)
'list' => $list,
'total' => $total,
] = $this->userService->inviteUsers($page, $pageSize);

$list = array_map(function ($item) {
$mobile = '******'.mb_substr($item['mobile'], 6);
$mobile = '******' . mb_substr($item['mobile'], 6);
return [
'mobile' => $mobile,
'created_at' => Carbon::parse($item['created_at'])->format('Y-m-d'),
];
}, $list);

return $this->data([
'total' => $total,
'data' => $list,
Expand Down Expand Up @@ -826,46 +827,82 @@ public function withdrawRecords(Request $request)
{
$page = $request->input('page', 1);
$pageSize = $request->input('page_size', 10);

[
'list' => $list,
'list' => $list,
'total' => $total,
] = $this->userInviteBalanceService->currentUserOrderPaginate($page, $pageSize);

return $this->data([
'total' => $total,
'data' => $list,
]);
}

/**
* @OA\Post(
* path="/member/withdraw",
* summary="邀请余额提现",
* tags={"用户"},
* @OA\RequestBody(description="",@OA\JsonContent(
* @OA\Property(property="channel",description="渠道",type="string"),
* @OA\Property(property="channel_name",description="姓名",type="string"),
* @OA\Property(property="channel_account",description="账号",type="string"),
* @OA\Property(property="total",description="提现金额",type="integer"),
* )),
* @OA\Response(
* description="",response=200,
* @OA\JsonContent(
* @OA\Property(property="code",type="integer",description="状态码"),
* @OA\Property(property="message",type="string",description="消息"),
* @OA\Property(property="data",type="object",description=""),
* )
* )
* )
*
* @param InviteBalanceWithdrawRequest $request
* @return void
*/
* @OA\Post(
* path="/member/withdraw",
* summary="邀请余额提现",
* tags={"用户"},
* @OA\RequestBody(description="",@OA\JsonContent(
* @OA\Property(property="channel",description="渠道",type="string"),
* @OA\Property(property="channel_name",description="姓名",type="string"),
* @OA\Property(property="channel_account",description="账号",type="string"),
* @OA\Property(property="total",description="提现金额",type="integer"),
* )),
* @OA\Response(
* description="",response=200,
* @OA\JsonContent(
* @OA\Property(property="code",type="integer",description="状态码"),
* @OA\Property(property="message",type="string",description="消息"),
* @OA\Property(property="data",type="object",description=""),
* )
* )
* )
*/
public function createWithdraw(InviteBalanceWithdrawRequest $request)
{
$data = $request->filldata();
$this->userInviteBalanceService->createCurrentUserWithdraw($data['total'], $data['channel']);
return $this->success();
}

/**
* @OA\Get(
* path="/member/credit1Records",
* summary="积分明细",
* tags={"用户"},
* @OA\Response(
* description="",response=200,
* @OA\JsonContent(
* @OA\Property(property="code",type="integer",description="状态码"),
* @OA\Property(property="message",type="string",description="消息"),
* @OA\Property(property="data",type="object",description="",
* @OA\Property(property="total",type="integer",description="总数"),
* @OA\Property(property="data",type="array",description="列表",@OA\Items(ref="#/components/schemas/UserCredit1Record")),
* ),
* )
* )
* )
* @return \Illuminate\Http\JsonResponse
*/
public function credit1Records(Request $request, CreditServiceInterface $creditService)
{
/**
* @var CreditService $creditService
*/

$page = $request->input('page', 1);
$pageSize = $request->input('page_size', 10);

$list = $creditService->getCredit1RecordsPaginate($this->id(), $page, $pageSize);
$list = arr2_clear($list, ApiV2Constant::MODEL_CREDIT1_RECORD_FIELD);

$total = $creditService->getCredit1RecordsCount($this->id());

return $this->data([
'total' => $total,
'data' => $list,
]);
}
}
4 changes: 1 addition & 3 deletions app/Http/Controllers/Api/V2/OrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use Illuminate\Http\Request;
use App\Constant\ApiV2Constant;
use Illuminate\Support\Facades\Auth;
use App\Services\Member\Services\RoleService;
use App\Services\Member\Services\UserService;
use App\Services\Order\Services\OrderService;
Expand Down Expand Up @@ -179,8 +178,7 @@ public function createVideoOrder(Request $request)
$videoId = $request->input('video_id');
$video = $this->videoService->find($videoId);
if ($video['is_ban_sell'] === ApiV2Constant::YES) {
flash(__('this video cannot be sold'));
return back();
return $this->error(__('this video cannot be sold'));
}
if ($video['charge'] === 0) {
return $this->error(__('video cant buy'));
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/Api/V2/OtherController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* @OA\Property(property="webname",type="string",description="网站名"),
* @OA\Property(property="icp",type="string",description="备案信息"),
* @OA\Property(property="user_protocol",type="string",description="用户协议url"),
* @OA\Property(property="user_private_protocol",type="string",description="隐私政策协议url"),
* @OA\Property(property="aboutus",type="integer",description="关于我们url"),
* @OA\Property(property="logo",type="object",description="logo",@OA\Property(
* @OA\Property(property="logo",type="string",description="默认logo"),
Expand Down Expand Up @@ -66,8 +67,6 @@ public function __construct(ConfigServiceInterface $configService)
* )
* )
* )
*
* @return void
*/
public function config()
{
Expand All @@ -76,6 +75,7 @@ public function config()
'webname' => $this->configService->getName(),
'icp' => $this->configService->getIcp(),
'user_protocol' => route('user.protocol'),
'user_private_protocol' => route('user.private_protocol'),
'aboutus' => route('aboutus'),
'logo' => $this->configService->getLogo(),
'player' => [
Expand Down
1 change: 0 additions & 1 deletion app/Http/Controllers/Api/V2/PaymentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Illuminate\Http\Request;
use App\Constant\FrontendConstant;
use App\Exceptions\SystemException;
use Illuminate\Support\Facades\Log;
use App\Services\Base\Services\CacheService;
use App\Services\Order\Services\OrderService;
use App\Services\Base\Interfaces\CacheServiceInterface;
Expand Down
1 change: 0 additions & 1 deletion app/Http/Controllers/Api/V2/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace App\Http\Controllers\Api\V2;

use Illuminate\Support\Str;
use App\Constant\ApiV2Constant;
use App\Exceptions\ApiV2Exception;
use App\Http\Requests\ApiV2\RegisterRequest;
Expand Down
1 change: 0 additions & 1 deletion app/Http/Controllers/Api/V2/VideoController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Illuminate\Http\Request;
use App\Constant\ApiV2Constant;
use App\Businesses\BusinessState;
use Illuminate\Support\Facades\Auth;
use App\Http\Requests\ApiV2\CommentRequest;
use App\Services\Base\Services\ConfigService;
use App\Services\Member\Services\UserService;
Expand Down
Loading

0 comments on commit c89b882

Please sign in to comment.