error('参数错误'); } if (!Validate::regex($phone, "^1\d{10}$")) { $this->error('手机号格式错误'); } //验证短信验证码 $time = time()-60; $sms = Db::name('store_sms')->where(['mobile' => $phone, 'event' => 'register']) ->where('createtime','>',$time) ->order('id', 'DESC') ->find(); if (!$sms || $sms['code'] != $ver_code) $this->error('短信验证码不正确!'); $user = Db::name('store_member') ->where('is_deleted',0) ->where('phone',$phone) ->find(); if ($user) $this->error('手机号已注册'); // if (!preg_match('/^[0-9a-z]{6,12}$/i',$password)) $this->error('密码格式错误,请输入6-12位数字+字母'); // if ($password!=$confirm_password) $this->error('密码与确认密码不一致'); if (!preg_match('/^[0-9]{6}$/i',$second_password)) $this->error('二级密码格式错误,请输入6位纯数字'); if ($second_password!=$confirm_second_password) $this->error('二级密码与确认密码不一致'); if ($invite_code){ $isset = Db::name('store_member')->where('is_deleted',0)->where('invite_code',$invite_code)->find(); if (!$isset) $this->error('邀请码不存在'); $invitecode = $isset['id']; }else{ $invitecode = 0; } $wallet_address = ''; $accountName = ''; $data = [ 'phone'=>$phone, 'pid'=>$invitecode, //'password'=>md5($password), 'second_password'=>md5($second_password), 'wallet_address'=>$wallet_address, 'accountName'=>$accountName, 'reg_ip'=>request()->ip() ]; $member_id = Db::name('store_member')->insertGetId($data); if ($member_id){ $code = get32Str(8); $invite_img = setintivecode($code); $invite_address = getintiveaddress($code); Db::name('store_member')->where('id',$member_id)->update(['name'=>'收藏者'.$member_id,'invite_img'=>$invite_img,'invite_address'=>$invite_address,'invite_code'=>$code]); //邀请好友送积分 if ($invite_code>0){ $invite_friends_integral = getConfigValue('invite_friends_integral'); memberMoneyChange($invite_friends_integral,1,$invite_code,'邀请好友',1,$member_id); } $this->success('注册成功'); } $this->error('注册失败'); } /** * @title 登录 * @desc 登录 * @url /api/Login/passwordLogin * @method POST * @tag 基础 * @header * @param name:phone type:int require:1 default:-- desc:手机号 * @param name:password type:string require:1 default:-- desc:密码 * @param name:ver_code type:string require:1 desc:验证码 * @return name:token type:string default:-- desc:用户登录成功后的token值 */ public function passwordLogin() { $phone = input('phone'); // $password = input('password'); $ver_code = input('ver_code'); if (empty($ver_code) || empty($phone)) { $this->error('参数错误'); } $member = Db::name('store_member') ->where('phone', $phone) ->where('is_deleted',0) ->find(); if (!$member) $this->error('手机号未注册'); //验证短信验证码 if ($phone!='15801075991'){ $time = time()-60; $sms = Db::name('store_sms')->where(['mobile' => $phone, 'event' => 'login']) ->where('createtime','>',$time) ->order('id', 'DESC') ->find(); if (!$sms || $sms['code'] != $ver_code) $this->error('短信验证码不正确!'); } // if ($member['password']!=md5($password)) $this->error('密码错误'); $token = self::create_jwt($member['id']); setMemberInfoHash($member['id']); Db::name('store_member')->where('id',$member['id'])->update(['ip'=>request()->ip()]); LoginLog($member['id']); $this->success('登录成功', $token); } //token加密 public function create_jwt($uid) { $key = md5(config('app.jwt')); //jwt的签发密钥,验证token的时候需要用到 $time = time(); //签发时间 $expire = $time + config('app.jwt_time'); //过期时间 $token = array( "uid" => $uid, "iss" => "https://zain.com",//签发组织 "aud" => "https://zain.com", //签发作者 "iat" => $time, "nbf" => $time, "exp" => $expire ); $jwt = JWT::encode($token, $key); return $jwt; } /** * @title 找回密码 * @desc 找回密码 * @url /api/Login/ForgetPassword * @method POST * @tag 基础 * @header * @param name:phone type:int require:1 default:-- desc:手机号 * @param name:ver_code type:string require:1 desc:验证码 * @param name:password type:string require:1 default:-- desc:密码 * @param name:confirm_password type:string require:1 desc:确认密码 */ public function ForgetPassword(){ $phone = input('phone'); $ver_code = input('ver_code'); $password = input('password'); $confirm_password = input('confirm_password'); if (!$phone || !$ver_code || !$password || !$confirm_password) $this->error('参数错误'); $member = Db::name('store_member') ->where('phone', $phone) ->where('is_deleted',0) ->find(); if (!$member) $this->error('手机号未注册'); //验证短信验证码 $time = time()-60; $sms = Db::name('store_sms')->where(['mobile' => $phone, 'event' => 'forgetpwd']) ->where('createtime','>',$time) ->order('id', 'DESC') ->find(); if (!$sms || $sms['code'] != $ver_code) $this->error('短信验证码不正确!'); if (!preg_match('/^[0-9a-z]{6,12}$/i',$password)) $this->error('密码格式错误,请输入6-12位数字+字母'); if ($password!=$confirm_password) $this->error('密码与确认密码不一致'); $data = [ 'password'=>md5($password), 'update_at'=>date('Y-m-d H:i:s') ]; if (Db::name('store_member')->where('id',$member['id'])->update($data)) $this->success('修改成功'); $this->error('修改失败'); } public function test(){ //获取奖励列表 $ids = Db::name('store_collection') ->where('is_deleted',0) ->where('pull_new',1) ->column('id'); dump($ids); if ($ids){ $array = []; foreach ($ids as &$v){ $now_inventory = getCollectionInventory($v); if ($now_inventory>0){ array_push($array,$v); } } if ($array){ $id = array_rand($array); echo $array[$id]; } } dump($array);die; die; $callback_url = 'http://'.$_SERVER['SERVER_NAME'].'/pages/mine/order-list?num=1'; $huiju = new HuijuH5Pay(); $notify_url = 'http://'.$_SERVER['SERVER_NAME'].'/index.php/api/Pay/ylOrderNotify';//回调地址 $huiju->ylh5Pay(get_order_sn(),$callback_url,$notify_url,"测试藏品","0.01",'100000',1); //$huiju = new HuijuKjPay(); //$huiju->sms(); //$huiju->signing(); // $huiju->kuaijiePay(); die; require_once env('root_path').'application/common/library/lib/YopRequest.php'; require_once env('root_path').'application/common/library/lib/YopClient3.php'; require_once env('root_path').'application/common/library/lib/YopRsaClient.php'; $private_key ="MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCSBUBO99o0ZCGp8/6qbaSW2MIeHKg/4RZEIexS11rW5wxFH9arHM16yZXObtm1qO1xNnRyofBkKvcOes63yNGqiulDjJbx2gxXzQdq6g0ckO06YZsb6v4AmkCLwu/kFPYTd2zu3nM6VCBsppkjXe2kcdgeKH55PSqTLcqe4TCeCQxxTjmixX/qFdKva7uJxXbdNjE+GERMTPsn9FBGjrv2/6RCz62eZljRcQf2zY9aooXnYaYOOkeYxJaFu4M8k1kEfL/A2ftDGa+9zyWUUp/PskIcSUCLtdd+yR1ZvNldBW7iaeTuZ4YQXg6N3BqFBacBmkHztpqbrg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shvGzAkzZaMBR6Xf1d//cuIWzU1bO7pkCQogq9MXv9hCZx2N1B51VSvwazJ6B029uzgYzr0iTeZBfB5ntb53/vEycLMhB9r9Bc+0x7bxrQZeWNwLlQFxhDeSO9le0ETjfGPt/nS2QbFL7bNHwRGE+AzxwH0aA=="; $request = new \YopRequest("app_10086863938", $private_key); $request->addParam('requestNo',get_order_sn()); $request->addParam('parentMerchantNo','10086863938'); $request->addParam('merchantNo','10086863938'); $request->addParam('name','宋星伟'); $request->addParam('cardNo','371324199210037710'); $request->addParam('cardType','ID'); $request->addParam('returnUrl','https://'.$_SERVER['SERVER_NAME'].'/web/h5/pages/mine/order-list?num=1'); $request->addParam('notifyUrl','https://'.$_SERVER['SERVER_NAME'].'/api/Pay/re'); $response = \YopRsaClient::post("/rest/v1.0/auth/face-auth", $request); dump(json_decode(json_encode($response,true),true)); die; // require_once env('root_path').'application/common/library/lib/YopRequest.php'; // require_once env('root_path').'application/common/library/lib/YopClient3.php'; // require_once env('root_path').'application/common/library/lib/YopRsaClient.php'; // $private_key ="MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCSBUBO99o0ZCGp8/6qbaSW2MIeHKg/4RZEIexS11rW5wxFH9arHM16yZXObtm1qO1xNnRyofBkKvcOes63yNGqiulDjJbx2gxXzQdq6g0ckO06YZsb6v4AmkCLwu/kFPYTd2zu3nM6VCBsppkjXe2kcdgeKH55PSqTLcqe4TCeCQxxTjmixX/qFdKva7uJxXbdNjE+GERMTPsn9FBGjrv2/6RCz62eZljRcQf2zY9aooXnYaYOOkeYxJaFu4M8k1kEfL/A2ftDGa+9zyWUUp/PskIcSUCLtdd+yR1ZvNldBW7iaeTuZ4YQXg6N3BqFBacBmkHztpqbrg1+C46Hp9C5AgMBAAECggEAHxpGPevWSzWO5BwIQTYUilsGUhKpld20d/O/2k9r1n2lY+3ptE3wyLg6lBuRfPvMA8LlH+u1gCiUsj1fXc9FNa3cDNrb5g0bdvJBo7jR7SVD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t/nS2QbFL7bNHwRGE+AzxwH0aA=="; // $request = new \YopRequest("app_10086863938", $private_key); // $request->addFile("merQual", "C:\Users\xk\Pictures\΢�Ž�ͼ_20220316150041.png"); // $response = \YopRsaClient::upload("/yos/v1.0/sys/merchant/qual/upload", $request); // dump($response); } }