From c9f7d1a9961e96f8dbd63dd58eb0a93f918d1b01 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 22 Aug 2024 15:33:04 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E4=BB=93=E5=BA=93?= =?UTF-8?q?=E5=BA=93=E5=AD=98=E8=AE=A1=E7=AE=97=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=95=86=E5=93=81=E5=BA=93=E5=AD=98=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=EF=BC=8C=E5=88=A0=E9=99=A4=E5=86=97=E4=BD=99=E5=BA=93?= =?UTF-8?q?=E5=AD=98=E6=A3=80=E6=9F=A5=E4=BB=A3=E7=A0=81=EF=BC=8C=E6=9B=B4?= =?UTF-8?q?=E6=94=B9=E5=BA=93=E5=AD=98=E6=9F=A5=E8=AF=A2=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WarehouseOrderController.php | 15 +++++----- .../StoreOrderCartInfoLists.php | 4 +-- app/admin/logic/statistic/WarehouseLogic.php | 30 ++++++++++--------- .../WarehouseProductLogic.php | 6 ++-- .../model/store_product/StoreProduct.php | 1 + 5 files changed, 29 insertions(+), 27 deletions(-) diff --git a/app/admin/controller/warehouse_order/WarehouseOrderController.php b/app/admin/controller/warehouse_order/WarehouseOrderController.php index 16cf1d31c..c03ed4932 100644 --- a/app/admin/controller/warehouse_order/WarehouseOrderController.php +++ b/app/admin/controller/warehouse_order/WarehouseOrderController.php @@ -74,13 +74,13 @@ class WarehouseOrderController extends BaseAdminController $delivery_time = $this->request->post('delivery_time'); $mark = $this->request->post('mark'); $count = count($store_arr); - foreach ($product_arr as $key => $arr) { - $stock = bcmul($arr['stock'], $count); - $nums = WarehouseProductStorege::where('warehouse_id', $warehouse_id)->where('product_id', $arr['id'])->value('nums'); - if ($nums < $stock) { - return $this->fail('商品库存不足'); - } - } + // foreach ($product_arr as $key => $arr) { + // $stock = bcmul($arr['stock'], $count); + // $nums = WarehouseProductStorege::where('warehouse_id', $warehouse_id)->where('product_id', $arr['id'])->value('nums'); + // if ($nums < $stock) { + // return $this->fail('商品库存不足'); + // } + // } Db::startTrans(); try { if ($count == 1) { @@ -124,7 +124,6 @@ class WarehouseOrderController extends BaseAdminController Db::commit(); } catch (\Throwable $e) { Db::rollback(); - d($e); throw new BusinessException($e->getMessage()); } return $this->success('已导入后台队列,请在门店入库记录中查看', [], 1, 1); diff --git a/app/admin/lists/store_order_cart_info/StoreOrderCartInfoLists.php b/app/admin/lists/store_order_cart_info/StoreOrderCartInfoLists.php index 7878ee999..dd9234c10 100644 --- a/app/admin/lists/store_order_cart_info/StoreOrderCartInfoLists.php +++ b/app/admin/lists/store_order_cart_info/StoreOrderCartInfoLists.php @@ -32,7 +32,7 @@ class StoreOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchI public function setSearch(): array { return [ - '=' => ['oid','product_id'], + '=' => ['oid','product_id','is_pay'], ]; } @@ -49,7 +49,7 @@ class StoreOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchI public function lists(): array { return StoreOrderCartInfo::where($this->searchWhere) - ->field('cart_info,product_id,store_id,cart_num,price,total_price,create_time')->limit($this->limitOffset, $this->limitLength) + ->field('oid,cart_info,product_id,store_id,cart_num,price,total_price,create_time')->limit($this->limitOffset, $this->limitLength) ->select()->each(function ($item) { $find=StoreProduct::where('id',$item['product_id'])->field('image,unit,store_name,store_info')->find(); if($find){ diff --git a/app/admin/logic/statistic/WarehouseLogic.php b/app/admin/logic/statistic/WarehouseLogic.php index e57bac543..a7ff4ec4e 100644 --- a/app/admin/logic/statistic/WarehouseLogic.php +++ b/app/admin/logic/statistic/WarehouseLogic.php @@ -60,7 +60,7 @@ class WarehouseLogic extends BaseLogic $topData[] = [ 'title' => '总仓库库存', 'desc' => '平台统计仓库库存', - 'total_money' => WarehouseProductStorege::sum('stock'), + 'total_money' => WarehouseProductStorege::sum('nums'), 'cash_title' => 0, 'value' => [], 'type' => 1, @@ -68,7 +68,7 @@ class WarehouseLogic extends BaseLogic $topData[] = [ 'title' => '海吉星仓库库存', 'desc' => '平台统计海吉星仓库库存', - 'total_money' => WarehouseProductStorege::where('warehouse_id',1)->sum('stock'), + 'total_money' => WarehouseProductStorege::where('warehouse_id',1)->sum('nums'), 'cash_title' => 0, 'value' => [], 'type' => 1, @@ -76,7 +76,7 @@ class WarehouseLogic extends BaseLogic $topData[] = [ 'title' => '泸县集采集配库存', 'desc' => '平台统计泸县集采集配库存', - 'total_money' => WarehouseProductStorege::where('warehouse_id',2)->sum('stock'), + 'total_money' => WarehouseProductStorege::where('warehouse_id',2)->sum('nums'), 'cash_title' => 0, 'value' => [], 'type' => 1, @@ -105,17 +105,19 @@ class WarehouseLogic extends BaseLogic public static function warehouse_list() { - $list = StoreProduct::where('is_show', 1)->select()->each(function ($item) { - $item->sales = StoreOrderCartInfo::where('product_id', $item['id'])->sum('cart_num'); - $store_stock = StoreBranchProduct::where('product_id', $item['id'])->sum('stock'); - $warehouse_stock = WarehouseProductStorege::where('product_id', $item['id'])->sum('nums'); - $item->store_stock=$store_stock; - $item->warehouse_stock=$warehouse_stock; - $item->total_stock=$store_stock+$warehouse_stock; - $item->total_purchase=WarehouseProduct::where('product_id', $item['id'])->sum('total_price'); - $item->total_completed_amount=WarehouseProduct::where('product_id', $item['id'])->where('is_pay',1)->sum('total_price'); - $item->total_outstanding_amount=WarehouseProduct::where('product_id', $item['id'])->where('is_pay',0)->sum('total_price'); - + $list = StoreProduct::where('is_show', 1) + ->field('id,store_name,image') + ->select()->each(function ($item) { + // $item->sales = StoreOrderCartInfo::where('product_id', $item['id'])->where('is_pay',1)->sum('cart_num'); + // $store_stock = StoreBranchProduct::where('product_id', $item['id'])->sum('stock'); + // $warehouse_stock = WarehouseProductStorege::where('product_id', $item['id'])->sum('nums'); + // $item->store_stock=$store_stock; + // $item->warehouse_stock=$warehouse_stock; + // $item->total_stock=$store_stock+$warehouse_stock; + // $item->total_purchase=WarehouseProduct::where('product_id', $item['id'])->sum('total_price'); + // $item->total_completed_amount=WarehouseProduct::where('product_id', $item['id'])->where('is_pay',1)->sum('total_price'); + // $item->total_outstanding_amount=WarehouseProduct::where('product_id', $item['id'])->where('is_pay',0)->sum('total_price'); + // sum(branch_product.stock) as store_stock,sum(w_p.total_price) as total_purchase, })->toArray(); return $list; } diff --git a/app/admin/logic/warehouse_product/WarehouseProductLogic.php b/app/admin/logic/warehouse_product/WarehouseProductLogic.php index c1731767c..5e1f61526 100644 --- a/app/admin/logic/warehouse_product/WarehouseProductLogic.php +++ b/app/admin/logic/warehouse_product/WarehouseProductLogic.php @@ -42,9 +42,9 @@ class WarehouseProductLogic extends BaseLogic if ($storege) { if ($params['financial_pm'] == 0) { $after_nums = $storege['nums'] - $params['nums']; - if ($after_nums < 0) { - throw new BusinessException('库存不足,warehouse_id:'.$params['warehouse_id'].'product_id:'.$params['product_id']); - } + // if ($after_nums < 0) { + // throw new BusinessException('库存不足,warehouse_id:'.$params['warehouse_id'].'product_id:'.$params['product_id']); + // } WarehouseProductStorege::where('id', $storege['id'])->dec('nums', $params['nums'])->update(); //门店加库存 $storeBranchProduct = StoreBranchProduct::where('product_id', $params['product_id'])->where('store_id',$params['store_id'])->find(); diff --git a/app/common/model/store_product/StoreProduct.php b/app/common/model/store_product/StoreProduct.php index dc810fdda..871b88caf 100644 --- a/app/common/model/store_product/StoreProduct.php +++ b/app/common/model/store_product/StoreProduct.php @@ -5,6 +5,7 @@ namespace app\common\model\store_product; use app\common\model\BaseModel; use app\common\model\store_category\StoreCategory; +use app\common\model\store_order_cart_info\StoreOrderCartInfo; use app\common\model\store_product_unit\StoreProductUnit; use think\model\concern\SoftDelete;