<?php
/*
 本代码由 焕岱科技 创建
 技术支持 WX：15285007200
 严禁反编译、逆向等任何形式的侵权行为，违者将追究法律责任
*/

namespace app\api\controller\salequota;

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


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

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

    public function getList(){
        $page = max(1,$this->param("page/d"));
        $limit = 20;
        $type = $this->param("type/d");

        $where = ["uniacid"=>UNIACID,"user_id"=>$this->user['id'],'type'=>$type];
        $list = Db::name("bbfx_salequota_user_stock_log")->where($where)->order("id desc")->limit(($page-1)*$limit,$limit)->select();

        foreach($list as $key=>&$val){
            $val['createtime'] = date("Y-m-d H:i:s",$val['createtime']);
        }
        unset($val);

        __success("操作成功",['list'=>$list]);
    }
}