|
...
|
...
|
@@ -56,65 +56,99 @@ class FetchTicketProjects extends Command |
|
|
|
*/
|
|
|
|
public function fetchV5()
|
|
|
|
{
|
|
|
|
# pm 项目经理 assm 售后服务经理
|
|
|
|
$response = Http::get('https://www.quanqiusou.cn/extend_api/webs/globalso_all.php');
|
|
|
|
if ($response->status() == 200) {
|
|
|
|
$items = $response->json();
|
|
|
|
foreach ($items as $item) {
|
|
|
|
# V5: 版本号+postid
|
|
|
|
$uuid = md5("V5{$item['postid']}");
|
|
|
|
$project = TicketProject::where('uuid', $uuid)->first();
|
|
|
|
$assm_id = Manage::where('name', $item['assm'])->value('id') ?? Manage::where('name', '张鸿飞')->value('id') ?? 0; //售后服务经理
|
|
|
|
$seom_id = Manage::where('name', $item['yhs'])->value('id') ?? Manage::where('name', '陶婵')->value('id') ?? 0; //优化师
|
|
|
|
// 如果 $item['cate'] 包含”推广“字符,则 $engineer_name = $item['assm']
|
|
|
|
/**
|
|
|
|
* 第一负责人逻即说明:
|
|
|
|
* 优化推广项目:找售后服务经理??鸿飞
|
|
|
|
* 建站类项目: 找杨长远
|
|
|
|
*/
|
|
|
|
$engineer_id = (strpos($item['cate'], '推广') !== false) ? $assm_id : Manage::where('name', '杨长远')->value('id') ?? 0;
|
|
|
|
$page = 1;
|
|
|
|
$postids = [];
|
|
|
|
|
|
|
|
$fields = [
|
|
|
|
'post_id' => $item['postid'],
|
|
|
|
'company_name' => $item['company'],
|
|
|
|
'title' => $item['title'],
|
|
|
|
'engineer_id' => $engineer_id, // 第一负责人
|
|
|
|
'assm_id' => $assm_id,
|
|
|
|
'seom_id' => $seom_id,
|
|
|
|
'website' => $item['main_url'] ?? '',
|
|
|
|
'test_website' => $item['test_url'] ?? '',
|
|
|
|
'is_del' => 0,
|
|
|
|
'plan' => $item['plan'] ?? '',
|
|
|
|
'project_cate' => 1,
|
|
|
|
];
|
|
|
|
if (!$project) {
|
|
|
|
$new = new TicketProject();
|
|
|
|
$new->uuid = $uuid;
|
|
|
|
$new->version = 5;
|
|
|
|
$new->table_id = 0;
|
|
|
|
foreach ($fields as $k => $v) {
|
|
|
|
$new->$k = $v;
|
|
|
|
}
|
|
|
|
$new->save();
|
|
|
|
} else {
|
|
|
|
$changed = false;
|
|
|
|
foreach ($fields as $k => $v) {
|
|
|
|
if ($project->$k != $v) {
|
|
|
|
$project->$k = $v;
|
|
|
|
$changed = true;
|
|
|
|
while (true) {
|
|
|
|
$response = Http::get('https://www.quanqiusou.cn/extend_api/webs/globalso_all.php?page=' . $page);
|
|
|
|
if ($response->status() == 200) {
|
|
|
|
$resp_json = $response->json();
|
|
|
|
$items = $resp_json['data'] ?? [];
|
|
|
|
if (empty($items))
|
|
|
|
{
|
|
|
|
echo now() . " | INFO | V5: not found items on page $page \n";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
foreach ($items as $item) {
|
|
|
|
# V5: 版本号+postid
|
|
|
|
$uuid = md5("V5{$item['postid']}");
|
|
|
|
$project = TicketProject::where('uuid', $uuid)->first();
|
|
|
|
|
|
|
|
// 项目状态, 根据 $item['cate'] 判断,建站中,建站客户,推广
|
|
|
|
if (strpos($item['cate'], '推广') !== false)
|
|
|
|
$status=3; // 推广
|
|
|
|
elseif ($item['cate'] == "建站客户")
|
|
|
|
$status=2; // 建站客户
|
|
|
|
elseif ($item['cate'] == "建站中")
|
|
|
|
$status=1; // 建站中
|
|
|
|
|
|
|
|
$assm_id = Manage::where('name', $item['assm'])->value('id') ?? Manage::where('name', '张鸿飞')->value('id') ?? 0; //售后服务经理
|
|
|
|
$seom_id = Manage::where('name', $item['yhs'])->value('id') ?? Manage::where('name', '陶婵')->value('id') ?? 0; //优化师
|
|
|
|
$pm_id = Manage::where('name', $item['pm'])->value('id') ?? Manage::where('name', '李洁玉')->value('id') ?? 0; // 项目经理
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 第一负责人逻即说明:
|
|
|
|
* 优化推广项目:找售后服务经理??鸿飞
|
|
|
|
* 建站中:项目经理
|
|
|
|
* 建站完成:杨长远
|
|
|
|
*/
|
|
|
|
|
|
|
|
if ($status == 3)
|
|
|
|
$engineer_id = $assm_id; // 推广类项目找售后服务经理
|
|
|
|
elseif ($status == 2)
|
|
|
|
$engineer_id = Manage::where('name', '杨长远')->value('id') ?? 0; //建站完成
|
|
|
|
elseif ($status == 1)
|
|
|
|
$engineer_id = $pm_id; // 建站中找项目经理
|
|
|
|
|
|
|
|
$fields = [
|
|
|
|
'post_id' => $item['postid'],
|
|
|
|
'company_name' => $item['company'],
|
|
|
|
'title' => $item['title'] . " - V5",
|
|
|
|
'engineer_id' => $engineer_id, // 第一负责人
|
|
|
|
'assm_id' => $assm_id,
|
|
|
|
'seom_id' => $seom_id,
|
|
|
|
'website' => $item['main_url'] ?? '',
|
|
|
|
'test_website' => $item['test_url'] ?? '',
|
|
|
|
'is_del' => 0,
|
|
|
|
'plan' => $item['plan'] ?? '',
|
|
|
|
'project_cate' => 1,
|
|
|
|
'pm_id' => $pm_id,
|
|
|
|
'status' => $status, // 项目状态
|
|
|
|
'wechat_group_id' => $item['wx_id']
|
|
|
|
];
|
|
|
|
if (!$project) {
|
|
|
|
$new = new TicketProject();
|
|
|
|
$new->uuid = $uuid;
|
|
|
|
$new->version = 5;
|
|
|
|
$new->table_id = 0;
|
|
|
|
foreach ($fields as $k => $v) {
|
|
|
|
$new->$k = $v;
|
|
|
|
}
|
|
|
|
$new->save();
|
|
|
|
} else {
|
|
|
|
$changed = false;
|
|
|
|
foreach ($fields as $k => $v) {
|
|
|
|
if ($project->$k != $v) {
|
|
|
|
$project->$k = $v;
|
|
|
|
$changed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($changed) {
|
|
|
|
$project->save();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($changed) {
|
|
|
|
$project->save();
|
|
|
|
}
|
|
|
|
echo now() . " | INFO | V5: {$item['postid']} {$item['company']} fetch ok \n";
|
|
|
|
}
|
|
|
|
$page++;
|
|
|
|
$postids = array_merge($postids, collect($items)->pluck('postid')->toArray());
|
|
|
|
}
|
|
|
|
$postids = collect($items)->pluck('postid')->toArray();
|
|
|
|
}
|
|
|
|
if ($postids)
|
|
|
|
{
|
|
|
|
// 软删除 gl_ticket_projects 中不存在的项目
|
|
|
|
TicketProject::where('version', 5)
|
|
|
|
->whereNotIn('post_id', $postids)
|
|
|
|
->update(['is_del' => 1]);
|
|
|
|
echo date("Y-m-d H:i:s") . " V5: fetch completed, total " . count($items) . " items\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -142,26 +176,35 @@ class FetchTicketProjects extends Command |
|
|
|
foreach ($items as $item) {
|
|
|
|
$uuid = md5("V6{$item->id}");
|
|
|
|
$project = TicketProject::where('uuid', $uuid)->first();
|
|
|
|
// 项目状态
|
|
|
|
if ($item->type == Project::TYPE_ONE)
|
|
|
|
$status = 1; // 建站中
|
|
|
|
elseif ($item->type == Project::TYPE_THREE)
|
|
|
|
$status = 2; // 建站完成
|
|
|
|
else
|
|
|
|
$status = 3; // 推广找售后服务经理
|
|
|
|
|
|
|
|
// 售后服务经理
|
|
|
|
$assm_id = collect([
|
|
|
|
ManageHr::find($item->deploy_optimize->manager_mid)->manage_id ?? 0,
|
|
|
|
ManageHr::find($item->deploy_optimize->tech_leader)->manage_id ?? 0,
|
|
|
|
8, //张鸿飞
|
|
|
|
])->first(fn($v) => $v !== null && $v !== 0, 0);
|
|
|
|
|
|
|
|
// 优化师
|
|
|
|
$optimist_mid = ManageHr::find($item->deploy_optimize->optimist_mid) ? ManageHr::find($item->deploy_optimize->optimist_mid)->manage_id : 0;
|
|
|
|
$seom_id = $optimist_mid ? $optimist_mid : $assm_id;
|
|
|
|
/**
|
|
|
|
* 第一负责人逻辑
|
|
|
|
* 建站类项目:找杨长远
|
|
|
|
* 推广类:找售后
|
|
|
|
*/
|
|
|
|
if ($item->type == Project::TYPE_THREE) {
|
|
|
|
$engineer_id = Manage::where('name', '杨长远')->value('id') ?? 0; // 建站类项目找杨长远
|
|
|
|
}else {
|
|
|
|
// 其他找售后服务经理
|
|
|
|
$engineer_id = $assm_id;
|
|
|
|
}
|
|
|
|
$seom_id = ManageHr::find($item->deploy_optimize->optimist_mid) ? ManageHr::find($item->deploy_optimize->optimist_mid)->manage_id : 0;
|
|
|
|
|
|
|
|
// 项目经理
|
|
|
|
$pm_id = ManageHr::find($item->deploy_build->manager_mid)->manage_id ?? ManageHr::where('name', '李洁玉')->value('manage_id') ?? 0;
|
|
|
|
|
|
|
|
// 第一负责人
|
|
|
|
if ($status == 1)
|
|
|
|
$engineer_id = $pm_id; // 建站中找项目经理
|
|
|
|
elseif ($status == 2)
|
|
|
|
$engineer_id = Manage::where('name', '杨长远')->value('id') ?? 0; // 建站完成找杨长远
|
|
|
|
else
|
|
|
|
$engineer_id = $assm_id; // 推广找售后服务经理
|
|
|
|
|
|
|
|
$is_del = (
|
|
|
|
$item->extend_type == 5
|
|
|
|
|| $item->type == 8
|
|
...
|
...
|
@@ -171,7 +214,7 @@ class FetchTicketProjects extends Command |
|
|
|
|
|
|
|
$fields = [
|
|
|
|
'company_name' => $item->company,
|
|
|
|
'title' => $item->title,
|
|
|
|
'title' => $item->title . " - V6",
|
|
|
|
'assm_id' => $assm_id,
|
|
|
|
'seom_id' => $seom_id,
|
|
|
|
'engineer_id' => $engineer_id,
|
|
...
|
...
|
@@ -181,10 +224,12 @@ class FetchTicketProjects extends Command |
|
|
|
'version' => empty($item->version) ? 7 : $item->version, // 版本号
|
|
|
|
'plan' => $item->planMap()[$item->deploy_build->plan] ?? '',
|
|
|
|
'project_cate' => 2,
|
|
|
|
'wechat_group_id' => ProjectAssociation::where('project_id', $project->table_id)
|
|
|
|
'wechat_group_id' => ProjectAssociation::where('project_id', $item->id)
|
|
|
|
->where('status', ProjectAssociation::STATUS_NORMAL)
|
|
|
|
->where('binding_app', ProjectAssociation::ENTERPRISE_WECHAT)
|
|
|
|
->value('friend_id')
|
|
|
|
->value('friend_id'),
|
|
|
|
'pm_id' => $pm_id,
|
|
|
|
'status' => $status, // 项目状态
|
|
|
|
];
|
|
|
|
if (!$project) {
|
|
|
|
$project = new TicketProject();
|
...
|
...
|
|