|
@@ -13,6 +13,8 @@ use App\Enums\Common\Code; |
|
@@ -13,6 +13,8 @@ use App\Enums\Common\Code; |
|
13
|
use App\Http\Controllers\Bside\BaseController;
|
13
|
use App\Http\Controllers\Bside\BaseController;
|
|
14
|
use App\Http\Logic\Bside\Setting\WebSettingLogic;
|
14
|
use App\Http\Logic\Bside\Setting\WebSettingLogic;
|
|
15
|
use App\Models\Com\UpdateNotify;
|
15
|
use App\Models\Com\UpdateNotify;
|
|
|
|
16
|
+use App\Models\Com\UpdateProgress;
|
|
|
|
17
|
+use App\Models\RouteMap\RouteMap;
|
|
16
|
use Illuminate\Http\Request;
|
18
|
use Illuminate\Http\Request;
|
|
17
|
|
19
|
|
|
18
|
class CNoticeController extends BaseController
|
20
|
class CNoticeController extends BaseController
|
|
@@ -22,7 +24,7 @@ class CNoticeController extends BaseController |
|
@@ -22,7 +24,7 @@ class CNoticeController extends BaseController |
|
22
|
* @param Request $request
|
24
|
* @param Request $request
|
|
23
|
* @param WebSettingLogic $webSettingLogic
|
25
|
* @param WebSettingLogic $webSettingLogic
|
|
24
|
*/
|
26
|
*/
|
|
25
|
- public function sendNotify(WebSettingLogic $webSettingLogic){
|
27
|
+ public function sendNotify(){
|
|
26
|
$type = $this->request->input('type', UpdateNotify::TYPE_MASTER);
|
28
|
$type = $this->request->input('type', UpdateNotify::TYPE_MASTER);
|
|
27
|
if (FALSE == in_array($type, [UpdateNotify::TYPE_MASTER, UpdateNotify::TYPE_MINOR])){
|
29
|
if (FALSE == in_array($type, [UpdateNotify::TYPE_MASTER, UpdateNotify::TYPE_MINOR])){
|
|
28
|
$this->response('非法参数!', Code::USER_ERROR);
|
30
|
$this->response('非法参数!', Code::USER_ERROR);
|
|
@@ -31,10 +33,67 @@ class CNoticeController extends BaseController |
|
@@ -31,10 +33,67 @@ class CNoticeController extends BaseController |
|
31
|
if (FALSE == in_array($type, [UpdateNotify::PAGE_ALL, UpdateNotify::PAGE_SINGLE])){
|
33
|
if (FALSE == in_array($type, [UpdateNotify::PAGE_ALL, UpdateNotify::PAGE_SINGLE])){
|
|
32
|
$this->response('非法参数!', Code::USER_ERROR);
|
34
|
$this->response('非法参数!', Code::USER_ERROR);
|
|
33
|
}
|
35
|
}
|
|
34
|
- $list = $webSettingLogic->sendNotifyMessage($type,$page);
|
36
|
+ $list = $this->sendNotifyMessage($type,$page);
|
|
35
|
if(!empty($list)){
|
37
|
if(!empty($list)){
|
|
36
|
$this->response('当前页面正在生成了,请完成后再点击',Code::USER_ERROR,$list);
|
38
|
$this->response('当前页面正在生成了,请完成后再点击',Code::USER_ERROR,$list);
|
|
37
|
}
|
39
|
}
|
|
38
|
$this->response('success');
|
40
|
$this->response('success');
|
|
39
|
}
|
41
|
}
|
|
|
|
42
|
+
|
|
|
|
43
|
+ /**
|
|
|
|
44
|
+ * 通知c端
|
|
|
|
45
|
+ * @param string $type
|
|
|
|
46
|
+ * @return array
|
|
|
|
47
|
+ */
|
|
|
|
48
|
+ public function sendNotifyMessage($type,$page){
|
|
|
|
49
|
+ $updateProgressModel = new UpdateProgress();
|
|
|
|
50
|
+ $progressInfo = $updateProgressModel->formatQuery(['project_id'=>$this->user['project_id'],'type'=>$type])->orderBy('id','desc')->first();
|
|
|
|
51
|
+ if((!empty($progressInfo))){
|
|
|
|
52
|
+ $progressInfo = $progressInfo->toArray();
|
|
|
|
53
|
+ if(($progressInfo['total_num'] > $progressInfo['current_num'])){
|
|
|
|
54
|
+ return $this->success($progressInfo);
|
|
|
|
55
|
+ }
|
|
|
|
56
|
+ }
|
|
|
|
57
|
+ $updateNotifyModel = new UpdateNotify();
|
|
|
|
58
|
+ $field = ($type == UpdateNotify::TYPE_MINOR) ? 'minor_languages_status' : 'status';
|
|
|
|
59
|
+ if($page == UpdateNotify::PAGE_ALL){
|
|
|
|
60
|
+ //如果是更新所有
|
|
|
|
61
|
+ $routeMapModel = new RouteMap();
|
|
|
|
62
|
+ $count = $routeMapModel->formatQuery(['project_id'=>$this->user['project_id']])->count();
|
|
|
|
63
|
+ }else{
|
|
|
|
64
|
+ $count = $updateNotifyModel->formatQuery(['project_id' => $this->user['project_id'], $field => 0])->count();
|
|
|
|
65
|
+ }
|
|
|
|
66
|
+ if($count == 0){
|
|
|
|
67
|
+ return $this->success();
|
|
|
|
68
|
+ }
|
|
|
|
69
|
+ $this->addProgress($count,$type);
|
|
|
|
70
|
+ $updateNotifyModel->edit([$field => 1], ['project_id' => $this->user['project_id'], $field => 0]);
|
|
|
|
71
|
+ $urlStr = $this->getString($type,$page);
|
|
|
|
72
|
+ $this->curlGet($urlStr);
|
|
|
|
73
|
+ return $this->success();
|
|
|
|
74
|
+ }
|
|
|
|
75
|
+
|
|
|
|
76
|
+ /**
|
|
|
|
77
|
+ * @remark :curl请求
|
|
|
|
78
|
+ * @name :curlGet
|
|
|
|
79
|
+ * @author :lyh
|
|
|
|
80
|
+ * @method :post
|
|
|
|
81
|
+ * @time :2023/9/12 10:10
|
|
|
|
82
|
+ */
|
|
|
|
83
|
+ public function curlGet($url){
|
|
|
|
84
|
+ $curl = curl_init();
|
|
|
|
85
|
+ curl_setopt_array($curl, array(
|
|
|
|
86
|
+ CURLOPT_URL => $url,
|
|
|
|
87
|
+ CURLOPT_RETURNTRANSFER => true,
|
|
|
|
88
|
+ CURLOPT_ENCODING => '',
|
|
|
|
89
|
+ CURLOPT_MAXREDIRS => 10,
|
|
|
|
90
|
+ CURLOPT_TIMEOUT => 0,
|
|
|
|
91
|
+ CURLOPT_FOLLOWLOCATION => true,
|
|
|
|
92
|
+ CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
|
|
|
93
|
+ CURLOPT_CUSTOMREQUEST => 'GET',
|
|
|
|
94
|
+ ));
|
|
|
|
95
|
+ $response = curl_exec($curl);
|
|
|
|
96
|
+ curl_close($curl);
|
|
|
|
97
|
+ return $response;
|
|
|
|
98
|
+ }
|
|
40
|
} |
99
|
} |