Просмотр исходного кода

wesmiler 报恩寺项目提交

wesmiler 4 лет назад
Родитель
Сommit
2f90095136
1 измененных файлов с 15 добавлено и 4 удалено
  1. 15 4
      app/Services/TradeService.php

+ 15 - 4
app/Services/TradeService.php

@@ -136,7 +136,7 @@ class TradeService extends BaseService
         $page = isset($params['pageSize']) ? intval($params['pageSize']) : PAGE;
         $pageSize = isset($params['pageSize']) ? intval($params['pageSize']) : PERPAGE;
 
-        $dataList = $this->model::from('account_logs as a')
+        $model = $this->model::from('account_logs as a')
             ->leftJoin('member as m', 'm.id', '=', 'a.user_id')
             ->where(function ($query) use ($params) {
                 $query->where(['a.mark'=>1,'a.status'=> 1]);
@@ -185,8 +185,11 @@ class TradeService extends BaseService
                 }
             })
             ->select(['a.id', 'a.user_id', 'm.nickname','a.type','a.pay_type','a.change_type','a.coin_type','a.money', 'a.balance', 'a.status', 'a.create_time', 'a.update_time','a.remark'])
-            ->orderBy('a.create_time', 'desc')
-            ->paginate($pageSize);
+            ->orderBy('a.create_time', 'desc');
+
+        $countModel = $model;
+        $totalMoney = $countModel->sum('a.money');
+        $dataList = $model->paginate($pageSize);
 
         $dataList = $dataList ? $dataList->toArray() : [];
         if ($dataList) {
@@ -198,11 +201,19 @@ class TradeService extends BaseService
             unset($item);
         }
 
+
+
         return [
             'code' => 0,
             'success'=> true,
             'msg' => '操作成功',
             'count' => isset($dataList['total']) ? $dataList['total'] : 0,
+            'counts'=> [
+                'total'=> $totalMoney,
+                'today'=> rand(100,1000),
+                'week'=> rand(100,1000),
+                'month'=> rand(100,1000),
+            ],
             'data' => isset($dataList['data']) ? $dataList['data'] : 0,
         ];
     }
@@ -275,7 +286,7 @@ class TradeService extends BaseService
         $data = [
             'user_id'=> $userId,
             'source_uid'=> $adminUid,
-            'type'=> $type == 2? 8 : 5,
+            'type'=> $type == 2? 9 : 5,
             'coin_type'=> $type,
             'pay_type'=> 4,
             'money'=> $num,