cqp hace 14 horas
padre
commit
cbddd0cf6c

+ 159 - 0
app/Exports/ExportOrder2.php

@@ -340,4 +340,163 @@ class ExportOrder2 extends DefaultValueBinder implements WithCustomValueBinder ,
             },
         ];
     }
+
+    private function jc3_set()
+    {
+        return [
+            AfterSheet::class => function (AfterSheet $event) {
+                $sheet = $event->sheet->getDelegate();
+
+                // ==========================
+                // 1. 第一行:大标题 (A1:Z2)
+                // 根据你的要求到 X2,但后面合计到了 Z,这里建议合并到 Z 保持美观
+                // ==========================
+                $sheet->mergeCells('A1:Z2');
+                $sheet->setCellValue('A1', '各业务员利润');
+
+                // ==========================
+                // 2. 第三、四行:固定表头与人员分组
+                // ==========================
+                $sheet->mergeCells('A3:A4');
+                $sheet->setCellValue('A3', '分类');
+                $sheet->mergeCells('B3:B4');
+                $sheet->setCellValue('B3', '项目');
+
+                // --- C-F: 张春勇、霍尚琳 (4列) ---
+                $sheet->mergeCells('C3:F3');
+                $sheet->setCellValue('C3', '张春勇、霍尚琳(社区加通路)');
+                $sheet->setCellValue('C4', '张春勇当月(社区)');
+                $sheet->setCellValue('D4', '张春勇、霍尚琳当月(通路)');
+                $sheet->setCellValue('E4', '合计');
+                $sheet->setCellValue('F4', '年累计(7月-明年的6月)');
+
+                // --- G-J: 金小勇 (4列) ---
+                $sheet->mergeCells('G3:J3');
+                $sheet->setCellValue('G3', '金小勇(通路,不含加盟)');
+                $sheet->setCellValue('G4', '当月通路');
+                $sheet->setCellValue('H4', '当月联华加盟');
+                $sheet->setCellValue('I4', '月合计');
+                $sheet->setCellValue('J4', '年累计(7月-明年的6月)');
+
+                // --- K-N: 沈强 (4列) ---
+                $sheet->mergeCells('K3:N3');
+                $sheet->setCellValue('K3', '沈强(通路,不含智鲸)');
+                $sheet->setCellValue('K4', '当月通路');
+                $sheet->setCellValue('L4', '当月智鲸');
+                $sheet->setCellValue('M4', '月合计');
+                $sheet->setCellValue('N4', '年累计(7月-明年的6月)');
+
+                // --- O-P: 王利英等 (2列) ---
+                $sheet->mergeCells('O3:P3');
+                $sheet->setCellValue('O3', '王利英、翁春燕、裴志华(通路加大卖场)');
+                $sheet->setCellValue('O4', '当月');
+                $sheet->setCellValue('P4', '年累计(7月-明年的6月)');
+
+                // --- Q-T: 叶南汝 (4列) ---
+                $sheet->mergeCells('Q3:T3');
+                $sheet->setCellValue('Q3', '叶南汝(通路加大卖场)');
+                $sheet->setCellValue('Q4', '当月通路');
+                $sheet->setCellValue('R4', '当月大卖场');
+                $sheet->setCellValue('S4', '当月合计');
+                $sheet->setCellValue('T4', '年累计(7月-明年的6月)');
+
+                // --- U-V: 行政 (2列) ---
+                $sheet->mergeCells('U3:V3');
+                $sheet->setCellValue('U3', '行政');
+                $sheet->setCellValue('U4', '当月');
+                $sheet->setCellValue('V4', '年累计(7月-明年的6月)');
+
+                // --- W-X: 鲍总 (2列) ---
+                $sheet->mergeCells('W3:X3');
+                $sheet->setCellValue('W3', '鲍总');
+                $sheet->setCellValue('W4', '当月');
+                $sheet->setCellValue('X4', '年累计(7月-明年的6月)');
+
+                // --- Y-Z: 合计 (2列) ---
+                $sheet->mergeCells('Y3:Z3');
+                $sheet->setCellValue('Y3', '合计');
+                $sheet->setCellValue('Y4', '当月');
+                $sheet->setCellValue('Z4', '年累计(7月-明年的6月)');
+
+                // ==========================
+                // 3. A列与B列内容 (5-32行)
+                // ==========================
+                $sheet->mergeCells('A5:A7');
+                $sheet->setCellValue('A5', '收入');
+
+                $sheet->mergeCells('A8:A32');
+                $sheet->setCellValue('A8', '销售支出');
+
+                $items = [
+                    5  => "收入",
+                    6  => "成本",
+                    7  => "毛利",
+                    8  => "结算费用(560116)",
+                    9  => "管理费(收入*5%)",
+                    10 => "物流配送(2.3%)",
+                    11 => "合同费(560115)",
+                    12 => "账扣费用(560114)",
+                    13 => "促销员工资(560113)",
+                    14 => "团购及其他返点(560105)",
+                    15 => "陈列费(560120)",
+                    16 => "客情费(560112)",
+                    17 => "赠品费用(560111)",
+                    18 => "广告宣传费(560110)",
+                    19 => "快递费(560109)",
+                    20 => "销售其他费用(560101)",
+                    21 => "员工工资支出(560119)",
+                    22 => "员工社保、福利费(560118)",
+                    23 => "退货亏损(不良仓)",
+                    24 => "采购费用(手工)(按人事计提)",
+                    25 => "税金(1%)",
+                    26 => "财务手续费(1%)",
+                    27 => "其他出库单",
+                    28 => "其他(1)为后续准备",
+                    29 => "其他(2)为后续准备",
+                    30 => "其他(3)为后续准备",
+                    31 => "其他(4)为后续准备",
+                    32 => "销售支出小计",
+                ];
+
+                foreach ($items as $rowNum => $text) {
+                    $sheet->setCellValue("B{$rowNum}", $text);
+                }
+
+                // ==========================
+                // 4. 样式设置
+                // ==========================
+                $lastCol = 'Z';
+                $sheet->getStyle("A1:{$lastCol}32")
+                    ->getAlignment()
+                    ->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER)
+                    ->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER)
+                    ->setWrapText(true);
+
+                // 设置列宽
+                $sheet->getColumnDimension('A')->setWidth(10);
+                $sheet->getColumnDimension('B')->setWidth(35);
+                foreach (range('C', $lastCol) as $col) {
+                    $sheet->getColumnDimension($col)->setWidth(16);
+                }
+
+                // ==========================
+                // 5. 数据填充逻辑 (从C5开始)
+                // ==========================
+                // 假设 $this->data 是一个二维数组,每一行代表从 C 列到 Z 列的值
+                $dataRowIndex = 0;
+                for ($row = 5; $row <= 32; $row++) {
+                    $rowValues = $this->data[$dataRowIndex] ?? [];
+                    $colIndex = 0;
+                    // 从 C (Index 3) 到 Z (Index 26)
+                    for ($col = 3; $col <= 26; $col++) {
+                        $colLetter = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::stringFromColumnIndex($col);
+                        $val = $rowValues[$colIndex] ?? '';
+                        $sheet->setCellValue($colLetter . $row, $val);
+                        $colIndex++;
+                    }
+                    $dataRowIndex++;
+                }
+            },
+        ];
+    }
 }

+ 2 - 1
app/Http/Controllers/Api/StatisticsController.php

