|
|
@@ -18,7 +18,7 @@ trait GzcApiRequest
|
|
18
|
18
|
* @author php迷途小书童
|
|
19
|
19
|
* @created 2021/1/14 14:34
|
|
20
|
20
|
*/
|
|
21
|
|
- public static function request(string $method, string $url, array $params = [], array $options = [])
|
|
|
21
|
+ public static function request(string $method, string $url, array $params = [], array $options = [], $type = 1)
|
|
22
|
22
|
{
|
|
23
|
23
|
$base_uri = env('GZC.HOSTNAME');
|
|
24
|
24
|
$request_uri = $base_uri.$url;
|
|
|
@@ -29,7 +29,7 @@ trait GzcApiRequest
|
|
29
|
29
|
"Accept:application/json"
|
|
30
|
30
|
);
|
|
31
|
31
|
if ($url != '/v1/api/third/auth/token') {
|
|
32
|
|
- $Token = self::getTokenFromServer();
|
|
|
32
|
+ $Token = self::getTokenFromServer($type);
|
|
33
|
33
|
$accessToken = $Token['extendData']['accessToken'];
|
|
34
|
34
|
array_push($headerArray, "token:".$accessToken);
|
|
35
|
35
|
}
|
|
|
@@ -56,14 +56,37 @@ trait GzcApiRequest
|
|
56
|
56
|
*/
|
|
57
|
57
|
public static function checkAmount($user)
|
|
58
|
58
|
{
|
|
59
|
|
- $data = [
|
|
|
59
|
+ $cardType = $user['card_type'] ? $user['card_type'] : 10;
|
|
|
60
|
+ $cxbData = [
|
|
60
|
61
|
'platformNo' => env('GZC.PLATFORM_NO'),
|
|
61
|
62
|
'appNo' => env('GZC.APP_NO'),
|
|
62
|
63
|
'conName' => $user['user_name'],
|
|
63
|
|
- 'conCertType' => 1,
|
|
|
64
|
+ 'conCertType' => $cardType,
|
|
|
65
|
+ 'conCertNo' => $user['user_card'],
|
|
|
66
|
+ ];
|
|
|
67
|
+ Log::info('储蓄保养老金请求参数:' . json_encode($cxbData));
|
|
|
68
|
+ $cxbResponseData = self::request('POST', '/v1/api/third/in/in30', $cxbData, [], 1);
|
|
|
69
|
+ Log::info('储蓄保养老金请求返回:' . json_encode($cxbResponseData));
|
|
|
70
|
+ if($cxbResponseData['code'] != 0) {
|
|
|
71
|
+ return $cxbResponseData['message'];
|
|
|
72
|
+ }
|
|
|
73
|
+
|
|
|
74
|
+ $xfbData = [
|
|
|
75
|
+ 'platformNo' => env('XINGFUBAO.PLATFORM_NO'),
|
|
|
76
|
+ 'appNo' => env('XINGFUBAO.APP_NO'),
|
|
|
77
|
+ 'conName' => $user['user_name'],
|
|
|
78
|
+ 'conCertType' => $cardType,
|
|
64
|
79
|
'conCertNo' => $user['user_card'],
|
|
65
|
80
|
];
|
|
66
|
|
- return self::request('POST', '/v1/api/third/in/in30', $data);
|
|
|
81
|
+ Log::info('幸福保养老金请求参数:' . json_encode($xfbData));
|
|
|
82
|
+ $xfbResponseData = self::request('POST', '/v1/api/third/in/in30', $xfbData, [], 2);
|
|
|
83
|
+ Log::info('幸福保养老金请求返回:' . json_encode($xfbResponseData));
|
|
|
84
|
+ if($xfbResponseData['code'] != 0) {
|
|
|
85
|
+ return $xfbResponseData['message'];
|
|
|
86
|
+ }
|
|
|
87
|
+
|
|
|
88
|
+ $amount = $cxbResponseData['extendData']['amount'] + $xfbResponseData['extendData']['amount'];
|
|
|
89
|
+ return $amount;
|
|
67
|
90
|
}
|
|
68
|
91
|
public function getAmountFromGzc()
|
|
69
|
92
|
{
|
|
|
@@ -102,13 +125,17 @@ trait GzcApiRequest
|
|
102
|
125
|
* @author php迷途小书童
|
|
103
|
126
|
* @created 2021/1/14 14:38
|
|
104
|
127
|
*/
|
|
105
|
|
- public static function getTokenFromServer()
|
|
|
128
|
+ public static function getTokenFromServer($type = 1)
|
|
106
|
129
|
{
|
|
107
|
130
|
$timestamp = (int)(microtime(true) * 1000);
|
|
108
|
|
- $appid = env('GZC.APP_ID');
|
|
|
131
|
+ if ($type == 1) {
|
|
|
132
|
+ $appid = env('GZC.APP_ID');
|
|
|
133
|
+ }else{
|
|
|
134
|
+ $appid = env('XINGFUBAO.APP_ID');
|
|
|
135
|
+ }
|
|
109
|
136
|
$data = [
|
|
110
|
137
|
'appid' => $appid,
|
|
111
|
|
- 'sign' => self::getSignContent($timestamp, $appid),
|
|
|
138
|
+ 'sign' => self::getSignContent($timestamp, $appid, $type),
|
|
112
|
139
|
'timestamp' => $timestamp
|
|
113
|
140
|
];
|
|
114
|
141
|
return self::request('POST', '/v1/api/third/auth/token', $data);
|
|
|
@@ -119,8 +146,12 @@ trait GzcApiRequest
|
|
119
|
146
|
* @author php迷途小书童
|
|
120
|
147
|
* @created 2020/10/29 9:35
|
|
121
|
148
|
*/
|
|
122
|
|
- public static function getSignContent(int $timestamp, string $appid) {
|
|
123
|
|
- $appsecret = md5(env('GZC.APP_SECRET'));
|
|
|
149
|
+ public static function getSignContent(int $timestamp, string $appid, $type = 1) {
|
|
|
150
|
+ if ($type == 1) {
|
|
|
151
|
+ $appsecret = md5(env('GZC.APP_SECRET'));
|
|
|
152
|
+ }else{
|
|
|
153
|
+ $appsecret = md5(env('XINGFUBAO.APP_SECRET'));
|
|
|
154
|
+ }
|
|
124
|
155
|
$stringToBeSigned = "appid={$appid}&secret={$appsecret}×tamp={$timestamp}";
|
|
125
|
156
|
return md5($stringToBeSigned);
|
|
126
|
157
|
}
|