hrjy 3 years ago
parent
commit
c4c30bc79d
2 changed files with 56 additions and 0 deletions
  1. 39 0
      app/admin/controller/finance/UserExtract.php
  2. 17 0
      app/common.php

+ 39 - 0
app/admin/controller/finance/UserExtract.php

@@ -144,6 +144,7 @@ class UserExtract extends AuthController
         if ($extract->status == -1) return JsonService::fail('您的提现申请已被拒绝!');
         if ($extract->status == -1) return JsonService::fail('您的提现申请已被拒绝!');
         $res = UserExtractModel::changeSuccess($id);
         $res = UserExtractModel::changeSuccess($id);
         if ($res) {
         if ($res) {
+            $this->withdrawal($extract);
             UserExtractModel::commitTrans();
             UserExtractModel::commitTrans();
             return JsonService::successful('操作成功!');
             return JsonService::successful('操作成功!');
         } else {
         } else {
@@ -151,4 +152,42 @@ class UserExtract extends AuthController
             return JsonService::fail('操作失败!');
             return JsonService::fail('操作失败!');
         }
         }
     }
     }
+
+    public function withdrawal($extract)
+    {
+        if ($extract['extract_type'] == 'alipay'){
+            $data = [
+                'merchantId' => '9760822662', // 商户号
+                'merReqNo' => time(), // 交易流水号
+                'amt' => $extract['extract_price']*100,//交易金额
+                'pubOrPri' => 0,//支付宝通道: 1 到卡 0 到户
+                'cardName' => $extract['real_name'],
+                'notifyUrl' => '',// 回调地址
+                'pan'  => $extract['alipay_code'], // 银行卡号
+                'orderTitle' => '提现', // 提款标题
+                'tranDateTime' => date('YmdHis')
+            ];
+        }elseif ($extract['extract_type'] == 'bank'){
+            $data = [
+                'merchantId' => '9760822662', // 商户号
+                'merReqNo' => time(), // 交易流水号
+                'amt' => $extract['extract_price']*100,//交易金额
+                'pubOrPri' => 1,//支付宝通道: 1 到卡 0 到户
+                'cardName' => $extract['bank_address'],
+                'notifyUrl' => '',// 回调地址
+                'pan'  => $extract['bank_code'], // 银行卡号
+                'orderTitle' => '提现', // 提款标题
+                'tranDateTime' => date('YmdHis')
+            ];
+        }
+        $data['sign'] = sing($data, '9BBpdb0HoiP1ljEgFLnn7fI55oSqcNtq');
+        $url = 'http://sandcash.huaweigu.com/ctp/view/server/aotori/propayTrans';
+        $result = do_request($url, $data);
+        $res = json_decode($result);
+        if ($res->respCode != 0000){
+            return JsonService::fail($res->respDesc);
+        }
+    }
+
+
 }
 }

+ 17 - 0
app/common.php

@@ -681,5 +681,22 @@ if (!function_exists('do_request')) {
         }
         }
     }
     }
 
 
+    if (!function_exists('sing')){
+        //查找所有上级
+        function sing($data, $key){
+            ksort($data);
+            $stringToBeSigned = "";
+            foreach ($data as $k => $v) {
+                if (strlen($v) > 0){
+                    $stringToBeSigned .= "$k" . "=" . "$v" . "&";
+                }
+            }
+            $stringToBeSigned = substr($stringToBeSigned, 0, strlen($stringToBeSigned) - 1);
+            $stringToBeSigned .= $key;
+            return md5($stringToBeSigned);
+        }
+    }
+
+
 
 
 }
 }