@@ -130,7 +130,8 @@ class StatisticsController extends BaseController
     public function statisticsRoad(Request $request){
         $service = new StatisticsService();
         $userData = $request->userData->toArray();
-        list($status,$data) = $service->statisticsRoad($request->all(),$userData);
+//        list($status,$data) = $service->statisticsRoad($request->all(),$userData);
+        list($status,$data) = $service->statisticsMan($request->all(),$userData);
 
         if($status){
             return $this->json_return(200,'',$data);

+ 0 - 264
app/Http/Controllers/Api/TestController.php

@@ -2,270 +2,6 @@
 
 namespace App\Http\Controllers\Api;
 
-
-use App\Model\BoxDetail;
-use App\Model\Depart;
-use App\Model\InOutRecord;
-use App\Model\Inventory;
-use App\Model\OutBoundOrder;
-use App\Model\Product;
-use App\Model\ProductInventory;
-use App\Model\ProductPriceDetail;
-use App\Model\PurchaseOrderInfoForOutBound;
-use App\Model\ReturnExchangeOrder;
-use App\Service\Box\BoxHookService;
-use App\Service\CheckService;
-use App\Service\EmployeeService;
-use App\Service\MeasureService;
-use App\Service\OaService;
-use App\Service\OperationLogService;
-use App\Service\OrderNoService;
-use App\Service\SalesOrderService;
-use App\Service\TPlusDatabaseServerService;
-use App\Service\WDTService;
-use Illuminate\Http\Request;
-use Illuminate\Support\Facades\DB;
-use Illuminate\Support\Facades\Hash;
-
-
 class TestController extends BaseController
 {
-
-
-    public function tt(){
-
-    }
-
-    public function boxInsert(){
-
-    }
-
-    public function aa(){echo 'ok';die;
-        $service = new TPlusDatabaseServerService(true);
-        if(! empty($service->error)) return [false, $service->error];
-        list($s, $msg) = $service->getSnList(["sn_type"=>1,"code"=>"1000004805"],[]);
-        return $this->json_return(200,'',$msg);dd(1111);
-        $array = (new SalesOrderService())->salesOrderPdf(['id' => 37938],['id'=>1,'head'=>['id' =>2]]);dd($array);
-        dd(2);$this->test3();dd(222);
-        (new WDTService())->getOrderListAuto([]);dd(222);
-        $service = new TPlusDatabaseServerService(true);
-        if(! empty($service->error)) return [false, $service->error];
-        dd(11111);
-        $this->test1();
-//        $array = (new SalesOrderService())->salesOrderPdf(['id' => 26604],['id'=>1,'head'=>['id' =>2]]);
-//        return view('pdf.salesOrder',['order' => $array]);
-        $send_data[] = [
-            'employee_id' => 1,
-            'type' => 2,
-            'state' => 0,
-            'menu_id' => 34,
-            'order_number' => "T9RMO.202408071529012839",
-            'tmp_data' => [
-                "T9RMO.202408071529012839",
-                "施工单",
-                '已完结',
-                "ee",
-                date('Y-m-d H:i:s'),
-            ],
-        ];
-        (new OaService())->sendWxOaCheckMessage($send_data);dd(11)
-               (new OaService())->sendWxMsg(1,2,0,34,["T9RMO.202408071529012839","施工单","待确认","陈庆鹏","2024-08-07 15:29:44"]);dd(1);
-//       (new OaService())->sendWxMsg(1,3,2,48,["T9RMO.202408071529012839","拒绝","2024-08-07 15:29:44","(未填写原因)"],"/pages/ReturnExchangeOrder/detail/detail?order_number=55");
-
-        //测试消息发送
-//        $tmp_data = [
-//            "T9XS.20240824095952611883",
-//            '陈庆鹏(订单合同)',
-//            '刁法森',
-//            date('Y-m-d H:i:s'),
-//        ];
-//        (new OaService())->sendWxMsg(1,1,0,37,$tmp_data,"/pageA/pages/SalesOrder/detail/detail?order_number=T9XS.20240824095952611883");
-        $tmp_data = [
-            "XNCG202411241422297482",
-            "拒绝",
-            "2024-11-24 14:22:29",
-            "测试"
-        ];
-        (new OaService())->sendWxMsg(1,3,2,44,$tmp_data,"/pageA/pages/SalesOrder/detail/detail?order_number=T9XX.2024080912410029251");dd(1);
-
-        //测试消息发送
-        $tmp_data = [
-            "22222",
-            '222',
-            '审核通过',
-            '22222',
-            date('Y-m-d H:i:s'),
-
-        ];
-//        (new OaService())->sendWxMsg(1,2,1,37,$tmp_data,"/pages/SalesOrder/index/index");
-
-        //测试消息发送
-        $tmp_data = [
-            "333333",
-            '审核通过',
-            date('Y-m-d H:i:s'),
-            '22222',
-        ];
-//        (new OaService())->sendWxMsg(1,3,2,37,$tmp_data,"/pages/SalesOrder/index/index");
-die;
-        $params = json_decode('{"api_key":"d3848b47-4179-4b02-8d32-b78cd7672c6c","return_url":"https://payment.rummyliver.in/notify/s2pay/payment","mode":"LIVE","order_id":"1710493215363410880003","amount":"501.00","currency":"INR","description":"for payment","name":"iahfi","email":"jvqbgvv2908699@outlook.com","phone":"9329086994","city":"Mumbai","zip_code":"400002","country":"IND"}',true);
-
-        $hash_columns = ['merchant_reference_number','Amount','account_name','account_number','ifsc_code','bank_name','bank_branch','transfer_type','address_line_1', 'address_line_2', 'amount', 'api_key', 'city', 'country', 'currency', 'description', 'email', 'mode', 'name', 'order_id', 'phone', 'return_url', 'state', 'udf1', 'udf2', 'udf3', 'udf4', 'udf5', 'zip_code',];
-        sort($hash_columns);
-        $hash_data = '3b1db341fa70abc03af5c3676811a82bec99673f';
-        foreach ($hash_columns as $column) {
-            if (isset($params[$column])) {
-                if (strlen($params[$column]) > 0) {
-                    $hash_data .= '|' . trim($params[$column]);
-                }
-            }
-        }
-        $hash = strtoupper(hash("sha512", $hash_data));
-        var_dump($hash);die;
-        return $hash;
-
-        $text = '这是测试';
-        $key = '72f8c912d462b1md034ff46cbedaskc80bf';
-        $sign = Hash::make($text.$key);
-        var_dump(Hash::check('这是测试'.'72f8c912d462b1md034ff46cbedaskc80bf',$sign));
-        var_dump($sign);die;
-    }
-
-
-    public function test1(){dd(222);
-        $service = new CheckService();
-        $service->recordReturnExchangeOrder([],ReturnExchangeOrder::where('order_number',"TH202503071106328078")->first()->toArray());
-dd(1);
-        $data = OutBoundOrder::where('del_time',0)->select('data_id')->get()->toArray();
-        $data = array_column($data,'data_id');
-        $data = ReturnExchangeOrder::where('del_time',0)
-            ->whereIn('data_id',$data)
-            ->where('type',ReturnExchangeOrder::Order_type)
-            ->get()->toArray();
-        dd($data);
-        foreach ($data as $value){
-        }
-        dd(1);
-    }
-    public function clear(){
-        $in_record = InOutRecord::select('top_depart_id')
-            ->groupBy('top_depart_id')
-            ->get()->toArray();
-        $in_record = array_column($in_record,'top_depart_id');
-
-        $depart = Depart::whereIn('id',$in_record)
-            ->pluck('basic_type_id', 'id')
-            ->toArray();
-
-        $product_inventory = ProductInventory::whereIn('top_depart_id',$in_record)
-            ->select('id','product_id','storehouse_id','number','lock_number','top_depart_id')
-            ->get()->toArray();
-        $product_inventory_map = [];
-        foreach ($product_inventory as $value){
-            $key = $value['top_depart_id'] . $value['product_id'];
-            $product_inventory_map[$key] = 111;
-        }
-
-        $record_list = InOutRecord::where('del_time',0)
-            ->whereIn('top_depart_id',$in_record)
-            ->get()->toArray();
-        $list = [];$error1 = [];
-        foreach ($record_list as $value){
-            $key = $value['top_depart_id'] . $value['product_id'];
-            if(! isset($product_inventory_map[$key])){
-                $error1[] = $value;
-            }else{
-                if(isset($list[$key])){
-                    $number = bcadd($value['number'],$list[$key],2);
-                    $list[$key] = $number;
-                }else{
-                    $list[$key] = $value['number'];
-                }
-            }
-        }
-        if(! empty($error1)){
-            foreach ($error1 as $value){
-                InOutRecord::where('id', $value['id'])->update(['del_time' => 1233]);
-            }dd(1);
-        }
-
-        $error = [];
-        foreach ($product_inventory as $value){
-            $key = $value['top_depart_id'] . $value['product_id'];
-            if(isset($list[$key])){
-                $tmp = $list[$key];
-                if($tmp != $value['number']){
-                    $numbers = bcsub($value['number'],$tmp,2);
-                    $error[] = [
-                        'product_id' => $value['product_id'],
-                        'top_depart_id' => $value['top_depart_id'],
-                        'depart_id' => $value['top_depart_id'],
-                        'storehouse_id' => $value['storehouse_id'],
-                        'number' => $numbers,
-                    ];
-                }
-            }else{
-                $error[] = [
-                    'product_id' => $value['product_id'],
-                    'top_depart_id' => $value['top_depart_id'],
-                    'depart_id' => $value['top_depart_id'],
-                    'storehouse_id' => $value['storehouse_id'],
-                    'number' => $value['number'],
-                ];
-            }
-        }
-
-        if(empty($error)) dd('no data');
-dd($error);
-        $price_detail_map = [];
-        $price_detail = ProductPriceDetail::whereIn('product_id',array_unique(array_column($error,'product_id')))
-            ->select('product_id','price','basic_type_id')
-            ->get()->toArray();
-        foreach ($price_detail as $value){
-            $price_detail_map[$value['product_id'] . $value['basic_type_id']] = $value['price'];
-        }
-
-        $price_2 = Product::whereIn('id',array_unique(array_column($error,'product_id')))
-            ->pluck('retail_price','id')
-            ->toArray();
-
-        foreach ($error as $e => $value){
-            $basic_type_id = $depart[$value['top_depart_id']] ?? 0;
-            $key = $value['product_id'] . $basic_type_id;
-            $price = $price_detail_map[$key] ?? 0;
-            if(! $price) $price = $price_2[$value['product_id']] ?? 0;
-            if(! $price) dd(1);
-            if(! $value['number'] > 0) dd(2222);
-
-            $error[$e]['price'] = $price;
-            $error[$e]['crt_time'] = 1740758399;
-            $error[$e]['order_type'] = PurchaseOrderInfoForOutBound::prefix2;
-            $error[$e]['order_number'] = (new OrderNoService())->createOrderNumber(PurchaseOrderInfoForOutBound::prefix2);
-        }
-
-        InOutRecord::insert($error);
-        dd(count($error),$error);
-    }
-    public function test2(){
-        $server = "8u80504l59.vicp.fun,57323"; // 如 localhost, IP 或域名
-        $database = "UFDATA_101_2023";
-        $username = "sa";
-        $password = "Aa1";
-
-        try {
-            $conn = new \PDO("sqlsrv:Server=$server;Database=$database;Driver={ODBC Driver 17 for SQL Server}", $username, $password);
-            echo "Connected successfully\n";
-        } catch (\PDOException $e) {
-            echo "Connection failed: " . $e->getMessage() . "\n";
-        }
-    }
-    public function test3(){
-        $dsn = "sqlsrv:Server=8u80504l59.vicp.fun,57323;Database=UFDATA_101_2023";
-        $pdo = new \PDO($dsn, "sa", "TiZi#40068642538");
-        $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
-
-        // 成功连接
-        $this->db = DB::setPdo($pdo); // 可选:将这个 pdo 绑定给 DB Facade 使用
-        dd(11222333);
-    }
 }

+ 0 - 2
app/Http/Middleware/CheckLogin.php

@@ -2,8 +2,6 @@
 
 namespace App\Http\Middleware;
 
-use App\Model\Depart;
-use App\Model\ProductInventorySet;
 use App\Service\EmployeeService;
 use Closure;
 use App\Service\TokenService;

+ 16 - 0
app/Model/ItemReportMan.php

@@ -0,0 +1,16 @@
+<?php
+
+namespace App\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+class ItemReportMan extends Model
+{
+    protected $guarded = [];
+    protected $table = "item_report_man"; //指定表
+    const CREATED_AT = null;
+    const UPDATED_AT = null;
+    protected $dateFormat = 'U';
+
+    public static $field = ['*'];
+}

+ 17 - 1
app/Service/ExportFileService.php

@@ -465,7 +465,7 @@ class ExportFileService extends Service
         return [true, $filename];
     }
 
-    public function twl($ergs,$user){
+    public function twlold($ergs,$user){
         $service = new StatisticsService();
         $result = $service->getChannelReportRoad($ergs);
         if(empty($result)) return [false, '暂无数据'];
@@ -546,6 +546,22 @@ class ExportFileService extends Service
         return [true, $filename];
     }
 
+    public function twl($ergs,$user){
+        $service = new StatisticsService();
+        $result = $service->getChannelReportMan($ergs); // 得到 5-32 行的二维数组
+
+        if (!$result || (isset($result[0]) && $result[0] === false)) {
+            return [false, $result[1] ?? '暂无数据'];
+        }
+        $export = new ExportOrder2($result, 'jc3', []);
+        if(empty($file_name)) $file_name = self::$filename . "_". date("Y-m-d") . "_". rand(1000,9999);
+        $filename =  $file_name . '.' . 'xlsx';
+
+        Excel::store($export, "public/export/{$filename}");
+
+        return [true, $filename];
+    }
+
     // 辅助方法(可放在同一个类中)
     private function numberToExcelColumn(int $num): string
     {

+ 6 - 283
app/Service/ImportService.php

@@ -4,10 +4,6 @@ namespace App\Service;
 
 use App\Exports\TableHeadExport;
 use App\Import\ImportAll;
-use App\Model\Employee;
-use App\Model\Freight;
-use App\Model\GiveOut;
-use App\Model\Product;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Log;
 use Maatwebsite\Excel\Facades\Excel;
@@ -18,8 +14,6 @@ class ImportService extends Service
 {
     public static $type = [
         'product', //存货
-        'freight', //运费设置
-        'giveOut', //发放统计
     ];
 
     public function getTableTitleXls($data,$user){
@@ -33,11 +27,7 @@ class ImportService extends Service
         if(! $status) return [false, $msg];
 
         $headers = array_column($msg,'value');
-        $comments = [];
-        foreach ($msg as $value){
-            if(! empty($value['comments'])) $comments[$value['value']] = $value['comments'];
-        }
-        Excel::store(new TableHeadExport([], $headers, $comments),"/public/export/{$filename}", null, 'Xlsx', []);
+        Excel::store(new TableHeadExport([], $headers),"/public/export/{$filename}", null, 'Xlsx', []);
         return [true, ['file' => $filename]];
     }
 
@@ -59,26 +49,6 @@ class ImportService extends Service
         return [true, [$config_array, $filename]];
     }
 
-    private function freight($data,$user){
-        $config_array = $this->getTableConfig($data['type']);
-        if(empty($config_array)) return [false, ['导入配置表头文件不存在','']];
-
-        //生成下载文件
-        $filename =  "运费设置导入模板_" . time() . '.' . 'xlsx';
-
-        return [true, [$config_array, $filename]];
-    }
-
-    private function giveOut($data,$user){
-        $config_array = $this->getTableConfig($data['type']);
-        if(empty($config_array)) return [false, ['导入配置表头文件不存在','']];
-
-        //生成下载文件
-        $filename =  "发放统计导入模板_" . time() . '.' . 'xlsx';
-
-        return [true, [$config_array, $filename]];
-    }
-
     //导入入口
     public function importAll($data,$user){
 //        //不超时
@@ -141,52 +111,10 @@ class ImportService extends Service
         unset($array[0]);
         if(empty($array)) return [false, '导入数据不能为空'];
 
-        list($array, $error) = $this->checkCommon($array, $table_config);
-        if(! empty($error)) return [0, $error];
+        list($array, $error) = $this->checkProduct($array, $table_config);
         if(empty($array)) return [false, '导入数据不能为空'];
 
-        //查找产品
-        $product_map = Product::whereIn("code", array_column($array,0))
-            ->where('del_time',0)
-            ->pluck('id','code')
-            ->toArray();
-
-        $time = time();
-        $insert = $update = [];
-        foreach ($array as $value){
-            $tmp = [];
-            foreach ($value as $k => $val){
-                $field = $table_config[$k]['key'];
-                $tmp[$field] = $val;
-            }
-
-            if(isset($product_map[$tmp['code']])){
-                $product_id = $product_map[$tmp['code']];
-                //产品主表
-                $update[$product_id] = $tmp;
-            }else{
-                $tmp['crt_id'] = $user['id'];
-                $tmp['crt_time'] = $time;
-
-                //产品主表
-                $insert[$tmp['code']] = $tmp;
-            }
-        }
-
         try{
-            //新增
-            if(! empty($insert)){
-                Product::insert($insert);
-            }
-
-            //编辑
-            if(! empty($update)){
-                foreach ($update as $p_id => $value){
-                    Product::where('id',$p_id)
-                        ->update($value);
-                }
-            }
-
             DB::commit();
         }catch (\Exception $e){
             DB::rollBack();
@@ -196,170 +124,8 @@ class ImportService extends Service
         return [true, ''];
     }
 
-    public function freightImport($array, $user, $other_param){
-        $upload = $array[0];
-        list($status, $msg) = $this->compareTableAndReturn($upload, $other_param);
-        if(! $status) return [false, $msg];
-        $table_config = $msg;
-
-        // 去除表头
-        unset($array[0]);
-        if(empty($array)) return [false, '导入数据不能为空'];
-
-        list($array, $error) = $this->checkCommon($array, $table_config);
-        if(! empty($error)) return [0, $error];
-        if(empty($array)) return [false, '导入数据不能为空'];
-
-        $time = time();
-        $insert = [];
-        foreach ($array as $value){
-            $tmp = [];
-            foreach ($value as $k => $val){
-                $field = $table_config[$k]['key'];
-                $tmp[$field] = $val;
-            }
-
-            $tmp['crt_id'] = $user['id'];
-            $tmp['crt_time'] = $time;
-
-            $insert[] = $tmp;
-        }
-
-        try{
-            Freight::where('del_time',0)
-                ->update(['del_time' => $time]);
-            //新增
-            if(! empty($insert)) Freight::insert($insert);
-
-            DB::commit();
-        }catch (\Exception $e){
-            DB::rollBack();
-            return [false, $e->getMessage() . $e->getLine() . $e->getCode()];
-        }
-
-        return [true, ''];
-    }
-
-    public function giveOutImport($array, $user, $other_param){
-        $upload = $array[0];
-        list($status, $msg) = $this->compareTableAndReturn($upload, $other_param);
-        if(! $status) return [false, $msg];
-        $table_config = $msg;
-
-        // 去除表头
-        unset($array[0]);
-        if(empty($array)) return [false, '导入数据不能为空'];
-
-        list($array, $error) = $this->checkCommon($array, $table_config);
-        if(! empty($error)) return [0, $error];
-        if(empty($array)) return [false, '导入数据不能为空'];
-
-        $time = time();
-        $new_array = [];
-        foreach ($array as $value){
-            $tmp = [];
-            foreach ($value as $k => $val){
-                $field = $table_config[$k]['key'];
-                $tmp[$field] = $val;
-            }
-            $tmp['crt_id'] = $user['id'];
-            $tmp['crt_time'] = $time;
-
-            $new_array[] = $tmp;
-        }
-        $emp_map = Employee::where('del_time',0)
-            ->whereIn('emp_name', array_column($new_array,'employee_id_1_title'))
-            ->pluck('id','emp_name')
-            ->toArray();
-
-        $error_2 = [];
-        foreach ($new_array as $key => $value){
-            $line_number = $key + 2;
-            $line = '第' . $line_number . '行';
-            if(! isset($emp_map[$value['employee_id_1_title']])) {
-                $error_2[] = $line . "业务员不存在或已被删除";
-            }else{
-                $new_array[$key]['employee_id_1'] = $emp_map[$value['employee_id_1_title']];
-            }
-            list($status, $msg) = $this->convertExcelCellToDate($value['send_time']);
-            if(! $status){
-                $error_2[] = $line . "发放日期错误";
-            }else{
-                $new_array[$key]['send_time'] = $msg;
-            }
-            if (strpos($value['belong_time'], '|') !== false) {
-                list($start,$end) = explode('|', $value['belong_time']);
-                $startStamp = strtotime($start);
-                $endStamp = strtotime($end);
-                if(! $startStamp || ! $endStamp || $startStamp > $endStamp) {
-                    $error_2[] = $line . "归属日期错误";
-                }else{
-                    $new_array[$key]['start_time'] = $startStamp;
-                    $new_array[$key]['end_time'] = $endStamp;
-                    unset($new_array[$key]['belong_time']);
-                }
-            }else{
-                list($status, $msg) = $this->convertExcelCellToDate($value['belong_time']);
-                if(! $status){
-                    $error_2[] = $line . "归属日期错误";
-                }else{
-                    $new_array[$key]['start_time'] = $msg;
-                    $new_array[$key]['end_time'] = $msg;
-                    unset($new_array[$key]['belong_time']);
-                }
-            }
-            $res = $this->checkNumber($value['give_out_amount'],2,'positive');
-            if(! $res['valid']) $error_2[] = $line . "分红已发放金额:" . $res['error'];
-        }
-        if(! empty($error_2)) {
-            $error_string = implode('|', $error_2);
-            return [0, $error_string];
-        }
-
-        try{
-            //新增
-            if(! empty($new_array)) GiveOut::insert($new_array);
-
-            DB::commit();
-        }catch (\Exception $e){
-            DB::rollBack();
-            return [false, $e->getMessage() . $e->getLine() . $e->getCode()];
-        }
-
-        return [true, ''];
-    }
-
-    //公共校验
-    private function checkCommon($array, $table_config){
+    private function checkProduct($array, $table_config){
         $error = [];
-
-        $uniqueValues = []; // 用于存储需要唯一性检查的值
-        // 第一次遍历:收集所有唯一字段的值
-        foreach ($array as $key => $value) {
-            foreach ($value as $k => $v) {
-                if (isset($table_config[$k]) && ! empty($table_config[$k]['unique'])) {
-                    $uniqueValues[$k][] = [
-                        'value' => trim($v),
-                        'line' => $key
-                    ];
-                }
-            }
-        }
-        // 检查唯一性
-        foreach ($uniqueValues as $column => $values) {
-            $valueCount = [];
-            foreach ($values as $item) {
-                $valueCount[$item['value']][] = $item['line'];
-            }
-            foreach ($valueCount as $value => $lines) {
-                if (count($lines) > 1) {
-                    $lineNumbers = implode(',', $lines);
-                    $error[] = $table_config[$column]['value'] . "重复,在第{$lineNumbers}行出现重复值:{$value}";
-                }
-            }
-        }
-        
-        // 第二次遍历:进行其他验证
         foreach ($array as $key => $value){
             $line = '第' . $key . '行';
             $rowData = array_filter($value);
@@ -373,25 +139,14 @@ class ImportService extends Service
                         $error[] = $line . $row . "数据不存在";
                     }else{
                         $table_tmp = $table_config[$k] ?? [];
-                        if(! empty($table_tmp['required'])){
-                            if ($tmp_v === '' || ! isset($tmp_v)) {
-                                $error[] = $line . $table_tmp['value'] . "必填";
-                            }
-                        }
+                        if(! empty($table_tmp['required']) && empty($tmp_v)) $error[] = $line . $table_tmp['value'] . "必填";
+                        if(! empty($table_tmp['unique']))
                     }
 
-                    if(empty($tmp_v) && isset($table_tmp['default'])) $tmp_v = $table_tmp['default'];
-                    $value[$k] = $tmp_v;
+                    $value[$k] = trim($v);
                 }
-
-                $array[$key] = $value;
             }
         }
-
-        $error_string = "";
-        if(! empty($error)) $error_string = implode('|', $error);
-
-        return [$array, $error_string];
     }
 
     //模板校验
@@ -409,37 +164,5 @@ class ImportService extends Service
 
         return [true, $config_array];
     }
-
-    //转换日期
-    function convertExcelCellToDate($cellValue) {
-        // 尝试将单元格值转换为浮点数(Excel 日期序列号)
-        $excelTimestamp = filter_var($cellValue, FILTER_VALIDATE_FLOAT);
-
-        if ($excelTimestamp !== false && $excelTimestamp > 0) {
-            // 如果成功转换并且值大于0,则认为是Excel日期序列号
-            try {
-                $dateTimeObject = Date::excelToDateTimeObject($cellValue);
-
-//                if ($dateTimeObject->format('H:i:s') === '00:00:00') {
-//                    // 如果是,则将时间设置为 '23:59:00'
-//                    $dateTimeObject->setTime(23, 59);
-//                }
-
-                // 现在你可以格式化这个日期了
-                $formattedDate = $dateTimeObject->format('Y-m-d');
-                if(! strtotime($formattedDate)) return [false, ''];
-
-                return [true,  strtotime($formattedDate)];
-            } catch (\Exception $e) {
-                // 处理转换失败的情况
-                return [false, '单元格日期格式转换时间戳失败'];
-            }
-        }
-
-        // 如果不是有效的浮点数,则尝试按照多种日期格式解析
-        if(! strtotime($cellValue)) return [false, '单元格文本格式转换时间戳失败'];
-
-        return [true, strtotime($cellValue)];
-    }
 }
 

