Showing
6 changed files
with
78 additions
and
6 deletions
| ... | @@ -95,6 +95,7 @@ class AdminMakeVideoController extends AdminController | ... | @@ -95,6 +95,7 @@ class AdminMakeVideoController extends AdminController |
| 95 | ->when(1,function (Form $form){ | 95 | ->when(1,function (Form $form){ |
| 96 | $form->file('video_url','上传视频') | 96 | $form->file('video_url','上传视频') |
| 97 | // ->accept('mp4,mov') | 97 | // ->accept('mp4,mov') |
| 98 | + ->chunked() | ||
| 98 | ->autoUpload() | 99 | ->autoUpload() |
| 99 | ->uniqueName() | 100 | ->uniqueName() |
| 100 | ->maxSize('128000') | 101 | ->maxSize('128000') | ... | ... |
| ... | @@ -5,6 +5,7 @@ namespace App\Http\Controllers\V1; | ... | @@ -5,6 +5,7 @@ namespace App\Http\Controllers\V1; |
| 5 | use App\Http\Controllers\Controller; | 5 | use App\Http\Controllers\Controller; |
| 6 | use App\Models\PackPoem; | 6 | use App\Models\PackPoem; |
| 7 | use Illuminate\Http\Request; | 7 | use Illuminate\Http\Request; |
| 8 | +use Illuminate\Support\Facades\Validator; | ||
| 8 | use Jiannei\Response\Laravel\Support\Facades\Response; | 9 | use Jiannei\Response\Laravel\Support\Facades\Response; |
| 9 | 10 | ||
| 10 | class HomeController extends Controller | 11 | class HomeController extends Controller |
| ... | @@ -23,7 +24,9 @@ class HomeController extends Controller | ... | @@ -23,7 +24,9 @@ class HomeController extends Controller |
| 23 | 24 | ||
| 24 | public function packpoem(Request $request) | 25 | public function packpoem(Request $request) |
| 25 | { | 26 | { |
| 26 | - $packpoems = PackPoem::query()->where('state',0)->paginate(0); | 27 | + $packpoems = PackPoem::query()->where('state',0) |
| 28 | + ->orderByDesc('id') | ||
| 29 | + ->simplePaginate(intval($request->per_page)); | ||
| 27 | 30 | ||
| 28 | return Response::success($packpoems); | 31 | return Response::success($packpoems); |
| 29 | } | 32 | } | ... | ... |
| ... | @@ -22,7 +22,7 @@ class UserController extends Controller | ... | @@ -22,7 +22,7 @@ class UserController extends Controller |
| 22 | public function login(Request $request) | 22 | public function login(Request $request) |
| 23 | { | 23 | { |
| 24 | $validator = Validator::make($request->all(), [ | 24 | $validator = Validator::make($request->all(), [ |
| 25 | - 'email' => 'required|max:255', | 25 | + 'email' => 'required|email|max:255', |
| 26 | 'password' => 'required', | 26 | 'password' => 'required', |
| 27 | ]); | 27 | ]); |
| 28 | 28 | ||
| ... | @@ -51,7 +51,7 @@ class UserController extends Controller | ... | @@ -51,7 +51,7 @@ class UserController extends Controller |
| 51 | public function register(Request $request) | 51 | public function register(Request $request) |
| 52 | { | 52 | { |
| 53 | $validator = Validator::make($request->all(), [ | 53 | $validator = Validator::make($request->all(), [ |
| 54 | - 'email' => 'required|unique:users|max:255', | 54 | + 'email' => 'required|email|unique:users|max:255', |
| 55 | 'password' => 'required', | 55 | 'password' => 'required', |
| 56 | 'verify_code' => 'required' | 56 | 'verify_code' => 'required' |
| 57 | ]); | 57 | ]); |
| ... | @@ -84,7 +84,7 @@ class UserController extends Controller | ... | @@ -84,7 +84,7 @@ class UserController extends Controller |
| 84 | public function verify(Request $request) | 84 | public function verify(Request $request) |
| 85 | { | 85 | { |
| 86 | $validator = Validator::make($request->all(), [ | 86 | $validator = Validator::make($request->all(), [ |
| 87 | - 'email' => 'required|max:255', | 87 | + 'email' => 'required|email|max:255', |
| 88 | ]); | 88 | ]); |
| 89 | 89 | ||
| 90 | if ($validator->fails()){ | 90 | if ($validator->fails()){ | ... | ... |
| ... | @@ -17,6 +17,8 @@ class PaymentFactory | ... | @@ -17,6 +17,8 @@ class PaymentFactory |
| 17 | return new AliPayment(); | 17 | return new AliPayment(); |
| 18 | case 'wechat': | 18 | case 'wechat': |
| 19 | return new WechatPayment(); | 19 | return new WechatPayment(); |
| 20 | + case 'paypal': | ||
| 21 | + return new PayPalPayment(); | ||
| 20 | default: | 22 | default: |
| 21 | throw new \Exception('未知的支付方式'); | 23 | throw new \Exception('未知的支付方式'); |
| 22 | } | 24 | } | ... | ... |
app/Payment/PaypalPayment.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * Created by PhpStorm. | ||
| 4 | + * User: lishuai | ||
| 5 | + * Date: 2022/2/15 | ||
| 6 | + * Time: 4:23 PM | ||
| 7 | + */ | ||
| 8 | + | ||
| 9 | +namespace App\Payment; | ||
| 10 | + | ||
| 11 | +use App\Models\Order; | ||
| 12 | +use GuzzleHttp\Client; | ||
| 13 | +use Illuminate\Support\Facades\Redis; | ||
| 14 | + | ||
| 15 | +class PaypalPayment implements PaymentInterface | ||
| 16 | +{ | ||
| 17 | + | ||
| 18 | + const IS_SANDBOX = true; | ||
| 19 | + | ||
| 20 | + public $authUrl = 'https://api-m.sandbox.paypal.com/v1/oauth2/token'; | ||
| 21 | + | ||
| 22 | + public $paySandboxUrl = 'https://api-m.sandbox.paypal.com'; | ||
| 23 | + | ||
| 24 | + public $payUrl = 'https://api-m.paypal.com'; | ||
| 25 | + | ||
| 26 | + public $clientId = 'AdDRE91WSp5q1fYLODpJduc2mRjA_v6E205SvkfVSOgvr98xLeyDCHY4OPAaSFMK1SHYOfJ4TksHSX1-'; | ||
| 27 | + public $secret = 'EDoy_PVrFyobWt9DzAMRMikJwWCXenkWSx9CGFz0MxHt3a8fs6v-LnORMilIbftb2GwBKxOoTVZNBHNR'; | ||
| 28 | + | ||
| 29 | + /** 访问令牌*/ | ||
| 30 | + public $accessToken; | ||
| 31 | + | ||
| 32 | + public function __construct() | ||
| 33 | + { | ||
| 34 | + // 初始化时做一些准备工作 | ||
| 35 | + $redis = Redis::connection(); | ||
| 36 | + $access_token = $redis->get('paypal:access_token'); | ||
| 37 | + if ($access_token){ | ||
| 38 | + $this->accessToken = $access_token; | ||
| 39 | + }else{ | ||
| 40 | + $client = new Client([ | ||
| 41 | + 'headers'=>[ | ||
| 42 | + 'Content-Type' => 'application/x-www-form-urlencoded', | ||
| 43 | + 'Accept'=>'application/json', | ||
| 44 | + ] | ||
| 45 | + ]); | ||
| 46 | + | ||
| 47 | + $response = $client->post($this->authUrl,[ | ||
| 48 | + 'form_params'=>['grant_type' => 'client_credentials'], | ||
| 49 | + 'auth' => [$this->clientId, $this->secret], | ||
| 50 | + ]); | ||
| 51 | + $body = $response->getBody(); | ||
| 52 | + $content = json_decode($body->getContents(),true); | ||
| 53 | + $this->accessToken = $content['access_token']; | ||
| 54 | + | ||
| 55 | + $redis->setex('paypal:access_token',$content['expires_in'],$content['access_token']); | ||
| 56 | + } | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + public function prepare(Order $order) | ||
| 60 | + { | ||
| 61 | + // 在PayPal上创建一个订单,它会返回一个订单对象,它有一个订单id | ||
| 62 | + | ||
| 63 | + | ||
| 64 | + return $this->accessToken; | ||
| 65 | + } | ||
| 66 | +} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| ... | @@ -81,10 +81,10 @@ return [ | ... | @@ -81,10 +81,10 @@ return [ |
| 81 | 'count' => ['alias' => 'count', 'show' => true], | 81 | 'count' => ['alias' => 'count', 'show' => true], |
| 82 | 'per_page' => ['alias' => 'per_page', 'show' => true], | 82 | 'per_page' => ['alias' => 'per_page', 'show' => true], |
| 83 | 'current_page' => ['alias' => 'current_page', 'show' => true], | 83 | 'current_page' => ['alias' => 'current_page', 'show' => true], |
| 84 | - 'total_pages' => ['alias' => 'total_pages', 'show' => true], | 84 | + 'total_pages' => ['alias' => 'total_pages', 'show' => false], |
| 85 | 'links' => [ | 85 | 'links' => [ |
| 86 | 'alias' => 'links', | 86 | 'alias' => 'links', |
| 87 | - 'show' => true, | 87 | + 'show' => false, |
| 88 | 88 | ||
| 89 | 'fields' => [ | 89 | 'fields' => [ |
| 90 | 'previous' => ['alias' => 'previous', 'show' => true], | 90 | 'previous' => ['alias' => 'previous', 'show' => true], | ... | ... |
-
Please register or login to post a comment