xialei 1 год назад
Родитель
Сommit
e5450e9764

+ 56 - 2
app/common/repositories/merchant/order/OrderGzcRepository.php

@@ -178,6 +178,7 @@ class OrderGzcRepository extends BaseRepository
178 178
         }
179 179
     }
180 180
 
181
+
181 182
     public function register($mobile)
182 183
     {
183 184
         $thirdKey = "xingfubao";
@@ -219,9 +220,62 @@ class OrderGzcRepository extends BaseRepository
219 220
         curl_close($curl);
220 221
 
221 222
         $response = json_decode($response, true);
222
-        return $response['data']['uid'];
223
+        return $response;
223 224
     }
224 225
 
226
+
227
+
228
+
229
+    public function certification($uid, $mobile, $user_name, $user_card, $card_positive, $card_reverse)
230
+    {
231
+        $thirdKey = "xingfubao";
232
+        $thirdsignKey = "xfb@86868.";
233
+        $time = time();
234
+
235
+        $data = [
236
+            'uid'  => $uid,
237
+            'mobile' => $mobile,
238
+            'user_name' => $user_name,
239
+            'user_card' => $user_card,
240
+            'card_positive'=> $card_positive,
241
+            'card_reverse'=> $card_reverse,
242
+        ];
243
+
244
+        ksort($data);
245
+        $params = '';
246
+        foreach ($data as $key => $value) {
247
+            $params .= '&' . $key . '=' . $value;
248
+        }
249
+        $params = ltrim($params, '&');
250
+        $sign = strtoupper(md5($params . '&key=' . $thirdKey . '&signKey=' . $thirdsignKey . '&timestamp=' . $time));
251
+        $curl = curl_init();
252
+
253
+        curl_setopt_array($curl, [
254
+            CURLOPT_URL            => "http://pcpc.bjtdba.com/api/third/certification",
255
+            CURLOPT_RETURNTRANSFER => true,
256
+            CURLOPT_ENCODING       => "",
257
+            CURLOPT_MAXREDIRS      => 10,
258
+            CURLOPT_TIMEOUT        => 30,
259
+            CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
260
+            CURLOPT_CUSTOMREQUEST  => "POST",
261
+            CURLOPT_POSTFIELDS     => $data,
262
+            CURLOPT_HTTPHEADER     => [
263
+                "key: $thirdKey",
264
+                "sign: $sign",
265
+                "timestamp: $time"
266
+            ],
267
+        ]);
268
+
269
+        $response = curl_exec($curl);
270
+
271
+        curl_close($curl);
272
+
273
+        $response = json_decode($response, true);
274
+        return $response;
275
+    }
276
+
277
+
278
+
225 279
     public function gzc($uid, $pension)
226 280
     {
227 281
         $thirdKey = "xingfubao";
@@ -264,6 +318,6 @@ class OrderGzcRepository extends BaseRepository
264 318
         curl_close($curl);
265 319
 
266 320
         $response = json_decode($response, true);
267
-        return $response['code'];
321
+        return $response;
268 322
     }
269 323
 }

+ 104 - 11
app/controller/admin/system/merchant/GzcLogs.php

@@ -69,38 +69,131 @@ class GzcLogs extends BaseController
69 69
      * created: 2021/3/24 13:56
70 70
      */
71 71
     public function inGzc()
