|
|
@@ -450,11 +450,18 @@ class StatSaleClass extends BaseClass
|
|
|
|
|
|
//批发开单
|
|
|
$pfIncome = 0;
|
|
|
+ $costIncome = [];
|
|
|
$where = ['mainId' => $mainId, 'status' => ['in', [OrderClass::ORDER_STATUS_UN_SEND, OrderClass::ORDER_STATUS_SENDING, OrderClass::ORDER_STATUS_COMPLETE]]];
|
|
|
$where['payTime'] = ['between', [$currentStartTime, $currentEndTime]];
|
|
|
$ghsOrderList = OrderClass::getAllByCondition($where, null, '*');
|
|
|
if (!empty($ghsOrderList)) {
|
|
|
foreach ($ghsOrderList as $ghsKey => $ghsOrder) {
|
|
|
+ $book = $ghsOrder['book'] ?? 0;
|
|
|
+ $status = $ghsOrder['status'] ?? 0;
|
|
|
+ if ($book == 1 && $status == 2) {
|
|
|
+ //预订单待发货的不算收入
|
|
|
+ continue;
|
|
|
+ }
|
|
|
$orderSn = $ghsOrder['orderSn'] ?? '';
|
|
|
$actPrice = $ghsOrder['actPrice'] ?? 0;
|
|
|
$tkPrice = $ghsOrder['tkPrice'] ?? 0;
|
|
|
@@ -492,6 +499,34 @@ 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) {
|
|
|
+ //$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];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -569,6 +604,7 @@ class StatSaleClass extends BaseClass
|
|
|
'totalIncome' => $totalIncome,
|
|
|
'totalExpend' => $totalExpend,
|
|
|
'totalProfit' => $totalProfit,
|
|
|
+ 'costIncome' => $costIncome,
|
|
|
]);
|
|
|
}
|
|
|
|