master
ljl 1 year ago
parent 84ad71dc69
commit e17eb1da6a

@ -81,6 +81,12 @@ class PaymentController extends AbstractController
return $this->success(['url' => $url]); return $this->success(['url' => $url]);
} }
public function transferPay(RequestInterface $request) {
[$app, $data, $token] = $this->parseReqest($request, UnbindCardRequest::class);
$acsNo = $this->paymentService->transferPay($data, $app, $token);
return $this->success(['acsNo' => $acsNo]);
}
public function refundApply(RequestInterface $request) public function refundApply(RequestInterface $request)
{ {
[$app, $data, $token] = $this->parseReqest($request, UnbindCardRequest::class); [$app, $data, $token] = $this->parseReqest($request, UnbindCardRequest::class);

@ -45,6 +45,11 @@ class ApiList
'url' => '/api/order/v3.0.0/paymentSplitApi', 'url' => '/api/order/v3.0.0/paymentSplitApi',
'signParams' => 'orgNo|merchantNo|terminalNo|loginNo|requestDate|outOrderNo|amount|paidType|splitInfoList', 'signParams' => 'orgNo|merchantNo|terminalNo|loginNo|requestDate|outOrderNo|amount|paidType|splitInfoList',
], ],
'transfer-split-pay' => [
'description' => '担保支付-转账支付',
'url' => '/api/transfer/v3.0.0/transferSplitPay',
'signParams' => 'orgNo|merchantNo|loginNo|terminalNo|requestDate|dataContent',
],
'payment' => [ 'payment' => [
'description' => '个人担保支付-聚合支付', 'description' => '个人担保支付-聚合支付',
'url' => '/api/wallet/v3.0.0/payment', 'url' => '/api/wallet/v3.0.0/payment',

@ -102,7 +102,33 @@ class Baofu
return $this->withReturnUrl($this->api('payment-split', $data), $token); return $this->withReturnUrl($this->api('payment-split', $data), $token);
} }
public function unifyPay($params){ public function transferSplitPay($params, $token)
{
$dataContent = [
'goodsName' => $params['goodsName'],
'amount' => $params['amount'],
'outOrderNo' => $params['outOrderNo'],
'agreementNo' => $params['agreementNo'],
'notifyUrl' => NotifyList::getNotifyUrl('payment', $token),
'expireDate' => $params['expireDate'],
'validDate' => $params['validDate'],
'splitInfoList' => $params['splitInfoList'],
'marketInfo' => [
'marketAmount' => $params['marketInfo']['amount'],
'remark' => $params['marketInfo']['remark'],
],
];
$data = [];
$data['loginNo'] = $params['loginNo'];
$data['callType'] = 'TRANSFER_ASSURE_PORTFOLIO_PAYMENT';
$data['dataContent'] = json_encode($dataContent);
$data['isDeductMarketAmount'] = '0';
return $this->api('transfer-split-pay', $data);
}
public function unifyPay($params)
{
$dataContent = [ $dataContent = [
'goodsName' => $params['goodsName'], 'goodsName' => $params['goodsName'],
'amount' => $params['amount'], 'amount' => $params['amount'],

@ -18,6 +18,7 @@ class Order extends Model
protected $casts = [ protected $casts = [
'org_split_info_list' => 'array', 'org_split_info_list' => 'array',
'market_info' => 'array',
]; ];
public function getExpiresIn() { public function getExpiresIn() {

@ -36,7 +36,25 @@ class PaymentService extends AbstractService
throw new BusinessException('订单号重复'); throw new BusinessException('订单号重复');
} }
[$order, $orderSplitInfos] = $this->createOrder($app, $data, $user); [$order, $orderSplitInfos] = $this->createOrder($app, $data, $user, 'paymentSplit');
$splitInfoList = $this->buildSplitInfoList($orderSplitInfos);
return $this->paymentSplit($order, $user, $splitInfoList, $token);
}
public function transferPay()
{
$user = User::where('app_id', $app->app_id)->where('user_id', $data['userId'])->first();
if (empty($user)) {
throw new BusinessException('用户不存在');
}
$order = Order::where('app_id', $app->app_id)->where('out_order_no', $data['outOrderNo'])->first();
if ($order) {
throw new BusinessException('订单号重复');
}
[$order, $orderSplitInfos] = $this->createOrder($app, $data, $user, 'transferSplitPay');
$splitInfoList = $this->buildSplitInfoList($orderSplitInfos); $splitInfoList = $this->buildSplitInfoList($orderSplitInfos);
@ -67,7 +85,7 @@ class PaymentService extends AbstractService
'amount' => $order->amount, 'amount' => $order->amount,
'paidType' => 'CARD', 'paidType' => 'CARD',
'agreementNo' => $order->agreement_no, 'agreementNo' => $order->agreement_no,
'pwdPayExpTime' => strtotime($order->expired_at), 'pwdPayExpTime' => strtotime($order->expires_in),
'splitInfoList' => $splitInfoList, 'splitInfoList' => $splitInfoList,
], $token); ], $token);
$order->status = 'APPLY_SUCCESS'; $order->status = 'APPLY_SUCCESS';
@ -85,7 +103,36 @@ class PaymentService extends AbstractService
} }
} }
public function createOrder(App $app, array $params, User $user) { private function transferSplitPay(Order $order, User $user, array $splitInfoList, string $token)
{
try {
$baofu = new Baofu();
$result = $baofu->transferSplitPay([
'loginNo' => $user->member_id,
'outOrderNo' => $order->order_no,
'amount' => $order->amount,
'agreementNo' => $order->agreement_no,
'expireDate' => date('YmdHis', time() + $order->expires_in),
'validDate' => $order->valid_date,
'splitInfoList' => $splitInfoList,
'marketInfo' => $order->market_info,
], $token);
$order->status = 'APPLY_SUCCESS';
$order->applied_at = date('Y-m-d H:i:s');
$order->acs_no = $result['acsNo'];
$order->save();
return $result['acsNo'];
} catch (ApiException $e) {
$order->status = 'APPLY_FAILED';
$order->applied_at = date('Y-m-d H:i:s');
$order->error_code = $e->getErrorCode();
$order->error_message = $e->getMessage();
$order->save();
throw $e;
}
}
public function createOrder(App $app, array $params, User $user, string $payMethod) {
$expiresIn = $params['expiresIn'] ?? 10 * 60; $expiresIn = $params['expiresIn'] ?? 10 * 60;
$order = new Order(); $order = new Order();
$order->app_id = $app->app_id; $order->app_id = $app->app_id;
@ -95,13 +142,16 @@ class PaymentService extends AbstractService
$order->out_order_no = $params['outOrderNo']; $order->out_order_no = $params['outOrderNo'];
$order->amount = $params['amount']; $order->amount = $params['amount'];
$order->notify_url = $params['notifyUrl']; $order->notify_url = $params['notifyUrl'];
$order->return_url = $params['returnUrl']; $order->return_url = $params['returnUrl'] ?? '';
$order->agreement_no = $params['agreementNo'] ?: ''; $order->agreement_no = $params['agreementNo'] ?? '';
$order->status = 'PREPARE'; $order->status = 'PREPARE';
$order->pay_channel = 'BAOFU'; $order->pay_channel = 'BAOFU';
$order->pay_method = 'paymentSplit'; $order->pay_method = $payMethod;
$order->pay_type = 'CARD'; $order->pay_type = 'CARD';
$order->expired_at = date('Y-m-d H:i:s', $expiresIn); $order->valid_date = $params['valid_date'] ?? null;
$order->expires_in = $expiresIn,
$order->expired_at = date('Y-m-d H:i:s', time() + $expiresIn);
$order->market_info = $params['marketInfo'] ?? [];
$order->org_split_info_list = $params['splitInfoList']; $order->org_split_info_list = $params['splitInfoList'];
$order->save(); $order->save();

@ -115,11 +115,15 @@ CREATE TABLE `orders` (
`pay_type` varchar(20) NOT NULL, `pay_type` varchar(20) NOT NULL,
`agreement_no` varchar(32) NOT NULL DEFAULT '', `agreement_no` varchar(32) NOT NULL DEFAULT '',
`expired_at` datetime DEFAULT NULL, `expired_at` datetime DEFAULT NULL,
`expires_in` int(11) NOT NULL DEFAULT 0,
`valid_date` date DEFAULT NULL,
`market_info` varchar(255) NOT NULL DEFAULT '',
`applied_at` datetime DEFAULT NULL, `applied_at` datetime DEFAULT NULL,
`notify_url` varchar(255) NOT NULL DEFAULT '', `notify_url` varchar(255) NOT NULL DEFAULT '',
`return_url` varchar(255) NOT NULL DEFAULT '', `return_url` varchar(255) NOT NULL DEFAULT '',
`org_split_info_list` varchar(512) NOT NULL DEFAULT '', `org_split_info_list` varchar(512) NOT NULL DEFAULT '',
`pay_url` varchar(255) NOT NULL DEFAULT '', `pay_url` varchar(255) NOT NULL DEFAULT '',
`acs_no` varchar(32) NOT NULL DEFAULT '',
`status` varchar(16) NOT NULL DEFAULT '', `status` varchar(16) NOT NULL DEFAULT '',
`error_code` varchar(64) NOT NULL DEFAULT '', `error_code` varchar(64) NOT NULL DEFAULT '',
`error_message` varchar(120) NOT NULL DEFAULT '', `error_message` varchar(120) NOT NULL DEFAULT '',
@ -212,3 +216,8 @@ CREATE TABLE `refund_split_infos` (
KEY `idx_memberid` (`member_id`) USING BTREE, KEY `idx_memberid` (`member_id`) USING BTREE,
KEY `idx_createdat` (`created_at`) USING BTREE KEY `idx_createdat` (`created_at`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 ROW_FORMAT=DYNAMIC; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 ROW_FORMAT=DYNAMIC;
-- `expires_in` int(11) NOT NULL DEFAULT 0,
-- `valid_date` date DEFAULT NULL,
-- `market_info` varchar(255) NOT NULL DEFAULT '',
-- `acs_no` varchar(32) NOT NULL DEFAULT '',
Loading…
Cancel
Save