From 097964d352cdf088887cc821406016774303d914 Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Sat, 3 Feb 2024 13:39:14 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E8=AF=95=E4=BE=9B=E5=BA=94=E9=93=BE?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E9=80=80=E6=AC=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/dao/store/consumption/CommissionDao.php | 14 +++++++++----- .../store/consumption/StoreConsumptionUserDao.php | 9 +++++---- .../store/order/StoreRefundOrderRepository.php | 10 ---------- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/app/common/dao/store/consumption/CommissionDao.php b/app/common/dao/store/consumption/CommissionDao.php index 9fd8e872..a243c3f8 100755 --- a/app/common/dao/store/consumption/CommissionDao.php +++ b/app/common/dao/store/consumption/CommissionDao.php @@ -162,15 +162,17 @@ class CommissionDao if ($refunded > 0) { return; } - // 退佣金和红包 + // 退佣金和红包、保证金 $financeRecord = FinancialRecord::where('order_id', $refundOrder->order['order_id']) - ->whereIn('financial_type', ['commission_to_store', 'commission_to_courier', 'commission_to_promoter']) + ->whereIn('financial_type', ['commission_to_store', 'commission_to_courier', 'commission_to_promoter', 'auto_margin']) ->field('user_id uid,user_info nickname,number,mer_id,financial_type')->select()->toArray(); if (empty($financeRecord)) { return; } + $userIds = []; $financeDao = new FinancialDao(); foreach ($financeRecord as $item) { + $userIds[] = $item['uid']; $financeDao->user = $item; $financeDao->order = $refundOrder->order; $financeDao->platformIn($item['number'], $item['financial_type'] . '_refund', $item['mer_id']); @@ -180,9 +182,11 @@ class CommissionDao } $financeDao->save(); - // TODO 服务团队退红包 -// $redPacks = UserBill::whereIn(''); -// (new StoreConsumptionUserDao())->refundByCommission($item['uid'], $refundOrder->order->order_id, $redPack); + // 服务团队退红包 + $redPacks = UserBill::whereIn('uid', $userIds)->where('extra->order_id',$refundOrder->order['order_id'])->select()->toArray(); + foreach ($redPacks as $redPack) { + (new StoreConsumptionUserDao())->refundByCommission($redPack['uid'], $refundOrder->order['order_id'], $redPack['number']); + } $promotionCode = User::where('uid', $refundOrder['uid'])->value('promotion_code'); if ($promotionCode) { diff --git a/app/common/dao/store/consumption/StoreConsumptionUserDao.php b/app/common/dao/store/consumption/StoreConsumptionUserDao.php index 4e8f83ed..fe245447 100755 --- a/app/common/dao/store/consumption/StoreConsumptionUserDao.php +++ b/app/common/dao/store/consumption/StoreConsumptionUserDao.php @@ -256,18 +256,19 @@ class StoreConsumptionUserDao extends BaseDao // 写入红包日志 /** @var $userBillRepository UserBillRepository */ $userBillRepository = app()->make(UserBillRepository::class); - $mark = ['order_amount' => $amount, 'coupon_user_id' => $model['coupon_user_id']]; + $extra = ['order_amount' => $amount, 'coupon_user_id' => $model['coupon_user_id']]; if ($this->orderType == 2) { - $mark['order_id'] = $groupOrderIds; + $extra['order_id'] = $groupOrderIds; } else { - $mark['group_order_id'] = $groupOrderIds; + $extra['group_order_id'] = $groupOrderIds; } $userBillRepository->incBill($userId, 'red_pack', "red_pack_{$type}", [ 'link_id' => $model['coupon_user_id'], 'status' => 1, 'title' => '获得' . $title, 'number' => $couponPrice, - 'mark' => json_encode($mark, JSON_UNESCAPED_UNICODE), + 'mark' => '获得' . $title . $couponPrice . ",订单金额:{$amount}", + 'extra' => json_encode($extra, JSON_UNESCAPED_UNICODE), 'balance' => 0 ]); } diff --git a/app/common/repositories/store/order/StoreRefundOrderRepository.php b/app/common/repositories/store/order/StoreRefundOrderRepository.php index d459aab6..57167173 100755 --- a/app/common/repositories/store/order/StoreRefundOrderRepository.php +++ b/app/common/repositories/store/order/StoreRefundOrderRepository.php @@ -1210,16 +1210,6 @@ class StoreRefundOrderRepository extends BaseRepository ->whereIn('product_id', $productIds) ->whereIn('activity_id', 2) ->update(['status' => 0]); - - app()->make(FinancialRecordRepository::class)->dec([ - 'order_id' => $refundOrder->refund_order_id, - 'order_sn' => $refundOrder->refund_order_sn, - 'user_info' => $refundOrder->user->nickname, - 'user_id' => $refundOrder->uid, - 'financial_type' => 'refund_order', - 'type' => 1, - 'number' => $refundOrder->refund_price, - ], $refundOrder->mer_id); } public function getRefundMerPrice(StoreRefundOrder $refundOrder, $refundPrice = null)