作者 张关杰

Merge branch 'develop' of http://47.244.231.31:8099/zhl/globalso-v6 into bate

@@ -33,10 +33,11 @@ class UpdateController extends BaseController @@ -33,10 +33,11 @@ class UpdateController extends BaseController
33 * @method :post 33 * @method :post
34 * @time :2023/8/19 9:25 34 * @time :2023/8/19 9:25
35 */ 35 */
36 - public function updateSeoTdk(){ 36 + public function updateSeoTdk()
  37 + {
37 $this->request->validate([ 38 $this->request->validate([
38 - 'project_id'=>'required',  
39 - ],[ 39 + 'project_id' => 'required',
  40 + ], [
40 'project_id.required' => 'project_id不能为空', 41 'project_id.required' => 'project_id不能为空',
41 ]); 42 ]);
42 ProjectUpdateTdk::add_task($this->param['project_id']); 43 ProjectUpdateTdk::add_task($this->param['project_id']);
@@ -48,14 +49,50 @@ class UpdateController extends BaseController @@ -48,14 +49,50 @@ class UpdateController extends BaseController
48 * @author Akun 49 * @author Akun
49 * @date 2023/11/24 11:33 50 * @date 2023/11/24 11:33
50 */ 51 */
51 - public function dataCollect(){ 52 + public function dataCollect()
  53 + {
52 $this->request->validate([ 54 $this->request->validate([
53 - 'project_id'=>'required',  
54 - ],[ 55 + 'project_id' => 'required',
  56 + 'type' => 'required',
  57 + ], [
55 'project_id.required' => 'project_id不能为空', 58 'project_id.required' => 'project_id不能为空',
  59 + 'type.required' => '采集类型不能为空',
56 ]); 60 ]);
57 61
58 - UpdateLog::updateLog($this->param['project_id']);  
59 - $this->response('任务添加成功'); 62 + $collect_un = UpdateLog::where('project_id', $this->param['project_id'])->where('collect_status', 0)->get();
  63 + if ($collect_un->count() > 0) {
  64 + $this->fail('项目正在采集中');
  65 + }
  66 +
  67 + $project = ProjectServer::useProject($this->param['project_id']);
  68 +
  69 + if(!$project){
  70 + $this->fail('项目不存在');
  71 + }
  72 +
  73 + if ($project->is_upgrade != 1) {
  74 + $this->fail('非升级无法进行采集操作');
  75 + }
  76 +
  77 + try {
  78 + DB::connection('custom_mysql')->statement("DELETE FROM `gl_collect_source` WHERE `origin` LIKE '%.css%' OR `origin` LIKE '%.js%'");
  79 + DB::connection('custom_mysql')->statement("UPDATE `gl_collect_task` SET `status` = 0 WHERE `language` = ''");
  80 + } catch (\Exception $e) {
  81 + errorLog('重新采集升级项目数据', $this->param, $e);
  82 +
  83 + $this->fail('采集任务添加失败');
  84 + }
  85 +
  86 + //关闭数据库
  87 + DB::disconnect('custom_mysql');
  88 +
  89 + $update = ['collect_status' => 0];
  90 + if ($this->param['type'] == 2) {
  91 + $update['status'] = 0;
  92 + }
  93 +
  94 + UpdateLog::where('project_id', $this->param['project_id'])->whereIn('api_type', ['post', 'page', 'news', 'blog'])->update($update);
  95 +
  96 + $this->response('采集任务添加成功');
60 } 97 }
61 } 98 }
@@ -54,7 +54,9 @@ class ProjectAssociationController extends BaseController @@ -54,7 +54,9 @@ class ProjectAssociationController extends BaseController
54 public function check() 54 public function check()
55 { 55 {
56 $project_id = (int)request()->input('project_id', 0); 56 $project_id = (int)request()->input('project_id', 0);
57 - $status = request()->input('status'); 57 + $status = request()->input('status');
  58 + // 重载redis缓存
  59 + $cache = request()->input('cache');
58 if (isset($status)) { 60 if (isset($status)) {
59 $status = (int)$status ? ProjectAssociation::STATUS_NORMAL : ProjectAssociation::STATUS_DISABLED; 61 $status = (int)$status ? ProjectAssociation::STATUS_NORMAL : ProjectAssociation::STATUS_DISABLED;
60 } 62 }
@@ -90,8 +92,16 @@ class ProjectAssociationController extends BaseController @@ -90,8 +92,16 @@ class ProjectAssociationController extends BaseController
90 if (is_null($isRes)) { 92 if (is_null($isRes)) {
91 $this->response('请开启AICC绑定!', Code::USER_ERROR, []); 93 $this->response('请开启AICC绑定!', Code::USER_ERROR, []);
92 } 94 }
93 - $url = env('AICC_URL') . env('AICC_WECHAT_FRIEND_API_URL');  
94 - $result = curlGet($url); 95 + $redis_key = 'aicc_friend_lists_' . (int)env('AICC_WECHAT_USER_ID');
  96 + $result = isset($cache) ? false : redis_get($redis_key);
  97 + if (empty($result)) {
  98 + $url = env('AICC_URL') . env('AICC_WECHAT_FRIEND_API_URL');
  99 + $result = curlGet($url);
  100 + redis_set($redis_key, json_encode($result));
  101 + } else {
  102 + $result = json_decode($result, true);
  103 + }
  104 +
95 $result['info'] = [ 105 $result['info'] = [
96 'friend_id' => $isRes->friend_id ?? 0, 106 'friend_id' => $isRes->friend_id ?? 0,
97 'nickname' => $isRes->nickname ?? '', 107 'nickname' => $isRes->nickname ?? '',
@@ -111,9 +111,6 @@ class DomainInfoLogic extends BaseLogic @@ -111,9 +111,6 @@ class DomainInfoLogic extends BaseLogic
111 111
112 /** 112 /**
113 * 删除域名 113 * 删除域名
114 - * @return array  
115 - * @throws \App\Exceptions\AsideGlobalException  
116 - * @throws \App\Exceptions\BsideGlobalException  
117 */ 114 */
118 public function delDomain(){ 115 public function delDomain(){
119 $ids = $this->param['id']; 116 $ids = $this->param['id'];