|
|
@@ -108,7 +108,8 @@ class TradeService extends BaseService
|
|
|
->orderBy('a.create_time', 'desc');
|
|
|
|
|
|
$countModel = $model;
|
|
|
- $totalMoney = $countModel->sum('a.money');
|
|
|
+ $totals = $countModel->groupBy('a.change_type')->sum('a.money');
|
|
|
+// $moneyInc = isset($totals[])
|
|
|
$dataList = $model->paginate($pageSize);
|
|
|
|
|
|
$dataList = $dataList ? $dataList->toArray() : [];
|
|
|
@@ -125,7 +126,7 @@ class TradeService extends BaseService
|
|
|
'msg' => '操作成功',
|
|
|
'count' => isset($dataList['total']) ? $dataList['total'] : 0,
|
|
|
'counts'=> [
|
|
|
- 'total'=> $totalMoney,
|
|
|
+ 'total'=> $totals,
|
|
|
'today'=> rand(100,1000),
|
|
|
'week'=> rand(100,1000),
|
|
|
'month'=> rand(100,1000),
|
|
|
@@ -135,6 +136,68 @@ class TradeService extends BaseService
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 统计
|
|
|
+ * @param $params
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
+ public function counts($params){
|
|
|
+ $counts = $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);
|
|
|
+
|
|
|
+ $type = isset($params['type']) ? $params['type'] : 0;
|
|
|
+ if ($type > 0) {
|
|
|
+ $type = explode(',', $type);
|
|
|
+ $query->whereIn('a.type', $type);
|
|
|
+ }
|
|
|
+
|
|
|
+ $payType = isset($params['pay_type']) ? $params['pay_type'] : 0;
|
|
|
+ if ($payType > 0) {
|
|
|
+ $query->where('a.pay_type', $payType);
|
|
|
+ }
|
|
|
+
|
|
|
+ $coinType = isset($params['coin_type']) ? $params['coin_type'] : 0;
|
|
|
+ if ($coinType > 0) {
|
|
|
+ $query->where('a.coin_type', $coinType);
|
|
|
+ }
|
|
|
+
|
|
|
+ $changeType = isset($params['change_type']) ? $params['change_type'] : 0;
|
|
|
+ if ($changeType > 0) {
|
|
|
+ $query->where('a.change_type', $changeType);
|
|
|
+ }
|
|
|
+
|
|
|
+ $userId = isset($params['user_id']) ? $params['user_id'] : 0;
|
|
|
+ if ($userId > 0) {
|
|
|
+ $query->where('a.user_id', $userId);
|
|
|
+ }
|
|
|
+
|
|
|
+ $datetime = isset($params['datetime'])? $params['datetime'] : [];
|
|
|
+ $dateStart = $datetime && isset($datetime[0])? $datetime[0] : '';
|
|
|
+ $dateEnd = isset($datetime[1])? $datetime[1] : '';
|
|
|
+ if($dateStart && $dateEnd && $dateEnd> $dateStart){
|
|
|
+ $query->where('a.create_time', '>', strtotime($dateStart))->where('a.create_time','<=', strtotime($dateEnd)+86399);
|
|
|
+ }else if($dateStart && $dateStart == $dateEnd){
|
|
|
+ $query->where('a.create_time', '>=', strtotime($dateStart))->where('a.create_time','<=', strtotime($dateStart)+86399);
|
|
|
+ }else if ($dateStart){
|
|
|
+ $query->where('a.create_time', '<=', strtotime($dateStart)+86399);
|
|
|
+ }
|
|
|
+
|
|
|
+ $status = isset($params['status']) ? $params['status'] : 0;
|
|
|
+ if ($status > 0) {
|
|
|
+ $query->where('a.status', $status);
|
|
|
+ } else {
|
|
|
+ $query->whereIn('a.status', [1, 2, 3]);
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
+ ->orderBy('a.create_time','desc')
|
|
|
+ ->groupBy('a.change_type')
|
|
|
+ ->sum();
|
|
|
+ return $counts;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 获取列表
|
|
|
* @return array
|
|
|
* @since 2020/11/11
|
|
|
@@ -210,7 +273,6 @@ class TradeService extends BaseService
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
return [
|
|
|
'code' => 0,
|
|
|
'success'=> true,
|