70 lines
2.0 KiB
PHP
70 lines
2.0 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @author Any
|
|
* @description KISS
|
|
* @date 2021年9月28日
|
|
* @version 1.0.0
|
|
*
|
|
* _____LOG_____
|
|
*
|
|
*/
|
|
namespace app\modules\admin\models\card;
|
|
|
|
use app\components\EncryptHelper;
|
|
use app\models\CardBank;
|
|
use app\models\CardUnion;
|
|
use app\models\Model;
|
|
use app\models\Store;
|
|
use yii\data\Pagination;
|
|
|
|
class CardUnionListForm extends Model
|
|
{
|
|
public $page;
|
|
public $limit;
|
|
|
|
public $keywords;
|
|
public $status;
|
|
public $store_id;
|
|
|
|
public function rules()
|
|
{
|
|
return [
|
|
[['keywords',], 'trim'],
|
|
[['keywords',], 'string'],
|
|
[['page', 'limit','status','store_id'], 'integer'],
|
|
[['page'], 'default', 'value' => 1],
|
|
[['limit'], 'default', 'value' => 20],
|
|
];
|
|
}
|
|
|
|
public function search()
|
|
{
|
|
$query = CardUnion::find()->alias('cu')
|
|
->select('cu.id,cu.card_number,cu.name,cu.mobile_phone,cu.status,cb.name as bank_name')
|
|
->leftJoin(['cb' => CardBank::tableName()],'cu.bank_id=cb.id')
|
|
->where(['cu.is_delete' => 0])
|
|
->andFilterWhere([
|
|
'OR',
|
|
['like','cu.card_number',$this->keywords],
|
|
['like','cu.name',$this->keywords],
|
|
['like','cu.mobile_phone',$this->keywords],
|
|
['like','cb.name',$this->keywords],
|
|
]);
|
|
|
|
$count = $query->count();
|
|
$pagination = new Pagination(['totalCount' => $count, 'pageSize' => $this->limit]);
|
|
$list = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['cu.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;
|
|
}
|
|
|
|
} |