elf 1 year ago
parent 9cb710d736
commit 4022901c65

@ -127,7 +127,7 @@ class PaymentController extends AbstractController
if (empty($user)) { if (empty($user)) {
throw new BusinessException('用户不存在'); throw new BusinessException('用户不存在');
} }
$user = $this->userService->rsyncUser($user->member_id); $user = $this->userService->rsyncUser($user->member_id, $app->app_id, $data['userId']);
$result = [ $result = [
'realnameFlag' => $user->realname_flag, 'realnameFlag' => $user->realname_flag,
'bindCardFlag' => $user->bind_bard_flag, 'bindCardFlag' => $user->bind_bard_flag,

@ -181,14 +181,14 @@ class Baofu
return $this->api('cloud-b2c-assure-recharge', $data); return $this->api('cloud-b2c-assure-recharge', $data);
} }
public function payment($params, $type = 'ASSURE_PAYMENT') public function payment($params, $type, $token)
{ {
$dataContent = [ $dataContent = [
'goodsName' => $params['goodsName'], 'goodsName' => $params['goodsName'],
'amount' => $params['amount'], 'amount' => $params['amount'],
'outOrderNo' => $params['outOrderNo'], 'outOrderNo' => $params['outOrderNo'],
'expireDate' => date('YmdHis', time() + 15*60), 'expireDate' => $params['expireDate'],
'notifyUrl' => $params['notifyUrl'], 'notifyUrl' => NotifyList::getNotifyUrl('payment', $token),
'splitInfoList' => $params['splitInfoList'], 'splitInfoList' => $params['splitInfoList'],
'paidType' => $params['paidType'], 'paidType' => $params['paidType'],
'validDate' => date('Ymd'), 'validDate' => date('Ymd'),
@ -199,14 +199,14 @@ class Baofu
// 1.微信支付(公众号、小程序)需填公众号授权获取微信用户openid // 1.微信支付(公众号、小程序)需填公众号授权获取微信用户openid
// 2.支付宝支付(生活号、小程序)需填生活号授权获取支付宝用户userid // 2.支付宝支付(生活号、小程序)需填生活号授权获取支付宝用户userid
// 其余时间不传 // 其余时间不传
$data['chanalId'] = $params['chanalId'] ?: ''; $data['chanalId'] = $params['chanalId'] ?? '';
$data['dataContent'] = json_encode($dataContent); $data['dataContent'] = json_encode($dataContent);
// 1.微信支付(公众号、小程序)需填公众号授权获取微信的appid // 1.微信支付(公众号、小程序)需填公众号授权获取微信的appid
// 2.支付宝支付(生活号、小程序)需填生活号授权获取支付宝的appid // 2.支付宝支付(生活号、小程序)需填生活号授权获取支付宝的appid
// 支付宝主扫 不需要 // 支付宝主扫 不需要
$data['appId'] = $params['appId'] ?: ''; $data['appId'] = $params['appId'] ?: '';
$data['isRaw'] = 0; $data['isRaw'] = 0;
$data['callType'] = $type; $data['callType'] = $params['callType'];
$res = base64_decode($this->api('payment', $data)); $res = base64_decode($this->api('payment', $data));
if(self::PEYMENT_PAID_TYPE[$params['paidType']]){ if(self::PEYMENT_PAID_TYPE[$params['paidType']]){

@ -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();

@ -225,3 +225,12 @@ add column `acs_no` varchar(32) NOT NULL DEFAULT '' after market_info;
alter table orders alter table orders
add column `goods_name` varchar(125) NOT NULL DEFAULT '' after amount; add column `goods_name` varchar(125) NOT NULL DEFAULT '' after amount;
alter table orders
add column `pay_mode` varchar(20) NOT NULL DEFAULT '' after market_info,
add column `remark` varchar(255) NOT NULL DEFAULT '' after return_url;
alter table orders
add column `channel_id` varchar(32) NOT NULL DEFAULT '' after market_info,
add column `channel_app_id` varchar(32) NOT NULL DEFAULT '' after market_info;
Loading…
Cancel
Save