作者 刘锟

update

... ... @@ -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,7 +217,7 @@ class ProjectUpdate extends Command
$category_id = '';
if ($item['category'] ?? []) {
$category_arr = [];
$pid = 0;
for ($i = 0; $i < count($item['category']); $i++) {
$return = $this->get_category_name_arr($item['category'], $pid);
... ... @@ -408,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'];
}
... ...