+ 436 - 0
app/Service/StatisticsService.php

@@ -6,6 +6,7 @@ use App\Model\EmployeeIndex;
 use App\Model\FreightFee;
 use App\Model\GiveOut;
 use App\Model\ItemReport;
+use App\Model\ItemReportMan;
 use App\Model\ItemReportRoad;
 use App\Model\RevenueCost;
 use App\Model\RevenueCostTotal;
@@ -915,6 +916,40 @@ class StatisticsService extends Service
         return $data;
     }
 
+    public function statisticsMan($data, $user)
+    {
+        $model = $this->statisticsManCommon($data, $user);
+        $list = $this->limit($model,'',$data);
+        $list = $this->statisticsManFillData($list, $user,$data);
+
+        $list['count'] = $this->countTotal($list['data'], $user['header_default']);
+
+        return [true, $list];
+    }
+
+    public function statisticsManCommon($data,$user, $field = []){
+        $model = ItemReportMan::select('*')
+            ->orderby('id', 'desc');
+
+        if(! empty($data['order_time'])){
+            $time = strtotime($data['order_time'] . "-01");
+            $model->where('time', $time);
+        }
+
+        return $model;
+    }
+
+    public function statisticsManFillData($data, $user, $ergs){
+        if(empty($data['data'])) return $data;
+
+        foreach ($data['data'] as $key => $value) {
+            $time = $value['time'] ? date('Y-m',$value['time']) : '';
+            $data['data'][$key]['time'] = $time;
+        }
+
+        return $data;
+    }
+
     public function getChannelReport($data)
     {
         if(empty($data['order_time'])) return [false, '年月不能为空'];
@@ -1102,4 +1137,405 @@ class StatisticsService extends Service
 
         return $finalResult;
     }
