zhangxiaobin 1 rok pred
rodič
commit
3152b0ee56

+ 2 - 1
addons/qcloudsms/config.php

@@ -101,7 +101,8 @@ return [
             'resetpwd' => '1844866',
             'changepwd' => '1844866',
             'profile' => '1844866',
-            'changepaypwd' => '1844866',
+            'editpaypwd' => '1844866',
+            'forgetpaypwd' => '1844866',
             'default' => '1844866',
         ],
         'rule' => 'required',

+ 2 - 1
application/api/controller/Usersign.php

@@ -111,7 +111,8 @@ class Usersign extends Api
         }
         //第七天赠送礼物
         $gift = [];
-        if ($data['times'] == 7) {
+        $sendGift = config('site.sign_gift');
+        if ($data['times'] == 7 && $sendGift == '1') {
             $userSignGift = model('UserSignGift')->with(['gift'])->find();
             if (!empty($userSignGift)) {
                 $giftData = isset($userSignGift['gift']) ? $userSignGift['gift'] : [];

+ 119 - 0
application/api/controller/Withdraw.php

@@ -4,6 +4,7 @@ namespace app\api\controller;
 
 use app\common\library\Sms;
 use app\api\controller\Common;
+use fast\Random;
 use think\Db;
 use think\Exception;
 use think\Validate;
@@ -328,4 +329,122 @@ class Withdraw extends Common
             $this->error("没有查询到用户信息!请前往app注册!");
         }
     }
+    public function getEncryptPassword($password, $salt = '')
+    {
+        return md5(md5($password) . $salt);
+    }
+
+    /**
+     * 设置交易密码
+     * @return void
+     */
+    public function setPaypwd()
+    {
+        try {
+            $userId = $this->auth->id;
+            $payPwd = $this->request->param('pay_pwd','');
+            $confirmPwd = $this->request->param('confirm_pay_pwd','');
+            if (empty($payPwd) || empty($confirmPwd)) {
+                throw new Exception('参数错误');
+            }
+            if ($payPwd != $confirmPwd) {
+                throw new Exception('密码不一致');
+            }
+            $paySalt = Random::alnum();
+            $payPassword = $this->getEncryptPassword($payPwd,$paySalt);
+            $where['id'] = $userId;
+            $user = model('User')->where($where)->find();
+            if (empty($user)) {
+                throw new Exception('未知的用户');
+            }
+            $user->pay_password = $payPassword;
+            $user->pay_salt = $paySalt;
+            $res = $user->save();
+            if (!$res) {
+                throw new Exception('设置失败');
+            }
+            $this->success('设置成功');
+        } catch (Exception $e) {
+            $this->error($e->getMessage());
+        }
+    }
+
+    /**
+     * 修改交易密码
+     * @return void
+     */
+    public function editPaypwd()
+    {
+        try {
+            $userId = $this->auth->id;
+            $oldPayPwd = $this->request->param('old_pay_pwd','');
+            $payPwd = $this->request->param('pay_pwd','');
+            $confirmPwd = $this->request->param('confirm_pay_pwd','');
+            if (empty($oldPayPwd) || empty($payPwd) || empty($confirmPwd)) {
+                throw new Exception('参数错误');
+            }
+            if ($payPwd != $confirmPwd) {
+                throw new Exception('密码不一致');
+            }
+            $where['id'] = $userId;
+            $user = model('User')->where($where)->find();
+            if (empty($user)) {
+                throw new Exception('未知的用户');
+            }
+            $userPaySalt = $user['pay_salt'];
+            $userPayPassword = $this->getEncryptPassword($oldPayPwd,$userPaySalt);
+            if ($userPayPassword != $user['pay_password']) {
+                throw new Exception('旧密码错误');
+            }
+            $paySalt = Random::alnum();
+            $payPassword = $this->getEncryptPassword($payPwd,$paySalt);
+
+            $user->pay_password = $payPassword;
+            $user->pay_salt = $paySalt;
+            $res = $user->save();
+            if (!$res) {
+                throw new Exception('设置失败');
+            }
+            $this->success('设置成功');
+        } catch (Exception $e) {
+            $this->error($e->getMessage());
+        }
+    }
+    
+    /**
+     * 验证改密码
+     * @return void
+     */
+    public function checkSms()
+    {
+        try {
+            $mobile = $this->request->param('mobile','');
+            $code = $this->request->param('code','');
+            //$event = $this->request->param('event','');//事件editpaypwd=修改支付密码,forgetpaypwd=忘记支付密码
+            if (empty($mobile) || empty($code)) {
+                throw new Exception('参数错误');
+            }
+            $userMobile = $this->auth->mobile;
+            if (empty($userMobile)) {
+                throw new Exception('绑定手机号');
+            }
+            if ($mobile != $userMobile) {
+                throw new Exception('手机号与绑定不一致');
+            }
+            //$where['event'] = $event;
+            $where['mobile'] = $mobile;
+            $where['code'] = $code;
+            $sms = model('Sms')->where($where)->find();
+            if (empty($sms)) {
+                throw new Exception('验证码错误');
+            }
+            $createtime = $sms['createtime'] - (60 * 2);
+            if ($sms['createtime'] < $createtime) {
+                throw new Exception('验证已过期,请重新获取。');
+            }
+            $this->success('验证成功');
+        } catch (Exception $e) {
+            $this->error($e->getMessage());
+        }
+    }
 }

+ 1 - 0
application/extra/site.php

@@ -111,4 +111,5 @@ return [
     'domain_name' => 'http://ggyuyin.huxiukeji.cn',
     'intro_image' => '/uploads/20230703/35b10db56529aa19086eeb3d1d0bb6b0.png',
     'egggift_content' => '<p>我是奖励概览</p>',
+    'sign_gift' => '1',
 ];