作者 lyh

gx

@@ -31,15 +31,6 @@ class DomainInfoController extends BaseController @@ -31,15 +31,6 @@ class DomainInfoController extends BaseController
31 $this->map['domain'] = ['like','%'.$this->map['domain'],'%']; 31 $this->map['domain'] = ['like','%'.$this->map['domain'],'%'];
32 } 32 }
33 $lists = $domainModel->lists($this->map,$this->page,$this->row,$this->order); 33 $lists = $domainModel->lists($this->map,$this->page,$this->row,$this->order);
34 - $projectModel = new Project();  
35 - if(!empty($lists)){  
36 - foreach ($lists['list'] as $k => $v){  
37 - if(!empty($info['project_id'])){  
38 - $v['company'] = $projectModel->read(['id'=>$info['project_id']],['title'])['title'];  
39 - }  
40 - $lists['list'][$k] = $v;  
41 - }  
42 - }  
43 return $this->response('success', Code::SUCCESS, $lists); 34 return $this->response('success', Code::SUCCESS, $lists);
44 } 35 }
45 36
@@ -40,12 +40,16 @@ class WebSettingController extends BaseController @@ -40,12 +40,16 @@ class WebSettingController extends BaseController
40 * @param Request $request 40 * @param Request $request
41 * @param WebSettingLogic $webSettingLogic 41 * @param WebSettingLogic $webSettingLogic
42 */ 42 */
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])) 43 + public function sendNotify(WebSettingLogic $webSettingLogic){
  44 + $type = $this->request->input('type', UpdateNotify::TYPE_MASTER);
  45 + if (FALSE == in_array($type, [UpdateNotify::TYPE_MASTER, UpdateNotify::TYPE_MINOR])){
46 $this->response('非法参数!', Code::USER_ERROR); 46 $this->response('非法参数!', Code::USER_ERROR);
47 -  
48 - $list = $webSettingLogic->sendNotifyMessage($type); 47 + }
  48 + $page = $this->request->input('page', UpdateNotify::PAGE_ALL);
  49 + if (FALSE == in_array($type, [UpdateNotify::PAGE_ALL, UpdateNotify::PAGE_SINGLE])){
  50 + $this->response('非法参数!', Code::USER_ERROR);
  51 + }
  52 + $list = $webSettingLogic->sendNotifyMessage($type,$page);
49 if(!empty($list)){ 53 if(!empty($list)){
50 $this->response('当前页面正在生成了,请完成后再点击',Code::USER_ERROR,$list); 54 $this->response('当前页面正在生成了,请完成后再点击',Code::USER_ERROR,$list);
51 } 55 }
@@ -5,6 +5,8 @@ namespace App\Http\Logic\Bside\Setting; @@ -5,6 +5,8 @@ namespace App\Http\Logic\Bside\Setting;
5 use App\Helper\Common as CommonHelper; 5 use App\Helper\Common as CommonHelper;
6 use App\Http\Logic\Bside\BaseLogic; 6 use App\Http\Logic\Bside\BaseLogic;
7 use App\Models\Com\UpdateNotify; 7 use App\Models\Com\UpdateNotify;
  8 +use App\Models\Com\UpdateProgress;
  9 +use App\Models\RouteMap\RouteMap;
8 use App\Models\WebSetting\WebSetting; 10 use App\Models\WebSetting\WebSetting;
9 11
10 class WebSettingLogic extends BaseLogic 12 class WebSettingLogic extends BaseLogic
@@ -62,24 +64,59 @@ class WebSettingLogic extends BaseLogic @@ -62,24 +64,59 @@ class WebSettingLogic extends BaseLogic
62 * @param string $type 64 * @param string $type
63 * @return array 65 * @return array
64 */ 66 */
65 - public function sendNotifyMessage($type = ''){  
66 - //获取当前项目所有未处理的更新并更换为1:处理中 2:处理完成 67 + public function sendNotifyMessage($type,$page){
  68 + $updateProgressModel = new UpdateProgress();
  69 + $progressInfo = $updateProgressModel->formatQuery(['project_id'=>$this->user['project_id'],'type'=>$type])->orderBy('id','desc')->first()->toArray();
  70 + if((!empty($progressInfo)) && ($progressInfo['total_num'] > $progressInfo['current_num'])){
  71 + return $this->success($progressInfo);
  72 + }
67 $updateNotifyModel = new UpdateNotify(); 73 $updateNotifyModel = new UpdateNotify();
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'; 74 + $field = ($type == UpdateNotify::TYPE_MINOR) ? 'minor_languages_status' : 'status';
  75 + $count = $updateNotifyModel->formatQuery(['project_id' => $this->user['project_id'], $field => 0])->count();
  76 + if($page == UpdateNotify::PAGE_ALL){
  77 + //如果是更新所有
  78 + $routeMapModel = new RouteMap();
  79 + $count = $routeMapModel->formatQuery(['project_id'=>$this->user['project_id'],'source'=>['!=','product_keyword']])->count();
  80 + }
  81 + $this->addProgress($count);
73 $updateNotifyModel->edit([$field => 1], ['project_id' => $this->user['project_id'], $field => 0]); 82 $updateNotifyModel->edit([$field => 1], ['project_id' => $this->user['project_id'], $field => 0]);
  83 + $urlStr = $this->getString();
  84 + http_get($urlStr,["charset = UTF-8"]);
  85 + return $this->success();
  86 + }
  87 +
  88 + /**
  89 + * @remark :生成一条更新记录
  90 + * @name :addProgress
  91 + * @author :lyh
  92 + * @method :post
  93 + * @time :2023/9/6 17:01
  94 + */
  95 + public function addProgress($count,$type){
  96 + $data = [
  97 + 'total_num'=>$count,
  98 + 'current_num'=>0,
  99 + 'type'=>$type,
  100 + 'created_at'=>date('Y-m-d H;i:s')
  101 + ];
  102 + $updateProgressModel = new UpdateProgress();
  103 + return $updateProgressModel->insert($data);
  104 + }
  105 +
  106 + /**
  107 + * @remark :通知参数处理
  108 + * @name :getString
  109 + * @author :lyh
  110 + * @method :post
  111 + * @time :2023/9/6 17:03
  112 + */
  113 + public function getString($type,$page){
74 $param = [ 114 $param = [
75 'project_id' => $this->user['project_id'], 115 'project_id' => $this->user['project_id'],
76 'type' => $type, 116 'type' => $type,
77 - 'route' => 'all' 117 + 'route' => $page
78 ]; 118 ];
79 $string = http_build_query($param); 119 $string = http_build_query($param);
80 - $urlStr = $this->user['domain'].'api/updateHtmlNotify/?' . $string;  
81 - http_get($urlStr,["charset = UTF-8"]);  
82 - return $this->success(); 120 + return $this->user['domain'].'api/updateHtmlNotify/?' . $string;
83 } 121 }
84 -  
85 } 122 }
@@ -17,6 +17,9 @@ class UpdateNotify extends Base @@ -17,6 +17,9 @@ class UpdateNotify extends Base
17 //连接数据库 17 //连接数据库
18 protected $connection = 'custom_mysql'; 18 protected $connection = 'custom_mysql';
19 19
20 - const TYPE_MASTER = 'master_website';  
21 - const TYPE_MINOR = 'minor_languages'; 20 + const TYPE_MASTER = 1;//主站
  21 + const TYPE_MINOR = 2;//小语种
  22 +
  23 + const PAGE_ALL= 1;//所有
  24 + const PAGE_SINGLE = 2;//按需
22 } 25 }
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :UpdateProgress.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/9/6 16:19
  8 + */
  9 +
  10 +namespace App\Models\Com;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +class UpdateProgress extends Base
  15 +{
  16 + protected $table = 'gl_update_progress';
  17 + //连接数据库
  18 + protected $connection = 'custom_mysql';
  19 +}