Browse Source

代理接口

jekon 6 years ago
parent
commit
35fc619b34
52 changed files with 818 additions and 2124 deletions
  1. 75 0
      app/Http/Appadapter/Adapter.php
  2. 297 0
      app/Http/Appadapter/Sport.php
  3. 0 14
      app/Http/Controllers/Api/AgentController.php
  4. 204 0
      app/Http/Controllers/Api/PartyController.php
  5. 0 103
      app/Http/Controllers/Api/ReliefController.php
  6. 0 243
      app/Http/Controllers/Api/SignController.php
  7. 25 0
      app/Http/Controllers/Controller.php
  8. 0 52
      app/Http/Controllers/Sys/ActivityController.php
  9. 99 0
      app/Http/Controllers/Sys/AppController.php
  10. 0 25
      app/Http/Controllers/Sys/MenuController.php
  11. 0 43
      app/Http/Controllers/Sys/RankController.php
  12. 0 130
      app/Http/Controllers/Sys/UserController.php
  13. 21 11
      app/Http/Middleware/authJWT.php
  14. 0 93
      app/Http/Models/Activity.php
  15. 0 68
      app/Http/Models/AgentCash.php
  16. 14 0
      app/Http/Models/App.php
  17. 14 0
      app/Http/Models/AppUser.php
  18. 14 0
      app/Http/Models/BalanceLog.php
  19. 0 128
      app/Http/Models/Common.php
  20. 0 138
      app/Http/Models/GameMoney.php
  21. 0 42
      app/Http/Models/GameUrlData.php
  22. 14 0
      app/Http/Models/Party.php
  23. 14 0
      app/Http/Models/PartyUser.php
  24. 0 134
      app/Http/Models/ReliefData.php
  25. 0 314
      app/Http/Models/SportsAgent.php
  26. 0 128
      app/Http/Models/UserInfo.php
  27. 0 16
      app/Models/Activity.php
  28. 0 17
      app/Models/Advert.php
  29. 12 0
      app/Models/App.php
  30. 0 24
      app/Models/Article.php
  31. 0 29
      app/Models/Category.php
  32. 0 11
      app/Models/District.php
  33. 0 16
      app/Models/GameMoney.php
  34. 0 16
      app/Models/GameUrl.php
  35. 0 16
      app/Models/GetRelief.php
  36. 0 16
      app/Models/GetSign.php
  37. 0 17
      app/Models/Gmenu.php
  38. 0 17
      app/Models/Icon.php
  39. 0 17
      app/Models/Message.php
  40. 0 23
      app/Models/MoneyDetails.php
  41. 0 14
      app/Models/Notice.php
  42. 12 0
      app/Models/Party.php
  43. 0 20
      app/Models/Permission.php
  44. 0 16
      app/Models/Position.php
  45. 0 7
      app/Models/Role.php
  46. 0 17
      app/Models/Sign.php
  47. 0 11
      app/Models/Site.php
  48. 0 16
      app/Models/Systemconfig.php
  49. 0 17
      app/Models/Tag.php
  50. 0 84
      app/Vendor/Jwt.php
  51. 1 0
      routes/api.php
  52. 2 21
      routes/web.php

+ 75 - 0
app/Http/Appadapter/Adapter.php

@@ -0,0 +1,75 @@
+<?php
+
+namespace App\Http\Appadapter;
+
+/**
+* 适配器(基类)
+*/
+class Adapter
+{
+
+    /**
+     * 检测内容方是否存在该用户,不存在则创建
+     * @param $appid
+     * @param $appUsername
+     * @param $password
+     * @return array
+     */
+    public function syncUser($appid, $appUsername , $password){
+        return array('code' => 1, 'msg'=>'');
+
+        $result = array('code'=>-1, 'msg'=>'');
+        if($appid == 1){//体育
+            $config = ['name' => 'agentname', 'key' => 'agentkey', 'secret' => 'agentsecret'];
+            $proxy = new Sport();
+            $proxy->Init($config);
+            $ret = $proxy->caca($appUsername, $password);
+            if($ret['key_error'] == 1){
+                $result = array('code'=>1, 'msg'=>'成功');
+            }elseif ($ret['key_error'] == 3){
+                $result = array('code'=>-3, 'msg'=>'用户名太长');
+            }else{
+                $result = array('code'=>-1, 'msg'=>'服务器繁忙');
+            }
+        }else{
+            $result = array('code'=>-100, 'msg'=>'应用不存在');
+        }
+
+        return $result;
+    }
+
+    /**
+     * 登陆游戏
+     * @param $appid
+     * @param $appUsername
+     * @param $password
+     * @param $money
+     * @return array
+     */
+    public function login($appid, $appUsername , $password, $money){
+        return array('code' => 1, 'msg'=>'成功');
+
+        $result = array('code'=>-2, 'msg'=>'');
+        if($appid == 1){//体育
+            $config = ['name' => 'agentname', 'key' => 'agentkey', 'secret' => 'agentsecret'];
+            $proxy = new Sport();
+            $proxy->Init($config);
+            $ret = $proxy->tg($appUsername, $password);
+            if($ret['key_error'] == 1){
+                //转账
+                $ret2 = $proxy->ptc($appUsername, $password, '', $money, 'IN');
+                if($ret2['key_error'] != 1){
+                    $result = array('code'=>1, 'msg'=>'成功');
+                }else{
+                    $result = array('code'=>-1, 'msg'=>'服务器繁忙');
+                }
+            }else{
+                $result = array('code'=>-1, 'msg'=>'服务器繁忙');
+            }
+        }else{
+            $result = array('code'=>-100, 'msg'=>'应用不存在');
+        }
+
+        return $result;
+    }
+}

+ 297 - 0
app/Http/Appadapter/Sport.php

@@ -0,0 +1,297 @@
+<?php
+
+namespace App\Http\Appadapter;
+
+/**
+ * 体育内容模型类
+ */
+class Sport
+{
+    private $token = '';
+    private $cacheFile = '';
+    private $domain = 'http://sports.bocai108.com';
+    private $configs = [];
+
+
+    public function setCacheFile($file = '')
+    {
+        if (empty($file)) {
+            $file = __DIR__ . DIRECTORY_SEPARATOR . 'token.cache';
+        }
+        $this->cacheFile = $file;
+    }
+
+    public function getCacheFile()
+    {
+        if (empty($this->cacheFile)) {
+            $this->cacheFile = __DIR__ . DIRECTORY_SEPARATOR . 'token.cache';
+        }
+        return $this->cacheFile;
+    }
+
+    //写入本地缓存 注意目录和文件要有与入权根
+    public function writeTokenCache($array)
+    {
+        $ret = file_put_contents($this->cacheFile, json_encode($array, 256));
+        if (!$ret) {
+            throw  new  \Exception("缓存文件写入失败,请检查文件写入权限", 1005);
+        }
+        return $ret;
+    }
+
+    //读取本地缓存
+    public function readTokenCache()
+    {
+        if (!file_exists($this->cacheFile)) {
+            return false;
+        }
+        $ret = file_get_contents($this->cacheFile);
+        if ($ret) {
+            return $ret;
+        } else {
+            return false;
+        }
+    }
+
+    //请求 url地址get时可以带参数  ,param为post提交的参数数组    isPost是否是post方式提交,默认为get
+    function request_post($url = '', $param = '', $isPost = 0)
+    {
+        if (empty($url)) {
+            return false;
+        }
+
+        if ($isPost && empty($param)) {
+            return false;
+        }
+
+        $postUrl = $url;
+        $curlPost = $param;
+        $ch = curl_init();//初始化curl
+        if (!$isPost && $param) {
+            $postUrl = $postUrl . '?' . $param;
+        }
+        curl_setopt($ch, CURLOPT_URL, $postUrl);//抓取指定网页
+        curl_setopt($ch, CURLOPT_HEADER, 0);//设置header
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上
+        if ($isPost) {
+            curl_setopt($ch, CURLOPT_POST, 1);//post提交方式
+            curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
+        }
+        $data = curl_exec($ch);//运行curl
+        curl_close($ch);
+
+        return $data;
+    }
+
+
+    //获取token
+    protected function getToken()
+    {
+        $cacheData = json_decode($this->readTokenCache(), true);
+        if ($cacheData && isset($cacheData['ctime']) && isset($cacheData['token']) && isset($cacheData['domain'])) {
+            $ctime = intval($cacheData['ctime']);
+            $token = $cacheData['token'];
+            $domain = $this->domain = $cacheData['domain'];
+
+            if ((time() - $ctime) >= 24 * 60 * 60 - 300) {
+                $token = '';
+            }
+
+            if ($token) {
+                $this->domain = $domain;
+                $this->token = $token;
+                return $token;
+            }
+        }
+        return false;
+    }
+
+    //刷新token值
+    public function refreshTokenData($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'] : '';
+
+        if (empty($name) || empty($key) || empty($secret) || empty($domain)) {
+            throw new  \Exception('require params error!', 1000);
+        }
+
+        $url = $domain . '/InApi-index/getToken';
+        $tokenTmp = $this->request_post($url, ['wagent_name' => $name, 'wagent_key' => $key, 'wagent_secret' => $secret], 1);
+
+        if ($tokenTmp) {
+            $tokenData = json_decode($tokenTmp, true);
+
+            if (isset($tokenData['status']) && $tokenData['status'] == 1 && isset($tokenData['data']['token']) && ($tokenData['data']['token'] != '')) {
+                $this->writeTokenCache(['ctime' => time(), 'token' => $tokenData['data']['token'], 'domain' => $domain]);
+                $this->token = $tokenData['data']['token'];
+                return $tokenData['data']['token'];
+            } else {
+                return $tokenTmp;
+            }
+        }
+        throw new  \Exception('get Token False', 1001);
+    }
+
+    //配置
+    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'] : '';
+
+        if (empty($name) || empty($key) || empty($secret)) {
+            throw  new  \Exception('初始化参数错误,name,key,secret不能为空', 1002);
+        }
+
+        if (empty($domain)) {
+            $domain = $this->domain;
+        }
+
+        $this->configs = ['name' => $name, 'key' => $key, 'secret' => $secret, 'domain' => $domain];
+        $this->setCacheFile($cachefile);
+
+        return true;
+    }
+
+    //生成带验证的请求url
+    public function makeUrl(String $route, Array $paraArray, $arrayRet = 0)
+    {
+        $str = '';
+        foreach ($paraArray as $nkey => $val) {
+            $str .= "&" . $nkey . '=' . $val;
+        }
+        $param = base64_encode(substr($str, 1));
+        if (empty($this->token)) {
+            throw  new  \Exception("token 不能为空!", 1007);
+        }
+
+        $Key = md5($param . $this->token);
+
+        if ($arrayRet) {
+            return ['url' => $this->domain . $route, 'param' => $param, 'key' => $Key];
+        }
+
+        $url = $this->domain . $route . '?params=' . $param . '&Key=' . $Key;
+
+        return $url;
+    }
+
+    //初始化操作
+    public function Init($config)
+    {
+        $this->setConfigs($config);
+        if ($this->getToken()) {
+            return true;
+        }
+
+        $this->refreshTokenData($this->configs);
+        return true;
+    }
+
+    //抽象公共请求方法[一定得带上method参数]
+    public function commfun(Array $datas, $isPost = 0)
+    {
+        if (!isset($datas['method'])) {
+            throw  new  \Exception("modthod参数缺失", 1006);
+        }
+        $arrcomm = ['agent' => $this->configs['name'], 'method' => $datas['method']];
+        unset ($datas['method']);
+        $urlData = $this->makeUrl('/InApi-index/dobusiness', array_merge($datas, $arrcomm), $isPost);
+
+        if ($isPost) {
+            $ret = $this->request_post($urlData['url'], ['params' => $urlData['param'], 'Key' => $urlData['key']], 1);
+        } else {
+            $ret = $this->request_post($urlData);
+        }
+
+        return $ret;
+    }
+
+    /////////////////////////////////////以下为具体业务逻辑
+    //请在调用以下方法前,调用 Init方法作初始化操作
+
+    //2.1检测账户是否存在
+    public function caie($name)
+    {
+        return $this->commfun(['method' => 'caie', 'username' => $name]);
+    }
+
+    //2.2 检测并创建账号
+    public function caca($name, $pass)
+    {
+        return $this->commfun(['method' => 'caca', 'username' => $name, 'password' => $pass]);
+    }
+
+    ///2.3用户查询余额
+    public function gb($name, $pass)
+    {
+        return $this->commfun(['method' => 'gb', 'username' => $name, 'password' => $pass]);
+    }
+
+    ///2.4用户密码更改  (用post方法提交的例子,注意参数格式)
+    public function ua($name, $pass)
+    {
+        return $this->commfun(['method' => 'ua', 'username' => $name, 'password' => $pass], 1);
+    }
+
+    ///2.5 代理转给用户或用户转回代理
+    public function ptc($name, $pass, $billno, $credit, $type)
+    {
+        return $this->commfun(['method' => 'ptc', 'username' => $name, 'password' => $pass, 'billno' => $billno, 'credit' => $credit, 'type' => $type], 1);
+    }
+
+    ///2.6  代理转给用户或用户转回代理的转账查询
+    public function ctc($name, $pass, $billno, $type)
+    {
+        return $this->commfun(['method' => 'ctc', 'username' => $name, 'password' => $pass, 'billno' => $billno, 'type' => $type]);
+    }
+
+    //2.7 按订单查询转账信息
+    public function gct($billno)
+    {
+        return $this->commfun(['method' => 'gct', 'billno' => $billno]);
+    }
+
+    //2.8 用户进入游戏
+    public function tg($name, $pass, $gametype = 2, $domain = '', $gamekind = 0, $iframe = '0', $platformname = '', $lang = 'zh')
+    {
+        return $this->commfun(['method' => 'tg', 'username' => $name, 'password' => $pass, 'gametype' => $gametype, 'domain' => $domain, 'gamekind' => $gamekind, 'iframe' => $iframe, 'platformname' => $platformname, 'lang' => $lang], 1);
+    }
+
+    //2.9 获取报表数据
+    public function gr($name, $pass, $datestart, $dateend)
+    {
+        return $this->commfun(['method' => 'tg', 'username' => $name, 'password' => $pass, 'datestart' => $datestart, 'dateend' => $dateend]);
+    }
+
+    // 2.10 获取用户的体育投注数据
+    public function gsbrbv($billno, $isjs)
+    {
+        return $this->commfun(['method' => 'gsbrbv', 'vendorid' => $billno, 'isjs' => $isjs]);
+    }
+
+    // 3.1 获取用户当天赚钱排行榜 (30分钟缓存)
+    public function todaycr()
+    {
+        return $this->commfun(['method' => 'todaycr']);
+    }
+
+
+    //...............
+}
+
+/**
+ * 使用例子
+ * // $config = ['name' => 'agentname', 'key' => 'agentkey', 'secret' => 'agentsecret', 'domain' => 'http://sports.bocai108.com', 'cachefile' => '/tmp/t234asfasf212128233333.cache'];
+ * $config = ['name' => 'agentname', 'key' => 'agentkey', 'secret' => 'agentsecret'];
+ * $proxy = new WagentProxy();
+ * $proxy->Init($config);
+ * $ret1 = $proxy->ua('onmygod', '123456789');
+ *
+ * print_r($ret1);
+ */

