diff --git a/app/admin/controller/beforehand_order/BeforehandOrderController.php b/app/admin/controller/beforehand_order/BeforehandOrderController.php index 2da9829bd..1dbb0f96e 100644 --- a/app/admin/controller/beforehand_order/BeforehandOrderController.php +++ b/app/admin/controller/beforehand_order/BeforehandOrderController.php @@ -340,5 +340,13 @@ class BeforehandOrderController extends BaseAdminController BeforehandOrderLogic::confirmLog($params); return $this->success('确认成功'); } + + public function copy() + { + $params = $this->request->post(); + $params['admin_id'] = $this->adminId; + BeforehandOrderLogic::copy($params); + return $this->success('复制成功'); + } } 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/beforehand_order/BeforehandOrderLogic.php b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php index e94bbf87b..0e5a772f7 100644 --- a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php +++ b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php @@ -1037,4 +1037,43 @@ class BeforehandOrderLogic extends BaseLogic return $data; } + + public static function copy($params) + { + Db::startTrans(); + try { + $order = BeforehandOrder::where('id', $params['id'])->find(); + if (empty($order)) { + throw new BusinessException('订单不存在'); + } + if ($order['order_type'] != 1) { + throw new BusinessException('只能复制铺货订单'); + } + $orderCartInfo = BeforehandOrderCartInfo::where('bhoid', $params['id'])->select()->toArray(); + unset($order['id'], $order['create_time'], $order['update_time']); + $newOrder = new BeforehandOrder(); + $newOrder->setAttrs($order->toArray()); + $newOrder->admin_id = $params['admin_id']; + $newOrder->store_id = $params['store_id']; + $newOrder->order_id = getNewOrderId('YG'); + if (!empty($params['mark'])) { + $newOrder->mark = $params['mark']; + } else { + $newOrder->mark = "复制订单,原订单id:{$params['id']}"; + } + $newOrder->save(); + $insert = []; + foreach ($orderCartInfo as $v) { + unset($v['id'], $v['create_time'], $v['update_time']); + $v['bhoid'] = $newOrder->id; + $insert[] = $v; + } + (new BeforehandOrderCartInfo())->saveAll($insert); + Db::commit(); + } catch (\Exception $e) { + Db::rollback(); + throw new BusinessException($e->getMessage()); + } + } + } 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; }