|
|
@@ -234,24 +234,29 @@ 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];
|
|
|
+ $payStatus = $ghsOrder['payStatus'] ?? 0;
|
|
|
+ $status = $ghsOrder['status'] ?? 0;
|
|
|
+ $book = $ghsOrder['book'] ?? 0;
|
|
|
+ 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];
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|