+ 0 - 14
app/Http/Controllers/Api/AgentController.php

@@ -21,20 +21,6 @@ class AgentController extends Controller
      * @return array JsonString
      */
     public function __construct() {
-        $code = -2;
-        $msg = '操作失败';
-        try {
-            // 获取Token url及参数.
-            $gmenuId = 7;
-            $sportsAgentModel = new Models\SportsAgent;
-            $backData = $sportsAgentModel->getSportsToken($gmenuId);
-            if ($backData !== 1) {
-                $msg = '链接失败';
-                return toJson($code, $msg, []);
-            }
-        } catch (Exception $e) {
-            return toJson($code, $msg, []);
-        }
 
     }
 

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

@@ -0,0 +1,204 @@
+<?php
+
+namespace App\Http\Controllers\Api;
+
+use App\Http\Appadapter\Adapter;
+use Illuminate\Http\Request;
+use App\Http\Controllers\Controller;
+use \App\Http\Models;
+use Illuminate\Support\Facades\DB;
+use \Exception;
+
+/**
+ * 第三方管理类
+ */
+class PartyController extends Controller
+{
+
+    /**
+     * 构造函数
+     *
+     * @access public
+     * @param mixed $req 数据传输
+     * @return array JsonString
+     */
+    public function __construct() {
+
+    }
+
+
+    /**
+     * 第三方账号登陆、注册
+     *
+     * @access public
+     * @param mixed $req 数据传输
+     * @return array JsonString
+     */
+    public function login(Request $req)
+    {
+        $code = -200;
+        $msg = '操作失败';
+        try {
+            $check = $this->checkLoginArg($req);
+            if($check['code'] != 1){
+                return toJson($check['code'], $check['msg'], []);
+            }
+
+            $partyModel = new Models\Party;
+            $key = $req->input('key');
+            $appid = $req->input('appid');
+            $partyUserName = $req->input('username');
+            //$partyInfo = \App\Models\Party::where('key', $key)->first();
+            $partyInfo = $partyModel->where('key', $key)->first();
+
+            $money = $req->input('money');
+            if($partyInfo['balance'] < $money){
+                return toJson(-100, '您的余额不足', []);
+            }
+
+            $appModel = new Models\App;
+            $appInfo = $appModel->where('id', $appid)->first();
+            if($appInfo['balance'] < $money){
+                return toJson(-101, '系统繁忙,请稍后重试', []); //我的余额不足
+            }
+
+            //查询该用户是否已在系统
+            $partyUserModel = new Models\PartyUser();
+            $partyUserInfo = $partyUserModel->where([
+                ['party_id', '=', $partyInfo['id']],
+                ['party_username', '=', $partyUserName],
+            ])->first();
+            if(empty($partyUserInfo)){
+                $partyUserModel->insert([
+                    'party_id' => $partyInfo['id'],
+                    'party_username' => $partyUserName,
+                    'password' => $req->input('password'),
+                    'login_time' => now(),
+                    'login_ip' => $this->get_real_ip(),
+                    //'ctime' =>now()
+                ]);
+            }else{
+                $partyUserModel->where('id', $partyUserInfo['id'])->update([
+                    'login_time' => now(),
+                    'login_ip' => $this->get_real_ip(),
+                ]);
+            }
+
+            $adapter = new Adapter();
+            //查询是否已创建对于应用的用户
+            $appUserModel = new Models\AppUser();
+            $appUsername = $this->buildAppUsername($partyInfo['id'], $partyUserName, $appid);
+            $appUserInfo = $appUserModel->where('app_username',$appUsername)->first();
+            if(empty($appUserInfo)){
+                $result = $adapter->syncUser($appid, $appUsername, $req->input('password')); //检测用户并创建用户
+                if($result['code'] != 1){
+                    return toJson(-2, $result['msg'], []);
+                }
+
+                $appUserModel->insert([
+                    'app_id' => $appInfo['id'],
+                    'party_username' => $partyUserName,
+                    'app_username' => $appUsername,
+                    'password' => $req->input('password'),
+                    'login_time' => now(),
+                    'login_ip' => $this->get_real_ip(),
+                    //'ctime' =>now()
+                ]);
+            }else{
+                $appUserModel->where('id', $appUserInfo['id'])->update([
+                    'login_time' => now(),
+                    'login_ip' => $this->get_real_ip(),
+                ]);
+            }
+
+            //调用内容方的登陆接口
+            $result = $adapter->login($appid, $appUsername, $req->input('password'), $money);
+            if($result['code'] != 1){
+                return toJson(-3, $result['msg'], []);
+            }
+
+            DB::beginTransaction();
+            //更新额度
+            $result = $partyModel->where('id', $partyInfo['id'])->update(array(
+                'balance' => $partyInfo['balance'] - $money
+            ));
+            if($result === false){
+                $appUserModel->rollBack();
+                return toJson(-4, '系统繁忙', []);
+            }
+
+
+            //更新额度
+            $result = $appModel->where('id', $appInfo['id'])->update(array(
+                'balance' => $appInfo['balance'] - $money
+            ));
+            if($result === false){
+                DB::rollBack();
+                return toJson(-4, '系统繁忙', []);
+            }
+
+            //记录日志
+            $result = $balanceLogModel = new Models\BalanceLog();
+            $balanceLogModel->insert([
+                'type' => 2,
+                'money' => $money,
+                'app_id' => $appInfo['id'],
+                'app_username' => $appUsername,
+                'party_id' =>$partyInfo['id'],
+                'party_username' => $partyUserName,
+                //'ctime' =>now()
+            ]);
+            if($result === false){
+                $appUserModel->rollBack();
+                return toJson(-4, '系统繁忙', []);
+            }
+
+            DB::commit();
+
+            $msg = '成功';
+            $code = 1;
+
+            return toJson($code, $msg, []);
+        } catch (Exception $e) {
+            var_dump($e);die;
+            return toJson($code, $msg, []);
+        }
+
+    }//end login()
+
+    /**
+     * 组装内容用户名称
+     * @param $partyId
+     * @param $partyUsername
+     * @param $appid
+     * @return string
+     */
+    public function buildAppUsername($partyId, $partyUsername, $appid){
+        return 't'.$partyId.'_'.$partyUsername.'_a'.$appid;
+    }
+
+    private function checkLoginArg($req){
+        $arr = array('code'=>-100, 'msg'=>'');
+        if(empty($req->input('username'))){
+            $arr['msg'] = '请输入用户名';
+            return $arr;
+        }
+        if(empty($req->input('password'))){
+            $arr['msg'] = '请输入密码';
+            return $arr;
+        }
+        if(empty($req->input('appid'))){
+            $arr['msg'] = '请输如appid';
+            return $arr;
+        }
+        if(!preg_match('/^[0-9]{1,8}(.[0-9]{1,2})?$/', $req->input('money'))){
+            $arr['msg'] = '请输入正确的金额';
+            return $arr;
+        }
+
+        $arr['code'] = 1;
+        return $arr;
+    }
+
+
+}

+ 0 - 103
app/Http/Controllers/Api/ReliefController.php

