Update Center.php

This commit is contained in:
邹景立 2021-01-28 10:56:18 +08:00
parent 19b71be233
commit c34f0e50ea

View File

@ -106,21 +106,21 @@ class Center extends Auth
*/ */
public function getFrom() public function getFrom()
{ {
$where = []; $map = [];
$where[] = ['deleted', '=', '0']; $map[] = ['deleted', '=', '0'];
$where[] = ['path', 'like', "%-{$this->uuid}-%"]; $map[] = ['path', 'like', "%-{$this->uuid}-%"];
// 查询邀请的朋友 // 查询邀请的朋友
$query = $this->_query($this->table); $query = $this->_query($this->table);
$query->like('nickname|username#nickname')->equal('from,id#uid'); $query->like('nickname|username#nickname')->equal('from,id#uid');
$query->field('id,from,username,nickname,headimg,amount_total,create_at'); $query->field('id,from,username,nickname,headimg,amount_total,create_at');
$result = $query->where($where)->order('id desc')->page(true, false, false, 15); $result = $query->where($map)->order('id desc')->page(true, false, false, 15);
// 统计当前用户所有下属数 // 统计当前用户所有下属数
$userTotal = $this->app->db->name($this->table)->where($where)->count(); $total = $this->app->db->name($this->table)->where($map)->count();
// 统计当前用户本月下属数 // 统计当前用户本月下属数
$where[] = ['create_at', 'like', date('Y-m-%')]; $map[] = ['create_at', 'like', date('Y-m-%')];
$userMonth = $this->app->db->name($this->table)->where($where)->count(); $month = $this->app->db->name($this->table)->where($map)->count();
// 返回结果列表数据及统计 // 返回结果列表数据及统计
$result['total'] = ['user_total' => $userTotal, 'user_month' => $userMonth]; $result['total'] = ['user_total' => $total, 'user_month' => $month];
$this->success('获取我邀请的朋友', $result); $this->success('获取我邀请的朋友', $result);
} }