|
@@ -121,7 +121,10 @@ class StatSaleClass extends BaseClass
|
|
|
return ['list' => $ghsOrderList];
|
|
return ['list' => $ghsOrderList];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //客户下单榜 ssh 20230502
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 客户业绩:按客户汇总笔数/扎数/金额/成本/利润,供 ghsApp customSale、/stat-kh-cg/profile 使用。
|
|
|
|
|
+ * totalCount 为总扎数(含隔天售后扣减),与各行 count 口径一致。
|
|
|
|
|
+ */
|
|
|
public static function statCustomCg($mainId)
|
|
public static function statCustomCg($mainId)
|
|
|
{
|
|
{
|
|
|
$get = Yii::$app->request->get();
|
|
$get = Yii::$app->request->get();
|
|
@@ -150,6 +153,7 @@ class StatSaleClass extends BaseClass
|
|
|
$ghsOrderList = OrderClass::getAllByCondition($where, null, '*');
|
|
$ghsOrderList = OrderClass::getAllByCondition($where, null, '*');
|
|
|
$totalAmount = 0;
|
|
$totalAmount = 0;
|
|
|
$totalNum = 0;
|
|
$totalNum = 0;
|
|
|
|
|
+ $totalCount = 0;
|
|
|
$totalProfit = 0;
|
|
$totalProfit = 0;
|
|
|
$totalCost = 0;
|
|
$totalCost = 0;
|
|
|
if (!empty($ghsOrderList)) {
|
|
if (!empty($ghsOrderList)) {
|
|
@@ -176,6 +180,7 @@ class StatSaleClass extends BaseClass
|
|
|
$customName = $customList[$customId]['name'] ?? '';
|
|
$customName = $customList[$customId]['name'] ?? '';
|
|
|
$py = $customList[$customId]['py'] ?? '';
|
|
$py = $customList[$customId]['py'] ?? '';
|
|
|
$totalNum++;
|
|
$totalNum++;
|
|
|
|
|
+ $totalCount = bcadd($totalCount, $count, 2);
|
|
|
$totalAmount = bcadd($totalAmount, $actPrice, 2);
|
|
$totalAmount = bcadd($totalAmount, $actPrice, 2);
|
|
|
$totalProfit = bcadd($totalProfit, $profit, 2);
|
|
$totalProfit = bcadd($totalProfit, $profit, 2);
|
|
|
$totalCost = bcadd($totalCost, $cost, 2);
|
|
$totalCost = bcadd($totalCost, $cost, 2);
|
|
@@ -261,6 +266,7 @@ class StatSaleClass extends BaseClass
|
|
|
}
|
|
}
|
|
|
$profit = bcsub($actPrice, $cost, 2);
|
|
$profit = bcsub($actPrice, $cost, 2);
|
|
|
$totalNum++;
|
|
$totalNum++;
|
|
|
|
|
+ $totalCount = bcadd($totalCount, $count, 2);
|
|
|
$totalAmount = bcadd($totalAmount, $actPrice, 2);
|
|
$totalAmount = bcadd($totalAmount, $actPrice, 2);
|
|
|
$totalProfit = bcadd($totalProfit, $profit, 2);
|
|
$totalProfit = bcadd($totalProfit, $profit, 2);
|
|
|
$totalCost = bcadd($totalCost, $cost, 2);
|
|
$totalCost = bcadd($totalCost, $cost, 2);
|
|
@@ -324,6 +330,7 @@ class StatSaleClass extends BaseClass
|
|
|
$arr[$cid]['count'] = bcsub((string)($arr[$cid]['count'] ?? 0), (string)$qty, 2);
|
|
$arr[$cid]['count'] = bcsub((string)($arr[$cid]['count'] ?? 0), (string)$qty, 2);
|
|
|
$totalAmount = bcsub((string)$totalAmount, (string)$amt, 2);
|
|
$totalAmount = bcsub((string)$totalAmount, (string)$amt, 2);
|
|
|
$totalProfit = bcsub((string)$totalProfit, (string)$amt, 2);
|
|
$totalProfit = bcsub((string)$totalProfit, (string)$amt, 2);
|
|
|
|
|
+ $totalCount = bcsub((string)$totalCount, (string)$qty, 2);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// hd 零售隔天:独立 key +「零售-」客户名
|
|
// hd 零售隔天:独立 key +「零售-」客户名
|
|
@@ -372,12 +379,13 @@ class StatSaleClass extends BaseClass
|
|
|
$arr[$rowKey]['count'] = bcsub((string)($arr[$rowKey]['count'] ?? 0), (string)$qty, 2);
|
|
$arr[$rowKey]['count'] = bcsub((string)($arr[$rowKey]['count'] ?? 0), (string)$qty, 2);
|
|
|
$totalAmount = bcsub((string)$totalAmount, (string)$amt, 2);
|
|
$totalAmount = bcsub((string)$totalAmount, (string)$amt, 2);
|
|
|
$totalProfit = bcsub((string)$totalProfit, (string)$amt, 2);
|
|
$totalProfit = bcsub((string)$totalProfit, (string)$amt, 2);
|
|
|
|
|
+ $totalCount = bcsub((string)$totalCount, (string)$qty, 2);
|
|
|
}
|
|
}
|
|
|
if (!empty($arr)) {
|
|
if (!empty($arr)) {
|
|
|
$arr = arrayUtil::arraySort($arr, 'profit');
|
|
$arr = arrayUtil::arraySort($arr, 'profit');
|
|
|
}
|
|
}
|
|
|
$totalAmount = floatval($totalAmount);
|
|
$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];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public static function profile($mainId)
|
|
public static function profile($mainId)
|