From 18fbbdeb366525a8c41acc6399770390b9d383a0 Mon Sep 17 00:00:00 2001
From: mkm <727897186@qq.com>
Date: Wed, 9 Oct 2024 14:06:02 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BB=93=E5=BA=93=E8=AE=A2?=
 =?UTF-8?q?=E5=8D=95=E5=AF=BC=E5=87=BA=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

- 移除了 IndexController 中的旧代码,该代码已不再使用
- 优化了 WarehouseOrderController 中的导出逻辑:
  - 移除了 withTrashed() 方法,避免导出已删除的产品
  - 修改了导出表格的列,增加了 'oid' 字段
  - 调整了导出文件名的生成逻辑,现在使用仓库名称和日期组合
---
 .../WarehouseOrderController.php              | 16 ++++-----
 app/api/controller/IndexController.php        | 35 -------------------
 2 files changed, 8 insertions(+), 43 deletions(-)

diff --git a/app/admin/controller/warehouse_order/WarehouseOrderController.php b/app/admin/controller/warehouse_order/WarehouseOrderController.php
index b6b4c6fa1..435d9df6e 100644
--- a/app/admin/controller/warehouse_order/WarehouseOrderController.php
+++ b/app/admin/controller/warehouse_order/WarehouseOrderController.php
@@ -230,15 +230,15 @@ class WarehouseOrderController extends BaseAdminController
         $total_price=0;
         foreach ($data as $key => &$value) {
             if(in_array($order['store_id'],[17,18])){
-                $find = StoreBranchProduct::where('product_id', $value->product_id)->where('store_id',$order['store_id'])->withTrashed()->find();
+                $find = StoreBranchProduct::where('product_id', $value->product_id)->where('store_id',$order['store_id'])->find();
             }else{
-                $find = StoreProduct::where('id', $value->product_id)->withTrashed()->find();
+                $find = StoreProduct::where('id', $value->product_id)->find();
             }
             $value->store_name = $find['store_name'] ?? '';
             $value->store_info = $find['store_info'] ?? '';
             if($type==2){
-                $value->price = $find['purchase'];
-                $value->total_price=bcmul($find['purchase'],$value['nums'],2);
+                $value->price = $value['purchase'];
+                $value->total_price=bcmul($value['purchase'],$value['nums'],2);
                 $total_price+=$value->total_price;
             }elseif($type==3){
                 $value->price = $find['cost'];
@@ -284,14 +284,14 @@ class WarehouseOrderController extends BaseAdminController
     {
         $id = $this->request->post('id');
         $warehouseOrder = WarehouseOrder::where('id', $id)->field('store_id,delivery_time')->find();
-        $system_store = SystemStore::where('id', $warehouseOrder['store_id'])->value('name');
-        $data = WarehouseProduct::where('oid', $id)->where('financial_pm',0)->field('product_id,nums')->select()
+        $system_store = SystemStore::where('id', $warehouseOrder['store_id'])->value('introduction');
+        $data = WarehouseProduct::where('oid', $id)->where('financial_pm',0)->field('oid,product_id,nums')->select()
             ->each(function ($item) use ($system_store,$warehouseOrder) {
-                $item['system_store'] = $system_store;
+                $item['system_store'] = $system_store.'  '.$item['oid'];
                 $find = StoreProduct::where('id', $item['product_id'])->field('store_name,unit')->find();
                 $item['store_name'] = $find['store_name'];
                 $unit_name = StoreProductUnit::where('id', $find['unit'])->value('name');
-                $item['unit_name'] = $item['nums'].'/'.$unit_name.'     '.date('m-d',$warehouseOrder['delivery_time']);
+                $item['unit_name'] = $item['nums'].'/'.$unit_name.' '.date('m-d',$warehouseOrder['delivery_time']);
             })
             ->toArray();
         $file_path=(new Beforehand())->export($data, $system_store);
diff --git a/app/api/controller/IndexController.php b/app/api/controller/IndexController.php
index 47238ffbb..d72bd27f3 100644
--- a/app/api/controller/IndexController.php
+++ b/app/api/controller/IndexController.php
@@ -48,41 +48,6 @@ class IndexController extends BaseApiController
 
     public function index()
     {
-        // 创建一个新的PHPWord文档
-        $phpWord = new \PhpOffice\PhpWord\PhpWord();
-
-        // 添加一个节
-        $section = $phpWord->addSection(array(
-            'pageSizeW' => Converter::cmToTwip(4), // 宽度转换为twips
-            'pageSizeH' => Converter::cmToTwip(2), // 高度转换为twips
-            'marginLeft' => Converter::cmToTwip(0.2),
-            'marginRight' => Converter::cmToTwip(0),
-            'marginTop' => Converter::cmToTwip(0.2),
-            'marginBottom' => Converter::cmToTwip(0),
-        ));
-
-        // 在节中添加一些内容
-        // 添加文本
-        $text = '这是一段测试文本,啊实打实的';
-        $text1 = '这是一段测试文本,啊实打实的';
-        $text2 = '这是一段测试文本,啊实打实的';
-        // 检查文本宽度是否超过纸张宽度
-        $fontStyle = ['name' => 'Arial', 'size' => 12, 'bold' => true];
-
-        // 比较文本宽度和纸张宽度
-        $section->addText(mb_substr($text, 0, 8, 'UTF-8'), $fontStyle);
-        $section->addText(mb_substr($text1, 0, 8, 'UTF-8'), $fontStyle);
-        $section->addText(mb_substr($text2, 0, 8, 'UTF-8'), $fontStyle);
-        $section->addText(mb_substr($text, 0, 8, 'UTF-8'), $fontStyle);
-        $section->addText(mb_substr($text1, 0, 8, 'UTF-8'), $fontStyle);
-        $section->addText(mb_substr($text2, 0, 8, 'UTF-8'), $fontStyle);
-
-        $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
-
-        $url =  '/export/' . date('Y-m') . '/' . '标签单-' . date('Y-m-d') . '.docx';
-
-        $a = $objWriter->save(public_path() . $url);
-        d($a);
         return json(1);
 
         $financeFlow = new StoreFinanceFlow();