From 884f319ddbce924654e7e33821a759c17cc1383a Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 23 Aug 2024 14:41:07 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E5=95=86=E5=93=81=E9=87=87=E8=B4=AD=E6=80=BB=E4=BB=B7=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/WorkbenchController.php | 11 +++++ app/admin/logic/statistic/WarehouseLogic.php | 44 ++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/app/admin/controller/WorkbenchController.php b/app/admin/controller/WorkbenchController.php index 047444343..ddd70d531 100644 --- a/app/admin/controller/WorkbenchController.php +++ b/app/admin/controller/WorkbenchController.php @@ -299,6 +299,17 @@ class WorkbenchController extends BaseAdminController * @return array */ public function total_warehouse_list() + { + $parmas=$this->request->get(); + $data =WarehouseLogic::total_warehouse_list($parmas,$parmas['type']??1); + return $this->data($data); + } + + /** + * 统计门店仓库总库存 + * @return array + */ + public function total_warehouse_product_list() { $parmas=$this->request->get(); $data =WarehouseLogic::total_warehouse_list($parmas,$parmas['type']??1); diff --git a/app/admin/logic/statistic/WarehouseLogic.php b/app/admin/logic/statistic/WarehouseLogic.php index db036f8c1..eb7f01d65 100644 --- a/app/admin/logic/statistic/WarehouseLogic.php +++ b/app/admin/logic/statistic/WarehouseLogic.php @@ -7,6 +7,7 @@ use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\store_order\StoreOrder; use app\common\model\store_order_cart_info\StoreOrderCartInfo; use app\common\model\store_product\StoreProduct; +use app\common\model\supplier\Supplier; use app\common\model\system_store\SystemStore; use app\common\model\user\User; use app\common\model\user\UserVisit; @@ -135,4 +136,47 @@ class WarehouseLogic extends BaseLogic } return ['lists'=>$list,'count'=>$count]; } + /** + * 统计商品采购总价 已结未结 + * @return array + */ + public static function total_warehouse_product_list($parmas,$type=1) { + $list=[]; + $count=0; + if($type==1){ + //总采购价 + $where=[['product_id','=',$parmas['product_id']],['nums','>',0],['financial_pm','=',1]]; + $list=WarehouseProduct::where($where)->select()->each(function ($item){ + $item->warehouse_name = Warehouse::where('id',$item['warehouse_id'])->value('name'); + $item->supplier_name = Supplier::where('id',$item['supplier_id'])->value('mer_name'); + $find = StoreProduct::where('id',$item['product_id'])->find(); + $item->store_name=$find['store_name']; + $item->image=$find['image']; + }); + $count=WarehouseProduct::where($where)->count(); + }elseif($type==2){ + //已结算采购价 + $where=[['product_id','=',$parmas['product_id']],['nums','>',0],['financial_pm','=',1]]; + $list=WarehouseProduct::where($where)->select()->each(function ($item){ + $item->warehouse_name = Warehouse::where('id',$item['warehouse_id'])->value('name'); + $item->supplier_name = Supplier::where('id',$item['supplier_id'])->value('mer_name'); + $find = StoreProduct::where('id',$item['product_id'])->find(); + $item->store_name=$find['store_name']; + $item->image=$find['image']; + }); + $count=WarehouseProduct::where($where)->count(); + }elseif($type==3){ + //未结算采购价 + $where=[['product_id','=',$parmas['product_id']],['nums','>',0],['financial_pm','=',1]]; + $list=WarehouseProduct::where($where)->select()->each(function ($item){ + $item->warehouse_name = Warehouse::where('id',$item['warehouse_id'])->value('name'); + $item->supplier_name = Supplier::where('id',$item['supplier_id'])->value('mer_name'); + $find = StoreProduct::where('id',$item['product_id'])->find(); + $item->store_name=$find['store_name']; + $item->image=$find['image']; + }); + $count=WarehouseProduct::where($where)->count(); + } + return ['lists'=>$list,'count'=>$count]; + } }