李帅

1.打印paypal token

This diff is collapsed. Click to expand it.
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
3 namespace App\Http\Controllers\V1; 3 namespace App\Http\Controllers\V1;
4 4
5 use App\Http\Controllers\Controller; 5 use App\Http\Controllers\Controller;
6 +use App\Jobs\UserMakeImmerse;
6 use App\Models\Collect; 7 use App\Models\Collect;
7 use App\Models\Immerse; 8 use App\Models\Immerse;
8 use App\Jobs\UserMakeVideo as MakeVideo; 9 use App\Jobs\UserMakeVideo as MakeVideo;
...@@ -52,34 +53,56 @@ class ImmerseController extends Controller ...@@ -52,34 +53,56 @@ class ImmerseController extends Controller
52 $user_id = $request->user()->id; 53 $user_id = $request->user()->id;
53 54
54 $immerse = Immerse::query()->find($request->item_id); 55 $immerse = Immerse::query()->find($request->item_id);
55 - if ($validated['type'] == 1){ 56 +// if ($validated['type'] == 1){
56 - $create = Immerse::query()->create([ 57 +// $create = Immerse::query()->create([
57 - 'user_id' => $user_id, 58 +// 'user_id' => $user_id,
58 - 'title' => '', 59 +// 'title' => '',
59 - 'content' => $validated['content'], 60 +// 'content' => $validated['content'],
60 - 'url' => '', 61 +// 'url' => '',
61 - 'type' => $validated['type'], 62 +// 'type' => $validated['type'],
62 - 'duration' => 0, 63 +// 'duration' => 0,
63 - 'size' => 0, 64 +// 'size' => 0,
64 - 'poem_id' => $immerse->poem_id, 65 +// 'poem_id' => $immerse->poem_id,
65 - 'temp_id' => $immerse->temp_id, 66 +// 'temp_id' => $immerse->temp_id,
66 - 'thumbnail' => $immerse->thumbnail, 67 +// 'thumbnail' => $immerse->thumbnail,
67 - 'bgm' => $validated['item_url'], 68 +// 'bgm' => $validated['item_url'],
68 - 'state' => 0 69 +// 'state' => 0
69 - ]); 70 +// ]);
71 +//
72 +// // 添加至队列
73 +// MakeImages::dispatch($create);
74 +// }else{
75 +// // 视频
76 +// $create = Immerse::query()->create([
77 +// 'user_id' => $user_id,
78 +// 'title' => '',
79 +// 'content' => $validated['content'],
80 +// 'url' => '',
81 +// 'type' => $validated['type'],
82 +// 'duration' => 0,
83 +// 'size' => 0,
84 +// 'poem_id' => $immerse->poem_id,
85 +// 'temp_id' => $immerse->temp_id,
86 +// 'thumbnail' => '',
87 +// 'bgm' => $immerse->bgm,
88 +// 'state' => 0
89 +// ]);
90 +//
91 +// // 添加至队列
92 +// MakeVideo::dispatch($create, $validated['item_url']);
93 +// }
70 94
71 - // 添加至队列
72 - MakeImages::dispatch($create);
73 - }else{
74 - // 视频
75 $create = Immerse::query()->create([ 95 $create = Immerse::query()->create([
76 'user_id' => $user_id, 96 'user_id' => $user_id,
77 'title' => '', 97 'title' => '',
78 'content' => $validated['content'], 98 'content' => $validated['content'],
79 'url' => '', 99 'url' => '',
80 'type' => $validated['type'], 100 'type' => $validated['type'],
101 + 'upload_file' => $validated['item_url'],
81 'duration' => 0, 102 'duration' => 0,
82 'size' => 0, 103 'size' => 0,
104 + 'origin_video_url' => $immerse->origin_video_url,
105 + 'origin_image_url' => $immerse->origin_image_url,
83 'poem_id' => $immerse->poem_id, 106 'poem_id' => $immerse->poem_id,
84 'temp_id' => $immerse->temp_id, 107 'temp_id' => $immerse->temp_id,
85 'thumbnail' => '', 108 'thumbnail' => '',
...@@ -88,8 +111,7 @@ class ImmerseController extends Controller ...@@ -88,8 +111,7 @@ class ImmerseController extends Controller
88 ]); 111 ]);
89 112
90 // 添加至队列 113 // 添加至队列
91 - MakeVideo::dispatch($create, $validated['item_url']); 114 + UserMakeImmerse::dispatch($create);
92 - }
93 115
94 return Response::success($create); 116 return Response::success($create);
95 } 117 }
......
...@@ -82,8 +82,11 @@ class MakeImages implements ShouldQueue ...@@ -82,8 +82,11 @@ class MakeImages implements ShouldQueue
82 'content' => $this->adminMakeVideo->feel, 82 'content' => $this->adminMakeVideo->feel,
83 'url' => str_replace(Storage::disk('public')->path(''),'',$output), 83 'url' => str_replace(Storage::disk('public')->path(''),'',$output),
84 'type' => $this->adminMakeVideo->type == 1 ? 2 : 1, 84 'type' => $this->adminMakeVideo->type == 1 ? 2 : 1,
85 + 'upload_file' => '',
85 'duration' => 0, 86 'duration' => 0,
86 'size' => filesize($image), 87 'size' => filesize($image),
88 + 'origin_video_url' => '',
89 + 'origin_image_url' => $this->adminMakeVideo->image_url,
87 'poem_id' => $this->adminMakeVideo->poem_id, 90 'poem_id' => $this->adminMakeVideo->poem_id,
88 'temp_id' => $this->adminMakeVideo->temp_id, 91 'temp_id' => $this->adminMakeVideo->temp_id,
89 'thumbnail' => str_replace(Storage::disk('public')->path(''),'',$image), 92 'thumbnail' => str_replace(Storage::disk('public')->path(''),'',$image),
...@@ -154,8 +157,11 @@ class MakeImages implements ShouldQueue ...@@ -154,8 +157,11 @@ class MakeImages implements ShouldQueue
154 'content' => $this->adminMakeVideo->feel, 157 'content' => $this->adminMakeVideo->feel,
155 'url' => str_replace(Storage::disk('public')->path(''),'',$output), 158 'url' => str_replace(Storage::disk('public')->path(''),'',$output),
156 'type' => $this->adminMakeVideo->type == 1 ? 2 : 1, 159 'type' => $this->adminMakeVideo->type == 1 ? 2 : 1,
160 + 'upload_file' => '',
157 'duration' => $video_info['format']['duration'], 161 'duration' => $video_info['format']['duration'],
158 'size' => $video_info['format']['size'], 162 'size' => $video_info['format']['size'],
163 + 'origin_video_url' => '',
164 + 'origin_image_url' => $this->adminMakeVideo->image_url,
159 'poem_id' => $this->adminMakeVideo->poem_id, 165 'poem_id' => $this->adminMakeVideo->poem_id,
160 'temp_id' => $this->adminMakeVideo->temp_id, 166 'temp_id' => $this->adminMakeVideo->temp_id,
161 'thumbnail' => str_replace(Storage::disk('public')->path(''),'',$this->adminMakeVideo->images_url), 167 'thumbnail' => str_replace(Storage::disk('public')->path(''),'',$this->adminMakeVideo->images_url),
......
...@@ -116,13 +116,28 @@ class MakeVideo implements ShouldQueue ...@@ -116,13 +116,28 @@ class MakeVideo implements ShouldQueue
116 return; 116 return;
117 } 117 }
118 118
119 + if ($this->adminMakeVideo->thumbnail == 2){
120 + // 截取中间帧作为视频封面
121 + $frame = ceil($media_info['streams'][0]['nb_frames'] / 2);
122 + $thumbnail = $this->getTempPath('.jpg',false);
123 + $cmd = $this->ffmpeg . ' -y ' .
124 + ' -i ' . escapeshellarg($file) .
125 + ' -filter_complex "[0:v]select=\'eq(n,' . $frame . ')\'[img]" ' .
126 + ' -map [img]'.
127 + ' -frames:v 1 -s 720x1280 -preset superfast '.
128 + escapeshellarg($thumbnail);
129 + if (!$this->execmd($cmd)) return ;
130 + }else{
131 + $thumbnail = $adminMakeVideo->thumbnail_url;
132 + }
133 +
119 $end_wallpaper = Storage::disk('public')->path('ffmpeg') . "/end_wallpaper.png"; 134 $end_wallpaper = Storage::disk('public')->path('ffmpeg') . "/end_wallpaper.png";
120 - $thumbnail = Storage::disk('public')->path('ffmpeg') . "/thumbnail.png"; 135 + $avatar = Storage::disk('public')->path('ffmpeg') . "/thumbnail.png";
121 $font = Storage::disk('public')->path('ffmpeg') . "/arialuni.ttf"; 136 $font = Storage::disk('public')->path('ffmpeg') . "/arialuni.ttf";
122 $signature = "一言 · 官方出品"; 137 $signature = "一言 · 官方出品";
123 138
124 // 生成贴纸和签名 139 // 生成贴纸和签名
125 - $end_wallpaper = $this->wallpaperWithSignature($end_wallpaper, $thumbnail, $signature, $font); 140 + $end_wallpaper = $this->wallpaperWithSignature($end_wallpaper, $avatar, $signature, $font);
126 141
127 // 截取最后一帧 142 // 截取最后一帧
128 $last_frame_video = $this->getTempPath(); 143 $last_frame_video = $this->getTempPath();
...@@ -176,11 +191,14 @@ class MakeVideo implements ShouldQueue ...@@ -176,11 +191,14 @@ class MakeVideo implements ShouldQueue
176 'content' => $this->adminMakeVideo->feel, 191 'content' => $this->adminMakeVideo->feel,
177 'url' => str_replace(Storage::disk('public')->path(''),'',$video), 192 'url' => str_replace(Storage::disk('public')->path(''),'',$video),
178 'type' => $this->adminMakeVideo->type == 1 ? 2 : 1, 193 'type' => $this->adminMakeVideo->type == 1 ? 2 : 1,
194 + 'upload_file' => '',
179 'duration' => $video_info['format']['duration'], 195 'duration' => $video_info['format']['duration'],
180 'size' => $video_info['format']['size'], 196 'size' => $video_info['format']['size'],
197 + 'origin_video_url' => $this->adminMakeVideo->video_url,
198 + 'origin_image_url' => '',
181 'poem_id' => $this->adminMakeVideo->poem_id, 199 'poem_id' => $this->adminMakeVideo->poem_id,
182 'temp_id' => $this->adminMakeVideo->temp_id, 200 'temp_id' => $this->adminMakeVideo->temp_id,
183 - 'thumbnail' => '', 201 + 'thumbnail' => $thumbnail,
184 'state' => 1, 202 'state' => 1,
185 'bgm' => $this->adminMakeVideo->bgm_url ?? '', 203 'bgm' => $this->adminMakeVideo->bgm_url ?? '',
186 ]); 204 ]);
......
This diff is collapsed. Click to expand it.
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\MembershipGood;
12 +use App\Models\Order;
13 +use App\Models\User;
14 +use App\Models\UserProfile;
15 +use Carbon\Carbon;
16 +use GuzzleHttp\Client;
17 +use Illuminate\Support\Facades\Log;
18 +use Illuminate\Support\Facades\Redis;
19 +
20 +class ApplePayment implements PaymentInterface
21 +{
22 +
23 + const IS_SANDBOX = true;
24 +
25 +
26 +
27 + public function __construct()
28 + {
29 +
30 + }
31 +
32 +
33 +
34 + public function prepare(Order $order)
35 + {
36 + // 查询订单对应的产品id
37 + }
38 +}
...\ No newline at end of file ...\ No newline at end of file
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\MembershipGood;
12 +use App\Models\Order;
13 +use App\Models\User;
14 +use App\Models\UserProfile;
15 +use Carbon\Carbon;
16 +use GuzzleHttp\Client;
17 +use Illuminate\Support\Facades\Log;
18 +use Illuminate\Support\Facades\Redis;
19 +
20 +class GooglePayment implements PaymentInterface
21 +{
22 +
23 + const IS_SANDBOX = true;
24 +
25 +
26 +
27 + public function __construct()
28 + {
29 +
30 + }
31 +
32 +
33 +
34 + public function prepare(Order $order)
35 + {
36 + // 查询订单对应的产品id
37 + }
38 +}
...\ No newline at end of file ...\ No newline at end of file
...@@ -19,8 +19,12 @@ class PaymentFactory ...@@ -19,8 +19,12 @@ class PaymentFactory
19 return new WechatPayment(); 19 return new WechatPayment();
20 case 'paypal': 20 case 'paypal':
21 return new PaypalPayment(); 21 return new PaypalPayment();
22 + case 'google':
23 + return new GooglePayment();
24 + case 'apple':
25 + return new ApplePayment();
22 default: 26 default:
23 - throw new \Exception('未知的支付方式'); 27 + return new \Exception('未知的支付方式');
24 } 28 }
25 } 29 }
26 } 30 }
...\ No newline at end of file ...\ No newline at end of file
......
1 +<?php
2 +
3 +use Illuminate\Database\Migrations\Migration;
4 +use Illuminate\Database\Schema\Blueprint;
5 +use Illuminate\Support\Facades\Schema;
6 +
7 +class AlterImmerse2Table extends Migration
8 +{
9 + /**
10 + * Run the migrations.
11 + *
12 + * @return void
13 + */
14 + public function up()
15 + {
16 + Schema::table('immerse', function (Blueprint $table) {
17 + $table->string('upload_file')->after('type')->comment('上传资源路径');
18 + $table->string('origin_video_url')->after('size')->comment('原始视频路径');
19 + $table->string('origin_image_url')->after('origin_video_url')->comment('原始图片路径');
20 + $table->string('tags')->after('comment')->default('')->comment('标签');
21 + });
22 + }
23 +
24 + /**
25 + * Reverse the migrations.
26 + *
27 + * @return void
28 + */
29 + public function down()
30 + {
31 + Schema::dropColumns('immerse', ['upload_file', 'origin_video_url', 'origin_image_url', 'tags']);
32 + }
33 +}
...@@ -23,7 +23,7 @@ Route::prefix('v1')->namespace('App\Http\Controllers\V1')->group(function (Route ...@@ -23,7 +23,7 @@ Route::prefix('v1')->namespace('App\Http\Controllers\V1')->group(function (Route
23 /** 社会化用户登录*/ 23 /** 社会化用户登录*/
24 $api->any('auth/{service}/callback', 'AuthController@apiHandleProviderCallback'); 24 $api->any('auth/{service}/callback', 'AuthController@apiHandleProviderCallback');
25 25
26 - /** */ 26 + /** 增加观看次数 */
27 $api->get('/addview/{id}', 'ImmerseController@addview'); 27 $api->get('/addview/{id}', 'ImmerseController@addview');
28 }); 28 });
29 29
......