From dcd4be4234d124c67760050482b8005235d9fe5b Mon Sep 17 00:00:00 2001 From: wuhui_zzw <1760308791@qq.com> Date: Wed, 3 Jan 2024 13:58:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9A=E4=BD=A3=E9=87=91?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=20-=20=E6=B7=BB=E5=8A=A0=E5=B7=B2=E9=80=80?= =?UTF-8?q?=E6=AC=BE=E4=BD=A3=E9=87=91=E5=A4=84=E7=90=86=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96=EF=BC=9A=E9=80=80=E6=AC=BE=E6=88=90=E5=8A=9F=20-=20?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E7=A7=AF=E5=88=86=E5=92=8C=E5=95=86=E6=88=B7?= =?UTF-8?q?=E7=A7=AF=E5=88=86=E7=9B=B8=E5=85=B3=E6=93=8D=E4=BD=9C=E9=9A=90?= =?UTF-8?q?=E8=97=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/dao/user/UserBillDao.php | 36 ++++++----- .../order/StoreRefundOrderRepository.php | 60 +++++++++---------- 2 files changed, 52 insertions(+), 44 deletions(-) diff --git a/app/common/dao/user/UserBillDao.php b/app/common/dao/user/UserBillDao.php index e5e3b80..b28a5a0 100644 --- a/app/common/dao/user/UserBillDao.php +++ b/app/common/dao/user/UserBillDao.php @@ -131,31 +131,39 @@ class UserBillDao extends BaseDao ->field('link_id,number') ->select() ->toArray(); - // if (count($lst)) { - // $refundPrice = -1 * UserBill::getDB()->whereIn('link_id', array_column($lst, 'link_id'))->where('uid', $uid) - // ->where('category', 'brokerage')->whereIn('type', ['refund_two', 'refund_one'])->sum('number'); - // } - foreach ($commissionList as $billTwo) { - $refundPrice = bcadd($refundPrice, $billTwo['number'], 2); + $commissionRefundPrice = 0; + if (count($lst)) { + $commissionRefundPrice = -1 * UserBill::getDB()->whereIn('link_id', array_column($lst, 'link_id'))->where('uid', $uid) + ->where('category', 'brokerage') + ->whereIn('type', ['commission_merchants', 'commission_promoter']) + ->sum('number'); + } + foreach ($commissionList as $billTwo) { + $commissionRefundPrice = bcadd($commissionRefundPrice, $billTwo['number'], 2); } - // 合伙人分红 - $commissionPartnerList = UserBill::getDB()->where('category', 'brokerage') + $commissionPartnerList = UserBill::getDB() + ->where('category', 'brokerage') ->whereIn('type', ['commission_partner']) ->where('uid', $uid) ->where('status', 0) ->field('link_id,number') ->select() ->toArray(); - // if (count($lst)) { - // $refundPrice = -1 * UserBill::getDB()->whereIn('link_id', array_column($lst, 'link_id'))->where('uid', $uid) - // ->where('category', 'brokerage')->whereIn('type', ['refund_two', 'refund_one'])->sum('number'); - // } + $commissionPartnerRefundPrice = 0; + if (count($lst)) { + $commissionPartnerRefundPrice = -1 * UserBill::getDB()->whereIn('link_id', array_column($lst, 'link_id')) + ->where('uid', $uid) + ->where('category', 'brokerage') + ->whereIn('type', ['commission_partner']) + ->sum('number'); + } foreach ($commissionPartnerList as $billThree) { - $refundPrice = bcadd($refundPrice, $billThree['number'], 2); + $commissionPartnerRefundPrice = bcadd($commissionPartnerRefundPrice, $billThree['number'], 2); } - return $refundPrice; + + return (float)sprintf("%.2f",(float)$refundPrice + (float)$commissionRefundPrice + (float)$commissionPartnerList); } public function lockIntegral($uid = null, $order_id = null) diff --git a/app/common/repositories/store/order/StoreRefundOrderRepository.php b/app/common/repositories/store/order/StoreRefundOrderRepository.php index 7066b99..a4d973d 100644 --- a/app/common/repositories/store/order/StoreRefundOrderRepository.php +++ b/app/common/repositories/store/order/StoreRefundOrderRepository.php @@ -1350,39 +1350,39 @@ class StoreRefundOrderRepository extends BaseRepository // $refundOrder->order // ],1)); if ($refundOrder->integral > 0) { - $make = app()->make(UserRepository::class); - $make->update($refundOrder->uid, ['integral' => Db::raw('integral+' . $refundOrder->integral)]); - $userIntegral = $make->get($refundOrder->uid)->integral; - $make1 = app()->make(UserBillRepository::class); + // $make = app()->make(UserRepository::class); + // $make->update($refundOrder->uid, ['integral' => Db::raw('integral+' . $refundOrder->integral)]); + // $userIntegral = $make->get($refundOrder->uid)->integral; + // $make1 = app()->make(UserBillRepository::class); // 判断:根据订单抵扣使用积分 退还平台积分或者商户积分 - if((float)$refundOrder->order->use_mer_integral > 0){ - // 使用的商户积分 - app()->make(IntegralRepository::class)->changeIntegral((int)$refundOrder->uid,(int)$refundOrder->mer_id,(float)sprintf('%.2f',$refundOrder->integral)); - $mark = '订单退款,返还积分抵扣使用的' . intval($refundOrder->integral) . '商户积分'; - }else{ - // 使用的平台积分 - app()->make(IntegralRepository::class)->changeIntegral((int)$refundOrder->uid,(int)0,(float)sprintf('%.2f',$refundOrder->integral)); - $mark = '订单退款,返还积分抵扣使用的' . intval($refundOrder->integral) . '平台积分'; - } + // if((float)$refundOrder->order->use_mer_integral > 0){ + // // 使用的商户积分 + // app()->make(IntegralRepository::class)->changeIntegral((int)$refundOrder->uid,(int)$refundOrder->mer_id,(float)sprintf('%.2f',$refundOrder->integral)); + // $mark = '订单退款,返还积分抵扣使用的' . intval($refundOrder->integral) . '商户积分'; + // }else{ + // // 使用的平台积分 + // app()->make(IntegralRepository::class)->changeIntegral((int)$refundOrder->uid,(int)0,(float)sprintf('%.2f',$refundOrder->integral)); + // $mark = '订单退款,返还积分抵扣使用的' . intval($refundOrder->integral) . '平台积分'; + // } - $make1->incBill($refundOrder->uid, 'integral', 'refund', [ - 'link_id' => $refundOrder->order_id, - 'status' => 1, - 'title' => '订单退款', - 'number' => $refundOrder->integral, - 'mark' => $mark, - 'balance' => $userIntegral - ]); - $make1->incBill($refundOrder->uid, 'mer_integral', 'refund', [ - 'link_id' => $refundOrder->order_id, - 'status' => 1, - 'title' => '订单退款', - 'number' => $refundOrder->integral, - 'mark' => $mark, - 'balance' => $userIntegral, - 'mer_id' => $refundOrder->mer_id - ]); + // $make1->incBill($refundOrder->uid, 'integral', 'refund', [ + // 'link_id' => $refundOrder->order_id, + // 'status' => 1, + // 'title' => '订单退款', + // 'number' => $refundOrder->integral, + // 'mark' => $mark, + // 'balance' => $userIntegral + // ]); + // $make1->incBill($refundOrder->uid, 'mer_integral', 'refund', [ + // 'link_id' => $refundOrder->order_id, + // 'status' => 1, + // 'title' => '订单退款', + // 'number' => $refundOrder->integral, + // 'mark' => $mark, + // 'balance' => $userIntegral, + // 'mer_id' => $refundOrder->mer_id + // ]); } //退还赠送积分