+
+    private function getAmountFieldManNames()
+    {
+        return [
+            'receipt_amount', 'receipt_not_amount', 'cost', 'profit', 'profit_not',
+            'settle_amount', 'gl_amount', 'gl_not_amount', 'wl_amount', 'wl_not_amount',
+            'ht_amount', 'zk_amount', 'cx_amount', 'tg_amount', 'cl_amount',
+            'kq_amount', 'zp_amount', 'gg_amount', 'kd_amount', 'xsqt_amount',
+            'ry_amount', 'sb_amount', 'sj_amount', 'sj_not_amount', 'sx_amount',
+            'sx_not_amount', 'other_ck_amount', 'cg_amount'
+        ];
+    }
+
+    private function injectAmountMan($data)
+    {
+        $result = [];
+        // 参与 total 计算的费用字段 (排除收入、成本和利润)
+        $expenseFields = [
+            'settle_amount', 'gl_amount', 'gl_not_amount', 'wl_amount', 'wl_not_amount',
+            'ht_amount', 'zk_amount', 'cx_amount', 'tg_amount', 'cl_amount',
+            'kq_amount', 'zp_amount', 'gg_amount', 'kd_amount', 'xsqt_amount',
+            'ry_amount', 'sb_amount', 'sj_amount', 'sj_not_amount', 'sx_amount',
+            'sx_not_amount', 'other_ck_amount', 'cg_amount'
+        ];
+
+        // 第一步:格式化并插入占位符
+        foreach ($this->getAmountFieldManNames() as $key) {
+            $val = $data[$key] ?? 0;
+
+            if ($key === 'sj_amount') {
+                $result['amount1'] = '0.00'; // 占位
+                $result['sj_amount'] = number_format((float)$val, 2, '.', '');
+                $result['amount2'] = '0.00'; // 占位
+            } else {
+                $result[$key] = number_format((float)$val, 2, '.', '');
+            }
+        }
+
+        // 第二步:计算费用总额
+        $total = 0;
+        foreach ($expenseFields as $field) {
+            $total += (float)($data[$field] ?? 0);
+        }
+        $result['total'] = number_format($total, 2, '.', '');
+
+        return $result;
+    }
+
+    public function getChannelReportMan1($data)
+    {
+        if(empty($data['order_time'])) return [false, '年月不能为空'];
+        $yearMonth = $data['order_time']; // 格式如 2026-02
+
+        [$year, $month] = explode('-', $yearMonth);
+        $year = (int)$year;
+        $month = (int)$month;
+
+        // 当前选择月的第一天戳
+        $currentMonthTs = mktime(0, 0, 0, $month, 1, $year);
+        // 去年7月1日的时间戳 (例如输入2026-02,则起始为2025-07-01)
+        $startTs = mktime(0, 0, 0, 7, 1, $year - 1);
+
+        // 从业务员报表获取数据
+        $records = DB::table('item_report_man')
+            ->whereBetween('time', [$startTs, $currentMonthTs])
+            ->get();
+
+        $channels = [];
+        $allFields = $this->getAmountFieldManNames();
+
+        foreach ($records as $record) {
+            // 以渠道财务分组
+            $channel = $record->channel_finance ?: '未知渠道';
+
+            if (!isset($channels[$channel])) {
+                $channels[$channel] = [
+                    'monthly'    => array_fill_keys($allFields, 0),
+                    'cumulative' => array_fill_keys($allFields, 0),
+                ];
+            }
+
+            $isCurrentMonth = ((int)$record->time === $currentMonthTs);
+
+            foreach ($allFields as $field) {
+                $val = (float)($record->$field ?? 0);
+                // 累计去年7月至今
+                $channels[$channel]['cumulative'][$field] += $val;
+                // 仅当月
+                if ($isCurrentMonth) {
+                    $channels[$channel]['monthly'][$field] += $val;
+                }
+            }
+        }
+
+        $finalResult = [];
+        foreach ($channels as $channelName => $values) {
+            $finalResult[] = [
+                'channel'    => $channelName,
+                'monthly'    => $this->injectAmountMan($values['monthly']),
+                'cumulative' => $this->injectAmountMan($values['cumulative']),
+            ];
+        }
+
+        return $finalResult;
+    }
+
+    public function getChannelReportMan2($data)
+    {
+        if (empty($data['order_time'])) return [false, '年月不能为空'];
+        $yearMonth = $data['order_time'];
+
+        [$year, $month] = explode('-', $yearMonth);
+        $year = (int)$year;
+        $month = (int)$month;
+
+        // 1. 计算时间范围
+        $currentMonthTs = mktime(0, 0, 0, $month, 1, $year);
+        // 财年规则:如果当前月 >= 7月,起始是当年7月;否则是去年7月
+        $startYear = ($month >= 7) ? $year : $year - 1;
+        $startTs = mktime(0, 0, 0, 7, 1, $startYear);
+
+        // 2. 一次性获取所有相关记录
+        $records = DB::table('item_report_man')
+            ->whereBetween('time', [$startTs, $currentMonthTs])
+            ->get();
+
+        // 3. 定义金额字段(按 B5-B27 的顺序排列,方便后面直接填充 row)
+        $rowFieldMapping = [
+            5  => 'receipt_amount',   6  => 'cost',            7  => 'profit',
+            8  => 'settle_amount',    9  => 'gl_amount',       10 => 'wl_amount',
+            11 => 'ht_amount',        12 => 'zk_amount',       13 => 'cx_amount',
+            14 => 'tg_amount',        15 => 'cl_amount',       16 => 'kq_amount',
+            17 => 'zp_amount',        18 => 'gg_amount',       19 => 'kd_amount',
+            20 => 'xsqt_amount',      21 => 'ry_amount',       22 => 'sb_amount',
+            23 => '退货亏损',          24 => 'cg_amount',       25 => 'sj_amount',
+            26 => 'sx_amount',        27 => 'other_ck_amount'
+        ];
+
+        // 4. 初始化列容器(C到Z)
+        $columns = [];
+        $columnKeys = range('C', 'Z');
+        foreach ($columnKeys as $col) {
+            $columns[$col] = array_fill(5, 28, 0); // 5-32行,初始化为0
+        }
+
+        // 5. 遍历分拣数据
+        foreach ($records as $record) {
+            $empId = (int)$record->employee_id_1;
+            $finance = $record->channel_finance;
+            $isCurrent = ((int)$record->time === $currentMonthTs);
+
+            foreach ($rowFieldMapping as $rowIdx => $field) {
+                $val = (float)($record->$field ?? 0);
+
+                // 规则分拣 (C, D, G, H, K, L, O, Q, R, U, W)
+                // C: 2+社区
+                if ($empId === 2 && $finance === '社区') {
+                    if ($isCurrent) $columns['C'][$rowIdx] += $val;
+                    $columns['F'][$rowIdx] += $val; // 累计
+                }
+                // D: (2+通路) + (5+通路)
+                if (($empId === 2 || $empId === 5) && $finance === '通路') {
+                    if ($isCurrent) $columns['D'][$rowIdx] += $val;
+                    $columns['F'][$rowIdx] += $val; // 累计到F
+                }
+                // G: 3+通路
+                if ($empId === 3 && $finance === '通路') {
+                    if ($isCurrent) $columns['G'][$rowIdx] += $val;
+                    $columns['J'][$rowIdx] += $val;
+                }
+                // H: 3+联华加盟
+                if ($empId === 3 && $finance === '联华加盟') {
+                    if ($isCurrent) $columns['H'][$rowIdx] += $val;
+                    $columns['J'][$rowIdx] += $val;
+                }
+                // K: 23+通路
+                if ($empId === 23 && $finance === '通路') {
+                    if ($isCurrent) $columns['K'][$rowIdx] += $val;
+                    $columns['N'][$rowIdx] += $val;
+                }
+                // L: 23+智鲸
+                if ($empId === 23 && $finance === '智鲸') {
+                    if ($isCurrent) $columns['L'][$rowIdx] += $val;
+                    $columns['N'][$rowIdx] += $val;
+                }
+                // O: (7,8,54) + (通路,大卖场)
+                if (in_array($empId, [7, 8, 54]) && in_array($finance, ['通路', '大卖场'])) {
+                    if ($isCurrent) $columns['O'][$rowIdx] += $val;
+                    $columns['P'][$rowIdx] += $val;
+                }
+                // Q: 48+通路
+                if ($empId === 48 && $finance === '通路') {
+                    if ($isCurrent) $columns['Q'][$rowIdx] += $val;
+                    $columns['T'][$rowIdx] += $val;
+                }
+                // R: 48+大卖场
+                if ($empId === 48 && $finance === '大卖场') {
+                    if ($isCurrent) $columns['R'][$rowIdx] += $val;
+                    $columns['T'][$rowIdx] += $val;
+                }
+                // U: 行政
+                if ($finance === '行政') {
+                    if ($isCurrent) $columns['U'][$rowIdx] += $val;
+                    $columns['V'][$rowIdx] += $val;
+                }
+                // W: 鲍总
+                if ($finance === '鲍总') {
+                    if ($isCurrent) $columns['W'][$rowIdx] += $val;
+                    $columns['X'][$rowIdx] += $val;
+                }
+            }
+        }
+
+        // 6. 计算横向合计列
+        for ($i = 5; $i <= 27; $i++) {
+            $columns['E'][$i] = $columns['C'][$i] + $columns['D'][$i]; // 张+霍当月合计
+            $columns['I'][$i] = $columns['G'][$i] + $columns['H'][$i]; // 金小勇当月合计
+            $columns['M'][$i] = $columns['K'][$i] + $columns['L'][$i]; // 沈强当月合计
+            $columns['S'][$i] = $columns['Q'][$i] + $columns['R'][$i]; // 叶南汝当月合计
+
+            // Y: 当月总计 (所有当月列累加)
+            $columns['Y'][$i] = $columns['C'][$i] + $columns['D'][$i] + $columns['G'][$i] +
+                $columns['H'][$i] + $columns['K'][$i] + $columns['L'][$i] +
+                $columns['O'][$i] + $columns['Q'][$i] + $columns['R'][$i] +
+                $columns['U'][$i] + $columns['W'][$i];
+
+            // Z: 年累计总计 (所有累计列累加)
+            $columns['Z'][$i] = $columns['F'][$i] + $columns['J'][$i] + $columns['N'][$i] +
+                $columns['P'][$i] + $columns['T'][$i] + $columns['V'][$i] + $columns['X'][$i];
+        }
+
+        // 7. 组装最终供 Excel 填充的数组 (5行到32行)
+        $finalData = [];
+        for ($row = 5; $row <= 32; $row++) {
+            $rowData = [];
+            // 从 C 到 Z 循环取数据
+            foreach (range('C', 'Z') as $colLetter) {
+                $val = $columns[$colLetter][$row] ?? 0;
+                // 28-32行填空字符串,其他格式化
+                if ($row > 27 && $row < 32) {
+                    $rowData[] = '';
+                } elseif ($row == 32) {
+                    // 如果需要算小计可以在这里加,目前先填空字符串
+                    $rowData[] = '';
+                } else {
+                    $rowData[] = $val == 0 ? '0.00' : number_format($val, 2, '.', '');
+                }
+            }
+            $finalData[] = $rowData;
+        }
+
+        return $finalData;
+    }
+
+    public function getChannelReportMan($data)
+    {
+        if (empty($data['order_time'])) return [false, '年月不能为空'];
+        $yearMonth = $data['order_time'];
+
+        [$year, $month] = explode('-', $yearMonth);
+        $year = (int)$year;
+        $month = (int)$month;
+
+        // 1. 计算时间范围:7月财年规则
+        $currentMonthTs = mktime(0, 0, 0, $month, 1, $year);
+        $startYear = ($month >= 7) ? $year : $year - 1;
+        $startTs = mktime(0, 0, 0, 7, 1, $startYear);
+
+        // 2. 一次性获取数据
+        $records = DB::table('item_report_man')
+            ->whereBetween('time', [$startTs, $currentMonthTs])
+            ->get();
+
+        // 3. 字段映射 (注意 23 行,若数据库无字段则设为 null 会自动补 0)
+        $rowFieldMapping = [
+            5  => 'receipt_amount',   6  => 'cost',            7  => 'profit',
+            8  => 'settle_amount',    9  => 'gl_amount',       10 => 'wl_amount',
+            11 => 'ht_amount',        12 => 'zk_amount',       13 => 'cx_amount',
+            14 => 'tg_amount',        15 => 'cl_amount',       16 => 'kq_amount',
+            17 => 'zp_amount',        18 => 'gg_amount',       19 => 'kd_amount',
+            20 => 'xsqt_amount',      21 => 'ry_amount',       22 => 'sb_amount',
+            23 => null,               // 退货亏损 (不良仓),暂无字段映射,填充0
+            24 => 'cg_amount',        25 => 'sj_amount',
+            26 => 'sx_amount',        27 => 'other_ck_amount'
+        ];
+
+        // 4. 初始化列容器 (C 到 Z)
+        $columns = [];
+        $columnKeys = range('C', 'Z');
+        foreach ($columnKeys as $col) {
+            $columns[$col] = array_fill(5, 28, 0); // 覆盖 5-32 行
+        }
+
+        // 5. 数据分拣累加
+        foreach ($records as $record) {
+            $empId = (int)$record->employee_id_1;
+            $finance = $record->channel_finance;
+            $isCurrent = ((int)$record->time === $currentMonthTs);
+
+            foreach ($rowFieldMapping as $rowIdx => $field) {
+                $val = $field ? (float)($record->$field ?? 0) : 0;
+
+                // 分拣规则
+                // 张春勇、霍尚琳
+                if ($empId === 2 && $finance === '社区') {
+                    if ($isCurrent) $columns['C'][$rowIdx] += $val;
+                    $columns['F'][$rowIdx] += $val;
+                }
+                if (($empId === 2 || $empId === 5) && $finance === '通路') {
+                    if ($isCurrent) $columns['D'][$rowIdx] += $val;
+                    $columns['F'][$rowIdx] += $val;
+                }
+                // 金小勇
+                if ($empId === 3 && $finance === '通路') {
+                    if ($isCurrent) $columns['G'][$rowIdx] += $val;
+                    $columns['J'][$rowIdx] += $val;
+                }
+                if ($empId === 3 && $finance === '联华加盟') {
+                    if ($isCurrent) $columns['H'][$rowIdx] += $val;
+                    $columns['J'][$rowIdx] += $val;
+                }
+                // 沈强
+                if ($empId === 23 && $finance === '通路') {
+                    if ($isCurrent) $columns['K'][$rowIdx] += $val;
+                    $columns['N'][$rowIdx] += $val;
+                }
+                if ($empId === 23 && $finance === '智鲸') {
+                    if ($isCurrent) $columns['L'][$rowIdx] += $val;
+                    $columns['N'][$rowIdx] += $val;
+                }
+                // 王利英等组合 (O/P列)
+                if (in_array($empId, [7, 8, 54]) && in_array($finance, ['通路', '大卖场'])) {
+                    if ($isCurrent) $columns['O'][$rowIdx] += $val;
+                    $columns['P'][$rowIdx] += $val;
+                }
+                // 叶南汝
+                if ($empId === 48 && $finance === '通路') {
+                    if ($isCurrent) $columns['Q'][$rowIdx] += $val;
+                    $columns['T'][$rowIdx] += $val;
+                }
+                if ($empId === 48 && $finance === '大卖场') {
+                    if ($isCurrent) $columns['R'][$rowIdx] += $val;
+                    $columns['T'][$rowIdx] += $val;
+                }
+                // 行政
+                if ($finance === '行政') {
+                    if ($isCurrent) $columns['U'][$rowIdx] += $val;
+                    $columns['V'][$rowIdx] += $val;
+                }
+                // 鲍总
+                if ($finance === '鲍总') {
+                    if ($isCurrent) $columns['W'][$rowIdx] += $val;
+                    $columns['X'][$rowIdx] += $val;
+                }
+            }
+        }
+
+        // 6. 计算合计列与纵向小计
+        for ($i = 5; $i <= 27; $i++) {
+            // 合计列
+            $columns['E'][$i] = $columns['C'][$i] + $columns['D'][$i];
+            $columns['I'][$i] = $columns['G'][$i] + $columns['H'][$i];
+            $columns['M'][$i] = $columns['K'][$i] + $columns['L'][$i];
+            $columns['S'][$i] = $columns['Q'][$i] + $columns['R'][$i];
+
+            // Y/Z 总计
+            $columns['Y'][$i] = $columns['C'][$i] + $columns['D'][$i] + $columns['G'][$i] + $columns['H'][$i] +
+                $columns['K'][$i] + $columns['L'][$i] + $columns['O'][$i] + $columns['Q'][$i] +
+                $columns['R'][$i] + $columns['U'][$i] + $columns['W'][$i];
+
+            $columns['Z'][$i] = $columns['F'][$i] + $columns['J'][$i] + $columns['N'][$i] + $columns['P'][$i] +
+                $columns['T'][$i] + $columns['V'][$i] + $columns['X'][$i];
+        }
+
+        // 纵向小计 (第 32 行 = 8 到 31 行累加)
+        foreach ($columnKeys as $col) {
+            $subTotal = 0;
+            for ($r = 8; $r <= 31; $r++) {
+                $subTotal += (float)($columns[$col][$r] ?? 0);
+            }
+            $columns[$col][32] = $subTotal;
+        }
+
+        // 7. 最终格式化
+        $finalData = [];
+        for ($row = 5; $row <= 32; $row++) {
+            $rowData = [];
+            foreach ($columnKeys as $colLetter) {
+                $val = $columns[$colLetter][$row] ?? 0;
+
+                if ($row >= 28 && $row <= 31) {
+                    $rowData[] = ''; // 预留行填空
+                } else {
+                    $rowData[] = ($val == 0) ? '0.00' : number_format($val, 2, '.', '');
+                }
+            }
+            $finalData[] = $rowData;
+        }
+
+        return $finalData;
+    }
 }