@@ -1,103 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api;
-
-use Illuminate\Http\Request;
-use App\Http\Controllers\Controller;
-use App\Http\Models\ReliefData;
-use App\Http\Models\UserInfo;
-use Illuminate\Support\Facades\DB;
-use \Exception;
-
-/**
- * 救济金控制器
- */
-class ReliefController extends Controller
-{
-
-
-    /**
-     * 数据获取
-     *
-     * @access public
-     * @param  mixed $req 参数.
-     * @return string
-     */
-    public function getRelief(Request $req){
-        try {
-            // 查询参数.
-            $reliefDataModel  = new ReliefData;
-            $userInfoModel    = new UserInfo;
-            $uid              = S('token_user_id');
-            $getReliefBetween = [
-                strtotime(date("Y-m-d")),
-                time(),
-            ];
-            $getReliefWhere['members_id'] = $uid;
-            // 查询用户领取次数.
-            $res = $reliefDataModel->countRelief($getReliefWhere, $getReliefBetween);
-            // 查询系统设置表救济金领取表.
-            $getConfigSelect = [
-                'systemconfig_data',
-                'systemconfig_status',
-                'systemconfig_id',
-            ];
-            $getConfigWhere['systemconfig_name'] = 'relief';
-            $getSystemconfig = $reliefDataModel->getSystemconfig($getConfigSelect, $getConfigWhere);
-            // 查询用户余额.
-            $getUserSelect              = ['membersDetailed_cash'];
-            $getUserWhere['members_id'] = $uid;
-            $cash = $userInfoModel->userInfo($getUserSelect, $getUserWhere);
-            // 查询用户游戏余额.
-            $gameMoneySelect              = ['gameMoney_money'];
-            $gameMoneyWhere['members_id'] = $uid;
-            $gameMoney                    = $userInfoModel->gameMoney($gameMoneySelect, $gameMoneyWhere);
-            // 获取用户总余额.
-            $allCash = $cash['membersDetailed_cash'];
-            foreach ($gameMoney as $v) {
-                $allCash += $v['gameMoney_money'];
-            }
-
-            // 验证是否可领取.
-            $data   = json_decode($getSystemconfig[0]['systemconfig_data'], true);
-            $status = $getSystemconfig[0]['systemconfig_status'];
-            if ($res >= $data['count']) {
-                return toJson(-30002);
-            } else if ($data['condition'] < $allCash) {
-                return toJson(-30003);
-            }
-
-            if ($status == 1 && $res < $data['count'] && $data['condition'] >= $allCash) {
-                DB::beginTransaction();
-                $upUserInfoWhere['members_id']          = $uid;
-                $upUserInfoData['membersDetailed_cash'] = ($data['mony'] + $cash['membersDetailed_cash']);
-                // 修改用户信息.
-                $upUserInfo = $userInfoModel->upUserInfo($upUserInfoWhere, $upUserInfoData);
-                // 新增救济金记录.
-                $orderId       = getOrderId();
-                $addReliefData = [
-                    'getrelief_identity'    => $orderId,
-                    'members_id'            => $uid,
-                    'getrelief_addtime'     => time(),
-                    'getrelief_mony'        => $data['mony'],
-                    'getrelief_begin_money' => $cash['membersDetailed_cash'],
-                    'getrelief_end_money'   => ($data['mony'] + $cash['membersDetailed_cash']),
-                ];
-                $addRelief     = $reliefDataModel->addRelief($addReliefData);
-                if ($addRelief && $upUserInfo) {
-                    DB::commit();
-                    return toJson(1, '成功', ['money' => ($data['mony'] + $cash['membersDetailed_cash'])]);
-                } else {
-                    return toJson(-2);
-                    DB::rollBack();
-                }
-            } else {
-                return toJson(-30003);
-            }//end if
-        } catch (Exception $e) {
-            echo $e->getMessage();
-        }//end try
-    }
-
-
-}

+ 0 - 243
app/Http/Controllers/Api/SignController.php

@@ -1,243 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Api;
-
-use Illuminate\Http\Request;
-use App\Http\Controllers\Controller;
-use App\Http\Models\Sign;
-use App\Http\Models\UserInfo;
-use Illuminate\Support\Facades\DB;
-use \Exception;
-
-/**
- * 签到控制器
- */
-class SignController extends Controller
-{
-
-    /**
-     * 签到次数
-     *
-     * @access public
-     * @param  mixed $req 参数.
-     * @return string
-     */
-    public function signCount(Request $req){
-        try {
-            $signModel = new Sign;
-            $uid       = S('token_user_id');
-            // 查询用户ID.
-            $getSignWhere['members_id'] = $uid;
-            // 获取当周1.
-            $timeMonday = date('Y-m-d', (time()-((date('w',time()) == 0?7:date('w',time()))-1)*24*3600));
-            // 获取当月一号.
-            $monthOne = date('Y-m-01');
-            // 时间区间.
-            $weekBetween  = [
-                strtotime($timeMonday),
-                time(),
-            ];
-            $monthBetween = [
-                strtotime($monthOne),
-                time(),
-            ];
-            // 查询用户签到次数.
-            $countWeek  = $signModel->countSign($getSignWhere, $weekBetween);
-            $countMonth = $signModel->countSign($getSignWhere, $monthBetween);
-
-            // 查询签到设置.
-            $signSelect  = [
-                'sign_title',
-                'sign_data',
-                'sign_name',
-                'sign_type',
-            ];
-            $getConfig   = $signModel->signConfig($signSelect, '', '');
-            $weekConfig  = [];
-            $monthConfig = [];
-            foreach ($getConfig as $v) {
-                if ($v['sign_type'] === 1) {
-                    $weekConfig[] = $v;
-                } else if ($v['sign_type'] === 2) {
-                    $monthConfig[] = $v;
-                }
-            }
-
-            $return = [
-                'countWeek'   => $countWeek,
-                'countMonth'  => $countMonth,
-                'weekConfig'  => $weekConfig,
-                'monthConfig' => $monthConfig,
-            ];
-
-            return toJson(1, '成功', $return);
-        } catch (Exception $e) {
-            echo $e->getMessage();
-        }//end try
-
-    }//end signCount()
-
-
-    /**
-     * 签到
-     *
-     * @access public
-     * @param  mixed $req 参数.
-     * @return string
-     */
-    public function pullSign(Request $req){
-        try {
-            // 查询参数.
-            $signModel     = new Sign;
-            $userInfoModel = new UserInfo;
-            $uid           = S('token_user_id');
-            // 获取当周1.
-            $timeMonday = date('Y-m-d', (time()-((date('w',time())==0?7:date('w',time()))-1)*24*3600));
-            // 获取当月一号.
-            $monthOne = date('Y-m-01');
-            // 时间区间.
-            $weekBetween  = [
-                strtotime($timeMonday),
-                time(),
-            ];
-            $monthBetween = [
-                strtotime($monthOne),
-                time(),
-            ];
-            $dayBetween = [
-                strtotime(date('Y-m-d')),
-                time(),
-            ];
-            // 查询用户ID.
-            $getSignWhere['members_id'] = $uid;
-            // 查询用户是否已签到.
-            $countDay = $signModel->countSign($getSignWhere, $dayBetween);
-            if ($countDay) {
-                return toJson(-30004);
-            }
-
-            // 查询用户签到次数.
-            $countWeek  = $signModel->countSign($getSignWhere, $weekBetween);
-            $countMonth = $signModel->countSign($getSignWhere, $monthBetween);
-            // 查询设置表.
-            $signSelect     = [
-                'sign_title',
-                'sign_data',
-                'sign_id',
-            ];
-            $signWeekWhere  = [];
-            $signMonthWhere = [];
-            // 根据签到天数获取查询条件.
-            switch ($countWeek) {
-                case 0:
-                    $signWeekWhere['sign_title'] = 'day1';
-                    break;
-                case 1:
-                    $signWeekWhere['sign_title'] = 'day2';
-                    break;
-                case 2:
-                    $signWeekWhere['sign_title'] = 'day3';
-                    break;
-                case 3:
-                    $signWeekWhere['sign_title'] = 'day4';
-                    break;
-                case 4:
-                    $signWeekWhere['sign_title'] = 'day5';
-                    break;
-                case 5:
-                    $signWeekWhere['sign_title'] = 'day6';
-                    break;
-                case 6:
-                    $signWeekWhere['sign_title'] = 'day7';
-                    break;
-            }
-            switch ($countMonth) {
-                case 4:
-                    $signMonthWhere['sign_title'] = 'accumulate1';
-                    break;
-                case 9:
-                    $signMonthWhere['sign_title'] = 'accumulate2';
-                    break;
-                case 14:
-                    $signMonthWhere['sign_title'] = 'accumulate3';
-                    break;
-                case 19:
-                    $signMonthWhere['sign_title'] = 'accumulate4';
-                    break;
-                case 24:
-                    $signMonthWhere['sign_title'] = 'accumulate5';
-                    break;
-            }
-            $getWeekConfig = [];
-            $getMonthConfig = [];
-            // 查询周签到设置.
-            if ($signWeekWhere) {
-                $getWeekConfig = $signModel->signConfig($signSelect, $signWeekWhere, '');
-            }
-            // 查询月签到设置.
-            if ($signMonthWhere) {
-                $getMonthConfig = $signModel->signConfig($signSelect, $signMonthWhere, '');
-            }
-            // 查询用户余额.
-            $getUserSelect              = ['membersDetailed_cash'];
-            $getUserWhere['members_id'] = $uid;
-            $cash = $userInfoModel->userInfo($getUserSelect, $getUserWhere);
-            $nowCash = $cash['membersDetailed_cash'];
-            // 添加记录,修改用户信息.
-            DB::beginTransaction();
-            $upUserInfo = 1;
-            $receiveMoney = 0;
-            $signId = '';
-            // 如果有签到奖励则修改用户余额.
-            if ($signWeekWhere || $signMonthWhere) {
-                $signIdArr = [];
-                $getWeekMoney = 0;
-                $getMonthMoney = 0;
-                if ($getWeekConfig) {
-                    $signIdArr[] = $getWeekConfig[0]['sign_id'];
-                    $getWeekMoney = $getWeekConfig[0]['sign_data'];
-                }
-                if ($getMonthConfig) {
-                    $signIdArr[] = $getMonthConfig[0]['sign_id'];
-                    $getMonthMoney = $getMonthConfig[0]['sign_data'];
-                }
-                $signId = json_encode($signIdArr);
-                // 计算签到后余额.
-                $receiveMoney = intval($getWeekMoney) + intval($getMonthMoney);
-                $nowCash += $receiveMoney;
-                $upUserInfoWhere['members_id']          = $uid;
-                $upUserInfoData['membersDetailed_cash'] = $nowCash;
-                // 修改用户信息.
-                $upUserInfo = $userInfoModel->upUserInfo($upUserInfoWhere, $upUserInfoData);
-            }
-            // 新增签到记录.
-            $orderId       = getOrderId();
-            $addSignData = [
-                'getsign_identity'    => $orderId,
-                'members_id'            => $uid,
-                'getsign_addtime'     => time(),
-                'getsign_mony'        => $receiveMoney,
-                'getsign_begin_money' => $cash['membersDetailed_cash'],
-                'getsign_end_money'   => $nowCash,
-                'sign_id'   => $signId,
-            ];
-            $addSign     = $signModel->addSign($addSignData);
-            if ($addSign && $upUserInfo) {
-                DB::commit();
-                $return = [
-                    'money' => $nowCash,
-                    'countWeek'  => $countWeek + 1,
-                    'countMonth' => $countMonth + 1,
-                ];
-                return toJson(1, '成功', $return);
-            } else {
-                return toJson(-2);
-                DB::rollBack();
-            }
-        } catch (Exception $e) {
-            echo $e->getMessage();
-        }//end try
-    }//end pullSign()
-
-
-}

+ 25 - 0
app/Http/Controllers/Controller.php

@@ -46,4 +46,29 @@ class Controller extends BaseController
         return $tree;
     }
 
