shish %!s(int64=2) %!d(string=hai) anos
pai
achega
150bfb4632
Modificáronse 1 ficheiros con 21 adicións e 33 borrados
  1. 21 33
      biz-ghs/stat/classes/StatSaleClass.php

+ 21 - 33
biz-ghs/stat/classes/StatSaleClass.php

@@ -434,11 +434,15 @@ class StatSaleClass extends BaseClass
                             $arr[$classId]['expend'] = $amount;
                             $arr[$classId]['income'] = 0;
                         }
-                        if (isset($tbCgIncome[$productId])) {
-                            $tbCgIncome[$productId]['num'] = bcadd($tbCgIncome[$productId]['num'], $remainNum);
-                            $tbCgIncome[$productId]['price'] = bcadd($tbCgIncome[$productId]['price'], $amount, 2);
-                        } else {
-                            $tbCgIncome[$productId] = ['num' => $remainNum, 'name' => $name, 'price' => $amount];
+                        //单独统计
+                        $belongCost = $cgData->belongCost ?? 0;
+                        if ($belongCost == 1) {
+                            if (isset($tbCgIncome[$productId])) {
+                                $tbCgIncome[$productId]['num'] = bcadd($tbCgIncome[$productId]['num'], $remainNum);
+                                $tbCgIncome[$productId]['price'] = bcadd($tbCgIncome[$productId]['price'], $amount, 2);
+                            } else {
+                                $tbCgIncome[$productId] = ['num' => $remainNum, 'name' => $name, 'price' => $amount];
+                            }
                         }
                     }
                     if ($tkPrice > 0) {
@@ -477,6 +481,8 @@ class StatSaleClass extends BaseClass
                 if (!empty($orderItemList)) {
                     foreach ($orderItemList as $orderItem) {
                         $refundNum = $orderItem->refundNum ?? 0;
+                        $name = $orderItem->name ?? '';
+                        $productId = $orderItem->productId ?? 0;
                         $num = $orderItem->xhNum ?? 0;
                         $remainNum = bcsub($num, $refundNum);
                         $classId = $orderItem->classId ?? 0;
@@ -491,6 +497,16 @@ class StatSaleClass extends BaseClass
                             $arr[$classId]['expend'] = 0;
                             $arr[$classId]['income'] = $amount;
                         }
+                        //单独统计
+                        $belongCost = $orderItem->belongCost ?? 0;
+                        if ($belongCost == 1) {
+                            if (isset($tbSaleIncome[$productId])) {
+                                $tbSaleIncome[$productId]['num'] = bcadd($tbSaleIncome[$productId]['num'], $remainNum);
+                                $tbSaleIncome[$productId]['price'] = bcadd($tbSaleIncome[$productId]['price'], $amount, 2);
+                            } else {
+                                $tbSaleIncome[$productId] = ['name' => $name, 'num' => $remainNum, 'price' => $amount];
+                            }
+                        }
                     }
                     if ($tkPrice > 0) {
                         $refundList = RefundOrderClass::getAllByCondition(['relateOrderSn' => $orderSn], null, '*', null, true);
@@ -506,34 +522,6 @@ class StatSaleClass extends BaseClass
                     }
 
                 }
-
-                //销售特别统计
-                $orderSn = $ghsOrder['orderSn'] ?? '';
-                if ($book == 0 || ($book == 1 && in_array($status, [3, 4]))) {
-                    $ghsOrderItemList = OrderItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true);
-                    if (!empty($ghsOrderItemList)) {
-                        foreach ($ghsOrderItemList as $ghsOrderItem) {
-                            $belongCost = $ghsOrderItem['belongCost'] ?? 0;
-                            if ($belongCost == 1) {
-                                //$tbSaleIncome
-                                $productId = $ghsOrderItem['productId'] ?? 0;
-                                $name = $ghsOrderItem['name'] ?? '';
-                                $num = $ghsOrderItem['xhNum'] ?? 0;
-                                $refundNum = $ghsOrderItem['refundNum'] ?? 0;
-                                $unitPrice = $ghsOrderItem['xhUnitPrice'] ?? 0;
-                                $remainNum = bcsub($num, $refundNum);
-                                $price = bcmul($remainNum, $unitPrice, 2);
-                                if (isset($tbSaleIncome[$productId])) {
-                                    $tbSaleIncome[$productId]['num'] = bcadd($tbSaleIncome[$productId]['num'], $remainNum);
-                                    $tbSaleIncome[$productId]['price'] = bcadd($tbSaleIncome[$productId]['price'], $price, 2);
-                                } else {
-                                    $tbSaleIncome[$productId] = ['name' => $name, 'num' => $remainNum, 'price' => $price];
-                                }
-                            }
-                        }
-                    }
-                }
-
             }
         }