shish преди 2 години
родител
ревизия
eff6b9be9f
променени са 2 файла, в които са добавени 49 реда и са изтрити 36 реда
  1. 6 6
      app-ghs/controllers/OrderController.php
  2. 43 30
      biz-ghs/stat/classes/StatSaleClass.php

+ 6 - 6
app-ghs/controllers/OrderController.php

@@ -2257,8 +2257,8 @@ class OrderController extends BaseController
                     $list[$customId]['orderPrice'] = bcadd($list[$customId]['orderPrice'], $orderPrice, 2);
                     $list[$customId]['num'] = bcadd($list[$customId]['num'], 1);
                     $list[$customId]['carton'] = bcadd($list[$customId]['carton'], $carton,2);
-                    $list[$customId]['pack'] = bcadd($list[$customId]['pack'], $carton,2);
-                    $list[$customId]['freight'] = bcadd($list[$customId]['freight'], $carton,2);
+                    $list[$customId]['pack'] = bcadd($list[$customId]['pack'], $pack,2);
+                    $list[$customId]['freight'] = bcadd($list[$customId]['freight'], $freight,2);
                     $list[$customId]['tkPrice'] = bcadd($list[$customId]['tkPrice'], $tkPrice,2);
                 } else {
                     $name = $customList[$customId] && $customList[$customId]['name'] ? $customList[$customId]['name'] : '未命名';
@@ -2270,10 +2270,10 @@ class OrderController extends BaseController
                         'orderPrice'=>$orderPrice,
                         'actPrice' => $actPrice,
                         'num' => 1,
-                        'carton'=>0,
-                        'pack'=>0,
-                        'freight'=>0,
-                        'tkPrice'=>0,
+                        'carton'=>$carton,
+                        'pack'=>$pack,
+                        'freight'=>$freight,
+                        'tkPrice'=>$tkPrice,
                     ];
                 }
             }

+ 43 - 30
biz-ghs/stat/classes/StatSaleClass.php

@@ -148,6 +148,8 @@ class StatSaleClass extends BaseClass
         if (!empty($ghsOrderList)) {
             foreach ($ghsOrderList as $ghsKey => $ghsOrder) {
                 $actPrice = $ghsOrder['actPrice'] ?? 0;
+                $orderPrice = $ghsOrder['orderPrice'] ?? 0;
+                $tkPrice = $ghsOrder['tkPrice'] ?? 0;
                 $customId = $ghsOrder['customId'] ?? 0;
                 $customName = $customList[$customId]['name'] ?? '';
                 $py = $customList[$customId]['py'] ?? '';
@@ -157,8 +159,19 @@ class StatSaleClass extends BaseClass
                     if (isset($arr[$customId])) {
                         $arr[$customId]['num']++;
                         $arr[$customId]['amount'] = bcadd($arr[$customId]['amount'], $actPrice, 2);
+                        $arr[$customId]['orderPrice'] = bcadd($arr[$customId]['orderPrice'], $orderPrice, 2);
+                        $arr[$customId]['tkPrice'] = bcadd($arr[$customId]['tkPrice'], $tkPrice, 2);
                     } else {
-                        $arr[$customId] = ['customId' => $customId, 'customName' => $customName, 'py' => $py, 'num' => 1, 'amount' => $actPrice, 'levelName' => ''];
+                        $arr[$customId] = [
+                            'customId' => $customId,
+                            'customName' => $customName,
+                            'py' => $py,
+                            'num' => 1,
+                            'amount' => $actPrice,
+                            'levelName' => '',
+                            'orderPrice' => $orderPrice,
+                            'tkPrice' => $tkPrice,
+                        ];
                     }
                 }
             }
@@ -386,8 +399,8 @@ class StatSaleClass extends BaseClass
             util::fail('查询时间不能超过三个月');
         }
 