+    /**
+     * 获取用户真是ip
+     * @return bool|mixed
+     */
+    public function get_real_ip()
+    {
+        $ip=FALSE;
+        //客户端IP 或 NONE
+        if(!empty($_SERVER["HTTP_CLIENT_IP"])){
+            $ip = $_SERVER["HTTP_CLIENT_IP"];
+        }
+        //多重代理服务器下的客户端真实IP地址(可能伪造),如果没有使用代理,此字段为空
+        if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
+            $ips = explode (", ", $_SERVER['HTTP_X_FORWARDED_FOR']);
+            if ($ip) { array_unshift($ips, $ip); $ip = FALSE; }
+            for ($i = 0; $i < count($ips); $i++) {
+                if (!eregi ("^(10│172.16│192.168).", $ips[$i])) {
+                    $ip = $ips[$i];
+                    break;
+                }
+            }
+        }
+        //客户端IP 或 (最后一个)代理服务器 IP
+        return ($ip ? $ip : $_SERVER['REMOTE_ADDR']);
+    }
 }

+ 0 - 52
app/Http/Controllers/Sys/ActivityController.php

@@ -1,52 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Sys;
-
-use Illuminate\Http\Request;
-use App\Http\Controllers\Controller;
-use \App\Http\Models;
-use \Exception;
-
-/**
- * 活动管理类
- */
-class ActivityController extends Controller
-{
-
-
-    /**
-     * 活动查询
-     *
-     * @access public
-     * @param mixed $req 数据传输
-     * @return array JsonString
-     */
-    public function activityList(Request $req)
-    {
-        $code = -2;
-        $msg = '操作失败';
-        try {
-            $activityModel = new Models\Activity;
-            $activityWhere = [];
-            if (empty($req->input('type')) === false) {
-                $activityWhere['activity_type'] = $req->input('type');
-            }
-
-            if (empty($req->input('label')) === false) {
-                $activityWhere['activity_label'] = $req->input('label');
-            }
-
-            $activityData = $activityModel->getActivity($activityWhere);
-
-            $msg = '成功';
-            $code = 1;
-
-            return toJson($code, $msg, $activityData);
-        } catch (Exception $e) {
-            return toJson($code, $msg, []);
-        }
-
-    }//end activityList()
-
-
-}

+ 99 - 0
app/Http/Controllers/Sys/AppController.php

@@ -0,0 +1,99 @@
+<?php
+
+namespace App\Http\Controllers\Sys;
+
+use App\Http\Appadapter\Adapter;
+use Illuminate\Http\Request;
+use App\Http\Controllers\Controller;
+use \App\Http\Models;
+use Illuminate\Support\Facades\DB;
+use \Exception;
+
+/**
+ * 第三方管理类
+ */
+class AppController extends Controller
+{
+
+    /**
+     * 构造函数
+     *
+     * @access public
+     * @param mixed $req 数据传输
+     * @return array JsonString
+     */
+    public function __construct() {
+
+    }
+
+    /**
+     * 接收app发来的下线通知
+     */
+    public function loginOut(Request $req){
+        $input =  $req->input();
+
+        if(!isset($input['money']) || !preg_match('/^[0-9]{1,8}(.[0-9]{1,2})?$/', $input['money'])){
+            $arr['msg'] = '请传入正确的金额';
+            return $arr;
+        }
+
+        $money = $req->input('money');
+        $appUsername = $req->input('username');
+
+        $appUserModel = new Models\AppUser();
+        $appUserInfo = $appUserModel->where('app_username',$appUsername)->first();
+
+        $mathches = array();
+        preg_match('/^t(\d+)_(\w+\W+)_a(\d+)$/', $appUsername, $mathches);
+        $partyId = $mathches[1];
+        $appId = $mathches[3];
+        $partyUserName = $mathches[2];
+
+        $appModel = new Models\App;
+        $appInfo = $appModel->where('id', $appId)->first();
+
+        DB::beginTransaction();
+        //更新额度
+        /*$result = $partyModel->where('id', $partyInfo['id'])->update(array(
+            'balance' => $partyInfo['balance'] - $money
+        ));
+        if($result === false){
+            $appUserModel->rollBack();
+            return toJson(-4, '系统繁忙', []);
+        }*/
+
+
+        //更新额度
+
+        $result = $appModel->where('id', $appId)->update(array(
+            'balance' => $appInfo['balance'] - $money
+        ));
+        if($result === false){
+            DB::rollBack();
+            return toJson(-4, '系统繁忙', []);
+        }
+
+        //记录日志
+        $result = $balanceLogModel = new Models\BalanceLog();
+        $balanceLogModel->insert([
+            'type' => 2,
+            'money' => $money,
+            'app_id' => $appInfo['id'],
+            'app_username' => $appUsername,
+            'party_id' =>$partyId,
+            'party_username' => $partyUserName,
+            //'ctime' =>now()
+        ]);
+        if($result === false){
+            $appUserModel->rollBack();
+            return toJson(-4, '系统繁忙', []);
+        }
+
+        DB::commit();
+
+        //TODO 调用第三方平台推出接口,更新第三方额度
+
+    }
+
+
+}

+ 0 - 25
app/Http/Controllers/Sys/MenuController.php

@@ -1,25 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Sys;
-
-use Illuminate\Http\Request;
-use App\Http\Controllers\Controller;
-use Illuminate\Support\Facades\Redis;
-
-
-use App\Models\Gmenu;
-
-class MenuController extends Controller
-{
-    public function getMenus(Request $req)
-    {
-        $pid = intval($req->input('pid', 0));
-        $data = (new  Gmenu())->getByPid($pid);
-        if (empty($data)) {
-            return toJson(-1);
-        } else {
-            $md5 = md5(json_encode($data));
-            return toJson(1, '', ['data' => $data, 'md5' => $md5]);
-        }
-    }
-}

+ 0 - 43
app/Http/Controllers/Sys/RankController.php

@@ -1,43 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Sys;
-
-use Illuminate\Http\Request;
-use App\Http\Controllers\Controller;
-use \App\Http\Models;
-use App\Http\Models\UserInfo;
-use \Exception;
-
-/**
- * 排行榜类
- */
-class RankController extends Controller
-{
-
-
-    /**
-     * 定时任务:更新用户前一天总余额
-     *
-     * @access public
-     * @param mixed $req 数据传输
-     * @return array JsonString
-     */
-    public function activityList(Request $req)
-    {
-        $userInfoModel    = new UserInfo;
-        // 查询用户余额.
-        $getUserSelect              = ['membersDetailed_cash'];
-        $userInfo = $userInfoModel->getUserInfo($getUserSelect, '');
-        // 查询用户游戏余额.
-        $gameMoneySelect              = ['gameMoney_money'];
-        $gameMoney = $userInfoModel->gameMoney($gameMoneySelect, '');
-        /*foreach ($userInfo as $v) {
-            foreach ()
-        }*/
-        $ress = $this->updateBatch('news', $multipleDatas);
-        print_r($gameMoney);die;
-
-    }//end activityList()
-
-
-}

+ 0 - 130
app/Http/Controllers/Sys/UserController.php

@@ -1,130 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Sys;
-
-use Illuminate\Http\Request;
-use App\Http\Controllers\Controller;
-use Illuminate\Support\Facades\DB;
-use Illuminate\Support\Facades\Redis;
-use \Exception;
-
-
-class UserController extends Controller
-{
-
-    //游客注册登录 133
-    public function hideLogin()
-    {
-        $ip = GETIP();
-
-        //检测是否注册过
-        $member = DB::table('members')->where('user_ip', $ip)->first();
-        if (!empty($member)) {
-            if (($member->deleted_at) > date('Y-m-d H:i:s')) {
-                $this->del_oldMap($member->remember_token);
-                $token = \App\Vendor\Jwt::getToken($member->id);
-                DB::table('members')
-                    ->where('id', $member->id)
-                    ->update(['remember_token' => $token]);
-                $this->ResetMaps($member->id,$token);
-                return toJson(1, '', array('token' => $token));
-            }
-            return toJson(-20004);
-        }
-        //没有注册,生成游客用户
-        $seed = time();
-        $name = rand(0, $seed);
-        $pwd = '123456';
-        $uuid = getUUID();
-        $userData = [
-            'name' => 'youke_' . $name,
-            'phone' => '180' . rand(10000000, 99999999),
-            'uuid' => $uuid,
-            'password' => createPasswd(trim($pwd), $uuid),
-            'identity' => 2,
-            'user_ip' => $ip,
-            'created_at' => date('Y-m-d H:i:s'),
-            'updated_at' => date('Y-m-d H:i:s'),
-            'deleted_at' => date('Y-m-d H:i:s', strtotime("+2 day"))
-        ];
-
-        try {
-            $ret = DB::table('members')->insertGetId($userData);
-            $membersDetailed['members_id'] = $ret;
-            $insertMembersDetailed = \App\Models\MembersDetailed::insert($membersDetailed);
-            $token = \App\Vendor\Jwt::getToken($ret);
-            DB::table('members')
-                ->where('id', $ret)
-                ->update(['remember_token' => $token]);
-        } catch (Exception $ex) {
-            return toJson(-20001);
-        }
-        $this->ResetMaps($ret,$token);
-        return toJson(1, '', array('token' => $token));
-    }
-
-    public function register(Request $req)
-    {
-        try {
-            $user = [];
-            $user['name'] = $req->input('user');
-            $user['password'] = $req->input('password');
-            $cpwd = $req->input('confirm_password');
-            $user['phone'] = $req->input('phone');
-            $user['uuid'] = getUUID();
-            $user['password'] = createPasswd(trim($user['password']), $user['uuid']);
-            $user['nick'] = $req->input('nick');
-            DB::beginTransaction();
-            $insertMembers = \App\Models\Member::insertGetId($user);
-            $membersDetailed['members_id'] = $insertMembers;
-            $insertMembersDetailed = \App\Models\MembersDetailed::insert($membersDetailed);
-            if ($insertMembers && $insertMembersDetailed) {
-                DB::commit();
-                return toJson(1);
-            } else {
-                return toJson(-2);
-                DB::rollBack();
-            }
-        } catch (Exception $ex) {
-            return toJson(-20001);
-        }
-    }
-
-    public function login(Request $req)
-    {
-        $user['name'] = $req->input('user');
-        $user['password'] = $req->input('password');
-        $member = \App\Models\Member::where('name', $user['name'])->first();
-        if (!$member) {
-            return toJson(-20002);
-        }
-        if (($member['password']) != createPasswd(trim($user['password']), $member['uuid'])) {
-            return toJson(-20003);
-        }
-        // echo $member['id'];
-        $token = \App\Vendor\Jwt::getToken($member['id']);
-        $this->del_oldMap($member['remember_token']);
-        DB::table('members')
-            ->where('id', $member['id'])
-            ->update(['remember_token' => $token]);
-        $this->ResetMaps($member['id'],$token);
-        return toJson(1, '', array('token' => $token));
-    }
-
-    private function ResetMaps($uid, $token)
-    {
-        $tokenmd5 = md5($token);
-        Redis::hset("MAPS_TOKEN_UID", $tokenmd5, $uid);
-        Redis::hset("MAPS_UID_TOKEN", $uid, $tokenmd5);
-    }
-    private  function del_oldMap($token){
-        $tokenmd5 = md5($token);
-        Redis::hdel("MAPS_TOKEN_UID", $tokenmd5);
-    }
-
-
-    public function logout()
-    {
-
-    }
-}

+ 21 - 11
app/Http/Middleware/authJWT.php

