84 lines
2.6 KiB
PHP
84 lines
2.6 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @author Any
|
|
* @description KISS
|
|
* @date 2020-11-23
|
|
* @version 1.0.0
|
|
*
|
|
* _____LOG_____
|
|
*
|
|
*/
|
|
namespace app\modules\admin\models;
|
|
|
|
use app\models\Banner;
|
|
use yii\data\Pagination;
|
|
|
|
|
|
class SlideListForm extends AdminModel
|
|
{
|
|
public $zone_id;
|
|
public $cx_mch_id;
|
|
|
|
public $page;
|
|
public $limit;
|
|
public $keywords;
|
|
|
|
|
|
public function rules()
|
|
{
|
|
return [
|
|
[['cx_mch_id', 'zone_id'], 'required'],
|
|
[['keywords'], 'trim'],
|
|
[['cx_mch_id', 'zone_id'], 'integer'],
|
|
[['page'], 'default', 'value' => 1],
|
|
[['limit'], 'default', 'value' => 20],
|
|
];
|
|
}
|
|
|
|
public function search($id,$type='in')
|
|
{
|
|
if(!$this->validate()){
|
|
$pagination = new Pagination([
|
|
"totalCount" => 0,
|
|
"pageSize" => $this->limit
|
|
]);
|
|
return [
|
|
'list' => [],
|
|
'paginaiton' => $pagination
|
|
];
|
|
}
|
|
$query = Banner::find()
|
|
->where([
|
|
'zone_id' => $this->zone_id,
|
|
"is_delete" => 0,
|
|
'cx_mch_id' => $this->cx_mch_id
|
|
])->andWhere([
|
|
$type,'id',$id
|
|
])
|
|
->select('id,url_type,app_id,app_ext,img_url,title,page_url,sort,created_at,status,media,video_url');
|
|
$count = $query->count();
|
|
$pagination = new Pagination([
|
|
"totalCount" => $count,
|
|
"pageSize" => $this->limit
|
|
]);
|
|
$list = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(["sort" => SORT_ASC, "created_at" => SORT_DESC])->asArray()->all();
|
|
foreach ($list as $index => $item){
|
|
$item["url_type_cn"] = Banner::getUrlType($item['url_type']);
|
|
$item['app_id'] = $item['app_id'] == null ? '--' : $item['app_id'];
|
|
$item['title'] = $item['title'] == null ? '--' : $item['title'];
|
|
$item['page_url'] = $item['page_url'] == null ? '--' : $item['page_url'];
|
|
$item['created_at_cn'] = date('Y-m-d H:i:s',$item['created_at']);
|
|
$item['status_cn'] = Banner::getStatus($item['status']);
|
|
$item['media_cn'] = Banner::getMedia($item['media']);
|
|
if(in_array($item['id'],$id)){
|
|
$item['status'] = -1;
|
|
}
|
|
$list[$index] = $item;
|
|
}
|
|
return [
|
|
'list' => $list,
|
|
'pagination' => $pagination
|
|
];
|
|
}
|
|
} |