|
...
|
...
|
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Api; |
|
|
|
use App\Enums\Common\Code;
|
|
|
|
use App\Helper\Translate;
|
|
|
|
use App\Models\Product\Category;
|
|
|
|
use App\Models\Product\CategoryRelated;
|
|
|
|
use App\Models\Product\Product;
|
|
|
|
use App\Models\RouteMap\RouteMap;
|
|
|
|
use App\Services\CosService;
|
|
...
|
...
|
@@ -101,7 +102,7 @@ class ProductController extends BaseController |
|
|
|
}else{
|
|
|
|
$cate_id = $cateInfo['id'];
|
|
|
|
}
|
|
|
|
$category_id = ','.$cate_id.',';
|
|
|
|
$category_id = $cate_id;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
$productModel = new Product();
|
|
...
|
...
|
@@ -118,11 +119,13 @@ class ProductController extends BaseController |
|
|
|
'updated_at'=>date('Y-m-d H:i:s')
|
|
|
|
];
|
|
|
|
if(!empty($category_id)){
|
|
|
|
$productData['category_id'] = $category_id;
|
|
|
|
$productData['category_id'] = ','.$cate_id.',';
|
|
|
|
}
|
|
|
|
$product_id = $productModel->addReturnId($productData);
|
|
|
|
$route = RouteMap::setRoute($productData['title'], RouteMap::SOURCE_PRODUCT, $product_id, $this->param['project_id']);
|
|
|
|
$productModel->edit(['route'=>$route],['id'=>$cate_id]);
|
|
|
|
$productModel->edit(['route'=>$route],['id'=>$product_id]);
|
|
|
|
//添加到关联分类
|
|
|
|
CategoryRelated::saveRelated($product_id, [$cate_id]);
|
|
|
|
}
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
LogUtils::error('Project Id: ' . $this->param['project_id'] . ' saveProduct error:' . $e->getMessage());
|
...
|
...
|
|