147 lines
3.6 KiB
PHP
147 lines
3.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'],
|
|
[['status',], 'string'],
|
|
[['page', 'limit'], '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, 'page' => $this->page - 1]);
|
|
$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
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @catalog 数据列表
|
|
* @title 获取详情
|
|
* @description 数据列表-获取详情
|
|
*/
|
|
public function actionGetInfo(){
|
|
if(empty($id)){
|
|
return $this->apiReturnError('请求错误');
|
|
}
|
|
$find = Report::findOne([
|
|
'id' => $this->id,
|
|
]);
|
|
if(empty($find)){
|
|
return $this->apiReturnError('暂无数据');
|
|
}
|
|
if(intval($find->step) !== 3){
|
|
return $this->apiReturnError('暂未生成结果');
|
|
}
|
|
$json_de = [];
|
|
if(!empty($find->json)){
|
|
$json_de = json_decode($find->json,true);
|
|
}
|
|
$res = $json_de??[];
|
|
$find_store = Store::findOne([
|
|
'id' => $find->store_id,
|
|
]);
|
|
$res['store'] = [
|
|
'id' => $find->store_id,
|
|
'name' => $find_store->name??'暂无门店',
|
|
];
|
|
$res['created_date'] = date('Y-m-d H:i:s',$find->created_at);
|
|
return $this->apiReturnSuccess('ok',$res);
|
|
}
|
|
|
|
|
|
} |