|
|
@ -36,6 +36,7 @@ class PaymentService extends AbstractService
|
|
|
|
throw new BusinessException('订单号重复');
|
|
|
|
throw new BusinessException('订单号重复');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$data['payType'] = $data['payType'] ?? 'CARD';
|
|
|
|
[$order, $orderSplitInfos] = $this->createOrder($app, $data, $user, 'paymentSplit');
|
|
|
|
[$order, $orderSplitInfos] = $this->createOrder($app, $data, $user, 'paymentSplit');
|
|
|
|
|
|
|
|
|
|
|
|
$splitInfoList = $this->buildSplitInfoList($orderSplitInfos);
|
|
|
|
$splitInfoList = $this->buildSplitInfoList($orderSplitInfos);
|
|
|
@ -83,7 +84,7 @@ class PaymentService extends AbstractService
|
|
|
|
'loginNo' => $user->member_id,
|
|
|
|
'loginNo' => $user->member_id,
|
|
|
|
'outOrderNo' => $order->order_no,
|
|
|
|
'outOrderNo' => $order->order_no,
|
|
|
|
'amount' => $order->amount,
|
|
|
|
'amount' => $order->amount,
|
|
|
|
'paidType' => 'CARD',
|
|
|
|
'paidType' => $order->pay_type,
|
|
|
|
'agreementNo' => $order->agreement_no,
|
|
|
|
'agreementNo' => $order->agreement_no,
|
|
|
|
'pwdPayExpTime' => $order->expires_in,
|
|
|
|
'pwdPayExpTime' => $order->expires_in,
|
|
|
|
'splitInfoList' => $splitInfoList,
|
|
|
|
'splitInfoList' => $splitInfoList,
|
|
|
@ -133,6 +134,43 @@ class PaymentService extends AbstractService
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private function unionPay(Order $order, User $user, array $splitInfoList, string $token)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// ASSURE_SHARE
|
|
|
|
|
|
|
|
// ASSURE_PAYMENT
|
|
|
|
|
|
|
|
// ASSURE_PORTFOLIO_PAY
|
|
|
|
|
|
|
|
// PAYMENT_SPLIT
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
$baofu = new Baofu();
|
|
|
|
|
|
|
|
$result = $baofu->payment([
|
|
|
|
|
|
|
|
'loginNo' => $user->member_id,
|
|
|
|
|
|
|
|
'outOrderNo' => $order->order_no,
|
|
|
|
|
|
|
|
'goodsName' => $order->goods_name,
|
|
|
|
|
|
|
|
'amount' => $order->amount,
|
|
|
|
|
|
|
|
'paidType' => $order->pay_type,
|
|
|
|
|
|
|
|
'agreementNo' => $order->agreement_no,
|
|
|
|
|
|
|
|
'expireDate' => date('YmdHis', time() + $order->expires_in),
|
|
|
|
|
|
|
|
'validDate' => date('Ymd', strtotime($order->valid_date)),
|
|
|
|
|
|
|
|
'splitInfoList' => $splitInfoList,
|
|
|
|
|
|
|
|
'chanalId' => $order->channel_id,
|
|
|
|
|
|
|
|
'appId' => $order->channel_app_id,
|
|
|
|
|
|
|
|
'callType' => 'PAYMENT_SPLIT',
|
|
|
|
|
|
|
|
], $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) {
|
|
|
|
public function createOrder(App $app, array $params, User $user, string $payMethod) {
|
|
|
|
if ($params['amount'] < 10) {
|
|
|
|
if ($params['amount'] < 10) {
|
|
|
|
throw new BusinessException('金额不能小于10');
|
|
|
|
throw new BusinessException('金额不能小于10');
|
|
|
@ -150,14 +188,18 @@ class PaymentService extends AbstractService
|
|
|
|
$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_mode = 'BAOFU';
|
|
|
|
|
|
|
|
$order->channel_id = $params['channelId'] ?? '';
|
|
|
|
|
|
|
|
$order->channel_app_id = $params['appId'] ?? '';
|
|
|
|
$order->pay_channel = 'BAOFU';
|
|
|
|
$order->pay_channel = 'BAOFU';
|
|
|
|
$order->pay_method = $payMethod;
|
|
|
|
$order->pay_method = $payMethod;
|
|
|
|
$order->pay_type = 'CARD';
|
|
|
|
$order->pay_type = $params['payType'] ?? '';
|
|
|
|
$order->valid_date = $params['validDate'] ?? null;
|
|
|
|
$order->valid_date = $params['validDate'] ?? null;
|
|
|
|
$order->expires_in = $expiresIn;
|
|
|
|
$order->expires_in = $expiresIn;
|
|
|
|
$order->expired_at = date('Y-m-d H:i:s', time() + $expiresIn);
|
|
|
|
$order->expired_at = date('Y-m-d H:i:s', time() + $expiresIn);
|
|
|
|
$order->market_info = $params['marketInfo'] ?? [];
|
|
|
|
$order->market_info = $params['marketInfo'] ?? [];
|
|
|
|
$order->org_split_info_list = $params['splitInfoList'];
|
|
|
|
$order->org_split_info_list = $params['splitInfoList'];
|
|
|
|
|
|
|
|
$order->remark = $params['remark'] ?? '';
|
|
|
|
$order->save();
|
|
|
|
$order->save();
|
|
|
|
|
|
|
|
|
|
|
|
$platformAccount = User::getPlatformAccount();
|
|
|
|
$platformAccount = User::getPlatformAccount();
|
|
|
|