72
-    {
73
-        return app('json')->fail('不可执行');
74
-        $params = $this->request->params(['account_type', 'bank_name', 'branch_name', 'bank_account', 'bank_no', 'alipay_account','alipay_no','wxpay_account','wxpay_no','deposit_dt']);
75
-        Db::table('rrx_gzc_logs')
76
-            ->where('gzc', 0)
77
-            ->where('pension', '>', 0)
78
-            ->update($params);
72
+    { 
73
+        $id = intval($this->request->param('id'));
79 74
         $cursor = Db::table('rrx_gzc_logs')
75
+            ->where('id', $id)
80 76
             ->where('gzc', 0)
77
+            ->where('success', 0)
81 78
             ->where('pension', '>', 0)
82 79
             ->cursor();
80
+            
83 81
         foreach($cursor as $log){
84 82
             if (!$log){
85 83
                 return app('json')->fail('暂无记录');
86 84
             }
87
-            $phone= Db::table('rrx_user')->where('uid',$log['uid'])->value('phone');
88
-            $OrderGzcRepository      = app()->make(OrderGzcRepository::class);
89
-            $uid = $OrderGzcRepository->register($phone);
90
-            $OrderGzcRepository->gzc($uid,$log['pension']);
85
+            $mobile= $log['mobile'];
86
+            $user_name =  Db::name('user_certification')->where('uid',$log['uid'])->value('user_name');
87
+            $user_card =  Db::name('user_certification')->where('uid',$log['uid'])->value('user_card');
88
+            $card_positive = Db::name('user_certification')->where('uid',$log['uid'])->value('card_positive');
89
+            $card_reverse = Db::name('user_certification')->where('uid',$log['uid'])->value('card_reverse');
90
+            if(!$mobile || !$user_name || !$user_card || !$card_positive || !$card_reverse){
91
+                return app('json')->fail('暂无记录');
92
+            }
93
+
94
+            //发起入账gzc
95
+            $OrderGzcRepository = app()->make(OrderGzcRepository::class);
96
+            $register = $OrderGzcRepository->register($mobile);
97
+            if($register['status'] != 200) return app('json')->fail('入账失败:'.$register['message']);
98
+            $uid = $register['data']['uid'] ?? 0;
99
+            if(!$uid) return app('json')->fail('创建或获取用户失败');
100
+            $certification = $OrderGzcRepository->certification($uid, $mobile, $user_name, $user_card, $card_positive, $card_reverse);
101
+            if($certification['status'] != 200) return app('json')->fail('实名认证失败:'.$certification['message']);
102
+            $gzc = $OrderGzcRepository->gzc($uid,$log['pension']);
103
+            if($gzc['status'] != 200) return app('json')->fail('入账失败:'.$gzc['message']);
104
+            $gzc_deposit_no = $gzc['data'];
105
+            $gzc_confirm_result = $gzc['message'];
91 106
         }
92 107
         $OrderMerchantRepository = app()->make(OrderMerchantRepository::class);
93 108
         $orderId = $OrderMerchantRepository->getNewOrderId('IN10');
94 109
         Db::table('rrx_gzc_logs')
110
+        ->where('id', $id)
111
+        ->where('gzc', 0)
112
+        ->where('success', 0)
113
+        ->where('pension', '>', 0)
114
+        ->update([
115
+            'gzc' => 1,
116
+            'platform_no' => $orderId,
117
+            'gzc_deposit_no' => $gzc_deposit_no,
118
+            'gzc_confirm_result' => $gzc_confirm_result,
119
+            'success' => 1,
120
+            'update_time' => date('Y-m-d H:i:s')
121
+        ]);
122
+        return app('json')->success('发起成功');
123
+    }
124
+
125
+
126
+
127
+
128
+    /**
129
+     * 发起入账
130
+     * author: php迷途小书童
131
+     * created: 2021/3/24 13:56
132
+     */
133
+    public function inGzcAll()
134
+    { 
135
+        $ids = intval($this->request->param('ids'));
136
+        if(!$ids) return app('json')->fail('请选择需要入账的记录');
137
+        $ids = explode(",", $ids);
138
+        if(!count($ids)){
139
+            return app('json')->fail('暂无记录');
140
+        }
141
+
142
+        $cursor = Db::table('rrx_gzc_logs')
143
+            ->whereIn('id', $ids)
95 144
             ->where('gzc', 0)
145
+            ->where('success', 0)
146
+            ->where('pension', '>', 0)
147
+            ->cursor();
148
+        foreach($cursor as $log){
149
+            if (!$log){
150
+                return app('json')->fail('暂无记录');
151
+            }
152
+            $mobile= $log['mobile'];
153
+            $user_name =  Db::name('user_certification')->where('uid',$log['uid'])->value('user_name');
154
+            $user_card =  Db::name('user_certification')->where('uid',$log['uid'])->value('user_card');
155
+            $card_positive = Db::name('user_certification')->where('uid',$log['uid'])->value('card_positive');
156
+            $card_reverse = Db::name('user_certification')->where('uid',$log['uid'])->value('card_reverse');
157
+            if(!$mobile || !$user_name || !$user_card || !$card_positive || !$card_reverse){
158
+                return app('json')->fail('暂无记录');
159
+            }
160
+
161
+            //发起入账gzc
162
+            $OrderGzcRepository = app()->make(OrderGzcRepository::class);
163
+            $register = $OrderGzcRepository->register($mobile);
164
+            if($register['status'] != 200) return app('json')->fail('入账失败:'.$register['message']);
165
+            $uid = $register['data']['uid'] ?? 0;
166
+            if(!$uid) return app('json')->fail('创建或获取用户失败');
167
+            $certification = $OrderGzcRepository->certification($uid, $mobile, $user_name, $user_card, $card_positive, $card_reverse);
168
+            if($certification['status'] != 200) return app('json')->fail('实名认证失败:'.$certification['message']);
169
+            $gzc = $OrderGzcRepository->gzc($uid,$log['pension']);
170
+            if($gzc['status'] != 200) return app('json')->fail('入账失败:'.$gzc['message']);
171
+            $gzc_deposit_no = $gzc['data'];
172
+            $gzc_confirm_result = $gzc['message'];
173
+
174
+            $OrderMerchantRepository = app()->make(OrderMerchantRepository::class);
175
+            $orderId = $OrderMerchantRepository->getNewOrderId('IN10');
176
+            Db::table('rrx_gzc_logs')
177
+            ->where('id', $log['id'])
178
+            ->where('gzc', 0)
179
+            ->where('success', 0)
96 180
             ->where('pension', '>', 0)
97 181
             ->update([
98 182
                 'gzc' => 1,
99 183
                 'platform_no' => $orderId,
184
+                'gzc_deposit_no' => $gzc_deposit_no,
185
+                'gzc_confirm_result' => $gzc_confirm_result,
186
+                'success' => 1,
100 187
                 'update_time' => date('Y-m-d H:i:s')
101 188
             ]);
189
+        }
102 190
         return app('json')->success('发起成功');
103 191
     }
192
+
193
+
194
+
195
+
196
+
104 197
     /**
105 198
      * TODO 导出文件
106 199
      * @author Qinii

+ 1 - 0
route/admin.php

@@ -191,6 +191,7 @@ Route::group(config('admin.api_admin_prefix') . '/', function () {
191 191
             Route::get('lst', '/lst')->name('systemMerchantGzcLogsLst');
192 192
             Route::get('inForm', '/inForm')->name('systemMerchantGzcInForm');
193 193
             Route::post('inGzc', '/inGzc')->name('systemMerchantGzcIn');
194
+            Route::post('inGzcAll', '/inGzcAll')->name('systemMerchantGzcInAll');
194 195
             Route::get('editForm/:id/form', '/editForm')->name('systemMerchantGzcEditForm');
195 196
             Route::post('editForm', '/editFormPost')->name('systemMerchantGzcEditFormPost');
196 197
             Route::post('checkAmount', '/checkAmount')->name('systemMerchantGzcEditFormPost');