Browse Source

调通体育平台接口

jekon 6 years ago
parent
commit
c96df72f4a

+ 11 - 9
app/Http/Appadapter/Adapter.php

@@ -16,17 +16,18 @@ class Adapter
      * @return array
      */
     public function syncUser($appid, $appUsername , $password){
-        return array('code' => 1, 'msg'=>'');
+        //return array('code' => 1, 'msg'=>'');
 
         $result = array('code'=>-1, 'msg'=>'');
         if($appid == 1){//体育
-            $config = ['name' => 'agentname', 'key' => 'agentkey', 'secret' => 'agentsecret'];
+            //$config = ['name' => 'dttes', 'key' => 'bf1f3678d5408390feb7a6ec2f014198', 'secret' => 'e2cd20b1ea965a6dac93c312a930436e'];
             $proxy = new Sport();
-            $proxy->Init($config);
+            $proxy->Init();
             $ret = $proxy->caca($appUsername, $password);
-            if($ret['key_error'] == 1){
+            $ret = json_decode($ret, true);
+            if($ret['status'] == 1){
                 $result = array('code'=>1, 'msg'=>'成功');
-            }elseif ($ret['key_error'] == 3){
+            }elseif ($ret['data'] == 3){
                 $result = array('code'=>-3, 'msg'=>'用户名太长');
             }else{
                 $result = array('code'=>-1, 'msg'=>'服务器繁忙');
@@ -34,7 +35,6 @@ class Adapter
         }else{
             $result = array('code'=>-100, 'msg'=>'应用不存在');
         }
-
         return $result;
     }
 
@@ -48,17 +48,19 @@ class Adapter
      * @return array
      */
     public function login($appid, $appUsername , $password, $money, $billno=''){
-        return array('code' => 1, 'msg'=>'成功');
+        //return array('code' => 1, 'msg'=>'成功');
 
         $result = array('code'=>-2, 'msg'=>'', 'data'=>array());
         if($appid == 1){//体育
-            $config = ['name' => 'agentname', 'key' => 'agentkey', 'secret' => 'agentsecret'];
             $proxy = new Sport();
-            $proxy->Init($config);
+            $proxy->Init();
             $ret = $proxy->tg($appUsername, $password);
+            //'{"status":1,"msg":"登录成功","data":{"ret":0,"tokenold":"UUaCai15678500915d737e6b2bd90","token":"%7B%22img_url%22%3Anull%2C%22name%22%3A%22dttes_t1_jekonefs_a1%22%2C%22token%22%3A%22UUaCai15678500915d737e6b2bd90%22%2C%22cash%22%3A%220.00%22%7D","url":"http:\/\/sports.bocai108.com\/m\/jump.html?token=%7B%22img_url%22%3Anull%2C%22name%22%3A%22dttes_t1_jekonefs_a1%22%2C%22token%22%3A%22UUaCai15678500915d737e6b2bd90%22%2C%22cash%22%3A%220.00%22%7D"}}'
+            $ret = json_decode($ret, true);
             if($ret['status'] == 1){
                 //转账
                 $ret2 = $proxy->ptc($appUsername, $password, $billno, $money, 'IN');
+                $ret2 = json_decode($ret2, true);
                 if($ret2['status'] == 1){
                     $result = array('code'=>1, 'msg'=>'成功', 'data'=>$ret['data']);
                 }else{

+ 11 - 7
app/Http/Appadapter/Sport.php

@@ -10,7 +10,11 @@ class Sport
     private $token = '';
     private $cacheFile = '';
     private $domain = 'http://sports.bocai108.com';
-    private $configs = [];
+    private $configs = [
+        'name' => 'dttes',
+        'key' => 'bf1f3678d5408390feb7a6ec2f014198',
+        'secret' => 'e2cd20b1ea965a6dac93c312a930436e'
+    ];
 
 
     public function setCacheFile($file = '')
@@ -138,11 +142,11 @@ class Sport
     //配置
     public function setConfigs(Array $config)
     {
-        $name = isset($config['name']) ? $config['name'] : '';
-        $key = isset($config['key']) ? $config['key'] : '';
-        $secret = isset($config['secret']) ? $config['secret'] : '';
-        $domain = isset($config['domain']) ? $config['domain'] : '';
-        $cachefile = isset($config['cachefile']) ? $config['cachefile'] : '';
+        $name = isset($config['name']) ? $config['name'] : $this->configs['name'];
+        $key = isset($config['key']) ? $config['key'] : $this->configs['key'];
+        $secret = isset($config['secret']) ? $config['secret'] : $this->configs['secret'];
+        $domain = isset($config['domain']) ? $config['domain'] : $this->domain;
+        $cachefile = isset($config['cachefile']) ? $config['cachefile'] : $this->cacheFile;
 
         if (empty($name) || empty($key) || empty($secret)) {
             throw  new  \Exception('初始化参数错误,name,key,secret不能为空', 1002);
@@ -182,7 +186,7 @@ class Sport
     }
 
     //初始化操作
-    public function Init($config)
+    public function Init($config = array())
     {
         $this->setConfigs($config);
         if ($this->getToken()) {

+ 1 - 0
app/Http/Controllers/Api/PartyController.php

@@ -165,6 +165,7 @@ class PartyController extends Controller
             $this->logger->addWarning('login out: 成功,$appResult:'.json_encode($appResult));
             return toJson($code, $msg, $appResult);
         } catch (Exception $e) {
+            $this->logger->addWarning('login out: -200 操作失败,err:'.json_encode($e));
             return toJson($code, $msg, []);
         }