Ken 2 settimane fa
parent
commit
06799ca1e4
2 ha cambiato i file con 41 aggiunte e 35 eliminazioni
  1. 40 35
      app/Http/Controllers/admin/Withdraw.php
  2. 1 0
      routes/admin.php

+ 40 - 35
app/Http/Controllers/admin/Withdraw.php

@@ -5,6 +5,7 @@ namespace App\Http\Controllers\admin;
 use App\Constants\HttpStatus;
 use App\Http\Controllers\Controller;
 use App\Services\BalanceLogService;
+use App\Services\PaymentOrderService;
 use App\Services\TopUpService;
 use App\Services\WalletService;
 use App\Services\WithdrawService;
@@ -12,11 +13,50 @@ use Illuminate\Support\Facades\DB;
 use Illuminate\Validation\ValidationException;
 use Exception;
 use App\Models\Withdraw as WithdrawModel;
+use App\Models\PaymentOrder;
 use App\Models\Config;
 
 class Withdraw extends Controller
 {
 
+    public function rmb()
+    {
+        try {
+            $params = request()->validate([
+                'page' => ['nullable', 'integer', 'min:1'],
+                'limit' => ['nullable', 'integer', 'min:1'],
+                'member_id' => ['nullable', 'string', 'min:1'],
+                'status' => ['nullable', 'integer', 'min:0', 'max:3']
+            ]);
+            $page = request()->input('page', 1);
+            $limit = request()->input('limit', 10);
+            $params['type'] = 2;
+            $query = PaymentOrder::query();
+            $where = PaymentOrderService::getWhere($params);
+            $count = $query->where($where)->count();
+            $list = $query->where($where)
+                ->with(['member'])
+                ->orderBy('created_at', 'desc')
+                ->forpage($page, $limit)->get();
+            foreach ($list as &$item) {
+                $item['exchange_rate'] = floatval($item['exchange_rate']);
+                $item['after_balance'] = floatval($item['after_balance']);
+                $item['service_charge'] = floatval($item['service_charge']);
+                $item['amount'] = floatval($item['amount']);
+                $item['to_account'] = floatval($item['to_account']);
+                $item['to_account_usdt'] = floatval(bcdiv($item['to_account'], $item['exchange_rate'], 4));
+            }
+
+
+            $result = ['total' => $count, 'data' => $list];
+        } catch (ValidationException $e) {
+            return $this->error(HttpStatus::CUSTOM_ERROR, $e->validator->errors()->first());
+        } catch (Exception $e) {
+            return $this->error(intval($e->getCode()));
+        }
+        return $this->success($result);
+    }
+
 
     public function setNote()
     {
@@ -38,41 +78,6 @@ class Withdraw extends Controller
     }
 
 
-    /**
-     * @api {get} /admin/withdraw 提现列表
-     * @apiGroup 提现管理
-     *
-     * @apiUse result
-     * @apiUse header
-     * @apiVersion 1.0.0
-     *
-     * @apiParam {int} [page=1]
-     * @apiParam {int} [limit=10]
-     * @apiParam {string} [member_id] tg会员ID
-     * @apiParam {int} [status] 状态
-     * - 0 申请中
-     * - 1 通过
-     * - 2 拒绝
-     * @apiSuccess (data) {Object} data
-     * @apiSuccess (data) {int} data.total 数量
-     * @apiSuccess (data) {Object[]} data.data 列表
-     * @apiSuccess (data) {int} data.data.id
-     * @apiSuccess (data) {int} data.data.member_id tg会员id
-     * @apiSuccess (data) {string} data.data.amount 提现金额
-     * @apiSuccess (data) {string} data.data.service_charge 手续费
-     * @apiSuccess (data) {string} data.data.to_account 到账金额
-     * @apiSuccess (data) {string} data.data.after_balance 提现后余额
-     * @apiSuccess (data) {string} data.data.address 钱包地址
-     * @apiSuccess (data) {string} data.data.updated_at
-     * @apiSuccess (data) {string} data.data.created_at
-     * @apiSuccess (data) {int} data.data.status 状态
-     * - 0 申请中
-     * - 1 通过
-     * - 2 拒绝
-     * @apiSuccess (data) {string} data.data.remark
-     *
-     *
-     */
     public function index()
     {
         try {

+ 1 - 0
routes/admin.php

@@ -108,6 +108,7 @@ Route::middleware(['admin.jwt'])->group(function () {
 
         Route::prefix('/withdraw')->group(function () {
             Route::get('/', [Withdraw::class, 'index']);
+            Route::get('/rmb', [Withdraw::class, 'rmb']);
             Route::post('setStatus', [Withdraw::class, 'setStatus']);
             Route::post('/setNote', [Withdraw::class, 'setNote']);