@@ -15,25 +15,35 @@ class authJWT
      */
     public function handle($request, Closure $next)
     {
+
         try {
+
             // 如果用户登陆后的所有请求没有jwt的token抛出异常
-            $user = \App\Vendor\Jwt::verifyToken($request->input('token')); 
-            if(!$user){
+            $token = $request->input('token');
+            if(empty($token)){
+                return toJson(-30001);
+            }
+
+            $myToken = $this->createToken($request);
+            if($token != $myToken){
                 return toJson(-30001);
             }
-           
-            S('token_user_id',$user['sub']);
 
         } catch (Exception $e) {
             return toJson(-30001);
-            // if ($e instanceof \Tymon\JWTAuth\Exceptions\TokenInvalidException){
-            //     return response()->json(['error'=>'Token 无效']);
-            // }else if ($e instanceof \Tymon\JWTAuth\Exceptions\TokenExpiredException){
-            //     return response()->json(['error'=>'Token 已过期']);
-            // }else{
-            //     return response()->json(['error'=>'出错了']);
-            // }
         }
         return $next($request);
     }
+
+    private function createToken($request){
+        $key = $request->input('key');
+        $secret = \App\Models\Party::where('key', $key)->first()['secret'];
+        if(empty($secret)){
+            return false;
+        }
+
+        $token = md5($key.$secret);
+        return $token;
+    }
+
 }

+ 0 - 93
app/Http/Models/Activity.php

@@ -1,93 +0,0 @@
-<?php
-
-namespace App\Http\Models;
-
-use Illuminate\Database\Eloquent\Model;
-use \App\Models;
-
-/**
- * 活动管理模型类
- */
-class Activity extends Model
-{
-
-
-    /**
-     * 获取活动
-     *
-     * @access public
-     * @param mixed $where 查询条件
-     * @return String
-     */
-    public function getActivity($where)
-    {
-        $activityModel = new Models\Activity;
-        $select = [
-            'activity_title',
-            'activity_content',
-            'activity_beginTime',
-            'activity_endTime',
-            'activity_type',
-            'activity_label',
-            'activity_money',
-            'activity_identity',
-            'activity_ico',
-        ];
-        $where = $where;
-        $where['activity_delete'] = 0;
-        $newTime = date('Y-m-d H:i:s');
-        $result = $activityModel
-            ->select($select)
-            ->where($where)
-            ->where('activity_beginTime', '<=', $newTime)
-            ->where('activity_endTime', '>', $newTime)
-            ->orderBy('activity_beginTime', 'asc')
-            ->get();
-
-        return $result;
-
-    }//end getActivity()
-
-
-    /**
-     * 获取所有活动
-     *
-     * @access public
-     * @param mixed $where 查询条件
-     * @param mixed $paginate 分页
-     * @return String
-     */
-    public function getAllActivity($where, $paginate)
-    {
-        // 获取游戏地址数据.
-        $activityModel = new Models\Activity;
-        $select = [
-            'activity_title',
-            'activity_content',
-            'activity_delete',
-            'activity_type',
-            'activity_label',
-            'activity_money',
-            'activity_data',
-            'activity_data',
-            'activity_identity',
-            'activity_beginTime',
-            'activity_endTime',
-            'activity_ico',
-        ];
-        $getActivity = $activityModel->select($select);
-        if (empty($where) === false) {
-            $getActivity = $getActivity->where($where);
-        }
-
-        $getActivity = $getActivity
-            ->orderBy('activity_beginTime','asc')
-            ->paginate($paginate)
-            ->toArray();
-
-        return $getActivity;
-
-    }//end getActivity()
-
-
-}

+ 0 - 68
app/Http/Models/AgentCash.php

@@ -1,68 +0,0 @@
-<?php
-
-namespace App\Http\Models;
-
-use Illuminate\Database\Eloquent\Model;
-use \App\Models;
-
-/**
- * 代理管理模型类
- */
-class AgentCash extends Model
-{
-
-
-    /**
-     * 查询游戏余额
-     *
-     * @access public
-     * @return array
-     */
-    public function seeGameMoney()
-    {
-        $gameMoneyModel = new Models\GameMoney;
-        $gameMoneySelect = [
-            'gname',
-            'gameMoney_money',
-            'gmenu_id',
-            'smalliconUrl',
-        ];
-        $gameMoneyWhere = [
-            'members_id' => S('token_user_id'),
-        ];
-        $result = $gameMoneyModel
-            ->join('gmenu', 'gameMoney.gmenu_id', 'gmenu.id')
-            ->select($gameMoneySelect)
-            ->where($gameMoneyWhere)
-            ->get();
-
-        return $result;
-
-    }//end seeGameMoney()
-
-
-    /**
-     * 查询所有人游戏余额
-     *
-     * @access public
-     * @return array
-     */
-    public function allGameMoney()
-    {
-        $gameMoneyModel = new Models\GameMoney;
-        $gameMoneySelect = [
-            'gameMoney_money',
-            'name',
-            'members_id',
-        ];
-        $result = $gameMoneyModel
-            ->join('members', 'gameMoney.members_id', 'members.id')
-            ->select($gameMoneySelect)
-            ->get();
-
-        return $result;
-
-    }//end allGameMoney()
-
-
-}

+ 14 - 0
app/Http/Models/App.php

@@ -0,0 +1,14 @@
+<?php
+
+namespace App\Http\Models;
+
+use Illuminate\Database\Eloquent\Model;
+use \App\Models;
+
+/**
+ * 签到模型类
+ */
+class App extends Model
+{
+    protected $table = 'ag_app';
+}

+ 14 - 0
app/Http/Models/AppUser.php

@@ -0,0 +1,14 @@
+<?php
+
+namespace App\Http\Models;
+
+use Illuminate\Database\Eloquent\Model;
+use \App\Models;
+
+/**
+ * 签到模型类
+ */
+class AppUser extends Model
+{
+    protected $table = 'ag_app_user';
+}

+ 14 - 0
app/Http/Models/BalanceLog.php

@@ -0,0 +1,14 @@
+<?php
+
+namespace App\Http\Models;
+
+use Illuminate\Database\Eloquent\Model;
+use \App\Models;
+
+/**
+ * 签到模型类
+ */
+class BalanceLog extends Model
+{
+    protected $table = 'ag_balance_log';
+}

+ 0 - 128
app/Http/Models/Common.php

@@ -1,128 +0,0 @@
-<?php
-
-namespace App\Http\Models;
-
-use Illuminate\Database\Eloquent\Model;
-use Illuminate\Support\Facades\Redis;
-/**
- * 代理管理模型类
- */
-class Common extends Model
-{
-
-
-    /**
-     * 接口调用
-     *
-     * @access public
-     * @param mixed $url 接口地址
-     * @param mixed $where $params参数
-     * @param mixed $timeout 请求时效
-     * @return String
-     */
-    public function make_request($url, $params, $timeout=30)
-    {
-        set_time_limit(0);
-        if (function_exists('curl_init') === true) {
-            $ch = curl_init();
-            $header = array(
-                'Accept-Language: zh-cn',
-                'Connection: Keep-Alive',
-                'Cache-Control: no-cache'
-            );
-            curl_setopt($ch, CURLOPT_POST, 1);
-            curl_setopt($ch, CURLOPT_URL, $url);
-            curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
-            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
-            curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
-            if ($timeout > 0) curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
-            $result = curl_exec($ch);
-            $errno = curl_errno($ch);
-            curl_close($ch);
-            return $result;
-        } else {
-            $context = array(
-                'http' => array(
-                    'method' => 'POST',
-                    'header' => 'Content-type: application/x-www-form-urlencoded' . "\r\n" .
-                        'Content-length: ' . strlen($params),
-                    'content' => $params));
-            if ($timeout > 0) $context['http']['timeout'] = $timeout;
-            $contextid = stream_context_create($context);
-            $sock = @fopen($url, 'r', false, $contextid);
-            if ($sock) {
-                $result = '';
-                while (!feof($sock)) {
-                    $result .= fgets($sock, 8192);
-                }
-                fclose($sock);
-            } else {
-                return 'TimeOut';
-            }
-        }
-        return $result;
-
-    }//end make_request()
-
-
-    /**
-     * 接口调用
-     *
-     * @access public
-     * @param mixed $paramsData 接口必要參數
-     * @param mixed $url 接口地址
-     * @return String
-     */
-    public function sportsAgentParams($paramsData, $url)
-    {
-        $paramsSting = '';
-        $a = 0;
-        foreach ($paramsData as $key => $value) {
-            if ($a === 0) {
-                $paramsSting .= $key . '=' . $value;
-            } else {
-                $paramsSting .= '&' . $key . '=' . $value;
-            }
-            $a++;
-        }
-        $params = base64_encode($paramsSting);
-        $key = md5($params . session('sportsToken'));
-        $loginUrl = $url . '?params=' . $params . '&Key=' . $key;
-
-        return $loginUrl;
-
-    }//end sportsAgentParams()
-
-    /**
-     * 添加系统通知
-     *
-     * @access public
-     * @param  key $key redis键名
-     * @param array $msg 通知内容
-     * @return
-     */
-     public function addNotification($key,array $msg){
-        $msg = json_encode($msg);
-        $rpush = Redis::rpush($key,$msg);
-        if(!$rpush){
-            return false;
-        }
-         return true;
-    }
-
-    /**
-     * 获取栈内系统通知
-     * @access public
-     * @param  key $key redis键名
-     * @param array $msg 通知内容
-     * @return
-     */
-     public function getNotification($key){
-        $msg = Redis::lrange($key,0,-1);
-        if(!empty($msg)){
-            $msg = json_decode($msg,true);
-            return $msg;
-        }
-        return [];
-    }
-}

+ 0 - 138
app/Http/Models/GameMoney.php

@@ -1,138 +0,0 @@
-<?php
-
-namespace App\Http\Models;
-
-use Illuminate\Database\Eloquent\Model;
-use \App\Models;
-
-/**
- * 签到模型类
- */
-class Sign extends Model
-{
-
-
-    /**
-     * 查询签到记录
-     *
-     * @access public
-     * @param mixed $where 查询条件
-     * @param mixed $between 查询条件
-     * @param mixed $paginate 分页
-     * @return array
-     */
-    public function getSignRecord($select, $paginate, $where='', $between='')
-    {
-        // 获取签到记录.
-        $getSignModel = new Models\GetSign;
-        $getSignModel = $getSignModel
-            ->select($select)
-            ->join('members', 'members.id', 'getsign.members_id');
-        if (empty($where) === false) {
-            $getSignModel = $getSignModel->where($where);
-        }
-
-        if (empty($between) === false) {
-            $getSignModel = $getSignModel->whereBetween('getsign_addtime', $between);
-        }
-
-        $getSignModel = $getSignModel
-            ->orderBy('getsign_addtime','desc')
-            ->paginate($paginate)
-            ->toArray();
-
-        return $getSignModel;
-
-    }//end getSignRecord()
-
-
-    /**
-     * 添加签到记录
-     *
-     * @access public
-     * @param mixed $data 数据
-     * @return array
-     */
-    public function addSign($data)
-    {
-        // 获取救济金记录.
-        $getSignModel = new Models\GetSign;
-        $result = $getSignModel->insert($data);
-
-        return $result;
-
-    }//end addSign()
-
-
-    /**
-     * 查询签到记录
-     *
-     * @access public
-     * @param mixed $where 查询条件
-     * @param mixed $between 查询条件
-     * @param mixed $paginate 分页
-     * @return array
-     */
-    public function countSign($where, $between)
-    {
-        // 获取救济金记录.
-        $getSignModel = new Models\GetSign;
-        $result = $getSignModel
-            ->where($where)
-            ->whereBetween('getsign_addtime', $between)
-            ->count();
-
-        return $result;
-
-    }//end countSign()
-
-
-    /**
-     * 查询签到设置
-     *
-     * @access public
-     * @param mixed $select 查询字段
-     * @param mixed $where 查询条件
-     * @param mixed $orWhere 查询条件
-     * @return array
-     */
-    public function signConfig($select, $where, $orWhere)
-    {
-        // 查询救济金系统设置.
-        $signModel = new Models\Sign;
-        $signModel = $signModel->select($select);
-        if ($where) {
-            $signModel = $signModel->Where($where);
-        }
-        if ($orWhere) {
-            $signModel = $signModel->orWhere($orWhere);
-        }
-        $signModel = $signModel->orderBy('sign_title', 'asc')->get();
-
-        return $signModel;
-
-    }//end signConfig()
-
-
-    /**
-     * 修改签到设置
-     *
-     * @access public
-     * @param mixed $where 查询条件
-     * @param mixed $data 数据
-     * @return array
-     */
-    public function upSignConfig($where, $data)
-    {
-        // 查询救济金系统设置.
-        $signModel = new Models\Sign;
-        $signModel = $signModel
-            ->where($where)
-            ->update($data);
-
-        return $signModel;
-
-    }//end upSignConfig()
-
-
-}

