1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- /**
- * @author: xaboy<365615158@qq.com>
- * @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;
- }
- }
|