ljl 1 year ago
parent a9d28b2b2d
commit d69dcdb6ac

@ -244,4 +244,10 @@ class NotifyController extends AbstractController
public function testNotify(RequestInterface $request) { public function testNotify(RequestInterface $request) {
return $this->success(['params' => $request->all()]); return $this->success(['params' => $request->all()]);
} }
public function transferWithdraw(RequestInterface $request)
{
$params = $request->all();
Log::info('NOTIFY_DATA: ' . $request->getUri() . ':', $params);
}
} }

@ -157,4 +157,28 @@ class PaymentController extends AbstractController
]; ];
return $this->success($result); return $this->success($result);
} }
public function withdraw(RequestInterface $request)
{
[$app, $data, $token] = $this->parseReqest($request, UnbindCardRequest::class);
$order = $this->paymentService->queryOrder($data, $app);
$result = [
'finishTime' => $order->finished_at,
'amount' => $order->amount,
'status' => $order->status,
];
return $this->success($result);
}
public function withdrawApply(RequestInterface $request)
{
[$app, $data, $token] = $this->parseReqest($request, UnbindCardRequest::class);
$order = $this->paymentService->queryOrder($data, $app);
$result = [
'finishTime' => $order->finished_at,
'amount' => $order->amount,
'status' => $order->status,
];
return $this->success($result);
}
} }

@ -527,6 +527,6 @@ class Baofu
echo $result; echo $result;
echo PHP_EOL; echo PHP_EOL;
$result = base64_decode($result); $result = base64_decode($result);
return json_encode($result, true); return json_decode($result, true);
} }
} }

@ -13,6 +13,9 @@ class StringHelper
const ORDER_NO_TYPE_UNBIND_CARD = 'unbind_card'; const ORDER_NO_TYPE_UNBIND_CARD = 'unbind_card';
const ORDER_NO_TYPE_QUERY_CUSTOMER_INFO = 'query_customer_info'; const ORDER_NO_TYPE_QUERY_CUSTOMER_INFO = 'query_customer_info';
const ORDER_NO_TYPE_REQUEST_ID = 'request_id'; const ORDER_NO_TYPE_REQUEST_ID = 'request_id';
const ORDER_NO_TYPE_WITHDRAW_APPLY_BATCH_NUM = 'withdraw_apply_batch_num';
const ORDER_NO_TYPE_WITHDRAW_APPLY_NO = 'withdraw_apply_no';
const ORDER_NO_TYPE_WITHDRAW_NO = 'withdraw_no';
public static function getRandomString($length, $withSpecialChar = false) public static function getRandomString($length, $withSpecialChar = false)
{ {

@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
namespace App\Model;
class Withdraw extends Model
{
protected $table = 'withdraw';
public function app()
{
return $this->belongsTo(App::class, 'app_id', 'app_id');
}
}

@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
namespace App\Model;
class WithdrawApply extends Model
{
protected $table = 'withdraw_apply';
public function app()
{
return $this->belongsTo(App::class, 'app_id', 'app_id');
}
}

@ -15,6 +15,7 @@ use App\Model\OrderSplitInfo;
use App\Model\Refund; use App\Model\Refund;
use App\Model\RefundSplitInfo; use App\Model\RefundSplitInfo;
use App\Model\User; use App\Model\User;
use App\Model\WithdrawApply;
class PaymentService extends AbstractService class PaymentService extends AbstractService
{ {
@ -505,4 +506,55 @@ class PaymentService extends AbstractService
return $this->updateOrder($info); return $this->updateOrder($info);
} }
public function withdrawApply(array $data, App $app) {
$user = User::where('app_id', $app->app_id)->where('user_id', $data['userId'])->first();
if (empty($user)) {
throw new BusinessException('用户不存在');
}
$apply = new WithdrawApply();
$apply->app_id = $app->app_id;
$apply->user_id = $user->user_id;
$apply->member_id = $user->member_id;
$apply->account_name = $data['accountName'];
$apply->batch_num = StringHelper::generateOrderNo(StringHelper::ORDER_NO_TYPE_WITHDRAW_APPLY_BATCH_NUM);
$apply->apply_no = StringHelper::generateOrderNo(StringHelper::ORDER_NO_TYPE_WITHDRAW_APPLY_NO);
$apply->out_apply_no = $params['outApplyNo'];
$apply->amount = $params['amount'];
$apply->status = 'PREPARE';
$apply->summary = $data['summary'] ?? '转账';
$apply->save();
$baofu = new Baofu();
$data = [
'transContent' => [
[
'transNo' => $apply->apply_no,
'transMoney' => round($apply->amount / 100, 2),
'transType' => 2,
'transAccNo' => $user->contract_no,
'transAccName' => $apply->account_name,
'transSummary' => $apply->summary,
]
]
];
$result = $baofu->transferWithdraw($data);
if ($result['header']['sysRespCode'] == 'S_0000' && $result['body']['transHeader']['returnCode'] == '0000') {
$apply->status = 'APPLY_SUCCESS';
} else {
$apply->status = 'APPLY_FAILED';
}
$apply->save();
}
public function withdraw(array $data, App $app, string $token) {
$baofu = new Baofu();
return $baofu->withdraw([
'amount' => $data['amount'],
'loginNo' => $data['amount'],
'agreementNo' => $data['agreementNo'],
'outOrderNo' => $data['outOrderNo'],
], $token);
}
} }

