|
|
@@ -378,9 +378,9 @@ class StatSaleClass extends BaseClass
|
|
|
$s = strtotime($currentStartTime);
|
|
|
$e = strtotime($currentEndTime);
|
|
|
$p = bcsub($e, $s);
|
|
|
- $xx = bcmul(86400, 60);
|
|
|
+ $xx = bcmul(86400, 90);
|
|
|
if ($p > $xx) {
|
|
|
- util::fail('查询时间不能超过二个月');
|
|
|
+ util::fail('查询时间不能超过三个月');
|
|
|
}
|
|
|
|
|
|
$classList = ItemClassClass::getAllByCondition(['mainId' => $mainId], null, 'id,name', 'id');
|
|
|
@@ -395,6 +395,7 @@ class StatSaleClass extends BaseClass
|
|
|
$onlyRefund = 0;
|
|
|
|
|
|
//采购入库
|
|
|
+ $tbCgIncome = [];
|
|
|
$cgWhere = ['mainId' => $mainId, 'status' => 4];
|
|
|
$cgWhere['entryTime'] = ['between', [$currentStartTime, $currentEndTime]];
|
|
|
$cgList = PurchaseOrderClass::getAllByCondition($cgWhere, null, '*');
|
|
|
@@ -417,6 +418,8 @@ class StatSaleClass extends BaseClass
|
|
|
if (!empty($cgItemInfoList)) {
|
|
|
foreach ($cgItemInfoList as $cgData) {
|
|
|
$itemNum = $cgData->itemNum ?? 0;
|
|
|
+ $productId = $cgData->productId ?? 0;
|
|
|
+ $name = $cgData->name ?? '';
|
|
|
$refundNum = $cgData->refundNum ?? 0;
|
|
|
$remainNum = bcsub($itemNum, $refundNum);
|
|
|
$bigPrice = $cgData->bigPrice ?? 0;
|
|
|
@@ -431,6 +434,12 @@ 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];
|
|
|
+ }
|
|
|
}
|
|
|
if ($tkPrice > 0) {
|
|
|
$cgRefundOrderList = CgRefundClass::getAllByCondition(['relateOrderSn' => $orderSn], null, '*', null, true);
|
|
|
@@ -438,8 +447,6 @@ class StatSaleClass extends BaseClass
|
|
|
foreach ($cgRefundOrderList as $cgRefundOrder) {
|
|
|
if ($cgRefundOrder->refundType == 2) {
|
|
|
$onlyRefundCg = bcadd($cgRefundOrder->refundPrice, $onlyRefundCg, 2);
|
|
|
- } else {
|
|
|
- //退货退款前面已经考虑,这里不再处理 OK
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -450,7 +457,7 @@ class StatSaleClass extends BaseClass
|
|
|
|
|
|
//批发开单
|
|
|
$pfIncome = 0;
|
|
|
- $costIncome = [];
|
|
|
+ $tbSaleIncome = [];
|
|
|
$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, '*');
|
|
|
@@ -500,7 +507,7 @@ 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);
|
|
|
@@ -508,7 +515,7 @@ class StatSaleClass extends BaseClass
|
|
|
foreach ($ghsOrderItemList as $ghsOrderItem) {
|
|
|
$belongCost = $ghsOrderItem['belongCost'] ?? 0;
|
|
|
if ($belongCost == 1) {
|
|
|
- //$costIncome
|
|
|
+ //$tbSaleIncome
|
|
|
$productId = $ghsOrderItem['productId'] ?? 0;
|
|
|
$name = $ghsOrderItem['name'] ?? '';
|
|
|
$num = $ghsOrderItem['xhNum'] ?? 0;
|
|
|
@@ -516,11 +523,11 @@ class StatSaleClass extends BaseClass
|
|
|
$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);
|
|
|
+ if (isset($tbSaleIncome[$productId])) {
|
|
|
+ $tbSaleIncome[$productId]['num'] = bcadd($tbSaleIncome[$productId]['num'], $remainNum);
|
|
|
+ $tbSaleIncome[$productId]['price'] = bcadd($tbSaleIncome[$productId]['price'], $price, 2);
|
|
|
} else {
|
|
|
- $costIncome[$productId] = ['name' => $name, 'num' => $remainNum, 'price' => $price];
|
|
|
+ $tbSaleIncome[$productId] = ['name' => $name, 'num' => $remainNum, 'price' => $price];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -604,7 +611,8 @@ class StatSaleClass extends BaseClass
|
|
|
'totalIncome' => $totalIncome,
|
|
|
'totalExpend' => $totalExpend,
|
|
|
'totalProfit' => $totalProfit,
|
|
|
- 'costIncome' => $costIncome,
|
|
|
+ 'tbSaleIncome' => $tbSaleIncome,
|
|
|
+ 'tbCgIncome' => $tbCgIncome,
|
|
|
]);
|
|
|
}
|
|
|
|