<?php

namespace app\models\user;

use crmeb\basic\BaseModel;
use crmeb\traits\ModelTrait;


class UserCodeInfo extends BaseModel
{
    /**
     * 数据表主键
     * @var string
     */
    protected $pk = 'id';

    /**
     * 模型名称
     * @var string
     */
    protected $name = 'user_code_goods';

    use ModelTrait;
    public static function lst($where)
    {
        $model = new self;
        $model = $model->alias('a')->join("user b","a.code=b.code and b.code_top=1","left");
        if(trim($where['code'])!='')  $model=$model->where('a.code',$where['code']);
        $model = $model->where('a.goods_stock','<',100);
        $count = $model->count();
        $data = $model->order('goods_stock asc')->page($where['page'],$where['limit'])->field('a.*,b.nickname')->select()->toArray();
        return compact('count','data');
    }




}