95 lines
2.4 KiB
PHP
95 lines
2.4 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @author Any
|
|
* @description KISS
|
|
* @date 2020-11-5
|
|
* @version 1.0.0
|
|
*
|
|
* _____LOG_____
|
|
*
|
|
*/
|
|
|
|
namespace app\modules\store\models\dev;
|
|
|
|
use app\components\EncryptHelper;
|
|
use app\components\Utils;
|
|
use app\models\Dev;
|
|
use app\models\District;
|
|
use app\models\Model;
|
|
use app\models\Report;
|
|
use app\models\Store;
|
|
use app\models\StoreUser;
|
|
use app\models\User;
|
|
use app\modules\store\models\AdminModel;
|
|
use app\models\common\CommonUserEditForm;
|
|
use yii\data\Pagination;
|
|
|
|
class DevtListForm extends AdminModel
|
|
{
|
|
public $page;
|
|
public $limit;
|
|
|
|
public $keywords;
|
|
public $status;
|
|
public $store_id;
|
|
|
|
|
|
public function rules()
|
|
{
|
|
return [
|
|
[['keywords',], 'trim'],
|
|
[['keywords',], 'string'],
|
|
[['page', 'limit'], 'integer'],
|
|
[['page'], 'default', 'value' => 1],
|
|
[['limit'], 'default', 'value' => 20],
|
|
];
|
|
}
|
|
|
|
public function search()
|
|
{
|
|
if (!$this->validate()) {
|
|
return $this->getModelError();
|
|
}
|
|
|
|
$where = ['o.store_id' => $this->store_id];
|
|
if (!empty($this->times)) {
|
|
$explode = explode(' - ', $this->times);
|
|
$where = [
|
|
'and',
|
|
['>=', 'o.created_at', strtotime($explode[0])],
|
|
['<=', 'o.created_at', strtotime($explode[1])],
|
|
];
|
|
}
|
|
|
|
$query = Dev::find()->alias('o')
|
|
->select('o.id,o.name,o.dev_number,o.created_at,o.status,s.name as store_name')
|
|
->leftJoin(['s' => Store::tableName()], 'o.store_id=s.id')
|
|
->where([
|
|
|
|
])->andWhere($where)
|
|
->andFilterWhere([
|
|
'OR',
|
|
['like', 'o.name', $this->keywords],
|
|
['like', 'o.dev_numbe', $this->keywords],
|
|
]);
|
|
|
|
|
|
$count = $query->count();
|
|
$pagination = new Pagination(['totalCount' => $count, 'pageSize' => $this->limit]);
|
|
$list = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['o.created_at' => SORT_DESC])->asArray()->all();
|
|
foreach ($list as $index => $item) {
|
|
$item['created_at_cn'] = date("Y-m-d H:i", $item['created_at']);
|
|
$list[$index] = $item;
|
|
}
|
|
$data = [];
|
|
$data['code'] = 0;
|
|
$data['msg'] = 'ok';
|
|
$data['data'] = $list;
|
|
$data['count'] = $count;
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
|
} |