-        $productList = ProductClass::getAllByCondition(['mainId'=>$mainId],null,'id,name','id');
-        if(empty($productList)){
+        $productList = ProductClass::getAllByCondition(['mainId' => $mainId], null, 'id,name', 'id');
+        if (empty($productList)) {
             util::fail('没有找到花材');
         }
 
@@ -429,12 +442,12 @@ class StatSaleClass extends BaseClass
                         $remainNum = bcsub($itemNum, $refundNum);
                         $bigPrice = $cgData->bigPrice ?? 0;
                         $amount = bcmul($remainNum, $bigPrice, 2);
-                        $itemName = $productList[$productId]['name']??'已删除';
+                        $itemName = $productList[$productId]['name'] ?? '已删除';
                         $arr[$productId]['name'] = $itemName;
                         $arr[$productId]['id'] = $productId;
                         if (isset($arr[$productId]['expend'])) {
                             $arr[$productId]['expend'] = bcadd($amount, $arr[$productId]['expend'], 2);
-                            $arr[$productId]['outNum'] = bcadd($arr[$productId]['outNum'],$remainNum,2);
+                            $arr[$productId]['outNum'] = bcadd($arr[$productId]['outNum'], $remainNum, 2);
                         } else {
                             $arr[$productId]['expend'] = $amount;
                             $arr[$productId]['outNum'] = $remainNum;
@@ -474,8 +487,8 @@ class StatSaleClass extends BaseClass
                 if ($status == 0 || $status == 5) {
                     continue;
                 }
-                $shopAdminId = $ghsOrder['shopAdminId']??0;
-                $shopAdminName = $ghsOrder['shopAdminName']??'';
+                $shopAdminId = $ghsOrder['shopAdminId'] ?? 0;
+                $shopAdminName = $ghsOrder['shopAdminName'] ?? '';
                 $orderSn = $ghsOrder['orderSn'] ?? '';
                 $actPrice = $ghsOrder['actPrice'] ?? 0;
                 $tkPrice = $ghsOrder['tkPrice'] ?? 0;
@@ -496,13 +509,13 @@ class StatSaleClass extends BaseClass
                         $xhUnitPrice = $orderItem->xhUnitPrice ?? 0;
                         $amount = bcmul($remainNum, $xhUnitPrice, 2);
 
-                        $itemName = $productList[$productId]['name']??'已删除';
+                        $itemName = $productList[$productId]['name'] ?? '已删除';
 
                         $arr[$productId]['name'] = $itemName;
                         $arr[$productId]['id'] = $productId;
                         if (isset($arr[$productId]['income'])) {
                             $arr[$productId]['income'] = bcadd($amount, $arr[$productId]['income'], 2);
-                            $arr[$productId]['inNum'] = bcadd($arr[$productId]['inNum'],$remainNum,2);
+                            $arr[$productId]['inNum'] = bcadd($arr[$productId]['inNum'], $remainNum, 2);
                         } else {
                             $arr[$productId]['expend'] = 0;
                             $arr[$productId]['outNum'] = 0;
@@ -519,11 +532,11 @@ class StatSaleClass extends BaseClass
                             } else {
                                 $tbSaleIncome[$productId] = ['name' => $name, 'num' => $remainNum, 'price' => $amount];
                             }
-                            if(isset($tbSaleIncomeStaff[$productId]) && isset($tbSaleIncomeStaff[$productId][$shopAdminId])){
+                            if (isset($tbSaleIncomeStaff[$productId]) && isset($tbSaleIncomeStaff[$productId][$shopAdminId])) {
                                 $tbSaleIncomeStaff[$productId][$shopAdminId]['num'] = bcadd($tbSaleIncomeStaff[$productId][$shopAdminId]['num'], $remainNum);
                                 $tbSaleIncomeStaff[$productId][$shopAdminId]['price'] = bcadd($tbSaleIncomeStaff[$productId][$shopAdminId]['price'], $amount, 2);
-                            }else{
-                                $tbSaleIncomeStaff[$productId][$shopAdminId] = ['name' => $name, 'num' => $remainNum, 'price' => $amount,'staffName'=>$shopAdminName];
+                            } else {
+                                $tbSaleIncomeStaff[$productId][$shopAdminId] = ['name' => $name, 'num' => $remainNum, 'price' => $amount, 'staffName' => $shopAdminName];
                             }
                         }
                     }
@@ -565,12 +578,12 @@ class StatSaleClass extends BaseClass
                     $productId = $orderItem->itemId ?? 0;
                     $remainNum = bcsub($num, $refundNum);
                     $amount = bcmul($remainNum, $unitPrice, 2);
-                    $itemName = $productList[$productId]['name']??'已删除';
+                    $itemName = $productList[$productId]['name'] ?? '已删除';
                     $arr[$productId]['name'] = $itemName;
                     $arr[$productId]['id'] = $productId;
                     if (isset($arr[$productId]['income'])) {
                         $arr[$productId]['income'] = bcadd($amount, $arr[$productId]['income'], 2);
-                        $arr[$productId]['inNum'] = bcadd($arr[$productId]['inNum'],$remainNum,2);
+                        $arr[$productId]['inNum'] = bcadd($arr[$productId]['inNum'], $remainNum, 2);
                     } else {
                         $arr[$productId]['expend'] = 0;
                         $arr[$productId]['outNum'] = 0;
@@ -627,12 +640,12 @@ class StatSaleClass extends BaseClass
 
         if ($export == 1) {
             $statData = [
-                ['id' => 0, 'name' => '物流打包费', 'income' => 0, 'expend' => $packFreight, 'profit' => -$packFreight,'inNum'=>0,'outNum'=>0],
-                ['id' => 0, 'name' => '采购仅退款', 'income' => $onlyRefundCg, 'expend' => 0, 'profit' => $onlyRefundCg,'inNum'=>0,'outNum'=>0],
-                ['id' => 0, 'name' => '销售仅退款', 'income' => 0, 'expend' => $onlyRefund, 'profit' => -$onlyRefund,'inNum'=>0,'outNum'=>0],
-                ['id' => 0, 'name' => '附加人工费', 'income' => $totalLabourCost, 'expend' => 0, 'profit' => $totalLabourCost,'inNum'=>0,'outNum'=>0],
-                ['id' => 0, 'name' => '优惠金额', 'income' => -$totalDiscountAmount, 'expend' => 0, 'profit' => -$totalDiscountAmount,'inNum'=>0,'outNum'=>0],
-                ['id' => 0, 'name' => '【汇总金额】', 'income' => $totalIncome, 'expend' => $totalExpend, 'profit' => $totalProfit,'inNum'=>0,'outNum'=>0],
+                ['id' => 0, 'name' => '物流打包费', 'income' => 0, 'expend' => $packFreight, 'profit' => -$packFreight, 'inNum' => 0, 'outNum' => 0],
+                ['id' => 0, 'name' => '采购仅退款', 'income' => $onlyRefundCg, 'expend' => 0, 'profit' => $onlyRefundCg, 'inNum' => 0, 'outNum' => 0],
+                ['id' => 0, 'name' => '销售仅退款', 'income' => 0, 'expend' => $onlyRefund, 'profit' => -$onlyRefund, 'inNum' => 0, 'outNum' => 0],
+                ['id' => 0, 'name' => '附加人工费', 'income' => $totalLabourCost, 'expend' => 0, 'profit' => $totalLabourCost, 'inNum' => 0, 'outNum' => 0],
+                ['id' => 0, 'name' => '优惠金额', 'income' => -$totalDiscountAmount, 'expend' => 0, 'profit' => -$totalDiscountAmount, 'inNum' => 0, 'outNum' => 0],
+                ['id' => 0, 'name' => '【汇总金额】', 'income' => $totalIncome, 'expend' => $totalExpend, 'profit' => $totalProfit, 'inNum' => 0, 'outNum' => 0],
             ];
             $list = array_merge($arr, $statData);
             self::exportIncomeOutItem($list, $mainId);
@@ -644,8 +657,8 @@ class StatSaleClass extends BaseClass
             'totalProfit' => $totalProfit,
             'tbSaleIncome' => $tbSaleIncome,
             'tbCgIncome' => $tbCgIncome,
-            'tbCgIncomeStaff'=>$tbCgIncomeStaff,
-            'tbSaleIncomeStaff'=>$tbSaleIncomeStaff,
+            'tbCgIncomeStaff' => $tbCgIncomeStaff,
+            'tbSaleIncomeStaff' => $tbSaleIncomeStaff,
             'totalLabourCost' => $totalLabourCost,
             'totalDiscountAmount' => $totalDiscountAmount,
         ]);
@@ -790,8 +803,8 @@ class StatSaleClass extends BaseClass
                 if ($status == 0 || $status == 5) {
                     continue;
                 }
-                $shopAdminId = $ghsOrder['shopAdminId']??0;
-                $shopAdminName = $ghsOrder['shopAdminName']??'';
+                $shopAdminId = $ghsOrder['shopAdminId'] ?? 0;
+                $shopAdminName = $ghsOrder['shopAdminName'] ?? '';
                 $orderSn = $ghsOrder['orderSn'] ?? '';
                 $actPrice = $ghsOrder['actPrice'] ?? 0;
                 $tkPrice = $ghsOrder['tkPrice'] ?? 0;
@@ -830,11 +843,11 @@ class StatSaleClass extends BaseClass
                             } else {
                                 $tbSaleIncome[$productId] = ['name' => $name, 'num' => $remainNum, 'price' => $amount];
                             }
