From d718fd567dc1ed5dc47a1853ca07758f10b6557c Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 14 Feb 2025 16:01:53 +0800 Subject: [PATCH 1/5] =?UTF-8?q?feat(inventory=5Fstore):=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E9=97=A8=E5=BA=97=E7=9B=98=E5=AD=98=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 InventoryStoreController 控制器,实现门店盘存列表、添加、编辑和核准 --- .../InventoryStoreController.php | 81 +++++++++++++ .../inventory_store/InventoryStoreLists.php | 71 +++++++++++ .../inventory_store/InventoryStoreLogic.php | 113 ++++++++++++++++++ .../InventoryStoreValidate.php | 82 +++++++++++++ .../model/inventory_store/InventoryStore.php | 22 ++++ 5 files changed, 369 insertions(+) create mode 100644 app/admin/controller/inventory_store/InventoryStoreController.php create mode 100644 app/admin/lists/inventory_store/InventoryStoreLists.php create mode 100644 app/admin/logic/inventory_store/InventoryStoreLogic.php create mode 100644 app/admin/validate/inventory_store/InventoryStoreValidate.php create mode 100644 app/common/model/inventory_store/InventoryStore.php diff --git a/app/admin/controller/inventory_store/InventoryStoreController.php b/app/admin/controller/inventory_store/InventoryStoreController.php new file mode 100644 index 000000000..d7c844d8a --- /dev/null +++ b/app/admin/controller/inventory_store/InventoryStoreController.php @@ -0,0 +1,81 @@ +dataLists(new InventoryStoreLists()); + } + + + /** + * @notes 添加门店盘存 + * @return \think\response\Json + * @author admin + * @date 2025/02/14 11:46 + */ + public function add() + { + $params = (new InventoryStoreValidate())->post()->goCheck('add'); + $result = InventoryStoreLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(InventoryStoreLogic::getError()); + } + + + /** + * @notes 编辑门店盘存 + * @return \think\response\Json + * @author admin + * @date 2025/02/14 11:46 + */ + public function edit() + { + $params = (new InventoryStoreValidate())->post()->goCheck('edit'); + $result = InventoryStoreLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(InventoryStoreLogic::getError()); + } + + + /** + * @notes 门店盘存核准 + * @return \think\response\Json + * @author admin + * @date 2025/02/14 11:46 + */ + public function enter_nums() + { + $params = $this->request->post(); + $result = InventoryStoreLogic::enterNums($params); + if (true === $result) { + return $this->success('核准成功', [], 1, 1); + } + } +} \ No newline at end of file diff --git a/app/admin/lists/inventory_store/InventoryStoreLists.php b/app/admin/lists/inventory_store/InventoryStoreLists.php new file mode 100644 index 000000000..aede20268 --- /dev/null +++ b/app/admin/lists/inventory_store/InventoryStoreLists.php @@ -0,0 +1,71 @@ + ['store_id', 'nums', 'enter_nums', 'status'], + ]; + } + + + /** + * @notes 获取门店盘存列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author admin + * @date 2025/02/14 11:46 + */ + public function lists(): array + { + return InventoryStore::where($this->searchWhere) + ->field(['id', 'product_id', 'admin_id', 'staff_id', 'store_id', 'nums', 'enter_nums', 'status', 'create_time']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['create_time' => 'desc']) + ->select()->each(function ($item) { + $item->status_name = match ($item->status) { + 0 => '待盘点', + 1 => '盘点中', + 2 => '盘点完成', + default => '未知', + }; + }) + ->toArray(); + } + + + /** + * @notes 获取门店盘存数量 + * @return int + * @author admin + * @date 2025/02/14 11:46 + */ + public function count(): int + { + return InventoryStore::where($this->searchWhere)->count(); + } +} diff --git a/app/admin/logic/inventory_store/InventoryStoreLogic.php b/app/admin/logic/inventory_store/InventoryStoreLogic.php new file mode 100644 index 000000000..bd713a63c --- /dev/null +++ b/app/admin/logic/inventory_store/InventoryStoreLogic.php @@ -0,0 +1,113 @@ +field('product_id,store_id,stock as nums')->select()->toArray(); + (new InventoryStore())->saveAll($arr); + Db::commit(); + return true; + } catch (\Throwable $e) { + Db::rollback(); + throw new BusinessException($e->getMessage()); + } + } + + + /** + * @notes 编辑门店盘存 + * @param array $params + * @return bool + * @author admin + * @date 2025/02/14 11:46 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + InventoryStore::where('id', $params['id'])->update([ + 'enter_nums'=>$params['nums'] + ]); + + Db::commit(); + return true; + } catch (\Throwable $e) { + Db::rollback(); + throw new BusinessException($e->getMessage()); + } + } + public static function enterNums(array $params): bool + { + Db::startTrans(); + try { + InventoryStore::where('store_id', $params['store_id'])->whereDay('create_time',$params['create_time'])->update([ + 'status'=>2 + ]); + + $arr=InventoryStore::where('store_id', $params['store_id'])->where('nums','<>','enter_nums')->whereDay('create_time',$params['create_time'])->select(); + foreach ($arr as $k=>$v){ + StoreBranchProduct::where('product_id',$v['product_id'])->where('store_id',$v['store_id'])->update([ + 'stock'=>$v['enter_nums'] + ]); + } + Db::commit(); + return true; + } catch (\Throwable $e) { + Db::rollback(); + throw new BusinessException($e->getMessage()); + } + } + + + /** + * @notes 删除门店盘存 + * @param array $params + * @return bool + * @author admin + * @date 2025/02/14 11:46 + */ + public static function delete(array $params): bool + { + return InventoryStore::destroy($params['id']); + } + + + /** + * @notes 获取门店盘存详情 + * @param $params + * @return array + * @author admin + * @date 2025/02/14 11:46 + */ + public static function detail($params): array + { + return InventoryStore::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/admin/validate/inventory_store/InventoryStoreValidate.php b/app/admin/validate/inventory_store/InventoryStoreValidate.php new file mode 100644 index 000000000..5891017e1 --- /dev/null +++ b/app/admin/validate/inventory_store/InventoryStoreValidate.php @@ -0,0 +1,82 @@ + 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + ]; + + + /** + * @notes 添加场景 + * @return InventoryStoreValidate + * @author admin + * @date 2025/02/14 11:46 + */ + public function sceneAdd() + { + return $this->remove('id', true); + } + + + /** + * @notes 编辑场景 + * @return InventoryStoreValidate + * @author admin + * @date 2025/02/14 11:46 + */ + public function sceneEdit() + { + return $this->only(['id']); + } + + + /** + * @notes 删除场景 + * @return InventoryStoreValidate + * @author admin + * @date 2025/02/14 11:46 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return InventoryStoreValidate + * @author admin + * @date 2025/02/14 11:46 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/common/model/inventory_store/InventoryStore.php b/app/common/model/inventory_store/InventoryStore.php new file mode 100644 index 000000000..eeed76808 --- /dev/null +++ b/app/common/model/inventory_store/InventoryStore.php @@ -0,0 +1,22 @@ + Date: Fri, 14 Feb 2025 16:24:23 +0800 Subject: [PATCH 2/5] =?UTF-8?q?feat(inventory=5Fstore):=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E7=AE=A1=E7=90=86=E5=91=98ID=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在编辑库存时,添加管理员ID字段 - 在逻辑层更新库存时,记录管理员ID --- .../controller/inventory_store/InventoryStoreController.php | 1 + app/admin/logic/inventory_store/InventoryStoreLogic.php | 1 + 2 files changed, 2 insertions(+) diff --git a/app/admin/controller/inventory_store/InventoryStoreController.php b/app/admin/controller/inventory_store/InventoryStoreController.php index d7c844d8a..af2d41d94 100644 --- a/app/admin/controller/inventory_store/InventoryStoreController.php +++ b/app/admin/controller/inventory_store/InventoryStoreController.php @@ -56,6 +56,7 @@ class InventoryStoreController extends BaseAdminController public function edit() { $params = (new InventoryStoreValidate())->post()->goCheck('edit'); + $params['admin_id']=$this->adminId; $result = InventoryStoreLogic::edit($params); if (true === $result) { return $this->success('编辑成功', [], 1, 1); diff --git a/app/admin/logic/inventory_store/InventoryStoreLogic.php b/app/admin/logic/inventory_store/InventoryStoreLogic.php index bd713a63c..a30f7bc88 100644 --- a/app/admin/logic/inventory_store/InventoryStoreLogic.php +++ b/app/admin/logic/inventory_store/InventoryStoreLogic.php @@ -53,6 +53,7 @@ class InventoryStoreLogic extends BaseLogic Db::startTrans(); try { InventoryStore::where('id', $params['id'])->update([ + 'admin_id'=>$params['admin_id']??0, 'enter_nums'=>$params['nums'] ]); From d3d35560380775431d0ee075de0e94070dc1dd4d Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 14 Feb 2025 16:42:57 +0800 Subject: [PATCH 3/5] =?UTF-8?q?feat(inventory=5Fstore):=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E9=97=A8=E5=BA=97=E7=9B=98=E5=AD=98=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=92=8C=E7=94=9F=E6=88=90=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 InventoryStoreLists 中添加了对管理员、员工、门店和商品名称的关联查询 - 在 InventoryStoreLogic 中增加了对当日数据已生成的检查,避免重复生成 - --- .../inventory_store/InventoryStoreLists.php | 17 ++++++++++++++++- .../inventory_store/InventoryStoreLogic.php | 18 +++++------------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/app/admin/lists/inventory_store/InventoryStoreLists.php b/app/admin/lists/inventory_store/InventoryStoreLists.php index aede20268..dfeb044a6 100644 --- a/app/admin/lists/inventory_store/InventoryStoreLists.php +++ b/app/admin/lists/inventory_store/InventoryStoreLists.php @@ -6,7 +6,10 @@ namespace app\admin\lists\inventory_store; use app\admin\lists\BaseAdminDataLists; use app\common\model\inventory_store\InventoryStore; use app\common\lists\ListsSearchInterface; - +use app\common\model\auth\Admin; +use app\common\model\store_product\StoreProduct; +use app\common\model\system_store\SystemStore; +use app\common\model\system_store\SystemStoreStaff; /** * 门店盘存列表 @@ -53,6 +56,18 @@ class InventoryStoreLists extends BaseAdminDataLists implements ListsSearchInter 2 => '盘点完成', default => '未知', }; + if($item->admin_id){ + $item->admin_name = Admin::where('id',$item->admin_id)->value('name'); + } + if($item->staff_id){ + $item->staff_name = SystemStoreStaff::where('id',$item->staff_id)->value('staff_name'); + } + if($item->store_id){ + $item->store_name = SystemStore::where('id',$item->store_id)->value('name'); + } + if($item->product_id){ + $item->product_name = StoreProduct::where('id',$item->product_id)->withTrashed()->value('store_name'); + } }) ->toArray(); } diff --git a/app/admin/logic/inventory_store/InventoryStoreLogic.php b/app/admin/logic/inventory_store/InventoryStoreLogic.php index a30f7bc88..836c0dabf 100644 --- a/app/admin/logic/inventory_store/InventoryStoreLogic.php +++ b/app/admin/logic/inventory_store/InventoryStoreLogic.php @@ -30,7 +30,11 @@ class InventoryStoreLogic extends BaseLogic { Db::startTrans(); try { - $arr=(new StoreBranchProduct())->field('product_id,store_id,stock as nums')->select()->toArray(); + $find=InventoryStore::where('store_id', $params['store_id'])->whereDay('create_time')->find(); + if($find){ + throw new BusinessException('今日数据已生成'); + } + $arr=StoreBranchProduct::where('store_id',$params['store_id'])->field('product_id,store_id,stock as nums')->select()->toArray(); (new InventoryStore())->saveAll($arr); Db::commit(); return true; @@ -99,16 +103,4 @@ class InventoryStoreLogic extends BaseLogic return InventoryStore::destroy($params['id']); } - - /** - * @notes 获取门店盘存详情 - * @param $params - * @return array - * @author admin - * @date 2025/02/14 11:46 - */ - public static function detail($params): array - { - return InventoryStore::findOrEmpty($params['id'])->toArray(); - } } \ No newline at end of file From 8567f2de4aa2ba9c7ab9cb5799004922d8d814f3 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 14 Feb 2025 18:00:33 +0800 Subject: [PATCH 4/5] =?UTF-8?q?fix(inventory=5Fstore):=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=BA=93=E5=AD=98=E7=9B=98=E7=82=B9=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 引入 Raw 类以处理复杂的数据库查询 - 使用 Raw 实例解决 nums 和 enter_nums 直接比较的问题 --- .../InventoryWarehouseController.php | 96 ++++++++++++++++ .../InventoryWarehouseLists.php | 79 +++++++++++++ .../inventory_store/InventoryStoreLogic.php | 3 +- .../InventoryWarehouseLogic.php | 108 ++++++++++++++++++ .../InventoryWarehouseValidate.php | 82 +++++++++++++ .../InventoryWarehouse.php | 22 ++++ 6 files changed, 389 insertions(+), 1 deletion(-) create mode 100644 app/admin/controller/inventory_warehouse/InventoryWarehouseController.php create mode 100644 app/admin/lists/inventory_warehouse/InventoryWarehouseLists.php create mode 100644 app/admin/logic/inventory_warehouse/InventoryWarehouseLogic.php create mode 100644 app/admin/validate/inventory_warehouse/InventoryWarehouseValidate.php create mode 100644 app/common/model/inventory_warehouse/InventoryWarehouse.php diff --git a/app/admin/controller/inventory_warehouse/InventoryWarehouseController.php b/app/admin/controller/inventory_warehouse/InventoryWarehouseController.php new file mode 100644 index 000000000..78ee75c02 --- /dev/null +++ b/app/admin/controller/inventory_warehouse/InventoryWarehouseController.php @@ -0,0 +1,96 @@ +dataLists(new InventoryWarehouseLists()); + } + + + /** + * @notes 添加仓库盘存 + * @return \think\response\Json + * @author admin + * @date 2025/02/14 17:24 + */ + public function add() + { + $params = (new InventoryWarehouseValidate())->post()->goCheck('add'); + $result = InventoryWarehouseLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(InventoryWarehouseLogic::getError()); + } + + + /** + * @notes 编辑仓库盘存 + * @return \think\response\Json + * @author admin + * @date 2025/02/14 17:24 + */ + public function edit() + { + $params = (new InventoryWarehouseValidate())->post()->goCheck('edit'); + $params['admin_id']=$this->adminId; + $result = InventoryWarehouseLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(InventoryWarehouseLogic::getError()); + } + + + /** + * @notes 删除仓库盘存 + * @return \think\response\Json + * @author admin + * @date 2025/02/14 17:24 + */ + public function delete() + { + $params = (new InventoryWarehouseValidate())->post()->goCheck('delete'); + InventoryWarehouseLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + /** + * @notes 门店盘存核准 + * @return \think\response\Json + * @author admin + * @date 2025/02/14 11:46 + */ + public function enter_nums() + { + $params = $this->request->post(); + $params['warehouse_id']=1; + $result = InventoryWarehouseLogic::enterNums($params); + if (true === $result) { + return $this->success('核准成功', [], 1, 1); + } + } +} \ No newline at end of file diff --git a/app/admin/lists/inventory_warehouse/InventoryWarehouseLists.php b/app/admin/lists/inventory_warehouse/InventoryWarehouseLists.php new file mode 100644 index 000000000..201626785 --- /dev/null +++ b/app/admin/lists/inventory_warehouse/InventoryWarehouseLists.php @@ -0,0 +1,79 @@ + ['product_id'], + ]; + } + + + /** + * @notes 获取仓库盘存列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author admin + * @date 2025/02/14 17:24 + */ + public function lists(): array + { + return InventoryWarehouse::where($this->searchWhere) + ->field(['id', 'product_id', 'admin_id', 'warehouse_id', 'nums', 'enter_nums', 'status','create_time']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select()->each(function ($item) { + $item->status_name = match ($item->status) { + 0 => '待盘点', + 1 => '盘点中', + 2 => '盘点完成', + default => '未知', + }; + if($item->admin_id){ + $item->admin_name = Admin::where('id',$item->admin_id)->value('name'); + } + if($item->product_id){ + $item->product_name = StoreProduct::where('id',$item->product_id)->withTrashed()->value('store_name'); + } + }) + ->toArray(); + } + + + /** + * @notes 获取仓库盘存数量 + * @return int + * @author admin + * @date 2025/02/14 17:24 + */ + public function count(): int + { + return InventoryWarehouse::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/admin/logic/inventory_store/InventoryStoreLogic.php b/app/admin/logic/inventory_store/InventoryStoreLogic.php index 836c0dabf..44cb5062e 100644 --- a/app/admin/logic/inventory_store/InventoryStoreLogic.php +++ b/app/admin/logic/inventory_store/InventoryStoreLogic.php @@ -7,6 +7,7 @@ use app\common\model\inventory_store\InventoryStore; use app\common\logic\BaseLogic; use app\common\model\store_branch_product\StoreBranchProduct; use support\exception\BusinessException; +use think\db\Raw; use think\facade\Db; @@ -76,7 +77,7 @@ class InventoryStoreLogic extends BaseLogic 'status'=>2 ]); - $arr=InventoryStore::where('store_id', $params['store_id'])->where('nums','<>','enter_nums')->whereDay('create_time',$params['create_time'])->select(); + $arr=InventoryStore::where('store_id', $params['store_id'])->where('nums','<>',new Raw('enter_nums'))->whereDay('create_time',$params['create_time'])->select(); foreach ($arr as $k=>$v){ StoreBranchProduct::where('product_id',$v['product_id'])->where('store_id',$v['store_id'])->update([ 'stock'=>$v['enter_nums'] diff --git a/app/admin/logic/inventory_warehouse/InventoryWarehouseLogic.php b/app/admin/logic/inventory_warehouse/InventoryWarehouseLogic.php new file mode 100644 index 000000000..32e82fe61 --- /dev/null +++ b/app/admin/logic/inventory_warehouse/InventoryWarehouseLogic.php @@ -0,0 +1,108 @@ +whereDay('create_time')->find(); + if($find){ + throw new BusinessException('今日数据已生成'); + } + $arr=WarehouseProductStorege::where('warehouse_id',1)->field('product_id,nums,warehouse_id')->select()->toArray(); + (new InventoryWarehouse())->saveAll($arr); + + Db::commit(); + return true; + } catch (\Throwable $e) { + Db::rollback(); + throw new BusinessException($e->getMessage()); + } + } + + + /** + * @notes 编辑仓库盘存 + * @param array $params + * @return bool + * @author admin + * @date 2025/02/14 17:24 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + InventoryWarehouse::where('id', $params['id'])->update([ + 'admin_id'=>$params['admin_id']??0, + 'enter_nums'=>$params['nums'] + ]); + Db::commit(); + return true; + } catch (\Throwable $e) { + Db::rollback(); + throw new BusinessException($e->getMessage()); + } + } + + + /** + * @notes 删除仓库盘存 + * @param array $params + * @return bool + * @author admin + * @date 2025/02/14 17:24 + */ + public static function delete(array $params): bool + { + return InventoryWarehouse::destroy($params['id']); + } + + public static function enterNums(array $params): bool + { + Db::startTrans(); + try { + InventoryWarehouse::where('warehouse_id', $params['warehouse_id'])->whereDay('create_time',$params['create_time'])->update([ + 'status'=>2 + ]); + + $arr=InventoryWarehouse::where('warehouse_id', $params['warehouse_id'])->where('nums','<>',new Raw('enter_nums'))->whereDay('create_time',$params['create_time'])->select(); + foreach ($arr as $k=>$v){ + WarehouseProductStorege::where('product_id',$v['product_id'])->where('warehouse_id',$v['warehouse_id'])->update([ + 'nums'=>$v['enter_nums'] + ]); + } + Db::commit(); + return true; + } catch (\Throwable $e) { + Db::rollback(); + throw new BusinessException($e->getMessage()); + } + } + +} \ No newline at end of file diff --git a/app/admin/validate/inventory_warehouse/InventoryWarehouseValidate.php b/app/admin/validate/inventory_warehouse/InventoryWarehouseValidate.php new file mode 100644 index 000000000..99da9280f --- /dev/null +++ b/app/admin/validate/inventory_warehouse/InventoryWarehouseValidate.php @@ -0,0 +1,82 @@ + 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + ]; + + + /** + * @notes 添加场景 + * @return InventoryWarehouseValidate + * @author admin + * @date 2025/02/14 17:24 + */ + public function sceneAdd() + { + return $this->remove('id', true); + } + + + /** + * @notes 编辑场景 + * @return InventoryWarehouseValidate + * @author admin + * @date 2025/02/14 17:24 + */ + public function sceneEdit() + { + return $this->only(['id']); + } + + + /** + * @notes 删除场景 + * @return InventoryWarehouseValidate + * @author admin + * @date 2025/02/14 17:24 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return InventoryWarehouseValidate + * @author admin + * @date 2025/02/14 17:24 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/common/model/inventory_warehouse/InventoryWarehouse.php b/app/common/model/inventory_warehouse/InventoryWarehouse.php new file mode 100644 index 000000000..fe0e08847 --- /dev/null +++ b/app/common/model/inventory_warehouse/InventoryWarehouse.php @@ -0,0 +1,22 @@ + Date: Sat, 15 Feb 2025 14:06:16 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=97=A8=E5=BA=97?= =?UTF-8?q?=E5=85=A5=E5=BA=93=E5=88=97=E8=A1=A8=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lists/inventory_warehouse/InventoryWarehouseLists.php | 2 +- .../lists/warehouse_product/StoreWarehouseProductLists.php | 4 +++- app/admin/lists/warehouse_product/WarehouseProductLists.php | 2 +- app/common/model/beforehand_order/BeforehandOrder.php | 6 ++++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/admin/lists/inventory_warehouse/InventoryWarehouseLists.php b/app/admin/lists/inventory_warehouse/InventoryWarehouseLists.php index 201626785..d428c934e 100644 --- a/app/admin/lists/inventory_warehouse/InventoryWarehouseLists.php +++ b/app/admin/lists/inventory_warehouse/InventoryWarehouseLists.php @@ -27,7 +27,7 @@ class InventoryWarehouseLists extends BaseAdminDataLists implements ListsSearchI public function setSearch(): array { return [ - '=' => ['product_id'], + '=' => ['product_id', 'warehouse_id'], ]; } diff --git a/app/admin/lists/warehouse_product/StoreWarehouseProductLists.php b/app/admin/lists/warehouse_product/StoreWarehouseProductLists.php index c62e1aee4..fefdb4e9e 100644 --- a/app/admin/lists/warehouse_product/StoreWarehouseProductLists.php +++ b/app/admin/lists/warehouse_product/StoreWarehouseProductLists.php @@ -4,6 +4,7 @@ namespace app\admin\lists\warehouse_product; use app\admin\lists\BaseAdminDataLists; +use app\common\model\beforehand_order\BeforehandOrder; use app\common\model\warehouse_product\WarehouseProduct; use app\common\lists\ListsSearchInterface; use app\common\model\auth\Admin; @@ -65,7 +66,7 @@ class StoreWarehouseProductLists extends BaseAdminDataLists implements ListsSear $this->searchWhere[] = ['financial_pm', '=',0]; $this->searchWhere[] = ['order_type', 'in',[1, 2, 3, 4, 8]]; return WarehouseProduct::where($this->searchWhere) - ->field(['id', 'admin_id', 'store_id','product_id', 'nums', 'refund_nums', 'status', 'mark', 'create_time',]) + ->field(['id', 'admin_id', 'store_id','product_id', 'nums', 'refund_nums', 'status', 'mark', 'create_time', 'order_type']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) // ->withTrashed() @@ -96,6 +97,7 @@ class StoreWarehouseProductLists extends BaseAdminDataLists implements ListsSear $item->unit_name = StoreProductUnit::where('id', $find->unit)->value('name'); } } + $item->order_type_name = BeforehandOrder::getOrderTypeName($item->order_type); }) ->toArray(); } diff --git a/app/admin/lists/warehouse_product/WarehouseProductLists.php b/app/admin/lists/warehouse_product/WarehouseProductLists.php index 20c42fcbd..1c637e7ca 100644 --- a/app/admin/lists/warehouse_product/WarehouseProductLists.php +++ b/app/admin/lists/warehouse_product/WarehouseProductLists.php @@ -73,7 +73,7 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt } } return WarehouseProduct::where($this->searchWhere) - ->field(['id', 'code','pay_type','oid','admin_id','supplier_id', 'store_id', 'warehouse_id', 'product_id', 'financial_pm', 'batch', 'nums', 'price', 'purchase', 'cost', 'total_price', 'manufacture', 'expiration_date', 'status', 'mark', 'create_time','is_pay']) + ->field(['id', 'code','pay_type','oid','admin_id','supplier_id', 'store_id', 'warehouse_id', 'product_id', 'financial_pm', 'batch', 'nums', 'price', 'purchase', 'cost', 'total_price', 'manufacture', 'expiration_date', 'status', 'mark', 'create_time','is_pay', 'order_type']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) // ->withTrashed() diff --git a/app/common/model/beforehand_order/BeforehandOrder.php b/app/common/model/beforehand_order/BeforehandOrder.php index 1ec1322f3..f709fccac 100644 --- a/app/common/model/beforehand_order/BeforehandOrder.php +++ b/app/common/model/beforehand_order/BeforehandOrder.php @@ -29,8 +29,10 @@ class BeforehandOrder extends BaseModel 3 => '一条龙订单', 4 => '线上订单', 5 => '仓库补货', - 6 => '采购订单', - 7 => '其他订单', + 6 => '往期补单', + 7 => '采购订单', + 8 => '其他订单', + 9 => '往期补单', ]; return $typeMap[$type] ?? ''; }