diff --git a/app/admin/controller/store_product/StoreProductController.php b/app/admin/controller/store_product/StoreProductController.php index 11e4810d..f494ea82 100644 --- a/app/admin/controller/store_product/StoreProductController.php +++ b/app/admin/controller/store_product/StoreProductController.php @@ -131,4 +131,12 @@ class StoreProductController extends BaseAdminController { return $this->fail('接口已关闭'); } + + public function restore() + { + $params = (new StoreProductValidate())->post()->goCheck('delete'); + StoreProductLogic::restore($params); + return $this->success('删除成功', [], 1, 1); + } + } diff --git a/app/admin/lists/beforehand_order_cart_info/BeforehandOrderCartInfoLists.php b/app/admin/lists/beforehand_order_cart_info/BeforehandOrderCartInfoLists.php index 1667ce5e..9e9e5bb9 100644 --- a/app/admin/lists/beforehand_order_cart_info/BeforehandOrderCartInfoLists.php +++ b/app/admin/lists/beforehand_order_cart_info/BeforehandOrderCartInfoLists.php @@ -118,6 +118,12 @@ class BeforehandOrderCartInfoLists extends BaseAdminDataLists implements ListsSe return $item; }) ->toArray(); + $orderTypeMap = BeforehandOrder::whereIn('id', array_unique(array_column($list, 'bhoid')))->field('id, order_type')->select()->toArray(); + $orderTypeMap = reset_index($orderTypeMap, 'id'); + foreach ($list as &$item) { + $orderType = $orderTypeMap[$item['bhoid']]['order_type'] ?? ''; + $item['order_type_name'] = BeforehandOrder::getOrderTypeName($orderType); + } $this->list = $list; return $list; } diff --git a/app/admin/logic/store_product/StoreProductLogic.php b/app/admin/logic/store_product/StoreProductLogic.php index e734e5ed..003b94b3 100644 --- a/app/admin/logic/store_product/StoreProductLogic.php +++ b/app/admin/logic/store_product/StoreProductLogic.php @@ -299,6 +299,17 @@ class StoreProductLogic extends BaseLogic return $res; } + public static function restore(array $params): bool + { + $data = StoreProduct::where('id', $params['id'])->onlyTrashed()->find(); + if (empty($data)) { + throw new BusinessException('数据不存在'); + } + $res = $data->restore(); + StoreBranchProduct::where('product_id', $params['id'])->update(['delete_time' => null]); + return $res; + } + /** * @notes 获取商品详情