wesmiler 2 months ago
parent
commit
45032167fc

+ 76 - 0
app/Http/Controllers/Admin/WithdrawController.php

@@ -0,0 +1,76 @@
+<?php
+// +----------------------------------------------------------------------
+// | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
+// +----------------------------------------------------------------------
+// | 版权所有 2017~2021 LARAVEL研发中心
+// +----------------------------------------------------------------------
+// | 官方网站: http://www.laravel.cn
+// +----------------------------------------------------------------------
+// | Author: laravel开发员 <laravel.qq.com>
+// +----------------------------------------------------------------------
+
+namespace App\Http\Controllers\Admin;
+
+use App\Services\Common\BalanceLogService;
+
+/**
+ * 提现管理-控制器
+ * @author laravel开发员
+ * @since 2020/11/11
+ * @package App\Http\Controllers
+ */
+class WithdrawController extends Backend
+{
+    /**
+     * 构造函数
+     * @author laravel开发员
+     * @since 2020/11/11
+     */
+    public function __construct()
+    {
+        parent::__construct();
+        $this->service = new  BalanceLogService();
+    }
+
+
+    /**
+     * 列表
+     * @return array
+     */
+    public function index()
+    {
+        $pageSize = request()->get('limit', 10);
+        $list = $this->service->getDataList(request()->all(), $pageSize);
+        $message = array(
+            "msg" => '操作成功',
+            "code" => 0,
+            "data" => isset($list['list'])? $list['list']:[],
+            "count" => isset($list['total'])? $list['total']:0,
+        );
+        return $message;
+    }
+
+    /**
+     * 统计
+     * @return array
+     */
+    public function count()
+    {
+        $datas = $this->service->getCount(request()->all());
+        $message = array(
+            "msg" => '操作成功',
+            "code" => 0,
+            "data" => $datas,
+        );
+        return $message;
+    }
+
+
+    /**
+     * 审核
+     * @return mixed
+     */
+    public function auth(){
+        return $this->service->audit();
+    }
+}

+ 121 - 1
app/Services/Common/BalanceLogsService.php

@@ -4,7 +4,6 @@ namespace App\Services\Common;
 
 use App\Models\BalanceLogModel;
 use App\Models\MemberModel;
-use App\Models\AgentModel;
 use App\Models\StoreModel;
 use App\Services\BaseService;
 use Illuminate\Support\Facades\DB;
