mirror of
https://github.com/crmeb/CRMEB.git
synced 2026-10-28 21:40:50 +00:00
fix(网盘商品): 删除/恢复/彻底删除接标准回收站链路
删除走标准 del(营销活动检测+自动下架+购物车失效),新增 restore/forceDelete 接口与权限菜单,彻底删除时级联清理 SKU 数据
This commit is contained in:
parent
407128413d
commit
76c4b9f840
@ -176,6 +176,8 @@ class Handler extends BaseProductTypeHandler
|
||||
{
|
||||
$dao = app(VirtualProductDao::class);
|
||||
$dao->delete(['product_id' => $productId]);
|
||||
// SKU 数据(含网盘链接/提取码)随商品彻底删除一并清理
|
||||
app(VirtualProductSkuDao::class)->delete(['product_id' => $productId]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -208,6 +208,32 @@ class Installer extends BaseModuleInstaller
|
||||
'access' => 1,
|
||||
'auth_type' => 3,
|
||||
],
|
||||
// 恢复网盘商品(隐藏,仅权限认证用)
|
||||
[
|
||||
'pid' => '@网盘产品',
|
||||
'menu_name' => '恢复网盘商品',
|
||||
'controller' => 'virtualProduct',
|
||||
'action' => 'restore',
|
||||
'module' => 'admin',
|
||||
'api_url' => 'virtual/product/restore/:id',
|
||||
'methods' => 'PUT',
|
||||
'is_show' => 1,
|
||||
'access' => 1,
|
||||
'auth_type' => 3,
|
||||
],
|
||||
// 彻底删除网盘商品(隐藏,仅权限认证用)
|
||||
[
|
||||
'pid' => '@网盘产品',
|
||||
'menu_name' => '彻底删除网盘商品',
|
||||
'controller' => 'virtualProduct',
|
||||
'action' => 'forceDelete',
|
||||
'module' => 'admin',
|
||||
'api_url' => 'virtual/product/force/:id',
|
||||
'methods' => 'DELETE',
|
||||
'is_show' => 1,
|
||||
'access' => 1,
|
||||
'auth_type' => 3,
|
||||
],
|
||||
// 网盘商品订单详情(隐藏,仅权限认证用)
|
||||
[
|
||||
'key' => 'virtual-order-detail',
|
||||
|
||||
@ -75,12 +75,36 @@ class ProductController extends AuthController
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除商品
|
||||
* 删除商品(移入回收站,标准链路同时自动下架)
|
||||
*/
|
||||
public function delete(int $id)
|
||||
{
|
||||
$service = app(\app\services\product\CenterProductServices::class);
|
||||
$service->update($id, ['is_del' => 1]);
|
||||
// 移入回收站前检测是否参与营销活动
|
||||
$service->checkActivity($id);
|
||||
$msg = $service->del($id);
|
||||
// 同步失效购物车中该商品
|
||||
app(\app\services\order\StoreCartServices::class)->changeStatus($id, 0);
|
||||
return app('json')->success($msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从回收站恢复商品
|
||||
*/
|
||||
public function restore(int $id)
|
||||
{
|
||||
$service = app(\app\services\product\CenterProductServices::class);
|
||||
$service->batchRecover([$id]);
|
||||
return app('json')->success('恢复成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 回收站商品彻底删除
|
||||
*/
|
||||
public function forceDelete(int $id)
|
||||
{
|
||||
$service = app(\app\services\product\CenterProductServices::class);
|
||||
$service->recycleProduct($id);
|
||||
return app('json')->success('删除成功');
|
||||
}
|
||||
|
||||
|
||||
@ -28,6 +28,8 @@ Route::group('virtual', function () {
|
||||
Route::delete('product/:id', [ProductController::class, 'delete'])->option(['real_name' => '删除网盘商品']);
|
||||
Route::get('product/:id', [ProductController::class, 'read'])->option(['real_name' => '网盘商品详情']);
|
||||
Route::put('product/status/:id/:status', [ProductController::class, 'setStatus'])->option(['real_name' => '上下架网盘商品']);
|
||||
Route::put('product/restore/:id', [ProductController::class, 'restore'])->option(['real_name' => '恢复网盘商品']);
|
||||
Route::delete('product/force/:id', [ProductController::class, 'forceDelete'])->option(['real_name' => '彻底删除网盘商品']);
|
||||
})->option(['parent' => 'virtual', 'cate_name' => '网盘商品管理']);
|
||||
|
||||
/** 网盘订单 */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user