+ 0 - 42
app/Http/Models/GameUrlData.php

@@ -1,42 +0,0 @@
-<?php
-
-namespace App\Http\Models;
-
-use Illuminate\Database\Eloquent\Model;
-use \App\Models;
-
-/**
- * 游戏url及参数模型类
- */
-class GameUrlData extends Model
-{
-
-
-    /**
-     * 查询游戏url及参数
-     *
-     * @access public
-     * @param mixed $getGameUrlWhere 查询条件
-     * @param mixed $paginate 分页
-     * @return array
-     */
-    public function getGameUrl($getGameUrlWhere='', $paginate)
-    {
-        // 获取游戏地址数据.
-        $gameUrlModel = new Models\GameUrl;
-        $getGameUrl = $gameUrlModel;
-        if (empty($getGameUrlWhere) === false) {
-            $getGameUrl = $getGameUrl->where($getGameUrlWhere);
-        }
-
-        $getGameUrl = $getGameUrl
-            ->orderBy('gameUrl_id','desc')
-            ->paginate($paginate)
-            ->toArray();
-
-        return $getGameUrl;
-
-    }//end getGameUrl()
-
-
-}

+ 14 - 0
app/Http/Models/Party.php

@@ -0,0 +1,14 @@
+<?php
+
+namespace App\Http\Models;
+
+use Illuminate\Database\Eloquent\Model;
+use \App\Models;
+
+/**
+ * 签到模型类
+ */
+class Party extends Model
+{
+    protected $table = 'ag_party';
+}

+ 14 - 0
app/Http/Models/PartyUser.php

@@ -0,0 +1,14 @@
+<?php
+
+namespace App\Http\Models;
+
+use Illuminate\Database\Eloquent\Model;
+use \App\Models;
+
+/**
+ * 签到模型类
+ */
+class PartyUser extends Model
+{
+    protected $table = 'ag_party_user';
+}

+ 0 - 134
app/Http/Models/ReliefData.php

@@ -1,134 +0,0 @@
-<?php
-
-namespace App\Http\Models;
-
-use Illuminate\Database\Eloquent\Model;
-use \App\Models;
-
-/**
- * 救济金模型类
- */
-class ReliefData extends Model
-{
-
-
-    /**
-     * 查询救济金记录
-     *
-     * @access public
-     * @param mixed $where 查询条件
-     * @param mixed $between 查询条件
-     * @param mixed $paginate 分页
-     * @return array
-     */
-    public function getRelief($select, $paginate, $where='', $between='')
-    {
-        // 获取救济金记录.
-        $getReliefModel = new Models\GetRelief;
-        $getReliefModel = $getReliefModel
-            ->select($select)
-            ->join('members', 'members.id', 'getrelief.members_id');
-        if (empty($where) === false) {
-            $getReliefModel = $getReliefModel->where($where);
-        }
-
-        if (empty($between) === false) {
-            $getReliefModel = $getReliefModel->whereBetween('getrelief_addtime', $between);
-        }
-
-        $getReliefModel = $getReliefModel
-            ->orderBy('getrelief_addtime','desc')
-            ->paginate($paginate)
-            ->toArray();
-
-        return $getReliefModel;
-
-    }//end getRelief()
-
-
-    /**
-     * 添加救济金记录
-     *
-     * @access public
-     * @param mixed $data 数据
-     * @return array
-     */
-    public function addRelief($data)
-    {
-        // 获取救济金记录.
-        $getReliefModel = new Models\GetRelief;
-        $result = $getReliefModel->insert($data);
-
-        return $result;
-
-    }//end addRelief()
-
-
-    /**
-     * 查询救济金记录
-     *
-     * @access public
-     * @param mixed $where 查询条件
-     * @param mixed $between 查询条件
-     * @param mixed $paginate 分页
-     * @return array
-     */
-    public function countRelief($where, $between)
-    {
-        // 获取救济金记录.
-        $getReliefModel = new Models\GetRelief;
-        $result = $getReliefModel
-            ->where($where)
-            ->whereBetween('getrelief_addtime', $between)
-            ->count();
-
-        return $result;
-
-    }//end countRelief()
-
-
-    /**
-     * 查询救济金系统设置
-     *
-     * @access public
-     * @param mixed $where 查询条件
-     * @param mixed $between 查询条件
-     * @param mixed $paginate 分页
-     * @return array
-     */
-    public function getSystemconfig($select, $where)
-    {
-        // 查询救济金系统设置.
-        $systemconfigModel = new Models\Systemconfig;
-        $systemconfigModel = $systemconfigModel
-            ->select($select)
-            ->where($where)
-            ->get();
-
-        return $systemconfigModel;
-
-    }//end getSystemconfig()
-
-
-    /**
-     * 修改救济金系统设置
-     *
-     * @access public
-     * @param mixed $where 查询条件
-     * @param mixed $data 数据
-     * @return array
-     */
-    public function upSystemconfig($where, $data)
-    {
-        // 查询救济金系统设置.
-        $systemconfigModel = new Models\Systemconfig;
-        $systemconfigModel = $systemconfigModel
-            ->where($where)
-            ->update($data);
-
-        return $systemconfigModel;
-
-    }//end upSystemconfig()
-
-
-}

+ 0 - 314
app/Http/Models/SportsAgent.php