+ 306 - 2
app/Service/TPlusServerService.php

@@ -10,6 +10,7 @@ use App\Model\EmployeeIndex;
 use App\Model\Freight;
 use App\Model\FreightFee;
 use App\Model\ItemReport;
+use App\Model\ItemReportMan;
 use App\Model\ItemReportRoad;
 use App\Model\Product;
 use App\Model\RevenueCost;
@@ -1500,8 +1501,10 @@ class TPlusServerService extends Service
                 $table->integer('order_type')->default(0)->comment('订单分类标识(1 费用单 2 其他出库单)');
                 $table->string('ck_type')->default("")->comment('出库单出库类别');
                 $table->integer('employee_id_1')->default(0)->comment('业务员id');
+                $table->string('employee_id_1_title')->default('')->comment('业务员名称');
 
                 // 维度信息
+                $table->string('channel_finance')->default('')->comment('渠道财务(cs.pubuserdefnvc11)');
                 $table->string('channel_details')->default('')->comment('渠道明细(cs.pubuserdefnvc12)');
                 $table->string('fy_code')->default('')->comment('费用项目编码(ae.code)');
 
@@ -1658,6 +1661,7 @@ class TPlusServerService extends Service
                 $rows = $this->databaseService->table('CS_ExpenseVoucher_b as cs_b')
                     ->join('CS_ExpenseVoucher as cs', 'cs_b.idExpenseVoucherDTO', '=', 'cs.ID')
                     ->leftJoin('AA_ExpenseItem as ae', 'ae.id', '=', 'cs_b.idexpenseitem')
