From 7c154e0528dc5c92e1261d3fea4974c68a12eb42 Mon Sep 17 00:00:00 2001
From: elf <360197197@qq.com>
Date: Fri, 22 Dec 2023 23:24:57 +0800
Subject: [PATCH] yg
---
app/Controller/Payment/AccountController.php | 87 ++++++++++++++++++++
app/Model/Order.php | 5 ++
app/Service/PaymentService.php | 12 +++
config/routes.php | 1 +
public/orders.html | 62 +++++---------
5 files changed, 127 insertions(+), 40 deletions(-)
diff --git a/app/Controller/Payment/AccountController.php b/app/Controller/Payment/AccountController.php
index e2bcfcf..fc47091 100644
--- a/app/Controller/Payment/AccountController.php
+++ b/app/Controller/Payment/AccountController.php
@@ -10,11 +10,13 @@ use App\Helper\RedisKey;
use App\Helper\StringHelper;
use App\Model\Account;
use App\Model\BankCard;
+use App\Model\Order;
use App\Model\User;
use Hyperf\HttpServer\Contract\RequestInterface;
use App\Service\PaymentService;
use App\Service\RequestService;
use App\Service\UserService;
+use Hyperf\DbConnection\Db;
class AccountController extends AbstractController
{
@@ -224,4 +226,89 @@ class AccountController extends AbstractController
$url = $this->userService->signWithdrawEntrust($requestLog->getData(), $requestLog->app, $requestLog->request_token);
return $this->success(['url' => $url]);
}
+
+ public function getOrders(RequestInterface $request)
+ {
+ $userInfo = $this->checkUser($request);
+ $userId = $this->resetUserId($userInfo['userId']);
+ $query = Order::query()->with('user');
+ if ($userId != 'ACT_5') {
+ $query->where('user_id', $userId);
+ }
+ if (!empty($request->input('outOrderNo'))) {
+ $query->where('out_order_no', $request->input('outOrderNo'));
+ }
+ if (!empty($request->input('mobile'))) {
+ $query->where('bank_mobile', $request->input('mobile'));
+ }
+ if (!empty($request->input('bankCardNo'))) {
+ $query->where('last_card_no', $request->input('bankCardNo'));
+ }
+ if (!empty($request->input('cardUserName'))) {
+ $query->where('card_user_name', 'like', Db::raw('%' . $request->input('cardUserName'));
+ }
+ $status = $request->input('status');
+ if (!empty($status)) {
+ $statusList = [];
+ if ($status == 'FAILED') {
+ $statusList = ['APPLY_FAILED', 'FAILED'];
+ } elseif ($status == 'FINISH') {
+ $statusList = ['CONFIRM_SUCCESS', 'FINISH'];
+ } elseif ($status == 'SUCCESS') {
+ $statusList = ['SUCCESS'];
+ } elseif ($status == 'CONFIRM_FAILED') {
+ $statusList = ['CONFIRM_FAILED'];
+ } elseif ($status == 'PROCESS') {
+ $statusList = ['APPLY_SUCCESS', 'PROCESS'];
+ }
+ $query->whereIn('status', $statusList);
+ }
+ if (!empty($request->input('timeRange'))) {
+ $timeRange[0] .= ' 00:00:00';
+ $timeRange[1] .= ' 23:59:59';
+ $query->whereBetween('created_at', $timeRange);
+ }
+ $countQuery = clone $query;
+ $sumQuery = clone $query;
+ $total = $countQuery->count();
+ $amount = $sumQuery->sum('amount');
+ $orders = $query->get();
+
+ $records = [];
+ foreach ($orders as $order) {
+ $statusText = '';
+ $systemStatus = '';
+ if (in_array($order->status, ['APPLY_FAILED', 'FAILED'])) {
+ $statusText = '转账失败';
+ $systemStatus = 'FAILED';
+ } elseif (in_array($order->status, ['CONFIRM_SUCCESS', 'FINISH'])) {
+ $statusText = '转账成功,入账成功';
+ $systemStatus = 'FINISH';
+ } elseif (in_array($order->status, ['SUCCESS'])) {
+ $statusText = '转账成功,待入账';
+ $systemStatus = 'SUCCESS';
+ } elseif (in_array($order->status, ['CONFIRM_FAILED'])) {
+ $statusText = '转账成功,入账失败';
+ $systemStatus = 'CONFIRM_FAILED';
+ } elseif (in_array($order->status, ['APPLY_SUCCESS', 'PROCESS'])) {
+ $statusText = '待转账';
+ $systemStatus = 'PROCESS';
+ }
+ $records[] = [
+ 'out_order_no' => $order->out_order_no,
+ 'created_at' => $order->created_at,
+ 'status' => $order->status,
+ 'amount' => number_format($order->amount / 100, 2, '.', ''),
+ 'card_user_name' => $order->card_user_name,
+ 'last_card_no' => $order->last_card_no,
+ 'bank_mobile' => $order->bank_mobile,
+ 'certificate_no' => $order->ucertificate_no,
+ 'status' => $order->status,
+ 'system_status' => $systemStatus,
+ 'status_text' => $statusText,
+ ];
+ }
+
+ return $this->success(['records' => $records, 'total' => $total, 'amount' => $amount]);
+ }
}
diff --git a/app/Model/Order.php b/app/Model/Order.php
index 8b703dd..883cfd3 100644
--- a/app/Model/Order.php
+++ b/app/Model/Order.php
@@ -29,4 +29,9 @@ class Order extends Model
{
return $this->hasMany(OrderSplitInfo::class, 'order_no', 'order_no');
}
+
+ public function user()
+ {
+ return $this->belongsTo(User::class, 'member_id', 'member_id');
+ }
}
\ No newline at end of file
diff --git a/app/Service/PaymentService.php b/app/Service/PaymentService.php
index c2b124f..60f802b 100644
--- a/app/Service/PaymentService.php
+++ b/app/Service/PaymentService.php
@@ -10,6 +10,7 @@ use App\Exception\BusinessException;
use App\Helper\Baofu\Baofu;
use App\Helper\StringHelper;
use App\Model\App;
+use App\Model\BankCard;
use App\Model\Order;
use App\Model\OrderSplitInfo;
use App\Model\Refund;
@@ -184,6 +185,10 @@ class PaymentService extends AbstractService
if ($params['amount'] < 10) {
throw new BusinessException('金额不能小于10');
}
+ $bankCard = BankCard::where('app_id', $app->app_id)->where('user_id', $user->user_id)->where('agreement_no', $params['agreementNo'])->first();
+ if (!$bankCard) {
+ throw new BusinessException('银行卡不存在');
+ }
$expiresIn = $params['expiresIn'] ?? 10 * 60;
$order = new Order();
$order->app_id = $app->app_id;
@@ -209,6 +214,13 @@ class PaymentService extends AbstractService
$order->market_info = $params['marketInfo'] ?? [];
$order->org_split_info_list = $params['splitInfoList'];
$order->remark = $params['remark'] ?? '';
+ $order->last_card_no = $bankCard->last_card_no;
+ $order->card_user_name = $bankCard->card_user_name;
+ $order->bank_mobile = $bankCard->bank_mobile;
+ $order->bank_name = $bankCard->bank_name;
+ $order->bank_code = $bankCard->bank_code;
+ $order->card_type = $bankCard->card_type;
+ $order->cnaps_code = $bankCard->cnaps_code;
$order->save();
$platformAccount = User::getPlatformAccount($params['isAccountPay']);
diff --git a/config/routes.php b/config/routes.php
index 084f0e9..9f5ed17 100644
--- a/config/routes.php
+++ b/config/routes.php
@@ -50,6 +50,7 @@ Router::addGroup('/account',function () {
Router::get('/company-register', [AccountController::class, 'companyRegister']);
Router::post('/update-password', [AccountController::class, 'updatePassword']);
Router::get('/sign-withdraw-entrust', [AccountController::class, 'signWithdrawEntrust']);
+ Router::post('/get-orders', [AccountController::class, 'getOrders']);
}, []);
Router::addGroup('/notify',function () {
diff --git a/public/orders.html b/public/orders.html
index a4a0e27..535ac6a 100644
--- a/public/orders.html
+++ b/public/orders.html
@@ -17,16 +17,13 @@
-
+
-
+
-
-
-
-
+
-
-
-
-
+
+
+
+
+
@@ -65,28 +63,28 @@
width="180">
+ prop="last_card_no"
+ label="银行卡号(后四位)">
+ prop="bank_mobile"
+ label="手机号(后四位)">
{
console.log(response);
let result = response.data
@@ -191,24 +191,6 @@
},
handleCurrentChange(val) {
this.searchList(val)
- },
- login() {
- axios.post('/recharge/login', this.loginer)
- .then( (response) => {
- console.log(response);
- let result = response.data
- if (result.code != 1000) {
- return this.$message.error(response.data.message);
- }
- window.sessionStorage.setItem('token', result.data.token)
- this.loginVisible = false;
- this.$message.success('登录成功');
- this.searchList(1);
- })
- .catch((error) => {
- this.$message.error('请求错误');
- console.log(error);
- });
}
}
})