-                            if(isset($tbSaleIncomeStaff[$productId]) && isset($tbSaleIncomeStaff[$productId][$shopAdminId])){
+                            if (isset($tbSaleIncomeStaff[$productId]) && isset($tbSaleIncomeStaff[$productId][$shopAdminId])) {
                                 $tbSaleIncomeStaff[$productId][$shopAdminId]['num'] = bcadd($tbSaleIncomeStaff[$productId][$shopAdminId]['num'], $remainNum);
                                 $tbSaleIncomeStaff[$productId][$shopAdminId]['price'] = bcadd($tbSaleIncomeStaff[$productId][$shopAdminId]['price'], $amount, 2);
-                            }else{
-                                $tbSaleIncomeStaff[$productId][$shopAdminId] = ['name' => $name, 'num' => $remainNum, 'price' => $amount,'staffName'=>$shopAdminName];
+                            } else {
+                                $tbSaleIncomeStaff[$productId][$shopAdminId] = ['name' => $name, 'num' => $remainNum, 'price' => $amount, 'staffName' => $shopAdminName];
                             }
                         }
                     }
@@ -963,8 +976,8 @@ class StatSaleClass extends BaseClass
             'totalProfit' => $totalProfit,
             'tbSaleIncome' => $tbSaleIncome,
             'tbCgIncome' => $tbCgIncome,
-            'tbCgIncomeStaff'=>$tbCgIncomeStaff,
-            'tbSaleIncomeStaff'=>$tbSaleIncomeStaff,
+            'tbCgIncomeStaff' => $tbCgIncomeStaff,
+            'tbSaleIncomeStaff' => $tbSaleIncomeStaff,
             'totalLabourCost' => $totalLabourCost,
             'totalDiscountAmount' => $totalDiscountAmount,
         ]);
@@ -1187,7 +1200,7 @@ class StatSaleClass extends BaseClass
             $objPHPExcel->getActiveSheet()->setCellValue('B' . $i, $custom['num']);
             $objPHPExcel->getActiveSheet()->setCellValue('C' . $i, $custom['amount']);
             $objPHPExcel->getActiveSheet()->setCellValue('D' . $i, $custom['gross']);
-            $objPHPExcel->getActiveSheet()->setCellValue('E' . $i, $custom['mll'].'%');
+            $objPHPExcel->getActiveSheet()->setCellValue('E' . $i, $custom['mll'] . '%');
             //居左
             $objPHPExcel->getActiveSheet()->getStyle('A' . $i)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
             $objPHPExcel->getActiveSheet()->getStyle('B' . $i)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_LEFT);