+                    ->leftJoin('AA_Person as ps', 'cs.idclerk', '=', 'ps.ID')
                     ->where('cs.voucherdate','>=',$data['start_time'])
                     ->where('cs.voucherdate','<=',$data['end_time'])
                     ->where('cs_b.ID', '>', $lastId)
@@ -1669,7 +1673,9 @@ class TPlusServerService extends Service
                         COALESCE(cs.code, '') as order_number,
                         cs.voucherdate as order_time,
                         cs.idclerk  as employee_id_1,
+                        COALESCE(ps.name, '') as employee_id_1_title,
                         COALESCE(cs.pubuserdefnvc12, '') as channel_details,
+                        COALESCE(cs.pubuserdefnvc11, '') as channel_finance,
                         COALESCE(ae.code, '') as fy_code,
                         COALESCE(cs_b.taxamount, 0) as taxamount,
                         COALESCE(cs_b.ID, 0) as id_detail
@@ -1705,10 +1711,11 @@ class TPlusServerService extends Service
             do {
                 $rows = $this->databaseService->table('ST_RDRecord_b as st_b')
                     ->join('ST_RDRecord as st', 'st_b.idRDRecordDTO', '=', 'st.ID')
+                    ->leftJoin('AA_Person as ps', 'st.idclerk', '=', 'ps.ID')
                     ->where('st.voucherdate','>=',$data['start_time'])
                     ->where('st.voucherdate','<=',$data['end_time'])
                     ->where('st.idvouchertype', 30)
-                    ->whereIn('st.idbusitype',[20048,60,20049]) //20049 客情出库 60 赠品出库  20048 员工福利
+//                    ->whereIn('st.idbusitype',[20048,60,20049]) //20049 客情出库 60 赠品出库  20048 员工福利
                     ->where('st_b.ID', '>', $lastId)
                     ->orderBy('st_b.ID')
                     ->limit($limit)
@@ -1718,7 +1725,9 @@ class TPlusServerService extends Service
                         COALESCE(st.code, '') as order_number,
                         st.voucherdate as order_time,
                         st.idclerk  as employee_id_1,
+                        COALESCE(ps.name, '') as employee_id_1_title,
                         COALESCE(st.pubuserdefnvc12, '') as channel_details,
+                        COALESCE(st.pubuserdefnvc11, '') as channel_finance,
                         COALESCE(st_b.amount, 0) as taxamount,
                         COALESCE(st_b.ID, 0) as id_detail,
                         st.idbusitype as ck_type
@@ -1748,7 +1757,7 @@ class TPlusServerService extends Service
         return [true, ''];
     }
 
