diff --git a/app/psi/controller/warehouse/WarehouseController.php b/app/psi/controller/warehouse/WarehouseController.php new file mode 100644 index 0000000..e616e0a --- /dev/null +++ b/app/psi/controller/warehouse/WarehouseController.php @@ -0,0 +1,48 @@ +dataLists(new WarehouseLists()); + } + + + /** + * @notes 添加仓库模块 + * @return \think\response\Json + * @author admin + * @date 2025/03/03 09:41 + */ + public function add() + { + $params =$this->request->post(); + $result = WarehouseLogic::add($params); + return $this->success('添加成功', [], 1, 1); + } + + + + +} \ No newline at end of file diff --git a/app/psi/controller/warehouse_storege/WarehouseStoregeController.php b/app/psi/controller/warehouse_storege/WarehouseStoregeController.php new file mode 100644 index 0000000..e56db92 --- /dev/null +++ b/app/psi/controller/warehouse_storege/WarehouseStoregeController.php @@ -0,0 +1,45 @@ +dataLists(new WarehouseStoregeLists()); + } + public function edit() + { + $params = $this->request->post(); + $result = WarehouseStoregeLogic::edit($params,$this->adminId); + return $this->success('编辑成功', [], 1, 1); + + } + + + public function verify(){ + $params=$this->request->post(); + WarehouseStorege::where('id',$params['id'])->update(['is_verify'=>$params['is_verify']]); + return $this->success('操作成功',[],1,1); + } + +} \ No newline at end of file diff --git a/app/psi/lists/purchase_order/PurchaseOrderLists.php b/app/psi/lists/purchase_order/PurchaseOrderLists.php index 6f6c61e..f4846bd 100644 --- a/app/psi/lists/purchase_order/PurchaseOrderLists.php +++ b/app/psi/lists/purchase_order/PurchaseOrderLists.php @@ -48,7 +48,7 @@ class PurchaseOrderLists extends BaseAdminDataLists implements ListsSearchInterf public function lists(): array { return PurchaseOrder::where($this->searchWhere) - ->field(['id', 'code', 'admin_id', 'batch', 'mark', 'total_price', 'status', 'create_time', 'oid', 'order_type']) + ->field(['id', 'code', 'admin_id','warehouse_id', 'mark', 'total_price', 'status', 'create_time', 'oid', 'order_type']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function ($item) { diff --git a/app/psi/lists/warehouse/WarehouseLists.php b/app/psi/lists/warehouse/WarehouseLists.php new file mode 100644 index 0000000..88efc93 --- /dev/null +++ b/app/psi/lists/warehouse/WarehouseLists.php @@ -0,0 +1,65 @@ + ['name', 'contacts', 'tel', 'address', 'notes', 'sort'], + ]; + } + + + /** + * @notes 获取仓库模块列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author admin + * @date 2025/03/03 09:41 + */ + public function lists(): array + { + return Warehouse::where($this->searchWhere) + ->field(['id', 'name', 'contacts', 'tel', 'address', 'notes', 'sort']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取仓库模块数量 + * @return int + * @author admin + * @date 2025/03/03 09:41 + */ + public function count(): int + { + return Warehouse::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/psi/lists/warehouse_storege/WarehouseStoregeLists.php b/app/psi/lists/warehouse_storege/WarehouseStoregeLists.php new file mode 100644 index 0000000..c4bf54b --- /dev/null +++ b/app/psi/lists/warehouse_storege/WarehouseStoregeLists.php @@ -0,0 +1,65 @@ + ['warehouse_id', 'product_id', 'nums', 'is_verify', 'price'], + ]; + } + + + /** + * @notes 获取列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author admin + * @date 2025/03/03 11:07 + */ + public function lists(): array + { + return WarehouseStorege::where($this->searchWhere) + ->field(['id', 'warehouse_id', 'product_id', 'nums', 'is_verify', 'price']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取数量 + * @return int + * @author admin + * @date 2025/03/03 11:07 + */ + public function count(): int + { + return WarehouseStorege::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/psi/logic/warehouse/WarehouseLogic.php b/app/psi/logic/warehouse/WarehouseLogic.php new file mode 100644 index 0000000..318d69c --- /dev/null +++ b/app/psi/logic/warehouse/WarehouseLogic.php @@ -0,0 +1,103 @@ + $params['name'], + 'contacts' => $params['contacts'], + 'tel' => $params['tel'], + 'address' => $params['address'], + 'notes' => $params['notes'], + 'sort' => $params['sort'] + ]); + + Db::commit(); + return true; + } catch (\Throwable $e) { + Db::rollback(); + throw new Exception($e->getMessage()); + } + } + + + /** + * @notes 编辑仓库模块 + * @param array $params + * @return bool + * @author admin + * @date 2025/03/03 09:41 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + Warehouse::where('id', $params['id'])->update([ + 'name' => $params['name'], + 'contacts' => $params['contacts'], + 'tel' => $params['tel'], + 'address' => $params['address'], + 'notes' => $params['notes'], + 'sort' => $params['sort'] + ]); + + Db::commit(); + return true; + } catch (\Throwable $e) { + Db::rollback(); + throw new Exception($e->getMessage()); + } + } + + + /** + * @notes 删除仓库模块 + * @param array $params + * @return bool + * @author admin + * @date 2025/03/03 09:41 + */ + public static function delete(array $params): bool + { + return PsiWarehouse::destroy($params['id']); + } + + + /** + * @notes 获取仓库模块详情 + * @param $params + * @return array + * @author admin + * @date 2025/03/03 09:41 + */ + public static function detail($params): array + { + return PsiWarehouse::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/psi/logic/warehouse_storege/WarehouseStoregeLogic.php b/app/psi/logic/warehouse_storege/WarehouseStoregeLogic.php new file mode 100644 index 0000000..3b14c8b --- /dev/null +++ b/app/psi/logic/warehouse_storege/WarehouseStoregeLogic.php @@ -0,0 +1,103 @@ + $params['warehouse_id'], + 'product_id' => $params['product_id'], + 'nums' => $params['nums'], + 'is_verify' => $params['is_verify'], + 'price' => $params['price'] + ]); + + Db::commit(); + return true; + } catch (\Throwable $e) { + Db::rollback(); + throw new Exception($e->getMessage()); + } + } + + + /** + * @notes 编辑 + * @param array $params + * @return bool + * @author admin + * @date 2025/03/03 11:07 + */ + public static function edit(array $params,$admin_id=0): bool + { + if (empty($params['remark'])) { + throw new Exception('请输入备注'); + } + Db::startTrans(); + try { + $find=WarehouseStorege::where('id',$params['id'])->find(); + if($find){ + $find->save(['nums'=>$params['nums']]); + // SqlChannelLog('WarehouseProductStorege', $params['id'], $params['nums'], 0,Request()->url(),$admin_id, $params['remark']); + } + Db::commit(); + return true; + + } catch (\Throwable $th) { + Db::rollback(); + throw new Exception($th->getMessage()); + } + return false; + } + + + /** + * @notes 删除 + * @param array $params + * @return bool + * @author admin + * @date 2025/03/03 11:07 + */ + public static function delete(array $params): bool + { + return WarehouseStorege::destroy($params['id']); + } + + + /** + * @notes 获取详情 + * @param $params + * @return array + * @author admin + * @date 2025/03/03 11:07 + */ + public static function detail($params): array + { + return WarehouseStorege::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file