xupuyuan пре 9 месеци
родитељ
комит
c37aab7e58
2 измењених фајлова са 11 додато и 88 уклоњено
  1. 6 31
      app/controller/api/user/User.php
  2. 5 57
      app/traits/GzcApiRequest.php

+ 6 - 31
app/controller/api/user/User.php

@@ -955,7 +955,6 @@ class User extends BaseController
955 955
         $params['create_time'] = time();
956 956
         $params['uid'] = $member_id;
957 957
         $baidu = new Ocr();
958
-
959 958
         // 兼容港澳台证件
960 959
         if ($cardType != 1) {
961 960
             // 设置exitentrypermit_type
@@ -983,6 +982,7 @@ class User extends BaseController
983 982
             if ($real_user_card != $params['user_card']) {
984 983
                 return app('json')->fail('姓名或身份证号输入有误~');
985 984
             }
985
+
986 986
             $params['reason'] = '';
987 987
             $params['audit_time'] = 0;
988 988
             $params['update_time'] = 0;
@@ -1018,6 +1018,7 @@ class User extends BaseController
1018 1018
             $image = file_get_contents($params['card_positive']);
1019 1019
             $idCardSide = "front";
1020 1020
             $result = $baidu->idcard($image, $idCardSide);
1021
+            Log::info('hkMacauTaiwan:' . json_encode($result));
1021 1022
             $real_user_name = $result['words_result']['姓名']['words'] ?? '';
1022 1023
             $real_user_card = $result['words_result']['公民身份号码']['words'] ?? '';
1023 1024
             if ($real_user_name != $params['user_name']) {
@@ -1028,6 +1029,7 @@ class User extends BaseController
1028 1029
             }
1029 1030
             if ($result['image_status'] == "normal" && $result['idcard_number_type'] == 1) {
1030 1031
                 $params['status'] = 1;
1032
+                $params['card_type'] = $cardType;
1031 1033
                 $res = $this->repository->add_cer($params, $member_id);
1032 1034
                 if ($res) {
1033 1035
                     $userRepository = app()->make(UserRepository::class);
@@ -1050,6 +1052,7 @@ class User extends BaseController
1050 1052
                 return app('json')->fail('认证失败,请重新认证');
1051 1053
             }
1052 1054
         }
1055
+
1053 1056
     }
1054 1057
 
1055 1058
 
@@ -3370,39 +3373,11 @@ class User extends BaseController
3370 3373
 
3371 3374
     public function getAmountFromGzc()
3372 3375
     {
3373
-//        $uid = $this->request->uid();
3374
-//        $userInfo = Db::name('UserCertification')->where('uid', $uid)->field('user_name,user_card')->find();
3375
-//        $res = GzcApiRequest::checkAmount($userInfo);
3376
-//
3377
-//        return app('json')->success(['amount' => sprintf("%01.2f", $res['extendData']['amount'] * 0.01)]);
3378 3376
         $uid = $this->request->uid();
3379 3377
         $userInfo = Db::name('UserCertification')->where('uid', $uid)->field('user_name,user_card')->find();
3378
+        $res = GzcApiRequest::checkAmount($userInfo);
3380 3379
 
3381
-        if (empty($userInfo['user_name']) || empty($userInfo['user_card'])) {
3382
-            Log::error('[getAmountFromGzc] 用户实名信息缺失', ['uid' => $uid, 'userInfo' => $userInfo]);
3383
-            return app('json')->fail('未找到用户实名信息');
3384
-        }
3385
-
3386
-        try {
3387
-            $res = GzcApiRequest::checkAmount($userInfo);
3388
-        } catch (\Throwable $e) {
3389
-            Log::error('[getAmountFromGzc] 调用异常', ['uid' => $uid, 'error' => $e->getMessage()]);
3390
-            return app('json')->fail('查询失败(第三方异常)');
3391
-        }
3392
-
3393
-        // 提取 amount(兼容多种字段位置)
3394
-        $amountCents = $res['extendData']['amount'] ?? $res['data']['amount'] ?? $res['amount'] ?? null;
3395
-        $amount = $amountCents === null ? 0.0 : floatval($amountCents) * 0.01;
3396
-        $formatted = sprintf('%.2f', $amount);
3397
-
3398
-        // 从 checkAmount 返回的 debug(若存在)
3399
-        $debug = $res['debug'] ?? null;
3400
-
3401
-        // 返回 amount 与 debug 给调用方(前端 / 调试)
3402
-        return app('json')->success([
3403
-            'amount' => $formatted,
3404
-            'debug'  => $debug
3405
-        ]);
3380
+        return app('json')->success(['amount' => sprintf("%01.2f", $res['extendData']['amount'] * 0.01)]);
3406 3381
     }
