error('系统升级中...'); $phone = input('phone'); $ver_code = input('ver_code'); $password = input('password'); $confirm_password = input('confirm_password'); $second_password = input('second_password'); $confirm_second_password = input('confirm_second_password'); $invite_code = input('invite_code'); if (!$phone || !$ver_code || !$password || !$confirm_password || !$second_password || !$confirm_second_password){ $this->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('短信验证码不正确!'); // if ($ver_code!=='123456') $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('id',$invite_code)->find(); if (!$isset) $this->error('邀请码不存在'); }else{ $invite_code = 0; } //钱包地址 //$offlineaccount = getOfflineAccount(); // $address = json_decode($offlineaccount,true)['address']; // $laddress = getWalletAddress($phone,$address); // if ($laddress['code']==0){ // $wallet_address = $laddress['data']['opbChainClientAddress']; // } $data = [ 'phone'=>$phone, 'pid'=>$invite_code, 'password'=>md5($password), 'second_password'=>md5($second_password), //'wallet_address'=>$wallet_address, //'offline_account'=>$offlineaccount ]; $member_id = Db::name('store_member')->insertGetId($data); if ($member_id){ $invite_img = setintivecode($member_id); $invite_address = getintiveaddress($member_id); Db::name('store_member')->where('id',$member_id)->update(['name'=>'收藏家'.$member_id,'invite_img'=>$invite_img,'invite_address'=>$invite_address]); //邀请好友送积分 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:密码 * @return name:token type:string default:-- desc:用户登录成功后的token值 */ public function passwordLogin() { $phone = input('phone'); $password = input('password'); if (empty($password) || empty($phone)) { $this->error('参数错误'); } $member = Db::name('store_member') ->where('phone', $phone) ->where('is_deleted',0) ->find(); if (!$member) $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(['token'=>$token]); $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(){ // $redis = new Redis(); // $nonce = $redis->get('nonce'); // $url2 = "http://192.144.219.204:8083/ddc1155/balanceOf?ddcId=10962&nonce=$nonce&owner=0x38700ebb3c04dfb905c93bb2b3fbe06fea607fb0"; // $res2=curlRequest($url2); // echo $res2;die; $url2='http://192.144.219.204:8083/ddc/getNonce'; $nonce=curlRequest($url2); echo $nonce;die; $str=rand(100000000,999999999); $url2 = "http://192.144.219.204:8083/ddc1155/safeMint?amount=10&ddcURI=$str&nonce=$nonce&to=0xc472ec30ec813784b19872565e045c7153ea3f17"; $res2=curlRequest($url2); $url = 'http://192.144.219.204:8083/ddc/getTransactionReceipt?hash='.$res2; $res=curlRequest($url); echo $res;die; $result2 = json_decode($res2,true); set_time_limit(0); $url2='http://192.144.219.204:8083/ddc/getNonce'; $nonce=curlRequest($url2); echo $nonce;die; // $redis = new Redis(); //$redis->set('nonce',$nonce); die; $list = Db::name('test')->where('error',1)->select(); foreach ($list as &$v){ $url2 = 'http://192.144.219.204:8083/ddc/official?address='.$v['key']; $res2=curlRequest($url2); $result2 = json_decode($res2,true); if ($result2['code']=='-1'){ Db::name('test')->where('key',$v['key'])->update(['error'=>0]); }else if ($result2['code']==0){ Db::name('test')->where('key',$v['key'])->update(['error'=>2]); } } die; $url2 = 'http://192.144.219.204:8083/ddc/official?address=0xd257295e958a7000fa572e5f114d1cae2ea5a279'; $res2=curlRequest($url2); $result2 = json_decode($res2,true); print_r($result2);die; Db::name('store_order_info') ->whereNotNull('company_hash') ->whereIn('status','1') ->where('company_hash','neq','') ->where('collectors_hash','eq','') ->chunk('20',function ($list){ $from = '0xc472ec30ec813784b19872565e045c7153ea3f17'; foreach ($list as &$v){ echo $v['id']."
"; $url2='http://192.144.219.204:8083/ddc/getNonce'; $nonce=curlRequest($url2); if ($v['status']==1){ $mid = $v['mid']; }elseif ($v['status']==3){ $from = Db::name('store_member')->where('id',$v['to_mid'])->value('wallet_address'); $mid = $v['to_mid']; } $to = Db::name('store_member')->where('id',$mid)->value('wallet_address'); if (empty($to) || $to == ''){ continue; } //$ddcid = Db::name('hash')->where('hash',$v['company_hash'])->value('ddcid'); $ddcid = $v['ddcid']; $url = "http://192.144.219.204:8083/ddc/transfer?from=$from&to=$to&ddcid=$ddcid&nonce=".$nonce; $res=curlRequest($url); echo $res.'
'; $result=json_decode($res,true); if($result['code']){ continue; }else{ Db::name('store_order_info') ->where('id',$v['id']) ->update(['collectors_hash'=>$res,'collectors_hash_time'=>date('Y-m-d H:i:s')]); } } },'id','desc'); die(); $list = Db::name('store_order_info')->whereNull('ddcid')->select(); foreach ($list as &$v){ $hash = Db::name('hash')->where('goods_id',$v['c_id'])->where('success',1)->where('status',0)->order('id asc')->limit(1)->find(); $data = [ 'company_hash'=>$hash['hash'], 'ddcid'=>$hash['ddcid'] ]; Db::name('store_order_info') ->where('id',$v['id']) ->update($data); Db::name('hash')->where('hash',$hash['hash'])->update(['status'=>1]); } dump($list);die; $list = Db::name('store_order_info')->where('c_id',0)->select(); foreach ($list as &$v){ $info = json_decode($v['pro_info'],true); Db::name('store_order_info')->where('id',$v['id'])->update(['c_id'=>$info['id']]); } die; Db::name('store_order_info') ->whereNotNull('company_hash') ->where('id','10100') ->whereIn('status','1,3') ->where('company_hash','neq','') ->where('collectors_hash','eq','') ->chunk('20',function ($list){ $from = '0xc472ec30ec813784b19872565e045c7153ea3f17'; foreach ($list as &$v){ echo $v['id']."
"; $url2='http://192.144.219.204:8083/ddc/getNonce'; $nonce=curlRequest($url2); if ($v['status']==1){ $mid = $v['mid']; }elseif ($v['status']==3){ $from = Db::name('store_member')->where('id',$v['to_mid'])->value('wallet_address'); $mid = $v['to_mid']; } $to = Db::name('store_member')->where('id',$mid)->value('wallet_address'); if (empty($to) || $to == ''){ continue; } $ddcid =Db::name('hash')->where('hash',$v['company_hash'])->value('ddcid'); $url = "http://192.144.219.204:8083/ddc/transfer?from=$from&to=$to&ddcid=$ddcid&nonce=".$nonce; $res=curlRequest($url); echo $res.'
'; $result=json_decode($res,true); if($result['code']){ continue; }else{ Db::name('store_order_info')->where('id',$v['id'])->update(['collectors_hash'=>$res,'collectors_hash_time'=>date('Y-m-d H:i:s')]); } } },'id','asc'); die; $url = 'http://192.144.219.204:8083/ddc/getTransactionReceipt?hash=0x3b27b0941070a9aac74c6315700557da112793aaa095702bb8308652c226bf71'; $res=curlRequest($url); print_r($res);die; // $url = 'http://192.144.219.204:8083/ddc/status?address=0x3a1ca5e6fd0acfa43eeea3002cf4c72c86ad0d81'; // $res=curlRequest($url); // $result = json_decode($res,true); // dump($result); // die; // // $url = 'http://192.144.219.204:8083/ddc/official?address=0x65f71404c42565c736536ec1e1ab29859d67b9d8'; // $res=curlRequest($url); // $result = json_decode($res,true); // dump($result); // die; $list = Db::name('hash')->whereIn('id','4386')->select(); foreach ($list as &$v){ $url = 'http://192.144.219.204:8083/ddc/getTransactionReceipt?hash='.$v['hash']; $res=curlRequest($url); Db::name('hash')->where('id',$v['id'])->update(['result'=>$res]); $result3=json_decode($res,true); dump($result3); if (isset($result3['status']) && $result3['status']=='0x1'){ $url4='http://192.144.219.204:8083/ddc/createDdcid?hash='.$v['hash']; $ddcid=curlRequest($url4); echo 'ddcid:'.$ddcid."
"; $result4=json_decode($ddcid,true); if($result4['code']){ dump($result4); }else{ $update_data['ddcid'] = $ddcid; } Db::name('hash')->where('id',$v['id'])->update($update_data); } } die; // // $member = Db::name('store_member')->where('id','100040')->select(); // foreach ($member as &$v){ // if (empty($v['offline_account']) || $v['offline_account']==''){ // $offline_accounts = getOfflineAccount(); // $v['offline_account'] =$offline_accounts; // } // $offline_account = json_decode($v['offline_account'],true); // $address = $offline_account['address']; // $laddress = getWalletAddress($v['phone'].$v['id'],$address); // dump($laddress); //// if ($laddress['code']==0){ //// $wallet_address = $laddress['data']['opbChainClientAddress']; //// Db::name('store_member')->where('id',$v['id'])->update(['wallet_address'=>$wallet_address]); //// } // } // die; // $url3 = 'http://192.144.219.204:8083/ddc/getTransactionReceipt?hash=0x29dd82a90fe77dd4581ed0e95d50588a4a5dfd7a5625e5b3530819d5235aefdf'; // $res3=curlRequest($url3); // echo $res3; // die; // $list = Db::name('hash')->order('id desc')->limit(30)->select(); // foreach ($list as &$v){ // $url3 = 'http://192.144.219.204:8083/ddc/getTransactionReceipt?hash='.$v['hash']; // $res3=curlRequest($url3); // $result3=json_decode($res3,true); // if (isset($result3['status']) && $result3['status']=='0x1'){ // echo "创建成功".$v['hash']."
"; // }else{ // echo "创建失败".$v['hash']."
"; // } // } // die; // $url = 'http://192.144.219.204:8083/ddc/getNonce'; // $res=curlRequest($url); // print_r($res);die; //充值能量 // $rand = get_order_sn(); // $url = 'http://192.144.219.204:8083/ddc/rechargeGas?money=40&address=0x3fc6da539f8591250a2f989574646ab03cde7cba&transSn='.$rand; // $res=curlRequest($url); // print_r($res);die; //充值业务费 $rand = get_order_sn(); $url = 'http://192.144.219.204:8083/ddc/rechargeBusiness?money=30&address=0x3fc6da539f8591250a2f989574646ab03cde7cba&transSn='.$rand; $res=curlRequest($url); print_r($res);die; //传递ddcid $url2='http://192.144.219.204:8083/ddc/getNonce'; $nonce=curlRequest($url2); // $from = '0x8583c53ca3759f0893cb6c156b682e8fef22ed95'; // $to = '0xf52a94d36dc81d48eed46a23b5397f822df0118e'; $from = '0xf52a94d36dc81d48eed46a23b5397f822df0118e'; $to = '0xf12ef3091e3169f0b79d7d224f0ab7fa5916945f'; $ddcid ='10816'; $url = "http://192.144.219.204:8083/ddc/transfer?from=$from&to=$to&ddcid=$ddcid&nonce=".$nonce; $res=curlRequest($url); print_r($res);die; $url = 'http://192.144.219.204:8083/ddc/createAccount'; $result = file_get_contents($url); $result = json_decode($result,true); $name = rand(0,100); $url2 = "http://192.144.219.204:8083/ddc/createAddress?name=".$name."&account=".$result['address']; $res=curlRequest($url2); $result=json_decode($res,true); dump($result); } }