From 358dfe078bb6c70702089612be8cb1451e16b0e0 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 23 May 2024 11:57:11 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E6=9B=B4=E6=96=B0=20UserWithdrawControlle?= =?UTF-8?q?r.php=20=E6=96=87=E4=BB=B6=EF=BC=8C=E4=BC=98=E5=8C=96=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=8F=90=E7=8E=B0=E9=80=BB=E8=BE=91=E3=80=82=202.=20?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=20MerchantLogic.php=20=E6=96=87=E4=BB=B6?= =?UTF-8?q?=EF=BC=8C=E4=BC=98=E5=8C=96=E5=95=86=E6=88=B7=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/user/UserWithdrawController.php | 7 ++++--- app/api/logic/merchant/MerchantLogic.php | 13 +++++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/api/controller/user/UserWithdrawController.php b/app/api/controller/user/UserWithdrawController.php index ca00a35..e9e64ca 100644 --- a/app/api/controller/user/UserWithdrawController.php +++ b/app/api/controller/user/UserWithdrawController.php @@ -56,10 +56,9 @@ class UserWithdrawController extends BaseApiController public function withdraw() { $params = (new MerchantWithdrawValidate())->post()->goCheck('withdraw'); - // $uid = $this->request->userInfo['user_id']; + $uid = $this->request->userId; // $merchant = Merchant::where('uid',$uid)->findOrEmpty(); - // $supplier = Supplier::where('uid',$uid)->findOrEmpty(); - $supplier = $this->request->userInfo['supplier']; + $supplier = Supplier::where('uid',$uid)->findOrEmpty(); if (!$supplier) { return $this->fail('当前用户非供应商'); } @@ -94,6 +93,8 @@ class UserWithdrawController extends BaseApiController 'admin_id' => 0, 'create_time' => time(), ]; + $supplier->mer_money =bcsub($supplier->mer_money, $params['amount'], 2); + $supplier->save(); (new MerchantWithdraw)->save($save_data); return $this->success('提现成功,等待管理员审核'); // }else{ diff --git a/app/api/logic/merchant/MerchantLogic.php b/app/api/logic/merchant/MerchantLogic.php index cba738b..b1a71ab 100644 --- a/app/api/logic/merchant/MerchantLogic.php +++ b/app/api/logic/merchant/MerchantLogic.php @@ -19,14 +19,17 @@ class MerchantLogic extends BaseLogic public static function amount_account($merchant) { try { - + $mer_money = Merchant::where('mer_id', $merchant['mer_id'])->value('mer_money'); $bank_list = MerchantBank::where('mer_id', $merchant['mer_id'])->where('is_check', 1)->select()->each(function ($data) { $bank_info = Bank::where('id', $data['bank_id'])->findOrEmpty(); $data['bank_name'] = !$bank_info->isEmpty() ? $bank_info['name'] : ''; $data['bank_image'] = !$bank_info->isEmpty() ? $bank_info['image'] : ''; return $data; })->toArray(); - return $bank_list; + return [ + 'balance' => $mer_money, + 'bank_list' => $bank_list + ]; } catch (\Exception $e) { self::setError($e->getMessage()); return false; @@ -53,6 +56,8 @@ class MerchantLogic extends BaseLogic 'admin_id' => 0, 'create_time' => time(), ]; + $merchant->mer_money =bcsub($merchant->mer_money, $params['amount'], 2); + $merchant->save(); (new MerchantWithdraw)->save($save_data); return true; } catch (\Exception $e) { @@ -64,7 +69,8 @@ class MerchantLogic extends BaseLogic /** * 提现信息 */ - public static function taking_info($merchant){ + public static function taking_info($merchant) + { try { $total_amount = MerchantWithdraw::where('mer_id', $merchant['mer_id'])->where('is_check', 1)->where('is_arrival', 1)->sum('amount'); $count = MerchantWithdraw::where('mer_id', $merchant['mer_id'])->where('is_check', 1)->where('is_arrival', 1)->count(); @@ -73,6 +79,5 @@ class MerchantLogic extends BaseLogic self::setError($e->getMessage()); return false; } - } }