RatingLogic.php
2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
/**
* @remark :
* @name :RatingLogic.php
* @author :lyh
* @method :post
* @time :2024/1/20 14:15
*/
namespace App\Http\Logic\Bside\Scoring;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Scoring\RatingQuestion;
use App\Models\Scoring\ScoringSystem;
use App\Models\User\User;
use AWS\CRT\Log;
class RatingLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->model = new RatingQuestion();
$this->scoringModel = new ScoringSystem();
$this->param = $this->requestAll;
}
/**
* @remark :获取详情
* @name :getRatingRead
* @author :lyh
* @method :post
* @time :2024/1/20 14:27
*/
public function getRatingRead(){
$data = [
'company'=>$this->project['company'],
'mobile'=>$this->user['mobile'],
'uptime'=>$this->project['uptime'],
'domain'=>$this->user['domain'],
'question'=>$this->model->list(['type'=>$this->param['type']]),
'project_id'=>$this->user['project_id']
];
return $this->success($data);
}
/**
* @remark :提交统计
* @name :ratingSave
* @author :lyh
* @method :post
* @time :2024/1/20 14:46
*/
public function ratingSave(){
$param = [
'data'=>json_encode($this->param['data']),
'mobile'=>$this->param['mobile'],
'project_id'=>$this->user['project_id'],
'type'=>$this->param['type']
];
$this->scoringModel->add($param);
return $this->httpSore($this->param['data'],$this->project['id'],$this->param['type']);
}
/**
* @remark :同步数据
* @name :httpSore
* @author :lyh
* @method :post
* @time :2024/1/24 15:04
*/
public function httpSore($data,$postId,$fType){
$fType = (int)($fType + 1);
$token = md5('qqs'.$postId.$fType.date("Y-m-d"));
//$ftype 2,3,4
$str = '';
foreach ($data as $k => $v){
$str .= 'name_'.(int)($k+1).'='.($v['level'] ?? 5).'&';
}
$str = trim($str,'&');
$url = "http://www.quanqiusou.cn/extend_api/api/service_score.php?postid=$postId&token=$token&ftype=$fType&$str";
$rs = http_get($url,['charset=utf-8']);
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($url, true) . PHP_EOL, FILE_APPEND);
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($rs, true) . PHP_EOL, FILE_APPEND);
return $rs;
}
}