From b4ef286e4e9c682fa7b32aaafb6bb66aa222d980 Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Tue, 13 Jun 2023 17:44:15 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=95=86=E6=88=B7=E5=86=BB?= =?UTF-8?q?=E7=BB=93=E9=87=91=E9=A2=9D=E5=85=A5=E8=B4=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/merchant/MerchantRepository.php | 46 ++++++++++--------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/app/common/repositories/system/merchant/MerchantRepository.php b/app/common/repositories/system/merchant/MerchantRepository.php index b0339772..47209f08 100644 --- a/app/common/repositories/system/merchant/MerchantRepository.php +++ b/app/common/repositories/system/merchant/MerchantRepository.php @@ -564,30 +564,32 @@ class MerchantRepository extends BaseRepository Db::transaction(function () use ($order) { $money = 0; $make = app()->make(UserBillRepository::class); - $bill = $make->search(['category' => 'mer_lock_money', 'type' => 'order', 'link_id' => '1' . $order->order_id, 'status' => 0])->find(); - if ($bill) { - $money = bcsub($bill->number, $make->refundMerchantMoney($bill->link_id, $bill->type, $bill->mer_id), 2); - if ($order->presellOrder) { - $presellBill = $make->search(['category' => 'mer_lock_money', 'type' => 'presell', 'link_id' => '2' . $order->presellOrder->presell_order_id, 'status' => 0])->find(); - if ($presellBill) { - $money = bcadd($money, bcsub($presellBill->number, $make->refundMerchantMoney($presellBill->link_id, $presellBill->type, $presellBill->mer_id), 2), 2); - $presellBill->status = 1; - $presellBill->save(); + $bills = $make->search(['category' => 'mer_lock_money', 'type' => 'order', 'link_id' => '1' . $order->order_id, 'status' => 0])->select(); + foreach ($bills as $bill) { + if ($bill) { + $money = bcsub($bill->number, $make->refundMerchantMoney($bill->link_id, $bill->type, $bill->mer_id), 2); + if ($order->presellOrder) { + $presellBill = $make->search(['category' => 'mer_lock_money', 'type' => 'presell', 'link_id' => '2' . $order->presellOrder->presell_order_id, 'status' => 0])->find(); + if ($presellBill) { + $money = bcadd($money, bcsub($presellBill->number, $make->refundMerchantMoney($presellBill->link_id, $presellBill->type, $presellBill->mer_id), 2), 2); + $presellBill->status = 1; + $presellBill->save(); + } } + $bill->status = 1; + $bill->save(); + } + if ($money > 0) { + app()->make(UserBillRepository::class)->incBill($bill->uid, 'mer_computed_money', 'order', [ + 'link_id' => $order->order_id, + 'mer_id' => $bill->mer_id, + 'status' => 0, + 'title' => '商户待解冻余额', + 'number' => $money, + 'mark' => '交易完成,商户待解冻余额' . floatval($money) . '元', + 'balance' => 0 + ]); } - $bill->status = 1; - $bill->save(); - } - if ($money > 0) { - app()->make(UserBillRepository::class)->incBill($order->uid, 'mer_computed_money', 'order', [ - 'link_id' => $order->order_id, - 'mer_id' => $order->mer_id, - 'status' => 0, - 'title' => '商户待解冻余额', - 'number' => $money, - 'mark' => '交易完成,商户待解冻余额' . floatval($money) . '元', - 'balance' => 0 - ]); } }); }