diff --git a/app/Controller/Payment/PayController.php b/app/Controller/Payment/PayController.php index 97dfcfd..b824a57 100644 --- a/app/Controller/Payment/PayController.php +++ b/app/Controller/Payment/PayController.php @@ -40,10 +40,9 @@ class PayController extends AbstractController return $this->success($data); } - public function protocolPayPreRequest(RequestInterface $request) + public function bindCardPay(RequestInterface $request) { - $data = $this->paymentService->protocolPayPreRequest($request->all()); - return $this->success($data); + } public function protocolPayConfirm(RequestInterface $request) diff --git a/app/Helper/Baofu/ApiList.php b/app/Helper/Baofu/ApiList.php index bb68ffe..4626dad 100644 --- a/app/Helper/Baofu/ApiList.php +++ b/app/Helper/Baofu/ApiList.php @@ -40,6 +40,11 @@ class ApiList 'url' => '/api/order/v3.0.0/assurePaymentSplit', 'signParams' => 'orgNo|merchantNo|terminalNo|loginNo|requestDate|outOrderNo|amount|paidType|splitInfoList', ], + 'paymentSplit' => [ + 'description' => '个人支付-余额和卡', + 'url' => '/api/order/v3.0.0/paymentSplitApi', + 'signParams' => 'orgNo|merchantNo|terminalNo|loginNo|requestDate|outOrderNo|amount|paidType|splitInfoList', + ], 'payment' => [ 'description' => '个人担保支付-聚合支付', 'url' => '/api/wallet/v3.0.0/payment', diff --git a/app/Helper/Baofu/Baofu.php b/app/Helper/Baofu/Baofu.php index 6b26e7a..3131ea9 100644 --- a/app/Helper/Baofu/Baofu.php +++ b/app/Helper/Baofu/Baofu.php @@ -43,7 +43,7 @@ class Baofu $data = []; $data['loginNo'] = $loginNo; $data['dataContent'] = NotifyList::getNotifyUrl('cardBind', $token); - return $this->h5('cardBind', $data); + return $this->h5('cardBind', $data, $token); } public function cardUnbind($loginNo, $agreementNo, $requestNo = '') @@ -77,7 +77,7 @@ class Baofu return $this->withReturnUrl($this->api($params['notifyUrl'], $data), $returnUrl); } - public function assurePaymentSplit($params, $returnUrl = 'assurePaymentSplit') + public function assurePaymentSplit($params, $token) { $data = []; $data['loginNo'] = $params['loginNo']; @@ -89,7 +89,21 @@ class Baofu $data['expireDate'] = date('YmdHis', time() + 15*60); $data['validDate'] = date('Ymd'); $data['notifyUrl'] = $params['notifyUrl']; - return $this->withReturnUrl($this->api('assurePaymentSplit', $data), $returnUrl, ['oid' => $params['oid']]); + return $this->withReturnUrl($this->api('assurePaymentSplit', $data), $token); + } + + public function paymentSplit($params, $token) + { + $data = []; + $data['loginNo'] = $params['loginNo']; + $data['amount'] = $params['amount']; + $data['outOrderNo'] = $params['outOrderNo']; + $data['paidType'] = $params['paidType'] ?: 'CARD'; + $data['agreementNo'] = Rsa::encryptByCERFile($params['agreementNo'], $this->getCerFilePath()); + $data['splitInfoList'] = json_encode($params['splitInfoList']); + $data['pwdPayExpTime'] = time() + 15*60; + $data['notifyUrl'] = $params['notifyUrl']; + return $this->withReturnUrl($this->api('paymentSplitApi', $data), $token); } public function unifyPay($params){ diff --git a/app/Helper/Baofu/Common.php b/app/Helper/Baofu/Common.php index 4d83b6e..150aab5 100644 --- a/app/Helper/Baofu/Common.php +++ b/app/Helper/Baofu/Common.php @@ -114,16 +114,16 @@ trait Common return $this->withReturnUrl($this->parseResponse($response, 'h5'), $token); } - private function api($apiName, $data) + private function api($apiName, $data, $token = null) { $apiItem = ApiList::get($apiName); if (is_null($apiItem)) { throw new BusinessException('未定义API接口'); } - if ($apiName == 'mEnterpriseUnbindCard'|| $apiName == 'EnterpriseUnbindCard') { + if ($apiName == 'EnterpriseUnbindCard') { $response = $this->post($data, $apiItem, 'json'); $res = $this->parseResponse($response, 'api'); - return $this->withReturnUrl($res['checkPwdUrl'], $apiName); + return $this->withReturnUrl($res['checkPwdUrl'], $token); }else{ $response = $this->post($data, $apiItem, 'json'); return $this->parseResponse($response, 'api'); diff --git a/app/Service/PaymentService.php b/app/Service/PaymentService.php index b6f3f76..90b0f24 100644 --- a/app/Service/PaymentService.php +++ b/app/Service/PaymentService.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace App\Service; use App\Exception\BusinessException; +use App\Helper\Baofu\Baofu; use App\Helper\Efps\Api; use App\Helper\Efps\Result; use App\Helper\Log; @@ -35,10 +36,30 @@ class PaymentService extends AbstractService return md5($appId . '-' . $outMemberId); } + public function bindCardPay($params, $token) { + $req = new PaymentRequest($params); + $app = $req->getApp(); + $reqData = $req->getData(); + $user = User::where('app_id', $app->app_id)->where('user_id', $reqData['userId'])->first(); + if ($user) { + throw new BusinessException('用户已存在'); + } + $baofu = new Baofu(); + $baofu->paymentSplit([ + 'loginNo' => $user->member_id, + 'outOrderNo' => '', + 'amount' => $user->member_id, + 'paidType' => 'CARD', + 'agreementNo' => $reqData[''], + 'pwdPayExpTime' => $reqData[''], + 'notifyUrl' => '', + ], $token); + + } + public function createOrder(App $app, array $params, $user) { $order = new Order(); $order->app_id = $app->app_id; - $order->order_no = $params['outTradeNo']; $order->member_id = $user->member_id; $order->out_member_id = $params['outMemberId'] ?? ''; $order->out_order_no = $params['outOrderNo'] ?? '';