Commit dc59533e dc59533ed75750fdc73ebe974e7a42614f50cd9e by lemon

*

1 parent d79cfd47
1 <?php
2
3
4 namespace App\Helper;
5
6
7 use Illuminate\Support\Str;
8 use Qcloud\Cos\Client;
9
10 class CosHelper
11 {
12 protected $client;
13 protected $bucket;
14
15 public function __construct()
16 {
17 $secretId = env('COS_SECRET_ID'); //"云 API 密钥 SecretId";
18 $secretKey = env('COS_SECRET_KEY'); //"云 API 密钥 SecretKey";
19 $region = env('COS_REGION'); //设置一个默认的存储桶地域
20 $cosClient = new Client(
21 array(
22 'region' => $region,
23 'schema' => 'https', //协议头部,默认为http
24 'credentials'=> array(
25 'secretId' => $secretId ,
26 'secretKey' => $secretKey)));
27
28 $this->client = $cosClient;
29 $this->bucket = env('COS_BUCKET');
30 }
31
32 /**
33 * 预览文档 ———— 同步转换为html
34 * @param string $key
35 * @param int $expire
36 * @return string
37 */
38 public function getPreviewUrl(string $key, int $expire = 10) : string
39 {
40 $url = $this->client->getObjectUrl($this->bucket, $key, "+{$expire}minutes");
41 return $url;
42 // return $url . "ci-process=doc-preview&dstType=html";
43 }
44
45 }
...@@ -2,10 +2,12 @@ ...@@ -2,10 +2,12 @@
2 2
3 namespace App\Services; 3 namespace App\Services;
4 4
5 use App\Helper\CosHelper;
5 use App\Helper\Response; 6 use App\Helper\Response;
6 use App\Models\Legal\Contract; 7 use App\Models\Legal\Contract;
7 use App\Models\Legal\StakeholderContract; 8 use App\Models\Legal\StakeholderContract;
8 use App\Models\Legal\Treaty; 9 use App\Models\Legal\Treaty;
10 use Qcloud\Cos\Client;
9 11
10 /** 12 /**
11 * Class MusicianAgreementService 13 * Class MusicianAgreementService
...@@ -18,17 +20,24 @@ class MusicianAgreementService extends Service ...@@ -18,17 +20,24 @@ class MusicianAgreementService extends Service
18 */ 20 */
19 public function treatyList() 21 public function treatyList()
20 { 22 {
21 $res = Treaty::query()->whereIn('party_b', $this->stakeholder_ids)->where('deadline_date', '>', $this->now)->with(['file:id,treaty_id,file_id', 'file.fileInfo:id,location']) 23 $res = Treaty::query()->whereIn('party_b', $this->stakeholder_ids)->where('deadline_date', '>', $this->now)->with(['file:id,treaty_id,file_id', 'file.fileInfo:id,key'])
22 ->select(['id', 'treaty_name', 'treaty_type', 'service_type', 'deadline_date', 'music_no'])->orderByDesc('created_at')->paginate($this->pageSize); 24 ->select(['id', 'treaty_name', 'treaty_type', 'service_type', 'deadline_date', 'music_no'])->orderByDesc('created_at')->paginate($this->pageSize);
23 25
26 $client = new CosHelper();
27
24 foreach ($res as &$item) { 28 foreach ($res as &$item) {
25 $item_res = $item->toArray(); 29 $item_res = $item->toArray();
26 $files = []; 30 $files = [];
27 if (!empty($item_res['file'])) { 31 if (!empty($item_res['file'])) {
28 foreach ($item_res['file'] as $file_item) { 32 foreach ($item_res['file'] as $file_item) {
29 !empty($file_item['file_info']['location']) && $files[] = $file_item['file_info']['location']; 33 !empty($file_item['file_info']['key']) && $files[] = $file_item['file_info']['key'];
30 } 34 }
31 } 35 }
36
37 foreach ($files as &$file) {
38 $file = $client->getPreviewUrl($file);
39 }
40
32 $item->setAttribute('files', $files); 41 $item->setAttribute('files', $files);
33 unset($item->file); 42 unset($item->file);
34 } 43 }
......
...@@ -48,43 +48,6 @@ class MusicianWithdrawService extends Service ...@@ -48,43 +48,6 @@ class MusicianWithdrawService extends Service
48 } 48 }
49 49
50 /** 50 /**
51 * 修改提现状态
52 * @return \Illuminate\Http\JsonResponse|mixed
53 */
54 public function changeStatus()
55 {
56 $withdraw_status = '';
57
58 $query = StakeholderIncomeSyncAppDetails::query()->where(['sync_status'=>1, 'identifier'=>$this->identifier->identifier])
59 ->whereIn('serial_no', $this->request->input('busi_id'));
60
61 switch ($this->request->input('type')) {
62 case 'confirm': //已确认
63 $withdraw_status = 1;
64 $query = $query->where(['withdraw_status'=>0]);
65 break;
66 case 'fail': //提现失败 -> 待提现
67 $withdraw_status = 1;
68 $query = $query->where(['withdraw_status'=>2]);
69 break;
70 case 'advance': //提现中
71 $withdraw_status = 2;
72 $query = $query->where(['withdraw_status'=>1]);
73 break;
74 case 'success': //提现完成
75 $withdraw_status = 3;
76 $query = $query->where(['withdraw_status'=>2]);
77 break;
78 }
79
80 if ($query->update(['withdraw_status'=>$withdraw_status])) {
81 return Response::success();
82 } else {
83 return Response::error();
84 }
85 }
86
87 /**
88 * 确认账单 51 * 确认账单
89 * @return \Illuminate\Http\JsonResponse 52 * @return \Illuminate\Http\JsonResponse
90 */ 53 */
...@@ -147,4 +110,22 @@ class MusicianWithdrawService extends Service ...@@ -147,4 +110,22 @@ class MusicianWithdrawService extends Service
147 } 110 }
148 } 111 }
149 112
113 /**
114 * 修改提现状态
115 * @return \Illuminate\Http\JsonResponse|mixed
116 */
117 public function changeStatus()
118 {
119 $withdraw_status = '';
120
121 $query = StakeholderIncomeSyncAppDetails::query()->where(['sync_status'=>1, 'identifier'=>$this->identifier->identifier])
122 ->whereIn('serial_no', $this->request->input('busi_id'));
123
124 if ($query->update(['withdraw_status'=>$withdraw_status])) {
125 return Response::success();
126 } else {
127 return Response::error();
128 }
129 }
130
150 } 131 }
......
...@@ -14,7 +14,8 @@ ...@@ -14,7 +14,8 @@
14 "guzzlehttp/guzzle": "^7.0.1", 14 "guzzlehttp/guzzle": "^7.0.1",
15 "laravel/framework": "^8.40", 15 "laravel/framework": "^8.40",
16 "laravel/tinker": "^2.5", 16 "laravel/tinker": "^2.5",
17 "phpseclib/phpseclib": "~3.0" 17 "phpseclib/phpseclib": "~3.0",
18 "qcloud/vod-sdk-v5": "^2.4"
18 }, 19 },
19 "require-dev": { 20 "require-dev": {
20 "facade/ignition": "^2.5", 21 "facade/ignition": "^2.5",
......