From e2014342bd2c4e0686c725d2344d73a6fa09b38d Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Tue, 14 Jan 2025 11:08:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=89=B9=E9=87=8F=E5=85=A5?= =?UTF-8?q?=E5=BA=93=EF=BC=8C=E4=BF=AE=E6=94=B9=E9=97=A8=E5=BA=97=E5=BA=93?= =?UTF-8?q?=E5=AD=98=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SystemStoreStorageController.php | 8 ++++++++ .../system_store_storage/SystemStoreStorageLists.php | 7 +++++-- .../store_branch_product/StoreBranchProductLogic.php | 2 +- .../system_store_storage/SystemStoreStorageLogic.php | 12 ++++++++---- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/app/admin/controller/system_store_storage/SystemStoreStorageController.php b/app/admin/controller/system_store_storage/SystemStoreStorageController.php index 9e0f35344..a243014d4 100644 --- a/app/admin/controller/system_store_storage/SystemStoreStorageController.php +++ b/app/admin/controller/system_store_storage/SystemStoreStorageController.php @@ -94,5 +94,13 @@ class SystemStoreStorageController extends BaseAdminController return $this->data($result); } + /** + * @notes 批量确认入库 + */ + public function batchConfirm() + { + SystemStoreStorageLogic::editAll([], $this->adminId); + return $this->success('操作成功',[]); + } } \ No newline at end of file diff --git a/app/admin/lists/system_store_storage/SystemStoreStorageLists.php b/app/admin/lists/system_store_storage/SystemStoreStorageLists.php index 4a380b5b4..91cc21635 100644 --- a/app/admin/lists/system_store_storage/SystemStoreStorageLists.php +++ b/app/admin/lists/system_store_storage/SystemStoreStorageLists.php @@ -45,14 +45,17 @@ class SystemStoreStorageLists extends BaseAdminDataLists implements ListsSearchI */ public function lists(): array { + if (!empty($this->params['product_name'])) { + $productIds = StoreProduct::where('store_name', 'like', '%' . $this->params['product_name'] . '%')->column('id'); + $this->searchWhere[] = ['product_id', 'in', $productIds]; + } return SystemStoreStorage::where($this->searchWhere) - ->field(['id', 'store_id', 'admin_id', 'staff_id', 'product_id', 'nums','mark', 'status']) + ->field(['id', 'store_id', 'admin_id', 'staff_id', 'product_id', 'nums','mark', 'status', 'create_time']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function ($item) { $item['system_store_name'] = SystemStore::where('id', $item['store_id'])->value('name'); $item['admin_name'] = Admin::where('id', $item['admin_id'])->value('name'); - $item['admin_name'] = Admin::where('id', $item['admin_id'])->value('name'); if ($item['staff_id'] > 0) { $item['staff_name'] = SystemStoreStaff::where('id', $item['staff_id'])->value('staff_name'); } else { diff --git a/app/admin/logic/store_branch_product/StoreBranchProductLogic.php b/app/admin/logic/store_branch_product/StoreBranchProductLogic.php index b833b399a..b66cf1c2c 100644 --- a/app/admin/logic/store_branch_product/StoreBranchProductLogic.php +++ b/app/admin/logic/store_branch_product/StoreBranchProductLogic.php @@ -82,7 +82,7 @@ class StoreBranchProductLogic extends BaseLogic Db::startTrans(); try { $storeBranchProduct = StoreBranchProduct::where('id', $params['id'])->find()->toArray(); - StoreBranchProduct::update(['stock' => $params['stock'], 'total_price' => bcmul($params['stock'], $storeBranchProduct['purchase'], 2)], ['id' => $params['id']]); + StoreBranchProduct::update(['stock' => $params['stock'], 'sales' => $params['sales'], 'total_price' => bcmul($params['stock'], $storeBranchProduct['purchase'], 2)], ['id' => $params['id']]); SqlChannelLog('StoreBranchProduct', $params['id'], $params['stock'], 0, Request()->url(), $admin_id); Db::commit(); return true; diff --git a/app/admin/logic/system_store_storage/SystemStoreStorageLogic.php b/app/admin/logic/system_store_storage/SystemStoreStorageLogic.php index e3837097a..a98d38016 100644 --- a/app/admin/logic/system_store_storage/SystemStoreStorageLogic.php +++ b/app/admin/logic/system_store_storage/SystemStoreStorageLogic.php @@ -73,7 +73,7 @@ class SystemStoreStorageLogic extends BaseLogic $branch_product->save(); SqlChannelLog('StoreBranchProduct', $branch_product['id'], $find['nums'], 1,Request()->url(),$admin_id); }else{ - $storeProduct = StoreProduct::where('id', $find['product_id'])->findOrEmpty(); + $storeProduct = StoreProduct::where('id', $find['product_id'])->withTrashed()->findOrEmpty(); $storeBranchProduct = StoreProductLogic::ordinary(['id' => $find['product_id']], $find['store_id'], 0, $storeProduct); $storeBranchProduct->stock = $find['nums']; $storeBranchProduct->save(); @@ -93,12 +93,16 @@ class SystemStoreStorageLogic extends BaseLogic } } - public static function editAll(array $params): bool + public static function editAll(array $params, $adminId = 0): bool { - $list = SystemStoreStorage::where(['store_id' => $params['store_id'], 'status' => 0])->column('id'); + $where = ['status' => 0]; + if (isset($params['store_id'])) { + $where['store_id'] = $params['store_id']; + } + $list = SystemStoreStorage::where($where)->column('id'); foreach ($list as $item) { $params['id'] = $item; - self::edit($params); + self::edit($params, $adminId); } return true; }