|
|
|
@ -4,7 +4,11 @@ declare (strict_types = 1); |
|
|
|
namespace app\controller; |
|
|
|
|
|
|
|
use app\BaseController; |
|
|
|
use app\model\AdminDownScoresRecords; |
|
|
|
use app\model\AdminUpScoresRecords; |
|
|
|
use app\model\AgentUser; |
|
|
|
use think\exception\ValidateException; |
|
|
|
use think\facade\Request; |
|
|
|
use think\facade\Session; |
|
|
|
use app\model\User as UserModel; |
|
|
|
|
|
|
|
@ -64,4 +68,76 @@ class AdminStatistics extends BaseController |
|
|
|
] |
|
|
|
]); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 上下分统计数据(柱状图) |
|
|
|
* @return array |
|
|
|
* @throws \think\db\exception\DataNotFoundException |
|
|
|
* @throws \think\db\exception\DbException |
|
|
|
* @throws \think\db\exception\ModelNotFoundException |
|
|
|
*/ |
|
|
|
public function upAndDownStatistics() |
|
|
|
{ |
|
|
|
|
|
|
|
$param = Request::param(); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
validate()->rule(['type|统计类型' => 'require|in:1,2'])->check($param); |
|
|
|
|
|
|
|
$type = $param['type']; |
|
|
|
|
|
|
|
$start_time = date("Y-m-d H:i:s",strtotime('-4 month')); |
|
|
|
|
|
|
|
$date = get_near_month_datetime(); |
|
|
|
|
|
|
|
$data = []; |
|
|
|
|
|
|
|
if ($type == 1) { |
|
|
|
// 上分统计 |
|
|
|
$sumData = AdminUpScoresRecords::field('SUM(balance) as sum_num') |
|
|
|
->where('id','>=',1) |
|
|
|
->find(); |
|
|
|
// 统计近4个月数据 |
|
|
|
foreach ($date as $month => $datetime) { |
|
|
|
|
|
|
|
$res = AdminUpScoresRecords::field('SUM(balance) as sum_num') |
|
|
|
->where([ |
|
|
|
['create_time','>=',$datetime['start_time']], |
|
|
|
['create_time','<=',$datetime['end_time']], |
|
|
|
]) |
|
|
|
->find(); |
|
|
|
$data['histogram'] = [ |
|
|
|
'date' => $month, |
|
|
|
'value' => $res['sum_num'] |
|
|
|
]; |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 下分统计 |
|
|
|
$sumData = AdminDownScoresRecords::field('SUM(withdrawal_amount) as sum_num') |
|
|
|
->where('id','>=',1) |
|
|
|
->find(); |
|
|
|
// 统计近4个月数据 |
|
|
|
foreach ($date as $month => $datetime) { |
|
|
|
$res = AdminDownScoresRecords::field('SUM(withdrawal_amount) as sum_num') |
|
|
|
->where([ |
|
|
|
['create_time','>=',$datetime['start_time']], |
|
|
|
['create_time','<=',$datetime['end_time']], |
|
|
|
]) |
|
|
|
->find(); |
|
|
|
$data['histogram'] = [ |
|
|
|
'date' => $month, |
|
|
|
'value' => $res['sum_num'] |
|
|
|
]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
$data['sum_value'] = $sumData['sum_num']; |
|
|
|
|
|
|
|
return $this->renderSuccess('数据返回成功',$data); |
|
|
|
} catch (ValidateException $validateException) { |
|
|
|
return $this->renderError($validateException->getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|