|
|
@ -87,7 +87,7 @@ class Category extends Controller |
|
|
|
return $this->renderError($model->getError() ?: '更新失败'); |
|
|
|
return $this->renderError($model->getError() ?: '更新失败'); |
|
|
|
} |
|
|
|
} |
|
|
|
public function copyCategory(int $new_store_id){ |
|
|
|
public function copyCategory(int $new_store_id){ |
|
|
|
$store_id = 10001; |
|
|
|
$store_id = 0; |
|
|
|
$model = new CategoryModel; |
|
|
|
$model = new CategoryModel; |
|
|
|
$list = $model->getList(['store_id' =>$store_id]); |
|
|
|
$list = $model->getList(['store_id' =>$store_id]); |
|
|
|
if (!$list) { |
|
|
|
if (!$list) { |
|
|
@ -101,6 +101,7 @@ class Category extends Controller |
|
|
|
$value['update_time'] = time(); |
|
|
|
$value['update_time'] = time(); |
|
|
|
$value['image_id'] = $value['image_id'] ? $this->copyImage($value['image_id'], $new_store_id) : 0; |
|
|
|
$value['image_id'] = $value['image_id'] ? $this->copyImage($value['image_id'], $new_store_id) : 0; |
|
|
|
$value['rank_image_id'] = $value['rank_image_id'] ? $this->copyImage($value['rank_image_id'], $new_store_id) : 0; |
|
|
|
$value['rank_image_id'] = $value['rank_image_id'] ? $this->copyImage($value['rank_image_id'], $new_store_id) : 0; |
|
|
|
|
|
|
|
$value['original_category_id'] = $value['category_id']; |
|
|
|
$temp = $value; |
|
|
|
$temp = $value; |
|
|
|
unset($temp['children']); |
|
|
|
unset($temp['children']); |
|
|
|
unset($temp['image']); |
|
|
|
unset($temp['image']); |
|
|
@ -119,6 +120,7 @@ class Category extends Controller |
|
|
|
$value1['update_time'] = time(); |
|
|
|
$value1['update_time'] = time(); |
|
|
|
$value1['image_id'] = $value1['image_id'] ? $this->copyImage($value1['image_id'], $new_store_id) : 0; |
|
|
|
$value1['image_id'] = $value1['image_id'] ? $this->copyImage($value1['image_id'], $new_store_id) : 0; |
|
|
|
$value1['rank_image_id'] = $value1['rank_image_id'] ? $this->copyImage($value1['rank_image_id'], $new_store_id) : 0; |
|
|
|
$value1['rank_image_id'] = $value1['rank_image_id'] ? $this->copyImage($value1['rank_image_id'], $new_store_id) : 0; |
|
|
|
|
|
|
|
$value1['original_category_id'] = $value1['category_id']; |
|
|
|
$temp1 = $value1; |
|
|
|
$temp1 = $value1; |
|
|
|
unset($temp1['children']); |
|
|
|
unset($temp1['children']); |
|
|
|
unset($temp1['image']); |
|
|
|
unset($temp1['image']); |
|
|
@ -137,6 +139,7 @@ class Category extends Controller |
|
|
|
$value2['update_time'] = time(); |
|
|
|
$value2['update_time'] = time(); |
|
|
|
$value2['image_id'] = $value2['image_id'] ? $this->copyImage($value2['image_id'], $new_store_id) : 0; |
|
|
|
$value2['image_id'] = $value2['image_id'] ? $this->copyImage($value2['image_id'], $new_store_id) : 0; |
|
|
|
$value2['rank_image_id'] = $value2['rank_image_id'] ? $this->copyImage($value2['rank_image_id'], $new_store_id) : 0; |
|
|
|
$value2['rank_image_id'] = $value2['rank_image_id'] ? $this->copyImage($value2['rank_image_id'], $new_store_id) : 0; |
|
|
|
|
|
|
|
$value2['original_category_id'] = $value2['category_id']; |
|
|
|
$temp2 = $value2; |
|
|
|
$temp2 = $value2; |
|
|
|
unset($temp2['children']); |
|
|
|
unset($temp2['children']); |
|
|
|
unset($temp2['image']); |
|
|
|
unset($temp2['image']); |
|
|
@ -155,6 +158,7 @@ class Category extends Controller |
|
|
|
$value3['update_time'] = time(); |
|
|
|
$value3['update_time'] = time(); |
|
|
|
$value3['image_id'] = $value3['image_id'] ? $this->copyImage($value3['image_id'], $new_store_id) : 0; |
|
|
|
$value3['image_id'] = $value3['image_id'] ? $this->copyImage($value3['image_id'], $new_store_id) : 0; |
|
|
|
$value3['rank_image_id'] = $value3['rank_image_id'] ? $this->copyImage($value3['rank_image_id'], $new_store_id) : 0; |
|
|
|
$value3['rank_image_id'] = $value3['rank_image_id'] ? $this->copyImage($value3['rank_image_id'], $new_store_id) : 0; |
|
|
|
|
|
|
|
$value3['original_category_id'] = $value3['category_id']; |
|
|
|
$temp3 = $value3; |
|
|
|
$temp3 = $value3; |
|
|
|
unset($temp3['children']); |
|
|
|
unset($temp3['children']); |
|
|
|
unset($temp3['image']); |
|
|
|
unset($temp3['image']); |
|
|
@ -162,6 +166,26 @@ class Category extends Controller |
|
|
|
unset($temp3['category_id']); |
|
|
|
unset($temp3['category_id']); |
|
|
|
|
|
|
|
|
|
|
|
Db::table('yoshop_category')->insertGetId($temp3); |
|
|
|
Db::table('yoshop_category')->insertGetId($temp3); |
|
|
|
|
|
|
|
if (!isset($value3['children']) || !$value3['children']) { |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
foreach ($value3['children'] as $value4) { |
|
|
|
|
|
|
|
$value4 = $value4->toArray(); |
|
|
|
|
|
|
|
$value4['parent_id'] = $secondid; |
|
|
|
|
|
|
|
$value4['store_id'] = $new_store_id; |
|
|
|
|
|
|
|
$value4['create_time'] = time(); |
|
|
|
|
|
|
|
$value4['update_time'] = time(); |
|
|
|
|
|
|
|
$value4['image_id'] = $value4['image_id'] ? $this->copyImage($value4['image_id'], $new_store_id) : 0; |
|
|
|
|
|
|
|
$value4['rank_image_id'] = $value4['rank_image_id'] ? $this->copyImage($value4['rank_image_id'], $new_store_id) : 0; |
|
|
|
|
|
|
|
$value4['original_category_id'] = $value4['category_id']; |
|
|
|
|
|
|
|
$temp4 = $value4; |
|
|
|
|
|
|
|
unset($temp4['children']); |
|
|
|
|
|
|
|
unset($temp4['image']); |
|
|
|
|
|
|
|
unset($temp4['rankimage']); |
|
|
|
|
|
|
|
unset($temp4['category_id']); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Db::table('yoshop_category')->insertGetId($temp4); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|