3407 3382
 
3408 3383
     public function check_user_annual_fee()

+ 5 - 57
app/traits/GzcApiRequest.php

@@ -56,66 +56,14 @@ trait GzcApiRequest
56 56
      */
57 57
     public static function checkAmount($user)
58 58
     {
59
-//        $data = [
60
-//            'platformNo' => env('GZC.PLATFORM_NO'),
61
-//            'appNo' => env('GZC.APP_NO'),
62
-//            'conName' => $user['user_name'],
63
-//            'conCertType' => 1,
64
-//            'conCertNo' => $user['user_card'],
65
-//        ];
66
-//        return self::request('POST', '/v1/api/third/in/in30', $data);
67
-        $debug = [];
68
-
69 59
         $data = [
70 60
             'platformNo' => env('GZC.PLATFORM_NO'),
71
-            'appNo'      => env('GZC.APP_NO'),
72
-            'conName'    => $user['user_name'] ?? '',
73
-            'conCertType'=> 1,
74
-            'conCertNo'  => $user['user_card'] ?? '',
61
+            'appNo' => env('GZC.APP_NO'),
62
+            'conName' => $user['user_name'],
63
+            'conCertType' => 1,
64
+            'conCertNo' => $user['user_card'],
75 65
         ];
76
-
77
-        $debug['request'] = $data;
78
-
79
-        try {
80
-            // 记录请求(原有日志可保留或删除)
81
-            Log::info('[checkAmount] request', $data);
82
-
83
-            $res = self::request('POST', '/v1/api/third/in/in30', $data);
84
-
85
-            $debug['raw_response'] = $res;
86
-
87
-            // 尝试解析 amount(以分为单位常见)
88
-            $amountCents = $res['extendData']['amount'] ?? $res['data']['amount'] ?? $res['amount'] ?? null;
89
-            $debug['parsed_amount'] = $amountCents;
90
-
91
-            // 如果没有 amount 字段或为0,附加简单推测
92
-            if ($amountCents === null) {
93
-                $debug['note'] = 'missing_amount';
94
-                Log::warning('[checkAmount] missing amount', ['user' => $user, 'response' => $res]);
95
-            } elseif ($amountCents == 0) {
96
-                $msg = $res['msg'] ?? $res['message'] ?? '';
97
-                $reasons = [];
98
-                if (stripos($msg, '未开户') !== false || stripos($msg, '未实名') !== false) $reasons[] = 'third_party_unopened_or_unverified';
99
-                if (stripos($msg, '无账户') !== false) $reasons[] = 'account_not_found';
100
-                if (stripos($msg, 'token') !== false) $reasons[] = 'token_issue_possible';
101
-                if (empty($reasons)) $reasons[] = 'balance_is_zero';
102
-                $debug['zero_reasons'] = $reasons;
103
-                Log::warning('[checkAmount] amount is 0', ['user' => $user, 'reasons' => $reasons]);
104
-            }
105
-
106
-            // 把 debug 附加到返回(不破坏原始返回结构)
107
-            if (is_array($res)) {
108
-                $res['debug'] = $debug;
109
-                return $res;
110
-            }
111
-
112
-            // 如果不是数组,包装返回
113
-            return ['code' => 200, 'msg' => 'ok', 'extendData' => ['amount' => $amountCents], 'debug' => $debug];
114
-        } catch (\Throwable $e) {
115
-            $debug['exception'] = $e->getMessage();
116
-            Log::error('[checkAmount] exception', ['user' => $user, 'err' => $e->getMessage()]);
117
-            return ['code' => 500, 'msg' => 'exception', 'debug' => $debug];
118
-        }
66
+        return self::request('POST', '/v1/api/third/in/in30', $data);
119 67
     }
120 68
     public function getAmountFromGzc()
121 69
     {