| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 | <?phpnamespace app\admin\controller\statistics;use app\model\Member;use support\Db;class MemberController{    public function index()    {        // 权益会员数量        $memberCount = Member::where('member_is_owner', 'N')->count();        // 业主数量        $ownerCount = Member::where('member_is_owner', 'N')->count();        // 用户总数        $userCount = $memberCount + $ownerCount;        // 今日新增用户数        $todayTime = strtotime(date('Y-m-d 00:00:00'));        $todayCount = Member::where('member_addtimes', '>', $todayTime)->count();        // 本月新增用户数        $monthTime = strtotime(date('Y-m-01 00:00:00'));        $monthCount = Member::where('member_addtimes', '>', $monthTime)->count();        // 折线图        $newAddition = Db::select("SELECT DATE_FORMAT(FROM_UNIXTIME(member_addtimes), '%Y/%m') AS `month`,count(*) as `num` FROM app_member group by month");        $newAdditionData = [];        foreach ($newAddition as $item){            $newAdditionData['category'][] = $item->month;            $newAdditionData['data'][] = $item->num;        }        // 饼图        $data = [            'memberCount'=>$memberCount,            'ownerCount'=>$ownerCount,            'userCount'=>$userCount,            'todayCount'=>$todayCount,            'monthCount'=>$monthCount,            'newAdditionData'=>$newAdditionData        ];        return json_success('',$data);    }}
 |