From 337f733cb9116245fdc2dfff448a1c6d14a205b2 Mon Sep 17 00:00:00 2001 From: wanghongjun <1445693971@qq,com> Date: Mon, 9 Oct 2023 11:51:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=80=BB=E5=90=8E=E5=8F=B0=E4=B8=AD=E5=A5=96?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/AdminStatistics.php | 42 ++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/app/controller/AdminStatistics.php b/app/controller/AdminStatistics.php index 3bbe842..a280d40 100644 --- a/app/controller/AdminStatistics.php +++ b/app/controller/AdminStatistics.php @@ -9,6 +9,7 @@ use app\model\AdminDownScoresRecords; use app\model\AdminUpScoresRecords; use app\model\AgentDownScoresRecords; use app\model\AgentUpScoresRecords; +use app\model\AwardsRecords; use think\exception\ValidateException; use think\facade\Request; use app\model\User as UserModel; @@ -152,4 +153,45 @@ class AdminStatistics extends BaseController return $data; } + /** + * 中奖记录 + * @return array + * @throws \think\db\exception\DbException + */ + public function awardRecords() + { + $data = Request::param(); + + $limit = $data['limit'] ?? 10; + $date = $data['date'] ?? date("Y-m-d",time()); + $start_time = $date . ' 00:00:00'; + $end_time = $date . ' 23:59:59'; + $where = [['create_time','>=',$start_time],['create_time', '<=', $end_time]]; + + $records = new AwardsRecords(); + + $list = $records->field('user_id,awards_amount,create_time') + ->where($where) + ->order('create_time desc') + ->paginate($limit); + + $data = $list->toArray()['data']; + + $sumRes = $records->field('SUM(awards_amount) as sum_amount')->where($where)->find(); + foreach ($data as &$item) { + $user = UserModel::field('phone')->find($item['user_id']); + $item['phone'] = $user['phone']; + $item['awards_amount'] *= 1; + $item['datetime'] = date("H:i:s",strtotime($item['create_time'])); + unset($item['create_time']); + } + + return $this->renderSuccess('数据返回成功',[ + 'list' => $data, + 'total' => $list->total(), + 'sum_amount' => $sumRes['sum_amount'] * 1, + 'unit' => '元' + ]); + } + }