|
|
@@ -5,6 +5,7 @@
|
|
|
*------Dev Model Jions------
|
|
|
*------Create Time 2017-06-23 15:06:45------
|
|
|
*/
|
|
|
+
|
|
|
namespace App\InApi\Controller;
|
|
|
|
|
|
|
|
|
@@ -13,45 +14,50 @@ use Biz\Game\GameLogic;
|
|
|
use App\Commons\Model\Wagent;
|
|
|
|
|
|
|
|
|
-class Index extends Controller {
|
|
|
+class Index extends Controller
|
|
|
+{
|
|
|
//用户上传参数数组;
|
|
|
- private $paras = [] ;
|
|
|
+ private $paras = [];
|
|
|
private $parasString = '';
|
|
|
- private $userKey = '' ;
|
|
|
- private $model = null ;
|
|
|
- private $logic = null ;
|
|
|
+ private $userKey = '';
|
|
|
+ private $model = null;
|
|
|
+ private $logic = null;
|
|
|
|
|
|
//默认返回数据格式
|
|
|
- private $defformat = 'json' ;
|
|
|
+ private $defformat = 'json';
|
|
|
|
|
|
//所有请求入口
|
|
|
- public function dobusiness() {
|
|
|
- $this->doLogic();
|
|
|
- }
|
|
|
+ public function dobusiness()
|
|
|
+ {
|
|
|
+ $this->doLogic();
|
|
|
+ }
|
|
|
|
|
|
- public function getdata(){
|
|
|
+ public function getdata()
|
|
|
+ {
|
|
|
$this->doLogic();
|
|
|
}
|
|
|
|
|
|
|
|
|
- private function doLogic(){
|
|
|
+ private function doLogic()
|
|
|
+ {
|
|
|
$this->ParasCheck();
|
|
|
$this->AgentKeyCheck();
|
|
|
|
|
|
$method = $this->ActionMap()[$this->paras['method']];
|
|
|
- $this->logic = new GameLogic($this->paras,$this->userKey,$this->model);
|
|
|
+ $this->logic = new GameLogic($this->paras, $this->userKey, $this->model);
|
|
|
|
|
|
- if ( (new \ReflectionClass($this->logic))->hasMethod($method)){
|
|
|
+ if ((new \ReflectionClass($this->logic))->hasMethod($method)) {
|
|
|
$ret = $this->logic->$method();
|
|
|
- Render($ret['datas'],$ret['status'],$ret['msg']);
|
|
|
+ Render($ret['datas'], $ret['status'], $ret['msg']);
|
|
|
}
|
|
|
- Render('',10009,lang('Errors','Sports')->get('error-10009'));
|
|
|
+ Render('', 10009, lang('Errors', 'Sports')->get('error-10009'));
|
|
|
|
|
|
}
|
|
|
|
|
|
- private function ActionMap(){
|
|
|
- $maps = [
|
|
|
- 'caie' => 'CheckAccountIsExist',
|
|
|
+ private function ActionMap()
|
|
|
+ {
|
|
|
+ $maps = [
|
|
|
+ 'caie' => 'CheckAccountIsExist',
|
|
|
'caca' => 'CheckAndCreateAccount',
|
|
|
'gb' => 'GetBalance',
|
|
|
'ptc' => 'TransferCredit',
|
|
|
@@ -69,119 +75,124 @@ class Index extends Controller {
|
|
|
'gvvi' => 'GetVideoVendorId',
|
|
|
'gsvi' => 'GetSportVendorId',
|
|
|
'atin' => 'AutoLogin',
|
|
|
+ 'todaycr' => 'ConsumptionRanking',
|
|
|
];
|
|
|
- return $maps;
|
|
|
+ return $maps;
|
|
|
}
|
|
|
|
|
|
|
|
|
//输入参数校验
|
|
|
- private function ParasCheck(){
|
|
|
+ private function ParasCheck()
|
|
|
+ {
|
|
|
$this->parasString = $params = $_REQUEST['params'];
|
|
|
$this->userKey = $_REQUEST['Key'];
|
|
|
|
|
|
- $arr = explode('&',base64_decode($params));
|
|
|
+ $arr = explode('&', base64_decode($params));
|
|
|
|
|
|
- if (is_array($arr)){
|
|
|
- foreach ($arr as $substring){
|
|
|
- $tmp = explode("=",$substring);
|
|
|
- if (isset($tmp['0'])){
|
|
|
+ if (is_array($arr)) {
|
|
|
+ foreach ($arr as $substring) {
|
|
|
+ $tmp = explode("=", $substring);
|
|
|
+ if (isset($tmp['0'])) {
|
|
|
$tmpkey = strtolower(trim($tmp['0']));
|
|
|
- $val = isset($tmp['1']) ? trim($tmp['1']) : '' ;
|
|
|
+ $val = isset($tmp['1']) ? trim($tmp['1']) : '';
|
|
|
$this->paras[$tmpkey] = $val;
|
|
|
}
|
|
|
}
|
|
|
- }else{
|
|
|
- Render('',10010,lang('Errors','Sports')->get('error-10009'));
|
|
|
+ } else {
|
|
|
+ Render('', 10010, lang('Errors', 'Sports')->get('error-10009'));
|
|
|
}
|
|
|
|
|
|
$allmap = $this->ActionMap();
|
|
|
$method = isset($this->paras['method']) ? $this->paras['method'] : '';
|
|
|
|
|
|
- if (!isset( $allmap[$method] )){
|
|
|
- Render('',10011,lang('Errors','Sports')->get('error-10009'));
|
|
|
+ if (!isset($allmap[$method])) {
|
|
|
+ Render('', 10011, lang('Errors', 'Sports')->get('error-10009'));
|
|
|
}
|
|
|
|
|
|
- $format = isset($this->paras['format'] ) ? strtolower(trim($this->paras['format'])) : '';
|
|
|
- if ($format =='' || !in_array($format,['json','xml'])){ $format = $this->defformat; }
|
|
|
- S('CUR_RETURN_FORMAT',$format);
|
|
|
+ $format = isset($this->paras['format']) ? strtolower(trim($this->paras['format'])) : '';
|
|
|
+ if ($format == '' || !in_array($format, ['json', 'xml'])) {
|
|
|
+ $format = $this->defformat;
|
|
|
+ }
|
|
|
+ S('CUR_RETURN_FORMAT', $format);
|
|
|
}
|
|
|
|
|
|
//Key验证
|
|
|
- private function AgentKeyCheck(){
|
|
|
- $agent = isset($this->paras['agent']) ? trim($this->paras['agent']) : '' ;
|
|
|
- if (empty($agent)){
|
|
|
- Render('key_error',0,'key_error');
|
|
|
+ private function AgentKeyCheck()
|
|
|
+ {
|
|
|
+ $agent = isset($this->paras['agent']) ? trim($this->paras['agent']) : '';
|
|
|
+ if (empty($agent)) {
|
|
|
+ Render('key_error', 0, 'key_error');
|
|
|
}
|
|
|
|
|
|
$model = (new Wagent)->getByName($agent);
|
|
|
- if (empty($model)){
|
|
|
- Render('10',0,'The agent not exist');
|
|
|
+ if (empty($model)) {
|
|
|
+ Render('10', 0, 'The agent not exist');
|
|
|
}
|
|
|
- $ret = $model->CheckKey($model,$this->parasString,$this->userKey) ;
|
|
|
- if ( $ret!=1 ){
|
|
|
- if ($ret == -1){
|
|
|
- Render('10',2,'Token overTime,please Refresh!');
|
|
|
+ $ret = $model->CheckKey($model, $this->parasString, $this->userKey);
|
|
|
+ if ($ret != 1) {
|
|
|
+ if ($ret == -1) {
|
|
|
+ Render('10', 2, 'Token overTime,please Refresh!');
|
|
|
}
|
|
|
- Render('10',0,'key check error!-'.$ret);
|
|
|
+ Render('10', 0, 'key check error!-' . $ret);
|
|
|
}
|
|
|
|
|
|
- $this->model = $model ;
|
|
|
- return true;
|
|
|
+ $this->model = $model;
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
|
|
|
//调试地址生成用
|
|
|
- public function makeurl(){
|
|
|
+ public function makeurl()
|
|
|
+ {
|
|
|
|
|
|
$remotip = $_SERVER['REMOTE_ADDR'];
|
|
|
- if (!($remotip =='127.0.0.1' || substr($remotip,0,7) == '192.168')){
|
|
|
+ if (!($remotip == '127.0.0.1' || substr($remotip, 0, 7) == '192.168')) {
|
|
|
//只能在内网调试使用
|
|
|
exit;
|
|
|
}
|
|
|
|
|
|
- $paras = $_REQUEST;
|
|
|
- unset($paras['_url']);
|
|
|
- if (empty($paras)){
|
|
|
- exit ;
|
|
|
+ $paras = $_REQUEST;
|
|
|
+ unset($paras['_url']);
|
|
|
+ if (empty($paras)) {
|
|
|
+ exit;
|
|
|
}
|
|
|
|
|
|
- $strArr = array() ;
|
|
|
- foreach ($paras as $key=>$val){
|
|
|
+ $strArr = array();
|
|
|
+ foreach ($paras as $key => $val) {
|
|
|
//if ($key=='agent'){ $val = 'test1agent' ; }
|
|
|
- array_push($strArr,$key.'='.$val);
|
|
|
+ array_push($strArr, $key . '=' . $val);
|
|
|
}
|
|
|
- $string = implode ('&',$strArr);
|
|
|
- $key = md5(base64_encode($string).'58f306c11e6a9d4cc74723bb76b17500');
|
|
|
+ $string = implode('&', $strArr);
|
|
|
+ $key = md5(base64_encode($string) . '58f306c11e6a9d4cc74723bb76b17500');
|
|
|
|
|
|
- if (isset($_REQUEST['debug'])){
|
|
|
+ if (isset($_REQUEST['debug'])) {
|
|
|
$host = $_SERVER['HTTP_HOST'];
|
|
|
- $url = 'http://' . $host . '/InApi-index/dobusiness?params='.base64_encode($string).'&Key='.$key;
|
|
|
- }else{
|
|
|
- $url = 'http://sports.5gogo.com/InApi-index/dobusiness?params='.base64_encode($string).'&Key='.$key;
|
|
|
+ $url = 'http://' . $host . '/InApi-index/dobusiness?params=' . base64_encode($string) . '&Key=' . $key;
|
|
|
+ } else {
|
|
|
+ $url = 'http://sports.5gogo.com/InApi-index/dobusiness?params=' . base64_encode($string) . '&Key=' . $key;
|
|
|
}
|
|
|
|
|
|
- Render(['url'=>$url],1,'success');
|
|
|
+ Render(['url' => $url], 1, 'success');
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
//客户获取token用于 Key 的生成使用
|
|
|
- public function getToken(){
|
|
|
+ public function getToken()
|
|
|
+ {
|
|
|
|
|
|
- $agengname = $_POST['wagent_name'] ;
|
|
|
- $key = $_POST['wagent_key'] ;
|
|
|
- $secret = $_POST['wagent_secret'] ;
|
|
|
+ $agengname = $_POST['wagent_name'];
|
|
|
+ $key = $_POST['wagent_key'];
|
|
|
+ $secret = $_POST['wagent_secret'];
|
|
|
|
|
|
- $model = (new Wagent)->TokenGetAndUpdate($agengname,$key,$secret);
|
|
|
- if (!$model){
|
|
|
- Render('',3,'get Token false!');
|
|
|
- }
|
|
|
+ $model = (new Wagent)->TokenGetAndUpdate($agengname, $key, $secret);
|
|
|
+ if (!$model) {
|
|
|
+ Render('', 3, 'get Token false!');
|
|
|
+ }
|
|
|
|
|
|
- Render(['token'=>$model->auth_token],1,'success');
|
|
|
+ Render(['token' => $model->auth_token], 1, 'success');
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
}
|