From 533a02806f6686f733ff47b173e6f72368927742 Mon Sep 17 00:00:00 2001 From: wucongxing8150 <815046773@qq.com> Date: Wed, 26 Jun 2024 09:02:37 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=8F=90=E7=8E=B0=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=20=E5=A2=9E=E5=8A=A0=E5=8F=AF=E6=8F=90=E7=8E=B0?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/DoctorAccountService.php | 40 +++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/app/Services/DoctorAccountService.php b/app/Services/DoctorAccountService.php index f1cb7c6..f7f4075 100644 --- a/app/Services/DoctorAccountService.php +++ b/app/Services/DoctorAccountService.php @@ -306,6 +306,45 @@ class DoctorAccountService extends BaseService $amount_total = floor($doctor_account['balance_account'] * 100) / 100; } + // 获取可提现订单列表 + $params = array(); + $params['doctor_id'] = $user_info['client_user_id']; + $params['is_withdrawal'] = 0; + + $orders = Order:: getDoctorWithdrawalOrderList($params, $user_doctor['is_platform_deep_cooperation']); + if (empty($orders)){ + // 无订单,账户余额强制赋0; + $amount_total = 0; + } + + $OrderService = new OrderService(); + + // 可提现金额 + $expected_amount_total = 0; + + // 订单号数据 + $order_nos = []; + + foreach ($orders as $order){ + // 获取订单退款金额 + $refund_total = $OrderService->getOrderRefundAmount($order['order_no']); + + // 获取订单可提现金额 + $expected_amount_total = bcadd( + $expected_amount_total, + $OrderService->getOrderWithdrawalAmount($order,$refund_total), + 2 + ); + + $order_nos[] = $order['order_no']; + } + + // 对比订单金额和账户金额;金额相差1元及以上返回错误 + $diff_amount_total = abs($amount_total - $expected_amount_total); + if ($diff_amount_total >= 1){ + return fail(HttpEnumCode::HTTP_ERROR, "提现金额错误"); + } + /* // 获取可提现订单列表 $orders = Order:: getDoctorWithdrawalOrderList($params, $user_doctor['is_platform_deep_cooperation'], ['*']); if (empty($orders)){ @@ -353,6 +392,7 @@ class DoctorAccountService extends BaseService $result['amount_total'] = $amount_total; // 账户余额 $result['withdrawal_amount'] = $withdrawal_amount; // 提现金额 $result['income_tax'] = $income_tax; // 个人所得税 + $result['order_nos'] = $order_nos; // 可提现订单号 return success($result); }