作者 赵彬吉
<?php
/**
* @remark :
* @name :GeoWritingsTask.php
* @author :lyh
* @method :post
* @time :2025/10/27 14:12
*/
namespace App\Console\Commands\Geo;
use App\Helper\Gpt;
use App\Models\Geo\GeoWritings;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Redis;
use App\Models\Geo\GeoWritingsTask as GeoWritingsTaskModel;
class GeoWritingsTask extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'geo_writings_task';
public $porject_id;//记录当时执行的project_id
/**
* The console command description.
*
* @var string
*/
protected $description = 'geoAi生成文章';
public function handle(){
while (true){
$geoWritingsTaskModel = new GeoWritingsTaskModel();
$task_id = $this->getTaskId();
if(empty($task_id)){
sleep(60);
continue;
}
echo date("Y-m-d H:i:s").',执行的任务id'.$task_id.PHP_EOL;
$info = $geoWritingsTaskModel->read(['id'=>$task_id]);
if($info === false){
echo date("Y-m-d H:i:s").',任务id数据不存在:'.$task_id.PHP_EOL;
continue;
}
//生成引言
$aiCommand1 = "请根据这个文章标题:{$info['title']},并同时参考公司的介绍’{$info['description']}‘以及公司参与的事件内容’{$info['event_content']}‘,给我写一个英文Press Release前言内容,前言内容请参考并引用{$info['keyword']}行业的一些专业数据报告,只需要1个段落,大约150-200字,请一定要出现这个关键词“{$info['prefix']}{$info['keyword']}{$info['suffix']}”,所有内容一定要用英文, 只需要回复我引言内容,不需要别的内容(比如序号、你的提示、寒暄、解释、注释之类的)";
$gptHelper = new Gpt();
$introduction = $gptHelper->openai_chat_qqs($aiCommand1);
//生成内容
$aiCommand2 = "请根据这个文章标题:{$info['title']},并同时参考公司的介绍{$info['description']},以及公司参与的事件内容{$info['event_content']},给我写一篇英文Press Release内容正文(已经有前言内容了),内容请参考并引用“{$info['prefix']}{$info['keyword']}{$info['suffix']}”行业的一些专业数据报告,新闻内容需要 5-6 个大纲,每个大纲需要标题和 1-2 段内容,最后1-2个大纲主要介绍企业的核心优势、主营产品应用场景、主要客户案例,并最后附带内容{$info['footer']},最后只需要回复我新闻稿内容,整个新闻稿内容字数1000字左右,不需要别的内容(比如序号、你的提示、寒暄、解释、注释之类的)";
$main = $gptHelper->openai_chat_qqs($aiCommand2);
$images = explode(',',$info['img']);
//组装一条数据
try {
$geoWritingsModel = new GeoWritings();
$saveData = [
'project_id'=>$info['project_id'],
'type'=>$geoWritingsModel::TYPE_AI_CREATE,
'title'=>$info['title'],
'content'=>$introduction.($images[0] ?? '').PHP_EOL.$main.($images[1] ?? ''),
'content_length'=>strlen($introduction.PHP_EOL.$main),
'uniqid'=>md5(uniqid().$task_id.$info['project_id']),
];
$id = $geoWritingsModel->addReturnId($saveData);
$data = [
'introduction'=>$introduction,
'main'=>$main,
'status'=>2,
'writings_id'=>$id,
];
$geoWritingsTaskModel->edit($data,['task_id'=>$task_id]);
}catch (\Exception $e){
echo date('Y-m-d H:i:s').'保存失败:'.$task_id.$e->getMessage().PHP_EOL;
continue;
}
}
}
/**
* @remark :获取任务id
* @name :getTaskId
* @author :lyh
* @method :post
* @time :2025/10/27 14:22
*/
public function getTaskId(){
$task_id = Redis::rpop('geo_writings_task');
$geoWritingsTaskModel = new GeoWritingsTaskModel();
if (empty($task_id)) {
$ids = $geoWritingsTaskModel->formatQuery(['status'=>0])->limit(100)->pluck('id');
if(!empty($ids)){
foreach ($ids as $id) {
Redis::lpush('geo_writings_task', $id);
}
$task_id = Redis::rpop('geo_writings_task');
}
}else{
$geoWritingsTaskModel->edit(['status'=>1],['id'=>$task_id]);
}
return $task_id;
}
}
... ...
... ... @@ -124,6 +124,7 @@ class PostInquiryForward extends Command
if ($res) {
$form = InquiryInfo::find($detail['form_id']);
$form->success = $form->success + 1;
$form->timestamps = false;
$form->save();
Log::channel('inquiry_forward')->info('询盘成功:', [$detail['form_id'], $val->id, getmypid()]);
}
... ...
... ... @@ -1597,18 +1597,24 @@ if (!function_exists('httpGetSsl')) {
* @time :2025/9/22 14:46
*/
function truncate_text($text, $limit = 300) {
// 长度小于限制直接返回
if (mb_strlen($text, 'UTF-8') <= $limit) {
return $text;
}
// 先取前 $limit 个字符
$truncated = mb_substr($text, 0, $limit, 'UTF-8');
// 如果这一段包含空格(说明有英文单词),尽量在最后一个空格处截断
// 优先找空格
$lastSpace = mb_strrpos($truncated, ' ', 0, 'UTF-8');
if ($lastSpace !== false) {
// 在最后一个空格处截断,避免英文单词被截断
if ($lastSpace === false) {
// 没有空格则找 '-'
$lastDash = mb_strrpos($truncated, '-', 0, 'UTF-8');
if ($lastDash !== false && $lastDash > 0) {
$lastSpace = $lastDash;
}
}
if ($lastSpace !== false && $lastSpace > 0) {
$truncated = mb_substr($truncated, 0, $lastSpace, 'UTF-8');
}
return $truncated;
}
}
... ...
... ... @@ -39,7 +39,7 @@ class GeoController extends BaseController
$projectModel = new Project();
$projectInfo = $projectModel->read(['project_id' => $project_id],['title','version']);
$geoWritingsModel = new GeoWritings();
$lists = $geoWritingsModel->list(['project_id' => $project_id, 'is_del' => GeoWritings::IS_DEL_FALSE],'id',['title', 'status', 'uniqid', 'confirm_at']);
$lists = $geoWritingsModel->list(['project_id' => $project_id, 'status' => 2 ,'is_del' => GeoWritings::IS_DEL_FALSE],'id',['title', 'status', 'uniqid', 'confirm_at']);
$result = [
'project' => $projectInfo,
'list' => $lists
... ... @@ -66,9 +66,9 @@ class GeoController extends BaseController
* @param Request $request
* @return false|string
*/
public function confirmWritings(Request $request)
public function confirmWritings()
{
$request->validate([
$this->request->validate([
'token' => 'required',
'title' => 'required|max:120',
'content' => 'required|max:5000'
... ... @@ -79,19 +79,21 @@ class GeoController extends BaseController
'content.required' => '内容不能为空',
'content.max' => '内容过长保存失败',
]);
$token = trim($request->input('token'));
$data = GeoWritings::where(['uniqid' => $token])->first();
if (empty($data)){
$token = trim($this->param['token']);
$geoWritingsModel = new GeoWritings();
$info = $geoWritingsModel->read(['uniqid' => $token]);
if ($info === false){
return $this->error('非法请求');
}
if ($data->status != GeoWritings::STATUS_RUNNING){
if ($info['status'] == GeoWritings::STATUS_FINISH){
return $this->error('当前文章已确认,不可再次确认');
}
// FIXME 验证完成,保存数据,计算内容长度,处理内容中的资源, IP 确认时间 状态
return $data;
$this->param['confirm_ip'] = $this->request->ip();
$this->param['confirm_at'] = date('Y-m-d H:i:s');
$this->param['content_length'] = strlen($this->param['content']);
$this->param['status'] = GeoWritings::STATUS_FINISH;
$geoWritingsModel->edit($this->param,['uniqid' => $token]);
return true;
}
/**
... ...
... ... @@ -68,16 +68,4 @@ class GeoController extends BaseController
$data = $this->logic->saveConfig($this->param);
$this->response('success', Code::SUCCESS, $data);
}
/**
* OA后台管理员,保存确认数据
* 客户可以进行确认, OA后台也可以进行确认,以及修改
* @param Request $request
*/
public function saveConfirmData(Request $request)
{
}
}
... ...
... ... @@ -10,6 +10,7 @@
namespace App\Http\Controllers\Aside\Geo;
use App\Enums\Common\Code;
use App\Helper\Gpt;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Geo\GeoWritingsTaskLogic;
use App\Http\Requests\Aside\Geo\GeoWritingsTaskRequest;
... ... @@ -49,8 +50,7 @@ class GeoWritingTaskController extends BaseController
* @method :post
* @time :2025/10/25 10:41
*/
public function saveWritingTask(){
$request = new GeoWritingsTaskRequest();
public function saveWritingTask(GeoWritingsTaskRequest $request){
$request->validated();
$data = $this->logic->saveWritingTask();
$this->response('success',Code::SUCCESS,$data);
... ... @@ -73,4 +73,33 @@ class GeoWritingTaskController extends BaseController
$data = $this->logic->delWritingTask();
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :Ai请求标题
* @name :sendAiTitle
* @author :lyh
* @method :post
* @time :2025/10/27 11:10
*/
public function sendAiTitle(){
$this->request->validate([
'company'=>'required',
'number'=>'required',
'prefix'=>'required',
'keyword'=>'required',
'suffix'=>'required',
'event_title'=>'required',
],[
'company.required' => '公司简称不能为空',
'number.required' => '生成数量不能为空',
'prefix.required' => '关键词前缀为数组',
'keyword.required' => '关键词不能为空',
'suffix.requiredrequired' => '关键词后缀不能为空',
'event_title.required' => '事件标题不能为空',
]);
$aiCommand = "请根据公司简称{$this->param['company']}和这个公司产品的关键词:{$this->param['prefix']}{$this->param['keyword']}{$this->param['suffix']},以及{$this->param['event_title']},帮我写{$this->param['number']}个有吸引力的英文新闻标题;确保这个标题在Google上面唯一存在的,只需要回复我标题,不需要别的内容(比如序号、你的提示、寒暄、解释、注释之类的) 标题不能超过 100 字符数!,一行一个";
$gptHelper = new Gpt();
$data = $gptHelper->openai_chat_qqs($aiCommand);
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
... ... @@ -13,6 +13,7 @@ use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Geo\GeoWritingsLogic;
use App\Http\Requests\Aside\Geo\GeoWritingsRequest;
use App\Models\Geo\GeoWritings;
use Illuminate\Http\Request;
/**
... ... @@ -49,8 +50,7 @@ class GeoWritingsController extends BaseController
* @method :post
* @time :2025/10/25 10:41
*/
public function saveWriting(){
$request = new GeoWritingsRequest();
public function saveWriting(GeoWritingsRequest $request){
$request->validated();
$data = $this->logic->saveWriting();
$this->response('success',Code::SUCCESS,$data);
... ... @@ -74,4 +74,20 @@ class GeoWritingsController extends BaseController
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :推送待审核列表消息
* @name :sendMessage
* @author :lyh
* @method :post
* @time :2025/10/28 09:59
*/
public function sendWechatMessage(){
$this->request->validate([
'project_id'=>'required',
],[
'project_id.required' => '项目ID不能为空',
]);
$data = $this->logic->sendWechatMessage();
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
... ... @@ -63,32 +63,34 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/8/30 10:11
*/
public function lists(Project $project){
public function lists(Project $project)
{
$query = $project->leftJoin('gl_project_payment', 'gl_project.id', '=', 'gl_project_payment.project_id')
->leftJoin('gl_project_deploy_build', 'gl_project.id', '=', 'gl_project_deploy_build.project_id')
->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id')
->leftJoin('gl_project_online_check', 'gl_project.id', '=', 'gl_project_online_check.project_id')
->leftJoin('gl_web_setting_template', 'gl_project.id', '=', 'gl_web_setting_template.project_id')
->leftJoin('gl_project_association', 'gl_project.id', '=', 'gl_project_association.project_id')
->where('gl_project.delete_status',Project::TYPE_ZERO);
->where('gl_project.delete_status', Project::TYPE_ZERO);
$query = $this->searchParam($query);
$query = $this->orderByList($query);
$lists = $query->paginate($this->row, $this->selectParam(), 'page', $this->page)->toArray();
if(!empty($lists) && !empty($lists['list'])){
foreach ($lists['list'] as $k => $v){
if (!empty($lists) && !empty($lists['list'])) {
foreach ($lists['list'] as $k => $v) {
$v = $this->handleParam($v);
// 组装 工单UUID END
$lists['list'][$k] = $v;
}
}
$this->response('success',Code::SUCCESS,$lists);
$this->response('success', Code::SUCCESS, $lists);
}
/**
* 需要查询的字段
* @return array
*/
public function selectParam(){
public function selectParam()
{
$select = [
'gl_project.id AS id',
'gl_project.title AS title',
... ... @@ -144,10 +146,11 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/12/29 17:14
*/
public function orderByList($query){
if(isset($this->map['seo_plan']) && $this->map['seo_plan'] == 1){
public function orderByList($query)
{
if (isset($this->map['seo_plan']) && $this->map['seo_plan'] == 1) {
$query = $query->orderBy('gl_project.cooperate_date', 'desc')->orderBy('gl_project.id', 'desc');
}else{
} else {
$query = $query->orderBy('gl_project.uptime', 'desc')->orderBy('gl_project.id', 'desc');
}
return $query;
... ... @@ -160,7 +163,8 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/8/18 10:58
*/
public function searchParam(&$query){
public function searchParam(&$query)
{
//参数type
$query = $this->searchType($query);
//根据查看权限获取项目搜索条件(必带)
... ... @@ -185,18 +189,19 @@ class ProjectController extends BaseController
* @param $query
* @return mixed
*/
public function searchType(&$query){
if(isset($this->map['type'])){
$query->where('gl_project.extend_type', '!=' ,5)->where('gl_project.extend_type', '!=' ,8);
if (in_array($this->map['type'], [Project::TYPE_ZERO, Project::TYPE_ONE, Project::TYPE_TWO, Project::TYPE_THREE])){
public function searchType(&$query)
{
if (isset($this->map['type'])) {
$query->where('gl_project.extend_type', '!=', 5)->where('gl_project.extend_type', '!=', 8);
if (in_array($this->map['type'], [Project::TYPE_ZERO, Project::TYPE_ONE, Project::TYPE_TWO, Project::TYPE_THREE])) {
$query->where('gl_project.type', $this->map['type']);
} elseif ($this->map['type'] == 8){
$query->where('gl_project_online_check.id', null)->where('gl_project.type',Project::TYPE_TWO);
}else{
$query->whereIn('gl_project.type', [Project::TYPE_FOUR,Project::TYPE_SIX]);
} elseif ($this->map['type'] == 8) {
$query->where('gl_project_online_check.id', null)->where('gl_project.type', Project::TYPE_TWO);
} else {
$query->whereIn('gl_project.type', [Project::TYPE_FOUR, Project::TYPE_SIX]);
}
}
if(isset($this->map['uptime']) && is_array($this->map['uptime'])){
if (isset($this->map['uptime']) && is_array($this->map['uptime'])) {
$query->whereBetween('gl_project.uptime', $this->map['uptime']);
}
return $query;
... ... @@ -209,8 +214,9 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/11/6 16:27
*/
public function searchUpgrade(&$query){
if(isset($this->map['is_upgrade'])){
public function searchUpgrade(&$query)
{
if (isset($this->map['is_upgrade'])) {
$query->where('gl_project.is_upgrade', $this->map['is_upgrade']);
}
return $query;
... ... @@ -221,31 +227,32 @@ class ProjectController extends BaseController
* @param $query
* @return mixed
*/
public function searchContent(&$query){
if(!empty($this->map['domain_type']) && !empty($this->map['domain_search'])){
if($this->map['domain_type'] == 'domain'){
public function searchContent(&$query)
{
if (!empty($this->map['domain_type']) && !empty($this->map['domain_search'])) {
if ($this->map['domain_type'] == 'domain') {
$parsedUrl = parse_url($this->map['domain_search']);
$this->map['domain_search'] = $parsedUrl['host'] ?? $this->map['domain_search'];
$ids = DomainInfoModel::where('domain', 'like', '%'.$this->map['domain_search'].'%')->pluck('id')->toArray();
$ids = DomainInfoModel::where('domain', 'like', '%' . $this->map['domain_search'] . '%')->pluck('id')->toArray();
$query->whereIn('gl_project_deploy_optimize.domain', $ids);
}else{
$query->where('gl_project_deploy_build.test_domain','like','%'.$this->map['domain_search'].'%');
} else {
$query->where('gl_project_deploy_build.test_domain', 'like', '%' . $this->map['domain_search'] . '%');
}
}
if(!empty($this->map['search']) && !empty($this->map['search_type'])){
if (!empty($this->map['search']) && !empty($this->map['search_type'])) {
$query->where(function ($subQuery) {
// 搜索域名
if ($this->map['search_type'] == 'domain') {
$parsedUrl = parse_url($this->map['search']);
$this->map['search'] = $parsedUrl['host'] ?? $this->map['search'];
$ids = DomainInfo::where('domain', 'like', '%'.$this->map['search'].'%')->pluck('id')->toArray();
$ids = DomainInfo::where('domain', 'like', '%' . $this->map['search'] . '%')->pluck('id')->toArray();
$subQuery->whereIn('gl_project_deploy_optimize.domain', $ids);
} else if($this->map['search_type'] == 'test_domain'){
$subQuery->where('gl_project_deploy_build.test_domain','like','%'.$this->map['search'].'%');
} else if ($this->map['search_type'] == 'test_domain') {
$subQuery->where('gl_project_deploy_build.test_domain', 'like', '%' . $this->map['search'] . '%');
} else {
// 搜索名称
$subQuery->orwhere('gl_project.company','like','%'.$this->map['search'].'%')
->orwhere('gl_project.title','like','%'.$this->map['search'].'%');
$subQuery->orwhere('gl_project.company', 'like', '%' . $this->map['search'] . '%')
->orwhere('gl_project.title', 'like', '%' . $this->map['search'] . '%');
}
});
}
... ... @@ -259,15 +266,16 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/11/9 10:16
*/
public function searchChannel(&$query){
if(isset($this->map['zone_id']) && !empty($this->map['zone_id'])){
$query->where('gl_project.channel','like','%"zone_id": "'.$this->map['zone_id'].'"%');
public function searchChannel(&$query)
{
if (isset($this->map['zone_id']) && !empty($this->map['zone_id'])) {
$query->where('gl_project.channel', 'like', '%"zone_id": "' . $this->map['zone_id'] . '"%');
}
if(isset($this->map['channel_id']) && !empty($this->map['channel_id'])){
$query->where('gl_project.channel','like','%"channel_id": "'.$this->map['channel_id'].'"%');
if (isset($this->map['channel_id']) && !empty($this->map['channel_id'])) {
$query->where('gl_project.channel', 'like', '%"channel_id": "' . $this->map['channel_id'] . '"%');
}
if(isset($this->map['user_id']) && !empty($this->map['user_id'])){
$query->where('gl_project.channel','like','%"user_id": "'.$this->map['user_id'].'"%');
if (isset($this->map['user_id']) && !empty($this->map['user_id'])) {
$query->where('gl_project.channel', 'like', '%"user_id": "' . $this->map['user_id'] . '"%');
}
return $query;
}
... ... @@ -279,14 +287,15 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/9/7 18:40
*/
public function searchDept(&$query){
if(!empty($this->map['dept_id'])){
if($this->map['dept_id'] == 7 || $this->map['dept_id'] == 9){//7,9代表合并组H+F组
$query->whereIn('gl_project_deploy_build.dept_id', [7,9]);
}else{
public function searchDept(&$query)
{
if (!empty($this->map['dept_id'])) {
if ($this->map['dept_id'] == 7 || $this->map['dept_id'] == 9) {//7,9代表合并组H+F组
$query->whereIn('gl_project_deploy_build.dept_id', [7, 9]);
} else {
$query->where(function ($subQuery) {
$subQuery->orwhere('gl_project_deploy_build.dept_id',$this->map['dept_id'])
->orwhere('gl_project_deploy_optimize.dept_id',$this->map['dept_id']);
$subQuery->orwhere('gl_project_deploy_build.dept_id', $this->map['dept_id'])
->orwhere('gl_project_deploy_optimize.dept_id', $this->map['dept_id']);
});
}
}
... ... @@ -300,20 +309,21 @@ class ProjectController extends BaseController
* @method :post
* @time :2024/3/4 14:58
*/
public function searchTechMid(&$query){
if(isset($this->map['tech_mid'])){
$query = $query->where('gl_project_deploy_optimize.tech_mid',$this->map['tech_mid']);
public function searchTechMid(&$query)
{
if (isset($this->map['tech_mid'])) {
$query = $query->where('gl_project_deploy_optimize.tech_mid', $this->map['tech_mid']);
}
if(isset($this->map['optimize_optimist_mid'])){
$query = $query->where('gl_project_deploy_optimize.optimist_mid',$this->map['optimize_optimist_mid']);
if (isset($this->map['optimize_optimist_mid'])) {
$query = $query->where('gl_project_deploy_optimize.optimist_mid', $this->map['optimize_optimist_mid']);
}
if(isset($this->map['plan'])){
$query = $query->where('gl_project_deploy_build.plan',$this->map['plan']);
if (isset($this->map['plan'])) {
$query = $query->where('gl_project_deploy_build.plan', $this->map['plan']);
}
if(isset($this->map['friend_id'])){
if($this->map['friend_id'] == 1){
if (isset($this->map['friend_id'])) {
if ($this->map['friend_id'] == 1) {
$query = $query->where('gl_project_association.friend_id', '!=', 0);
}else{
} else {
$query = $query->where(function ($subQuery) {
$subQuery->where('gl_project_association.friend_id', 0)
->orWhereNull('gl_project_association.friend_id');
... ... @@ -327,25 +337,25 @@ class ProjectController extends BaseController
->orWhere('gl_project_deploy_build.seo_plan', '!=', 9);
});
}
if(isset($this->map['site_status'])){
$query = $query->where('gl_project.site_status',$this->map['site_status']);
if (isset($this->map['site_status'])) {
$query = $query->where('gl_project.site_status', $this->map['site_status']);
}
if(isset($this->map['domain'])){
if($this->map['domain'] == 0){
$query = $query->where('gl_project_deploy_optimize.domain',null);
}else{
$query = $query->where('gl_project_deploy_optimize.domain','!=',null);
if (isset($this->map['domain'])) {
if ($this->map['domain'] == 0) {
$query = $query->where('gl_project_deploy_optimize.domain', null);
} else {
$query = $query->where('gl_project_deploy_optimize.domain', '!=', null);
}
}
if(isset($this->map['project_type'])){
$query = $query->where('gl_project.project_type',$this->map['project_type']);
if (isset($this->map['project_type'])) {
$query = $query->where('gl_project.project_type', $this->map['project_type']);
}
if(isset($this->param['geo'])){
if($this->param['geo'] == 1){
$query = $query->where('gl_project.geo_status',1);
}else{
if (isset($this->param['geo'])) {
if ($this->param['geo'] == 1) {
$query = $query->where('gl_project.geo_status', 1);
} else {
$ids = GeoLink::pluck('project_id')->unique()->values()->all();
$query = $query->whereIn('gl_project.id',$ids);
$query = $query->whereIn('gl_project.id', $ids);
}
}
... ... @@ -359,14 +369,15 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/9/7 17:28
*/
public function getManagerRole(&$query){
if(($this->manage['role'] != 1)){//1代表查看所有
public function getManagerRole(&$query)
{
if (($this->manage['role'] != 1)) {//1代表查看所有
//获取用户所在组
$managerHr = new ManageHr();
$info = $managerHr->read(['manage_id'=>$this->manage['id']]);
$info = $managerHr->read(['manage_id' => $this->manage['id']]);
//获取当前用户自己的项目
$query->where(function ($subQuery) use ($info) {
$subQuery->whereIn('gl_project.id', [1]) // 项目1 + 项目3默认显示
$subQuery->whereIn('gl_project.id', [1])// 项目1 + 项目3默认显示
->orWhere('gl_project_deploy_build.leader_mid', $info['id'])
->orWhere('gl_project_deploy_build.manager_mid', $info['id'])
->orWhere('gl_project_deploy_build.designer_mid', $info['id'])
... ... @@ -428,55 +439,56 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/8/18 14:44
*/
public function handleParam(&$item){
if(($item['type'] != Project::TYPE_ZERO)){
public function handleParam(&$item)
{
if (($item['type'] != Project::TYPE_ZERO)) {
$data = APublicModel::getNumByProjectId($item['id']);
}
if($item['type'] == Project::TYPE_ONE){//建站中
if ($item['type'] == Project::TYPE_ONE) {//建站中
$processModel = new ProcessRecords();
$item['sign_project'] = 1;
$count = $processModel->counts(['project_id'=>$item['id']]);
if($count < 1){
$count = $processModel->counts(['project_id' => $item['id']]);
if ($count < 1) {
$item['sign_project'] = 0;
}else{
$proInfo = $processModel->read(['project_id'=>$item['id'],'date'=>['>=',date('Y-m-d', strtotime('-3 days'))]],['id']);
if($proInfo !== false){
} else {
$proInfo = $processModel->read(['project_id' => $item['id'], 'date' => ['>=', date('Y-m-d', strtotime('-3 days'))]], ['id']);
if ($proInfo !== false) {
$item['sign_project'] = 0;
}
}
}
if(!empty($item['extend_type'])){
if (!empty($item['extend_type'])) {
$item['type'] = $item['extend_type'];
}
$manageModel = new ManageHr();
//geo项目
if(($item['plan'] == 0) && ($item['seo_plan'] != 0)){
if (($item['plan'] == 0) && ($item['seo_plan'] != 0)) {
//geo项目负责人
$geoConfModel = new GeoConf();
$manage_id = $geoConfModel->getValue(['project_id'=>$item['id']],'manager_id');
$manage_id = $geoConfModel->getValue(['project_id' => $item['id']], 'manager_id');
$item['geo_manage_name'] = $manageModel->getName($manage_id);
$geoArticleModel = new GeoArticle();
$item['geo_article_num'] = $geoArticleModel->counts(['project_id'=>$item['id']]);//文章数量
$item['geo_article_num'] = $geoArticleModel->counts(['project_id' => $item['id']]);//文章数量
$geoLinkModel = new GeoLink();
$item['geo_link_num'] = $geoLinkModel->counts(['project_id'=>$item['id']]);//权威新闻数量
$item['geo_link_num'] = $geoLinkModel->counts(['project_id' => $item['id']]);//权威新闻数量
$questionResModel = new GeoQuestionResult();
$item['geo_qualify_num'] = $questionResModel->counts(['project_id'=>$item['id'],'hit'=>['!=',0],'platform'=>['in',['openai', 'gemini','google_ai_overview']]]);//排名
$item['geo_qualify_num'] = $questionResModel->counts(['project_id' => $item['id'], 'hit' => ['!=', 0], 'platform' => ['in', ['openai', 'gemini', 'google_ai_overview']]]);//排名
}
$item['build_leader'] = $manageModel->getName($item['leader_mid']);
$item['build_manager'] = $manageModel->getName($item['manager_mid']);
$item['build_designer'] = $manageModel->getName($item['designer_mid']);
$item['build_tech'] = $manageModel->getName($item['tech_mid']);
$item['optimize_manager'] = $manageModel->getName($item['optimize_manager_mid']);
$item['optimize_optimist'] = $manageModel->getName($item['optimize_optimist_mid']);
$item['optimize_assist'] = $manageModel->getName($item['optimize_assist_mid']);
$item['optimize_tech'] = $manageModel->getName($item['optimize_tech_mid']);
$item['quality_mid_name'] = $manageModel->getName($item['quality_mid']);
$item['build_leader'] = $manageModel->getName($item['leader_mid']);
$item['build_manager'] = $manageModel->getName($item['manager_mid']);
$item['build_designer'] = $manageModel->getName($item['designer_mid']);
$item['build_tech'] = $manageModel->getName($item['tech_mid']);
$item['optimize_manager'] = $manageModel->getName($item['optimize_manager_mid']);
$item['optimize_optimist'] = $manageModel->getName($item['optimize_optimist_mid']);
$item['optimize_assist'] = $manageModel->getName($item['optimize_assist_mid']);
$item['optimize_tech'] = $manageModel->getName($item['optimize_tech_mid']);
$item['quality_mid_name'] = $manageModel->getName($item['quality_mid']);
$planMap = Project::planMap();
$seoPlanMap = Project::seoMap();
$item['plan'] = $planMap[$item['plan']] ?? '';
$item['seo_plan'] = $seoPlanMap[$item['seo_plan']] ?? '';
$domainModel = new DomainInfoModel();
$item['domain'] = !empty($item['domain']) ? $domainModel->getDomain($item['domain']) : '';
$item['domain'] = !empty($item['domain']) ? $domainModel->getDomain($item['domain']) : '';
$item['uuid'] = TicketProject::where('table_id', $item['id'])->where('project_cate', 2)->value('uuid') ?? null;
$item['friend_id'] = ProjectAssociation::where('project_id', $item['id'])->where('status', ProjectAssociation::STATUS_NORMAL)->where('binding_app', ProjectAssociation::ENTERPRISE_WECHAT)->value('friend_id') ?? null;
$item['autologin_code'] = getAutoLoginCode($item['id']);
... ... @@ -498,14 +510,15 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/8/17 16:42
*/
public function info(ProjectLogic $logic){
public function info(ProjectLogic $logic)
{
$this->request->validate([
'id'=>'required'
],[
'id' => 'required'
], [
'id.required' => 'ID不能为空'
]);
$data = $logic->getProjectInfo($this->param['id']);
$this->response('success',Code::SUCCESS,$data);
$this->response('success', Code::SUCCESS, $data);
}
/**
... ... @@ -515,14 +528,15 @@ class ProjectController extends BaseController
* @method :post
* @time :2024/6/18 11:53
*/
public function deleteMinorLanguages(ProjectLogic $logic){
public function deleteMinorLanguages(ProjectLogic $logic)
{
$this->request->validate([
'id'=>'required'
],[
'id' => 'required'
], [
'id.required' => 'ID不能为空'
]);
$data = $logic->deleteMinorLanguages();
$this->response('success',Code::SUCCESS,$data);
$this->response('success', Code::SUCCESS, $data);
}
/**
... ... @@ -535,9 +549,9 @@ class ProjectController extends BaseController
public function save(ProjectLogic $logic)
{
$this->request->validate([
'type'=>'required',
'serve_id'=>'required',
],[
'type' => 'required',
'serve_id' => 'required',
], [
'type.required' => '类型不能为空',
'serve_id.required' => '请选择服务器'
]);
... ... @@ -550,23 +564,24 @@ class ProjectController extends BaseController
* @author zbj
* @date 2023/5/17
*/
public function inquiry_set(Request $request, ProjectLogic $logic){
public function inquiry_set(Request $request, ProjectLogic $logic)
{
$request->validate([
'project_id'=>'required'
],[
'project_id' => 'required'
], [
'project_id.required' => '项目ID不能为空'
]);
if($request->isMethod('get')){
if ($request->isMethod('get')) {
$data = InquirySet::where('project_id', $request->project_id)->first();
if(!$data){
if (!$data) {
$data = ['emails' => '', 'phones' => ''];
}else{
} else {
$data = $data->toArray();
}
$this->response('success',Code::SUCCESS,$data);
$this->response('success', Code::SUCCESS, $data);
}
$data = $logic->saveInquirySet($this->param);
$this->response('success',Code::SUCCESS,$data);
$this->response('success', Code::SUCCESS, $data);
}
... ... @@ -577,9 +592,10 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/12/7 10:41
*/
public function data_source(ProjectLogic $logic){
public function data_source(ProjectLogic $logic)
{
$data = $logic->dataSource();
$this->response('success',Code::SUCCESS,$data);
$this->response('success', Code::SUCCESS, $data);
}
/**
... ... @@ -587,9 +603,10 @@ class ProjectController extends BaseController
* @author zbj
* @date 2023/6/27
*/
public function city_source(){
public function city_source()
{
$data = City::source($this->param['id'] ?? 0);
$this->response('success',Code::SUCCESS,$data);
$this->response('success', Code::SUCCESS, $data);
}
/**
... ... @@ -597,9 +614,10 @@ class ProjectController extends BaseController
* @author zbj
* @date 2023/6/27
*/
public function channel_source(ProjectLogic $logic){
public function channel_source(ProjectLogic $logic)
{
$data = $logic->channelSource($this->param);
$this->response('success',Code::SUCCESS,$data);
$this->response('success', Code::SUCCESS, $data);
}
/**
... ... @@ -607,14 +625,15 @@ class ProjectController extends BaseController
* @author zbj
* @date 2023/6/25
*/
public function get_process_records(Request $request, ProcessRecordsLogic $logic){
public function get_process_records(Request $request, ProcessRecordsLogic $logic)
{
$request->validate([
'project_id'=>'required'
],[
'project_id' => 'required'
], [
'project_id.required' => '项目ID不能为空'
]);
$data = $logic->getInfo($this->param['project_id']);
$this->response('success',Code::SUCCESS,$data);
$this->response('success', Code::SUCCESS, $data);
}
... ... @@ -623,7 +642,8 @@ class ProjectController extends BaseController
* @author zbj
* @date 2023/6/25
*/
public function save_process_records(ProcessRecordsRequest $request, ProcessRecordsLogic $logic){
public function save_process_records(ProcessRecordsRequest $request, ProcessRecordsLogic $logic)
{
$request->validated();
$logic->recordSave();
$this->response('success');
... ... @@ -634,15 +654,16 @@ class ProjectController extends BaseController
* @author zbj
* @date 2023/6/27
*/
public function get_contract_bill(Request $request){
public function get_contract_bill(Request $request)
{
$request->validate([
'id'=>'required'
],[
'id' => 'required'
], [
'id.required' => 'ID不能为空'
]);
$payment = Payment::where('project_id', $this->param['id'])->select(['contract', 'bill'])->first();
$data = $payment->makeVisible(['contract', 'bill']);
$this->response('success',Code::SUCCESS,$data ? $data->toArray() : []);
$this->response('success', Code::SUCCESS, $data ? $data->toArray() : []);
}
/**
... ... @@ -652,10 +673,11 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/12/2 9:59
*/
public function submit_check(OnlineCheckLogic $logic){
public function submit_check(OnlineCheckLogic $logic)
{
$this->request->validate([
'id'=>'required'
],[
'id' => 'required'
], [
'id.required' => 'ID不能为空'
]);
$logic->saveOnlineCheck();
... ... @@ -669,12 +691,13 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/8/30 19:01
*/
public function online_check(OnlineCheckLogic $logic){
public function online_check(OnlineCheckLogic $logic)
{
$this->request->validate([
'id'=>'required',
'type'=>'required|in:optimist,qa',
'status'=>'required|in:0,1'
],[
'id' => 'required',
'type' => 'required|in:optimist,qa',
'status' => 'required|in:0,1'
], [
'id.required' => 'ID不能为空',
'type.required' => '请选择审核类型',
'type.in' => '审核类型值无效',
... ... @@ -692,15 +715,16 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/8/4 16:27
*/
public function getBelongingGroup(){
public function getBelongingGroup()
{
$this->request->validate([
'type'=>'required',
],[
'type' => 'required',
], [
'type.required' => '请选择审核类型'
]);
$belongGroupModel = new BelongingGroup();
$lists = $belongGroupModel->list($this->map,'name',['id','name','type'],'asc');
$this->response('success',Code::SUCCESS,$lists);
$lists = $belongGroupModel->list($this->map, 'name', ['id', 'name', 'type'], 'asc');
$this->response('success', Code::SUCCESS, $lists);
}
/**
... ... @@ -710,21 +734,22 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/8/8 10:29
*/
public function getManagerList(){
public function getManagerList()
{
$hrManagerModel = new ManageHr();
if(!isset($this->map['status'])){
if (!isset($this->map['status'])) {
$this->map['status'] = $hrManagerModel::STATUS_ONE;
}else{
if(!is_array($this->map['status'])){
} else {
if (!is_array($this->map['status'])) {
$this->map['status'] = [$this->map['status']];
}
$this->map['status'] = ['in',$this->map['status']];
$this->map['status'] = ['in', $this->map['status']];
}
if(isset($this->map['entry_position']) && !empty($this->map['entry_position'])){
$this->map['entry_position'] = ['in',$this->map['entry_position']];
if (isset($this->map['entry_position']) && !empty($this->map['entry_position'])) {
$this->map['entry_position'] = ['in', $this->map['entry_position']];
}
$lists = $hrManagerModel->list($this->map,['sort','id'],['id','manage_id','name','entry_position','is_leader']);
$this->response('success',Code::SUCCESS,$lists);
$lists = $hrManagerModel->list($this->map, ['sort', 'id'], ['id', 'manage_id', 'name', 'entry_position', 'is_leader']);
$this->response('success', Code::SUCCESS, $lists);
}
/**
... ... @@ -734,10 +759,11 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/8/14 10:23 todo::后面删除
*/
public function getServiceConfig(){
public function getServiceConfig()
{
$serviceConfigModel = new ServerConfig();
$list = $serviceConfigModel->list($this->param,'id',['id','type','title','count','init_domain','service_type']);
$this->response('success',Code::SUCCESS,$list);
$list = $serviceConfigModel->list($this->param, 'id', ['id', 'type', 'title', 'count', 'init_domain', 'service_type']);
$this->response('success', Code::SUCCESS, $list);
}
/**
... ... @@ -747,15 +773,16 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/8/14 10:29
*/
public function getDomain(){
public function getDomain()
{
$this->request->validate([
'project_id'=>'required',
],[
'project_id' => 'required',
], [
'project_id.required' => 'project_id不能为空',
]);
$domainModel = new DomainInfo();
$list = $domainModel->list(['status'=>0,'project_id'=>['or',$this->param['project_id']]]);
$this->response('success',Code::SUCCESS,$list);
$list = $domainModel->list(['status' => 0, 'project_id' => ['or', $this->param['project_id']]]);
$this->response('success', Code::SUCCESS, $list);
}
/**
... ... @@ -763,18 +790,19 @@ class ProjectController extends BaseController
* @author zbj
* @date 2023/9/4
*/
public function getProjectInService(){
public function getProjectInService()
{
$company = $this->param['company'];
if(!$company){
$this->response('企业名称必传',Code::SYSTEM_ERROR);
if (!$company) {
$this->response('企业名称必传', Code::SYSTEM_ERROR);
}
$project = Project::where('company', $company)->first();
if($project && ($project['remain_day'] > 0 || in_array($project['type'], [0, 1,6]))){
if ($project && ($project['remain_day'] > 0 || in_array($project['type'], [0, 1, 6]))) {
$in_service = 1;
}else{
} else {
$in_service = 0;
}
$this->response('success',Code::SUCCESS, ['in_service' => $in_service]);
$this->response('success', Code::SUCCESS, ['in_service' => $in_service]);
}
/**
... ... @@ -784,10 +812,11 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/9/8 15:21
*/
public function del(ProjectLogic $logic){
public function del(ProjectLogic $logic)
{
$this->request->validate([
'id'=>'required',
],[
'id' => 'required',
], [
'id.required' => 'id不能为空',
]);
$logic->projectDel();
... ... @@ -799,64 +828,74 @@ class ProjectController extends BaseController
* @author zbj
* @date 2023/9/11
*/
public function getProjectByChannel(Request $request){
public function getProjectByChannel(Request $request)
{
$id = $this->param['id'] ?? '';
$notice_order_id = $this->param['notice_order_id'] ?? '';
$source_id = $this->param['channel_id'] ?? 0; //原系统渠道id
$size = $this->param['page_size'] ?? 20;
$type = $this->param['type'] ?? '';
$company = $this->param['company'] ?? '';
$order_by_field = $request->input('order_by_field', 'id');
$order_by_sort = $request->input('order_by_sort', 'desc');
$order_by_field = $request->input('order_by_field', 'id');
$order_by_sort = $request->input('order_by_sort', 'desc');
$start_time = $this->param['start_time'] ?? '';
$end_time = $this->param['end_time'] ?? '';
if(!$source_id && !$id){
$this->response('参数异常',Code::SYSTEM_ERROR);
$plan = $this->param['plan'] ?? '';
if (!$source_id && !$id) {
$this->response('参数异常', Code::SYSTEM_ERROR);
}
$channel_id = 0;
if($source_id){
if ($source_id) {
$channel = Channel::where('source_id', $source_id)->first();
if(!$channel){
$this->response('渠道不存在',Code::SYSTEM_ERROR);
if (!$channel) {
$this->response('渠道不存在', Code::SYSTEM_ERROR);
}
$channel_id = $channel->id;
}
if ($id){
if(!is_array($id)){
if ($id) {
if (!is_array($id)) {
$id = explode(',', $id);
}
}
if ($notice_order_id){
if(!is_array($notice_order_id)){
if ($notice_order_id) {
if (!is_array($notice_order_id)) {
$notice_order_id = explode(',', $notice_order_id);
}
}
$data = Project::with(['deploy_build', 'deploy_optimize', 'online_check'])
->whereHas('deploy_build', function ($query) use ($plan) {
if ($plan && in_array($plan, Project::planMap())) {
$query->where('plan', array_search($plan, Project::planMap()));
}
if ($plan && in_array($plan, Project::seoMap())) {
$query->where('seo_plan', array_search($plan, Project::seoMap()));
}
})
->where('delete_status', 0)
->where(function ($query) use ($channel_id, $type, $company, $id, $notice_order_id, $start_time, $end_time){
if ($channel_id) {
$query->where('channel->channel_id', $channel_id);
}
if ($type) {
$query->where('type', $type);
}
if ($company) {
$query->where('company', 'like', '%' . $company . '%');
}
if ($id) {
$query->whereIn('id', $id);
}
if ($notice_order_id) {
$query->whereIn('notice_order_id', $notice_order_id);
}
if ($start_time && $end_time ) {
$query->whereBetween('uptime', [$start_time, $end_time]);
}
})->orderBy($order_by_field, $order_by_sort)->paginate($size)->toArray();
->where(function ($query) use ($channel_id, $type, $company, $id, $notice_order_id, $start_time, $end_time) {
if ($channel_id) {
$query->where('channel->channel_id', $channel_id);
}
if ($type) {
$query->where('type', $type);
}
if ($company) {
$query->where('company', 'like', '%' . $company . '%');
}
if ($id) {
$query->whereIn('id', $id);
}
if ($notice_order_id) {
$query->whereIn('notice_order_id', $notice_order_id);
}
if ($start_time && $end_time) {
$query->whereBetween('uptime', [$start_time, $end_time]);
}
})->orderBy($order_by_field, $order_by_sort)->paginate($size)->toArray();
$list = [];
foreach ($data['list'] as $item){
foreach ($data['list'] as $item) {
$domain = '';
if ($item['deploy_optimize']['domain']) {
$domain_pro = DomainInfo::where('id', $item['deploy_optimize']['domain'])->first();
... ... @@ -868,29 +907,31 @@ class ProjectController extends BaseController
$item['channel']['user'] = User::where('id', $item['channel']['user_id'])->value('name');
$manageHr = new ManageHr();
$param = [
"id" => $item['id'],
"title" => $item['title'],
"company" => $item['company'],
"type" => $item['extend_type'] ?: $item['type'],
"type_text" => Project::typeMap()[$item['type']] ?? '',
"channel" => $item['channel'],
"created_at" => $item['created_at'],
"updated_at" => $item['updated_at'],
"post_id" => $item['post_id'],
"from_order_id" => $item['from_order_id'],
"remain_day" => $item['remain_day'],
"last_inquiry_time" => $item['last_inquiry_time'],
"plan" => $item['deploy_build']['plan'] ?: 0,
"plan_text" => Project::planMap()[$item['deploy_build']['plan']] ?? '',
"start_date" => $item['deploy_optimize']['start_date'] ?? '',
"domain" => $domain ? 'https://' . $domain : $domain,
"test_domain" => $item['deploy_build']['test_domain'] ?? '',
"id" => $item['id'],
"title" => $item['title'],
"company" => $item['company'],
"type" => $item['extend_type'] ?: $item['type'],
"type_text" => Project::typeMap()[$item['type']] ?? '',
"channel" => $item['channel'],
"created_at" => $item['created_at'],
"updated_at" => $item['updated_at'],
"post_id" => $item['post_id'],
"from_order_id" => $item['from_order_id'],
"remain_day" => $item['remain_day'],
"last_inquiry_time" => $item['last_inquiry_time'],
"plan" => $item['deploy_build']['plan'] ?: 0,
"plan_text" => Project::planMap()[$item['deploy_build']['plan']] ?? '',
"geo_plan" => $item['deploy_build']['seo_plan'] ?: 0,
"geo_plan_text" => Project::seoMap()[$item['deploy_build']['seo_plan']] ?? '',
"start_date" => $item['deploy_optimize']['start_date'] ?? '',
"domain" => $domain ? 'https://' . $domain : $domain,
"test_domain" => $item['deploy_build']['test_domain'] ?? '',
// "online_time" => $item['online_check']['qa_check_time'] ?? '',
"online_time" => $item['uptime'] ?? '',
"cooperate_date" => $item['cooperate_date'],
"project_manager_name" => $manageHr->getName($item['deploy_build']['manager_mid']), //项目经理
"after_sales_manager_name" => $manageHr->getName($item['deploy_optimize']['manager_mid']), //售后服务经理
"leader_name" => $manageHr->getName($item['deploy_build']['leader_mid']), //组长
"online_time" => $item['uptime'] ?? '',
"cooperate_date" => $item['cooperate_date'],
"project_manager_name" => $manageHr->getName($item['deploy_build']['manager_mid']), //项目经理
"after_sales_manager_name" => $manageHr->getName($item['deploy_optimize']['manager_mid']), //售后服务经理
"leader_name" => $manageHr->getName($item['deploy_build']['leader_mid']), //组长
'version' => $item['version']
];
if ($item['type'] == Project::TYPE_TWO) {
... ... @@ -906,7 +947,8 @@ class ProjectController extends BaseController
$list[] = $param;
}
$data['list'] = $list;
$this->response('success',Code::SUCCESS, $data);
$data['plan'] = array_merge(Project::planMap(), Project::seoMap());
$this->response('success', Code::SUCCESS, $data);
}
/**
... ... @@ -916,9 +958,10 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/9/28 9:09
*/
public function getRenewLog(RenewLog $renewLog){
$lists = $renewLog->lists($this->map,$this->page,$this->row,$this->order);
$this->response('success',Code::SUCCESS,$lists);
public function getRenewLog(RenewLog $renewLog)
{
$lists = $renewLog->lists($this->map, $this->page, $this->row, $this->order);
$this->response('success', Code::SUCCESS, $lists);
}
/**
... ... @@ -928,20 +971,21 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/11/8 11:17
*/
public function tdkList(){
public function tdkList()
{
$this->request->validate([
'project_id'=>'required',
],[
'project_id' => 'required',
], [
'project_id.required' => '项目ID不能为空',
]);
$tdkModel = new ProjectUpdateTdk();
$list = $tdkModel->list(['project_id'=>$this->map['project_id']],'id',['*'],'desc',5);
if(!empty($list)){
foreach ($list as $k => $v){
$list = $tdkModel->list(['project_id' => $this->map['project_id']], 'id', ['*'], 'desc', 5);
if (!empty($list)) {
foreach ($list as $k => $v) {
$list[$k] = $this->handleTdk($v);
}
}
$this->response('success',Code::SUCCESS,$list);
$this->response('success', Code::SUCCESS, $list);
}
/**
... ... @@ -951,28 +995,29 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/12/29 11:16
*/
public function handleTdk($item){
public function handleTdk($item)
{
$data = [
'gl_product'=>'产品',
'gl_product_category'=>'产品分类',
'gl_product_keyword'=>'产品关键字',
'gl_news'=>'新闻',
'gl_news_category'=>'新闻分类',
'gl_blog'=>'博客',
'gl_blog_category'=>'博客分类',
'gl_web_custom_template'=>'自定义页面',
'gl_product' => '产品',
'gl_product_category' => '产品分类',
'gl_product_keyword' => '产品关键字',
'gl_news' => '新闻',
'gl_news_category' => '新闻分类',
'gl_blog' => '博客',
'gl_blog_category' => '博客分类',
'gl_web_custom_template' => '自定义页面',
];
foreach ($data as $k => $v){
if(isset($item[$k])){
foreach ($data as $k => $v) {
if (isset($item[$k])) {
$data = Arr::s2a($item[$k]);
//{"des": 3500, "title": 0, "keyword": 3501, "total_page": 8458, "keyword_title": 3500, "keyword_content": 3500}
$item[$k] = $v.'总条数:'.$data['total_page'].
', title更新数:'.$data['title'].
',keyword更新数:'.$data['keyword'].
',des更新数:'.$data['des'];
if($k == 'gl_product_keyword'){
$item[$k] .= ',keyword_title更新数:'.($data['keyword_title']??0);
$item[$k] .= ',keyword_content更新数:'.($data['keyword_content']??0);
$item[$k] = $v . '总条数:' . $data['total_page'] .
', title更新数:' . $data['title'] .
',keyword更新数:' . $data['keyword'] .
',des更新数:' . $data['des'];
if ($k == 'gl_product_keyword') {
$item[$k] .= ',keyword_title更新数:' . ($data['keyword_title'] ?? 0);
$item[$k] .= ',keyword_content更新数:' . ($data['keyword_content'] ?? 0);
}
}
... ... @@ -987,14 +1032,15 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/11/8 14:17
*/
public function copyProject(ProjectLogic $logic){
public function copyProject(ProjectLogic $logic)
{
$this->request->validate([
'project_id'=>'required',
],[
'project_id' => 'required',
], [
'project_id.required' => 'project_id不能为空',
]);
$data = $logic->copyProject();
$this->response('success',Code::SUCCESS,$data);
$this->response('success', Code::SUCCESS, $data);
}
/**
... ... @@ -1002,14 +1048,15 @@ class ProjectController extends BaseController
* @author zbj
* @date 2023/11/10
*/
public function site_token(ProjectLogic $logic){
public function site_token(ProjectLogic $logic)
{
$this->request->validate([
'project_id'=>'required',
],[
'project_id' => 'required',
], [
'project_id.required' => 'project_id不能为空',
]);
$token = $logic->getSiteToken($this->map);
$this->response('success',Code::SUCCESS,['site_token' => $token]);
$this->response('success', Code::SUCCESS, ['site_token' => $token]);
}
/**
... ... @@ -1019,12 +1066,13 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/11/17 15:23
*/
public function saveOtherProject(ProjectLogic $logic){
public function saveOtherProject(ProjectLogic $logic)
{
$this->request->validate([
'id'=>'required',
'aicc'=>'required',
'hagro'=>'required',
],[
'id' => 'required',
'aicc' => 'required',
'hagro' => 'required',
], [
'id.required' => 'id不能为空',
'aicc.required' => 'aicc是否开启不能为空',
'hagro.required' => 'hagro是否开启不能为空',
... ... @@ -1040,14 +1088,15 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/11/17 15:23
*/
public function getOtherProject(ProjectLogic $logic){
public function getOtherProject(ProjectLogic $logic)
{
$this->request->validate([
'id'=>'required',
],[
'id' => 'required',
], [
'id.required' => 'id不能为空',
]);
$info = $logic->getOtherProject();
$this->response('success',Code::SUCCESS,$info);
$this->response('success', Code::SUCCESS, $info);
}
/**
... ... @@ -1057,20 +1106,21 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/11/17 16:08
*/
public function getChannel(){
public function getChannel()
{
$zoneModel = new Zone();
$zone_list = $zoneModel->list();
$channelModel = new Channel();
$channelUserModel = new User();
foreach ($zone_list as $k => $v){
$channel_list = $channelModel->list(['zone_id'=>$v['id']]);
foreach ($channel_list as $k1 => $v1){
$user_list = $channelUserModel->list(['channel_id'=>$v1['id']]);
foreach ($zone_list as $k => $v) {
$channel_list = $channelModel->list(['zone_id' => $v['id']]);
foreach ($channel_list as $k1 => $v1) {
$user_list = $channelUserModel->list(['channel_id' => $v1['id']]);
$channel_list[$k1]['sub'] = $user_list;
}
$zone_list[$k]['sub'] = $channel_list;
}
$this->response('success',Code::SUCCESS,$zone_list);
$this->response('success', Code::SUCCESS, $zone_list);
}
/**
... ... @@ -1080,10 +1130,11 @@ class ProjectController extends BaseController
* @method :post
* @time :2023/11/30 10:59
*/
public function languageLists(){
public function languageLists()
{
$webLanguageModel = new WebLanguage();
$lists = $webLanguageModel->list();
$this->response('success',Code::SUCCESS,$lists);
$this->response('success', Code::SUCCESS, $lists);
}
/**
... ... @@ -1091,8 +1142,9 @@ class ProjectController extends BaseController
* @author zbj
* @date 2024/1/19
*/
public function countryLists(){
$this->response('success',Code::SUCCESS, Country::getCountryList());
public function countryLists()
{
$this->response('success', Code::SUCCESS, Country::getCountryList());
}
/**
... ... @@ -1100,10 +1152,11 @@ class ProjectController extends BaseController
* @author zbj
* @date 2024/1/19
*/
public function saveInquiryFilterConfig(ProjectLogic $logic){
public function saveInquiryFilterConfig(ProjectLogic $logic)
{
$this->request->validate([
'project_id'=>'required',
],[
'project_id' => 'required',
], [
'project_id.required' => '项目id不能为空',
]);
$logic->saveInquiryFilterConfig($this->param);
... ... @@ -1115,10 +1168,11 @@ class ProjectController extends BaseController
* @author zbj
* @date 2024/3/29
*/
public function saveWebTrafficConfig(ProjectLogic $logic){
public function saveWebTrafficConfig(ProjectLogic $logic)
{
$this->request->validate([
'project_id'=>'required',
],[
'project_id' => 'required',
], [
'project_id.required' => '项目id不能为空',
]);
$logic->saveWebTrafficConfig($this->param);
... ... @@ -1132,28 +1186,29 @@ class ProjectController extends BaseController
* @method :post
* @time :2024/4/7 10:41
*/
public function updateProjectManager(ProjectLogic $logic){
public function updateProjectManager(ProjectLogic $logic)
{
$this->request->validate([
'old_id'=>'required',
'new_id'=>'required'
],[
'old_id' => 'required',
'new_id' => 'required'
], [
'old_id.required' => '参数不能为空',
'new_id.required' => '参数不能为空',
]);
//查看当前用户是否存在
$hrModel = new ManageHr();
$oldHrInfo = $hrModel->read(['id'=>$this->param['old_id']]);
if($oldHrInfo === false){
$this->response('当前用户不存在',Code::SYSTEM_ERROR);
$oldHrInfo = $hrModel->read(['id' => $this->param['old_id']]);
if ($oldHrInfo === false) {
$this->response('当前用户不存在', Code::SYSTEM_ERROR);
}
$newHrInfo = $hrModel->read(['id'=>$this->param['new_id'],'status'=>1]);
if($newHrInfo === false){
$this->response('变更的用户不存在',Code::SYSTEM_ERROR);
$newHrInfo = $hrModel->read(['id' => $this->param['new_id'], 'status' => 1]);
if ($newHrInfo === false) {
$this->response('变更的用户不存在', Code::SYSTEM_ERROR);
}
if($oldHrInfo['entry_position'] != $newHrInfo['entry_position']){
$this->response('不同岗位不允许变更',Code::SYSTEM_ERROR);
if ($oldHrInfo['entry_position'] != $newHrInfo['entry_position']) {
$this->response('不同岗位不允许变更', Code::SYSTEM_ERROR);
}
$logic->getManagerFiled($newHrInfo['entry_position'],$this->param['old_id'],$this->param['new_id'],$this->param['project_id'] ?? []);
$logic->getManagerFiled($newHrInfo['entry_position'], $this->param['old_id'], $this->param['new_id'], $this->param['project_id'] ?? []);
$this->response('success');
}
... ... @@ -1164,16 +1219,17 @@ class ProjectController extends BaseController
* @method :post
* @time :2024/6/19 10:07
*/
public function setIsParticiple(){
public function setIsParticiple()
{
$this->request->validate([
'project_id'=>'required',
'is_participle'=>'required'
],[
'project_id' => 'required',
'is_participle' => 'required'
], [
'project_id.required' => '项目id不能为空',
'is_participle.required' => '项目id不能为空',
]);
$deployBuildModel = new DeployBuild();
$deployBuildModel->edit(['is_participle'=>$this->param['is_participle']],['project_id'=>$this->param['project_id']]);
$deployBuildModel->edit(['is_participle' => $this->param['is_participle']], ['project_id' => $this->param['project_id']]);
$this->response('success');
}
... ... @@ -1185,54 +1241,55 @@ class ProjectController extends BaseController
* @method :post
* @time :2024/7/29 17:12
*/
public function saveSiteStatus(){
public function saveSiteStatus()
{
$this->request->validate([
'id'=>'required',
'site_status'=>'required'
],[
'id' => 'required',
'site_status' => 'required'
], [
'id.required' => '项目id不能为空',
'site_status.required' => '状态不能为空',
]);
//获取项目数据
$projectModel = new Project();
$projectInfo = $projectModel->read(['id'=>$this->param['id']],['project_type','serve_id','site_status','site_token']);
if(!$projectInfo){
$projectInfo = $projectModel->read(['id' => $this->param['id']], ['project_type', 'serve_id', 'site_status', 'site_token']);
if (!$projectInfo) {
$this->fail('获取项目数据失败');
}
if($projectInfo['site_status'] == $this->param['site_status']){
if ($projectInfo['site_status'] == $this->param['site_status']) {
$this->response('success');
}
//获取服务器数据
$serverIpModel = new ServersIp();
$serversIpInfo = $serverIpModel->read(['id' => $projectInfo['serve_id']], ['servers_id']);
if(!$serversIpInfo){
if (!$serversIpInfo) {
$this->fail('获取项目所属服务器失败');
}
if($serversIpInfo['servers_id'] == ServerConfig::SELF_SITE_ID){
if ($serversIpInfo['servers_id'] == ServerConfig::SELF_SITE_ID) {
//自建站项目
if($this->param['site_status'] == 1){
if ($this->param['site_status'] == 1) {
//关闭站点
$site_token = $projectInfo['site_token'] ? $projectInfo['site_token'].'_expired' : '';
}else{
$site_token = $projectInfo['site_token'] ? $projectInfo['site_token'] . '_expired' : '';
} else {
//开启站点
$site_token = str_replace('_expired','',$projectInfo['site_token']);
$site_token = str_replace('_expired', '', $projectInfo['site_token']);
}
$projectModel->edit(['site_status'=>$this->param['site_status'],'site_token'=>$site_token],['id'=>$this->param['id']]);
}else{
$projectModel->edit(['site_status' => $this->param['site_status'], 'site_token' => $site_token], ['id' => $this->param['id']]);
} else {
//普通项目
//获取域名数据
$domainModel = new DomainInfoModel();
$domainInfo = $domainModel->read(['project_id'=>$this->param['id']],['id','domain','amp_status']);
if(!$domainInfo){
$domainInfo = $domainModel->read(['project_id' => $this->param['id']], ['id', 'domain', 'amp_status']);
if (!$domainInfo) {
$this->fail('获取域名数据失败');
}
if($this->param['site_status'] == 1){
if ($this->param['site_status'] == 1) {
//关闭站点:通知C端
$re = curl_get('https://'.$domainInfo['domain'].'/api/stop_or_start_website');
if(isset($re['status']) && $re['status'] !== 200){
$re = curl_get('https://' . $domainInfo['domain'] . '/api/stop_or_start_website');
if (isset($re['status']) && $re['status'] !== 200) {
$this->fail($re['message']);
}
}else{
} else {
//开启站点:创建建站任务
if ($projectInfo['project_type'] == Project::PROJECT_TYPE_SEO) {
$type = DomainCreateTask::TYPE_BLOG;
... ... @@ -1253,7 +1310,7 @@ class ProjectController extends BaseController
]);
}
if($domainInfo['amp_status']){
if ($domainInfo['amp_status']) {
$task_info_amp = $domainCreateTaskModel->read(['type' => DomainCreateTask::TYPE_AMP, 'domain_id' => $domainInfo['id'], 'is_open' => DomainCreateTask::IS_OPEN, 'status' => ['<', DomainCreateTask::STATUS_SUC]], ['id']);
if (!$task_info_amp) {
$domainCreateTaskModel->add([
... ... @@ -1266,7 +1323,7 @@ class ProjectController extends BaseController
}
}
}
$projectModel->edit(['site_status'=>$this->param['site_status']],['id'=>$this->param['id']]);
$projectModel->edit(['site_status' => $this->param['site_status']], ['id' => $this->param['id']]);
}
$this->response('success');
}
... ... @@ -1290,15 +1347,16 @@ class ProjectController extends BaseController
* @method :post
* @time :2025/6/10 10:51
*/
public function generateCountCharts(){
public function generateCountCharts()
{
$this->request->validate([
'project_id'=>'required',
],[
'project_id' => 'required',
], [
'project_id.required' => '项目id不能为空',
]);
$noticeModel = new NoticeLog();
$info = $noticeModel->read(['type'=>NoticeLog::TYPE_GENERATE_COUNT_CHARTS,'status'=>0,'data'=>['like','%"'.$this->param['project_id'].'"%']]);
if($info !== false){
$info = $noticeModel->read(['type' => NoticeLog::TYPE_GENERATE_COUNT_CHARTS, 'status' => 0, 'data' => ['like', '%"' . $this->param['project_id'] . '"%']]);
if ($info !== false) {
$this->fail('当前数据在生成中');
}
NoticeLog::createLog(NoticeLog::TYPE_GENERATE_COUNT_CHARTS, ['project_id' => $this->param['project_id']]);
... ... @@ -1312,16 +1370,17 @@ class ProjectController extends BaseController
* @method :post
* @time :2025/7/2 11:04
*/
public function updateTdk(){
public function updateTdk()
{
$this->request->validate([
'project_id'=>'required',
'url'=>'required'
],[
'project_id' => 'required',
'url' => 'required'
], [
'project_id.required' => '项目id不能为空',
'url.required' => '文件路径不为空',
]);
NoticeLog::createLog(NoticeLog::TYPE_UPDATE_PROJECT_TDK, ['project_id' => $this->param['project_id'],'url'=>$this->param['url']]);
$this->response('success',Code::SUCCESS,['url'=>$this->param['url']]);
NoticeLog::createLog(NoticeLog::TYPE_UPDATE_PROJECT_TDK, ['project_id' => $this->param['project_id'], 'url' => $this->param['url']]);
$this->response('success', Code::SUCCESS, ['url' => $this->param['url']]);
}
/**
... ... @@ -1331,11 +1390,12 @@ class ProjectController extends BaseController
* @method :post
* @time :2025/8/5 9:50
*/
public function videoSetting(){
public function videoSetting()
{
$videoModel = new AiVideoTask();
$data['videoSetting'] = $videoModel->videoSetting();
$data['videoFrequency'] =$videoModel->videoFrequency();
$this->response('success',Code::SUCCESS,$data);
$data['videoFrequency'] = $videoModel->videoFrequency();
$this->response('success', Code::SUCCESS, $data);
}
/**
... ...
... ... @@ -9,10 +9,8 @@
namespace App\Http\Logic\Aside\Geo;
use App\Enums\Common\Code;
use App\Http\Logic\Aside\BaseLogic;
use App\Models\Geo\GeoConf;
use App\Models\Geo\GeoQuestion;
use App\Models\Manage\ManageHr;
use App\Models\Project\KeywordPrefix;
use App\Models\Project\Project;
... ...
... ... @@ -49,9 +49,7 @@ class GeoWritingsLogic extends BaseLogic
*/
public function saveWriting(){
try {
$this->param['content_length'] = strlen($this->param['content']);
$this->param['confirm_ip'] = $this->request->ip();
$this->param['confirm_at'] = date('Y-m-d H:i:s');
$this->param['status'] = GeoWritings::STATUS_INIT;
if(isset($this->param['id']) &&!empty($this->param['id'])){
$id = $this->param['id'];
$this->model->edit($this->param,['id'=>$id]);
... ... @@ -80,4 +78,18 @@ class GeoWritingsLogic extends BaseLogic
}
return $this->success();
}
/**
* @remark :推送微信
* @name :sendWechatMessage
* @author :lyh
* @method :post
* @time :2025/10/28 10:15
*/
public function sendWechatMessage()
{
$this->model->edit(['status'=>2],['status'=>1,'project_id'=>$this->param['project_id']]);
GeoWritings::sendConfirmMessage($this->param['project_id']);
return $this->success();
}
}
... ...
... ... @@ -225,9 +225,7 @@ class NewsLogic extends BaseLogic
if(isset($param['related_product_id'])){
$param['related_product_id'] = implode(',',$param['related_product_id']);
}
if(!isset($param['seo_title']) || empty($param['seo_title'])){
$param['seo_title'] = truncate_text($param['name'],70);
}
$param['seo_title'] = truncate_text($param['seo_title'] ?? $param['name'],70);
return $this->success($param);
}
... ...
... ... @@ -26,7 +26,7 @@ class NewsRequest extends FormRequest
return [
'name'=>'required|max:200',
'url'=>'required',
'seo_title' => 'max:70',
// 'seo_title' => 'max:70',
'seo_keywords' => 'max:300',
'seo_description' => 'max:200',
];
... ... @@ -38,7 +38,7 @@ class NewsRequest extends FormRequest
'name.required'=>'请填写名称',
'name.max'=>'名称超过最长长度200',
'url.required'=>'链接不能为空',
'seo_title.max' => 'SEO标题不能超过70个字符',
// 'seo_title.max' => 'SEO标题不能超过70个字符',
'seo_keywords.max' => 'SEO关键词不能超过300个字符',
'seo_description.max' => 'SEO描述不能超过200个字符',
];
... ...
... ... @@ -84,7 +84,7 @@ class RouteMap extends Base
}
$length = strlen($sign);
if($length > $route_len){
$sign = trim(mb_substr($sign, 0, $route_len, 'UTF-8'),'-');
$sign = truncate_text($sign,$route_len);
}
$i=1;//路由重复时拼接
$route = $sign.$suffix;
... ...
... ... @@ -113,5 +113,7 @@ Route::prefix('geo')->group(function () {
Route::any('/getWritingsList', [\App\Http\Controllers\Api\GeoController::class, 'getWritingsList'])->name('geo.getWritingsList');//确认文章数据
Route::any('/getWritingsDetail', [\App\Http\Controllers\Api\GeoController::class, 'getWritingsDetail'])->name('geo.getWritingsDetail');//文章数据详情
Route::any('/saveConfirm', [\App\Http\Controllers\Api\GeoController::class, 'saveConfirm'])->name('geo.saveConfirm');//保存用户确认信息
Route::any('/getWritingsList', [\App\Http\Controllers\Api\GeoController::class, 'getWritingsList'])->name('geo.getWritingsList');//文章确认列表
Route::any('/confirmWritings', [\App\Http\Controllers\Api\GeoController::class, 'confirmWritings'])->name('geo.confirmWritings');//确认文章信息
});
... ...
... ... @@ -600,12 +600,14 @@ Route::middleware(['aloginauth'])->group(function () {
Route::any('/', [Aside\Geo\GeoWritingTaskController::class, 'lists'])->name('admin.geo_writing_task_lists');
Route::any('/saveWritingTask', [Aside\Geo\GeoWritingTaskController::class, 'saveWritingTask'])->name('admin.geo_writing_task_saveWritingTask');
Route::any('/delWritingTask', [Aside\Geo\GeoWritingTaskController::class, 'delWritingTask'])->name('admin.geo_writing_task_delWritingTask');
Route::any('/sendAiTitle', [Aside\Geo\GeoWritingTaskController::class, 'sendAiTitle'])->name('admin.geo_writing_task_sendAiTitle');
});
//geo文章管理
Route::prefix('writing')->group(function () {
Route::any('/', [Aside\Geo\GeoWritingsController::class, 'lists'])->name('admin.geo_writing_task');
Route::any('/saveWriting', [Aside\Geo\GeoWritingsController::class, 'saveWriting'])->name('admin.geo_writing_saveWriting');
Route::any('/delWriting', [Aside\Geo\GeoWritingsController::class, 'delWriting'])->name('admin.geo_writing_delWriting');
Route::any('/sendWechatMessage', [Aside\Geo\GeoWritingsController::class, 'sendWechatMessage'])->name('admin.geo_writing_sendWechatMessage');
});
});
// 任务相关
... ...