paras = $paras; $this->userKey = $userKey; $this->wagetnModel = $wagentModel ; } //返回数据 private function makeret($status=1,$msg='success',$datas=[]){ return [ 'status'=>$status, 'msg'=>$msg, 'datas'=>$datas ]; } //CheckAccountIsExist(账户是否存在) public function CheckAccountIsExist(){ $username= isset($this->paras['username']) ? trim($this->paras['username']) : ''; if (empty($username)){ return $this->makeret(0,'请求参数缺失','key_error'); } $username = $this->wagetnModel->agent_pre.$username; $ac = new AccountManager(); $ret = $ac->getAccount($username); if ($ret){ return $this->makeret(1,'success',1); }else{ return $this->makeret(1,'success',0); } } //CheckAndCreateAccount(检测并创建游戏帐户) public function CheckAndCreateAccount(){ $username = isset($this->paras['username']) ? trim($this->paras['username']) : ''; $password = isset($this->paras['password']) ? trim($this->paras['password']) : '' ; $remark = [ 'moneysort'=>'', 'limitvideo'=>0, 'limitroulette'=>0, ]; $remark['moneysort'] = isset($this->paras['moneysort']) ? trim($this->paras['moneysort']) : '' ; $remark['limitvideo'] = isset($this->paras['limitvideo']) ? intval($this->paras['limitvideo']) : 0; $remark['limitroulette'] = isset($this->paras['limitroulette']) ? intval($this->paras['limitroulette']) : 0 ; $remark = json_encode($remark); if (empty($username) || empty($password) ){ return $this->makeret(0,'请求参数缺失','key_error'); } $username = $this->wagetnModel->agent_pre.$username; $ac = new AccountManager(); $userInfo = $ac->getAccount($username); if ($userInfo){ return $this->makeret(1,'success','1'); } if (!$this->nameCheck($username)){ return $this->makeret(0,'false',3); } if (!$this->passCheck($password)){ return $this->makeret(0,'false',2); } $wagent_name = isset($this->paras['agent']) ? $this->paras['agent'] : ''; $postdatas = [ 'account' => $username, 'password' => $password, 'again_password' => $password, 'name' => $username, 'phone' => uniqid('agent_'), 'remark' => $remark, 'wagent_name' => $wagent_name, ]; $ac = new AccountManager(); $ret = $ac->register($postdatas); if (isset($ret['status']) && $ret['status']==1){ return $this->makeret(1,'success','1'); }else{ $errormsg = isset($ret['msg']) ? $ret['msg'] : 'false' ; return $this->makeret(0,$errormsg,'0'); } } private function nameCheck($name){ if (mb_strlen($name) >= 32){ return false; } return true; } private function passCheck($pass){ $skip = ['\'','"','\\','/','>','<','&','#','--','%','?','$',' '] ; foreach ($skip as $val){ if ( stripos($pass,$val) !== false ){ return false; } } return true; } //GetBalance(查询余额) public function GetBalance(){ $accountModel= $this->accountAndPassCheck(); $account_identity = $accountModel->account_indentity; $parentinfo = lm('account_detailed', 'commons')->where('account_identity', $account_identity)->first(); if (empty($parentinfo)) { return $this->makeret(1,'账号记录不存在','0'); } return $this->makeret(1,'success',$parentinfo->cash) ; } public function accountAndPassCheck(){ $username= isset($this->paras['username']) ? trim($this->paras['username']) : ''; $password = isset($this->paras['password']) ? trim($this->paras['password']) : ''; if (empty($username) || empty($password) ){ $ret = $this->makeret(0,'请求参数缺失','key_error'); Render($ret['datas'],$ret['status'],$ret['msg']); } $username = $this->wagetnModel->agent_pre.$username; $ac = new AccountManager(); $account = $ac->getAccount($username); if (!$account){ $ret = $this->makeret(0,'账号不存在','account_no_exist'); Render($ret['datas'],$ret['status'],$ret['msg']); } $account_identity = $account->identity; $passCheckret = VerPassword($account_identity,$password); if (!$passCheckret){ $ret = $this->makeret(0,'密码有误','key_error'); Render($ret['datas'],$ret['status'],$ret['msg']); } return $account ; } //TransferCredit(转帐) public function TransferCredit(){ $accountModel = $this->accountAndPassCheck(); if ($accountModel->status !=1){ $ret = $this->makeret(0,'false','userStatus false!') ; return $ret; } $type = isset($this->paras['type']) ? strtoupper(trim($this->paras['type'])) : ''; if (!in_array( $type , ['IN','OUT'])){ return $this->makeret(0,'type error!','type error'); } $credit = isset($this->paras['credit']) ? floatval(trim($this->paras['credit'])) : 0; if ( $credit <=0 ){ return $this->makeret(0,'credit error','credit error'); } $billno = isset($this->paras['billno']) ? strtoupper(trim($this->paras['billno'])) : ''; if (empty($billno)){ return $this->makeret(0,'billno empty','billno empty'); } $transferModel = new Money_transfer(); $hasexit = $transferModel->findOneByAttr('billno',$billno); if ( $hasexit ){ return $this->makeret(0,'billno exists','billno exists'); } $parentinfo = lm('account_detailed', 'commons')->where('account_identity', $accountModel->account_identity)->first(); if (empty($parentinfo)) { return $this->makeret(1,'account_detailed not exists','0'); } $cash = $parentinfo->cash ; if ( $type == 'OUT' && $cash<$credit ){ return $this->makeret(0,'no_enough_credit','no_enough_credit'); } $transferModel->account_indent = $accountModel->identity; $transferModel->ordernumber = OrderID('transfer_') ; $transferModel->billno = $billno; $transferModel->tradeamount = $credit ; $transferModel->blance = ($type == 'IN') ? $cash + $credit : $cash - $credit ; $transferModel->type = $type ; $transferModel->tradtype = ($type == 'IN') ? 8 : 9 ; $transferModel->tfrom = 0 ; $transferModel->tto = 0 ; $transferModel->agent_name = $this->wagetnModel->agent_name ; $ret = $transferModel->save(); if ($ret){ $ret = $this->makeret(1,'success',1) ; return $ret; }else{ $ret = $this->makeret(0,'false',0) ; return $ret; } } //ConfirmTransferCredit(查询转帐) public function ConfirmTransferCredit(){ $ret = $this->makeret() ; return $ret; } //TransferGame(进入游戏) public function TransferGame(){ $ret = $this->makeret() ; return $ret; } //GetReport(获取报表数据) public function GetReport(){ $ret = $this->makeret() ; return $ret; } // GetCashTrade(转帐记录) public function GetCashTrade(){ $ret = $this->makeret() ; return $ret; } //GetBettingRecordByVendor(真人游戏记录) public function GetBettingRecordByVendor(){ $ret = $this->makeret() ; return $ret; } //GetSportsBettingRecordByVendor(体育投注记录) public function GetSportsBettingRecordByVendor(){ $ret = $this->makeret() ; return $ret; } //GetEleBettingRecord(电子投注记录) public function GetEleBettingRecord(){ $ret = $this->makeret() ; return $ret; } //GetFishBettingRecord(捕鱼王投注记录) public function GetFishBettingRecord(){ $ret = $this->makeret() ; return $ret; } //GetLotteryBettingRecord(彩票投注记录) public function GetLotteryBettingRecord(){ $ret = $this->makeret() ; return $ret; } //GetGameResult(游戏结果记录) public function GetGameResult(){ $ret = $this->makeret() ; return $ret; } //UpdateAccount(帐户密码更改) public function UpdateAccount(){ $username = isset($this->paras['username']) ? trim($this->paras['username']) : ''; $password = isset($this->paras['password']) ? trim($this->paras['password']) : '' ; if (empty($username) || empty($password) ){ return $this->makeret(0,'请求参数缺失','key_error'); } $username = $this->wagetnModel->agent_pre.$username; $ac = new AccountManager(); $userInfo = $ac->getAccount($username); if (!$userInfo){ return $this->makeret(0,'false','key_error'); } if ($userInfo->status != 1){ return $this->makeret(0,'用户状态不正确','key_error'); } $pwdData = GenPassword($password); $passdatas = [ 'account_password'=>$pwdData['password'], "encryption" => $pwdData['encryption'], ]; $ret = lm('account_password', 'Commons')->where('account_identity',$userInfo->identity)->update($passdatas); if ($ret ){ $ret = $this->makeret(1,'success',1) ; }else{ $ret = $this->makeret(0,'false',0) ; } return $ret; } //GetSportVendorId(获取体育VendorId) public function GetSportVendorId(){ $ret = $this->makeret() ; return $ret; } }