作者 zhl

u

@@ -5,6 +5,8 @@ namespace App\Http\Controllers\Bside\Setting; @@ -5,6 +5,8 @@ namespace App\Http\Controllers\Bside\Setting;
5 use App\Enums\Common\Code; 5 use App\Enums\Common\Code;
6 use App\Http\Controllers\Bside\BaseController; 6 use App\Http\Controllers\Bside\BaseController;
7 use App\Http\Logic\Bside\Setting\WebSettingLogic; 7 use App\Http\Logic\Bside\Setting\WebSettingLogic;
  8 +use App\Models\Com\UpdateNotify;
  9 +use Illuminate\Http\Request;
8 10
9 /** 11 /**
10 * @name:项目首页设置 12 * @name:项目首页设置
@@ -34,14 +36,16 @@ class WebSettingController extends BaseController @@ -34,14 +36,16 @@ class WebSettingController extends BaseController
34 } 36 }
35 37
36 /** 38 /**
37 - * @remark :更新通知C端  
38 - * @name :updateNotify  
39 - * @author :lyh  
40 - * @method :post  
41 - * @time :2023/8/1 9:33 39 + * 更新通知C端
  40 + * @param Request $request
  41 + * @param WebSettingLogic $webSettingLogic
42 */ 42 */
43 - public function sendNotify(WebSettingLogic $webSettingLogic){  
44 - $list = $webSettingLogic->sendNotifyMessage(); 43 + public function sendNotify(Request $request, WebSettingLogic $webSettingLogic){
  44 + $type = $request->input('type', UpdateNotify::TYPE_MASTER);
  45 + if (FALSE == in_array($type, [UpdateNotify::TYPE_MASTER, UpdateNotify::TYPE_MINOR]))
  46 + $this->response('非法参数!', Code::USER_ERROR);
  47 +
  48 + $list = $webSettingLogic->sendNotifyMessage($type);
45 if(!empty($list)){ 49 if(!empty($list)){
46 $this->response('当前页面正在生成了,请完成后再点击',Code::USER_ERROR,$list); 50 $this->response('当前页面正在生成了,请完成后再点击',Code::USER_ERROR,$list);
47 } 51 }
@@ -58,21 +58,26 @@ class WebSettingLogic extends BaseLogic @@ -58,21 +58,26 @@ class WebSettingLogic extends BaseLogic
58 } 58 }
59 59
60 /** 60 /**
61 - * @remark :通知c端  
62 - * @name :sendNotifyMessage  
63 - * @author :lyh  
64 - * @method :post  
65 - * @time :2023/8/1 9:36 61 + * 通知c端
  62 + * @param string $type
  63 + * @return array
66 */ 64 */
67 - public function sendNotifyMessage(){ 65 + public function sendNotifyMessage($type = ''){
68 //获取当前项目所有未处理的更新并更换为1:处理中 2:处理完成 66 //获取当前项目所有未处理的更新并更换为1:处理中 2:处理完成
69 $updateNotifyModel = new UpdateNotify(); 67 $updateNotifyModel = new UpdateNotify();
70 - $list = $updateNotifyModel->list(['project_id'=>$this->user['project_id'],'status'=>1]);  
71 - if(!empty($list)){  
72 - return $this->success($list);  
73 - }  
74 - $updateNotifyModel->edit(['status'=>1],['project_id'=>$this->user['project_id'],'status'=>0]);  
75 - $urlStr = 'https://'.$this->user['domain'].'/api/updateHtmlNotify?project_id='.$this->user['project_id']; 68 +// $list = $updateNotifyModel->list(['project_id'=>$this->user['project_id'],'status'=>1]);
  69 +// if(!empty($list)){
  70 +// return $this->success($list);
  71 +// }
  72 + $field = $type == UpdateNotify::TYPE_MINOR ? 'minor_languages_status' : 'status';
  73 + $updateNotifyModel->edit(['status'=>1],['project_id' => $this->user['project_id'], $field => 0]);
  74 + $param = [
  75 + 'project_id' => $this->user['project_id'],
  76 + 'type' => $type,
  77 + 'route' => 'all'
  78 + ];
  79 + $string = http_build_query($param);
  80 + $urlStr = 'https://'.$this->user['domain'].'/api/updateHtmlNotify?' . $string;
76 http_get($urlStr); 81 http_get($urlStr);
77 return $this->success(); 82 return $this->success();
78 } 83 }
@@ -16,4 +16,7 @@ class UpdateNotify extends Base @@ -16,4 +16,7 @@ class UpdateNotify extends Base
16 protected $table = 'gl_update_notify'; 16 protected $table = 'gl_update_notify';
17 //连接数据库 17 //连接数据库
18 protected $connection = 'custom_mysql'; 18 protected $connection = 'custom_mysql';
  19 +
  20 + const TYPE_MASTER = 'master_website';
  21 + const TYPE_MINOR = 'minor_languages';
19 } 22 }