修复统计bug

This commit is contained in:
2024-11-14 13:26:29 +08:00
parent 4cf496c1f1
commit 6a5ddb3a99

View File

@@ -118,6 +118,10 @@ class DataController extends BaseAdminController
// 判断获取时间方法
$dateStr = !empty($day) ? 'm-d' : 'Y-m';
$dateArr = !empty($day) ? $day : $month;
foreach ($dateArr as $v) {
if (!isset($saleMoney[$v])) $saleMoney[$v] = '0.00';
if (!isset($refundMoney[$v])) $refundMoney[$v] = '0.00';
}
foreach ($query as $v) {
$thisMonth = date($dateStr, $v['created_at']);
$saleMoney[$thisMonth] = bcadd($saleMoney[$thisMonth] ?? '0', $v['total_price'], 2);
@@ -136,10 +140,6 @@ class DataController extends BaseAdminController
$refundMoney[$thisMonth] = bcadd($refundMoney[$thisMonth] ?? '0', $v['total_price'], 2);
}
}
foreach ($dateArr as $v) {
if (!isset($saleMoney[$v])) $saleMoney[$v] = '0.00';
if (!isset($refundMoney[$v])) $refundMoney[$v] = '0.00';
}
// 循环$drugSaleMoney计算药品分类占比
foreach ($drugSaleMoney as $k => $v) {
$drugSaleMoney[$k]['percentage'] = bcadd(0, bcdiv($v['value'], $totalMoney, 6) * 100, 4). '%';