<?php
/**
 *
 * @file:HomeStatisticsController.php
 * @Date: 2023/6/28
 * @Time: 09:23
 */


namespace Modules\Statistic\Http\Controllers;

use Catch\Base\CatchController;
use Illuminate\Http\Request;
use Modules\Statistic\Services\UserStatisticsService;
use Modules\User\Http\Controllers\UserTrait;

class HomeStatisticsController  extends CatchController
{
    use UserTrait;
    public  function  statistics(Request $request)
    {
        $userContext = $this->getUserContext(null);
        $type = 1;
        if( $userContext['loginUserRoles']->contains('company')){
            $type = 2;
        }else if ($userContext['loginUserRoles']->contains('optimizer')){
            $type = 3;
        }
        $uid = $this->getLoginUserId();
        $miniProgramId = $request->input('miniprogram_id',0);

        return UserStatisticsService::getTodayHomeData($uid,$type,$miniProgramId);
    }

}