@@ -15,6 +14,7 @@ use Illuminate\Support\Facades\DB;
  */
 class BalanceLogsService extends BaseService
 {
+
     /**
      * 获取列表
      * @param array $params 请求参数
@@ -293,6 +293,126 @@ class BalanceLogsService extends BaseService
     }
 
     /**
+     * 列表
+     * @param $params
+     * @param int $pageSize
+     * @return array
+     */
+    public function getDataList($params, $pageSize = 10)
+    {
+        $where = ['a.mark' => 1];
+        $list = $this->model->from('balance_logs as a')
+            ->leftJoin('member as b','b.id','=','a.user_id')
+            ->leftJoin('driver as c','c.id','=','a.user_id')
+            ->where($where)
+            ->where(function ($query) use($params){
+                $userType = isset($params['user_type'])? $params['user_type'] : 0;
+                if($userType == 1){
+                    $query->where('a.user_type', $userType);
+
+                    $keyword = isset($params['keyword'])? $params['keyword'] : '';
+                    if($keyword){
+                        $query->where(function($query) use($keyword){
+                            $query->where('a.order_no','like',"%{$keyword}%")->orWhere('b.nickname','like',"%{$keyword}%")->orWhere('b.mobile','like',"%{$keyword}%");
+                        });
+                    }
+                }else if ($userType == 2){
+                    $query->where('a.user_type', $userType);
+
+                    $keyword = isset($params['keyword'])? $params['keyword'] : '';
+                    if($keyword){
+                        $query->where(function($query) use($keyword){
+                            $query->where('a.order_no','like',"%{$keyword}%")->orWhere('c.realname','like',"%{$keyword}%")->orWhere('c.mobile','like',"%{$keyword}%");
+                        });
+                    }
+                }
+            })
+            ->where(function ($query) use($params){
+                $status = isset($params['status'])? $params['status'] : 0;
+                if($status>0 && is_array($status)){
+                    $query->whereIn('a.status', $status);
+                }else if($status){
+                    $query->where('a.status', $status);
+                }
+
+                $type = isset($params['type'])? $params['type'] : 0;
+                if($type>0){
+                    $query->where('a.type', $type);
+                }
+            })
+            ->select(['a.*','b.nickname as user_nickname','b.realname as user_realname','b.mobile as user_mobile','c.realname as driver_name','c.mobile as driver_mobile','c.realname as driver_realname'])
+            ->orderBy('a.create_time','desc')
+            ->orderBy('a.id','desc')
+            ->paginate($pageSize > 0 ? $pageSize : 9999999);
+        $list = $list? $list->toArray() :[];
+        if($list){
+            foreach($list['data'] as &$item){
+                $item['create_time'] = $item['create_time']? datetime($item['create_time'],'Y-m-d H.i.s') : '';
+                $item['qrcode'] = $item['qrcode']? get_image_url($item['qrcode']) : '';
+                $item['account'] = $item['account']? json_decode($item['account'], true) : [];
+                $item['username'] = $item['user_nickname']? $item['user_nickname'].($item['user_mobile']?'-'.$item['user_mobile']:'') : '';
+                $item['driver'] = $item['driver_name']? $item['driver_name'].($item['driver_mobile']?'-'.$item['driver_mobile']:'') : '';
+                if($item['user_type'] == 2){
+                    $item['realname'] = $item['realname']? $item['realname'] : $item['driver_realname'];
+                }else{
+                    $item['realname'] = $item['realname']? $item['realname'] : $item['user_realname'];
+                }
+
+            }
+        }
+
+        return [
+            'pageSize'=> $pageSize,
+            'total'=>isset($list['total'])? $list['total'] : 0,
+            'list'=> isset($list['data'])? $list['data'] : []
+        ];
+    }
+
+    /**
+     * 统计
+     * @param $params
+     * @return array
+     */
+    public function getCount($params)
+    {
+        $where = ['a.mark' => 1];
+        $model = $this->model->from('balance_logs as a')
+            ->leftJoin('member as b','b.id','=','a.user_id')
+            ->where($where)
+            ->where(function ($query) use($params){
+                $userType = isset($params['user_type'])? $params['user_type'] : 0;
+                if($userType == 1){
+                    $query->where('a.user_type', $userType);
+
+                    $keyword = isset($params['keyword'])? $params['keyword'] : '';
+                    if($keyword){
+                        $query->where(function($query) use($keyword){
+                            $query->where('a.order_no','like',"%{$keyword}%")->orWhere('b.nickname','like',"%{$keyword}%")->orWhere('b.mobile','like',"%{$keyword}%");
+                        });
+                    }
+                }
+            })
+            ->where(function ($query) use($params){
+                $status = isset($params['status'])? $params['status'] : 0;
+                if($status>0 && is_array($status)){
+                    $query->whereIn('a.status', $status);
+                }else if($status){
+                    $query->where('a.status', $status);
+                }
+
+                $type = isset($params['type'])? $params['type'] : 0;
+                if($type>0){
+                    $query->where('a.type', $type);
+                }
+            });
+        $counts = [
+            'count'=> $model->count('a.id'),
+            'total'=> $model->sum('a.money'),
+        ];
+        return $counts;
+    }
+
+    /**
      * 更新代理表的累计提现金额
      */
     private function updateAgentWithdrawTotal($record)

+ 9 - 0
routes/web.php

@@ -227,6 +227,15 @@ Route::post('/account/status', [\App\Http\Controllers\Admin\AccountController::c
 Route::post('/account/delete', [\App\Http\Controllers\Admin\AccountController::class, 'delete']);
 Route::post('/account/count', [\App\Http\Controllers\Admin\AccountController::class, 'count']);
 
+// 提现记录
+Route::get('/withdraw/index', [\App\Http\Controllers\Admin\WithdrawController::class, 'index']);
+Route::post('/withdraw/count', [\App\Http\Controllers\Admin\WithdrawController::class, 'count']);
+Route::post('/withdraw/edit', [\App\Http\Controllers\Admin\WithdrawController::class, 'edit']);
+Route::post('/withdraw/auth', [\App\Http\Controllers\Admin\WithdrawController::class, 'auth']);
+Route::post('/withdraw/status', [\App\Http\Controllers\Admin\WithdrawController::class, 'status']);
+Route::post('/withdraw/delete', [\App\Http\Controllers\Admin\WithdrawController::class, 'delete']);
+
+
 
 // 操作日志
 Route::get('/actionlog/index', [ActionLogController::class, 'index']);