@ -27,6 +27,8 @@ Router::addGroup('/payment',function () {
Router::post('/refund-apply', [PaymentController::class, 'refundApply']); Router::post('/refund-apply', [PaymentController::class, 'refundApply']);
Router::post('/refund-confirm', [PaymentController::class, 'refundConfirm']); Router::post('/refund-confirm', [PaymentController::class, 'refundConfirm']);
Router::post('/refund-cancel', [PaymentController::class, 'refundCancel']); Router::post('/refund-cancel', [PaymentController::class, 'refundCancel']);
Router::post('/withdraw-apply', [PaymentController::class, 'withdrawApply']);
Router::post('/withdraw', [PaymentController::class, 'withdraw']);
}, ['middleware' => [\App\Middleware\RequestLogMiddleware::class, \App\Middleware\AppAuthMiddleWare::class]]); }, ['middleware' => [\App\Middleware\RequestLogMiddleware::class, \App\Middleware\AppAuthMiddleWare::class]]);
Router::addGroup('/notify',function () { Router::addGroup('/notify',function () {
@ -34,6 +36,7 @@ Router::addGroup('/notify',function () {
Router::addRoute(['GET', 'POST'], '/bind-card/{token}', [NotifyController::class, 'bindCard']); Router::addRoute(['GET', 'POST'], '/bind-card/{token}', [NotifyController::class, 'bindCard']);
Router::addRoute(['GET', 'POST'], '/payment/{token}', [NotifyController::class, 'payment']); Router::addRoute(['GET', 'POST'], '/payment/{token}', [NotifyController::class, 'payment']);
Router::addRoute(['GET', 'POST'], '/refund/{token}', [NotifyController::class, 'refund']); Router::addRoute(['GET', 'POST'], '/refund/{token}', [NotifyController::class, 'refund']);
Router::addRoute(['GET', 'POST'], '/transfer-withdraw', [NotifyController::class, 'transferWithdraw']);
Router::addRoute(['POST'], '/test-notify', [NotifyController::class, 'testNotify']); Router::addRoute(['POST'], '/test-notify', [NotifyController::class, 'testNotify']);
Router::addRoute(['GET', 'POST'], '/confirm-assure-portfolio-pay/{token}', [NotifyController::class, 'confirmAssurePortfolioPay']); Router::addRoute(['GET', 'POST'], '/confirm-assure-portfolio-pay/{token}', [NotifyController::class, 'confirmAssurePortfolioPay']);
}); });

Loading…
Cancel
Save