From 36261817171dbc1d7436671c3f0428caaf5d432d Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Tue, 30 Jan 2024 14:10:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=B4=A2=E5=8A=A1=E6=B5=81?= =?UTF-8?q?=E6=B0=B4=E5=86=99=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dao/store/consumption/CommissionDao.php | 24 ++++++------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/app/common/dao/store/consumption/CommissionDao.php b/app/common/dao/store/consumption/CommissionDao.php index 5306b8e8..feca73b2 100755 --- a/app/common/dao/store/consumption/CommissionDao.php +++ b/app/common/dao/store/consumption/CommissionDao.php @@ -86,23 +86,20 @@ class CommissionDao if (empty($consumption)) { return []; } - $financialRecordRepository = app()->make(FinancialRecordRepository::class); - $financeSn = $financialRecordRepository->getSn(); $users = $this->getUsers($data['user']); $order = StoreOrder::where('order_id', $data['order_id'])->find(); if (empty($order)) { return []; } - $finance = []; $result = []; $financeDao = new FinancialDao(); - foreach ($users as $k => $user) { + foreach ($users as $user) { $commission = bcdiv($user['user_profit'], 100, 2); if ($commission > 0) { $financeDao->user = $user; $financeDao->order = $order; $financialType = $user['type'] == 3 ? 'order_commission' : 'first_order_commission'; // TODO 配送员的佣金类型需要调整 - $finance[] = $financeDao->platformOut($commission, $financialType, $financeSn, $k + 1); + $financeDao->platformOut($commission, $financialType); $result[] = $user; } $redPack = bcmul($order['pay_price'], $consumption['config']['red_pack_rate'], 2); @@ -114,9 +111,7 @@ class CommissionDao } } } - if (count($finance) > 0) { - $financialRecordRepository->insertAll($finance); - } + $financeDao->save(); return $result; } @@ -168,15 +163,12 @@ class CommissionDao return; } $commission = bcmul($refundOrder->order['pay_price'], 0.01, 2); - $financialRecordRepository = app()->make(FinancialRecordRepository::class); - $financeSn = $financialRecordRepository->getSn(); $financeDao = new FinancialDao(); - $finance = []; if ($commission > 0 && $refundOrder->order['order_type'] == 1) { // 订单为自提,且佣金大于0,下单的店铺退佣金 $financeDao->user = $refundOrder->order->user; $financeDao->order = $refundOrder->order; - $finance[] = $financeDao->platformIn($commission, 'first_order_commission_refund', $financeSn, 0); + $financeDao->platformIn($commission, 'first_order_commission_refund'); app()->make(MerchantRepository::class)->subLockMoney($refundOrder->order['mer_id'], 'order', $refundOrder->order['order_id'], $commission); } @@ -186,14 +178,12 @@ class CommissionDao ->field('user_id uid,user_info nickname')->select()->toArray(); $redPack = bcmul($refundOrder->order['pay_price'], 0.07, 2); (new StoreConsumptionUserDao())->refundByCommission($refundOrder->order['uid'], $refundOrder->order->order_id, $redPack); - foreach ($financeRecord as $k => $item) { + foreach ($financeRecord as $item) { $financeDao->user = $item; $financeDao->order = $refundOrder->order; - $finance[] = $financeDao->platformIn($item['number'], $item['financial_type'] . '_refund', $financeSn, $k + 1); - } - if (count($finance) > 0) { - $financialRecordRepository->insertAll($finance); + $financeDao->platformIn($item['number'], $item['financial_type'] . '_refund'); } + $financeDao->save(); $promotionCode = User::where('uid', $refundOrder['uid'])->value('promotion_code'); if ($promotionCode) {