This commit is contained in:
2025-04-25 15:47:08 +08:00
parent 7889883e1c
commit 21a48829c6
2 changed files with 26 additions and 18 deletions

View File

@@ -195,12 +195,16 @@ class LedgerForm extends BaseModel
* 医保支付(走月付)
*/
if ($productOrder['prescription']['category'] == 2) {
$model = new MonthlyPaymentModel();
$model->store_id = $productOrder->store_id;
$model->order_id = $productOrder->id;
$model->amount = $productOrder->market_price;
$model->created_at = $time;
$model->save();
// 查询订单是否已生成月付
$monthInfo = MonthlyPaymentModel::find()->where(['order_id' => $productOrder->id, 'store_id' => $productOrder->store_id])->one();
if (!$monthInfo) {
$model = new MonthlyPaymentModel();
$model->store_id = $productOrder->store_id;
$model->order_id = $productOrder->id;
$model->amount = $productOrder->market_price;
$model->created_at = $time;
$model->save();
}
} else {
$ledger[] = [
'order_id' => $this->order_id,
@@ -247,19 +251,18 @@ class LedgerForm extends BaseModel
foreach($productOrderItems as $v){
$totalPrice = round($v['number'] * $v['price'], 4);
$totalBuyPrice = round($v['number'] * $v['buy_price'], 4);
// 月付
if ($productOrder['prescription']['category'] == 2) {
// (new MonthlyPaymentModel)->save([
// 'store_id' => $productOrder->store_id,
// 'order_id' => $productOrder->id,
// 'amount' => $totalBuyPrice,
// 'created_at' => $time,
// ]);
$model = new MonthlyPaymentModel();
$model->store_id = $productOrder->store_id;
$model->order_id = $productOrder->id;
$model->amount = $totalBuyPrice;
$model->created_at = $time;
$model->save();
// 查询订单是否已生成月付
$monthInfo = MonthlyPaymentModel::find()->where(['order_id' => $productOrder->id, 'store_id' => $productOrder->store_id])->one();
if (!$monthInfo) {
$model = new MonthlyPaymentModel();
$model->store_id = $productOrder->store_id;
$model->order_id = $productOrder->id;
$model->amount = $productOrder->market_price;
$model->created_at = $time;
$model->save();
}
} else {
$ledger[] = [
'order_id' => $this->order_id,