作者 lyh

gx

... ... @@ -28,53 +28,7 @@ use Mrgoon\AliSms\AliSms;
*/
class RatingController extends BaseController
{
/**
* @remark :获取问卷调查记录(阶段记录)
* @name :getHistory
* @author :lyh
* @method :post
* @time :2024/1/20 15:03
*/
public function getHistory(ScoringSystem $scoringSystem){
$projectInfo = Cache::get('user-'.$this->user['project_id']);
if(!$projectInfo){
$this->response('success',Code::SUCCESS,['type'=>0]);
}
//建站中直接返回
if($projectInfo['type'] == 1){
$this->response('success',Code::SUCCESS,['type'=>0]);
}
//上线项目判断当前属于第几阶段
if(empty($projectInfo['uptime'])){
$this->response('success',Code::SUCCESS,['type'=>0]);
}
//获取上线时间30天后
$after30Days = date('Y-m-d H:i:s', strtotime($projectInfo['uptime'] . ' +30 days'));
$afterThreeMonths = date('Y-m-d H:i:s', strtotime($projectInfo['uptime'] . ' +3 months'));
$afterSixMonths = date('Y-m-d H:i:s', strtotime($projectInfo['uptime'] . ' +6 months'));
$afterOneYear = date('Y-m-d H:i:s', strtotime($projectInfo['uptime'] . ' +1 year'));
//获取当前时间
$date = date('Y-m-d H:i:s');
if($date <= $after30Days){
$info = $scoringSystem->read(['type'=>1]);//第一阶段是否有值
if($info === false){
$this->response('success',Code::SUCCESS,['type'=>1]);
}
}
if($date >= $afterThreeMonths && $date <= $afterSixMonths){
$info = $scoringSystem->read(['type'=>2]);//第一阶段是否有值
if($info === false){
$this->response('success',Code::SUCCESS,['type'=>2]);
}
}
if($date >= $afterOneYear){
$info = $scoringSystem->read(['type'=>3]);//第一阶段是否有值
if($info === false){
$this->response('success',Code::SUCCESS,['type'=>3]);
}
}
$this->response('success',Code::SUCCESS,['type'=>0]);
}
/**
* @remark :问卷调查详情
* @name :getProjectRead
... ...
... ... @@ -78,6 +78,7 @@ class RatingLogic extends BaseLogic
$str = trim($str,'&');
$url = "http://www.quanqiusou.cn/extend_api/api/service_score.php?postid=$postId&token=$token&ftype=$fType&$str";
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($url, true) . PHP_EOL, FILE_APPEND);
return http_get($url,['charset=utf-8']);
dd();
// return http_get($url,['charset=utf-8']);
}
}
... ...
... ... @@ -8,6 +8,7 @@ use App\Exceptions\BsideGlobalException;
use App\Helper\Common;
use App\Models\Domain\DomainInfo;
use App\Models\Project\Project;
use App\Models\Scoring\ScoringSystem;
use App\Models\Sms\SmsLog;
use App\Models\User\ProjectRole as ProjectRoleModel;
use App\Models\User\User;
... ... @@ -170,7 +171,7 @@ class UserLoginLogic
$info['upload_config'] = $project['upload_config'];
$info['main_lang_id'] = $project['main_lang_id'];
$info['image_max'] = $project['image_max'];
$info['uptime'] = $project['uptime'];
$info['uptime_type'] = $this->getHistory($project);
$info['storage_type'] = $project['storage_type'];
$info['project_location'] = $project['project_location'];
$info['is_update_language'] = $project['is_update_language'];
... ... @@ -180,10 +181,57 @@ class UserLoginLogic
$info['is_visualization'] = json_decode($project['is_visualization']);
}
//保存项目缓存
Cache::put('user-'.$info['project_id'],$project,$minutes = null);
Cache::put('user-'.$info['project_id'],$project,12 * 3600);
return $this->success($info);
}
/**
* @remark :获取问卷调查记录(阶段记录)
* @name :getHistory
* @author :lyh
* @method :post
* @time :2024/1/20 15:03
*/
public function getHistory($projectInfo){
if(!$projectInfo){
return $this->success(0);
}
//建站中直接返回
if($projectInfo['type'] == 1){
return $this->success(0);
}
//上线项目判断当前属于第几阶段
if(empty($projectInfo['uptime'])){
return $this->success(0);
}
//获取上线时间30天后
$after30Days = date('Y-m-d H:i:s', strtotime($projectInfo['uptime'] . ' +30 days'));
$afterThreeMonths = date('Y-m-d H:i:s', strtotime($projectInfo['uptime'] . ' +3 months'));
$afterSixMonths = date('Y-m-d H:i:s', strtotime($projectInfo['uptime'] . ' +6 months'));
$afterOneYear = date('Y-m-d H:i:s', strtotime($projectInfo['uptime'] . ' +1 year'));
//获取当前时间
$date = date('Y-m-d H:i:s');
$scoringSystem = new ScoringSystem();
if($date <= $after30Days){
$info = $scoringSystem->read(['type'=>1]);//第一阶段是否有值
if($info === false){
return $this->success(1);
}
}
if($date >= $afterThreeMonths && $date <= $afterSixMonths){
$info = $scoringSystem->read(['type'=>2]);//第一阶段是否有值
if($info === false){
return $this->success(2);
}
}
if($date >= $afterOneYear){
$info = $scoringSystem->read(['type'=>3]);//第一阶段是否有值
if($info === false){
return $this->success(3);
}
}
return $this->success(0);
}
/**
* @remark :组装返回数据
... ... @@ -212,7 +260,7 @@ class UserLoginLogic
$info['upload_config'] = $project['upload_config'];
$info['main_lang_id'] = $project['main_lang_id'];
$info['image_max'] = $project['image_max'];
$info['uptime'] = $project['uptime'];
$info['uptime_type'] = $this->getHistory($project);
$info['is_update_language'] = $project['is_update_language'];
$info['configuration'] = $project['deploy_build']['configuration'];
$info['project_type'] = $project['type'];
... ... @@ -222,7 +270,7 @@ class UserLoginLogic
$info['is_visualization'] = json_decode($project['is_visualization']);
}
//保存项目缓存
Cache::put('user-'.$info['project_id'],$project,$minutes = null);
Cache::put('user-'.$info['project_id'],$project,12 * 3600);
return $this->success($info);
}
... ...
... ... @@ -484,7 +484,6 @@ Route::middleware(['bloginauth'])->group(function () {
Route::prefix('rating')->group(function () {
Route::any('/read', [\App\Http\Controllers\Bside\Scoring\RatingController::class, 'getProjectRead'])->name('rating_getProjectRead');
Route::any('/save', [\App\Http\Controllers\Bside\Scoring\RatingController::class, 'save'])->name('rating_save');
Route::any('/getHistory', [\App\Http\Controllers\Bside\Scoring\RatingController::class, 'getHistory'])->name('rating_getHistory');
Route::any('/code', [\App\Http\Controllers\Bside\Scoring\RatingController::class, 'verificationCode'])->name('rating_code');
});
});
... ...