From 6e0a9e73f1ea0a63ab14298d02a95b9199f168cd Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 6 Sep 2024 17:53:43 +0800 Subject: [PATCH] =?UTF-8?q?feat(warehouse=5Fproduct):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=BB=93=E5=BA=93=E4=BA=A7=E5=93=81=E7=BB=93=E7=AE=97=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WarehouseProductController.php | 11 ++++++++++ .../lists/statistics/StoreProductLists.php | 12 ++++++++++- .../StoreBranchProductLists.php | 2 +- app/admin/lists/supplier/SupplierLists.php | 7 +++++-- .../WarehouseProductLists.php | 4 ++-- .../WarehouseProductLogic.php | 21 +++++++++++++++++++ .../validate/supplier/SupplierValidate.php | 4 ++-- app/common/service/xlsx/OrderDetail.php | 18 +++++++++------- 8 files changed, 64 insertions(+), 15 deletions(-) diff --git a/app/admin/controller/warehouse_product/WarehouseProductController.php b/app/admin/controller/warehouse_product/WarehouseProductController.php index 35f2971d..1578d14a 100644 --- a/app/admin/controller/warehouse_product/WarehouseProductController.php +++ b/app/admin/controller/warehouse_product/WarehouseProductController.php @@ -109,6 +109,17 @@ class WarehouseProductController extends BaseAdminController return $this->data($result); } + /** + * @notes 结算 + * @return \think\response\Json + * @author admin + * @date 2024/07/31 16:55 + */ + public function settlement(){ + $id=$this->request->post('id'); + $result = WarehouseProductLogic::settlement($id); + return $this->success('结算成功', [], 1, 1); + } /** * 确认操作 */ diff --git a/app/admin/lists/statistics/StoreProductLists.php b/app/admin/lists/statistics/StoreProductLists.php index b6bb6704..f64a536d 100644 --- a/app/admin/lists/statistics/StoreProductLists.php +++ b/app/admin/lists/statistics/StoreProductLists.php @@ -80,7 +80,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa $list = StoreProduct::where($this->searchWhere) ->alias('p') // 为 StoreProduct 表设置别名 ->limit($this->limitOffset, $this->limitLength) - ->field('p.id, p.store_name, p.image,p.stock as total_stock,p.unit, + ->field('p.id, p.store_name, p.image,p.stock as total_stock,p.unit,p.total_price, (SELECT SUM(c.cart_num) FROM `la_store_order_cart_info` c WHERE c.product_id=p.id AND c.is_pay=1 AND c.delete_time IS NULL) AS sales, (SELECT SUM(b.stock) FROM `la_store_branch_product` b WHERE b.product_id=p.id AND b.delete_time IS NULL) AS store_stock, (SELECT SUM(w.nums) FROM `la_warehouse_product_storege` w WHERE w.product_id=p.id AND w.delete_time IS NULL) AS warehouse_stock, @@ -110,6 +110,16 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa }else{ $item->total_purchase='0元'; } + if($item->total_price){ + $item->total_price=$item->total_price.'元'; + }else{ + $item->total_price='0元'; + } + if($item->total_stock){ + $item->total_stock=$item->total_stock.'|'.$unit_name; + }else{ + $item->total_stock=''; + } }) ->toArray(); return $list; diff --git a/app/admin/lists/store_branch_product/StoreBranchProductLists.php b/app/admin/lists/store_branch_product/StoreBranchProductLists.php index 032545c9..3feb38d7 100644 --- a/app/admin/lists/store_branch_product/StoreBranchProductLists.php +++ b/app/admin/lists/store_branch_product/StoreBranchProductLists.php @@ -83,7 +83,7 @@ class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchI $this->searchWhere[] = $where; } return StoreBranchProduct::where($this->searchWhere) - ->field(['id', 'store_id', 'product_id', 'image', 'store_name', 'store_info', 'cate_id', 'price', 'sales', 'stock', 'unit', 'cost', 'purchase', 'status', 'batch', 'vip_price','bar_code', 'manufacturer_information']) + ->field(['id', 'store_id', 'product_id', 'image', 'store_name', 'store_info', 'cate_id', 'price', 'sales', 'stock', 'unit', 'cost', 'purchase', 'status', 'batch', 'vip_price','bar_code', 'manufacturer_information','total_price']) ->when(!empty($this->adminInfo['store_id']), function ($query) { $query->where('store_id', $this->adminInfo['store_id']); }) diff --git a/app/admin/lists/supplier/SupplierLists.php b/app/admin/lists/supplier/SupplierLists.php index a9321cc6..c0757cda 100644 --- a/app/admin/lists/supplier/SupplierLists.php +++ b/app/admin/lists/supplier/SupplierLists.php @@ -6,7 +6,7 @@ namespace app\admin\lists\supplier; use app\admin\lists\BaseAdminDataLists; use app\common\model\supplier\Supplier; use app\common\lists\ListsSearchInterface; - +use app\common\model\warehouse_product\WarehouseProduct; /** * 供应链列表 @@ -47,7 +47,10 @@ class SupplierLists extends BaseAdminDataLists implements ListsSearchInterface ->field(['id', 'category_id', 'mer_name', 'phone', 'settle_cycle', 'address', 'mark']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) - ->select() + ->select()->each(function ($item) { + $item->total_completed_amount=WarehouseProduct::where('supplier_id',$item['id'])->where('financial_pm',1)->where('is_pay',1)->sum('total_price'); + $item->total_outstanding_amount=WarehouseProduct::where('supplier_id',$item['id'])->where('financial_pm',1)->where('is_pay',0)->sum('total_price'); + }) ->toArray(); } diff --git a/app/admin/lists/warehouse_product/WarehouseProductLists.php b/app/admin/lists/warehouse_product/WarehouseProductLists.php index beffc597..c36d44e2 100644 --- a/app/admin/lists/warehouse_product/WarehouseProductLists.php +++ b/app/admin/lists/warehouse_product/WarehouseProductLists.php @@ -33,7 +33,7 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt public function setSearch(): array { return [ - '=' => ['warehouse_id', 'financial_pm', 'store_id','oid','supplier_id'], + '=' => ['warehouse_id', 'financial_pm', 'store_id','oid','supplier_id','is_pay'], 'between_time' => 'create_time' ]; } @@ -71,7 +71,7 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt } } return WarehouseProduct::where($this->searchWhere) - ->field(['id', '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']) + ->field(['id', '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']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function ($item) { diff --git a/app/admin/logic/warehouse_product/WarehouseProductLogic.php b/app/admin/logic/warehouse_product/WarehouseProductLogic.php index 20c547c9..33652898 100644 --- a/app/admin/logic/warehouse_product/WarehouseProductLogic.php +++ b/app/admin/logic/warehouse_product/WarehouseProductLogic.php @@ -236,6 +236,27 @@ class WarehouseProductLogic extends BaseLogic throw new BusinessException('没有查到出入库信息'); } + /** + * * @notes 结算 + * @param $id + * @return void + */ + public static function settlement($id){ + Db::startTrans(); + try { + $find=WarehouseProduct::where(['id'=>$id,'financial_pm'=>1,'is_pay'=>0])->find(); + if($find){ + $find->is_pay=1; + $find->save(); + } else{ + throw new BusinessException('没有查到出入库信息'); + } + Db::commit(); + } catch (\Throwable $th) { + Db::rollback(); + throw new BusinessException($th->getMessage()); + } + } /** * @notes 获取商品仓储信息详情 * @param $params diff --git a/app/admin/validate/supplier/SupplierValidate.php b/app/admin/validate/supplier/SupplierValidate.php index 92f4322c..1aa1d662 100644 --- a/app/admin/validate/supplier/SupplierValidate.php +++ b/app/admin/validate/supplier/SupplierValidate.php @@ -52,7 +52,7 @@ class SupplierValidate extends BaseValidate */ public function sceneAdd() { - return $this->only(['mer_name','phone','settle_cycle','address','mark','status']); + return $this->only(['mer_name','phone','settle_cycle','address']); } @@ -64,7 +64,7 @@ class SupplierValidate extends BaseValidate */ public function sceneEdit() { - return $this->only(['id','mer_name','phone','settle_cycle','address','mark','status']); + return $this->only(['id','mer_name','phone','settle_cycle','address']); } diff --git a/app/common/service/xlsx/OrderDetail.php b/app/common/service/xlsx/OrderDetail.php index 84ba39e8..2fa5e115 100644 --- a/app/common/service/xlsx/OrderDetail.php +++ b/app/common/service/xlsx/OrderDetail.php @@ -106,13 +106,17 @@ class OrderDetail $sheet->mergeCells('A' . ($count + 11) . ':J' . $count + 11); - $sheet->setCellValue('A' . $count + 12, '仓库',); - // $sheet->setCellValue('B' . $count + 11, $this->warehouse); + + $sheet->setCellValue('A' . $count + 12, '下单人',); $sheet->mergeCells('B' . ($count + 12) . ':C' . $count + 12); - $sheet->setCellValue('D' . $count + 12, '送货'); - $sheet->mergeCells('E' . ($count + 12) . ':F' . $count + 12); - $sheet->setCellValue('G' . $count + 12, '签收人'); - $sheet->mergeCells('H' . ($count + 12) . ':J' . $count + 12); + $sheet->setCellValue('D' . $count + 12, '电话'); + + $sheet->setCellValue('A' . $count + 13, '仓库',); + $sheet->mergeCells('B' . ($count + 13) . ':C' . $count + 13); + $sheet->setCellValue('D' . $count + 13, '送货'); + $sheet->mergeCells('E' . ($count + 13) . ':F' . $count + 13); + $sheet->setCellValue('G' . $count + 13, '签收人'); + $sheet->mergeCells('H' . ($count + 13) . ':J' . $count + 13); // 设置单元格的样式 $styleArray = [ @@ -131,7 +135,7 @@ class OrderDetail ], ], ]; - $sheet->getStyle('A1:J' . ($count + 12))->applyFromArray($styleArray); + $sheet->getStyle('A1:J' . ($count + 13))->applyFromArray($styleArray); // 保存文件到 public 下