@@ -1,314 +0,0 @@
-<?php
-
-namespace App\Http\Models;
-
-use Illuminate\Database\Eloquent\Model;
-use \App\Http\Models as HttpModel;
-use Illuminate\Support\Facades\DB;
-use \App\Models;
-
-/**
- * 赛事代理管理模型类
- */
-class SportsAgent extends Model
-{
-
-
-    /**
-     * 获取体育token
-     *
-     * @access public
-     * @param mixed $gmenuId 游戏ID
-     * @return string
-     */
-    public function getSportsToken($gmenuId)
-    {
-        $agentModel = new HttpModel\Agent;
-        // 获取数据库token.
-        $getAgentWhere = [
-            'agent_name' => 'sports',
-        ];
-        $getAgent = $agentModel->getAgent($getAgentWhere);
-        $agent_token = $getAgent && $getAgent->agent_token ? $getAgent->agent_token : '';
-        $updated_at = $getAgent && $getAgent->updated_at ? $getAgent->updated_at : '';
-        $newDate = date('Y-m-d H:i:s',strtotime('-20 hour'));
-        if ($agent_token && $updated_at > $newDate) {
-            session()->put('sportsToken', $agent_token);
-            return 1;
-        }
-        // 获取url及参数.
-        $getGameUrlWhere = [
-            'gmenu_id' => $gmenuId,
-            'gameUrl_type' => 'getSportsToken',
-        ];
-        $getGameUrl = $agentModel->getGameUrl($getGameUrlWhere);
-
-        // 获取Token传参.
-        $data = json_decode($getGameUrl->gameUrl_data);
-        // 获取Token url.
-        $url = $getGameUrl->gameUrl_url;
-        $dataString = '';
-        foreach ($data as $key => $value) {
-            $dataString .= '&' . $key . '=' . urlencode($value);
-        }
-        $commonModel = new HttpModel\Common;
-        // 获取token.
-        $getToken = $commonModel->make_request($url, $dataString);
-        if ($getToken && json_decode($getToken)->status === 1) {
-            // 存儲token
-            $updateAgentWhere = [
-                'agent_name' => 'sports',
-            ];
-            $agentModel->updateAgent($updateAgentWhere, json_decode($getToken)->data->token);
-            session()->put('sportsToken', json_decode($getToken)->data->token);
-            return 1;
-        } else {
-            return 2;
-        }
-
-    }//end getSportsToken()
-
-
-    /**
-     * 验证用户
-     *
-     * @access public
-     * @param mixed $gmenuId 游戏ID
-     * @param mixed $getMemberInfo 用户信息
-     * @return string
-     */
-    public function checkAccountSports($gmenuId, $getMemberInfo)
-    {
-        $agentModel = new HttpModel\Agent;
-        // 获取验证用户 url及参数.
-        $getGameUrlWhere = [
-            'gmenu_id' => $gmenuId,
-            'gameUrl_type' => 'sportsCheckAccount',
-        ];
-        $getGameUrl = $agentModel->getGameUrl($getGameUrlWhere);
-        // 获取验证用户传参.
-        $data = json_decode($getGameUrl->gameUrl_data);
-        // 获取验证用户url.
-        $url = $getGameUrl->gameUrl_url;
-        // 验证用户.
-        $paramsData = [
-            'agent' => $data->agent,
-            'username' => $getMemberInfo['name'],
-            'method' => $data->method,
-            'password' => $getMemberInfo['password'],
-        ];
-        $commonModel = new HttpModel\Common;
-        $checkAccountUrl = $commonModel->sportsAgentParams($paramsData, $url);
-        $checkAccountData = $commonModel->make_request($checkAccountUrl, '');
-        if ($checkAccountData && json_decode($checkAccountData)->status === 1) {
-            return 1;
-        } else {
-            return 2;
-        }
-
-    }//end loginSports()
-
-
-    /**
-     * 登陆体育
-     *
-     * @access public
-     * @param mixed $gmenuId 游戏ID
-     * @param mixed $getMemberInfo 用户信息
-     * @return string
-     */
-    public function loginSports($gmenuId, $getMemberInfo)
-    {
-        $agentModel = new HttpModel\Agent;
-        // 获取登陆 url及参数.
-        $getGameUrlWhere = [
-            'gmenu_id' => $gmenuId,
-            'gameUrl_type' => 'sportsLogin',
-        ];
-        $getGameUrl = $agentModel->getGameUrl($getGameUrlWhere);
-        // 获取登陆传参.
-        $data = json_decode($getGameUrl->gameUrl_data);
-        // 获取登陆url.
-        $url = $getGameUrl->gameUrl_url;
-        // 登陆.
-        $paramsData = [
-            'agent' => $data->agent,
-            'username' => $getMemberInfo['name'],
-            'method' => $data->method,
-            'password' => $getMemberInfo['password'],
-            'gametype' => $data->gameType,
-        ];
-        $commonModel = new HttpModel\Common;
-        $loginUrl = $commonModel->sportsAgentParams($paramsData, $url);
-        $loginData = $commonModel->make_request($loginUrl, '');
-        if ($loginData && json_decode($loginData)->status === 1) {
-            $tokenArr = json_decode(urldecode(json_decode($loginData)->data->token), true);
-            return [
-                'status' => 1,
-                'token' => json_decode($loginData)->data->token,
-                'tokenold' => $tokenArr['token'],
-                'url' => json_decode($loginData)->data->url,
-            ];
-        } else {
-            return 2;
-        }
-
-    }//end loginSports()
-
-
-    /**
-     * 体育转账
-     *
-     * @access public
-     * @param mixed $gmenuId 游戏ID
-     * @param mixed $money 金额
-     * @param mixed $cash 余额
-     * @param mixed $getMemberInfo 用户信息
-     * @param mixed $type IN转入OUT转出
-     * @return string
-     */
-    public function transferSports($gmenuId, $money, $cash, $getMemberInfo, $type)
-    {
-        $agentModel = new HttpModel\Agent;
-        // 扣去用户余额.
-        DB::beginTransaction();
-        $newUuid = getUUID();
-        $agentModel->updateMembersDetailed(['membersDetailed_cash' => $cash]);
-        // 添加转账记录.
-        if ($type === 'IN') {
-            $agentModel->addMoneyDetails($newUuid, $money, 2, $cash, '转账至体育赛事');
-        } elseif ($type === 'OUT') {
-            $agentModel->addMoneyDetails($newUuid, $money, 1, $cash, '体育赛事转回账户');
-        }
-        // 获取转账 url及参数.
-        $getGameUrlWhere = [
-            'gmenu_id' => $gmenuId,
-            'gameUrl_type' => 'sportsTransfer',
-        ];
-        $getGameUrl = $agentModel->getGameUrl($getGameUrlWhere);
-        // 获取转账传参.
-        $data = json_decode($getGameUrl->gameUrl_data);
-        // 获取转账url.
-        $url = $getGameUrl->gameUrl_url;
-        // 转账.
-        $transferParams = [
-            'agent' => $data->agent,
-            'username' => $getMemberInfo['name'],
-            'method' => $data->method,
-            'password' => $getMemberInfo['password'],
-            'billno' => $newUuid,
-            'credit' => $money,
-            'type' => $type,
-        ];
-        $commonModel = new HttpModel\Common;
-        $transferUrl = $commonModel->sportsAgentParams($transferParams, $url);
-        $transferData = $commonModel->make_request($transferUrl, '');
-        $self = $this;
-        if ($transferData && json_decode($transferData)->status === 1) {
-            DB::commit();
-            $self->seeSportsCash($gmenuId, $getMemberInfo);
-            return 1;
-        } else {
-            DB::rollBack();
-            return 2;
-        }
-    }//end transferSports()
-
-
-    /**
-     * 盈利
-     *
-     * @access public
-     * @param mixed $gmenuId 游戏ID
-     * @param mixed $money 金额
-     * @param mixed $cash 余额
-     * @param mixed $getMemberInfo 用户信息
-     * @param mixed $type IN转入OUT转出
-     * @return string
-     */
-    public function sportsProfit()
-    {
-        $agentModel = new HttpModel\Agent;
-        // 获取查询盈利 url及参数.
-        $getGameUrlWhere = [
-            'gmenu_id' => 7,
-            'gameUrl_type' => 'getSportsProfit',
-        ];
-        $getGameUrl = $agentModel->getGameUrl($getGameUrlWhere);
-        // 获取查询盈利传参.
-        $data = json_decode($getGameUrl->gameUrl_data);
-        // 获取查询盈利url.
-        $url = $getGameUrl->gameUrl_url;
-        // 查询盈利.
-        $transferParams = [
-            'agent' => $data->agent,
-            'method' => $data->method,
-        ];
-        $commonModel = new HttpModel\Common;
-        $transferUrl = $commonModel->sportsAgentParams($transferParams, $url);
-        $transferData = $commonModel->make_request($transferUrl, '');
-        if ($transferData && json_decode($transferData)->status === 1) {
-            return json_decode($transferData)->data;
-        } else {
-            return 2;
-        }
-    }//end transferSports()
-
-
-    /**
-     * 查看体育余额
-     *
-     * @access public
-     * @param mixed $gmenuId 游戏ID
-     * @param mixed $getMemberInfo 用户信息
-     * @return string
-     */
-    public function seeSportsCash($gmenuId, $getMemberInfo)
-    {
-        $agentModel = new HttpModel\Agent;
-        // 获取余额 url及参数.
-        $getGameUrlWhere = [
-            'gmenu_id' => $gmenuId,
-            'gameUrl_type' => 'sportsSeeCash',
-        ];
-        $getGameUrl = $agentModel->getGameUrl($getGameUrlWhere);
-        // 获取余额传参.
-        $data = json_decode($getGameUrl->gameUrl_data);
-        // 获取余额url.
-        $url = $getGameUrl->gameUrl_url;
-        // 查询余额.
-        $seeCashParams = [
-            'agent' => $data->agent,
-            'username' => $getMemberInfo['name'],
-            'method' => $data->method,
-            'password' => $getMemberInfo['password'],
-        ];
-        $commonModel = new HttpModel\Common;
-        $seeCashUrl = $commonModel->sportsAgentParams($seeCashParams, $url);
-        $seeCash = $commonModel->make_request($seeCashUrl, '');
-        if ($seeCash && json_decode($seeCash)->status === 1) {
-            // 将查询到的余额写入.
-            $gameMoneySelect = [
-                'gameMoney_id',
-            ];
-            $gameMoneyWhere = [
-                'members_id' => S('token_user_id'),
-                'gmenu_id' => $gmenuId,
-            ];
-            // 查询是否存在该记录.
-            $backData = $agentModel->seeGameMoney($gameMoneySelect, $gameMoneyWhere);
-            if (empty($backData) === true) {
-                $gameMoneyData = [
-                    'gameMoney_money' => json_decode($seeCash)->data,
-                    'members_id' => S('token_user_id'),
-                    'gmenu_id' => $gmenuId,
-                ];
-                $agentModel->addGameMoney($gameMoneyData);
-            } else {
-                $agentModel->updateGameMoney(json_decode($seeCash)->data, $gameMoneyWhere);
-            }
-        }
-    }//end transferSports()
-
-
-}

+ 0 - 128
app/Http/Models/UserInfo.php

@@ -1,128 +0,0 @@
-<?php
-
-namespace App\Http\Models;
-
-use Illuminate\Database\Eloquent\Model;
-use \App\Models;
-
-/**
- * 救济金模型类
- */
-class UserInfo extends Model
-{
-
-
-    /**
-     * 用户详细查询
-     *
-     * @access public
-     * @param mixed $where 查询条件
-     * @param mixed $select 查询字段
-     * @return array
-     */
-    public function userInfo($select, $where)
-    {
-        // 获取救济金记录.
-        $membersDetailedModel = new Models\MembersDetailed;
-        $result = $membersDetailedModel
-            ->select($select)
-            ->where($where)
-            ->first();
-
-        return $result;
-
-    }//end userInfo()
-
-
-    /**
-     * 用户详细多个查询
-     *
-     * @access public
-     * @param mixed $where 查询条件
-     * @param mixed $select 查询字段
-     * @return array
-     */
-    public function getUserInfo($select, $where)
-    {
-        // 获取救济金记录.
-        $membersDetailedModel = new Models\MembersDetailed;
-        $result               = $membersDetailedModel->select($select);
-        if (empty($where) === false) {
-            $result = $result->where($where);
-        }
-
-        $result = $result->get();
-
-        return $result;
-
-    }//end getUserInfo()
-
-
-    /**
-     * 用户详细多个查询
-     *
-     * @access public
-     * @param mixed $where 查询条件
-     * @param mixed $select 查询字段
-     * @return array
-     */
-    public function getAllUserInfo($select)
-    {
-        $membersDetailedModel = new Models\MembersDetailed;
-        $result               = $membersDetailedModel
-            ->select($select)
-            ->join('members', 'membersDetailed.members_id', 'members.id')
-            ->whereNotIn('membersDetailed_cash', [0])
-            ->get();
-
-        return $result;
-
-    }//end getAllUserInfo()
-
-
-    /**
-     * 用户游戏余额
-     *
-     * @access public
-     * @param mixed $where 查询条件
-     * @param mixed $select 查询字段
-     * @return array
-     */
-    public function gameMoney($select, $where)
-    {
-        // 获取救济金记录.
-        $gameMoneyModel = new Models\GameMoney;
-        $result         = $gameMoneyModel->select($select);
-        if (empty($where) === false) {
-            $result = $result->where($where);
-        }
-
-        $result = $result->get();
-
-        return $result;
-
-    }//end gameMoney()
-
-
-    /**
-     * 修改用户信息
-     *
-     * @access public
-     * @param mixed $where 查询条件
-     * @param mixed $data 修改数据
-     * @return array
-     */
-    public function upUserInfo($where, $data)
-    {
-        // 获取救济金记录.
-        $membersDetailedModel = new Models\MembersDetailed;
-        $result = $membersDetailedModel
-            ->where($where)
-            ->update($data);
-
-        return $result;
-
-    }//end upUserInfo()
-
-
-}

+ 0 - 16
app/Models/Activity.php

@@ -1,16 +0,0 @@
-<?php
-
-namespace App\Models;
-
-use Illuminate\Database\Eloquent\Model;
-
-/**
- * activity
- */
-class Activity extends Model
-{
-
-    protected $table = 'activity';
-
-
-}

+ 0 - 17
app/Models/Advert.php

@@ -1,17 +0,0 @@
-<?php
-
-namespace App\Models;
-
-use Illuminate\Database\Eloquent\Model;
-
-class Advert extends Model
-{
-
-    protected $fillable = ['title','thumb','link','position_id','sort','description'];
-    //广告所在的位置信息
-    public function position()
-    {
-        return $this->belongsTo('App\Models\Position');
-    }
-
-}

+ 12 - 0
app/Models/App.php

@@ -0,0 +1,12 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Model;
+
+class App extends Model
+{
+    protected $table = 'ag_app';
+
+
+}

+ 0 - 24
app/Models/Article.php

@@ -1,24 +0,0 @@
-<?php
-
-namespace App\Models;
-
-use Illuminate\Database\Eloquent\Model;
-
-class Article extends Model
-{
-    protected $fillable = ['category_id','title','keywords','description','content','thumb','click'];
-
-    //文章所属分类
-    public function category()
-    {
-        return $this->belongsTo('App\Models\Category');
-    }
-
-    //与标签多对多关联
-    public function tags()
-    {
-        return $this->belongsToMany('App\Models\Tag','article_tag','article_id','tag_id');
-    }
-
-
-}

+ 0 - 29
app/Models/Category.php

@@ -1,29 +0,0 @@
-<?php
-
-namespace App\Models;
-
-use Illuminate\Database\Eloquent\Model;
-
-class Category extends Model
-{
-    protected $fillable = ['name','sort','parent_id'];
-
-    //子分类
-    public function childs()
-    {
-        return $this->hasMany('App\Models\Category','parent_id','id');
-    }
-
-    //所有子类
-    public function allChilds()
-    {
-        return $this->childs()->with('allChilds');
-    }
-
-    //分类下所有的文章
-    public function articles()
-    {
-        return $this->hasMany('App\Models\Article');
-    }
-
-}

+ 0 - 11
app/Models/District.php

@@ -1,11 +0,0 @@
-<?php
-
-namespace App\Models;
-
-use Illuminate\Database\Eloquent\Model;
-
-class District extends Model
-{
-    protected $table = 'districts';
-    protected $fillable = ['citycode','adcode','name','center','level'];
-}

+ 0 - 16
app/Models/GameMoney.php

@@ -1,16 +0,0 @@
-<?php
-
-namespace App\Models;
-
-use Illuminate\Database\Eloquent\Model;
-
-/**
- * 数据库gameMoney模型类
- */
-class GameMoney extends Model
-{
-
-    protected $table = 'gameMoney';
-
-
-}

