master
cody 4 months ago
parent 200ea9d2f2
commit 9172bee757

@ -21,6 +21,7 @@ use App\Models\Orders;
use App\Models\Paramedic; use App\Models\Paramedic;
use App\Models\Product; use App\Models\Product;
use App\Models\ProductItems; use App\Models\ProductItems;
use App\Models\ProductParamedicLevel;
use App\Models\Project; use App\Models\Project;
use App\Models\Recharge; use App\Models\Recharge;
use App\Models\Refund; use App\Models\Refund;
@ -476,6 +477,9 @@ class StatisticsController extends CommonController
$product = Product::where('project_id', $project_id)->first(); $product = Product::where('project_id', $project_id)->first();
$productItem = ProductItems::where('product_id', $product->id)->get(); $productItem = ProductItems::where('product_id', $product->id)->get();
$factor = FactorItems::where('factor_id', $product->statistic_factor_id)->get(); $factor = FactorItems::where('factor_id', $product->statistic_factor_id)->get();
// 护工等级加价:取该产品下最小的护工级别加价,作为统计时的基础护工价
$min_paramedic_price = (float) ProductParamedicLevel::where('product_id', $product->id)->min('price');
$sumOrderTotal = 0; $sumOrderTotal = 0;
foreach ($data as $item) { foreach ($data as $item) {
// 获取所有床位id // 获取所有床位id
@ -487,7 +491,7 @@ class StatisticsController extends CommonController
->sum('total'); ->sum('total');
$sumOrderTotal += $item->order_total; $sumOrderTotal += $item->order_total;
// 子项 // 子项
$item->lies = $this->getLies($bedIds, $productItem, $factor, $month); $item->lies = $this->getLies($bedIds, $productItem, $factor, $month, $min_paramedic_price);
} }
// 获取所有列(包含价格和 factor_item 名称) // 获取所有列(包含价格和 factor_item 名称)
$lie = []; $lie = [];
@ -502,7 +506,7 @@ class StatisticsController extends CommonController
/** /**
* 获取动态列 * 获取动态列
*/ */
public function getLies($bedIds, $productItem, $factor, $month) public function getLies($bedIds, $productItem, $factor, $month, $min_paramedic_price = 0)
{ {
$list = []; $list = [];
@ -532,8 +536,11 @@ class StatisticsController extends CommonController
$total = $query->sum('total'); $total = $query->sum('total');
// 修复:明确计算价格总和,避免运算符优先级问题 // 价格逻辑与下单保持一致(近似):
$totalPrice = (float) $item->price + (float) $factor_item->price; // 基础价 = 产品子项价格 + 最低护工级别加价
// 列对应的因子价 = 当前统计因子的价格
// 最终表头价格 = 基础价 + 当前因子价
$totalPrice = (float) $item->price + (float) $min_paramedic_price + (float) $factor_item->price;
$list[] = [ $list[] = [
'name' => $totalPrice . '元/天', 'name' => $totalPrice . '元/天',

Loading…
Cancel
Save