* @day: 2017/11/11 */ namespace app\admin\model\store; use app\admin\model\user\User; use crmeb\traits\ModelTrait; use crmeb\basic\BaseModel; /** * Class StoreCategory * @package app\admin\model\store */ class ProductCode extends BaseModel { /** * 数据表主键 * @var string */ protected $pk = 'id'; /** * 模型名称 * @var string */ protected $name = 'product_code'; use ModelTrait; protected $autoWriteTimestamp = true; public static function list($where) { $model = self::alias('a') ->field('a.*,b.nickname') ->leftJoin('user b', 'a.uid = b.uid') ->where('a.product_id', $where['id']) ->order('id DESC'); if ($where['bd'] == 1) $model->where('a.uid' , '=', 0); if ($where['bd'] == 2) $model->where('a.uid' , '>', 0); $data['count'] = $model->count(); if ($where['page'] && $where['limit']){ $model->page($where['page'], $where['limit']); }else{ $model->page(20, 1); } $list = $model->select()->toArray(); foreach ($list as &$item){ if (empty($item['nickname'])){ $item['nickname'] = '未绑定'; } if (empty($item['end_time'])){ $item['end_time'] = '未使用'; }else{ $item['end_time'] = date('Y-m-d H:i:s', $item['end_time']); } } $data['data'] = $list; return $data; } }