<?php


namespace app\api\controller\incentivead;

use app\api\controller\Base;
use think\Db;

class User extends Base
{
    protected $noNeedLogin = ['getList'];
    protected $noNeedRight = ['*'];
    
    public $model = null;
    public function _initialize(){
        parent::_initialize();
        $this->model = new \app\common\model\bbfxshop\Incentivead;
    }

    public function index(){
        $count = Db::name("bbfx_incentivead_view_log")->where(['uniacid'=>UNIACID,'user_id'=>$this->user['id'],'createtime'=>['>',strtotime(date('Y-m-d 00:00:00'))]])->count();
        __success("操作成功",['view_count'=>$count]);
    }

    public function setReward(){
        $result = $this->model->setReward($this->user['id']);
        __result($result);
    }

    public function getViewLogList(){
        $page = max(1,$this->param("page/d"));
        $limit = max(10,$this->param("limit/d"));
        $where = ['a.uniacid'=>UNIACID,'a.user_id'=>$this->user['id']];
        $result = $this->model->getViewLogList($where,$page,$limit);
        __result($result);
    }
}