+ 0 - 16
app/Models/GameUrl.php

@@ -1,16 +0,0 @@
-<?php
-
-namespace App\Models;
-
-use Illuminate\Database\Eloquent\Model;
-
-/**
- * 数据库gameUrl模型类
- */
-class GameUrl extends Model
-{
-
-    protected $table = 'gameUrl';
-
-
-}

+ 0 - 16
app/Models/GetRelief.php

@@ -1,16 +0,0 @@
-<?php
-
-namespace App\Models;
-
-use Illuminate\Database\Eloquent\Model;
-
-/**
- * 救济金记录模型类
- */
-class GetRelief extends Model
-{
-
-    protected $table = 'getrelief';
-
-
-}

+ 0 - 16
app/Models/GetSign.php

@@ -1,16 +0,0 @@
-<?php
-
-namespace App\Models;
-
-use Illuminate\Database\Eloquent\Model;
-
-/**
- * 救济金记录模型类
- */
-class GetSign extends Model
-{
-
-    protected $table = 'getsign';
-
-
-}

+ 0 - 17
app/Models/Gmenu.php

@@ -1,17 +0,0 @@
-<?php
-
-namespace App\Models;
-
-use Illuminate\Database\Eloquent\Model;
-
-class Gmenu extends Model
-{
-    protected $table = 'gmenu';
-    protected $fillable =  ['id','parent_id','status','sort','gname','iconUrl','gaction','updated_at','isleaf'];
-
-    public function  getByPid($pid=0){
-        $data = $this->select('id','parent_id','gname','iconUrl','gaction','updated_at','isleaf')->where(['parent_id'=>$pid,'status'=>1])->orderby('sort','asc')->get()->toArray();
-        return $data;
-    }
-
-}

+ 0 - 17
app/Models/Icon.php

@@ -1,17 +0,0 @@
-<?php
-
-namespace App\Models;
-
-use Illuminate\Database\Eloquent\Model;
-
-class Icon extends Model
-{
-    protected $table = 'icons';
-    protected $fillable = ['unicode','class','name','sort'];
-
-    //对应菜单
-    public function menus()
-    {
-        return $this->hasMany('App\Models\Menu','icon_id','id');
-    }
-}

+ 0 - 17
app/Models/Message.php

@@ -1,17 +0,0 @@
-<?php
-
-namespace App\Models;
-
-use Illuminate\Database\Eloquent\Model;
-
-class Message extends Model
-{
-    protected $table = 'messages';
-    protected $fillable = ['title','content','read','send_uuid','accept_uuid','flag'];
-
-    public $read_status=[
-        '1'=>'未读',
-        '2'=>'已读'
-    ];
-
-}

+ 0 - 23
app/Models/MoneyDetails.php

@@ -1,23 +0,0 @@
-<?php
-
-namespace App\Models;
-
-use Illuminate\Database\Eloquent\Model;
-
-/**
- * 数据库moneyDetails模型类
- */
-class MoneyDetails extends Model
-{
-    protected $table = 'moneyDetails';
-
-    //查询用户交易记录
-    public function tradeRecord($member_id){
-        $record = $this->where(['members_id'=>$member_id])->orderby('moneyDetails_time','desc')->get();
-        if(!empty($record)){
-            $record->toArray();
-            return $record;
-        }
-        return [];
-    }
-}

+ 0 - 14
app/Models/Notice.php

@@ -1,14 +0,0 @@
-<?php
-
-namespace App\Models;
-
-use Illuminate\Database\Eloquent\Model;
-
-class Notice extends Model
-{
-    protected $table = 'notice';
-    function notice_info() {
-        $info = $this->select('title','type','content')->get();
-        return $info;
-    }
-}

+ 12 - 0
app/Models/Party.php

@@ -0,0 +1,12 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Model;
+
+class Party extends Model
+{
+    protected $table = 'ag_party';
+
+
+}

+ 0 - 20
app/Models/Permission.php

@@ -1,20 +0,0 @@
-<?php
-namespace App\Models;
-
-class Permission extends \Spatie\Permission\Models\Permission
-{
-
-
-    //菜单图标
-    public function icon()
-    {
-        return $this->belongsTo('App\Models\Icon','icon_id','id');
-    }
-
-    //子权限
-    public function childs()
-    {
-        return $this->hasMany('App\Models\Permission','parent_id','id');
-    }
-
-}

+ 0 - 16
app/Models/Position.php

@@ -1,16 +0,0 @@
-<?php
-
-namespace App\Models;
-
-use Illuminate\Database\Eloquent\Model;
-
-class Position extends Model
-{
-    protected $fillable = ['name','sort'];
-    //该位置下所有的广告
-    public function adverts()
-    {
-        return $this->hasMany('App\Models\Advert');
-    }
-
-}

+ 0 - 7
app/Models/Role.php

@@ -1,7 +0,0 @@
-<?php
-namespace App\Models;
-
-class Role extends \Spatie\Permission\Models\Role
-{
-
-}

+ 0 - 17
app/Models/Sign.php

@@ -1,17 +0,0 @@
-<?php
-
-namespace App\Models;
-
-use Illuminate\Database\Eloquent\Model;
-
-/**
- * 救济金记录模型类
- */
-class Sign extends Model
-{
-
-    protected $table = 'sign';
-    const UPDATED_AT = null;
-
-
-}

+ 0 - 11
app/Models/Site.php

@@ -1,11 +0,0 @@
-<?php
-
-namespace App\Models;
-
-use Illuminate\Database\Eloquent\Model;
-
-class Site extends Model
-{
-    protected $table = 'sites';
-    protected $guarded = ['id'];
-}

+ 0 - 16
app/Models/Systemconfig.php

@@ -1,16 +0,0 @@
-<?php
-
-namespace App\Models;
-
-use Illuminate\Database\Eloquent\Model;
-
-/**
- * 系统设置模型类
- */
-class Systemconfig extends Model
-{
-
-    protected $table = 'systemconfig';
-    const UPDATED_AT = null;
-
-}

+ 0 - 17
app/Models/Tag.php

@@ -1,17 +0,0 @@
-<?php
-
-namespace App\Models;
-
-use Illuminate\Database\Eloquent\Model;
-
-class Tag extends Model
-{
-    protected $fillable = ['name','sort'];
-
-    //与文章多对多关联
-    public function articles()
-    {
-        return $this->belongsToMany('App\Models\Article','article_tag','tag_id','article_id');
-    }
-
-}

+ 0 - 84
app/Vendor/Jwt.php

@@ -5,53 +5,6 @@ namespace App\Vendor;
  */
 class Jwt {
 
-    //头部
-    private static $header=array(
-        'alg'=>'HS256', //生成signature的算法
-        'typ'=>'JWT'    //类型
-    );
-
-    //使用HMAC生成信息摘要时所使用的密钥
-    private static $key='123456';
-
-
-    /**
-     * 获取jwt token
-     * @param array $payload jwt载荷   格式如下非必须
-     * [
-     *  'iss'=>'jwt_admin',  //该JWT的签发者
-     *  'iat'=>time(),  //签发时间
-     *  'exp'=>time()+7200,  //过期时间
-     *  'nbf'=>time()+60,  //该时间之前不接收处理该Token
-     *  'sub'=>'www.admin.com',  //面向的用户
-     *  'jti'=>md5(uniqid('JWT').time())  //该Token唯一标识
-     * ]
-     * @return bool|string
-     */
-    public static function _getToken(array $payload)
-    {
-        if(is_array($payload))
-        {
-            $base64header=self::base64UrlEncode(json_encode(self::$header,JSON_UNESCAPED_UNICODE));
-            $base64payload=self::base64UrlEncode(json_encode($payload,JSON_UNESCAPED_UNICODE));
-            $token=$base64header.'.'.$base64payload.'.'.self::signature($base64header.'.'.$base64payload,self::$key,self::$header['alg']);
-            return $token;
-        }else{
-            return false;
-        }
-    }
-
-    public static function getToken($uid){
-        $playload=[
-               'iss'=>'born',  //该JWT的签发者
-               'iat'=>time(),  //签发时间
-               'exp'=>time()+7200,  //过期时间
-               'nbf'=>time()+60,  //该时间之前不接收处理该Token
-               'sub'=>$uid,  //面向的用户
-               'jti'=>getUUID(),  //该Token唯一标识
-        ];
-        return self::_getToken($playload);
-   }
 
     /**
      * 验证token是否有效,默认验证exp,nbf,iat时间
@@ -95,43 +48,6 @@ class Jwt {
 
 
 
-    /**
-     * base64UrlEncode   https://jwt.io/  中base64UrlEncode编码实现
-     * @param string $input 需要编码的字符串
-     * @return string
-     */
-    private static function base64UrlEncode(string $input)
-    {
-        return str_replace('=', '', strtr(base64_encode($input), '+/', '-_'));
-    }
 
-    /**
-     * base64UrlEncode  https://jwt.io/  中base64UrlEncode解码实现
-     * @param string $input 需要解码的字符串
-     * @return bool|string
-     */
-    private static function base64UrlDecode(string $input)
-    {
-        $remainder = strlen($input) % 4;
-        if ($remainder) {
-            $addlen = 4 - $remainder;
-            $input .= str_repeat('=', $addlen);
-        }
-        return base64_decode(strtr($input, '-_', '+/'));
-    }
 
-    /**
-     * HMACSHA256签名   https://jwt.io/  中HMACSHA256签名实现
-     * @param string $input 为base64UrlEncode(header).".".base64UrlEncode(payload)
-     * @param string $key
-     * @param string $alg   算法方式
-     * @return mixed
-     */
-    private static function signature(string $input, string $key, string $alg = 'HS256')
-    {
-        $alg_config=array(
-            'HS256'=>'sha256'
-        );
-        return self::base64UrlEncode(hash_hmac($alg_config[$alg], $input, $key,true));
-    }
 }

+ 1 - 0
routes/api.php

@@ -19,6 +19,7 @@ Route::any('/{class}/{action}', function ( $class, $action) {
 	return appExec($module, $class, $action);
 })->middleware('auth.jwt');
 
+
 // Route::middleware('auth:api')->get('/user', function (Request $request) {
     
 //     return $request->user();

+ 2 - 21
routes/web.php

@@ -1,28 +1,9 @@
 <?php
-//文件上传接口,前后台共用
-Route::post('uploadImg', 'PublicController@uploadImg')->name('uploadImg');
-//发送短信
-Route::post('/sendMsg', 'PublicController@sendMsg')->name('sendMsg');
 
-Route::get('/','Home\IndexController@index')->name('home');
 
-//支付
-Route::group(['namespace' => 'Home'], function () {
-    //微信支付
-    Route::get('/wechatPay', 'PayController@wechatPay')->name('wechatPay');
-    //微信支付回调
-    Route::post('/wechatNotify', 'PayController@wechatNotify')->name('wechatNofity');
-});
 
-//会员-不需要认证
-Route::group(['namespace'=>'Home','prefix'=>'member'],function (){
-    //注册
-    Route::get('register', 'MemberController@showRegisterForm')->name('home.member.showRegisterForm');
-    Route::post('register', 'MemberController@register')->name('home.member.register');
-    //登录
-    Route::get('login', 'MemberController@showLoginForm')->name('home.member.showLoginForm');
-    Route::post('login', 'MemberController@login')->name('home.member.login');
-});
+
+
 //会员-需要认证
 Route::group(['namespace'=>'Home','prefix'=>'member','middleware'=>'member'],function (){
     //个人中心