WIN-2308041133\Administrator 2 mesi fa
parent
commit
2016bc24bf

+ 18 - 1
app/adminapi/controller/v1/finance/Finance.php

@@ -11,6 +11,7 @@
 namespace app\adminapi\controller\v1\finance;
 namespace app\adminapi\controller\v1\finance;
 
 
 use app\services\user\UserBillServices;
 use app\services\user\UserBillServices;
+use app\services\user\UserBrokerageServices;
 use think\facade\App;
 use think\facade\App;
 use app\adminapi\controller\AuthController;
 use app\adminapi\controller\AuthController;
 
 
@@ -97,5 +98,21 @@ class Finance extends AuthController
         $where['type'] = ['brokerage', 'brokerage_user'];
         $where['type'] = ['brokerage', 'brokerage_user'];
         return app('json')->success($this->services->getBillOneList((int)$id, $where));
         return app('json')->success($this->services->getBillOneList((int)$id, $where));
     }
     }
-
+    /**
+     * 获取用户佣金列表
+     * @param UserBrokerageServices $services
+     * @param string $id
+     * @return mixed
+     */
+    public function getUserBrokeragelist(UserBrokerageServices $services, $id = '')
+    {
+        if ($id == '') return app('json')->fail('缺少参数');
+        $where = $this->request->getMore([
+            ['start_time', ''],
+            ['end_time', ''],
+            ['nickname', '']
+        ]);
+        $where['uid'] = (int)$id;
+        return app('json')->success($services->getBrokerageListNew($where));
+    }
 }
 }

+ 2 - 1
app/adminapi/route/finance.php

@@ -40,7 +40,8 @@ Route::group('finance', function () {
         //佣金详情用户信息
         //佣金详情用户信息
         Route::get('finance/user_info/:id', 'v1.finance.Finance/user_info')->option(['real_name' => '佣金详情用户信息']);
         Route::get('finance/user_info/:id', 'v1.finance.Finance/user_info')->option(['real_name' => '佣金详情用户信息']);
         //佣金提现记录个人列表
         //佣金提现记录个人列表
-        Route::get('finance/extract_list/:id', 'v1.finance.Finance/get_extract_list')->option(['real_name' => '佣金提现记录个人列表']);
+//        Route::get('finance/extract_list/:id', 'v1.finance.Finance/get_extract_list')->option(['real_name' => '佣金提现记录个人列表']);
+        Route::get('finance/extract_list/:id', 'v1.finance.Finance/getUserBrokeragelist')->option(['real_name' => '佣金提现记录个人列表']);
         /** 余额记录 */
         /** 余额记录 */
         Route::get('balance/list', 'v1.finance.UserBalance/balanceList')->option(['real_name' => '余额记录列表']);
         Route::get('balance/list', 'v1.finance.UserBalance/balanceList')->option(['real_name' => '余额记录列表']);
         Route::post('balance/set_mark/:id', 'v1.finance.UserBalance/balanceRecordRemark')->option(['real_name' => '余额记录备注']);
         Route::post('balance/set_mark/:id', 'v1.finance.UserBalance/balanceRecordRemark')->option(['real_name' => '余额记录备注']);

+ 29 - 1
app/dao/user/UserBrokerageDao.php

@@ -46,6 +46,23 @@ class UserBrokerageDao extends BaseDao
             $query->page($page, $limit);
             $query->page($page, $limit);
         })->order('id desc')->select()->toArray();
         })->order('id desc')->select()->toArray();
     }
     }
+    /**
+     * 获取列表
+     * @param array $where
+     * @param string $field
+     * @param int $page
+     * @param int $limit
+     * @return array
+     */
+    public function getBrokerageList(array $where, string $field = '*', int $page = 0, int $limit = 0)
+    {
+        return $this->search($where)->field($field)->with([
+            'user' => function ($query) {
+                $query->field('uid,nickname');
+            }])->when($page && $limit, function ($query) use ($page, $limit) {
+            $query->page($page, $limit);
+        })->order('id desc')->select()->toArray();
+    }
 
 
     /**
     /**
      * 查询列表
      * 查询列表
@@ -95,7 +112,18 @@ class UserBrokerageDao extends BaseDao
         } else
         } else
             return $this->search($where)->sum('number');
             return $this->search($where)->sum('number');
     }
     }
-
+    /**
+     * 获取某些条件的bill总数
+     * @param array $where
+     * @return mixed
+     */
+    public function getBrokerageSumColumnNew(array $where)
+    {
+        if (isset($where['uid']) && is_array($where['uid'])) {
+            return $this->search($where)->group('uid')->column('sum(number) as num', 'uid');
+        } else
+            return $this->search($where)->sum('number');
+    }
     /**
     /**
      * 获取某个账户下的冻结佣金
      * 获取某个账户下的冻结佣金
      * @param int $uid
      * @param int $uid

+ 43 - 1
app/services/user/UserBrokerageServices.php

@@ -481,7 +481,49 @@ class UserBrokerageServices extends BaseServices
         }
         }
         return ['list' => $list, 'time' => $times, 'count' => $count];
         return ['list' => $list, 'time' => $times, 'count' => $count];
     }
     }
-
+    /**
+     * 获取资金列表
+     * @param array $where
+     * @param string $field
+     * @param int $limit
+     * @return array
+     */
+    public function getBrokerageListNew(array $where, string $field = '*', int $limit = 0)
+    {
+        $where_data = [];
+        if (isset($where['uid']) && $where['uid'] != '') {
+            $where_data['uid'] = $where['uid'];
+        }
+        if ($where['start_time'] != '' && $where['end_time'] != '') {
+            $where_data['time'] = str_replace('-', '/', $where['start_time']) . ' - ' . str_replace('-', '/', $where['end_time']);
+        }
+        if (isset($where['type']) && $where['type'] != '') {
+            $where_data['type'] = $where['type'];
+        }
+        if (isset($where['nickname']) && $where['nickname'] != '') {
+            $where_data['like'] = $where['nickname'];
+        }
+        if ($limit) {
+            [$page] = $this->getPageValue();
+        } else {
+            [$page, $limit] = $this->getPageValue();
+        }
+        $data = $this->dao->getBrokerageList($where_data, $field, $page, $limit);
+        $count = $this->dao->count($where_data);
+        $data2 = $this->dao->getBrokerageList($where_data, $field);
+        $where_data['pm'] = 1;
+        $data3 = $this->dao->getBrokerageSumColumnNew($where_data);
+        $where_data['pm'] = 0;
+        $data4 = $this->dao->getBrokerageSumColumnNew($where_data);
+        $data5 = $data3 - $data4;
+        $sum = round($data5, 2);
+        foreach ($data as &$item) {
+            $item['nickname'] = $item['user']['nickname'] ?? '';
+            $item['_add_time'] = $item['add_time'] ? date('Y-m-d H:i:s', $item['add_time']) : '';
+            unset($item['user']);
+        }
+        return compact('data', 'count', 'sum');
+    }
     /**
     /**
      * 前端佣金排行页面数据
      * 前端佣金排行页面数据
      * @param int $uid
      * @param int $uid