|
|
@@ -1688,6 +1688,10 @@ class StatSaleClass extends BaseClass
|
|
|
return $arr;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 片区业绩:按片区汇总笔数/扎数/金额/成本/利润,供 ghsApp distSale、/stat-kh-cg/dist 使用。
|
|
|
+ * totalCount 为总扎数(含隔天售后扣减),与各行 count 口径一致。
|
|
|
+ */
|
|
|
public static function customDistStat($mainId)
|
|
|
{
|
|
|
$get = Yii::$app->request->get();
|
|
|
@@ -1718,6 +1722,7 @@ class StatSaleClass extends BaseClass
|
|
|
$ghsOrderList = OrderClass::getAllByCondition($where, null, '*');
|
|
|
$totalAmount = 0;
|
|
|
$totalNum = 0;
|
|
|
+ $totalCount = 0;
|
|
|
$totalProfit = 0;
|
|
|
$totalCost = 0;
|
|
|
if (!empty($ghsOrderList)) {
|
|
|
@@ -1746,6 +1751,7 @@ class StatSaleClass extends BaseClass
|
|
|
$distName = isset($distMap[$distId]) ? $distMap[$distId]['name'] : '未划片区';
|
|
|
|
|
|
$totalNum++;
|
|
|
+ $totalCount = bcadd($totalCount, $count, 2);
|
|
|
$totalAmount = bcadd($totalAmount, $actPrice, 2);
|
|
|
$totalProfit = bcadd($totalProfit, $profit, 2);
|
|
|
$totalCost = bcadd($totalCost, $cost, 2);
|
|
|
@@ -1822,6 +1828,7 @@ class StatSaleClass extends BaseClass
|
|
|
}
|
|
|
$profit = bcsub($actPrice, $cost, 2);
|
|
|
$totalNum++;
|
|
|
+ $totalCount = bcadd($totalCount, $count, 2);
|
|
|
$totalAmount = bcadd($totalAmount, $actPrice, 2);
|
|
|
$totalProfit = bcadd($totalProfit, $profit, 2);
|
|
|
$totalCost = bcadd($totalCost, $cost, 2);
|
|
|
@@ -1879,6 +1886,7 @@ class StatSaleClass extends BaseClass
|
|
|
$arr[$distId]['count'] = bcsub((string)($arr[$distId]['count'] ?? 0), (string)$qty, 2);
|
|
|
$totalAmount = bcsub((string)$totalAmount, (string)$amt, 2);
|
|
|
$totalProfit = bcsub((string)$totalProfit, (string)$amt, 2);
|
|
|
+ $totalCount = bcsub((string)$totalCount, (string)$qty, 2);
|
|
|
}
|
|
|
|
|
|
$hdAmtMap = HdNextDayRefundClass::sumAmountGroupByCustom($mainId, $currentStartTime, $currentEndTime);
|
|
|
@@ -1911,12 +1919,13 @@ class StatSaleClass extends BaseClass
|
|
|
$arr[$hdDistKey]['count'] = bcsub((string)($arr[$hdDistKey]['count'] ?? 0), $hdQtyTotal, 2);
|
|
|
$totalAmount = bcsub((string)$totalAmount, $hdAmtTotal, 2);
|
|
|
$totalProfit = bcsub((string)$totalProfit, $hdAmtTotal, 2);
|
|
|
+ $totalCount = bcsub((string)$totalCount, $hdQtyTotal, 2);
|
|
|
}
|
|
|
if (!empty($arr)) {
|
|
|
$arr = arrayUtil::arraySort($arr, 'profit');
|
|
|
}
|
|
|
$totalAmount = floatval($totalAmount);
|
|
|
- return ['list' => $arr, 'totalAmount' => $totalAmount, 'totalNum' => $totalNum, 'totalCost' => $totalCost, 'totalProfit' => $totalProfit];
|
|
|
+ return ['list' => $arr, 'totalAmount' => $totalAmount, 'totalNum' => $totalNum, 'totalCount' => floatval($totalCount), 'totalCost' => $totalCost, 'totalProfit' => $totalProfit];
|
|
|
}
|
|
|
|
|
|
/**
|