moonsflyer 4 месяцев назад
Родитель
Сommit
730cccf90a
1 измененных файлов с 22 добавлено и 0 удалено
  1. 22 0
      app/common/logic/PayNotifyLogic.php

+ 22 - 0
app/common/logic/PayNotifyLogic.php

@@ -122,7 +122,29 @@ class PayNotifyLogic extends BaseLogic
                 $award_integral = floor($order['order_amount'] * ($award_ratio / 100));
             }
         }
+        //混合支付扣减余额
+        if($order['pay_way'] == PayEnum::MIXED_PAY) {
+            //扣除余额
+            User::update([
+                'user_money' => ['dec', $order['balance_amount']]
+            ], ['id' => $order['user_id']]);
+
+            // 记录余额流水
+            AccountLogLogic::add(
+                $order['user_id'],
+                AccountLogEnum::BNW_DEC_ORDER,
+                AccountLogEnum::DEC,
+                $order['balance_amount'],
+                $order['sn'],
+                '混合支付-余额部分'
+            );
 
+            file_put_contents(
+                runtime_path() . 'log' . DIRECTORY_SEPARATOR . 'mixed_pay_debug_' . date('Y-m-d') . '.log',
+                "[" . date('Y-m-d H:i:s') . "] 余额扣除成功,扣除金额: {$order['balance_amount']}" . PHP_EOL,
+                FILE_APPEND | LOCK_EX
+            );
+        }
         //更新订单状态
         Order::update([
             'pay_status'            => PayEnum::ISPAID,