|
|
@@ -177,4 +177,67 @@ trait GzcApiRequest
|
|
177
|
177
|
return md5($stringToBeSigned);
|
|
178
|
178
|
}
|
|
179
|
179
|
|
|
|
180
|
+ /**
|
|
|
181
|
+ * @param $user
|
|
|
182
|
+ * @return array|mixed|string
|
|
|
183
|
+ * @author 史晨
|
|
|
184
|
+ * @date 2025/10/22 11:05
|
|
|
185
|
+ * 幸福保账户获取养老金
|
|
|
186
|
+ */
|
|
|
187
|
+ public static function getAmountXfb($user)
|
|
|
188
|
+ {
|
|
|
189
|
+ $debug = [];
|
|
|
190
|
+
|
|
|
191
|
+ $data = [
|
|
|
192
|
+ 'platformNo' => env('XINGFUBAO.PLATFORM_NO'),
|
|
|
193
|
+ 'appNo' => env('XINGFUBAO.APP_NO'),
|
|
|
194
|
+ 'conName' => $user['user_name'] ?? '',
|
|
|
195
|
+ 'conCertType'=> 1,
|
|
|
196
|
+ 'conCertNo' => $user['user_card'] ?? '',
|
|
|
197
|
+ ];
|
|
|
198
|
+
|
|
|
199
|
+ $debug['request'] = $data;
|
|
|
200
|
+
|
|
|
201
|
+ try {
|
|
|
202
|
+ // 记录请求(原有日志可保留或删除)
|
|
|
203
|
+ Log::info('[checkAmount] request', $data);
|
|
|
204
|
+
|
|
|
205
|
+ $res = self::request('POST', '/v1/api/third/in/in30', $data);
|
|
|
206
|
+
|
|
|
207
|
+ $debug['raw_response'] = $res;
|
|
|
208
|
+
|
|
|
209
|
+ // 尝试解析 amount(以分为单位常见)
|
|
|
210
|
+ $amountCents = $res['extendData']['amount'] ?? $res['data']['amount'] ?? $res['amount'] ?? null;
|
|
|
211
|
+ $debug['parsed_amount'] = $amountCents;
|
|
|
212
|
+
|
|
|
213
|
+ // 如果没有 amount 字段或为0,附加简单推测
|
|
|
214
|
+ if ($amountCents === null) {
|
|
|
215
|
+ $debug['note'] = 'missing_amount';
|
|
|
216
|
+ Log::warning('[checkAmount] missing amount', ['user' => $user, 'response' => $res]);
|
|
|
217
|
+ } elseif ($amountCents == 0) {
|
|
|
218
|
+ $msg = $res['msg'] ?? $res['message'] ?? '';
|
|
|
219
|
+ $reasons = [];
|
|
|
220
|
+ if (stripos($msg, '未开户') !== false || stripos($msg, '未实名') !== false) $reasons[] = 'third_party_unopened_or_unverified';
|
|
|
221
|
+ if (stripos($msg, '无账户') !== false) $reasons[] = 'account_not_found';
|
|
|
222
|
+ if (stripos($msg, 'token') !== false) $reasons[] = 'token_issue_possible';
|
|
|
223
|
+ if (empty($reasons)) $reasons[] = 'balance_is_zero';
|
|
|
224
|
+ $debug['zero_reasons'] = $reasons;
|
|
|
225
|
+ Log::warning('[checkAmount] amount is 0', ['user' => $user, 'reasons' => $reasons]);
|
|
|
226
|
+ }
|
|
|
227
|
+
|
|
|
228
|
+ // 把 debug 附加到返回(不破坏原始返回结构)
|
|
|
229
|
+ if (is_array($res)) {
|
|
|
230
|
+ $res['debug'] = $debug;
|
|
|
231
|
+ return $res;
|
|
|
232
|
+ }
|
|
|
233
|
+
|
|
|
234
|
+ // 如果不是数组,包装返回
|
|
|
235
|
+ return ['code' => 200, 'msg' => 'ok', 'extendData' => ['amount' => $amountCents], 'debug' => $debug];
|
|
|
236
|
+ } catch (\Throwable $e) {
|
|
|
237
|
+ $debug['exception'] = $e->getMessage();
|
|
|
238
|
+ Log::error('[checkAmount] exception', ['user' => $user, 'err' => $e->getMessage()]);
|
|
|
239
|
+ return ['code' => 500, 'msg' => 'exception', 'debug' => $debug];
|
|
|
240
|
+ }
|
|
|
241
|
+ }
|
|
|
242
|
+
|
|
180
|
243
|
}
|