112 lines
2.6 KiB
PHP
112 lines
2.6 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @author Any
|
|
* @description KISS
|
|
* @date 2020-12-2
|
|
* @version 1.0.0
|
|
*
|
|
* _____LOG_____
|
|
*
|
|
*/
|
|
|
|
namespace app\modules\api\models;
|
|
|
|
use function AlibabaCloud\Client\value;
|
|
use app\components\FlashStorage;
|
|
use app\components\SiteHelper;
|
|
use app\models\BallMark;
|
|
use app\models\Coach;
|
|
use app\models\DeviceUniqueBindUser;
|
|
use app\models\Report;
|
|
use app\models\Store;
|
|
use app\models\User;
|
|
use app\components\auth\AToken;
|
|
use app\components\EncryptHelper;
|
|
use app\modules\api\components\ApiHelper;
|
|
use app\modules\api\components\GetDistance;
|
|
use yii\data\Pagination;
|
|
|
|
|
|
class ReportForm extends ApiModel
|
|
{
|
|
|
|
public $page;
|
|
public $limit;
|
|
|
|
public $keywords;
|
|
public $status;
|
|
|
|
public $user_id;
|
|
public $cx_mch_id;
|
|
|
|
public function rules()
|
|
{
|
|
return [
|
|
[['keywords',], 'trim'],
|
|
[['keywords',], 'string'],
|
|
[['page', 'limit', 'status'], 'integer'],
|
|
[['page'], 'default', 'value' => 1],
|
|
[['limit'], 'default', 'value' => 20],
|
|
];
|
|
}
|
|
|
|
|
|
/**
|
|
* 型号列表
|
|
*/
|
|
public function search()
|
|
{
|
|
if (!$this->validate()) {
|
|
return $this->getModelError();
|
|
}
|
|
|
|
//未完成
|
|
if ($this->status == 1) {
|
|
$status = [0, 1, 2];
|
|
}
|
|
//完成
|
|
if ($this->status == 2) {
|
|
$status = [3];
|
|
}
|
|
|
|
$query = Report::find()
|
|
->select('id,model_number,pdf_path,pdf_at,step')
|
|
->where([
|
|
'user_id' => $this->user_id
|
|
])->andFilterWhere([
|
|
'in', 'step', $status
|
|
]);
|
|
|
|
$count = $query->count();
|
|
$pagination = new Pagination(['totalCount' => $count, 'pageSize' => $this->limit]);
|
|
$list = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['id' => SORT_DESC])->asArray()->all();
|
|
|
|
foreach ($list as $key => $value) {
|
|
$value['pdf_at_cn'] = '';
|
|
if (!empty($value['pdf_at'])) {
|
|
$value['pdf_at_cn'] = date('Y-m-d H:i:s', $value['pdf_at']);
|
|
}
|
|
|
|
$value['pdf_path'] = SiteHelper::getFullUrl($value['pdf_path']);
|
|
|
|
$list[$key] = $value;
|
|
}
|
|
|
|
|
|
$end_flag = $this->page > $pagination->pageCount ? true : false;
|
|
|
|
return [
|
|
'code' => 0,
|
|
'msg' => 'ok',
|
|
'data' => $list,
|
|
'count' => $count,
|
|
'page_size' => $this->limit,
|
|
'page_count' => $pagination->pageCount,
|
|
'page_no' => $this->page,
|
|
'end_flag' => $end_flag
|
|
];
|
|
}
|
|
|
|
|
|
} |