87 lines
2.4 KiB
PHP
87 lines
2.4 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @author Any
|
|
* @description KISS
|
|
* @date 2020-11-5
|
|
* @version 1.0.0
|
|
*
|
|
* _____LOG_____
|
|
*
|
|
*/
|
|
|
|
namespace app\modules\admin\models\store;
|
|
|
|
use app\components\EncryptHelper;
|
|
use app\models\Admin;
|
|
use app\models\auth\RoleUser;
|
|
use app\models\Box;
|
|
use app\models\common\CommonUserEditForm;
|
|
use app\models\Goods;
|
|
use app\models\GoodsHub;
|
|
use app\models\Store;
|
|
use app\models\StoreBj;
|
|
use app\models\StoreUser;
|
|
use app\models\SysAdmin;
|
|
use app\models\User;
|
|
use app\modules\admin\models\AdminModel;
|
|
use yii\data\Pagination;
|
|
|
|
class BoxListForm extends AdminModel
|
|
{
|
|
|
|
public $page;
|
|
public $limit;
|
|
|
|
public $keywords;
|
|
public $status;
|
|
|
|
public $store_id;
|
|
|
|
public function rules()
|
|
{
|
|
return [
|
|
[['keywords',], 'trim'],
|
|
[['keywords',], 'string'],
|
|
[['page', 'limit', 'status', 'province_id', 'city_id', 'area_id'], 'integer'],
|
|
[['page'], 'default', 'value' => 1],
|
|
[['limit'], 'default', 'value' => 20],
|
|
];
|
|
}
|
|
|
|
|
|
public function search()
|
|
{
|
|
$query = Box::find()->alias('b')
|
|
->leftJoin(['goods' => Goods::tableName()], 'b.goods_id=goods.id')
|
|
->leftJoin(['goodHub' => GoodsHub::tableName()], 'goods.goods_hub_id=goodHub.id')
|
|
->leftJoin(['storeBj' => StoreBj::tableName()], 'b.bj_id=storeBj.id')
|
|
->select('b.id,b.created_at,b.status,goodHub.name as goods_name,storeBj.name as bj_name,b.sort')
|
|
->where([
|
|
'b.is_delete' => 0
|
|
])
|
|
->andFilterWhere(['b.status' => $this->status])
|
|
->andFilterWhere(['goodHub.name' => $this->keywords]);
|
|
|
|
$count = $query->count();
|
|
$pagination = new Pagination(['totalCount' => $count, 'pageSize' => $this->limit]);
|
|
$list = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['b.sort'=>SORT_DESC,'b.id' => SORT_DESC])->asArray()->all();
|
|
foreach ($list as $index => $item) {
|
|
// $item['business'] = $item['begin_time'] . '-' . $item['end_time'];
|
|
$item['created_at_cn'] = date("Y-m-d H:i", $item['created_at']);
|
|
|
|
// $item['device'] = json_decode($item['device'], true);
|
|
$list[$index] = $item;
|
|
}
|
|
$data = [];
|
|
$data['code'] = 0;
|
|
$data['msg'] = 'ok';
|
|
$data['data'] = $list;
|
|
$data['count'] = $count;
|
|
return $data;
|
|
|
|
|
|
}
|
|
|
|
|
|
} |