fix: 同步产品目录产品分类及产品

This commit is contained in:
2025-07-09 11:32:51 +08:00
parent ca6296a276
commit 91a38dee28
2 changed files with 10 additions and 4 deletions

View File

@@ -162,7 +162,7 @@ class ReceiveProductSync
} }
try { try {
$product_tco_category = ProductTcoCategoryModel::language($lang_id)->erpCade($data['category_erp_code'])->find(); $product_tco_category = ProductTcoCategoryModel::language($lang_id)->erpCode($data['category_erp_code'])->find();
if (empty($product_tco_category)) { if (empty($product_tco_category)) {
throw new \Exception('官网未找到产品目录同步分类'); throw new \Exception('官网未找到产品目录同步分类');
} }
@@ -186,10 +186,10 @@ class ReceiveProductSync
'is_sale' => 0, 'is_sale' => 0,
'is_new' => 0, 'is_new' => 0,
'is_hot' => 0, 'is_hot' => 0,
'is_show' => Operate_Of_ReceiveSync::Disable == $data['operate'] ? 0 : 1, 'is_show' => 0,
'sort' => 0, 'sort' => 0,
'detail' => '', 'detail' => '',
'status' => 1, 'status' => Operate_Of_ReceiveSync::Disable == $data['operate'] ? -1 : 1,
'seo_title' => '', 'seo_title' => '',
'seo_keywords' => '', 'seo_keywords' => '',
'seo_desc' => '', 'seo_desc' => '',
@@ -203,7 +203,7 @@ class ReceiveProductSync
$product->spu = $data['spu']; $product->spu = $data['spu'];
$product->name = $data['name']; $product->name = $data['name'];
$product->category_id = $product_category['id']; $product->category_id = $product_category['id'];
$product->is_show = Operate_Of_ReceiveSync::Disable == $data['operate'] ? 0 : 1; $product->status = Operate_Of_ReceiveSync::Disable == $data['operate'] ? -1 : 1;
if (!$product->save()) { if (!$product->save()) {
throw new \Exception('产品更新失败'); throw new \Exception('产品更新失败');
} }

View File

@@ -616,6 +616,12 @@ Route::group('v1', function () {
}); });
})->prefix('v1.'); })->prefix('v1.');
// 接收产品目录同步数据
Route::group('receive_sync', function () {
Route::post('category', 'ReceiveProductSync/category');
Route::post('product', 'ReceiveProductSync/product');
});
Route::miss(function() { Route::miss(function() {
return '404 Not Found!'; return '404 Not Found!';
}); });