-    private function saveResult($data, $user){
+    private function saveResultold($data, $user){
         // 初始化汇总数组------报表一
         $paymentSummary = [];
         $costSummary = [];
@@ -2393,6 +2402,301 @@ class TPlusServerService extends Service
         return [true, ''];
     }
 
+    private function saveResult($data, $user){
+        // 初始化汇总数组------报表一
+        $paymentSummary = [];
+        $costSummary = [];
+        $costSummary2 = [];
+
+        // 初始化汇总数组------报表二 (业务员报表)
+        $manSummary = [];
+
+        try{
+            $limit = 500;
+            $lastId = 0;
+            do {
+                //收入
+                $rows = DB::table('tmp_item_road')
+                    ->where('id', '>', $lastId)
+                    ->orderBy('id')
+                    ->limit($limit)
+                    ->select([
+                        'id',
+                        'order_time',
+                        'channel_details',
+                        'channel_finance',
+                        'payment_amount',
+                        'price_4_total',
+                        'is_kh',
+                        'employee_id_1',
+                        'employee_id_1_title',
+                        'employee_id_2'
+                    ])
+                    ->get();
+
+                if ($rows->isEmpty()) {
+                    break;
+                }
+
+                foreach ($rows as $row) {
+                    $order_time = $row->order_time;
+                    $month = strtotime(date("Y-m-01", $order_time));
+                    $channel = $row->channel_details ?? '';
+                    $finance = $row->channel_finance ?? '';
+                    $empId = $row->employee_id_1 ?? 0;
+                    $empName = $row->employee_id_1_title ?? '';
+
+                    // --- 原报表一逻辑 (不改动) ---
+                    if (! $row->is_kh) {
+                        $paymentSummary[$month][$channel] = bcadd($paymentSummary[$month][$channel] ?? 0, $row->payment_amount, 3);
+                    }
+                    $costSummary[$month][$channel] = bcadd($costSummary[$month][$channel] ?? 0, $row->price_4_total, 3);
+
+                    // --- 新报表二逻辑 (业务员维度) ---
+                    $key = "{$month}_{$finance}_{$empId}";
+                    if (!isset($manSummary[$key])) {
+                        $manSummary[$key] = [
+                            'time'                => $month,
+                            'channel_finance'     => $finance,
+                            'employee_id_1'       => $empId,
+                            'employee_id_1_title' => $empName,
+                            'receipt_amount'      => 0,
+                            'receipt_not_amount'  => 0,
+                            'cost'                => 0,
+                            'profit'              => 0,
+                            'profit_not'          => 0,
+                            'settle_amount'       => 0,
+                            'gl_amount'           => 0,
+                            'gl_not_amount'       => 0,
+                            'wl_amount'           => 0,
+                            'wl_not_amount'       => 0,
+                            'ht_amount'           => 0,
+                            'zk_amount'           => 0,
+                            'cx_amount'           => 0,
+                            'tg_amount'           => 0,
+                            'cl_amount'           => 0,
+                            'kq_amount'           => 0,
+                            'zp_amount'           => 0,
+                            'gg_amount'           => 0,
+                            'kd_amount'           => 0,
+                            'xsqt_amount'         => 0,
+                            'ry_amount'           => 0,
+                            'sb_amount'           => 0,
+                            'sj_amount'           => 0,
+                            'sj_not_amount'       => 0,
+                            'sx_amount'           => 0,
+                            'sx_not_amount'       => 0,
+                            'cg_amount'           => 0,
+                            'other_ck_amount'     => 0,
+                        ];
+                    }
+                    // 收款总额 (所有)
+                    $manSummary[$key]['receipt_amount'] = bcadd($manSummary[$key]['receipt_amount'], $row->payment_amount, 3);
+                    // 收款 (不含不计考勤 is_kh == 0)
+                    if (!$row->is_kh) {
+                        $manSummary[$key]['receipt_not_amount'] = bcadd($manSummary[$key]['receipt_not_amount'], $row->payment_amount, 3);
+                    }
+                    // 业务成本
+                    $manSummary[$key]['cost'] = bcadd($manSummary[$key]['cost'], $row->price_4_total, 3);
+                }
+                $lastId = $rows->last()->id;
+            } while ($rows->count() === $limit);
+
+            // 计算毛利
+            foreach ($manSummary as $key => $val) {
+                // 1. 计算总毛利:总收款 - 总成本
+                $manSummary[$key]['profit'] = bcsub(
+                    $val['receipt_amount'],
+                    $val['cost'],
+                    3
+                );
+
+                // 2. 计算不含不计考勤毛利:考核收款 - 总成本
+                $manSummary[$key]['profit_not'] = bcsub(
+                    $val['receipt_not_amount'],
+                    $val['cost'],
+                    3
+                );
+            }
+
+            $limit = 500;
+            $lastId = 0;
+            do {
+                //指出
+                $rows = DB::table('tmp_item_cost')
+                    ->where('id', '>', $lastId)
+                    ->orderBy('id')
+                    ->limit($limit)
+                    ->select([
+                        'id', 'order_time', 'channel_details', 'ck_type', 'fy_code', 'taxamount', 'employee_id_1', 'channel_finance', 'order_type' , 'employee_id_1_title'
+                    ])
+                    ->get();
+
+                if ($rows->isEmpty()) {
+                    break;
+                }
+
+                foreach ($rows as $row) {
+                    $order_time = $row->order_time;
+                    $month = strtotime(date("Y-m-01", $order_time));
+                    $channel = $row->channel_details ?? '';
+                    $finance = $row->channel_finance ?? '';
+                    $empId = $row->employee_id_1 ?? 0;
+                    $empName = $row->employee_id_1_title ?? '';
+                    $amount = $row->taxamount;
+
+                    //表一-------------------------------------------------------
+                    // 结算费用
+                    if($row->fy_code == 7004){
+                        $costSummary2[$month][$channel]['settle_amount'] = bcadd($costSummary2[$month][$channel]['settle_amount'] ?? 0, $amount, 3);
+                    }
+                    // 管理费 (5%)
+                    $gl_amount = bcmul($amount, 0.05, 3);
+                    $costSummary2[$month][$channel]['gl_amount'] = bcadd($costSummary2[$month][$channel]['gl_amount'] ?? 0, $gl_amount, 3);
+                    // 物流费 (2.3%)
+                    $wl_amount = bcmul($amount, 0.023, 3);
+                    $costSummary2[$month][$channel]['wl_amount'] = bcadd($costSummary2[$month][$channel]['wl_amount'] ?? 0, $wl_amount, 3);
+                    if($row->fy_code == 7005) $costSummary2[$month][$channel]['ht_amount'] = bcadd($costSummary2[$month][$channel]['ht_amount'] ?? 0, $amount, 3);
+                    if($row->fy_code == 7006) $costSummary2[$month][$channel]['zk_amount'] = bcadd($costSummary2[$month][$channel]['zk_amount'] ?? 0, $amount, 3);
+                    if($row->fy_code == 7007) $costSummary2[$month][$channel]['cx_amount'] = bcadd($costSummary2[$month][$channel]['cx_amount'] ?? 0, $amount, 3);
+                    if($row->fy_code == 7013) $costSummary2[$month][$channel]['tg_amount'] = bcadd($costSummary2[$month][$channel]['tg_amount'] ?? 0, $amount, 3);
+                    if($row->fy_code == 7012) $costSummary2[$month][$channel]['cl_amount'] = bcadd($costSummary2[$month][$channel]['cl_amount'] ?? 0, $amount, 3);
+                    // 客情出库
+                    if($row->fy_code == 7008 || $row->ck_type == 20049) {
+                        $costSummary2[$month][$channel]['kq_amount'] = bcadd($costSummary2[$month][$channel]['kq_amount'] ?? 0, $amount, 3);
+                    }
+                    // 赠品出库
+                    if($row->fy_code == 7009 || $row->ck_type == 60) {
+                        $costSummary2[$month][$channel]['zp_amount'] = bcadd($costSummary2[$month][$channel]['zp_amount'] ?? 0, $amount, 3);
+                    }
+                    if($row->fy_code == 7010) $costSummary2[$month][$channel]['gg_amount'] = bcadd($costSummary2[$month][$channel]['gg_amount'] ?? 0, $amount, 3);
+                    if($row->fy_code == 7011) $costSummary2[$month][$channel]['kd_amount'] = bcadd($costSummary2[$month][$channel]['kd_amount'] ?? 0, $amount, 3);
+                    if($row->fy_code == 7001) $costSummary2[$month][$channel]['xsqt_amount'] = bcadd($costSummary2[$month][$channel]['xsqt_amount'] ?? 0, $amount, 3);
+                    if($row->fy_code == 7003) $costSummary2[$month][$channel]['ry_amount'] = bcadd($costSummary2[$month][$channel]['ry_amount'] ?? 0, $amount, 3);
+                    // 社保/福利
+                    if($row->fy_code == 7019 || $row->ck_type == 20048) {
+                        $costSummary2[$month][$channel]['sb_amount'] = bcadd($costSummary2[$month][$channel]['sb_amount'] ?? 0, $amount, 3);
+                    }
+                    // 税金 (1%)
+                    $sj_amount = bcmul($amount, 0.01, 3);
+                    $costSummary2[$month][$channel]['sj_amount'] = bcadd($costSummary2[$month][$channel]['sj_amount'] ?? 0, $sj_amount, 3);
+
+
+                    // 表二----------------------------------------------------------------------
+                    $key = "{$month}_{$finance}_{$empId}";
+                    if (!isset($manSummary[$key])) {
+                        $manSummary[$key] = [
+                            'time'                => $month,
+                            'channel_finance'     => $finance,
+                            'employee_id_1'       => $empId,
+                            'employee_id_1_title' => $empName,
+                            'receipt_amount'      => 0,
+                            'receipt_not_amount'  => 0,
+                            'cost'                => 0,
+                            'profit'              => 0,
+                            'profit_not'          => 0,
+                            'settle_amount'       => 0,
+                            'gl_amount'           => 0,
+                            'gl_not_amount'       => 0,
+                            'wl_amount'           => 0,
+                            'wl_not_amount'       => 0,
+                            'ht_amount'           => 0,
+                            'zk_amount'           => 0,
+                            'cx_amount'           => 0,
+                            'tg_amount'           => 0,
+                            'cl_amount'           => 0,
+                            'kq_amount'           => 0,
+                            'zp_amount'           => 0,
+                            'gg_amount'           => 0,
+                            'kd_amount'           => 0,
+                            'xsqt_amount'         => 0,
+                            'ry_amount'           => 0,
+                            'sb_amount'           => 0,
+                            'sj_amount'           => 0,
+                            'sj_not_amount'       => 0,
+                            'sx_amount'           => 0,
+                            'sx_not_amount'       => 0,
+                            'cg_amount'           => 0,
+                            'other_ck_amount'     => 0,
+                        ];
+                    }
+                    if ($row->order_type == 2) {
+                        // 1. 判断是否为其他出库
+                        $manSummary[$key]['other_ck_amount'] = bcadd($manSummary[$key]['other_ck_amount'] ?? 0, $amount, 3);
+                    } else {
+                        // 2. 正常费用代码归类
+                        if($row->fy_code == 7004) $manSummary[$key]['settle_amount'] = bcadd($manSummary[$key]['settle_amount'] ?? 0, $amount, 3);
+                        if($row->fy_code == 7005) $manSummary[$key]['ht_amount'] = bcadd($manSummary[$key]['ht_amount'] ?? 0, $amount, 3);
+                        if($row->fy_code == 7006) $manSummary[$key]['zk_amount'] = bcadd($manSummary[$key]['zk_amount'] ?? 0, $amount, 3);
+                        if($row->fy_code == 7007) $manSummary[$key]['cx_amount'] = bcadd($manSummary[$key]['cx_amount'] ?? 0, $amount, 3);
+                        if($row->fy_code == 7013) $manSummary[$key]['tg_amount'] = bcadd($manSummary[$key]['tg_amount'] ?? 0, $amount, 3);
+                        if($row->fy_code == 7012) $manSummary[$key]['cl_amount'] = bcadd($manSummary[$key]['cl_amount'] ?? 0, $amount, 3);
+                        if($row->fy_code == 7008) $manSummary[$key]['kq_amount'] = bcadd($manSummary[$key]['kq_amount'] ?? 0, $amount, 3);
+                        if($row->fy_code == 7009) $manSummary[$key]['zp_amount'] = bcadd($manSummary[$key]['zp_amount'] ?? 0, $amount, 3);
+                        if($row->fy_code == 7010) $manSummary[$key]['gg_amount'] = bcadd($manSummary[$key]['gg_amount'] ?? 0, $amount, 3);
+                        if($row->fy_code == 7011) $manSummary[$key]['kd_amount'] = bcadd($manSummary[$key]['kd_amount'] ?? 0, $amount, 3);
+                        if($row->fy_code == 7001) $manSummary[$key]['xsqt_amount'] = bcadd($manSummary[$key]['xsqt_amount'] ?? 0, $amount, 3);
+                        if($row->fy_code == 7003) $manSummary[$key]['ry_amount'] = bcadd($manSummary[$key]['ry_amount'] ?? 0, $amount, 3);
+                        if($row->fy_code == 7019) $manSummary[$key]['sb_amount'] = bcadd($manSummary[$key]['sb_amount'] ?? 0, $amount, 3);
+                        if($row->fy_code == 7023) $manSummary[$key]['cg_amount'] = bcadd($manSummary[$key]['cg_amount'] ?? 0, $amount, 3);
+                    }
+                }
+                $lastId = $rows->last()->id;
+            } while ($rows->count() === $limit);
+
+        } catch (\Throwable $exception){
+            return [false, "初步汇总异常" . $exception->getMessage() . "|" . $exception->getLine()];
+        }
+        foreach ($manSummary as $key => $item) {
+            $r_amount = $item['receipt_amount'];
+            $r_not_amount = $item['receipt_not_amount'];
+
+            // 1. 计算毛利
+            $manSummary[$key]['profit'] = bcsub($r_amount, $item['cost'], 3);
+            $manSummary[$key]['profit_not'] = bcsub($r_not_amount, $item['cost'], 3);
+
+            // 2. 统一计算比例费用(此时 $r_amount 是汇总后的总额,只算一次,绝对准确)
+            $manSummary[$key]['gl_amount'] = bcmul($r_amount, 0.05, 3);
+            $manSummary[$key]['gl_not_amount'] = bcmul($r_not_amount, 0.05, 3);
+
+            $manSummary[$key]['wl_amount'] = bcmul($r_amount, 0.023, 3);
+            $manSummary[$key]['wl_not_amount'] = bcmul($r_not_amount, 0.023, 3);
+
+            $manSummary[$key]['sj_amount'] = bcmul($r_amount, 0.01, 3);
+            $manSummary[$key]['sj_not_amount'] = bcmul($r_not_amount, 0.01, 3);
+
+            // 补齐字段,防止 DB 报错
+            $manSummary[$key]['sx_amount'] = bcmul($r_amount, 0.01, 3);
+            $manSummary[$key]['sx_not_amount'] = bcmul($r_not_amount, 0.01, 3);
+        }
+
+        try {
+            $start_timeStamp = $data['start_timeStamp'];
+            $end_timeStamp = $data['end_timeStamp'];
+
+            $result = $this->sumRes($paymentSummary, $costSummary, $costSummary2);
+            $manSummary = array_values($manSummary);
+
+            DB::transaction(function () use ($start_timeStamp, $end_timeStamp, $result, $manSummary) {
+                ItemReport::where('time', '>=', $start_timeStamp)
+                    ->where('time', '<=', $end_timeStamp)
+                    ->delete();
+
+                ItemReport::insert($result);
+
+                ItemReportMan::where('time', '>=', $start_timeStamp)
+                    ->where('time', '<=', $end_timeStamp)
+                    ->delete();
+
+                ItemReportMan::insert($manSummary);
+            });
+        } catch (\Throwable $exception){
+            return [false, "结果异常" . $exception->getMessage() . "|" . $exception->getLine()];
+        }
+
+        return [true, ''];
+    }
+
     private function sumRes($paymentSummary, $costSummary, $costSummary2){
         // 合并三个汇总数组为最终结果
         $result = [];

+ 151 - 2
config/header/79.php

@@ -6,19 +6,128 @@
  */
 
 return [
+//    [
+//        'key' => 'time',
+//        'value' => '年月'
+//    ],
+//    [
+//        'key' => 'employee_title_type_title',
+//        'value' => '渠道明细'
+//    ],
+//    [
+//        'key' =>'receipt_amount',
+//        'value' => '收款销售收入',
+//        'sum' => 1,
+//    ],
+//    [
+//        'key' =>'cost',
+//        'value' => '成本',
+//        'sum' => 1,
+//    ],
+//    [
+//        'key' =>'profit',
+//        'value' => '收款销售毛利',
+//        'sum' => 1,
+//    ],
+//    [
+//        'key' =>'settle_amount',
+//        'value' => '结算费用',
+//        'sum' => 1,
+//    ],
+//    [
+//        'key' =>'gl_amount',
+//        'value' => '管理费用',
+//        'sum' => 1,
+//    ],
+//    [
+//        'key' =>'wl_amount',
+//        'value' => '物流配送',
+//        'sum' => 1,
+//    ],
+//    [
+//        'key' =>'ht_amount',
+//        'value' => '合同费',
+//        'sum' => 1,
+//    ],
+//    [
+//        'key' =>'zk_amount',
+//        'value' => '账扣费',
+//        'sum' => 1,
+//    ],
+//    [
+//        'key' =>'cx_amount',
+//        'value' => '促销员工资',
+//        'sum' => 1,
+//    ],
+//    [
+//        'key' =>'tg_amount',
+//        'value' => '团购及其他返点',
+//        'sum' => 1,
+//    ],
+//    [
+//        'key' =>'cl_amount',
+//        'value' => '陈列费',
+//        'sum' => 1,
+//    ],
+//    [
+//        'key' =>'kq_amount',
+//        'value' => '客情费',
+//        'sum' => 1,
+//    ],
+//    [
+//        'key' =>'zp_amount',
+//        'value' => '赠品费用',
+//        'sum' => 1,
+//    ],
+//    [
+//        'key' =>'gg_amount',
+//        'value' => '广告宣传费',
+//        'sum' => 1,
+//    ],
+//    [
+//        'key' =>'kd_amount',
+//        'value' => '快递费',
+//        'sum' => 1,
+//    ],
+//    [
+//        'key' =>'xsqt_amount',
+//        'value' => '销售其他费用',
+//        'sum' => 1,
+//    ],
+//    [
+//        'key' =>'ry_amount',
+//        'value' => '人员工资',
+//        'sum' => 1,
+//    ],
+//    [
+//        'key' =>'sb_amount',
+//        'value' => '员工社保、福利费',
+//        'sum' => 1,
+//    ],
+//    [
+//        'key' =>'sj_amount',
+//        'value' => '税金(手工)',
+//        'sum' => 1,
+//    ],
+
     [
         'key' => 'time',
         'value' => '年月'
     ],
     [
-        'key' => 'employee_title_type_title',
-        'value' => '渠道明细'
+        'key' => 'channel_finance',
+        'value' => '渠道财务'
     ],
     [
         'key' =>'receipt_amount',
         'value' => '收款销售收入',
         'sum' => 1,
     ],
+    [
+        'key' =>'receipt_not_amount',
+        'value' => '收款销售收入(不含考核)',
+        'sum' => 1,
+    ],
     [
         'key' =>'cost',
         'value' => '成本',
@@ -29,6 +138,11 @@ return [
         'value' => '收款销售毛利',
         'sum' => 1,
     ],
+    [
+        'key' =>'profit_not',
+        'value' => '收款销售毛利(不含考核)',
+        'sum' => 1,
+    ],
     [
         'key' =>'settle_amount',
         'value' => '结算费用',
@@ -39,11 +153,21 @@ return [
         'value' => '管理费用',
         'sum' => 1,
     ],
+    [
+        'key' =>'gl_not_amount',
+        'value' => '管理费用(不含考核)',
+        'sum' => 1,
+    ],
     [
         'key' =>'wl_amount',
         'value' => '物流配送',
         'sum' => 1,
     ],
+    [
+        'key' =>'wl_not_amount',
+        'value' => '物流配送(不含考核)',
+        'sum' => 1,
+    ],
     [
         'key' =>'ht_amount',
         'value' => '合同费',
@@ -104,9 +228,34 @@ return [
         'value' => '员工社保、福利费',
         'sum' => 1,
     ],
+    [
+        'key' =>'cg_amount',
+        'value' => '采购费用',
+        'sum' => 1,
+    ],
     [
         'key' =>'sj_amount',
         'value' => '税金(手工)',
         'sum' => 1,
     ],
+    [
+        'key' =>'sj_not_amount',
+        'value' => '税金(手工 不含考核)',
+        'sum' => 1,
+    ],
+    [
+        'key' =>'sx_amount',
+        'value' => '财务手续费',
+        'sum' => 1,
+    ],
+    [
+        'key' =>'sx_not_amount',
+        'value' => '财务手续费(不含考核)',
+        'sum' => 1,
+    ],
+    [
+        'key' =>'other_ck_amount',
+        'value' => '其他出库单',
+        'sum' => 1,
+    ],
 ];