|
...
|
...
|
@@ -13,6 +13,8 @@ use App\Enums\Common\Code; |
|
|
|
use App\Http\Controllers\Bside\BaseController;
|
|
|
|
use App\Http\Logic\Bside\Setting\WebSettingLogic;
|
|
|
|
use App\Models\Com\UpdateNotify;
|
|
|
|
use App\Models\Com\UpdateProgress;
|
|
|
|
use App\Models\RouteMap\RouteMap;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
class CNoticeController extends BaseController
|
|
...
|
...
|
@@ -22,7 +24,7 @@ class CNoticeController extends BaseController |
|
|
|
* @param Request $request
|
|
|
|
* @param WebSettingLogic $webSettingLogic
|
|
|
|
*/
|
|
|
|
public function sendNotify(WebSettingLogic $webSettingLogic){
|
|
|
|
public function sendNotify(){
|
|
|
|
$type = $this->request->input('type', UpdateNotify::TYPE_MASTER);
|
|
|
|
if (FALSE == in_array($type, [UpdateNotify::TYPE_MASTER, UpdateNotify::TYPE_MINOR])){
|
|
|
|
$this->response('非法参数!', Code::USER_ERROR);
|
|
...
|
...
|
@@ -31,10 +33,67 @@ class CNoticeController extends BaseController |
|
|
|
if (FALSE == in_array($type, [UpdateNotify::PAGE_ALL, UpdateNotify::PAGE_SINGLE])){
|
|
|
|
$this->response('非法参数!', Code::USER_ERROR);
|
|
|
|
}
|
|
|
|
$list = $webSettingLogic->sendNotifyMessage($type,$page);
|
|
|
|
$list = $this->sendNotifyMessage($type,$page);
|
|
|
|
if(!empty($list)){
|
|
|
|
$this->response('当前页面正在生成了,请完成后再点击',Code::USER_ERROR,$list);
|
|
|
|
}
|
|
|
|
$this->response('success');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 通知c端
|
|
|
|
* @param string $type
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function sendNotifyMessage($type,$page){
|
|
|
|
$updateProgressModel = new UpdateProgress();
|
|
|
|
$progressInfo = $updateProgressModel->formatQuery(['project_id'=>$this->user['project_id'],'type'=>$type])->orderBy('id','desc')->first();
|
|
|
|
if((!empty($progressInfo))){
|
|
|
|
$progressInfo = $progressInfo->toArray();
|
|
|
|
if(($progressInfo['total_num'] > $progressInfo['current_num'])){
|
|
|
|
return $this->success($progressInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$updateNotifyModel = new UpdateNotify();
|
|
|
|
$field = ($type == UpdateNotify::TYPE_MINOR) ? 'minor_languages_status' : 'status';
|
|
|
|
if($page == UpdateNotify::PAGE_ALL){
|
|
|
|
//如果是更新所有
|
|
|
|
$routeMapModel = new RouteMap();
|
|
|
|
$count = $routeMapModel->formatQuery(['project_id'=>$this->user['project_id']])->count();
|
|
|
|
}else{
|
|
|
|
$count = $updateNotifyModel->formatQuery(['project_id' => $this->user['project_id'], $field => 0])->count();
|
|
|
|
}
|
|
|
|
if($count == 0){
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
$this->addProgress($count,$type);
|
|
|
|
$updateNotifyModel->edit([$field => 1], ['project_id' => $this->user['project_id'], $field => 0]);
|
|
|
|
$urlStr = $this->getString($type,$page);
|
|
|
|
$this->curlGet($urlStr);
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :curl请求
|
|
|
|
* @name :curlGet
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/9/12 10:10
|
|
|
|
*/
|
|
|
|
public function curlGet($url){
|
|
|
|
$curl = curl_init();
|
|
|
|
curl_setopt_array($curl, array(
|
|
|
|
CURLOPT_URL => $url,
|
|
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
|
|
CURLOPT_ENCODING => '',
|
|
|
|
CURLOPT_MAXREDIRS => 10,
|
|
|
|
CURLOPT_TIMEOUT => 0,
|
|
|
|
CURLOPT_FOLLOWLOCATION => true,
|
|
|
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
|
|
|
CURLOPT_CUSTOMREQUEST => 'GET',
|
|
|
|
));
|
|
|
|
$response = curl_exec($curl);
|
|
|
|
curl_close($curl);
|
|
|
|
return $response;
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|