Merge remote-tracking branch 'origin/master' into zhl
正在显示
12 个修改的文件
包含
143 行增加
和
52 行删除
| @@ -73,7 +73,7 @@ class Count extends Command | @@ -73,7 +73,7 @@ class Count extends Command | ||
| 73 | $arr['ip_num'] = $this->ip_num($yesterday,$v['test_domain']); | 73 | $arr['ip_num'] = $this->ip_num($yesterday,$v['test_domain']); |
| 74 | DB::disconnect('custom_mysql'); | 74 | DB::disconnect('custom_mysql'); |
| 75 | //服务达标天数 | 75 | //服务达标天数 |
| 76 | - $arr['compliance_day'] = $this->compliance_day($v['id']); | 76 | + $arr['compliance_day'] = $v['finish_remain_day']; |
| 77 | //剩余服务时常 | 77 | //剩余服务时常 |
| 78 | $arr['service_day'] = $v['remain_day']; | 78 | $arr['service_day'] = $v['remain_day']; |
| 79 | //项目id | 79 | //项目id |
| @@ -193,6 +193,7 @@ class Count extends Command | @@ -193,6 +193,7 @@ class Count extends Command | ||
| 193 | 'gl_project.type AS type', | 193 | 'gl_project.type AS type', |
| 194 | 'gl_project.extend_type AS extend_type', | 194 | 'gl_project.extend_type AS extend_type', |
| 195 | 'gl_project.remain_day AS remain_day', | 195 | 'gl_project.remain_day AS remain_day', |
| 196 | + 'gl_project.finish_remain_day AS finish_remain_day', | ||
| 196 | 'gl_project_deploy_build.test_domain AS test_domain', | 197 | 'gl_project_deploy_build.test_domain AS test_domain', |
| 197 | 'gl_project_deploy_optimize.domain AS domain', | 198 | 'gl_project_deploy_optimize.domain AS domain', |
| 198 | 'gl_project_deploy_build.project_id AS project_id', | 199 | 'gl_project_deploy_build.project_id AS project_id', |
| @@ -49,13 +49,19 @@ class DomainInfo extends Command | @@ -49,13 +49,19 @@ class DomainInfo extends Command | ||
| 49 | } | 49 | } |
| 50 | $ssl = $this->updateDomainSsl($v['domain']); | 50 | $ssl = $this->updateDomainSsl($v['domain']); |
| 51 | $time = $this->updateDomain($v['domain']); | 51 | $time = $this->updateDomain($v['domain']); |
| 52 | + if(!empty($time['start']) && !!empty($time['end'])){ | ||
| 52 | $data = [ | 53 | $data = [ |
| 53 | 'certificate_start_time'=>$ssl['from'], | 54 | 'certificate_start_time'=>$ssl['from'], |
| 54 | 'certificate_end_time'=>$ssl['to'], | 55 | 'certificate_end_time'=>$ssl['to'], |
| 55 | 'domain_start_time'=>$time['start'], | 56 | 'domain_start_time'=>$time['start'], |
| 56 | 'domain_end_time'=>$time['end'] | 57 | 'domain_end_time'=>$time['end'] |
| 57 | ]; | 58 | ]; |
| 58 | - | 59 | + }else{ |
| 60 | + $data = [ | ||
| 61 | + 'domain_start_time'=>$time['start'], | ||
| 62 | + 'domain_end_time'=>$time['end'] | ||
| 63 | + ]; | ||
| 64 | + } | ||
| 59 | $domainModel->edit($data,['id'=>$v['id']]); | 65 | $domainModel->edit($data,['id'=>$v['id']]); |
| 60 | } | 66 | } |
| 61 | return 1; | 67 | return 1; |
| @@ -169,8 +175,8 @@ class DomainInfo extends Command | @@ -169,8 +175,8 @@ class DomainInfo extends Command | ||
| 169 | $valid_to = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validTo_time_t']); | 175 | $valid_to = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validTo_time_t']); |
| 170 | fclose($stream); | 176 | fclose($stream); |
| 171 | }catch (\Exception $e){ | 177 | }catch (\Exception $e){ |
| 172 | - $valid_from = date('Y-m-d H:i:s'); | ||
| 173 | - $valid_to = date('Y-m-d H:i:s'); | 178 | + $valid_from = ''; |
| 179 | + $valid_to = ''; | ||
| 174 | } | 180 | } |
| 175 | return ['from'=>$valid_from,'to'=>$valid_to]; | 181 | return ['from'=>$valid_from,'to'=>$valid_to]; |
| 176 | } | 182 | } |
| @@ -83,10 +83,12 @@ class HtmlCollect extends Command | @@ -83,10 +83,12 @@ class HtmlCollect extends Command | ||
| 83 | //采集html页面,下载资源到本地并替换 | 83 | //采集html页面,下载资源到本地并替换 |
| 84 | try { | 84 | try { |
| 85 | $html = curl_c('https://' . $collect_info->domain . $collect_info->route, false); | 85 | $html = curl_c('https://' . $collect_info->domain . $collect_info->route, false); |
| 86 | - if ($html == '0') { | 86 | + if ($html == '0' || strpos($html,'404 Not Found') !== false) { |
| 87 | $collect_info->status = CollectTask::STATUS_FAIL; | 87 | $collect_info->status = CollectTask::STATUS_FAIL; |
| 88 | $collect_info->save(); | 88 | $collect_info->save(); |
| 89 | - echo 'date:' . date('Y-m-d H:i:s') . ', project_id: ' . $project_id . ', collect_id: ' . $collect_id . ', error: no html' . PHP_EOL; | 89 | + |
| 90 | + $error = $html == '0' ? 'no html' : '404 not found'; | ||
| 91 | + echo 'date:' . date('Y-m-d H:i:s') . ', project_id: ' . $project_id . ', collect_id: ' . $collect_id . ', error: ' . $error . PHP_EOL; | ||
| 90 | sleep(2); | 92 | sleep(2); |
| 91 | return true; | 93 | return true; |
| 92 | } | 94 | } |
| @@ -85,10 +85,12 @@ class HtmlLanguageCollect extends Command | @@ -85,10 +85,12 @@ class HtmlLanguageCollect extends Command | ||
| 85 | //采集html页面,下载资源到本地并替换 | 85 | //采集html页面,下载资源到本地并替换 |
| 86 | try { | 86 | try { |
| 87 | $html = curl_c('https://' . $collect_info->domain . $collect_info->route, false); | 87 | $html = curl_c('https://' . $collect_info->domain . $collect_info->route, false); |
| 88 | - if ($html == '0') { | 88 | + if ($html == '0' || strpos($html,'404 Not Found') !== false) { |
| 89 | $collect_info->status = CollectTask::STATUS_FAIL; | 89 | $collect_info->status = CollectTask::STATUS_FAIL; |
| 90 | $collect_info->save(); | 90 | $collect_info->save(); |
| 91 | - echo 'date:' . date('Y-m-d H:i:s') . ', project_id: ' . $project_id . ', collect_id: ' . $collect_id . ', error: no html' . PHP_EOL; | 91 | + |
| 92 | + $error = $html == '0' ? 'no html' : '404 not found'; | ||
| 93 | + echo 'date:' . date('Y-m-d H:i:s') . ', project_id: ' . $project_id . ', collect_id: ' . $collect_id . ', error: ' . $error . PHP_EOL; | ||
| 92 | sleep(2); | 94 | sleep(2); |
| 93 | return true; | 95 | return true; |
| 94 | } | 96 | } |
| @@ -85,10 +85,12 @@ class HtmlLanguageSpecialCollect extends Command | @@ -85,10 +85,12 @@ class HtmlLanguageSpecialCollect extends Command | ||
| 85 | //采集html页面,下载资源到本地并替换 | 85 | //采集html页面,下载资源到本地并替换 |
| 86 | try { | 86 | try { |
| 87 | $html = curl_c('https://' . $collect_info->domain . $collect_info->route, false); | 87 | $html = curl_c('https://' . $collect_info->domain . $collect_info->route, false); |
| 88 | - if ($html == '0') { | 88 | + if ($html == '0' || strpos($html,'404 Not Found') !== false) { |
| 89 | $collect_info->status = CollectTask::STATUS_FAIL; | 89 | $collect_info->status = CollectTask::STATUS_FAIL; |
| 90 | $collect_info->save(); | 90 | $collect_info->save(); |
| 91 | - echo 'date:' . date('Y-m-d H:i:s') . ', project_id: ' . $project_id . ', collect_id: ' . $collect_id . ', error: no html' . PHP_EOL; | 91 | + |
| 92 | + $error = $html == '0' ? 'no html' : '404 not found'; | ||
| 93 | + echo 'date:' . date('Y-m-d H:i:s') . ', project_id: ' . $project_id . ', collect_id: ' . $collect_id . ', error: ' . $error . PHP_EOL; | ||
| 92 | sleep(2); | 94 | sleep(2); |
| 93 | return true; | 95 | return true; |
| 94 | } | 96 | } |
| @@ -13,6 +13,7 @@ use App\Models\Com\UpdateOldInfo; | @@ -13,6 +13,7 @@ use App\Models\Com\UpdateOldInfo; | ||
| 13 | use App\Models\News\News; | 13 | use App\Models\News\News; |
| 14 | use App\Models\News\NewsCategory; | 14 | use App\Models\News\NewsCategory; |
| 15 | use App\Models\Product\Category; | 15 | use App\Models\Product\Category; |
| 16 | +use App\Models\Product\CategoryRelated; | ||
| 16 | use App\Models\Product\Extend; | 17 | use App\Models\Product\Extend; |
| 17 | use App\Models\Product\ExtendInfo; | 18 | use App\Models\Product\ExtendInfo; |
| 18 | use App\Models\Product\Keyword; | 19 | use App\Models\Product\Keyword; |
| @@ -258,6 +259,7 @@ class ProjectUpdate extends Command | @@ -258,6 +259,7 @@ class ProjectUpdate extends Command | ||
| 258 | } | 259 | } |
| 259 | //分类 | 260 | //分类 |
| 260 | $category_id = ''; | 261 | $category_id = ''; |
| 262 | + $category_arr = []; | ||
| 261 | if ($item['category'] ?? []) { | 263 | if ($item['category'] ?? []) { |
| 262 | $category_arr = $category_model->list(['original_id' => ['in', array_column($item['category'], 'id')]]); | 264 | $category_arr = $category_model->list(['original_id' => ['in', array_column($item['category'], 'id')]]); |
| 263 | $category_id = $logic->getLastCategory(array_column($category_arr, 'id')); | 265 | $category_id = $logic->getLastCategory(array_column($category_arr, 'id')); |
| @@ -290,7 +292,6 @@ class ProjectUpdate extends Command | @@ -290,7 +292,6 @@ class ProjectUpdate extends Command | ||
| 290 | 'route' => $route | 292 | 'route' => $route |
| 291 | ]); | 293 | ]); |
| 292 | $this->set_map($route, RouteMap::SOURCE_PRODUCT, $id, $project_id); | 294 | $this->set_map($route, RouteMap::SOURCE_PRODUCT, $id, $project_id); |
| 293 | - | ||
| 294 | CollectTask::_insert($item['url'], $project_id, RouteMap::SOURCE_PRODUCT, $id, $link_type, $language_list, $page_list); | 295 | CollectTask::_insert($item['url'], $project_id, RouteMap::SOURCE_PRODUCT, $id, $link_type, $language_list, $page_list); |
| 295 | } else { | 296 | } else { |
| 296 | $id = $product['id']; | 297 | $id = $product['id']; |
| @@ -310,6 +311,11 @@ class ProjectUpdate extends Command | @@ -310,6 +311,11 @@ class ProjectUpdate extends Command | ||
| 310 | ], ['id' => $id]); | 311 | ], ['id' => $id]); |
| 311 | } | 312 | } |
| 312 | 313 | ||
| 314 | + //关联分类 | ||
| 315 | + if($category_arr){ | ||
| 316 | + CategoryRelated::saveRelated($id, array_column($category_arr, 'id')); | ||
| 317 | + } | ||
| 318 | + | ||
| 313 | //扩展字段 | 319 | //扩展字段 |
| 314 | if ($item['extend'] ?? []) { | 320 | if ($item['extend'] ?? []) { |
| 315 | foreach (array_reverse($item['extend']) as $ke => $ve) { | 321 | foreach (array_reverse($item['extend']) as $ke => $ve) { |
| @@ -289,11 +289,12 @@ class OptimizeController extends BaseController | @@ -289,11 +289,12 @@ class OptimizeController extends BaseController | ||
| 289 | $this->request->validate([ | 289 | $this->request->validate([ |
| 290 | 'project_id'=>'required', | 290 | 'project_id'=>'required', |
| 291 | 'status'=>'required', | 291 | 'status'=>'required', |
| 292 | - 'type'=>'required', | 292 | + 'type'=>'required|in:is_translate,is_translate_tag', |
| 293 | ],[ | 293 | ],[ |
| 294 | 'project_id.required' => 'project_id不能为空', | 294 | 'project_id.required' => 'project_id不能为空', |
| 295 | 'status.required' => 'status不能为空', | 295 | 'status.required' => 'status不能为空', |
| 296 | 'type.required' => 'type不能为空', | 296 | 'type.required' => 'type不能为空', |
| 297 | + 'type.in' => 'type类型错误', | ||
| 297 | ]); | 298 | ]); |
| 298 | $projectModel = new Project(); | 299 | $projectModel = new Project(); |
| 299 | $projectModel->edit([$this->param['type']=>$this->param['status']],['id'=>$this->param['project_id']]); | 300 | $projectModel->edit([$this->param['type']=>$this->param['status']],['id'=>$this->param['project_id']]); |
| @@ -63,7 +63,8 @@ class ProjectController extends BaseController | @@ -63,7 +63,8 @@ class ProjectController extends BaseController | ||
| 63 | ->where('gl_project.delete_status',Project::TYPE_ZERO) | 63 | ->where('gl_project.delete_status',Project::TYPE_ZERO) |
| 64 | ->where('gl_project.extend_type',Project::TYPE_ZERO); | 64 | ->where('gl_project.extend_type',Project::TYPE_ZERO); |
| 65 | $query = $this->searchParam($query); | 65 | $query = $this->searchParam($query); |
| 66 | - $lists = $query->orderBy('gl_project.id', 'desc')->paginate($this->row, $this->selectParam(), 'page', $this->page)->toArray(); | 66 | + $query = $this->orderByList($query); |
| 67 | + $lists = $query->paginate($this->row, $this->selectParam(), 'page', $this->page)->toArray(); | ||
| 67 | if(!empty($lists) && !empty($lists['list'])){ | 68 | if(!empty($lists) && !empty($lists['list'])){ |
| 68 | foreach ($lists['list'] as $k => $v){ | 69 | foreach ($lists['list'] as $k => $v){ |
| 69 | $v = $this->handleParam($v); | 70 | $v = $this->handleParam($v); |
| @@ -74,6 +75,18 @@ class ProjectController extends BaseController | @@ -74,6 +75,18 @@ class ProjectController extends BaseController | ||
| 74 | } | 75 | } |
| 75 | 76 | ||
| 76 | /** | 77 | /** |
| 78 | + * @remark :排序 | ||
| 79 | + * @name :orderByList | ||
| 80 | + * @author :lyh | ||
| 81 | + * @method :post | ||
| 82 | + * @time :2023/12/29 17:14 | ||
| 83 | + */ | ||
| 84 | + public function orderByList($query){ | ||
| 85 | + $query = $query->orderBy('gl_project.uptime', 'desc')->orderBy('gl_project.id', 'desc'); | ||
| 86 | + return $query; | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + /** | ||
| 77 | * @remark :搜索参数处理 | 90 | * @remark :搜索参数处理 |
| 78 | * @name :searchParam | 91 | * @name :searchParam |
| 79 | * @author :lyh | 92 | * @author :lyh |
| @@ -48,9 +48,13 @@ class ProjectAssociationController extends BaseController | @@ -48,9 +48,13 @@ class ProjectAssociationController extends BaseController | ||
| 48 | $image = request()->post('image', ''); | 48 | $image = request()->post('image', ''); |
| 49 | $data = compact('project_id', 'user_id', 'friend_id', 'nickname', 'user_name', 'image'); | 49 | $data = compact('project_id', 'user_id', 'friend_id', 'nickname', 'user_name', 'image'); |
| 50 | $this->ProjectAssociationLogic->saveWeChatData($data); | 50 | $this->ProjectAssociationLogic->saveWeChatData($data); |
| 51 | - $this->response('success'); | 51 | + $this->response('绑定成功'); |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | + /** | ||
| 55 | + * 获取aicc用户列表 并返回绑定的数据 | ||
| 56 | + * @return void | ||
| 57 | + */ | ||
| 54 | public function check() | 58 | public function check() |
| 55 | { | 59 | { |
| 56 | $project_id = (int)request()->input('project_id', 0); | 60 | $project_id = (int)request()->input('project_id', 0); |
| @@ -61,53 +65,30 @@ class ProjectAssociationController extends BaseController | @@ -61,53 +65,30 @@ class ProjectAssociationController extends BaseController | ||
| 61 | $status = (int)$status ? ProjectAssociation::STATUS_NORMAL : ProjectAssociation::STATUS_DISABLED; | 65 | $status = (int)$status ? ProjectAssociation::STATUS_NORMAL : ProjectAssociation::STATUS_DISABLED; |
| 62 | } | 66 | } |
| 63 | $isRes = $this->ProjectAssociationLogic->normal($project_id); | 67 | $isRes = $this->ProjectAssociationLogic->normal($project_id); |
| 64 | - DB::beginTransaction(); | ||
| 65 | - try { | ||
| 66 | // 当数据不存在时并开启状态,自动添加一条数据 | 68 | // 当数据不存在时并开启状态,自动添加一条数据 |
| 67 | if (is_null($isRes) && (!is_null($status) && $status)) { | 69 | if (is_null($isRes) && (!is_null($status) && $status)) { |
| 68 | - $isRes = $this->ProjectAssociationLogic->disabled($project_id); | 70 | + $isRes = $this->ProjectAssociationLogic->saveProject($project_id, $status); |
| 69 | if (is_null($isRes)) { | 71 | if (is_null($isRes)) { |
| 70 | - $isRes = new ProjectAssociation(); | 72 | + // 保存数据失败 |
| 73 | + $this->response('绑定AICC数据失败!', Code::SERVER_ERROR); | ||
| 71 | } | 74 | } |
| 72 | - $isRes->project_id = $project_id; | ||
| 73 | - $isRes->user_id = (int)env('AICC_WECHAT_USER_ID'); | ||
| 74 | - $isRes->status = $status; | ||
| 75 | - $isRes->save(); | ||
| 76 | - DB::commit(); | ||
| 77 | } // 关闭状态 | 75 | } // 关闭状态 |
| 78 | elseif (!is_null($isRes) && (!is_null($status) && empty($status))) { | 76 | elseif (!is_null($isRes) && (!is_null($status) && empty($status))) { |
| 79 | - $isRes->status = $status; | ||
| 80 | - $isRes->save(); | ||
| 81 | - DB::commit(); | ||
| 82 | - return [ | ||
| 83 | - 'code' => Code::SUCCESS, | ||
| 84 | - 'data' => [], | ||
| 85 | - 'message' => '关闭AICC绑定成功!', | ||
| 86 | - ]; | 77 | + $bool = $this->ProjectAssociationLogic->closedState($isRes, $status); |
| 78 | + if ($bool) { | ||
| 79 | + // 关闭aicc绑定成功 | ||
| 80 | + $this->response('关闭aicc绑定 - 成功!'); | ||
| 81 | + }else{ | ||
| 82 | + // 关闭aicc绑定失败 | ||
| 83 | + $this->response('关闭aicc绑定 - 失败!'); | ||
| 87 | } | 84 | } |
| 88 | - } catch (\Exception $exception) { | ||
| 89 | - DB::rollBack(); | ||
| 90 | - $this->response('数据错误,请重试!', Code::SERVER_ERROR); | ||
| 91 | } | 85 | } |
| 92 | if (is_null($isRes)) { | 86 | if (is_null($isRes)) { |
| 93 | - $this->response('请开启AICC绑定!', Code::USER_ERROR, []); | 87 | + // 请开启AICC绑定 |
| 88 | + $this->response('success', Code::SERVER_ERROR); | ||
| 94 | } | 89 | } |
| 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 | - | ||
| 105 | - $result['info'] = [ | ||
| 106 | - 'friend_id' => $isRes->friend_id ?? 0, | ||
| 107 | - 'nickname' => $isRes->nickname ?? '', | ||
| 108 | - 'user_name' => $isRes->user_name ?? '', | ||
| 109 | - 'image' => $isRes->image ?? '', | ||
| 110 | - ]; | 90 | + $cache = isset($cache); |
| 91 | + $result = $this->ProjectAssociationLogic->getAiccWechatLists($isRes, $cache); | ||
| 111 | $this->response('success', Code::SUCCESS, $result); | 92 | $this->response('success', Code::SUCCESS, $result); |
| 112 | } | 93 | } |
| 113 | } | 94 | } |
| @@ -39,7 +39,7 @@ class DomainInfoLogic extends BaseLogic | @@ -39,7 +39,7 @@ class DomainInfoLogic extends BaseLogic | ||
| 39 | $this->param['domain'] = trim($domain['host']); | 39 | $this->param['domain'] = trim($domain['host']); |
| 40 | } | 40 | } |
| 41 | //验证域名 | 41 | //验证域名 |
| 42 | - $this->verifyDomain($this->param['domain'],isset($this->param['id']) ?? ''); | 42 | + $this->verifyDomain($this->param['domain'],$this->param['id'] ?? ''); |
| 43 | if(isset($this->param['id']) && !empty($this->param['id'])){ | 43 | if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 44 | $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | 44 | $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); |
| 45 | }else{ | 45 | }else{ |
| @@ -47,4 +47,76 @@ class ProjectAssociationLogic extends Logic | @@ -47,4 +47,76 @@ class ProjectAssociationLogic extends Logic | ||
| 47 | { | 47 | { |
| 48 | return ProjectAssociation::query()->whereProjectId($project_id)->whereStatus(ProjectAssociation::STATUS_DISABLED)->first(); | 48 | return ProjectAssociation::query()->whereProjectId($project_id)->whereStatus(ProjectAssociation::STATUS_DISABLED)->first(); |
| 49 | } | 49 | } |
| 50 | + | ||
| 51 | + /** | ||
| 52 | + * 初始化数据/修改数据 | ||
| 53 | + * @param int $project_id | ||
| 54 | + * @param int $status | ||
| 55 | + * @return Builder|Model|object|ProjectAssociation|null | ||
| 56 | + */ | ||
| 57 | + public function saveProject($project_id, $status) | ||
| 58 | + { | ||
| 59 | + $bool = false; | ||
| 60 | + DB::beginTransaction(); | ||
| 61 | + $isRes = $this->disabled($project_id); | ||
| 62 | + if (is_null($isRes)) { | ||
| 63 | + $isRes = new ProjectAssociation(); | ||
| 64 | + } | ||
| 65 | + $isRes->project_id = $project_id; | ||
| 66 | + $isRes->user_id = (int)env('AICC_WECHAT_USER_ID'); | ||
| 67 | + $isRes->status = $status; | ||
| 68 | + try { | ||
| 69 | + $isRes->save(); | ||
| 70 | + DB::commit(); | ||
| 71 | + } catch (\Exception $exception) { | ||
| 72 | + DB::rollBack(); | ||
| 73 | + } | ||
| 74 | + return $isRes; | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + /** | ||
| 78 | + * 获取AICC微信列表数据 | ||
| 79 | + * @param ProjectAssociation $res | ||
| 80 | + * @param bool $cache | ||
| 81 | + * @return mixed | ||
| 82 | + */ | ||
| 83 | + public function getAiccWechatLists($res, $cache = false) | ||
| 84 | + { | ||
| 85 | + $redis_key = 'aicc_friend_lists_' . (int)env('AICC_WECHAT_USER_ID'); | ||
| 86 | + $result = $cache ? false : redis_get($redis_key); | ||
| 87 | + if (empty($result)) { | ||
| 88 | + $url = env('AICC_URL') . env('AICC_WECHAT_FRIEND_API_URL'); | ||
| 89 | + $result = curlGet($url); | ||
| 90 | + redis_set($redis_key, json_encode($result), 60); | ||
| 91 | + } else { | ||
| 92 | + $result = json_decode($result, true); | ||
| 93 | + } | ||
| 94 | + $result['info'] = [ | ||
| 95 | + 'friend_id' => $res->friend_id ?? 0, | ||
| 96 | + 'nickname' => $res->nickname ?? '', | ||
| 97 | + 'user_name' => $res->user_name ?? '', | ||
| 98 | + 'image' => $res->image ?? '', | ||
| 99 | + ]; | ||
| 100 | + return $result; | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + /** | ||
| 104 | + * 关闭状态 | ||
| 105 | + * @param ProjectAssociation $res | ||
| 106 | + * @param int $status 1 - 正常, 0 - 禁用 | ||
| 107 | + * @return bool | ||
| 108 | + */ | ||
| 109 | + public function closedState($res, $status) | ||
| 110 | + { | ||
| 111 | + DB::beginTransaction(); | ||
| 112 | + $bool = false; | ||
| 113 | + try { | ||
| 114 | + $res->status = $status; | ||
| 115 | + $bool = $res->save(); | ||
| 116 | + DB::commit(); | ||
| 117 | + } catch (\Exception $exception) { | ||
| 118 | + DB::rollBack(); | ||
| 119 | + } | ||
| 120 | + return $bool; | ||
| 121 | + } | ||
| 50 | } | 122 | } |
| @@ -41,6 +41,11 @@ class CountLogic extends BaseLogic | @@ -41,6 +41,11 @@ class CountLogic extends BaseLogic | ||
| 41 | $info = $this->model->read(['project_id' => $this->user['project_id']], | 41 | $info = $this->model->read(['project_id' => $this->user['project_id']], |
| 42 | ['pv_num','ip_num','inquiry_num','date','compliance_day','service_day','country']); | 42 | ['pv_num','ip_num','inquiry_num','date','compliance_day','service_day','country']); |
| 43 | } | 43 | } |
| 44 | + //获取项目的剩余时长 | ||
| 45 | + $projectModel = new Project(); | ||
| 46 | + $projectInfo = $projectModel->read(['id'=>$this->user['project_id']],['remain_day','finish_remain_day']); | ||
| 47 | + $info['service_day'] = $projectInfo['remain_day']; | ||
| 48 | + $info['compliance_day'] = $projectInfo['finish_remain_day']; | ||
| 44 | return $this->success($info); | 49 | return $this->success($info); |
| 45 | } | 50 | } |
| 46 | 51 |
-
请 注册 或 登录 后发表评论