|
|
|
|
@ -339,7 +339,7 @@ class AppointmentController extends Controller
|
|
|
|
|
// 2. 按类型汇总(个检type=1, 团检type=2)
|
|
|
|
|
$charge_amount = round($orders->sum('true_price'), 2);
|
|
|
|
|
$refund_amount = round($refund_orders->sum('true_price'), 2);
|
|
|
|
|
$total_amount = round($charge_amount - $refund_amount, 2);
|
|
|
|
|
$total_amount = round(round($charge_amount - $refund_amount, 4), 2);
|
|
|
|
|
|
|
|
|
|
$type_summary = [];
|
|
|
|
|
foreach ([1 => '个人', 2 => '团检'] as $type_val => $type_name) {
|
|
|
|
|
@ -409,7 +409,7 @@ class AppointmentController extends Controller
|
|
|
|
|
|
|
|
|
|
$price = floatval($item['价格']);
|
|
|
|
|
if (isset($item['优惠方式']) && $item['优惠方式'] === '打折') {
|
|
|
|
|
$price = $price * floatval($item['优惠值']);
|
|
|
|
|
$price = round($price * floatval($item['优惠值']), 2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$key = $matched ? $alias : '__unmatched__';
|
|
|
|
|
@ -420,7 +420,7 @@ class AppointmentController extends Controller
|
|
|
|
|
'item_names' => [],
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
$statistics[$key]['amount'] += $price;
|
|
|
|
|
$statistics[$key]['amount'] = round($statistics[$key]['amount'] + $price, 2);
|
|
|
|
|
if (!$matched) {
|
|
|
|
|
$statistics[$key]['item_names'][] = $item['名称'];
|
|
|
|
|
}
|
|
|
|
|
@ -429,14 +429,22 @@ class AppointmentController extends Controller
|
|
|
|
|
|
|
|
|
|
// 格式化金额,未匹配项去重
|
|
|
|
|
$categories = [];
|
|
|
|
|
$category_total = 0;
|
|
|
|
|
foreach ($statistics as $item) {
|
|
|
|
|
$item['amount'] = round($item['amount'], 2);
|
|
|
|
|
$category_total = round($category_total + $item['amount'], 2);
|
|
|
|
|
if (isset($item['item_names'])) {
|
|
|
|
|
$item['item_names'] = array_values(array_unique($item['item_names']));
|
|
|
|
|
}
|
|
|
|
|
$categories[] = $item;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 合计金额取分类汇总,确保合计与各项之和一致
|
|
|
|
|
if ($category_total > 0) {
|
|
|
|
|
$charge_amount = $category_total;
|
|
|
|
|
}
|
|
|
|
|
$total_amount = round($charge_amount - $refund_amount, 2);
|
|
|
|
|
|
|
|
|
|
return Yo::echo([
|
|
|
|
|
'type_summary' => $type_summary,
|
|
|
|
|
'charge_amount' => $charge_amount,
|
|
|
|
|
|