|
|
@@ -4,6 +4,7 @@ namespace bizGhs\stat\classes;
|
|
|
|
|
|
use biz\shop\classes\ShopAdminClass;
|
|
|
use bizGhs\order\classes\OrderClass;
|
|
|
+use bizGhs\order\classes\OrderItemClass;
|
|
|
use bizGhs\order\classes\StockOutOrderClass;
|
|
|
use bizHd\order\classes\SettleClass;
|
|
|
use common\components\dateUtil;
|
|
|
@@ -147,6 +148,8 @@ class StatKdClass extends BaseClass
|
|
|
],
|
|
|
];
|
|
|
|
|
|
+ $costIncome = [];
|
|
|
+
|
|
|
//批发开单
|
|
|
$where = ['mainId' => $mainId, 'status' => ['in', [OrderClass::ORDER_STATUS_UN_SEND, OrderClass::ORDER_STATUS_SENDING, OrderClass::ORDER_STATUS_COMPLETE]]];
|
|
|
$where['payTime'] = ['between', [$currentStartTime, $currentEndTime]];
|
|
|
@@ -228,6 +231,31 @@ class StatKdClass extends BaseClass
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //计算属于成本的收入
|
|
|
+ $orderSn = $ghsOrder['orderSn'] ?? '';
|
|
|
+ $ghsOrderItemList = OrderItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true);
|
|
|
+ if (!empty($ghsOrderItemList)) {
|
|
|
+ foreach ($ghsOrderItemList as $ghsOrderItem) {
|
|
|
+ $belongCost = $ghsOrderItem['belongCost'] ?? 0;
|
|
|
+ if ($belongCost == 1) {
|
|
|
+ //$costIncome
|
|
|
+ $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($costIncome[$productId])) {
|
|
|
+ $costIncome[$productId]['num'] = bcadd($costIncome[$productId]['num'], $remainNum);
|
|
|
+ $costIncome[$productId]['price'] = bcadd($costIncome[$productId]['price'], $price, 2);
|
|
|
+ } else {
|
|
|
+ $costIncome[$productId] = ['name' => $name, 'num' => $remainNum, 'price' => $price];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -477,8 +505,7 @@ class StatKdClass extends BaseClass
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //noticeUtil::push(json_encode($incomeList), '15280215347');
|
|
|
- return $incomeList;
|
|
|
+ return ['costIncome' => $costIncome, 'incomeList' => $incomeList];
|
|
|
|
|
|
}
|
|
|
|