From d4ac7912759a183b1b8aefc566b1399758623d3b Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Fri, 15 Mar 2024 16:34:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=8F=90=E7=8E=B0=E5=AF=86?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/model/system/merchant/Merchant.php | 5 +++ app/controller/api/Auth.php | 7 ++++ .../api/store/merchant/Merchant.php | 10 ++++- app/controller/api/user/User.php | 38 +++++++++++++++++++ route/api.php | 2 + 5 files changed, 61 insertions(+), 1 deletion(-) diff --git a/app/common/model/system/merchant/Merchant.php b/app/common/model/system/merchant/Merchant.php index 43c7c2af..48ccaec5 100644 --- a/app/common/model/system/merchant/Merchant.php +++ b/app/common/model/system/merchant/Merchant.php @@ -191,6 +191,11 @@ class Merchant extends BaseModel return $this->hasOne(MerchantType::class, 'mer_type_id', 'type_id'); } + public function user() + { + return $this->hasOne(User::class, 'uid', 'uid'); + } + public function typeName() { return $this->merchantType()->bind(['type_name']); diff --git a/app/controller/api/Auth.php b/app/controller/api/Auth.php index 7cf584f5..d888a167 100644 --- a/app/controller/api/Auth.php +++ b/app/controller/api/Auth.php @@ -211,6 +211,13 @@ class Auth extends BaseController }else{ $data['show_controller_applet']=false; } + //提现密码 + if($data['withdrawal_pwd']){ + $data['withdrawal_pwd'] = 1; + }else{ + $data['withdrawal_pwd'] = 0; + } + return app('json')->success($data); } diff --git a/app/controller/api/store/merchant/Merchant.php b/app/controller/api/store/merchant/Merchant.php index 3eb23a2c..7f38d8a3 100644 --- a/app/controller/api/store/merchant/Merchant.php +++ b/app/controller/api/store/merchant/Merchant.php @@ -144,7 +144,15 @@ class Merchant extends BaseController public function apply($merId) { - $merchant = app()->make(MerchantRepository::class)->search(['mer_id' => $merId])->field('uid,mer_id,mer_name,mer_money,financial_bank,financial_wechat,financial_alipay,financial_type,ot_margin')->find(); + $withdrawal_pwd = $this->request->param('withdrawal_pwd'); + if(empty($withdrawal_pwd)) return \app('json')->fail('请输入提现密码'); + //找到商户的密码 + $userInfo = \app\common\model\system\merchant\Merchant::getDB()->with('user')->where('mer_id',$merId)->find()->toArray(); + if (!password_verify($pwd = (string)$withdrawal_pwd, $userInfo['user']['withdrawal_pwd'])) + return app('json')->fail('提现密码错误'); + + + $merchant = app()->make(MerchantRepository::class)->search(['mer_id' => $merId])->field('uid,mer_id,mer_name,mer_money,financial_bank,financial_wechat,financial_alipay,financial_type,ot_margin')->find(); if (($msg = $this->checkAuth($merchant)) !== true) { return app('json')->fail($msg); } diff --git a/app/controller/api/user/User.php b/app/controller/api/user/User.php index 54f83a89..93d4bdb1 100644 --- a/app/controller/api/user/User.php +++ b/app/controller/api/user/User.php @@ -378,6 +378,44 @@ class User extends BaseController return app('json')->success('绑定成功'); } + //设置提现密码 + public function set_withdrawalPassword() + { + $data = $this->request->params([ 'password','repassword']); + if (empty($data['repassword']) || empty($data['password'])) + return app('json')->fail('请输入提现密码'); + if ($data['repassword'] !== $data['password']) + return app('json')->fail('两次密码不一致'); + $password = $this->repository->encodePassword($data['password']); + $this->repository->update($this->request->uid(), ['withdrawal_pwd' => $password]); + return app('json')->success('设置成功'); + } + + + //修改 + public function withdrawalPassword() + { + $data = $this->request->params(['repassword', 'password', 'sms_code']); + if (!$this->user->phone) + return app('json')->fail('请先绑定手机号'); + if (empty($data['repassword']) || empty($data['password'])) + return app('json')->fail('请输入提现密码'); + if ($data['repassword'] !== $data['password']) + return app('json')->fail('两次密码不一致'); + + $sms_code = app()->make(SmsService::class)->checkSmsCode($this->user->phone, $data['sms_code'], 'change_pwd'); + if (!$data['sms_code'] || !$sms_code) + return app('json')->fail('验证码不正确'); + + $password = $this->repository->encodePassword($data['password']); + + $this->repository->update($this->request->uid(), ['withdrawal_pwd' => $password]); + return app('json')->success('绑定成功'); + + } + + + public function changePhone() { $data = $this->request->params(['phone', 'sms_code']); diff --git a/route/api.php b/route/api.php index 3c34e37f..0091883e 100644 --- a/route/api.php +++ b/route/api.php @@ -122,6 +122,8 @@ Route::group('api/', function () { Route::post('change/info', 'User/updateBaseInfo'); Route::post('change/password', 'User/changePassword'); Route::post('change/bind_promotion_code', 'User/bindPromotionCode'); + Route::post('change/withdrawal_pwd', 'User/withdrawalPassword');//更改提现密码 + Route::post('set/withdrawal_pwd', 'User/set_withdrawalPassword');//设置提现密码 //收藏 Route::get('/relation/product/lst', 'UserRelation/productList'); Route::get('/relation/merchant/lst', 'UserRelation/merchantList');