IssueService.php
2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
namespace App\Services;
use App\Helper\AesEncrypt;
use App\Helper\ErrorCode;
use App\Helper\Response;
use App\Models\Legal\Stakeholder;
use App\Models\Legal\Subject;
use Illuminate\Support\Facades\Log;
/**
* Class IssueService
* @package App\Services
*/
class IssueService extends Service
{
/**
* 转发
* @return \Illuminate\Http\JsonResponse
*/
public function forward()
{
$client = new \GuzzleHttp\Client([
'base_uri' => env('resource_url'),
'timeout' => 3.0,
]);
$token = uniqid();
try {
$params['data'] = $this->request->all();
$params['ext'] = [
'user_id' => $this->identifier->company_id, //机构id
'operator' => $this->identifier->user_id, //操作人id
'stakeholder_ids' => $this->stakeholder_ids,
];
Log::info(__METHOD__.':请求参数', ['params'=>$params, 'token'=>$token, 'uri'=>$client->post($this->request->getRequestUri())]);
$data = ['params' => AesEncrypt::encrypt(json_encode($params))];
$response = $client->post($this->request->getRequestUri(), [
'json' => $data,
]);
$respArr = json_decode($response->getBody()->getContents(), true);
$respArr['msg'] = $respArr['message'];
unset($respArr['message']);
Log::info(__METHOD__.':请求返回体', ['respArr'=>$respArr, 'token'=>$token, 'data'=>$data, 'uri'=>$client->post($this->request->getRequestUri())]);
return response()->json($respArr, 200);
} catch (\Throwable $throwable) {
return Response::error(ErrorCode::SERVER_ERROR, $throwable->getMessage());
}
}
/**
* 版权方
* @return \Illuminate\Http\JsonResponse
*/
public function subCompany()
{
$company_ids = Stakeholder::query()->whereIn('id', $this->stakeholder_ids)->pluck('company_id')->toArray();
$subject = Subject::query()->whereIn('company_id', $company_ids)
->where('attr', 'like', "%3%")
->groupBy('no')
->get(['no as value', 'name']);
return Response::success($subject);
}
}