|
...
|
...
|
@@ -149,11 +149,16 @@ class ProjectUpdate extends Command |
|
|
|
if ($v_phone) {
|
|
|
|
$receiving_phones = $model->read(['type' => 2, 'values' => $v_phone]);
|
|
|
|
if (!$receiving_phones) {
|
|
|
|
$model->add([
|
|
|
|
'type' => 1,
|
|
|
|
'values' => $v_phone,
|
|
|
|
'project_id' => $project_id
|
|
|
|
]);
|
|
|
|
try {
|
|
|
|
$model->add([
|
|
|
|
'type' => 2,
|
|
|
|
'values' => $v_phone,
|
|
|
|
'project_id' => $project_id
|
|
|
|
]);
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
...
|
...
|
@@ -164,11 +169,16 @@ class ProjectUpdate extends Command |
|
|
|
if ($v_email) {
|
|
|
|
$receiving_emails = $model->read(['type' => 1, 'values' => $v_email]);
|
|
|
|
if (!$receiving_emails) {
|
|
|
|
$model->add([
|
|
|
|
'type' => 2,
|
|
|
|
'values' => $v_email,
|
|
|
|
'project_id' => $project_id
|
|
|
|
]);
|
|
|
|
try {
|
|
|
|
$model->add([
|
|
|
|
'type' => 1,
|
|
|
|
'values' => $v_email,
|
|
|
|
'project_id' => $project_id
|
|
|
|
]);
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
...
|
...
|
@@ -207,13 +217,16 @@ class ProjectUpdate extends Command |
|
|
|
$category_id = '';
|
|
|
|
if ($item['category'] ?? []) {
|
|
|
|
$category_arr = [];
|
|
|
|
foreach ($item['category'] as $cate) {
|
|
|
|
if ($cate['parent'] == 0) {
|
|
|
|
array_unshift($category_arr, $cate['name']);
|
|
|
|
} else {
|
|
|
|
array_push($category_arr, $cate['name']);
|
|
|
|
|
|
|
|
$pid = 0;
|
|
|
|
for ($i = 0; $i < count($item['category']); $i++) {
|
|
|
|
$return = $this->get_category_name_arr($item['category'], $pid);
|
|
|
|
if ($return) {
|
|
|
|
$category_arr[] = $return['name'];
|
|
|
|
$pid = $return['id'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($category_arr) {
|
|
|
|
$categoryLogic = new CategoryLogic();
|
|
|
|
$category_id = $categoryLogic->importProductCategory($project_id, implode('/', $category_arr));
|
|
...
|
...
|
@@ -405,15 +418,20 @@ class ProjectUpdate extends Command |
|
|
|
if ($item['name'] ?? '') {
|
|
|
|
$parent = $model->read(['pid' => $pid, 'title' => $item['name']], 'id');
|
|
|
|
if (!$parent) {
|
|
|
|
$parent_id = $model->addReturnId([
|
|
|
|
'project_id' => $project_id,
|
|
|
|
'title' => $item['name'],
|
|
|
|
'pid' => $pid,
|
|
|
|
'keywords' => $item['keywords'] ?? '',
|
|
|
|
'describe' => $item['description'] ?? ''
|
|
|
|
]);
|
|
|
|
$route = RouteMap::setRoute($item['url'] ? $this->get_url_route($item['url']) : $item['name'], RouteMap::SOURCE_PRODUCT_CATE, $parent_id, $project_id);
|
|
|
|
$model->edit(['route' => $route], ['id' => $parent_id]);
|
|
|
|
try {
|
|
|
|
$parent_id = $model->addReturnId([
|
|
|
|
'project_id' => $project_id,
|
|
|
|
'title' => $item['name'],
|
|
|
|
'pid' => $pid,
|
|
|
|
'keywords' => $item['keywords'] ?? '',
|
|
|
|
'describe' => $item['description'] ?? ''
|
|
|
|
]);
|
|
|
|
$route = RouteMap::setRoute($item['url'] ? $this->get_url_route($item['url']) : $item['name'], RouteMap::SOURCE_PRODUCT_CATE, $parent_id, $project_id);
|
|
|
|
$model->edit(['route' => $route], ['id' => $parent_id]);
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
echo 'date:' . date('Y-m-d H:i:s') . ', category_insert error: ' . $e->getMessage() . PHP_EOL;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$parent_id = $parent['id'];
|
|
|
|
}
|
|
...
|
...
|
@@ -424,4 +442,16 @@ class ProjectUpdate extends Command |
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//获取分类名称数组
|
|
|
|
protected function get_category_name_arr($category, $pid = 0)
|
|
|
|
{
|
|
|
|
foreach ($category as $k => $v) {
|
|
|
|
if ($v['parent'] == $pid) {
|
|
|
|
return $v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|