diff --git a/app/Helper/Baofu/Baofu.php b/app/Helper/Baofu/Baofu.php index 71a44d2..fa867bf 100644 --- a/app/Helper/Baofu/Baofu.php +++ b/app/Helper/Baofu/Baofu.php @@ -473,4 +473,50 @@ class Baofu $data['tradeId'] = $params['tradeId']; return $this->api('query-order', $data); } + + public function transferWithdraw($params) { + $header = []; + $header['memberId'] = $params['memberId']; + $header['terminalId'] = $params['82254']; + $header['serviceTp'] = 'T-1001-003-01'; + $header['verifyType'] = 1; + + $items = []; + foreach ($params['transContent'] as $transItem) { + $item = []; + $item['transNo'] = $transItem['transNo']; + $item['transMoney'] = $transItem['transMoney']; + $item['transType'] = $transItem['transType']; + $item['transAccNo'] = $transItem['transAccNo']; + $item['transAccName'] = $transItem['transAccName']; + $item['transSummary'] = $transItem['transSummary'] ?? '转账'; + if ($transItem['transType'] == 0) { + // 付款类型为银行时 传银行信息 + $item['cardBankName'] = $transItem['cardBankName']; + $item['cardProName'] = $transItem['cardProName']; + $item['cardCityName'] = $transItem['cardCityName']; + $item['cardAccDept'] = $transItem['cardAccDept']; + $item['cardCnap'] = $transItem['cardCnap']; + $item['transIdCard'] = $transItem['transIdCard']; + $item['transMobile'] = $transItem['transMobile']; + } + ksort($item); + $items[] = $item; + } + + $body = ['transContent' => $items]; + $content = [ + 'header' => $header, + 'body' => $body, + ]; + ksort($content); + $contentSign = SignatureUtil::sign(base64_encode(json_encode($content)), $this->getPfxFilePath(), $this->getPrivateKeyPassword()); + $header['content'] = $contentSign; + + $url = 'https://vgw.baofoo.com/union-gw/api/' . $header['serviceTp'] . '/transReq.do'; + $response = HttpClient::post($url, $header); + $result = Rsa::decryptByPublicKey($response, $this->getCerFilePath()); + $result = base64_decode($result); + return json_encode($result, true); + } }