对账功能修改(修复历史遗留问题:中药对账没有按照贴数*克数计算)

This commit is contained in:
2025-04-07 10:31:51 +08:00
parent 601cabb393
commit 869431e982
3 changed files with 91 additions and 51 deletions

View File

@@ -191,6 +191,9 @@ class LedgerForm extends BaseModel
$totalPrice = round($number * $v['price'], 4);
$totalBuyPrice = round($number * $v['buy_price'], 4);
/*
* 医保支付(走月付)
*/
if ($productOrder['prescription']['category'] == 2) {
$model = new MonthlyPaymentModel();
$model->store_id = $productOrder->store_id;
@@ -198,14 +201,6 @@ class LedgerForm extends BaseModel
$model->amount = $productOrder->market_price;
$model->created_at = $time;
$model->save();
// (new MonthlyPaymentModel)->save([
// 'store_id' => $productOrder->store_id,
// 'order_id' => $productOrder->id,
// 'amount' => $totalBuyPrice,
// 'created_at' => $time,
// ]);
} else {
$ledger[] = [
'order_id' => $this->order_id,
@@ -511,6 +506,7 @@ class LedgerForm extends BaseModel
$productOrderItems = ProductOrderItems::find()->with(['drug.supplier'])->where(['product_order_id' => $productOrder->id])->asArray()->all();
$Reconciliation = new Reconciliation();
foreach($productOrderItems as $v){
$number = $v['dosage'] === 0 ? $v['number'] : $v['number'] * $v['dosage'];
$item = clone $Reconciliation;
$item->store_id = $productOrder->store_id;
$item->order_id = $productOrder->id;
@@ -518,9 +514,11 @@ class LedgerForm extends BaseModel
$item->xd_time = $productOrder->created_at;
$item->drug_id = $v['drug_id'];
$item->drug_type = $v['type'];
$item->number = $v['number'];
$item->total_buy_price = $v['number'] * $v['buy_price'];
$item->total_price = $v['number'] * $v['price'];
$item->number = $number;
// $item->total_buy_price = $v['number'] * $v['buy_price'];
$item->total_buy_price = bcmul($number, $v['buy_price'], 6);
// $item->total_price = $v['number'] * $v['price'];
$item->total_price = bcmul($number, $v['price'], 6);
$item->created_at = $time;
$item->updated_at = $time;
$item->saveOrFail();