Ver Fonte

切换版本

彭俊 há 6 anos atrás
pai
commit
61ad5c2300
100 ficheiros alterados com 11826 adições e 0 exclusões
  1. 8 0
      .htaccess
  2. 0 0
      .tgitconfig
  3. 762 0
      Application/Api/Controller/Account.php
  4. 60 0
      Application/Api/Controller/BaseController.php
  5. 591 0
      Application/Api/Controller/Betorder.php
  6. 37 0
      Application/Api/Controller/Close.php
  7. 24 0
      Application/Api/Controller/Common.php
  8. 162 0
      Application/Api/Controller/Money.php
  9. 982 0
      Application/Api/Controller/Nologin.php
  10. 411 0
      Application/Api/Controller/Notice.php
  11. 919 0
      Application/Api/Controller/Other.php
  12. 133 0
      Application/Api/Controller/Settings.php
  13. 69 0
      Application/Api/Controller/Signin.php
  14. 50 0
      Application/Api/Controller/SystemInfo.php
  15. 27 0
      Application/Api/Controller/Token.php
  16. 191 0
      Application/Api/Controller/UserBuy.php
  17. 833 0
      Application/Api/Controller/UserDetails.php
  18. 307 0
      Application/Api/Controller/UserGrade.php
  19. 27 0
      Application/Api/Controller/Uuid.php
  20. 27 0
      Application/Api/Lang/AndroidConf.php
  21. 5 0
      Application/Api/Lang/Api-notice.php
  22. 24 0
      Application/Api/Lang/Common.php
  23. 474 0
      Application/Api/Lang/Errors.php
  24. 86 0
      Application/Api/Lang/Faces.php
  25. 5 0
      Application/Api/Lang/Index.php
  26. 18 0
      Application/Api/Lang/IosConf.php
  27. 128 0
      Application/Api/Lang/OddsTemp.php
  28. 27 0
      Application/Api/Lang/TradeType.php
  29. 106 0
      Application/Api/Model/Account.php
  30. 100 0
      Application/Api/Model/AccountDetail.php
  31. 62 0
      Application/Api/Model/AccountNews.php
  32. 17 0
      Application/Api/Model/Advert.php
  33. 14 0
      Application/Api/Model/Article.php
  34. 18 0
      Application/Api/Model/ArticleType.php
  35. 14 0
      Application/Api/Model/BandBank.php
  36. 17 0
      Application/Api/Model/Banner.php
  37. 16 0
      Application/Api/Model/BetStr.php
  38. 15 0
      Application/Api/Model/Chat_redbag.php
  39. 242 0
      Application/Api/Model/Chat_rooms.php
  40. 16 0
      Application/Api/Model/Chat_users.php
  41. 14 0
      Application/Api/Model/Lottery_money.php
  42. 78 0
      Application/Api/Model/Lottery_money_log.php
  43. 14 0
      Application/Api/Model/Lottery_type.php
  44. 156 0
      Application/Api/Model/LuckyMoney.php
  45. 187 0
      Application/Api/Model/LuckyMoneyTake.php
  46. 534 0
      Application/Api/Model/MoneyBuy.php
  47. 16 0
      Application/Api/Model/MoneyBuyDetail.php
  48. 16 0
      Application/Api/Model/MoneyBuyMatch.php
  49. 16 0
      Application/Api/Model/MoneyBuySimplex.php
  50. 16 0
      Application/Api/Model/MoneyBuyStr.php
  51. 14 0
      Application/Api/Model/MoneyCount.php
  52. 14 0
      Application/Api/Model/MoneyDetails.php
  53. 16 0
      Application/Api/Model/MoneyFlowCount.php
  54. 54 0
      Application/Api/Model/MoneyPrize.php
  55. 151 0
      Application/Api/Model/MoneyRecharge.php
  56. 14 0
      Application/Api/Model/MoneyRechargeRemark.php
  57. 14 0
      Application/Api/Model/Payment.php
  58. 14 0
      Application/Api/Model/SetInfo.php
  59. 65 0
      Application/Api/Model/SixmoneyBuy.php
  60. 15 0
      Application/Api/Model/St_bet_order.php
  61. 21 0
      Application/Api/Model/St_odds_code.php
  62. 16 0
      Application/Api/Model/SystemAppupdate.php
  63. 19 0
      Application/Api/Model/SystemRed.php
  64. 14 0
      Application/Api/Model/System_routes.php
  65. 14 0
      Application/Api/Model/System_routes_category.php
  66. 293 0
      Application/Api/Model/UserGrade.php
  67. 40 0
      Application/Api/Model/UserSetting.php
  68. 14 0
      Application/Api/Model/User_log_record.php
  69. 14 0
      Application/Api/Model/User_vip.php
  70. 112 0
      Application/Api/Model/Withdraw.php
  71. 88 0
      Application/Api/Model/Withdraw_rule.php
  72. 14 0
      Application/Api/Model/Xy28_buy.php
  73. 18 0
      Application/Commons/Controller/BaseController.php
  74. 49 0
      Application/Commons/Controller/Validation.php
  75. 1008 0
      Application/Commons/Lang/Common.php
  76. 33 0
      Application/Commons/Model/Account.php
  77. 15 0
      Application/Commons/Model/AccountList.php
  78. 31 0
      Application/Commons/Model/Account_bank.php
  79. 159 0
      Application/Commons/Model/Account_detailed.php
  80. 95 0
      Application/Commons/Model/Account_news.php
  81. 46 0
      Application/Commons/Model/Account_password.php
  82. 22 0
      Application/Commons/Model/Account_token.php
  83. 14 0
      Application/Commons/Model/Band_bank.php
  84. 14 0
      Application/Commons/Model/Bank.php
  85. 22 0
      Application/Commons/Model/Banner.php
  86. 15 0
      Application/Commons/Model/Comendnotice.php
  87. 15 0
      Application/Commons/Model/Dc_user_grade.php
  88. 15 0
      Application/Commons/Model/Logfile.php
  89. 89 0
      Application/Commons/Model/Message.php
  90. 14 0
      Application/Commons/Model/Message_read.php
  91. 60 0
      Application/Commons/Model/Money_buy.php
  92. 21 0
      Application/Commons/Model/Money_buy_detail.php
  93. 186 0
      Application/Commons/Model/Money_buy_match.php
  94. 140 0
      Application/Commons/Model/Money_buy_simplex.php
  95. 151 0
      Application/Commons/Model/Money_buy_str.php
  96. 22 0
      Application/Commons/Model/Money_details.php
  97. 58 0
      Application/Commons/Model/Money_prize.php
  98. 209 0
      Application/Commons/Model/Money_recharge.php
  99. 97 0
      Application/Commons/Model/Money_record.php
  100. 107 0
      Application/Commons/Model/Money_take.php

+ 8 - 0
.htaccess

@@ -0,0 +1,8 @@
+RewriteEngine On
+
+RewriteCond %{REQUEST_FILENAME} !-f
+RewriteCond %{REQUEST_FILENAME} !-d
+
+RewriteRule ^.*$ index.php [L]
+RewriteRule ^Library|_Route|Application|Cache|Config|vendor index.php [L]
+

+ 0 - 0
.tgitconfig


+ 762 - 0
Application/Api/Controller/Account.php

@@ -0,0 +1,762 @@
+<?php
+/**
+ *------Create thems Controller------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-08 10:07:19------
+ */
+
+namespace App\Api\Controller;
+
+use App\Api\Model\Lottery_money;
+use App\Api\Model\Lottery_money_log;
+
+use Biz\Account\AccountManager;
+use Biz\Common\Common;
+use Biz\Game\GameList;
+use System\Lang;
+use App\Api\Model\AccountDetail;
+use App\Api\Model\AccountNews;
+
+
+class Account extends BaseController {
+    private $accountManager;
+
+    public function init() {
+        $this->accountManager = new AccountManager();
+    }
+
+    /**
+     * 验证用户资金密码
+     */
+    public function checkPayPass() {
+        $payPass = $_POST['payPass'];
+        $token = $_GET['token'] ?? '';
+        if (empty($token)) {
+            Render('5555', '-4010', lang('errors')->get('-4010'));
+        }
+        $status = \App\Api\Model\Account::checkPayPwd($token, $payPass);
+        $data = new \stdClass();
+        Render($data, $status);
+    }
+
+    /**
+     * 用户登录
+     */
+    public function Login() {
+        $result = $this->accountManager->login($_POST['account'], $_POST['password']);
+
+        //$result = $this->accountManager->login('x0053', '123456');
+
+        /*if ($result['status'] == 1) {
+            $this->UserUpgrade();
+        }*/
+        Render($result['data'], $result['status'], $result['msg']);
+    }
+
+    /**
+     * 用户修改密码
+     */
+    public function resetPassword() {
+        $result = $this -> accountManager -> savePassword($_POST);
+        Render($result['data'], $result['status'], $result['msg']);
+    }
+
+    /**
+     * 用户修改支付密码
+     */
+    public function resetPayPassword() {
+        $result = $this -> accountManager -> savePayPassword();
+        Render($result['data'], $result['status'], $result['msg']);
+    }
+
+    /**
+     * 用户注册
+     */
+    public function enroll() {
+        $account_name = $_POST['account'];
+//        if (stripos($_POST['account_name'],'guest') === false){
+////                var_dump($v['account_name']);
+//            Render('',-4101);
+//        }
+        $result = $this->accountManager->register($_POST);
+        if ($result['status'] == 1) {
+            $settings = lm('settings', 'Commons')->first();
+            $result['data']['0']['success_tip'] = $settings->success_tip;
+        }
+
+        Render($result['data'], $result['status'], $result['msg']);
+    }
+
+    /**
+     * 直接开户
+     */
+    public function directAccount() {
+        $result = $this->accountManager->directAccountOpening($_POST);
+        Render($result['data'], $result['status'], $result['msg']);
+    }
+
+    /**
+     * token获取用户详情
+     */
+    public function getAccount() {
+        if ($_REQUEST['dbg'] == 1) dd($_SESSION);
+        $checkToken = $this->accountManager->checkEffectiveTime();
+        if ($checkToken['status'] != 1) {
+            Render($checkToken['data'], $checkToken['status'], $checkToken['msg']);
+        };
+        $result = $this->accountManager->refreshToken();
+        //删除不需要的字段
+        unset($result['data']['token']);
+        unset($result['data']['finance_cash']);
+        unset($result['data']['parent_id']);
+        unset($result['data']['parent_path']);
+        unset($result['data']['hand_pass']);
+        if (!empty($result)) {
+            $find_name = lm('dc_user_grade', 'commons')->where('grade', $result['data']['grade'])->first();
+            if (!empty($find_name)) {
+                $res = $find_name->toArray();
+                $result['data']['vname'] = $res['name'];
+
+            }
+        }
+        $result['data']['qq'] = trim($result['data']['qq']);
+        if (!$result['data']['img_url']) {
+            $result['data']['img_url'] = $result['data']['img_id'] ? "/Public/themes/default/static/img/{$result['data']['img_url']}.png" : "/Public/themes/default/static/img/0.png";
+        }
+        Render($result['data'], $result['status'], $result['msg']);
+    }
+
+    /**
+     * 用户退出登录
+     */
+    public function Logout() {
+        $account = $this->accountManager->getCurrentUser();
+
+        if ($account) {
+            $result = $this->accountManager->logout($account->account_identity);
+            Render($result['data'], $result['status'], $result['msg']);
+        } else {
+            Render('', -1);
+        }
+    }
+
+    /**
+     * 试玩用户注册
+     */
+    public function Playtest() {
+        $ip = GETIP();
+
+        $time = lm('Setinfo', 'commons')->select('infocontent')->where('status', 1)->where('infotype', '2000')->first();
+        $time = $time->toArray();
+        // $limit_time = date ('Y-m-d H:i:s', strtotime ('-3day'));
+        $limit_time = date('Y-m-d H:i:s', strtotime('-' . $time['infocontent'] . 'hour'));
+
+        $res = lm('account_detailed', 'commons')->join('account', 'account.identity', 'account_detailed.account_identity')->where('account.status', 4)->where('register_ip', $ip)->where('register_time', '>', $limit_time)->first();
+        if ($res) {
+            Render('', -4025);
+        }
+        $result = $this->accountManager->demoAccount();
+        Render($result['data'], $result['status'], $result['msg']);
+    }
+
+    /**
+     * 判断是否已绑定银行卡
+     */
+    public function Iscard() {
+        $result = $this->accountManager->Iscard();
+        Render($result['data'], $result['status'], $result['msg']);
+    }
+
+    /**
+     * 申请代理用户
+     */
+    public function applyAgent() {
+        $result = $this->accountManager->applyAgent($_POST);
+        Render('', $result, lang('errors')->get($result));
+    }
+
+    /**
+     * 代理用户登录
+     */
+    public function agentLogin() {
+        $result = $this->accountManager->agentLogin($_POST);
+        if ($result < 0) {
+            Render('', $result);
+        } else {
+            Render($result, 1, lang('errors')->get(1));
+        }
+    }
+
+    /**
+     * 代理用户token是否过期
+     */
+    public function agentTokenOverdue() {
+
+        $token = isset($_GET['token']) ? $_GET['token'] : '';
+        $result = $this->accountManager->agentTokenOverdue($token);
+        if ($result < 0) {
+            Render('', $result, lang('errors')->get($result));
+        } else {
+            Render($result, 1, lang('errors')->get(1));
+        }
+    }
+
+    /**
+     *登录添加登录区域日志
+     */
+    public function areaLog() {
+        $result = $this->accountManager->areaLog($_GET['ip'], $_GET['accountIdentity']);
+        if ($result == 1) {
+            Render('', $result, '成功');
+        } else {
+            Render('', $result, '添加登录日志区域错误');
+        }
+    }
+
+    /**
+     * 获取用户信息
+     */
+    function getAccountInfo() {
+        $data = array();
+        $data = $_SESSION['uinfo'];
+        $bankInfo = lm('account_bank', 'commons')->where('account_identity', $_SESSION['uinfo']['account_identity'])->first();
+        if (empty($bankInfo)) {
+            Render('', -40451);
+        }
+        $bankInfo = $bankInfo->toArray();
+        $data['bank_name'] = $bankInfo['bank_name'];
+        $data['bank_address'] = $bankInfo['bank_address'];
+        $data['bank_number'] = $bankInfo['bank_number'];
+        Render($data, 1);
+    }
+
+    /**
+     * token获取用户详情
+     */
+    public function getAgent() {
+        $checkToken = $this->accountManager->checkEffectiveTime();
+
+        if ($checkToken['status'] != 1) {
+            Render($checkToken['data'], $checkToken['status'], lang('commons')->get('user does login'));
+        };
+
+        $result = $this->accountManager->refreshToken();
+        Render($result['data'], $result['status'], $result['msg']);
+    }
+
+    /**
+     * 等级升级申请
+     * @return [type] [description]
+     */
+    public function UserUpgrade(int $total_flow = 0) {
+
+        $uinfo = $this->accountManager->getCurrentUser();
+        if (!$uinfo) {
+            return '-50003';
+        }
+        $result['data'] = $uinfo->toArray();
+        if ($result['data']['grade'] == 0 || $result['data']['grade'] == -1) {
+            return '-50019';
+        }
+        $res = lm('UserGrade', 'Api')->upgrade($result['data'], $total_flow);
+        if ($res == 1) {
+            return 1;
+        } else {
+            return $res;
+        }
+
+    }
+
+    /**
+     * 活动升级彩金公用接口
+     * @return [type] [description]
+     */
+    public function Promotiongold() {
+        $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : "";
+        if (empty($id)) {
+            Render('', "-50009");
+        }
+        $wherel['id'] = $id;
+        $Promotiong = lm('lottery_money', 'Api')->where($wherel)->first();
+        if (empty($Promotiong)) {
+            Render('', "-50010");
+        }
+
+        $Promotiong = $Promotiong->toArray();
+        if ($Promotiong['type'] == 'upgrade') {
+            $this->rank($id);
+        } elseif ($Promotiong['type'] == 'first_save') {
+            $utype = $_REQUEST['per_key'];
+            if (!$utype) {
+                Render('', -50025);
+            }
+            $this->firstRecharge($id, $utype);
+        }
+    }
+
+    //晋级彩金
+    public function rank($id) {
+        $uinfo = $this->accountManager->getCurrentUser();
+        if (!$uinfo) {
+            return '-50003';
+        }
+        $result['data'] = $uinfo->toArray();
+        if ($result['data']['grade'] == 0 || $result['data']['grade'] == '-1') {
+            return Render('', '-50035');
+        }
+        $res = lm('UserGrade', 'Api')->gold($result['data'], $id);
+        if ($res == 1) {
+            return Render('', 1);
+        } else {
+            return Render('', $res);
+        }
+
+    }
+
+    protected function firstRecharge($active_id, $utype = '') {
+        $uinfo = $this->accountManager->getCurrentUser();
+        if (!$uinfo) {
+            Render('', -50011);
+        }
+        $userinfo = $uinfo->toArray();
+        //$userinfo = lm ('AccountDetail', 'Api')->where ('account_identity', $uinfo['account_identity'])->first ();
+        $account = $userinfo['account'];
+        $account_identity = $userinfo['account_identity'];
+        $lm = new Lottery_money();
+        $type = 'first_save';
+        $data = $lm->where('id', $active_id)->first()->toArray();
+        if (!$data)
+            Render('', -50016);
+        $money = 0;
+        //todo:首充检查并返回金额
+        $content = json_decode($data['conent'], 1);
+        $ftype = $content['fr_type'];
+        $f = \App\Api\Model\Account::chkFirstRecharge($account_identity, $active_id, $ftype);
+        $order_id = $f->order_id;
+        $activeName = Lottery_money::where('id', $active_id)->first(['name'])->name ?? '';
+        $Lottery_log = new Lottery_money_log();
+        //查询申请记录
+        $where = [
+            ['account_identity', $account_identity],
+            ['order_id', $order_id],
+            ['status', '<>', 2]
+        ];
+        //需要逻辑:查询当前用户当前订单号是否有参与当前活动
+        $active = $Lottery_log->where($where)->first();
+        if ($active) {
+            Render('', -50034);
+        }
+        $money = $f->money;
+        $ranges = json_decode($data['conent'], 1)['ranges'];
+        $sel = (function ($param, $num, $type) {
+            foreach ($param as $k => $v) {
+                if ($v[5] == $type && $num >= $v[0])
+                    return $v;
+            }
+            return [];
+        })($ranges, $money, $utype);
+        if (!$sel)
+            Render('', -50016);//无活动数据
+        $giftMoney = $money * ($sel[2] / 100);
+        if ($giftMoney > (float)$sel[3])
+            $giftMoney = $sel[3];
+        $totalMoney = $giftMoney + $money;
+        $rate = $sel[2];
+        $frate = $sel[4];
+        $needMoney = $totalMoney * $frate;
+        $newremark = ['gift_money' => $giftMoney, 'money' => $money, 'needBettingMoney' => $needMoney, 'frate' => $sel[2] / 100, 'rate' => $sel[4]];
+        $tpl = lang('money')->get('first');
+        $grade = $sel[5];
+        $newremark['selected'] = $grade;
+        $detail = sprintf($tpl, $account, $activeName, $money, $rate, $giftMoney, $grade, $frate, $order_id);
+        $newremark = json_encode($newremark);
+        if (!$active) {
+            {
+                $data = [];
+                $data['account_identity'] = $account_identity;
+                $data['grade'] = $userinfo["grade"];
+                $data['lottery_money_type'] = $type;
+                $data['lottery_money_id'] = $active_id;
+                $data['money'] = $giftMoney;
+                $data['create_time'] = date('Y-m-d H:i:s');
+                $data['status'] = 0;
+                $data['detail'] = $detail ?? '无';
+                $data['account_name'] = $account;
+                $data['lottery_money_name'] = $activeName;
+                $data['flow_record'] = $newremark ?? '';
+                $data['order_id'] = $order_id;
+                $res = lm('lottery_money_log', 'Api')->insert($data);
+            }
+            if ($res) Render('', 1);
+        }
+        Render('', -30018);
+    }
+
+    public function analysis($str = '', $arr = array()) {
+        if (empty($str)) {
+            return -51055;
+        }
+        if (empty($arr)) {
+            return -51055;
+        }
+        foreach ($arr as $key => $value) {
+            $str = str_replace("#" . $key . "#", $value, $str);
+        }
+
+        return $str;
+    }
+
+
+    //申请vip
+    public function ApplyVip() {
+        $result = $this->accountManager->refreshToken();
+        if ($result['status'] < 0) {
+            Render('', "-50011");
+        }
+        if ($result['data']['grade'] > 0) {
+            Render('', "-50028");
+        }
+        if ($result['data']['grade'] != 0) {
+            Render('', "-50028");
+        }
+
+        //试玩账号 --2019/1/15 17/14 blues
+        if (isset($result['data']['status']) && $result['data']['status'] == 4) {
+            Render('', -4026);
+        }
+        $num = lm('User_vip', 'Api')->where('account_identity', $result['data']['account_identity'])->count();
+        if ($num == 0) {
+            $data['account_name'] = $result['data']['account'];
+            $data['account_identity'] = $result['data']['account_identity'];
+            $data['addtime'] = date('Y-m-d H:i:s');
+            $data['status'] = 1;
+            $res = lm('User_vip', 'Api')->insert($data);
+            if ($res) {
+                lm('AccountDetail', 'Api')->where('account_identity', $result['data']['account_identity'])->update(['grade' => -1]);
+                Render('', '1');
+            } else {
+                Render('', "-50026");
+            }
+        } else {
+            if ($result['data']['grade'] == 0) {
+                lm('User_vip', 'Api')->where('account_identity', $result['data']['account_identity'])->update(['status' => 1]);
+                lm('AccountDetail', 'Api')->where('account_identity', $result['data']['account_identity'])->update(['grade' => -1]);
+                Render('', '1');
+            } else {
+                Render('', "-50036");
+            }
+        }
+
+
+    }
+
+    //开新用户
+    public function households() {
+
+        if (empty($_POST['account'])) {
+            Render('', "-50060", '缺少用户名称');
+        }
+        if (empty($_POST['name'])) {
+            Render('', "-50061", '缺少真实用户名称');
+        }
+        if (empty($_POST['password'])) {
+            Render('', "-50062", '缺少密码');
+        }
+        if (empty($_POST['again_password'])) {
+            Render('', "-50063", '缺少确定密码');
+        }
+        if ($_POST['password'] != $_POST['again_password']) {
+            Render('', "-50064", '确定密码不一致');
+        }
+        if (empty($_POST['phone'])) {
+            Render('', "-50065", '缺少手机号码');
+        }
+        $this->checkLogin();
+        $uinfo = $this->accountManager->getCurrentUser();
+        if (empty($uinfo->account_identity)) {
+            Render('', "-50066", '用户未登录');
+        }
+        $_POST['parent_identity'] = $uinfo->account_identity;
+        $result = $this->accountManager->newhouseholds($_POST);
+        Render($result['data'], $result['status'], $result['msg']);
+    }
+
+    protected function checkLogin() {
+        $checkToken = $this->accountManager->checkEffectiveTime();
+        if ($checkToken['status'] != 1) {
+            Render($checkToken['data'], $checkToken['status'], $checkToken['msg']);
+        };
+        $this->accountManager->refreshToken();
+    }
+
+    public function checkHandPass() {
+        $hand_pass = $_REQUEST['hand_pass'];
+        $this->checkLogin();
+        $uinfo = $this->accountManager->getCurrentUser();
+        $uuid = $uinfo->account_identity;
+        if ($uuid) {
+            $ret = lm('UserSetting', 'api')->getUserSetting($uuid);
+            //dd($ret);
+            if ($ret && isset($ret['hand_pass']) && $ret['hand_pass']) {
+                if (!$ret['hand_lock'])
+                    Render('' - 60002);//未开启手势密码
+                if ($ret['hand_pass'] === md5($hand_pass))
+                    Render('', 1);
+                Render('', -60000);//手势密码不匹配
+            } else
+                Render('', -60001);//未设置手势密码
+        }
+        Render('', -51017);//用户不存在
+    }
+
+    public function getUserSetting() {
+        $this->checkLogin();
+        $uinfo = $this->accountManager->getCurrentUser();
+        $uuid = $uinfo->account_identity;
+        $ret = lm('UserSetting', 'api')->getUserSetting($uuid);
+        if ($_REQUEST['devicetype'] === 'android' || $_REQUEST['devicetype'] === 'ios') {
+            $ret['fav_info'] = json_decode($ret['fav_info'], 1) ?? [];
+            $ret['cart_info'] = json_decode($ret['cart_info'], 1) ?? [];
+        }
+        Render($ret, 1);
+    }
+
+    public function setUserSetting() {
+        $this->checkLogin();
+        $uinfo = $this->accountManager->getCurrentUser();
+        //if ($uinfo && $uinfo->account_identity)
+        $uuid = $uinfo->account_identity;
+        if (isset($_POST['hand_pass']) && $_POST['hand_pass'] != '') $data ['hand_pass'] = md5($_POST['hand_pass']);
+        if (isset($_POST['hand_lock']) && $_POST['hand_lock'] != '') $data ['hand_lock'] = $_POST['hand_lock'];
+        if (isset($_POST['sound']) && $_POST['sound'] != '') $data ['sound'] = $_POST['sound'];
+        if (isset($_POST['shake_rand']) && $_POST['shake_rand'] != '') $data ['shake_rand'] = $_POST['shake_rand'];
+        if (isset($_POST['prize_ani']) && $_POST['prize_ani'] != '') $data ['prize_ani'] = $_POST['prize_ani'];
+        if (isset($_POST['prize_all']) && $_POST['prize_all'] != '') $data ['prize_all'] = $_POST['prize_all'];
+        if (isset($_POST['win_games']) && $_POST['win_games'] != '') $data ['win_games'] = $_POST['win_games'];
+        if (isset($_POST['prize_games']) && $_POST['prize_games'] != '') $data ['prize_games'] = $_POST['prize_games'];
+        if (isset($_POST['fav_info']) && $_POST['fav_info'] != '') $data ['fav_info'] = ($_POST['fav_info']);
+        if (isset($_POST['cart_info']) && $_POST['cart_info'] != '') $data ['cart_info'] = ($_POST['cart_info']);
+        if (isset($_POST['device_state']) && $_POST['device_state'] != '') $data ['device_state'] = ($_POST['device_state']);
+        if (isset($_POST['device_number']) && $_POST['device_number'] != '') $data ['device_number'] = ($_POST['device_number']);
+        if ($data['prize_games'] == -1) $data['prize_games'] = '';
+        $lm = lm('UserSetting', 'api');
+        $favs = json_decode($data['fav_info'], 1);
+        $favs = array_unique($favs);
+        $data['fav_info'] = json_encode($favs);
+        $ret = $lm->setUserSettings($uuid, $data);
+        Render('', 1);
+    }
+
+    public function setUserSet() {
+        $this->checkLogin();
+        $uinfo = $this->accountManager->getCurrentUser();
+        //if ($uinfo && $uinfo->account_identity)
+        $uuid = $uinfo->account_identity;
+        // $data ['hand_pass'] = md5 ($_POST['hand_pass']);
+        // $data ['win_games'] = $_POST['win_games'];
+
+        $data = array(
+            'prize_all' => isset($_POST['prize_all']) ? 1 : 0,
+            'win_games' => isset($_POST['win_games']) ? 1 : 0,
+        );
+        if (empty($data)) {
+            return -909090;
+        }
+        $ret = lm('UserSetting', 'api')->where('account_identity', $uuid)->update($data);
+        if ($ret == 1) {
+            return Render('', 1);
+        } else {
+            return Render('', 0);
+        }
+
+    }
+
+    public function setHeadImg() {
+        //$imgUrl = $_REQUEST['imgUrl'];
+        $imgId = $_REQUEST['imgId'] ?? 0;
+        $accountMan = new AccountManager();
+//        if ($_POST['dd'] == 1)
+//            dd ($imgUrl);
+//        if (!$imgUrl) {
+//            $arr = json_decode (file_get_contents ('php://input'), 1);
+//            if (isset($arr['imgUrl']) && $arr['imgUrl']) {
+//                $imgUrl = $arr['imgUrl'];
+//            }
+//        }
+
+        $ret = null;
+        $imgUrl = "/Public/themes/default/static/img/{$imgId}.png";
+        if ($imgUrl) $ret = $accountMan->chHeadImg($imgUrl, $imgId);
+        if ($ret < 1) {
+            Render('', $ret);
+        }
+        Render($ret, 1);
+    }
+
+    public function setDetail() {
+        $phone = $_POST['phone'] ? strip_tags(trim($_POST['phone'])) : '';
+        $qq = $_POST['qq'] ? strip_tags(trim($_POST['qq'])) : '';
+        $email = $_POST['email'] ? strip_tags(trim($_POST['email'])) : '';
+        $wechat = $_POST['wechat'] ? strip_tags(trim($_POST['wechat'])) : '';
+
+        if (!$phone && !$qq && !$email && !$wechat) {
+            Render('', -40256);//数据不能全为空
+        }
+        $data = [];
+        if ($phone) {
+            $data['phone'] = $phone;
+        }
+        if ($qq) {
+            $data['qq'] = $qq;
+        }
+        if ($email) {
+            $data['email'] = $email;
+        }
+        if ($wechat) {
+            $data['wechat'] = $wechat;
+        }
+        $accountMan = new AccountManager();
+        $uinfo = $accountMan->getCurrentUser();
+        $uuid = $uinfo->account_identity ?? null;
+        if (!$uuid) {
+            Render('', -4001);//用户未找到
+        }
+        $ret = lm('AccountDetail', 'Api')->where('account_identity', $uuid)->update($data);
+        if ($ret) {
+            Render('', 1);
+        } else {
+            Render('', -40254);
+        }
+    }
+
+    //获取当前用户安全等级
+    public function safetygrade() {
+        //if($_REQUEST['dbg']==1)dd($_SESSION);
+        $checkToken = $this->accountManager->checkEffectiveTime();
+        if ($checkToken['status'] != 1) {
+            Render($checkToken['data'], $checkToken['status'], $checkToken['msg']);
+        };
+        $result = $this->accountManager->refreshToken();
+        if (!empty($result)) {
+            $bankstate = lm('account_bank', 'commons')->where('account_identity', $result['data']['account_identity'])->count();
+            $paypasswordstate = lm('pay_password', 'commons')->where('account_identity', $result['data']['account_identity'])->count();
+            if ($bankstate != 0 && $paypasswordstate != 0 && $result['data']['email'] != '' && $result['data']['qq'] != '') {
+                $safetystate = '高';
+            } elseif ($bankstate != 0 && $paypasswordstate != 0) {
+                $safetystate = '中';
+            } else {
+                $safetystate = '低';
+            }
+            Render($safetystate, 1);
+        } else {
+            Render('', $result['status'], $result['msg']);
+        }
+    }
+
+    //检查用户是否已注册
+    public function isRegistered() {
+        $an = $_REQUEST['account_name'];
+        $ret = (new \App\Api\Model\Account())->where('account', $an)->exists();
+        Render(null, $ret ? -40040 : 1);
+    }
+
+    /**
+     *错误码列表接口
+     */
+    public function getErrLangs() {
+        $lang = Lang('Errors', 'Api');
+        $langs = $lang->getAll();
+        $newLangs = [];
+        foreach ($langs as $k => $v) {
+            $k = trim($k, 'error');
+            $newLangs["$k"] = $v;
+        }
+        Render($newLangs, 1);
+    }
+
+    /**
+     * 玩法语言包总列表接口
+     */
+    public function getGameLangs() {
+        if (C()->get('cache')->has('totalGameLangs')) {
+            $data = C()->get('cache')->get('totalGameLangs');
+//            C()->get('cache')->delete('totalGameLangs');
+        } else {
+            $cls = new Common();
+            $data = $cls->getGameLangs();
+            C()->get('cache')->set('totalGameLangs', $data, 86400 * 7);
+        }
+        Render($data, 1);
+    }
+
+    /**
+     * 修改用户基本信息
+     *
+     * @access public
+     * @return array JsonString
+     */
+    public function updateUserInfo() {
+        $code = 0;
+        $msg = lang('Common','Api') -> get('error');
+        try{
+            $accountDetailClass = new AccountDetail();
+            // 修改用户基本信息
+            $result = $accountDetailClass -> updateUserInfo();
+            if ($result) {
+                $code = 1;
+                $msg = lang('Index','Api') -> get('success');
+
+                Render($result, $code, $msg);
+            } else {
+                Render([], $code, $msg);
+            }
+        } catch (Exception $e) {
+            Render([], $code, $msg);
+        }
+    }
+
+    /**
+     * 用户消息
+     *
+     * @access public
+     * @return array JsonString
+     */
+    public function userNews() {
+        $code = 0;
+        $msg = lang('Common','Api') -> get('error');
+        try{
+            $accountDetailClass = new AccountNews();
+            // 获取用户消息
+            $result = $accountDetailClass -> userNews();
+            $code = 1;
+            $msg = lang('Index','Api') -> get('success');
+
+            Render($result, $code, $msg);
+        } catch (Exception $e) {
+            Render([], $code, $msg);
+        }
+    }
+
+    /**
+     * 上传用户头像
+     *
+     * @access public
+     * @return array JsonString
+     */
+    public function updateHeader() {
+        $code = 0;
+        $msg = lang('Common','Api') -> get('error');
+        try{
+            $accountDetailClass = new AccountDetail();
+            // 修改用户基本信息
+            $result = $accountDetailClass -> updateHeader();
+            $code = 1;
+            $msg = lang('Index', 'Api')->get('success');
+
+            Render($result, $code, $msg);
+        } catch (Exception $e) {
+            Render([], $code, $msg);
+        }
+    }
+}

+ 60 - 0
Application/Api/Controller/BaseController.php

@@ -0,0 +1,60 @@
+<?php
+
+/**
+ *------Create thems Controller------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-13 01:06:44------.
+ */
+
+namespace App\Api\Controller;
+
+use BaseController\Controller;
+
+class BaseController extends Controller
+{
+    public function init()
+    {
+        // lm('user_logs', 'commons')->initVisitor();
+        if (isCheckToken()) {
+            $token = isset($_GET['token']) && !empty($_GET['token']) ? trim($_GET['token']) : '';
+            if (empty($token)) {
+                Render('5555', '-4010', lang('errors')->get('-4010'));
+            }
+            $re = C()->get('user')->refreshStatus($token);
+            if ($re < 0) {
+                Render('', $re, lang('errors')->get($re));
+            }
+        }
+    }
+
+    /**
+     * 全局更新缓存.
+     */
+    private function updateCache()
+    {
+        $setTime = lm('Setinfo', 'Commons')->getType(1912);
+        if (empty($setTime)) {
+            return;
+            // $setTime = date('Y-m-d H:i:s');
+        }
+        if (C()->get('cache')->has('systenLastUpdateTime')) {
+            $lastTime = C()->get('cache')->get('systenLastUpdateTime');
+        } else {
+            // $lastTime = date('Y-md-d H:i:s');
+            $lastTime = 0;
+        }
+
+        $setTimestamp = strtotime($setTime);
+        $lastTimestamp = strtotime($lastTime);
+        if ($setTimestamp > $lastTimestamp) {
+            C()->get('cache')->clear();
+            C()->get('cache')->set('systenLastUpdateTime', $setTime, 86400 * 365);
+        }
+    }
+
+    public function beforeInit()
+    {
+        $this->updateCache();
+    }
+}

+ 591 - 0
Application/Api/Controller/Betorder.php

@@ -0,0 +1,591 @@
+<?php
+namespace App\Api\Controller;
+
+use Biz\Money\Moneycopy;
+use Biz\Money\Money;
+use Biz\Account\AccountManager;
+use App\Api\Model\St_odds_code as odds_codeModel;
+/*
+ * Class Register
+ * @package App\Api\Controller
+ * User: junghwi
+ * Date: 2019/3/21
+ */
+class Betorder extends BaseController{
+
+    private $simplex_money = 0; //单式投注总额
+    public function init() {
+        $this->time = date('Y-m-d H:i:s',time());
+        $this->MC = new Moneycopy();
+        $this->M = new Money();
+        $this->accountManager = new AccountManager();
+        $this->commonFunction =  C()->get('commonFunction');
+
+    }
+    /**
+     * 单式串式分类
+     * @param  [array] $res 投注数据
+     * @return  [array] $data
+     *
+     */
+    public function Classify(array $res){
+        if(empty($res)){
+            Render('', '7003',lang('Errors','Api')->get('error-7003'));
+        }
+        $data['single'] = [];//单式
+        $data['bunch'] = [];//串式
+        $last[] = $res[count($res)-1];
+        unset($res[count($res)-1]);
+        foreach ($last as $k =>$v){
+            foreach ($v as $kk =>$vv){
+                $num = $kk+1;
+                //验证联赛是否存在
+                $this->verify_league($vv['ballId'],(int)$vv['lg_id'],$num);
+                //验证赛事是否存在
+                $this->verify_match($vv['ballId'],$vv['match_id'],$num);
+                //验证球类代码是否有效
+                $this->verify_gameType($vv['ballId'],$num);
+                //验证赛事下赔率玩法是否有效
+                $this->verify_odds($vv['ballId'],$vv['odds_only'],$vv['odds'],$vv['condition'],$vv['odds_code'],$num);
+            }
+        }
+        foreach($res as $k => $v){
+            //根据类型分组
+            if($v['type'] == '1'){
+                $data['single'][$k] = array_merge($last[0][$v['index']],$v);
+            }else{
+                $data['bunch'][$k] = $v;
+            }
+        }
+        if(!empty($data['bunch'])){
+            $data['bunch'] = array_merge_recursive($data['bunch'],$last);
+        }
+        return $data;
+    }
+
+    /**
+     * 根据赛事ID分组
+     * @param  [array] $data 球类数据
+     * @return  [array] $data
+     */
+    public function Group_ball($data = []){
+        if(empty($data)){
+            return $data;
+        }
+        foreach($data as $k => $v){
+            if(!isset($data[$v['match_id']])){
+                $data[$v['match_id']][] = $v;
+                unset($data[$k]);
+            }else{
+                $data[$v['match_id']][] = $v;
+                unset($data[$k]);
+            }
+        }
+        return $data;
+    }
+
+    /**
+     * 单式投注数据处理
+     * @param  [array] $res 单式投注数据
+     * @return  [int] 1 成功 其他失败
+     * @param  [int]  $batch_id 批量ID
+     */
+    public function Simplex_bet(array $res,array $userInfo,$batch_id){
+
+        if(empty($res)||empty($userInfo)||empty($batch_id)){
+            Render('', '7003',lang('Errors','Api')->get('error-7003'));
+        }
+        //验证与判断投注了几种
+        foreach($res as $k => $v){
+            $num = $k + 1;
+            if(empty($v['bet_amount'])){
+                $msg = '第'.$num.'条'.lang('Errors','Api')->get('error-5105');
+                Render([], '5105',$msg);
+            }
+            //根据类型分组
+            if(!isset($res[$v['ballId']])){
+                $res[$v['ballId']][] = $v;
+                unset($res[$k]);
+            }else{
+                $res[$v['ballId']][] = $v;
+                unset($res[$k]);
+            }
+
+        }
+        //球类联赛分类并且插入数据库
+        foreach($res as $k => $v){
+            $gamedate = $this->Group_ball($res[$k]);
+            $this->Simplex_bet_insert($gamedate,$userInfo,$k,$batch_id);
+        }
+    }
+
+    /**
+     * 单式投注单个球类数据插入
+     * @param  [array] $data 单式投注数据
+     * @param  [array] $userInfo 用户信息
+     * @param  [type] $game_code 球类代码
+     * @param  [int]  $batch_id 批量ID
+     * @return  [int] 1 成功 其他失败
+     */
+    public function Simplex_bet_insert($data,$userInfo,$game_code,$batch_id){
+        if(empty($data)||empty($userInfo)||empty($game_code)){
+            Render('', '7003',lang('Errors','Api')->get('error-7003'));
+        }
+        foreach($data as $k => $v){
+            $OrderID = OrderID();//生成订单ID
+            $UUID = UUID(); //生成信息ID
+            $bet_money = 0; //赛事总投注额
+            $prize_money = 0; //可赢额
+            foreach($v as $kk => $vv){
+                $bet_money += $vv['bet_amount'];
+                $prize_money +=  $vv['odds']* $vv['bet_amount'];
+                $matchData =[
+                    'odds_id' =>$vv['id'],
+                    'home_team' => $vv['home_team'],
+                    'guest_team' => $vv['guest_team'],
+                    'condition' => $vv['condition'],
+                    'odds' => $vv['odds'],
+                    'odds_code' => $vv['odds_code'],
+                    'p_code' => $vv['p_code'],
+                    'odds_only' => $vv['odds_only'],
+                    'match_id' => $vv['match_id'],
+                    'game_code' => $game_code,
+                    'lg_id' => $vv['lg_id'],
+                    'batch_id' => $batch_id,
+                    'bet_type' => 1,
+                    'bet_money' => $vv['bet_amount'],
+                    'ctime' => $this->time,
+                    'utime' => $this->time
+                ];
+                //插入数据源
+                $moneyBuyMatch = lm('MoneyBuyMatch','Api')->insert($matchData);
+                if(!$moneyBuyMatch){
+                    Render('','3205',lang('errors','Api')->get('error-3205'));
+                }
+            }
+            $order =[
+                'info_identity' => $UUID,
+                'account_name' => $userInfo['account'],
+                'account_identity' => $userInfo['account_identity'],
+                'order_id' => $OrderID,
+                'game_code' => $game_code,
+                'batch_id' => $batch_id,
+                'match_id' => $k,
+                'game_no'  => "",
+                'prize_money'=> $prize_money,
+                'money' => $bet_money, //投注金额
+                'money_time' => $this->time
+            ];
+            $insert = lm("MoneyBuySimplex",'Api')->insert($order);
+            if(!$insert){
+                Render('','3205',lang('errors','Api')->get('error-3205'));
+            }
+            $insertMoney  = $this->M->insertMoney($userInfo['account_identity'],$bet_money,$OrderID,1,"",$UUID,$userInfo);
+            if($insertMoney!=1){
+                Render('', $insertMoney,lang('Errors','Api')->get('error'.$insertMoney));
+            }
+            $this->M->fanshui($userInfo['account_identity'],$userInfo['account'],$bet_money,$OrderID);//反水
+        }
+    }
+
+    public function Bet(){
+
+        $userInfo = $this->getAgent();//获取用户信息
+        $data = $_REQUEST['data'];
+        $bet_money = $_REQUEST['bet_money'];
+        if(empty($data)||empty($bet_money)){
+            Render('', '51029',lang('Errors','Api')->get('error-51029'));
+        }
+        //获取用户金额信息
+        if(!$this->M->verifyMoney($bet_money,$userInfo['cash'])){
+            Render('', '4204',lang('Errors','Api')->get('error-4204'));
+        }
+        $batch_id = strtotime(date('Y-m-d H:i:s',time())).mt_rand('1','99');//批量ID
+        //执行数据插入
+        try {
+            _beginTransaction();//开启事务
+            $data = $this->Classify($data);
+            if(!empty($data['single'])){
+                $this->Simplex_bet($data['single'],$userInfo,$batch_id);//单式数据处理
+            }
+            if(!empty($data['bunch'])){
+                $data_all = $data['bunch'][count($data['bunch'])-1];//获取最后一个数组
+                unset($data['bunch'][count($data['bunch'])-1]);//删除最后一个元素
+                $this->stringBet($data['bunch'],$data_all,$userInfo,$batch_id);
+            }
+            _commit();//提交
+            Render('', '1',lang('Errors','Api')->get('error-1'));
+        } catch (Exception $e) {
+            _rollBack();//回滚
+            print $e->getMessage();
+        }
+}
+
+    /**
+     * token获取用户详情
+     */
+    public function getAgent() {
+        $checkToken = $this->accountManager->checkEffectiveTime();
+        if ($checkToken['status'] != 1) {
+            Render($checkToken['data'], $checkToken['status'], lang('commons')->get('user does login'));
+        };
+        $result = $this->accountManager->refreshToken();
+        return $result['data'];
+    }
+
+    //验证联赛是否存在
+    public function verify_league($game_code,$lg_id,$num = 1){
+        if(empty($lg_id)){
+            $msg = '第'.$num.'条'.lang('Errors','Api')->get('error-5112');
+            Render([], '5112',$msg);
+        }
+
+        //根据球类代码 获取相关model
+        $model = $this->commonFunction->getModels($game_code);
+        $model_league = $model['model_league'];
+        $info = lm($model_league,'Sports')
+            ->select('id')
+            ->where('id',$lg_id)
+            ->first();
+        if(empty($info)){
+            $msg = '第'.$num.'条'.lang('Errors','Api')->get('error-5113');
+            Render([], '5113',$msg);
+        }
+    }
+
+    /**
+     * 赛事是否存在或结束
+     * @param  [type] $game_code 球类代码
+     * @param  [type] $match_id  赔率ID
+     * @param  [type] $num 循环键值
+     * $@param  [type]type_str 串式
+     *
+     */
+    public  function verify_match($game_code,$match_id,$num = 1){
+        if(empty($match_id)){
+                $msg = '第'.$num.'条'.lang('Errors','Api')->get('error-5109');
+                Render([], '5109',$msg);
+        }
+        //根据球类代码 获取相关model
+        $models = $this->commonFunction->getModels($game_code);
+        $model_match = $models['model_match'];
+        $info = lm($model_match,'Sports')
+            ->select('status')
+            ->where('status', '<', '2')
+//            ->where('us_time','>',qgmdate('Y-m-d H:i:s','', -4))
+//            ->where('source','hg3535')
+            ->where('id',$match_id)
+            ->first();
+        if(empty($info)){
+            $msg = '第'.$num.'条'.lang('Errors','Api')->get('error-5103');
+            Render([], '5103',$msg);
+        }
+        $info = $info->toarray();
+        if($info['status'] == 2){
+            $msg = '第'.$num.'条'.lang('Errors','Api')->get('error-5108');
+            Render([], '5108',$msg);
+        }
+        return $info;
+    }
+
+    /**
+     * 验证球类是否存在
+     * @param  [type] $game_code 球类代码
+     * @param  [type] $num 第几条
+     */
+    public  function verify_gameType($game_code,$num){
+        if(empty($game_code)){
+            $msg = '第'.$num.'条数据'.lang('Errors','Api')->get('error-5102');
+            Render([], '5102', $msg);
+        }
+        $info = lm('GameType','Sports')->where('game_code',$game_code)->first();
+        if(empty($info)){
+            $msg = '第' . $num . '条数据' . lang('Errors', 'Api')->get('error-5102');
+            Render([], '5102', $msg);
+        }
+        return $info;
+    }
+
+    /**
+     * 验证赔率是否存在
+     * @param  [type] $game_code 球类代码
+     *  @param  [type] $odds_id 赔率IDkk
+     *
+     */
+    public function verify_odds($game_code,$odds_only,$odds,$condition,$odds_code,$num = 1){
+        if (empty($odds_only)){
+            $msg = '第'.$num.'条数据'.lang('Errors','Api')->get('error-5111');
+            Render([], '5111', $msg);
+        }
+        if(empty($odds_code)){
+            $msg = '第'.$num.'条数据'.lang('Errors','Api')->get('error-7052');
+            Render([], '7052', $msg);
+        }
+        if(empty($odds)){
+            $msg = '第'.$num.'条数据'.lang('Errors','Api')->get('error-7029');
+            Render([], '7029', $msg);
+        }
+        $odds_codeNum = odds_codeModel::getOddsCode($odds_code,$game_code);
+        if($odds_codeNum < 1){
+            $msg = '第'.$num.'条数据'.lang('Errors','Api')->get('error-7053');
+            Render([], '7053', $msg);
+        }
+        //根据球类代码 获取相关model
+        $models = $this->commonFunction->getModels($game_code);
+        $model_odds = $models['model_odds'];
+        $model_odds_record = $models['model_odds_record'];
+        //匹配赔率是否过期
+        $odds_info = lm($model_odds,'Sports')
+            ->join($model_odds_record,$model_odds_record.'.odds_only',$model_odds.'.odds_only')
+            ->select($model_odds_record.'.odds',$model_odds_record.'.condition')
+            ->where($model_odds.'.odds_only',$odds_only)
+            ->first();
+        if(empty($odds_info)){
+            $msg = '第'.$num.'条数据'.lang('Errors','Api')->get('error-7051');
+            Render([], '7051', $msg);
+        }
+        $odds_info = $odds_info->toarray();
+        if($condition != $odds_info['condition']){
+            $msg = '第'.$num.'条数据'.lang('Errors','Api')->get('error-7047');
+            Render([], '7047', $msg);
+        }
+        if($odds != $odds_info['odds']){
+            $msg = '第'.$num.'条数据'.lang('Errors','Api')->get('error-7049');
+            Render([], '7049', $msg);
+        }
+        return $odds_info;
+    }
+
+    /**
+     * 处理串式投注
+     * $data_str 各串式 数据
+     * $data_all 所有赛事 数据
+     * $userInfo 用户数据
+     * $batch_id 批次号
+     */
+    public function stringBet($data_str=[],$data_all=[],$userInfo=[],$batch_id=0){
+        //验证串式投注是否合法
+        $this->verify_stringType($data_all);
+        //获取串式 总赛事数量
+        $groupNum = count($data_all);//总数量
+
+        $orderData = [];
+        foreach ($data_str as $k=>$v){
+            //字符串替换
+            $str = str_ireplace("串","_",$v['type']);
+            //获取type 3_12
+            $after = substr($str,strpos($str,"_")+1);
+            //当前串式 值
+            $sonNum = substr($str,0,strrpos($str,"_"));
+            //获取倍数
+            if((int)$after == 1){
+                $multiple = $this->getMultiple($groupNum,(int)$sonNum);
+            }else{
+                $multiple =(int)$after;
+            }
+
+            //获取当前串式投注金额及可赢金额
+            if($after == 1){
+                $money_all = $this->getmakeMoney((int)$sonNum,$v['bet_amount'],$multiple,$data_all,$after);
+            }else{
+                $money_all = $this->getStrAllMoney((int)$sonNum,$v['bet_amount'],$multiple,$data_all,$after);
+            }
+            //投注金额
+            $moneyData = $money_all['moneyData'];
+            //可赢金额
+            $prize_money = $money_all['prize_money'];
+            $uuid = UUID();
+            $orderID = OrderID();
+
+            $orderData[$k]['info_identity'] = $uuid;
+            $orderData[$k]['account_name'] = $userInfo['account'];
+            $orderData[$k]['account_identity'] = $userInfo['account_identity'];
+            $orderData[$k]['order_id'] = $orderID;
+            $orderData[$k]['game_no'] = "";
+            $orderData[$k]['money'] = $moneyData;//$pay_money//总投注金额
+            $orderData[$k]['money_time'] = $this->time;//下注时间
+            $orderData[$k]['prize_money'] = $prize_money;//$expect_money ;//预期总可赢金额
+            $orderData[$k]['str_type'] = $v['type'];//串式类型
+            $orderData[$k]['batch_id'] = $batch_id;//批次号
+            $orderData[$k]['wait_match_num'] = count($data_all);//批次号
+
+            //写资金变动表
+            $insertMoney  = $this->M->insertMoney($userInfo['account_identity'],$moneyData,$orderID,1,"",$uuid,$userInfo);
+            if($insertMoney!=1){
+                Render('', $insertMoney,lang('Errors','Api')->get('error'.$insertMoney));
+            }
+            $this->M->fanshui($userInfo['account_identity'],$userInfo['account'],$moneyData,$orderID);//反水
+        }
+
+        //写注单 表
+        $moneyBuy = lm('MoneyBuyStr','Api')->insert($orderData);
+
+        if(!$moneyBuy){
+            Render('','3205',lang('errors','Api')->get('error-3205'));
+        }
+
+
+        foreach ($data_all as $kk=>$vv){
+            $getModels = $this->commonFunction->getModels($vv['ballId']);
+            $model_match = $getModels['model_match'];
+
+            $matchData[] = [
+                'batch_id'=>$batch_id,
+                'odds_id'=>$vv['id'],
+                'home_team'=>$vv['home_team'],
+                'guest_team'=>$vv['guest_team'],
+                'condition'=>$vv['condition'],
+                'odds'=>$vv['odds'],
+                'odds_code'=>$vv['odds_code'],
+                'p_code'=>$vv['p_code'],
+                'odds_only'=>$vv['odds_only'],
+                'status'=>0,
+                'match_id'=>$vv['match_id'],
+                'game_code'=>$vv['ballId'],
+                'lg_id'=> $vv['lg_id'],//lm($model_match,"Sports")->select('lg_id')->where('match_id',$vv['match_id'])->first()->lg_id,
+                'ctime'=>$this->time,//写入时间
+                'utime' => $this->time,
+                'bet_type'=>2
+            ];
+        }
+        //写赔率数据表
+        $moneyBuyMatch = lm('MoneyBuyMatch','Api')->insert($matchData);
+        if(!$moneyBuyMatch){
+            Render('','3205',lang('errors','Api')->get('error-3205'));
+        }
+
+        return true;
+    }
+
+    /**
+     * 计算串式投注 倍率
+     * $groupNum 总赛事 数量
+     * $sonNum 当前串式 数量
+     */
+    public function getMultiple($groupNum = 0,$sonNum = 0){
+
+        if($groupNum and $sonNum){
+            $group =1;
+            for($i = $groupNum ; $i >($groupNum - $sonNum);$i--) {
+                $group = $group * $i;
+            }
+
+            $son =1;
+            for($i = $sonNum ; $i >0;$i--) {
+                $son = $son * $i;
+            }
+        }
+        return $group/$son;
+    }
+
+    /**
+     * @param int $sonNum 当前串式数量
+     * @param int $bet_amount 当前串式投注额
+     * @param int $multiple 当前串式倍数
+     * @param array $data_all 当前注单 所有投注数据
+     * @return mixed
+     * 计算当前串式投注总额、可赢总额
+     */
+    public function getmakeMoney($sonNum=0,$bet_amount=0,$multiple=0,$data_all=[],$after = 0){
+        $allNum = count($data_all);//所有数量
+        $odds_all = [];//所有投注项数据
+        foreach ($data_all as $k=>$v){
+            $odds_all[] = $v['odds']+1;
+        }
+        //投注总额
+        $data['moneyData'] = (double)$bet_amount*(double)$multiple;
+        if($sonNum == $allNum and (int)$after ==1){//N场赛事  N串一
+            //获取所有赛事赔率乘积
+            $odds = array_product($odds_all) - 1;
+            //获取可赢金额
+            $data['prize_money'] =  sprintf("%.2f",substr(sprintf("%.3f", $bet_amount*$odds), 0, -1));//floor($bet_amount*$odds*100)/100;//保留两位小数
+        }
+
+        if($sonNum < $allNum and (int)$after ==1){//例:N场赛事 <N串一
+            $group = $this->commonFunction->combination($odds_all, $sonNum);
+
+            foreach ($group as $k=>$v){
+                $odds[] = array_product($v);
+            }
+            $odds = (array_sum($odds))-(count($odds));
+
+            //获取可赢金额
+            $data['prize_money'] =  sprintf("%.2f",substr(sprintf("%.3f", $bet_amount*$odds), 0, -1));//floor($bet_amount*$odds*100)/100;
+        }
+
+        return $data;
+    }
+
+    /**
+     * 获取所有可用串式  N场赛事 2串1,3串1...N串1,N<11
+     * 并计算 其投注可赢金额
+     */
+    public function getStrAllMoney($sonNum=0,$bet_amount=0,$multiple=0,$data_all=[],$after = 0){
+        $d = [];
+        for ($i=2;$i<($sonNum+1);$i++){
+            $d[] = $i;
+        }
+
+        foreach ($d as $k=>$v){
+            $multiple = $this->getMultiple($sonNum,$v);
+            $money[] = $this->getmakeMoney($v,$bet_amount,$multiple,$data_all,1);
+        }
+        $data=array();
+        foreach($money as $k=>$v){
+            $data['moneyData']+=$v['moneyData'];
+            $data['prize_money']+=$v['prize_money'];
+        }
+        return $data;
+    }
+
+    /**
+     * 验证串式投注 是否合法
+     * $data 串式 所有赛事
+     */
+    public function verify_stringType($data=[]){
+        if($data){
+            foreach($data as $k=>$v){
+                if($v['match_id']==$v['match_id']){
+                    $r[$v['match_id']][] = $v;
+                }
+            }
+        }
+        if($r){
+            foreach ($r as $k=>$v){
+                if(count($v) > 1){
+                    $msg = lang('Errors','Api')->get('error-50038');
+                    Render([], '50038',$msg);
+                }
+            }
+        }
+    }
+
+    /**
+     * 更新投注项相关数据
+     */
+    public function getBetData(){
+        $data = $_REQUEST;
+//        $data = [['game_code'=>'zq','match_id'=>3095448,'odds_id'=>623078],['game_code'=>'zq','match_id'=>3095448,'odds_id'=>623078]];
+        foreach ($data as $k=>$v){
+            $getModels = $this->commonFunction->getModels($v['game_code']);
+            $model_match = $getModels['model_match'];
+            $model_odds = $getModels['model_odds'];
+
+            $oddsData = lm($model_match,"Sports")
+                ->join($model_odds,$model_odds.'.match_id',$model_match.'.id')
+                ->select($model_match.'.id as match_id',$model_match.'.match_date',$model_match.'.home_team',$model_match.'.guest_team',$model_odds.'.id as odds_id',$model_odds.'.p_code',$model_odds.'.odds_code',$model_odds.'.condition',$model_odds.'.odds',$model_odds.'.odds_only',$model_odds.'.status',$model_odds.'.sort')
+//                ->where($model_match.'.source',$this->source)
+                ->where($model_match.'.id',$v['match_id'])
+                ->where($model_odds.'.id',$v['odds_id'])
+                //->where($model_odds.'.expire_time','>',date("Y-m-d H:i:s"))
+                ->first();
+            $oddsData->game_code = $v['game_code'];
+
+            $betData[] = $oddsData;
+        }
+
+        Render($betData, '1', lang('Tips','Sports')->get('success'));
+    }
+
+}
+

+ 37 - 0
Application/Api/Controller/Close.php

@@ -0,0 +1,37 @@
+<?php
+/**
+ *------Create thems Controller------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-23 15:06:45------
+ */
+namespace App\Api\Controller;
+use \BaseController\Controller;
+// ini_set('display_errors', 1);
+
+// error_reporting(E_ALL);
+class Close extends Controller {
+
+	//关闭网站
+	public function CloseWeb() {
+		$status = isset($_GET['status'])?intval($_GET['status']):-1;
+		$token = isset($_GET['token'])?$_GET['token']:'';
+		if($status<1 || empty($token)){
+			return -5007;
+		}
+		if (!empty($token) && ($re = lm('SystemUser', 'commons')->checkToken($token)) < 1) {
+			return $re;
+		}
+		try{
+			if($status==1){
+				\file_put_contents(ROOT_PATH."/Cache/system.lock",'');
+			}else{
+				if(\file_exists(ROOT_PATH."/Cache/system.lock")){
+					unlink(ROOT_PATH."/Cache/system.lock");
+				}
+			}
+		}catch(PDOException $e){
+			return -5011;
+		}
+	}
+}

+ 24 - 0
Application/Api/Controller/Common.php

@@ -0,0 +1,24 @@
+<?php
+/**
+ *------Create thems Controller------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-07-07 03:15:50------
+ */
+namespace App\Api\Controller;
+date_default_timezone_set('RPC');
+class Common extends BaseController {
+
+	function init() {
+
+	}
+
+	function getTime(){
+        $data=array(
+                'addrss' => date_default_timezone_get(),
+                'time' => date("Y-m-d H:i:s",  time() + 3600 * 8),
+        );
+        Render($data, 1, '');
+    }
+
+}

+ 162 - 0
Application/Api/Controller/Money.php

@@ -0,0 +1,162 @@
+<?php
+/**
+ *------Create thems Controller------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-13 15:41:29------
+ */
+namespace App\Api\Controller;
+use Biz\Account\AccountManager;
+
+class Money extends BaseController {
+    public $money;
+	public function init() {
+		$this->money = new \Biz\Money\MoneyHandle;
+	}
+	/**
+	 * 绑银行卡接口
+	 */
+	public function Bind_bank() {
+		$account_identity = $this->verifyPar('account_identity', 'post'); //用户唯一id
+		$bank_address = $this->verifyPar('bank_address', 'post'); //开户银行所在地
+		$bank_name = $this->verifyPar('bank_name', 'post'); //银行名称
+		$bank_no = $this->verifyPar('bank_no', 'post'); //银行卡号
+		$bank_user = $this->verifyPar('bank_user', 'post'); //开户人姓名
+		$pay_pwd = $this->verifyPar('pay_pwd', 'post'); //支付密码
+		$sure_pwd = $this->verifyPar('sure_pwd', 'post'); //确认密码
+		//$money = new \Biz\Money\MoneyHandle();
+		$res = $this->money->bind_bank($account_identity, $bank_address, $bank_name, $bank_no, $bank_user, $pay_pwd, $sure_pwd);
+		Render($res, '1', lang()->get('success'));
+	}
+
+	/**
+	 * 设置交易密码接口
+	 */
+	public function Set_payPwd() {
+		$account_identity = $this->verifyPar('account_identity', 'post'); //用户唯一id
+		$pay_pwd = $this->verifyPar('pay_pwd', 'post'); //支付密码
+		$sure_pwd = $this->verifyPar('sure_pwd', 'post'); //确认密码
+		//$money = new \Biz\Money\MoneyHandle();
+		$res = $this->money->setPayPwd($account_identity, $pay_pwd, $sure_pwd);
+        Render($res, '1', lang()->get('success'));
+	}
+
+    /**
+     * 设置交易密码接口 ,新增
+     */
+    public function SetPayPwd() {
+        //$account_identity = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+        $am=new AccountManager();
+        $uinfo=$am->getCurrentUser ();
+        $account_identity=$uinfo?$uinfo->account_identity:'';
+        $pay_pwd = $this->verifyPar('pay_pwd', 'post'); //支付密码
+        $sure_pwd = $this->verifyPar('sure_pwd', 'post'); //确认密码
+        //$money = new \Biz\Money\MoneyHandle();
+        $res = $this->money->setPayPwd($account_identity, $pay_pwd, $sure_pwd);
+        Render('', $res, '');
+    }
+    /**
+     * 检测用户是否设置交易密码
+     */
+    public function CheckSetPayPwd() {
+        $am=new AccountManager();
+        $uinfo=$am->getCurrentUser ();
+        $account_identity=$uinfo?$uinfo->account_identity:'';
+        $res = $this->money->checkPayPwd($account_identity);
+        Render('', $res, '');
+    }
+
+	/**
+	 * 修改银行卡状态接口
+	 */
+	public function ChangeStatus() {
+		$account_identity = $this->verifyPar('account_identity', 'post'); //用户唯一id
+		$pay_pwd = $this->verifyPar('pay_pwd', 'post'); //支付密码
+		$bank_no = $this->verifyPar('bank_no', 'post'); //银行卡号
+		$type = $this->verifyPar('type', 'post'); //修改状态
+		//$money = new \Biz\Money\MoneyHandle();
+		$res = $this->money->bankStatus($account_identity, $bank_no, $pay_pwd, $type);
+		Render($res, '1', lang()->get('success'));
+	}
+
+	/**
+	 * 提现申请接口
+	 */
+	public function TakeMoney() {
+		$money = $this->verifyPar('money', 'post'); //提现金额
+		$account_identity = $this->verifyPar('account_identity', 'post'); //用户唯一id
+		$pwd = $this->verifyPar('pay_pwd', 'post'); //支付密码
+		//$money123 = new \Biz\Money\MoneyHandle();
+		$res = $this->money->takeMoney($account_identity, $money, $pwd);
+		Render($res, '1', lang()->get('success'));
+	}
+
+	/**
+	 * 投注
+	 */
+	public function Betting() {
+		$account_identity = $this->verifyPar('account_identity', 'post'); //用户唯一id
+		$money = $this->verifyPar('money', 'post'); //操作所需金额
+		$money_type = $this->verifyPar('money_type', 'post'); //资金类型
+		$identity = UUID();
+		$orderId = OrderID();
+		$game_type = $this->verifyPar('game_type', 'post'); //游戏id
+		$data = [
+			'money_type' => $money_type,
+			'identity' => $identity,
+			'order_id' => $orderId,
+			'game_type' => $game_type,
+		];
+		//$moneyclass = new \Biz\Money\MoneyHandle();
+		$res = $this->money->betting($account_identity, $money, $data);
+		Render($res, '1', lang()->get('success'));
+	}
+
+	/***
+		     * 中奖
+	*/
+	public function Prize() {
+		$account_identity = $this->verifyPar('account_identity', 'post'); //用户唯一id
+		$money = $this->verifyPar('money', 'post'); //操作所需金额
+		$game_type = 'testGame';
+		//$moneyclass = new \Biz\Money\MoneyHandle();
+		$res = $this->money->prize($account_identity, $money, $game_type);
+		Render($res, '1', lang()->get('success'));}
+
+	/**
+	 * 充值
+	 */
+	public function AddMoney() {
+		$account_identity = $this->verifyPar('account_identity', 'post'); //用户唯一id
+		$money = $this->verifyPar('money', 'post'); //操作所需金额
+		//$moneyclass = new \Biz\Money\MoneyHandle();
+		$res = $this->money->addMoney($account_identity, $money);
+		Render($res, '1', lang()->get('success'));
+	}
+
+	/**
+	 * 撤单
+	 */
+	public function Cancel() {
+		$account_identity = $this->verifyPar('account_identity', 'post'); //用户唯一id
+		$order_id = $this->verifyPar('order_id', 'post'); //订单id
+		//$money = new \Biz\Money\MoneyHandle();
+		//$money->setPayPwd();
+		$abc = $this->money->cancel($account_identity, $order_id);
+		Render($abc, '1', lang()->get('success'));
+	}
+	/**
+	 * 验证参数是否传入
+	 * @param  [type] $name 参数名
+	 * @param  [type] $type 传入类型
+	 * @return [type]       返回参数
+	 */
+	public function verifyPar($name, $type) {
+		if ($type == 'get') {
+			$value = isset($_GET[$name]) ? $_GET[$name] : '';
+		} else if ($type == 'post') {
+			$value = isset($_POST[$name]) ? $_POST[$name] : '';
+		}
+		return $value;
+	}
+}

+ 982 - 0
Application/Api/Controller/Nologin.php

@@ -0,0 +1,982 @@
+<?php
+/**
+ *------Create thems Controller------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-23 15:06:45------
+ */
+
+namespace App\Api\Controller;
+
+use Biz\Account\AccountManager;
+use Biz\Game\GameList;
+use Illuminate\Support\Facades\DB;
+use App\Api\Model\SystemRed;
+use App\Api\Model\LuckyMoney;
+
+/*ini_set('display_errors', 1);
+error_reporting(E_ALL);*/
+
+class Nologin extends BaseController {
+
+    private $red;
+    private $LuckyMoney;
+
+    function init()
+    {
+        $this->red = new SystemRed();
+        $this->LuckyMoney = new LuckyMoney();
+    }
+
+    //线路gen
+    function routes() {
+        // $res = lm('system_routes','api')->get();
+        // if (!$res) {
+        //     return -6030001222;
+        // }
+        $type = $_REQUEST['type'] ?? '';
+        if (!$type) Render('', -60004);
+
+        $ret = lm('system_routes_category', 'api')->where('remark', $type)->first(['id']);
+        if (!$ret) Render('', -60005);
+        $res = lm('system_routes', 'api')->where('cate_id', $ret['id'])->get(['name', 'rdesc', 'ip', 'url']);
+        if (!$res) Render('', -60005);
+        Render($res, '1', lang()->get('success'));
+    }
+
+    /**
+     * 试玩用户名获取
+     * @auther: ikeke
+     * @time: 2018-10-30
+     */
+    function getTestUsername() {
+        $accountManager = new AccountManager();
+        $num = $accountManager->getAccountId();
+        $name = 'gust' . ($num + 1);
+
+        return $name;
+    }
+
+    /**
+     * 启动页
+     */
+    public function startup() {
+        $res = lm('setinfo', 'Commons')->where('id', '1111')->first();
+        if (isset($res->infocontent)) {
+            $res->infocontent = str_replace('white-space:normal;', 'white-space:nowrap;', $res->infocontent);
+            $res->infocontent = str_replace('white-space: normal;', 'white-space: nowrap;', $res->infocontent);
+        }
+        Render($res, '1', lang()->get('success'));
+    }
+
+    /**
+     * jnd
+     */
+    public function jndset() {
+        $res = lm('setinfo', 'Commons')->where('id', '1113')->first();
+        $res = $res->toArray();
+        $res['extinfo'] = explode('~', $res['extinfo']);
+        if (isset($res->infocontent)) {
+            $res->infocontent = str_replace('white-space:normal;', 'white-space:nowrap;', $res->infocontent);
+            $res->infocontent = str_replace('white-space: normal;', 'white-space: nowrap;', $res->infocontent);
+        }
+        Render($res, '1', lang()->get('success'));
+    }
+
+    /**
+     * 连号、遗漏接口
+     */
+    public function getHotList() {
+        $limit = $_REQUEST['limit'] ?? 50;//二维数组长度
+        $gameName = isset($_REQUEST['gameName']) && trim($_REQUEST['gameName']) ? trim($_REQUEST['gameName']) : '';
+        $gameList = new GameList();
+        $lm = lm($gameName, 'commons');
+        if (!$lm) {
+            Render('', -3201);//游戏不存在
+        }
+        $gameArray = $lm->where('status', 2)->orderBy('info_no', 'desc')->select('info_no', 'prizes')->limit($limit)->get();
+        if ($gameArray)
+            $result = $gameList->getPrizes($gameArray);
+
+        //$limit = count ($result);//二维数组长度
+        $width = count($result[0]);//二维数组宽度
+        $arr = [];
+        $arr=self::calcHotOrCold($result);
+//        for ($i = 0; $i < $width; $i++) { //遍历列
+//            //遍历二维数组中的每一列,移动数组指针,如果当前数据与下条数据相同,same++;继续
+//            //否则,从下一个位置的数据起,返回其和一次出现的index与第一条的index的差作为其遗漏值,
+//            $same = 1;//换列时默认求同
+//            for ($j = 0; $j < $limit; $j++) {  //遍历行,$j=当前行
+//                if ($j === 0)
+//                    $same = 1;//如果第一行默认求同
+//                //如果行当前值==第一行值且求同
+//                if ($result[$j][$i] === $result[0][$i] && $same) {
+//                    //if (!isset($arr['same'][$result[$i]])) $arr['same'][$result[$i]] = 1;
+//                    $arr['same'][$result[0][$i]] = $j + 1;//统计相同
+//                } else {
+//                    $same = 0;
+//                    if ($j + 1 <= $limit) { //如果下一行数据存在
+//                        //如果当$arr['dif'][当前行值]不存在且当前行值不等于第一行值 则设置它的值为当前index+1:
+//                        if (!isset($arr['dif'][$result[$j][$i]]) && $result[$j][$i] != $result[0][$i]) {
+//                            if ($result[$j][$i])//过虑当前期值为空的情况
+//                                $arr['dif'][$result[$j][$i]] = $j;
+//                        }
+//                    }
+//                }
+//
+//            }
+//
+//        }
+
+        //Render ([$result, $arr], 1);
+        Render($arr, 1);
+    }
+
+    /* function getBetTypes($gameName)
+     {
+         return (new GameList())->getBetTypes ($gameName);
+
+     }*/
+
+    /*
+     * 路珠统计
+     */
+    public function getRoadBead() {
+        //--2019-01-16 ---blues
+        $time = $_REQUEST['time'] ? $_REQUEST['time'] : date('Y-m-d');
+        $game_name = trim($_REQUEST['game_name']) ? trim($_REQUEST['game_name']) : '';
+        $rule = lang('Long', 'Api')->get('games')[$game_name]['rule'] ?? '5';
+//        $rule = ($_REQUEST['rule'])??'5';
+//        $rule = trim ($_REQUEST['rule']) ? trim ($_REQUEST['rule']) : '';
+        if (empty($game_name)) {
+            Render('', -3201);//游戏为空
+        }
+        if (empty($rule)) {
+            Render('', -3204);//现在规则
+        }
+        $lm = lm($game_name, 'commons');
+        if (empty($lm)) {
+            Render('', -3202);//游戏不存在
+        }
+
+        $nexttime = date("Y-m-d", strtotime("$time +1 day"));
+        $where[] = array('status', '=', '2');
+        $where[] = array('time', '>=', $time . ' 05:00:00');
+        $where[] = array('time', '<=', $nexttime . ' 05:00:00');
+        $data = $lm->where($where)->select('info_no', 'prizes', 'codes', 'open_time', 'extra', 'time')->orderby('id', 'asc')->get();
+        if (empty($data)) {
+            Render('', -3203);//暂无数据
+        }
+        $data = $data->toArray();
+        if (strpos($game_name, '28') !== false) {
+            foreach ($data as $key => $value) {
+                $extra = json_decode($value['extra'], true);
+                //$data[$key]['codes'] = $extra['one'].','.$extra['two'].','.$extra['three'];
+                $data[$key]['codes'] = intval($extra['one']) + intval($extra['two']) + intval($extra['three']); //qtx 2018-12-12
+            }
+        }
+
+        if (strpos($game_name, 'kuai3') !== false) {
+            foreach ($data as $key => $value) {
+                $extra =explode(',',trim($value['codes']));
+                //$data[$key]['codes'] = $extra['one'].','.$extra['two'].','.$extra['three'];
+                $data[$key]['codes'] = array_sum($extra); //---- blues
+            }
+        }
+
+
+        $arr = array();
+
+        foreach ($data as $key => $value) {
+            $codes = explode(',', trim($value['codes']));
+            foreach ($codes as $ke => $val) {
+                $num = count($arr[$ke]['size']);
+                $numtwo = count($arr[$ke]['singlepair']);
+                if ($key > 0) {
+                    $prevcodes = explode(',', $data[$key - 1]['codes']);
+                    if ($val >= $rule) {
+                        if ($prevcodes[$ke] >= $rule) {
+                            $arr[$ke]['size'][$num][] = 1;
+                        } else {
+                            $arr[$ke]['size'][$num + 1][] = 1;
+                        }
+                    } else {
+                        if ($prevcodes[$ke] >= $rule) {
+                            $arr[$ke]['size'][$num + 1][] = 0;
+                        } else {
+                            $arr[$ke]['size'][$num][] = 0;
+                        }
+                    }
+                    if ($val % 2 == 0) {
+                        if ($prevcodes[$ke] % 2 == 0) {
+                            $arr[$ke]['singlepair'][$numtwo][] = 1;
+                        } else {
+                            $arr[$ke]['singlepair'][$numtwo + 1][] = 1;
+                        }
+                    } else {
+                        if ($prevcodes[$ke] % 2 == 0) {
+                            $arr[$ke]['singlepair'][$numtwo + 1][] = 0;
+                        } else {
+                            $arr[$ke]['singlepair'][$numtwo][] = 0;
+                        }
+                    }
+
+                } else {
+                    if ($val >= $rule) {
+                        $arr[$ke]['size'][1][] = 1;
+                    } else {
+                        $arr[$ke]['size'][1][] = 0;
+                    }
+                    if ($val % 2 == 0) {
+                        $arr[$ke]['singlepair'][1][] = 1;
+                    } else {
+                        $arr[$ke]['singlepair'][1][] = 0;
+                    }
+                }
+
+            }
+
+        }
+
+        Render($arr, 1);
+    }
+
+    public function resultAnalysis() {
+        $limit = $_REQUEST['limit'] ?? 100;//二维数组长度
+        $gameName = isset($_REQUEST['gameName']) && trim($_REQUEST['gameName']) ? trim($_REQUEST['gameName']) : '';
+        return ($return = $this->calc($gameName, $limit));
+    }
+
+
+    /**
+     * 冷热遗漏数据计算函数
+     * @param $gameName
+     * @param int $limit
+     * @return mixed
+     */
+    private function calc($gameName, $limit = 100) {
+        $gameList = new GameList();
+        $lm = lm($gameName, 'commons');
+        if (!$lm) {
+            Render('', -3201);//游戏不存在
+        }
+        $gameArray = $lm->where('status', 2)->orderBy('info_no', 'desc')->select('info_no', 'prizes')->limit($limit)->get();
+        if ($gameArray)
+            $result = $gameList->getPrizes($gameArray);
+        $count = count($result);//数组长度
+        $width = count($result[0]);//数组宽度
+        $hots = [];
+        $colds = [];
+        for ($i = 0; $i < $width; $i++) { //$i=>列ID
+            $ret = [];//当前列的所有元素
+            for ($j = 0; $j < $count; $j++) { //$j=>行ID
+                //取回各列元素数组
+                array_push($ret, $result[$j][$i]);
+            }
+            //热号统计:
+            //遍历结果集每一列的每一个元素,统计其出现的频次(取回每列的值ARR,通过array_count_values函数统计)
+            $hots = array_merge($hots, array_count_values($ret));
+            //
+            $colds = array_merge($colds, $this->getCold($ret));
+        }
+        $return['hots'] = $hots;
+        $return['colds'] = $colds;
+        return $return;
+    }
+
+    /**
+     * 遗漏计算子函数
+     * @param $arr
+     * @return array
+     */
+    private function getCold($arr) {
+        $ret = [];
+        foreach ($arr as $k => $v) {
+            //遍历每一个元素
+            if (!isset($ret[$v]))
+                $ret[$v] = (function ($k) use ($arr) {
+                    $num = 0;
+                    //reset ($arr);
+                    if ($arr[0] === $arr[$k]) return 0;
+                    while ($arr[$num] !== $arr[$k]) {
+                        $num++;
+                    }
+                    return $num;
+
+                })($k);
+        }
+        //dd($ret);
+        return $ret;
+    }
+
+    /**
+     *统计游戏冷热遗漏接口
+     *
+     */
+    public function getGameAnalysis() {
+        $game_code = $_REQUEST['gameName'];
+        if (!$game_code) {
+            Render('', -3264);//游戏名不能为空
+        }
+        $limit = $_REQUEST['limit'] ?? 100;
+        $currentGame = lm($game_code, 'commons')->whereNotNull('prizes')->orderBy('info_no', 'desc')->select('info_no')->first();
+        //currentGame=>游戏当前开奖数据
+        if (!$currentGame) {
+            //无当前游戏开奖数据
+            Render('', -3266);
+        }
+        $current_issue = $currentGame->info_no;
+        $lm = lm('GameAnalysis', 'commons');
+        $currentData = $lm->where('game_code', $game_code)->first();//分析数据
+        if ($currentData && $current_issue == $currentData->current_issue) {
+            $ret = [
+                'hots' => json_decode($currentData->hot_list),
+                'colds' => json_decode($currentData->cold_list),
+                'issue' => $current_issue
+            ];
+        } else {
+            //重新请求计算
+            $calc = $this->calc($game_code, $limit);
+            if (!$calc) {
+                Render('', -51028);//统计数据不存在
+            }
+            $hots = json_encode($calc['hots']);
+            $colds = json_encode($calc['colds']);
+            if (!$currentData) {
+                $lm->insert(['game_code' => $game_code, 'hot_list' => $hots, 'cold_list' => $colds, 'current_issue' => $current_issue]);
+            } else {
+                $lm->where('game_code', $game_code)
+                    ->update(['game_code' => $game_code, 'hot_list' => $hots, 'cold_list' => $colds, 'current_issue' => $current_issue]);
+            }
+            $ret = ['hots' => $calc['hots'], 'colds' => $calc['colds'], 'issue' => $current_issue];
+        }
+        Render($ret, 1);
+    }
+
+    // todo 这个为临时工具代码 不上线 可删
+    public function toJson() {
+        $game_code = $_REQUEST['gameName'];
+        $ret = $this->calc($game_code, 200);
+        $hots = $ret['hots'];
+        $arr = [];
+        $group = [];
+        $childs = [];
+        foreach ($hots as $v => $k) {
+            //$v=>玩法名称
+            //$vv[0]=>分类
+            //$name=>分类下分组名称
+            $vv = explode('-', $v);
+            $vvv = explode('_', $vv[1] ?? $vv[0]);
+            $name = count($vvv) === 2 ? $vv[0] . '-' . $vvv[0] : $vv[0];
+            $group[$vv[0]][$name] = [
+                'name' => $name,//当前组的名称
+                'title' => $this->getTitle($game_code, $name),//当前组的中文名称
+                'desc' => ''
+            ];
+            $childs[$vv[0]][$name][$v] = $this->getChild($game_code, $v);
+            ksort($childs[$vv[0]][$name]);
+            $group[$vv[0]][$name]['childs'] = array_values($childs[$vv[0]][$name]);
+            $arr['root'][$vv[0]] = [
+                'name' => $vv[0],
+                'title' => $this->getTitle($game_code, $vv[0]),
+                'extra' => null,
+                'group' => array_values($group[$vv[0]])
+            ];
+
+        }
+        foreach ($arr['root'] as $k => $v) {
+
+            ksort($arr['root'][$k]['group']);
+        }
+        $arr['root'] = array_values($arr['root']);
+        return ([$arr]);
+    }
+
+    // todo 这个为临时工具代码 不上线 可删
+    public function gameExplain() {
+        $game_code = $_REQUEST['gameName'];
+        $ret = $this->calc($game_code, 200);
+        $hots = $ret['hots'];
+        $arr = [];
+        $group = [];
+        $childs = [];
+        foreach ($hots as $v => $k) {
+            //$v=>玩法名称
+            //$vv[0]=>分类
+            //$name=>分类下分组名称
+            $vv = explode('-', $v);
+            $vvv = explode('_', $vv[1] ?? $vv[0]);
+            $name = count($vvv) === 2 ? $vv[0] . '-' . $vvv[0] : $vv[0];
+            $group[$vv[0]][$name] = [
+                'name' => $name,//当前组的名称
+                'title' => $this->getTitle($game_code, $name),//当前组的中文名称
+                'desc' => ''
+            ];
+            $childs[$vv[0]][$name][$v] = $this->getChild($game_code, $v);
+            ksort($childs[$vv[0]][$name]);
+            $group[$vv[0]][$name]['childs'] = array_values($childs[$vv[0]][$name]);
+            $arr['root'][$vv[0]] = [
+                'name' => $vv[0],
+                'title' => $this->getTitle($game_code, $vv[0]),
+                'extra' => null,
+                'group' => array_values($group[$vv[0]])
+            ];
+
+        }
+        foreach ($arr['root'] as $k => $v) {
+
+            ksort($arr['root'][$k]['group']);
+        }
+        echo $str = $game_code . PHP_EOL . PHP_EOL;
+        file_put_contents("./gameExplain.cvs", $str);
+        foreach ($arr["root"] as $a => $x) {
+            if (count($x["group"]) == 1) {
+                echo $str = $x["title"] . "," . $x["name"] . PHP_EOL;
+                file_put_contents("./gameExplain.cvs", $str, FILE_APPEND);
+            } else {
+                foreach ($x["group"] as $b) {
+                    $b["title"] = !empty($b["title"]) ? $b["title"] : $x["title"];
+                    echo $str = $b["title"] . "," . $b["name"] . PHP_EOL;
+                    file_put_contents("./gameExplain.cvs", $str, FILE_APPEND);
+                }
+            }
+
+        }
+        // $arr['root'] = array_values ($arr['root']);
+        // return (1);
+
+    }
+
+    private function getTitle($game_name, $name) {
+        $name = lang($game_name)->get($name);
+        return $name;
+    }
+
+    private function getChild($game_name, $name) {
+        return $data = [
+            'name' => $name,
+//            'title' => $this->getTitle ($game_name, $name),
+            'title' => '',
+            'align' => 1
+        ];
+    }
+
+    //注册设置
+    public function getSettings() {
+        $settings = lm('settings', 'commons')->where('id', 1)->first();
+        if (!empty($settings)) {
+            $settings = $settings->toArray();
+        }
+        return $settings;
+    }
+
+    /**
+     * 头像列表
+     * @return mixed
+     */
+    public function getFaces() {
+        $list = file_get_contents(ROOT_PATH . '/Config/faces.json');
+        Render(json_decode($list), 1);
+    }
+
+    //根据域名获取代理用户邀请码
+    public function getInviteByDom() {
+        $dom = isset($_REQUEST['dom']) ? $_REQUEST['dom'] : '';
+        if (!$dom) {
+            Render('', -41101, '参数错误');
+        }
+        $res = lm('nagent_detailed', 'commons')->select('invite')->where('domain_name','like','%'.$dom.'%')->first();
+        if (!$res) {
+            Render('', -41101, '代理不存在');
+        }
+        $data = $res->toArray();
+        Render($data, 1, '成功');
+    }
+
+    public function room_conf() {
+        $sStr = lm('Setinfo', 'commons')->getSensitive()->infocontent ?? '';
+        $wlStr = lm('Setinfo', 'commons')->getWhiteList()->infocontent ?? '';
+        $data = [
+            "info_t" => $wlStr,
+            "in_status" => "1",
+            'word_info' => $sStr,
+            "word_status" => "1"
+        ];
+        return ($data);
+    }
+
+    /**自动拉取流水记录**/
+    public function automaticPullData()
+    {
+        $gametype = $_GET['gametype'];
+
+        if($gametype === 'oggame')
+        {
+            $og = new \App\Egame\Controller\OgGame();
+
+            $lastdata = lm('oggame_betting_ogrbv','commons')->orderBy('id','desc')->first();
+
+            $data = $og->getBettingRecordByVendorNew($lastdata->VendorId);
+
+            $userobj = new \App\Commons\Model\Oggame_user();
+
+            foreach($data['data'] as $key => $val)
+            {
+                $iscf = lm('oggame_betting_ogrbv','commons')->where('VendorId', $val['VendorId'])->first();
+
+                if(empty($iscf->VendorId))
+                {
+                    $user = $userobj->getRpUser($val['UserName'], 'oggame');
+
+                    $data['data'][$key]['AddTime'] = strtotime(str_replace('/','-',$val['AddTime']));
+
+                    if(!empty($user->lo_name))
+                    {
+                        $uid = lm('account','commons')->where('', $user->lo_name)->first();
+
+                        $data['data'][$key]['account_name'] = $uid->account;
+                        $data['data'][$key]['account_identity'] = $uid->identity;
+                    }
+                    else
+                    {
+                        $data['data'][$key]['account_name'] = '';
+                        $data['data'][$key]['account_identity'] = '';
+                    }
+                }
+
+                lm('oggame_betting_ogrbv','commons')->insert($data['data'][$key]);
+            }
+
+            render('',1,'数据拉取成功');
+        }
+        else if($gametype === 'kygame')
+        {
+            $ky = new \App\Egame\Controller\KyGame();
+
+            $data = $ky->getBettingRecordByVendorNew();
+
+            if($data['status'] == -1)
+            {
+                render('',-1,'暂无可拉取的数据');
+            }
+            else if($data['status'] == -2)
+            {
+                render('',-1,'接口异常,请稍后再试');
+            }
+            else if($data['status'] == 1)
+            {
+                $userobj = new \App\Commons\Model\Oggame_user();
+
+                $arr = array();
+                foreach($data['data']['d']['list'] as $key => $val)
+                {
+                    for($i = 0; $i < $data['data']['d']['count']; $i++)
+                    {
+                        $arr[$i][$key] = $val[$i];
+                    }
+                }
+
+                foreach($arr as $ak => $al)
+                {
+                    $is = lm('kygame_betting_ogrbv','commons')->where('GameID', $al['GameID'])->first();
+
+                    if(empty($is->GameID))
+                    {
+                        $user = $userobj->getRpUser($al['Accounts'], 'kygame');
+
+                        if(!empty($user->lo_name))
+                        {
+                            $uid = lm('account','commons')->where('', $user->lo_name)->first();
+
+                            $al['account_name'] = $uid->account;
+                            $al['account_identity'] = $uid->identity;
+                        }
+                        else
+                        {
+                            $al['account_name'] = '';
+                            $al['account_identity'] = '';
+                        }
+                    }
+
+                    lm('kygame_betting_ogrbv','commons')->insert($al);
+                }
+
+                render('',1,'数据拉取成功');
+            }
+            else
+            {
+                render('',-1,'接口异常,请稍后再试');
+            }
+        }
+        else
+        {
+            render('',-1,'游戏类型错误');
+        }
+    }
+
+    /**
+     * 用户所有游戏或单个游戏有效投注总额
+     * @param $account_identity
+     * @param string $starttime
+     * @param string $endtime
+     * @param string $gametype
+     * @return int 返回真人流水
+     */
+    public function totalUserStatistics($account_identity, $starttime = '', $endtime = '', $gametype = 'all'): int
+    {
+        $starttime = $starttime ? $starttime : '' . date('Y-m-d 00:00:00', time()) . '';
+        $endtime = $endtime ? $endtime : '' . date('Y-m-d 23:59:59', time()) . '';
+
+     if(empty($account_identity))
+        {
+            return -1;
+        }
+        else
+        {
+            $rgame_setting = new \App\Commons\Model\Rgame_setting();
+            $whererg['isopen'] = 1;
+            $rgamelist = $rgame_setting->getGameList($whererg);
+//            var_dump($rgamelist);exit;
+            $ogobj = new \App\Commons\Model\Oggame_betting_ogrbv();
+            $kyobj = new \App\Commons\Model\Kygame_betting_ogrbv();
+            $agobj = new \App\Commons\Model\Aggame_betting_ogrbv();
+            $hjobj = new \App\Commons\Model\Hjgame_betting_ogrbv();
+            $lcqpobj = new \App\Commons\Model\Lcqpgame_betting_ogrbv();
+            $lyobj = new \App\Commons\Model\Lygame_betting_ogrbv();
+
+            $om =  $km= 0;
+            if($gametype == 'all')
+            {
+                $where = array();
+                $where[] = array('account_identity','=', $account_identity);
+                $ogwhere[] = array('AddTime','>=', strtotime($starttime));
+                $ogwhere[] = array('AddTime','<=', strtotime($endtime));
+
+                $om = $ogobj->getUserMoney($where,$ogwhere);
+                
+                $kywhere[] = array('GameEndTime','>=', strtotime($starttime));
+                $kywhere[] = array('GameEndTime','<=', strtotime($endtime));
+
+                $km = $kyobj->getUserMoney($where, $kywhere);
+
+                $agwhere[] = array('betTime','>=', strtotime($starttime));
+                $agwhere[] = array('betTime','<=', strtotime($endtime));
+                $ag = $agobj->getUserMoney($where, $agwhere);
+
+                $hjwhere[] = array('bet_time','>=', strtotime($starttime));
+                $hjwhere[] = array('bet_time','<=', strtotime($endtime));
+                $hj = $hjobj->getUserMoney($where, $hjwhere);
+
+                $lcqpwhere[] = array('GameEndTime','>=', strtotime($starttime));
+                $lcqpwhere[] = array('GameEndTime','<=', strtotime($endtime));
+                $lcqp = $lcqpobj->getUserMoney($where, $lcqpwhere);
+
+                $lywhere[] = array('GameEndTime','>=', strtotime($starttime));
+                $lywhere[] = array('GameEndTime','<=', strtotime($endtime));
+                $ly = $lyobj->getUserMoney($where, $lywhere);
+
+            }
+
+            return   $om + $km + $ag + $hj + $lcqp + $ly;
+        }
+    }
+
+    //系统红包生成,用于服务器定时请求,不对前台开放 2019-01-22 anton
+    public function createSystemRed()
+    {
+        $user = $_REQUEST['user'];
+        $time = $_REQUEST['time'];
+        $sign = $_REQUEST['sign'];
+        if(empty($user))
+        {
+            echo lang('SystemRed')->get('admin_error');
+            exit;
+        }
+        if(empty($sign))
+        {
+            echo lang('SystemRed')->get('sign_error');
+            exit;
+        }
+        $token  = lm('Setinfo', 'commons')->where('id',1007)->first();
+        if(empty($token->infocontent))
+        {
+            echo lang('SystemRed')->get('token_error');
+            exit;
+        }
+        if($this->sign($user,$time,$token->infocontent,$sign))
+        {
+            $time = ['1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','00'];
+            $curt = date('H',time());
+            $start = date('Y-m-d H',time()).':00:00';
+            $end = date('Y-m-d H',time()).':59:59';
+            foreach ($time as $t)
+            {
+               if($curt == $t)
+               {
+                   $where['start'] = $start;
+                   $where['end'] = $end;
+                   $res = $this->LuckyMoney->checkRed($where);
+                   if(!count($res))
+                   {
+                       _beginTransaction();
+                       $redinfo = $this->red->getRedInfo();
+                       if (count($redinfo) == 0) {
+                           echo lang('SystemRed')->get('red_error');
+                           exit;
+                       }
+                       $redinfo = $redinfo->toArray();
+                       foreach ($redinfo as $k => $v)
+                       {
+                           //获取用户金额
+                           $uinfo = lm('account', 'Commons')
+                               ->leftjoin('account_detailed', 'account_detailed.account_identity', '=', 'account.identity')
+                               ->select('account.identity', 'account_detailed.cash','account.account')
+                               ->where('account.account', '=', $v['username'])
+                               ->first();
+                           if (count($uinfo) == 0) {
+                               echo $v['username'] . lang('SystemRed')->get('account_error');
+                               exit;
+                           }
+                           $uinfo = $uinfo->toArray();
+                           if (floatval($v['red_money']) > floatval($uinfo['cash'])) {
+                               echo $v['username'] . lang('SystemRed')->get('money_error');
+                               exit;
+                           }
+                           try {
+                               $roomid = intval($v['room_id']);
+                               $money = floatval($v['red_money']);
+                               $nos = intval($v['red_num']);
+                               $message = trim($v['red_mark']);
+                               $type = 3;
+                               $luck = $this->LuckyMoney->handleLuckyMoney($uinfo['identity'], $money, $nos, $roomid, $type, $message, function ($redid, float $money, int $nos, int $type) {
+
+                                   $redList = $this->redBag($money, $nos); //生成红包数据
+                                   $in_data = [];
+                                   foreach ($redList as $d) {
+                                       $in_data[] = ['redid' => $redid, 'money' => $d, 'created_at' => date('Y-m-d H:i:s')];
+                                   }
+                                   lm('Chat_redbag', 'Api')->insert($in_data);
+                                   return 1;
+                               });
+                               if(intval($luck) < 0){
+                                   Render('', $luck);
+                               }else{
+                                   $redData[$k]['data']['data']['lm_id'] = $luck;
+                                   $redData[$k]['data']['type'] = 203;
+                                   $redData[$k]['data']['time'] = (int)time();
+                                   $redData[$k]['data']['data']['room_id'] = $roomid;
+                                   $redData[$k]['data']['data']['money'] = $money;
+                                   $redData[$k]['data']['data']['type'] = 3;
+                                   $redData[$k]['data']['data']['data'] = $message;
+                                   $redData[$k]['type'] = 203;
+                                   $redData[$k]['has_take'] = 0;
+                                   $redData[$k]['time'] = (int)time();
+                               }
+                               _commit();
+                           } catch (\Exception $e) {
+                               _rollback();
+                               Render('', -7045);
+                           }
+                       }
+                       $this->SendMesage($redData);
+                   }else{
+                       echo lang('SystemRed')->get('send_red');
+                       break;
+                   }
+               }else{
+                    continue;
+               }
+            }
+        }else{
+            echo lang('SystemRed')->get('sign_error');
+            exit;
+        }
+    }
+
+    //红包数据生成
+    function redBag($money, int $piece, $min = 1)
+    {
+        srand(time());
+        $list = [];
+        $count = 0;
+        while ($piece > 1) {
+            $curr = rand($min, $money * 100 / $piece * 1.5);
+            $money -= $curr / 100;
+            $list[] = (float)number_format($curr / 100, 2, '.', '');
+            $count += $curr / 100;
+            $piece--;
+        }
+        $list[] = (float)number_format($money, 2, '.', '');
+        $count += $money;
+        return $list;
+    }
+
+    //推送红包数据
+    public function SendMesage($redData)
+    {
+        $wsport = lm('Setinfo', 'commons')->getInfo(9501);
+        $server = $wsport[0]['infocontent'];
+        $server = !empty($server) ? explode('||', $server) : '';
+        $server = !empty($server[0]) ? explode(':', $server[0]) : '';
+
+        if (empty($server[1])) {
+             echo lang('SystemRed')->get('server_error');
+             return false;
+        }
+        $server = count($server) > 2 ? $server[1] . ':' . $server[2] : $server[1];
+        $postUrls = $server . '/' . 'srpkg';
+        $sendData = [
+            'sign' => md5(time() . $wsport[0]['extinfo']),
+            'time' => (int)time(),
+            'redData' => json_encode($redData)
+        ];
+        $chs = curl_init();//初始化curl
+        curl_setopt($chs, CURLOPT_URL, $postUrls);//抓取指定网页
+        curl_setopt($chs, CURLOPT_HEADER, 0);//设置header
+        curl_setopt($chs, CURLOPT_TIMEOUT, 15);
+        curl_setopt($chs, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上
+        curl_setopt($chs, CURLOPT_POST, 1);//post提交方式
+        curl_setopt($chs, CURLOPT_POSTFIELDS, $sendData);
+        curl_exec($chs);//运行curl
+        if (curl_errno($chs) != 0) {
+            $status = curl_errno($chs);
+            $msg = lang('SystemRed')->get('server_error');
+        } else {
+            $status = 1;
+            $msg = lang('SystemRed')->get('success');
+        }
+        curl_close($chs);
+        echo lang('SystemRed')->get('sendtime'). date('Y-m-d H:i:s', time()) . ','.lang('SystemRed')->get('status') . $status . ','.lang('SystemRed')->get('msg') . $msg;
+    }
+
+    protected function calcHotOrCold($data) {
+        $xy28=['specialthree'];
+        $ssc=['fronttwostar','frontthreestar','behindthreestar','fourstar','fivestar'];
+        $lhc=['series','selfselect','general_pass','join_born'];
+        $pk10=['head_two','head_three'];
+        $k3=['thdiffnum','trnumro','tsnum','tsnumro','twodiffnum'];
+        $arr=array_merge($xy28,$ssc,$pk10,$k3,$lhc);
+        $pattern='/'.implode('|',$arr).'/';
+        $hot=[];
+        $cold=[];
+        $count=count($data);
+        foreach($data as $k=>$v){
+            foreach($v as $kk=>$vv){
+                $skip=preg_match($pattern,$vv);
+                if($skip)continue;
+                if($k===0)$hot[$vv]=1;
+                $hot[$vv]++;
+            }
+        }
+        foreach ($hot as $k=>$v){
+            $cold[$k]=$count-$v;
+        }
+        return['same'=>$hot,'dif'=>$cold];
+    }
+
+    //签名验证
+    protected function sign($user,$time,$token,$sign)
+    {
+        if(isset($time) && $time !=0) //时间存在
+        {
+            if(time()-intval($time) < 60) //小于一分钟
+            {
+                $str = 'user='.$user.'&time='.$time.'&token='.$token;
+                $md5 = md5($str);
+                if($md5 == $sign)
+                {
+                    return true;
+                }else{
+                    return false;
+                }
+            }else{
+                return false;
+            }
+        }else{
+            $str = 'user='.$user.'&token='.$token;
+            $md5 = md5($str);
+            if($md5 == $sign)
+            {
+                return true;
+            }else{
+                return false;
+            }
+        }
+    }
+
+    /**
+     * 子游戏列表
+     */
+    public function getSubGameLists()
+    {
+        $child_type = isset($_REQUEST['child_type']) ? $_REQUEST['child_type'] : '';
+        $is_page = isset($_REQUEST['is_page']) ? $_REQUEST['is_page'] : 0;
+        $page = isset($_REQUEST['page']) ? $_REQUEST['page'] : 1;
+        $limit = isset($_REQUEST['limit']) ? $_REQUEST['limit'] : 10;
+
+        if(empty($child_type))
+        {
+            render('', -1, '请传入子游戏类型');
+        }
+        else
+        {
+            $subgame = array();
+            $where[] = array('parent_id','>', 0);
+            //不需要分页
+            if($is_page == 0)
+            {
+                $subgame = lm('rgame_subclass','commons')
+                    ->where('sub_type', $child_type)
+                    ->where('status', 1)
+                    ->where($where)
+                    ->select('id','sname_en','icon','sname_zh','game_type','recommend','sub_type','child_name','order','parent_id','cate_id','status','extend','corner')
+                    ->orderBy('order','desc')
+                    ->get();
+            }
+            //需要分页
+            else if($is_page == 1)
+            {
+                $count = lm('rgame_subclass','commons')
+                    ->where('sub_type', $child_type)
+                    ->where('status', 1)
+                    ->where($where)
+                    ->count();
+
+                $count_page = ceil($count / $limit);
+
+                if($page > $count_page)
+                {
+                    render('', -1, '没有更多数据了');
+                }
+
+                $first = ($page - 1) * $limit;
+
+                $subgame = lm('rgame_subclass','commons')
+                    ->where('sub_type', $child_type)
+                    ->where('status', 1)
+                    ->where($where)
+                    ->select('id','sname_en','icon','sname_zh','game_type','recommend','sub_type','child_name','order','parent_id','cate_id','status','extend','corner')
+                    ->offset($first)->limit($limit)->orderBy('order','desc')->get();
+            }
+            else
+            {
+                render('', -1, '分页开关值错误');
+            }
+
+            if(count($subgame) > 0)
+            {
+                $arr = $subgame->toArray();
+                foreach($arr as $key => $val)
+                {
+                    $arr[$key]['icon'] = '/Public/themes/default/static/gamesimg/'.$val['game_type'].'/'.$val['icon'];
+                }
+
+                render($arr, 1, '子游戏列表获取成功');
+            }
+            else
+            {
+                render('', -1, '子游戏类型错误');
+            }
+        }
+    }
+}

+ 411 - 0
Application/Api/Controller/Notice.php

@@ -0,0 +1,411 @@
+<?php
+/**
+ *------Create thems Controller------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-12 02:52:02------
+ */
+
+namespace App\Api\Controller;
+/* ini_set('display_errors', 1);
+ error_reporting(E_ALL);*/
+
+use App\Api\Model\ArticleType;
+
+class Notice extends BaseController {
+
+    private  $longExpireTime   =  3600;
+    private  $ExpireTime       =  60;
+    private  $shortExpireTime  =  5;
+
+    private   $_cacheKey;
+    Public function Index() {
+    }
+
+    /**
+     * 获取内容
+     * [getContent description]
+     * @return [type] [description]
+     */
+    public function Content() {
+
+        $identity = isset($_REQUEST['identity']) ? $_REQUEST['identity'] : "";
+        if (empty($identity)) {
+            Render(null, '-5005', lang()->get("notice no identity"));
+        }
+
+      //添加缓存Bruce
+/*        if( $cache_data=C()->get('cache')->get($this->cacheKey(__FUNCTION__,$identity))){
+            Render(json_decode($cache_data,1), "1", "success");
+        }*/
+
+        $data = lm('article')
+            ->select('title', 'content', 's_title', 'time', 'author', 'img', 'type', 'mobileimg', 'mobilecontent')
+            ->where('identity', "{$identity}")
+            ->where('status', '1')
+            ->first();
+        if (!$data) {
+            return '-5003';
+        }
+
+
+        $data = $data->toArray();
+        if ($data) {
+//            C()->get('cache')->set($this->_cacheKey,json_encode($data),$this->longExpireTime);
+            Render($data, "1", "success");
+        } else {
+            Render($data, "-5004", lang()->get('Content fail data'));
+        }
+    }
+
+    /**
+     *查询帮助教程
+     *
+     */
+    public function HelpTutorial() {
+
+        $type = isset($_GET['type']) ? $_GET['type'] : '';
+        $limit = isset($_GET['limit']) ? $_GET['limit'] : 3;
+        if (empty($type)) {
+            Render(null, '-5009');
+        }
+        //添加缓存Bruce
+
+            if($cache_data=C()->get('cache')->get( $this->cacheKey(__FUNCTION__,$type))){
+            Render(json_decode($cache_data,1), "1", "success");
+        }
+
+        $data = lm('article')
+            ->select('identity', 'title', 'content', 'time')
+            ->where('typebind', $type)
+            ->where('status', '1')
+            ->orderBy('sort', 'desc')
+            ->limit($limit)
+            ->get();
+
+        if (!($data)) {
+            return '-5008';
+        }
+        $data   = $data->toArray();
+        if ($data) {
+            C()->get('cache')->set($this->_cacheKey,json_encode($data),$this->longExpireTime);
+            Render($data, "1", "success");
+        } else {
+            Render($data, "-5007", '');
+        }
+    }
+
+
+    /**
+     * 资讯公告
+     * [Tittle description]
+     */
+    public function Tittle() {
+        $identity = isset($_GET['identity']) ? $_GET['identity'] : "";
+        if (empty($identity)) {
+            Render(null, '-5009');
+        }
+
+        //添加缓存Bruce
+        if( $cache_data=C()->get('cache')->get($this->cacheKey(__FUNCTION__,$identity))){
+            Render(json_decode($cache_data,1), "1", "success");
+        }
+
+        $data = lm('article')
+            ->select('title', 'content', 'time', 'type', 'mobilecontent')
+            ->where('identity', $identity)
+            ->where('status', '1')
+            ->get()
+            ->toArray();
+
+        if (!is_array($data)) {
+            return '-5008';
+        }
+        if ($data) {
+            C()->get('cache')->set($this->_cacheKey,json_encode($data),$this->shortExpireTime);
+            Render($data, "1", "success");
+        } else {
+            Render($data, "-5007", '');
+        }
+
+    }
+
+    //只显示优惠活动下面的子分类 type =3
+    public function TypeName() {
+        //添加缓存Bruce
+        if( $cache_data=C()->get('cache')->get($this->cacheKey(__FUNCTION__))){
+            Render(json_decode($cache_data,1), "1", "success");
+        }
+        $data = lm('articleType')
+            ->select('id', 'cate_name as name', 'create_time as create_at')
+            ->where(["parent_id" => 3])
+            ->get()
+            ->toArray();
+
+        if (!is_array($data)) {
+            return '-5008';
+        }
+        if ($data) {
+            C()->get('cache')->set($this->_cacheKey,json_encode($data),$this->longExpireTime);
+            Render($data, "1", "success");
+        } else {
+            Render($data, "-5007", '');
+        }
+
+    }
+
+    /**
+     * 点击更多
+     * @return string
+     */
+    public function Mores() {
+        $data = lm('article')
+            ->select('identity', 'title', 'content', 'time')
+            ->where('type', '2')
+            ->where('status', 1)
+            ->first();
+
+
+        if (!$data) {
+            return '-5011';
+        }
+        $data = $data->toArray();
+        if ($data) {
+            Render($data, "1", "success");
+        } else {
+            Render(null, "-5010", '');
+        }
+    }
+
+    /**
+     * 通知
+     * [Notice description]
+     */
+    public function Notice() {
+        $user = $this->_getList();
+        Render($user, '1', 'success');
+    }
+
+    /**
+     * 充值跑马灯
+     * [recharge description]
+     */
+    public function RechargeDesc() {
+
+        //缓存--Bruce
+        if( $cache_data=C()->get('cache')->get($this->cacheKey(__FUNCTION__))){
+            Render(json_decode($cache_data,1), "1", "success");
+        }
+
+        $list = lm('setinfo', 'commons')->where('infotype', 9)->select('infocontent')->first();
+        if (empty($list)) {
+            Render(null, '-2102', '');
+        }
+        C()->get('cache')->set($this->_cacheKey,json_encode($list['infocontent']),$this->longExpireTime);
+        Render($list['infocontent'], '1', 'success');
+    }
+
+    /**
+     * 通知封装
+     * [_getList description]
+     * @return [type] [description]
+     */
+    private function _getList() {
+        try {
+            $type = isset($_REQUEST['type']) ? $_REQUEST['type'] : "";
+
+            // if (empty($type)) {
+            // 	Render(null, '-5002', lang()->get('type fail get'));
+            // }
+            $curpage = isset($_POST['curpage']) ? intval($_POST['curpage']) : "1";
+            $pagelist = '20';
+            $firstcode = ($curpage - 1) * $pagelist;
+            //获取总页数
+
+            if($cache_data=C()->get('cache')->get($this->cacheKey(__FUNCTION__,$type.'$curpage'))){
+                Render(json_decode($cache_data,1), "1", "success");
+            }
+            //文章类别
+            $all_type = (new ArticleType)->type();
+
+            /*        $sontype    =   lm("ArticleType",'Api')->get()->toarray();
+                    var_dump($sontype);exit();*/
+            //获取子类别
+            $types = [];
+            if (!empty($type)) {
+
+                $_type = explode(',', $type);
+                foreach ($_type as $v) {
+                    if (!empty($v)) {
+                        $types = array_merge($types, $this->getTree($all_type, $v));
+                    }
+                }
+
+                $types = array_column($types, 'id');
+                $types = array_merge($_type, $types);
+            } else {
+                //为空的时候只显示优惠活动下的  id=3
+                $types = array_merge($types, $this->getTree($all_type, 3));
+                $types = array_column($types, 'id');
+                $types = array_merge($types, [3]);
+            }
+
+
+            $tol_list = lm('article');
+            if (empty($types)) {
+                $datas = $tol_list->where('status', '1')->where('type', '!=', 8)->count();
+            } else {
+
+                if (count($types > 1)) {
+                    $datas = $tol_list->whereIn('type', $types)->where('status', '1')->count();
+                } else {
+                    $datas = $tol_list->where('type', $types[0])->where('status', '1')->count();
+                }
+
+            }
+
+
+            $tolpage = ceil($tol_list / $pagelist);
+            $res = lm('article')
+                ->leftJoin('lottery_money', 'article.child_id', '=', 'lottery_money.id')
+                ->select('article.identity', 'article.title', 'article.content',
+                    'article.s_title', 'article.time', 'article.author', 'article.img',
+                    'article.child_id', 'article.type', 'article.mobilecontent',
+                    'article.mobileimg', 'article.typebind', 'article.sort', 'article.id', 'lottery_money.type as act_cate');
+            if (empty($types)) {
+                $datas = $res->where('article.status', '1')->where('article.type', '!=', 8)
+                    ->orderBy('article.sort', 'desc')->orderBy('article.time', 'desc')
+                    ->skip("{$firstcode}")
+                    ->take("{$pagelist}")
+//                    ->leftjoin('')
+                    ->get()
+                    ->toArray();
+            } else {
+                if (count($types > 1)) {
+                    $datas = $res->whereIn('article.type', $types);
+                } else {
+                    $datas = $res->where('article.type', $types[0]);
+                }
+
+                $datas = $datas->where('article.status', '1')
+                    ->orderBy('article.sort', 'desc')->orderBy('article.time', 'desc')
+                    ->skip("{$firstcode}")
+                    ->take("{$pagelist}")
+                    ->get()
+                    ->toArray();
+            }
+
+            if (!is_array($datas)) {
+                return '-5001';
+            }
+            $data['data'] = $datas;
+            $data['page']['curpage'] = $curpage;
+            $data['page']['tolpage'] = $tolpage;
+            C()->get('cache')->set($this->_cacheKey,json_encode($data),$this->shortExpireTime);
+            return $data;
+        } catch (\Exception $e) {
+            // Render("",-5007);
+            print $e->getMessage();
+            exit();
+        }
+    }
+
+    /**
+     * 支付切换
+     * [switch description]
+     * @return [type] [description]
+     */
+    public function Switchs() {
+        $status = isset($_POST['status']) ? $_POST['status'] : '-1';
+        if (empty($status)) {
+            Render(null, '-5017');
+        }
+        $identity = isset($_POST['identity']) ? $_POST['identity'] : '76d6e867-19bd-b553-c58d-4548561dd217';
+        if (empty($identity)) {
+            Render(null, '-5018');
+        }
+        $res = [
+            'status' => $status,
+        ];
+        $data = lm('payment')
+            ->where('identity', $identity)
+            ->update($res);
+
+        if ($data) {
+            Render($data, '1', 'success');
+        } else {
+            Render(null, '-5016', 'error');
+        }
+    }
+
+    /**
+     * 银行卡与人员管理
+     * @return string
+     */
+    public function Bank_card_management() {
+        $accountManager = new \Biz\Account\AccountManager();
+        $uinfo = $accountManager->getCurrentUser();
+        if ($uinfo) {
+            $uinfo = json_encode($uinfo);
+            $uinfo = json_decode($uinfo, 1);
+            $gc = explode(',', $uinfo['group_code']);
+        } else {
+            Render('', -4001);
+        }
+        $temp = 1;
+        $where='';
+        if (!isset($gc)) {
+            $where = "groups = '0,'";
+        } else {
+            foreach ($gc as $k => $v) {
+                if (!empty($v)) {
+                    $where .= ($temp == 1) ? '(' : ' or ';
+                    $temp = 2;
+                    $where .= "groups like '%," . $v . ",%'";
+                }
+            }
+            $where .= ($temp == 2) ? ')' : '';
+        }
+        $data = lm('system_bank', 'commons')->getInfos($where);
+        if (!is_array($data)) {
+            if (isset($gc)) {
+                $where = "groups = '0,'";
+                $data = lm('system_bank', 'commons')->getInfos($where);
+                if (!is_array($data)) {
+                    Render(null, '-5025', 'error');
+                }
+            } else {
+                Render(null, '-5025', 'error');
+            }
+        }
+
+        if ($data) {
+            Render($data, '1', 'success');
+        } else {
+            Render(null, '-5024', 'error');
+        }
+    }
+
+    private function getTree($array, $pid = 0, $cen = 0) {
+        $arr = array();
+        $cen = ++$cen;
+        $str = "";
+        foreach ($array as $k => $v) {
+            if ($v['parent_id'] == $pid) {
+                $str = str_repeat("&nbsp;&nbsp;&nbsp;&nbsp;", $cen - 1);
+                $arr[] = ["id" => $v["id"], "name" => ($cen - 1 ? $str . "└" . $v["cate_name"] : $v["cate_name"])];
+                unset($array[$k]);
+                $arr = array_merge($arr, $this->getTree($array, $v['id'], $cen));
+            }
+        }
+        return $arr;
+    }
+
+    /**
+     * @param $keyAdd 附加数据
+     * @return string   返回缓存keyo值
+     */
+    private function cacheKey($fun,$keyAdd=''){
+      return  $this->_cacheKey=md5( __CLASS__.'_'.$fun.'_'.$keyAdd);
+    }
+}

+ 919 - 0
Application/Api/Controller/Other.php

@@ -0,0 +1,919 @@
+<?php
+/**
+ *------Create thems Controller------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-23 15:06:45------
+ */
+namespace App\Api\Controller;
+use Illuminate\Support\Facades\DB;
+// ini_set('display_errors', 1);
+
+// error_reporting(E_ALL);
+
+class Other extends BaseController {
+
+	/**
+	 * 轮播图
+	 */
+	public function Banner() {
+        $where = array();
+        $type = $_REQUEST['type'] ? $_REQUEST['type'] : "1";
+        $where['type'] = $type;
+
+         $cachekey    =    md5( 'Banner'.  implode($where));
+        $cache=   C()->get('cache')->get($cachekey);
+
+        if(!empty($cache)){
+            Render($cache, '1', lang()->get('success'));
+        }
+
+		$res = lm('banner', 'Commons')->getBanner($where);
+		if ($res){
+		    $i=0;
+		    foreach ($res as $k=>$v){
+		        $res[$k]['num']=$i;
+		        $i++;
+            }
+        }
+
+        C()->get('cache')->set($cachekey,$res,600);
+		Render($res, '1', lang()->get('success'));
+	}
+
+	/**
+	 * 公告
+	 */
+	public function Notice() {
+		$res = lm('setinfo', 'Commons')->where('id', '19')->first();
+        if(isset($res->infocontent)){
+            $res->infocontent = str_replace('white-space:normal;', 'white-space:nowrap;', $res->infocontent);
+            $res->infocontent = str_replace('white-space: normal;', 'white-space: nowrap;', $res->infocontent);
+        }
+		Render($res, '1', lang()->get('success'));
+	}
+
+
+
+    /**
+     * 轮播图
+     */
+    public function BannerType() {
+        $res = lm('advert', 'Commons')->getBanner();
+        Render($res, '1', lang()->get('success'));
+    }
+	/**
+	 * pc帮助中心
+	 */
+	public function Help()
+    {
+        $res = lm("game_type", 'commons')->where('close_status',1)->where('type','<','3')->orderBy('hot','desc')->select('play_desc as content', 'name as title','table_name','identity')
+        ->get();
+        if ($res){
+            $res=$res->toArray();
+        }else{
+            $res=[];
+        }
+
+        $dat = lm('article', 'api')->orderBy('sort','desc')->where('type', 11)->oRwhere('type', 9)
+            ->get();
+
+        if ($dat){
+            $dat=$dat->toArray();
+        }else{
+            $dat=[];
+        }
+        $da = lm('article', 'api')->orderBy('sort','desc')->where('type', 10)
+            ->get();
+
+        if ($da){
+            $da=$da->toArray();
+        }else{
+            $da=[];
+        }
+
+        $data = [
+            'opencai' => $res,
+            'recharge' => $dat,
+            'quert' => $da,
+        ];
+        Render($data, '1', lang()->get('success'));
+    }
+    public function HelpData()
+    {
+        $identity = $_GET['identity'] ? $_GET['identity'] : '';
+        $name = $_GET['name'] ? $_GET['name'] : '';
+        if (empty($identity)) {
+            Render('', '-10009', 'no game');
+            return;
+
+        }
+
+        $arr = [ //向数据库追加数组  然后循环出来
+            'title' => $name,
+            'identity' => $identity,
+        ];
+        $where = '1 = 1';
+
+        foreach ($arr as $key => $value) {
+            //循环数组
+            if ($value != '' && $key != 'a.id' && $key != 'b.id') { //判断条件
+                $where .= " AND {$key}='{$value}'"; //获取值
+            }
+        }
+        $data = lm('article', 'api')->whereRaw($where)
+            ->first();
+        if ($data){
+            $data=$data->toArray();
+        }else{
+            $data=[];
+        }
+
+        Render($data, '1', lang()->get('success'));
+    }
+
+	/**
+     * 联系我们客服信息
+     */
+    public function GetNewNoticeinfo() {
+        $info = lm('setinfo', 'commons')->where('infotype', 33)->get();
+        if (!$info) {
+            Render('', '-5006', lang('error')->get('-5006'));
+        }
+        $data = array();
+        foreach ($info as $k => $v) {
+            $data[$v['remarks']] = $v['infocontent'];
+        }
+        Render($data, 1);
+    }
+
+
+    public function GameExplan()
+    {
+        $game = isset($_GET['game']) ? trim($_GET['game']) : '';
+        if (empty($game)) {
+            Render('', '-10009', 'no game');
+            return;
+        }
+        $data = lm("game_type", 'commons')->where("table_name", $game)->select('play_desc as content', 'name as title')->first();
+        if (!$data) {
+            Render('', '-10009', 'no game');
+            return;
+
+        }
+        if ($data){
+            $data = $data->toArray();
+        }else{
+            $data =[];
+        }
+
+        Render($data, '1', lang()->get('success'));
+
+    }
+    /**
+     * 手机主页弹框内容
+     */
+    public function Mobile_tan()
+    {
+        $content = lm('setinfo', 'Commons')->where(['status' => 1, 'infotype' => 6])->first();
+        if ($content) {
+            $con = $content->toArray();
+        } else {
+            Render('', '-5001', lang()->get('fail'));
+        }
+        Render($con, '1', lang()->get('success'));
+    }
+    /**
+     * 获得用户银行卡
+     */
+    public function GetBank()
+    {
+        $user_id = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+        if (empty($user_id)) {
+            Render('', '-4010', lang()->get('user not login'));
+        }
+        $res = array();
+        $res = lm('account_bank', 'Commons')->where('account_identity', $user_id)->first();
+        if ($res) {
+            $res = $res->toArray();
+        }
+        if (!empty($res)) {
+            Render($res, 1, lang()->get('success'));
+        }
+        Render('', '-2004', lang()->get('Please bind the bank card'));
+    }
+
+    /**
+     * 检测试玩用户
+     */
+    public function CheckUser()
+    {
+        $user_id = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+        if (empty($user_id)) {
+            Render('', -4001, lang('error')->get('-4001'));
+        }
+        $res = lm('account', 'commons')->where('identity', $user_id)->first();
+        if ($res) {
+            Render($res, 1);
+        }
+        Render('', '-5001', lang('error')->get('-5001'));
+    }
+
+    //意见反馈
+    public function FeedBack()
+    {
+        $user_id = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+        $name = isset($_SESSION['uinfo']['account']) ? $_SESSION['uinfo']['account'] : '';
+        $type = isset($_POST['type']) ? strip_tags($_POST['type']) : "";
+        $content = isset($_POST['content']) ? strip_tags($_POST['content']) : "";
+        $tel = isset($_POST['tel']) ? strip_tags($_POST['tel']) : "";
+        $qq = isset($_POST['qq']) ? strip_tags($_POST['qq']) : "";
+        $weixin = isset($_POST['weixin']) ? strip_tags($_POST['weixin']) : "";
+        $dat = [
+            'account_identity' => $user_id,
+            'type' => $type,
+            'account_name' => $name,
+            'content' => $content,
+            'submit_time' => date('Y-m-d H:i:s',time()),
+        ];
+        if(!empty($tel))$dat['account_tel']=$tel;
+        if(!empty($qq))$dat['account_qq']=$qq;
+        if(!empty($weixin))$dat['account_weixin']=$weixin;
+        $data = lm('feedback', 'Commons')->insert($dat);
+        if ($data) {
+            Render($data, 1, lang()->get('success'));
+        } else {
+            Render('', '-5001', lang('error')->get('-5001'));
+        }
+    }
+
+    //意见反馈
+    public function FeedBackList()
+    {
+        $user_id = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+        $page = isset($_POST['page']) ? $_POST['page'] : "1";
+        $lists = isset($_POST['lists']) ? $_POST['lists'] : "10";
+
+        $list = $lists;
+        //获取总页数
+        $count_list = lm('feedback', 'Commons')->where('account_identity', $user_id)->count();
+        $count_page = ceil($count_list / $list);
+        $first = ($page - 1) * $list;
+
+        $data = lm('feedback', 'Commons')->where('account_identity', $user_id)->orderBy('submit_time', 'desc')->offset($first)->limit($list)
+            ->get();
+        $dat = [
+            'see_status' => '1',
+        ];
+        $da = lm('feedback', 'Commons')->where('account_identity', $user_id)
+            ->where('see_status', '0')
+            ->where('status', '1')
+            ->update($dat);
+
+        if ($data) {
+            $data = $data->toArray();
+
+            $Iteas = [
+                'data' => $data,
+                'count_page' => $count_page,
+                'page' => $page,
+            ];
+            Render($Iteas, 1, lang()->get('success'));
+        } else {
+            Render('', '-5001', lang('error')->get('-5001'));
+        }
+    }
+
+    //移动意见反馈
+    public function FeedBackLists()
+    {
+        $user_id = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+
+        $data = lm('feedback', 'Commons')->where('account_identity', $user_id)->orderBy('submit_time', 'desc')
+            ->get();
+        $dat = [
+            'see_status' => '1',
+        ];
+        $da = lm('feedback', 'Commons')->where('account_identity', $user_id)
+            ->where('see_status', '0')
+            ->where('status', '1')
+            ->update($dat);
+
+        if ($data) {
+            $data = $data->toArray();
+
+            $Iteas = [
+                'data' => $data,
+            ];
+            Render($Iteas, 1, lang()->get('success'));
+        } else {
+            Render('', '-5001', lang('error')->get('-5001'));
+        }
+    }
+
+    //意见反馈
+    public function FeedBackNum()
+    {
+        $user_id = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+        $data = lm('feedback', 'Commons')->where('account_identity', $user_id)
+            ->where('status', '1')
+            ->where('see_status', '0')
+            ->count();
+        Render($data, 1, lang()->get('success'));
+    }
+
+    //我的消息
+    public function Message()
+    {
+        $user_id = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+        $user_name = isset($_SESSION['uinfo']['account']) ? $_SESSION['uinfo']['account'] : '';
+        $timed=lm('account_detailed','Commons')->where('account_identity',$user_id)->first();
+        $group_codes=$timed['group_code'];
+        $group_codes_arr=explode(',',$group_codes);
+        array_pop($group_codes_arr);
+        $len=count($group_codes_arr);
+        $register_time=$timed['register_time'];
+
+            $sql = "SELECT count(*) as num FROM message WHERE message.type = 3 and ((add_time > '$register_time' AND message.add_type = '2') or add_type='1')";
+            if(is_array($group_codes_arr)&&$len>0){
+                    $sql.=" and (";
+                    foreach ($group_codes_arr as $v){
+                        $sql.=" group_code like '%,".$v.",%' or";
+                    }
+                    $sql .= " toname = 'all') ";
+                }
+            $sql.="and id not in( SELECT message_id from message_read WHERE account_identity = '" . $user_id . "'  GROUP BY message_id)";
+
+            $sqls="SELECT count(*) as num FROM message WHERE  type = 1  and toname = '$user_name' and id not in( SELECT message_id from message_read WHERE  account_identity = '" . $user_id . "'  GROUP BY message_id)";
+            $num1=S('DB')->select($sql);
+            $num2=S('DB')->select($sqls);
+            $num=$num1[0]->num + $num2[0]->num;
+//            return $num[0]->num;
+//            $num=1;
+//            $num=1;
+            Render($num,1);
+    }
+
+    //新增:2018-12-06 Anton liu
+    public function getHomeMsg(){
+        $user_id = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+        //获取最新首页弹出消息
+        $msg = lm('message','Commons')
+            ->where('type','=',3)
+            ->where('is_show','=',1)
+            ->orderBy('add_time','desc')
+            ->first();
+        if($msg){
+            //查看是否已读
+            $read = lm('message_read','Commons')
+                ->where('message_id','=',$msg->id)
+                ->where('account_identity','=',$user_id)
+                ->first();
+            if($read){
+                Render('',-1);
+            }else{
+                Render($msg->toArray(),1);
+            }
+        }else{
+            Render('',-1);
+        }
+    }
+
+    function AllMessageOne(){
+
+        $admin_id= isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+        $admin_name= isset($_SESSION['uinfo']['account']) ? $_SESSION['uinfo']['account'] : '';
+        $group_code=isset($_SESSION['uinfo']['group_code'])?$_SESSION['uinfo']['group_code']:0;
+        $timed=lm('account_detailed','Commons')->where('account_identity',$admin_id)->first();
+
+        $group_code_arr=explode(',',$group_code);
+        array_pop($group_code_arr);//删除最后一个空元素
+        $lenth=count($group_code_arr);
+        $time=$timed['last_time'];
+        $register_time=$timed['register_time'];
+
+            $sql="SELECT * FROM message where  message.type = 3 and ((add_time > '$register_time' AND message.add_type
+= '2') or add_type='1' ) ";
+            if(is_array($group_code_arr)&&$lenth>0){
+                $sql.=" and (";
+                foreach ($group_code_arr as $k=> $v){
+                    $sql.= " group_code LIKE '%,".$v.",%' or";
+                }
+                $sql.=" toname = 'all')";
+            }
+
+ $sql.=" and id not in ( SELECT message_id from message_read WHERE account_identity = '$admin_id'  GROUP BY message_id) order by add_time desc";
+
+            $sqlone="SELECT * FROM message WHERE  type = 1 and toname = '$admin_name' and id not in (SELECT message_id from message_read WHERE account_identity = '" . $admin_id . "'  GROUP BY message_id) order by add_time desc ";
+
+            $sqltwo="SELECT * FROM message WHERE add_time > '$time' and type = 2 and toname = '$admin_name' and id not in( SELECT message_id from message_read WHERE account_identity = '" . $admin_id . "'  GROUP BY message_id) order by add_time desc ";
+        $datas=S('DB')->select($sql);
+        $dataone=S('DB')->select($sqlone);
+        $datatwo=S('DB')->select($sqltwo);
+
+
+        if(empty($datas)){
+            $data= array_merge($dataone,$datas);
+        }
+        if(empty($dataone)){
+            $data= array_merge($datas,$dataone);
+        }
+        if(empty($dataone) && empty($datas)){
+            $datadd= [];
+        }
+        if(!empty($dataone) && !empty($datas)){
+            $data= array_merge($datas,$dataone);
+        }
+
+
+        if (!empty($data)){
+            $i=0;
+            foreach ($data as $v){
+                $dataddd[$v->id]=$v;
+            }
+
+            krsort($dataddd);
+
+            foreach ($dataddd as $vv){
+               $datadd[$i]=$vv;
+               $i++;
+            }
+        }
+
+        $sql = "SELECT count(*) as num FROM message WHERE message.type = 3 and  ((add_time > '$register_time' AND message.add_type = '2') or add_type='1' )";
+        if(is_array($group_code_arr)&&$lenth>0){
+            $sql.=" and (";
+            foreach ($group_code_arr as $k=> $v){
+                $sql.= " group_code LIKE '%,".$v.",%' or";
+            }
+            $sql.=" toname = 'all')";
+        }
+        $sql.=" and id not in( SELECT message_id from message_read WHERE account_identity = '" . $admin_id . "'  GROUP BY message_id)";
+
+        $sqls = "SELECT count(*) as num FROM message WHERE  type = 1  and toname = '$admin_name' and id not in( SELECT message_id from message_read WHERE account_identity = '" . $admin_id . "'  GROUP BY message_id)";
+
+        $num1=S('DB')->select($sql);
+        $num2=S('DB')->select($sqls);
+        $num=$num1[0]->num + $num2[0]->num;
+
+
+        $datas=[
+            'dataone'=>$datadd,
+            'datatwo'=>$datatwo,
+            'data'=>$num,
+        ];
+        return $datas;
+    }
+
+    function AllMessagetwo(){
+
+        $admin_id= isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+        $time=lm('account_detailed','Commons')->where('account_identity',$admin_id)->first();
+
+        $time=$time['last_time'];
+
+        $admin_name= isset($_SESSION['uinfo']['account']) ? $_SESSION['uinfo']['account'] : '';
+            $sql="select *,(select count(id) from message_read where message_id=message.id and account_identity = '{$admin_id}' ) as hasread   from message where add_time > '$time' and type = 2 and toname = '$admin_name' order by add_time desc ";
+
+
+        $data=S('DB')->select($sql);
+
+//        $pagedata=$pagedata[0]['num']/$num;
+//        dump();
+
+        return array('data'=>$data);
+    }
+
+    function AllMessage(){
+        $page=isset($_POST['page'])?intval($_POST['page']):'';
+        $type=isset($_POST['type'])?intval($_POST['type']):"";
+        $num=20;
+
+        $admin_id= isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+        $admin_name= isset($_SESSION['uinfo']['account']) ? $_SESSION['uinfo']['account'] : '';
+        $account_group=isset($_SESSION['uinfo']['group_code'])?$_SESSION['uinfo']['group_code']:'';
+        $group_code_arr=explode(',',$account_group);
+        array_pop($group_code_arr);//删除最后一个空元素
+        $lenth=count($group_code_arr);
+        $timed=lm('account_detailed','Commons')->where('account_identity',$admin_id)->first();
+        $register_time=$timed['register_time'];
+        if (!empty($type)){
+            $pagedata=lm('message','Commons')->where('type',3)->count();
+            $nums=ceil($pagedata/$num);
+            if ($page > $nums){
+                $page= $nums;
+            }elseif ($page == 0){
+                $page=1;
+            }
+
+            $sql="select *,(select count(id) from message_read where message_id=message.id and account_identity = '{$admin_id}' ) as hasread   from message where type = {$type} and message.type = 3 and message.id in (select message_id from message_read where status=1)";
+            if(is_array($group_code_arr)&&$lenth>0){
+                $sql.=" and (";
+                foreach ($group_code_arr as $v){
+                    $sql.=" group_code like '%,".$v.",%' or";
+                }
+                $sql.=" toname ='all' )";
+            }
+
+            $sql.=" and id not in (select message_id from message_read where status=-1 and account_identity = '{$admin_id}') and ((add_time > '$register_time' AND message.add_type = '2') or add_type='1') order by add_time desc   limit {$num}  offset ".(($page-1)*$num);
+        }else{
+//            $pagedata=lm('message','Commons')->where('type',1)->where('toname',$admin_name)->count();
+            $sqls="select count(*) as num from message where (type = 3 or (type = 1 and toname = '$admin_name')) and id not in (select message_id from message_read where status=-1 and account_identity = '{$admin_id}') ";
+            $pagedata=S('DB')->select($sqls);
+            $nums=ceil($pagedata[0]->num/$num);
+            if ($page > $nums){
+                $page= $nums;
+            }elseif ($page == 0){
+                $page=1;
+            }
+            $sql="select *,(select count(id) from message_read where message_id=message.id and account_identity = '{$admin_id}' ) as hasread   from message where message.type = 3";
+            if(is_array($group_code_arr)&&$lenth>0){
+                $sql.=" and (";
+                foreach ($group_code_arr as $v){
+                    $sql.=" group_code like '%,".$v.",%' or ";
+                }
+                $sql.=" toname = 'all')";
+            }
+
+            $sql.=" and id not in (select message_id from message_read where status=-1 and account_identity = '{$admin_id}') and ((add_time > '$register_time' AND message.add_type
+= '2') or add_type='1') or (type = 1 and toname = '$admin_name')   order by add_time desc  limit {$num}  offset ".(($page-1)*$num);
+        }
+        $data=S('DB')->select($sql);
+        $data = json_decode(json_encode($data),1);
+
+        $new    =  $data;
+        return array('data'=>$new,'cont'=>$pagedata,'page'=>$page);
+    }
+
+    function AllMessageModel(){
+        $page=isset($_POST['page'])?intval($_POST['page']):1;
+        $type=isset($_POST['type'])?intval($_POST['type']):"";
+        $num=10;
+        $pagedata=lm('message','Commons')->count();
+
+        $admin_name= isset($_SESSION['uinfo']['account']) ? $_SESSION['uinfo']['account'] : '';
+        $admin_id= isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+        $timed=lm('account_detailed','Commons')->where('account_identity',$admin_id)->first();
+        $group_codes=$timed['group_code'];
+        $group_codes_arr=explode(',',$group_codes);
+        array_pop($group_codes_arr);
+        $len=count($group_codes_arr);
+        $register_time=$timed['register_time'];
+        if (!empty($type)){
+            $sql="select *,(select count(id) from message_read where message_id=message.id and account_identity = '{$admin_id}' ) as hasread   from message where type = {$type} and message.type = 3 ";
+            if(is_array($group_codes_arr)&&$len>0){
+                $sql.=" and (";
+                foreach ($group_codes_arr as $v){
+                    $sql.=" group_code like '%,".$v.",%' or ";
+                }
+                $sql.=" toname = 'all')";
+            }
+            $sql.=" and id not in (select message_id from message_read where status=-1 and account_identity = '{$admin_id}') and ((add_time > '$register_time' AND message.add_type= '2') or add_type='1') order by add_time desc  limit {$num}  offset ".(($page-1)*$num);
+
+        }else{
+            $sql="select *,(select count(id) from message_read where message_id=message.id and account_identity = '{$admin_id}' ) as hasread   from message where (type = 3 or (type = 1 and toname = '$admin_name')) and id not in (select message_id from message_read where status=-1 and account_identity = '{$admin_id}')";
+            if(is_array($group_codes_arr)&&$len>0){
+                $sql.=" and (";
+                foreach ($group_codes_arr as $v){
+                    $sql.=" group_code like '%,".$v.",%' or ";
+                }
+                $sql.=" toname = 'all')";
+            }
+            $sql.=" and id not in (select message_id from message_read where status=-1 and account_identity = '{$admin_id}') and ((add_time > '$register_time' AND message.add_type
+= '2') or add_type='1') or (type = 1 and toname = '$admin_name') order by add_time desc  limit {$num}  offset ".(($page-1)*$num);
+
+        }
+        $data=S('DB')->select($sql);
+//        if($data){
+//            foreach ($data as $k=>$v){
+//                $data_t[$k]['title']=$v->title;
+//                $data_t[$k]['content']=$v->content;
+//                $data_t[$k]['type']=$v->type;
+//                $data_t[$k]['formname']=$v->formname;
+//                $data_t[$k]['toname']=$v->toname;
+//                $data_t[$k]['add_time']=$v->add_time;
+//                $data_t[$k]['id']=$v->id;
+//                $data_t[$k]['status']=$v->status;
+//                $data_t[$k]['message_type']=$v->message_type;
+//                $data_t[$k]['hasread']=$v->hasread;
+////                $data_t[$k]['desc']=substr(strip_tags($data_t[$k]['content']),0,100);
+//            }
+//        }
+
+//        $pagedata=$pagedata[0]['num']/$num;
+//        dump();
+//return array('data'=>$data_t,'cont'=>$pagedata,'page'=>$page);exit;
+//        return Render(array('data'=>$data_t,'cont'=>$pagedata,'page'=>$page),1);
+        return Render($data);
+    }
+
+    //消息列表
+    public function MessageList()
+    {
+        $limit = isset($_GET['limit']) ? $_GET['limit'] : '10';
+
+        $title =isset($_GET['title']) ? $_GET['title'] : '';
+        $message_type = isset($_GET['message_type']) ? $_GET['message_type'] : '';
+        $type = isset($_GET['type']) ? $_GET['type'] : '';
+        $user_name = isset($_SESSION['uinfo']['account']) ? $_SESSION['uinfo']['account'] : '';
+
+        $where = array();
+        $wheres = array();
+        if (!empty($title)) {
+            $where[] = array('title', 'like', '%' . $title . '%');
+            $wheres[] = array('title', 'like', '%' . $title . '%');
+        }
+        if (empty($type)) {
+            $where[] = array('type', '!=', '4');
+            $where[] = array('type', '!=', '2');
+
+
+            $wheres[] = array('type', 'in', '2');
+            $wheres[] = array('toname', '=', $user_name);
+        }
+        if (empty($message_type)) {
+            $where[] = array('message_type', '=', '2');
+            $wheres[] = array('message_type', '=', '2');
+        }
+
+        $data1 = $this->getlist($limit, $where);
+        $data2 = $this->getlist($limit, $wheres);
+
+        if (!empty($data1) || !empty($data2)){
+            $data=array_merge($data1,$data2);
+        }elseif (empty($data1)){
+            $data=$data2;
+        }elseif (empty($data2)){
+            $data=$data1;
+        }else{
+            $data ="";
+        }
+
+        $admin_id= isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+
+        $datas=$this->getlistd($admin_id);
+
+        if (!empty($datas)){
+
+            foreach ($data as $k=>$v){
+                foreach ($datas as $vv){
+                    if($vv['type'] == '1' && $v['id'] == $vv['message_id']){
+
+                        $data[$k]['message_type']='1';
+                    }
+
+                }
+            }
+
+            foreach ($data as $k=>$v){
+                if($v['message_type'] == '2'){
+                    $dat[$k]=$v;
+                }
+            }
+
+            if (!empty($dat)){
+                $data=  $dat;
+            }else{
+                $data="";
+            }
+        }
+
+
+
+        if (!empty($data)) {
+
+            foreach ($data as $k=>$v){
+                foreach ($datas as $val){
+
+
+                    if ($v['id'] == $val['message_id'] && $val['type'] == '3'){
+                        $data[$k]['status']='3';
+                    }elseif ($v['id'] == $val['message_id']){
+                        $data[$k]['status']='1';
+                    }
+
+                }
+            }
+        }
+        return $data;
+    }
+
+    //已读消息
+    public function Tmessage()
+    {
+        $id = isset($_POST['id']) ? $_POST['id'] : '';
+        $admin_id=isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+
+        $dataWhwew=[
+            'type'=>'2',
+        ];
+        $data= $this->MessageUp($id,$admin_id,$dataWhwew);
+
+        return $data;
+    }
+
+    //是否弹出消息
+    public function MessageRed()
+    {
+        $id = isset($_POST['id']) ? $_POST['id'] : '';
+        $admin_id=isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+
+        $dataWhwew=[
+            'message_id'=>$id,
+            'account_identity'=>$admin_id,
+            'add_time'=>date("Y-m-d H:i",time())
+        ];
+
+
+        $dataRead = $this->Messagelista($id,$admin_id);
+        if ($dataRead < 0){
+            $dataRead = $this->addMessage($dataWhwew);
+        }
+        return $dataRead;
+    }
+
+    //消息详情
+    public function MessageL()
+    {
+        $id = isset($_POST['id']) ? $_POST['id'] : '';
+
+
+
+        $dataRead = $this->MessagelistaL($id);
+        if ($dataRead < 0){
+            return -6030001222;
+        }
+        return $dataRead;
+    }
+    //添加消息数据
+    function addMessage($data)
+    {
+        $res = lm('message_read','Commons')->insert($data);
+        if (!$res) {
+            return -6030001222;
+        }
+        return 1;
+    }
+
+    //查询一条数据
+    function MessagelistaL($id)
+    {
+        $res = lm('message','Commons')->where('id',$id)->first();
+        if (!$res) {
+            return -6030001222;
+        }
+        return $res;
+    }
+    //查询一条数据
+    function MessageUp($id,$admin_id,$data)
+    {
+        $res = lm('message_read','Commons')->where('message_id', $id)->where('account_identity', $admin_id)->update($data);
+        if (!$res) {
+            return -6030001222;
+        }
+        return $res;
+    }
+
+    function getlist($list = 10, $where = '') {
+        $data =  lm('message', 'Commons')->orderBy('add_time', 'desc');
+
+        if (!empty($where) && is_array($where)) {
+            $data = $data->where($where)->get();
+        }
+
+
+        if (!$data) {
+            return -4010010022; //没有数据
+        }
+        return $data->toArray();
+    }
+
+    //查询消息
+    function Messagelista($id, $admin_id)
+    {
+        $data = lm('message_read', 'Commons')->where('message_id', $id)->where('account_identity', $admin_id)->first();
+        if (!$data) {
+            return -4010010022; //没有数据
+        }
+        return 1;
+    }
+
+
+    function getlistd($id)
+    {
+
+        $data =  lm('message_read', 'Commons')->where('account_identity', $id)->get();
+
+        if (!$data) {
+            return -4010010022; //没有数据
+        }
+        return $data->toArray();
+    }
+
+	//代理开关
+	public function AgentList() {
+    
+		$data = lm('setinfo', 'Commons')->where('infotype', 13)->first();
+		if ($data) {
+			$data = $data->toArray();
+			Render($data, 1, lang()->get('success'));
+		} else {
+			Render('', '-5001', lang('error')->get('-5001'));
+		}
+	}
+	/**
+	 * 客服qq链接
+	 */
+	public function GetQQ() {
+		$info = lm('setinfo', 'commons')->where('infotype', 16)->first();
+		if (!$info) {
+			Render('', '-5006', lang('error')->get('-5006'));
+		}
+		$data['url'] = 'http://wpa.qq.com/msgrd?v=3&uin=' . $info->infocontent . '&site=qq&menu=yes';
+		$data['wapurl'] = 'mqqwpa://im/chat?chat_type=wpa&uin=' . $info->infocontent . '&version=1';
+		$data['iosurl'] = 'mqq://im/chat?chat_type=wpa&uin=' . $info->infocontent . '&version=1&src_type=web';
+		$data['qq'] = $info->infocontent;
+		Render($data, 1);
+	}
+
+    /**
+     * 联系我们客服信息
+     */
+    public function GetConinfo() {
+        $info = lm('setinfo', 'commons')->where('infotype', 1017)->get();
+        if (!$info) {
+            Render('', '-5006', lang('error')->get('-5006'));
+        }
+        $data = array();
+        foreach ($info as $k => $v) {
+            $data[$v['remarks']] = $v['infocontent'];
+        }
+        //新增图片服务器地址
+        $img = lm('setinfo', 'commons')->where('infotype', 2004)->first();
+        $data['imgserver'] = $img['infocontent'];
+        Render($data, 1);
+    }
+
+	/**
+	 * 银行列表
+	 */
+	public function BankList() {
+		$bank = lm('band_bank', 'commons')->select('bank_name')->get();
+		if (!$bank) {
+			Render('', -5001, lang('error')->get('-5001'));
+		}
+		Render($bank->toArray(), 1);
+	}
+
+
+
+    public function DelMessageRed(){
+        $id = isset($_POST['id']) ? $_POST['id'] : '';
+        $admin_id=isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+
+        $dataWhwew=[
+            'status'=>'-1',
+        ];
+        $ids = explode(',', $id);
+        if (!is_array($ids) && intval($ids) < 0) {
+            return -2002;
+        }
+        if (is_array($ids) && count($ids) > 0) {
+            foreach ($ids as $k => $v) {
+                if (intval($v) < 1) {
+                    unset($ids[$k]);
+                }
+            }
+        }
+        $res = lm('message','Commons')->whereIn('id',$ids)->first();
+        if ($res['type'] == 1 ) {
+            $data = lm('message','Commons')->whereIn('id',$ids)->delete();
+        }else{
+            $data= $this->DelMessageUp($ids,$admin_id,$dataWhwew);
+        }
+
+        return $data;
+    }
+
+
+
+    function DelMessageUp($id,$admin_id,$data)
+    {
+        $res = lm('message_read','Commons')->whereIn('message_id', $id)->where('account_identity', $admin_id)->update($data);
+
+        if (!$res) {
+            return -6030001222;
+        }
+        return $res;
+    }
+
+
+    function GetPageSet(){
+        $data = lm('setinfo', 'commons')->where('infotype', 1024)->first();
+        if (!$data) {
+            Render('', '-5006', lang('error')->get('-5006'));
+        }
+        $data = $data->toArray();
+        Render($data, 1,'获取信息成功');
+    }
+}

+ 133 - 0
Application/Api/Controller/Settings.php

@@ -0,0 +1,133 @@
+<?php
+/**
+ *------Create thems Controller------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-21 07:25:34------
+ */
+
+namespace App\Api\Controller;
+
+//ini_set('display_errors', 1);
+
+//error_reporting(E_ALL);
+use Biz\Game\GameQuery;
+
+define('SETTINGS_REMOTE_KEY', '14e1b600b1fd579f47433b88e8d85291');
+
+class Settings extends BaseController {
+
+    function init() {
+    }
+
+
+    function Query() {
+        $game = isset($_GET['game']) && !empty($_GET['game']) ? $_GET['game'] : null;
+        $playtype = isset($_GET['playtype']) && !empty($_GET['playtype']) ? $_GET['playtype'] : null;
+        if (!$game) {
+            Render('', -3216); //查询游戏设置,游戏名不能为空
+        }
+        $key = empty($playtype) ? $game : $game . $playtype;
+        if (C()->get('cache')->has('odds-' . $key)) {
+            $items = C()->get('cache')->get('odds-' . $key);
+
+        } else {
+            $cls = "\\Biz\\Game\\Settings\\" . ucfirst($game) . "Settings";
+            $settings = new $cls();
+            $items = $settings->get($playtype);
+            // dump($items);
+            if ($items < 0) {
+                Render('', $items); //查询游戏设置,游戏名不能为空
+            }
+            C()->get('cache')->set('odds-' . $key, $items, 60);
+        }
+
+        Render($items);
+    }
+
+
+    //更新缓存
+    public function odds() {
+
+        $clear = isset($_REQUEST['clear']) && ($_REQUEST['clear'] == '-99999') ? 1 : 0;
+//        $odds=C()->get('cache')->get('odds-list');
+        $lastTime = C()->get('cache')->get('odds-lastUpdateTime');
+        $times = $this->getUpdateTime();
+
+        if (empty($lastTime) || $clear) {
+            $this->_buildOdds();
+            // header('location:/Cache/odds.json');
+            //Render($odds,1,strtotime($lastTime) .'='.$times);
+
+        }
+        if (empty($times)) {
+            $times = strtotime($lastTime);
+        }
+        if (strtotime($lastTime) < $times) {
+            $this->_buildOdds();
+            //返回所有最新赔率               
+        }
+        // header('location:/Cache/odds.json');
+        $json = file_get_contents(ROOT_PATH . '/Cache/odds.json');
+        file_put_contents(ROOT_PATH . '/Cache/odds2.json',$json);
+        if (!$json) {
+            $this->_buildOdds();
+            $json = file_get_contents(ROOT_PATH . '/Cache/odds.json');
+        }
+        $data=json_decode($json,1);
+        Render($data, 1, strtotime($lastTime) . '+' . $times);
+
+    }
+
+
+    /**
+     * 得到系统更新的赔率修改时间
+     *
+     * @return void
+     */
+    private function getUpdateTime() {
+        $time = lm('Setinfo', 'commons')->getType(1911);
+        return strtotime($time);
+    }
+
+    /**
+     * 生成赔率根据数据
+     *
+     * @param [type] $oddsList 存储赔率生成结果数组
+     * @param [type] $game 游戏名称
+     * @param [type] $table_data  指定游戏的数据表的赔率记录信息
+     * @return void
+     */
+    private function _build_odds(&$oddsList, $game, $table_data) {
+        $cls = "\\Biz\\Game\\Settings\\" . ucfirst($game) . "Settings";
+        if (!class_exists($cls)) {
+            return -1;
+        }
+        $settings = new $cls(0);
+        $settings->setOddsSettings($table_data);
+        $items = $settings->get('');
+        if ($items < 0) {
+            return -2;
+        }
+        $oddsList[] = array('game_type' => $game, 'odds' => $items);
+    }
+
+    private function _buildOdds() {
+        //本地缓存和服务器比较
+        $allOdds = lm('Game_odds', 'Commons')->get(['game_type', 'odds', 'update_time']);
+        if (!$allOdds) {
+            Render('', -7029); //赔率数据不存在
+        }
+        $oddsList = array();
+
+        foreach ($allOdds as $odds_item) {
+            $this->_build_odds($oddsList, $odds_item->game_type, $odds_item);
+        }
+
+        $time = date('Y-m-d H:i:s', time());
+        C()->get('cache')->set('odds-lastUpdateTime', $time, 31536000); //最后更新时间
+        C()->get('cache')->set('odds-list', $oddsList, 31536000);
+        file_put_contents(ROOT_PATH . '/Cache/odds.json', json_encode($oddsList));
+        return $oddsList;
+    }
+}

+ 69 - 0
Application/Api/Controller/Signin.php

@@ -0,0 +1,69 @@
+<?php
+    /**
+     * Created by PhpStorm.
+     * User: Lenovo
+     * Date: 2018/10/15
+     * Time: 16:25
+     */
+
+ namespace App\Api\Controller;
+use Biz\Account\AccountManager;
+use Illuminate\Contracts\Session\Session;
+
+//ini_set('display_errors',1);
+//error_reporting(E_ALL);
+    class Signin extends BaseController
+    {
+
+        //获取用户信息
+        private function userInfo(){
+
+            $userinfo = isset($_SESSION["uinfo"])?$_SESSION["uinfo"]:[];
+            if(empty($userinfo))Render('',-4001);
+            return   $userinfo;
+        }
+
+        //当前彩金信息
+        private function lotteryInfo($type='sign'){
+            $info   =       $lottery = lm ('lottery_money', 'Api')->where ('type',$type)->first ();
+            if(empty($info))Render('',-5007);
+            return $info->toarray();
+        }
+
+
+        //查看用户连续签到天数
+        private function countSignDays($id,$account_identity,$grade){
+
+          $days   =   lm('Lottery_money_log','Api')->Signin(['lottery_money_id'=>$id,'account_identity'=>$account_identity,'grade' =>$grade]);
+            if(empty($days))Render('',-600017);
+           return $days;
+        }
+
+        //今天是否签到
+        private function signStatus($userid){
+            $has   =   lm('Lottery_money_log','Api')->todaySignin(['account_identity'=>$userid]);
+            if($has<0)Render('',$has);
+            return $has;
+
+        }
+
+        public function signInfo(){
+            $grade = ($this->userInfo())["grade"];
+            $id     =  ($this->lotteryInfo())["id"];
+            $userid = ($this->userInfo())["account_identity"];
+            $days   =   $this->countSignDays($id,$userid,$grade);
+            $status =   $this->signStatus($userid);
+            if(empty($days))Render('',$days);
+            if($status<0)Render('',$status);
+
+           Render(['days'=>$days,'signed'=>$status["active"],'money'=>$status["money"],'time'=>$status["create_time"]],1) ;
+        }
+
+        //签到
+        public function goSign(){
+            $re=C()->get('SignActive')->main($this->userInfo()['account_identity']);
+            is_array($re)? Render($re,1): Render('',$re);
+        }
+
+
+    }

+ 50 - 0
Application/Api/Controller/SystemInfo.php

@@ -0,0 +1,50 @@
+<?php
+    /**
+     * Created by PhpStorm.
+     * User: Lenovo
+     * Date: 2018/10/30
+     * Time: 17:34
+     */
+
+    namespace App\Api\Controller;
+
+
+    class SystemInfo extends BaseController
+    {
+        //获取网站基本信息、平台维护状态
+        function GetNetworkInfo()
+        {
+            $data = lm('Setinfo', 'Commons')
+                ->select('identity', 'infoname', 'infocontent', 'extinfo', 'remarks', 'status', 'infotype')
+                ->whereIn('infotype', array(0, 24))
+                ->get();
+            if ($data && count($data->toArray()) > 0) Render($data->toArray(), 1);
+            Render('', -5201);
+
+        }
+
+        function DefaultInfo()
+        {
+            $cache  =      C()->get('cache')->get('DefaultInfo');
+            if(!empty($cache))
+
+            Render(json_decode($cache,1));
+
+            //--Bruce--合并接口
+            $info = lm('setinfo', 'commons')->whereIn('infotype', [2004, 2001, 1017, 24,100,20060])->orderBy('infotype', 'desc')->get(['identity', 'infoname', 'infocontent', 'extinfo', 'remarks', 'status', 'infotype']);
+            if (!$info) {
+                Render('', -5201);
+            }
+//            $infodata = [];
+//            foreach ($info as $v) {
+//                if (in_array($v['infotype'], [2001, 2004, 1017])) {
+//                    $infodata[$v['remarks']] = $v['infocontent'];
+//                } else {
+//                    $infodata[] = $v;
+//                }
+//            }
+            $ret    =array_column($info->toarray(),'infocontent','remarks');
+            C()->get('cache')->set('DefaultInfo',json_encode($ret),600);
+            Render($ret, 1);
+        }
+    }

+ 27 - 0
Application/Api/Controller/Token.php

@@ -0,0 +1,27 @@
+<?php
+/**
+*------Create thems Controller------
+*------SCWPHP  Version 1.0.0------
+*------Dev Model Jions------
+*------Create Time 2017-06-07 05:31:59------
+*/
+namespace App\Api\Controller;
+use \Biz\TokenManager as TokenManager;
+class Token extends BaseController {
+
+
+	Public function Index(){
+
+	}
+
+	public function Login(){
+		$str_token=isset($_GET['token']) && !empty($_GET['token'])?trim($_GET['token']):'';
+		if(empty($str_token)){
+			return -2;
+		}
+		$token=new TokenManager();
+		$token->doLogin($str_token);
+		return 1;
+	}
+
+}

+ 191 - 0
Application/Api/Controller/UserBuy.php

@@ -0,0 +1,191 @@
+<?php
+/**
+ *------Create thems Controller------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-08 10:07:19------
+ */
+
+namespace App\Api\Controller;
+
+use App\Api\Model\Lottery_money;
+use App\Api\Model\Lottery_money_log;
+
+use App\Api\Model\MoneyBuy;
+use App\Api\Model\MoneyRecharge;
+use App\Api\Model\MoneyPrize;
+use App\Api\Model\Withdraw;
+use Biz\Common\Common;
+use Biz\Game\GameList;
+use System\Lang;
+use \Exception;
+
+
+class UserBuy extends BaseController {
+
+    public function init() {}
+
+    /**
+     * 投注记录
+     *
+     * @access public
+     * @return array JsonString
+     */
+    public function bettingRecord() {
+        $code = 0;
+        $msg = lang('Common','Api') -> get('error');
+        try{
+            $moneyBuyClass = new MoneyBuy();
+            // 获取下注信息
+            if ($_POST['type'] == 2) {
+                $result = $moneyBuyClass -> stringBetRecord();
+            } else {
+                $result = $moneyBuyClass -> singleBetRecord();
+            }
+            $code = 1;
+            $msg = lang('Index','Api') -> get('success');
+
+            Render($result, $code, $msg);
+        } catch (Exception $e) {
+            Render([], $code, $msg);
+        }
+    }
+
+    /**
+     * 盈亏记录
+     *
+     * @access public
+     * @return array JsonString
+     */
+    public function moneyRecord() {
+        $code = 0;
+        $msg = lang('Common','Api') -> get('error');
+        try{
+            $moneyBuyClass = new MoneyBuy();
+            // 获取盈亏记录
+            $result = $moneyBuyClass -> moneyRecord();
+            $code = 1;
+            $msg = lang('Index','Api') -> get('success');
+
+            Render($result, $code, $msg);
+        } catch (Exception $e) {
+            Render([], $code, $msg);
+            //Render([], $code, $e->getMessage());
+        }
+    }
+
+    /**
+     * 充值记录
+     *
+     * @access public
+     * @return array JsonString
+     */
+    public function rechargeRecord() {
+        $code = 0;
+        $msg = lang('Common','Api') -> get('error');
+        try{
+            $moneyRechargeClass = new MoneyRecharge();
+            // 获取充值记录
+            $result = $moneyRechargeClass -> rechargeRecord();
+            $result['code'] = 1;
+            $code = 1;
+            $msg = lang('Index','Api') -> get('success');
+
+            Render($result, $code, $msg);
+        } catch (Exception $e) {
+            Render([], $code, $msg);
+            //Render([], $code, $e->getMessage());
+        }
+    }
+
+    /**
+     * 取款记录
+     *
+     * @access public
+     * @return array JsonString
+     */
+    public function moneyOutRecord() {
+        $code = 0;
+        $msg = lang('Common','Api') -> get('error');
+        try{
+            $moneyRechargeClass = new MoneyRecharge();
+            // 获取取款记录
+            $result = $moneyRechargeClass -> moneyOutRecord();
+            $code = 1;
+            $msg = lang('Index','Api') -> get('success');
+
+            Render($result, $code, $msg);
+        } catch (Exception $e) {
+            Render([], $code, $msg);
+        }
+    }
+
+    /**
+     * 中奖记录
+     *
+     * @access public
+     * @return array JsonString
+     */
+    public function prizeRecord() {
+        $code = 0;
+        $msg = lang('Common','Api') -> get('error');
+        try{
+            $moneyRechargeClass = new MoneyPrize();
+            // 获取充值记录
+            $result = $moneyRechargeClass -> prizeRecord();
+            $code = 1;
+            $msg = lang('Index','Api') -> get('success');
+
+            Render($result, $code, $msg);
+        } catch (Exception $e) {
+            Render([], $code, $msg);
+            //Render([], $code, $e->getMessage());
+        }
+    }
+
+    /**
+     * 提款申请
+     *
+     * @access public
+     * @return array JsonString
+     */
+    public function withdrawalRequest() {
+        $code = 0;
+        $msg = lang('Common','Api') -> get('error');
+        try{
+            $withdrawClass = new Withdraw();
+            // 提款申请
+            $result = $withdrawClass -> withdrawalRequest();
+            $code = 1;
+            $msg = lang('Index','Api') -> get('success');
+
+            Render($result, $code, $msg);
+        } catch (Exception $e) {
+            Render([], $code, $msg);
+            //Render([], $code, $e->getMessage());
+        }
+    }
+
+    /**
+     * 个人中心初始显示
+     *
+     * @access public
+     * @return array JsonString
+     */
+    public function index() {
+        $code = 0;
+        $msg = lang('Common','Api') -> get('error');
+        try{
+            $MoneyBuyModel = new MoneyBuy();
+            // 数据获取
+            $result = $MoneyBuyModel -> monthRecord();
+            $code = 1;
+            $msg = lang('Index','Api') -> get('success');
+
+            Render($result, $code, $msg);
+        } catch (Exception $e) {
+            Render([], $code, $msg);
+            //Render([], $code, $e->getMessage());
+        }
+    }
+}

+ 833 - 0
Application/Api/Controller/UserDetails.php

@@ -0,0 +1,833 @@
+<?php
+/**
+ *------Create thems Controller------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-19 18:04:54------
+ */
+
+namespace App\Api\Controller;
+//ini_set('display_errors', 1);
+//
+//error_reporting(E_ALL);
+class UserDetails extends BaseController {
+
+    /**
+     * 用户明细列表
+     * @return [type] [description]
+     */
+    public function MoneyList() {
+        $moneyClass = new \Biz\Money\MoneyQuery;
+        $data = array();
+        $data['account_identity'] = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+        $res = $moneyClass->Winning($data);
+        //echo $res;
+        Render($res, '1', 'success');
+    }
+
+    /**
+     * 资金流水订单详情
+     * @return [type] [description]
+     */
+    public function MoneyDetail() {
+        $moneyClass = new \Biz\Money\MoneyQuery;
+        $data = array();
+        $order_id = isset($_REQUEST['order_id']) ? $_REQUEST['order_id'] : '';
+        if (empty($order_id)) Render('', '-4046');
+        $res = $moneyClass->MorderDetail($order_id);
+        //echo $res;
+        if ($res < 0) Render('', $res);
+        Render($res, '1', 'success');
+    }
+
+    /**
+     * 充值列表
+     * @return [type] [description]
+     */
+    public function MoneyRecharge() {
+        $moneyClass = new \Biz\Money\MoneyQuery;
+        $data['account_identity'] = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+        $data['status'] = isset($_POST['status']) ? $_POST['status'] : '';
+        $data['order_id'] = isset($_POST['order_id']) ? $_POST['order_id'] : '';
+        $data['page'] = isset($_POST['page']) ? $_POST['page'] : '';
+        $res = $moneyClass->Recharge($data);
+        //echo $res;
+        Render($res, '1', 'success');
+    }
+
+    /**
+     * 提现列表
+     * @return [type] [description]
+     */
+    public function MoneyTake() {
+        $moneyClass = new \Biz\Money\MoneyQuery;
+        $data['account_identity'] = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+        $data['status'] = isset($_POST['status']) ? $_POST['status'] : '';
+        $data['order_id'] = isset($_POST['order_id']) ? $_POST['order_id'] : '';
+        $data['page'] = isset($_POST['page']) ? $_POST['page'] : '';
+        $res = $moneyClass->Withdrawals($data);
+        //echo $res;
+        Render($res, '1', 'success');
+    }
+
+
+    //彩金升级记录
+
+    public function cToUpgrade() {
+        $moneyClass = new \Biz\Money\MoneyQuery;
+        $data['account_identity'] = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+        $data['create_time'] = isset($_POST['create_time']) ? $_POST['create_time'] : '';
+        $data['page'] = isset($_POST['page']) ? $_POST['page'] : '';
+        $res = $moneyClass->cToUpgrade($data);
+
+        //echo $res;
+        Render($res, '1', 'success');
+    }
+
+    //新增查询彩金记录
+    public function getLotteryLog() {
+        $moneyClass = new \Biz\Money\MoneyQuery;
+        $data['account_identity'] = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+        if (empty($data['account_identity'])) {
+            Render('', -4010, '缺少用户唯一标识');
+        }
+        $data['time'] = isset($_POST['time']) ? $_POST['time'] : '';
+        if (empty($data['time'])) {
+            Render('', -4010, '缺少时间参数');
+        }
+        $data['page'] = isset($_POST['page']) ? $_POST['page'] : 1;
+        $log = $moneyClass->getLotteryLog($data);
+        if ($log < 0) {
+            Render('', $log, '获取数据失败');
+        }
+        Render($log, 1, '获取数据成功');
+    }
+
+
+    //彩金详细
+    public function cToDetail() {
+
+        $moneyClass = new \Biz\Money\MoneyQuery;
+        $data['account_identity'] = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+        $data['uid'] = isset($_POST['uid']) ? $_POST['uid'] : '';
+        $data['money_type'] = isset($_POST['money_type']) ? $_POST['money_type'] : '';
+        $res = $moneyClass->CToDetail($data);
+        //echo $res;
+        Render($res, '1', 'success');
+    }
+
+    //充值明细新
+    public function saveMoneyRecord() {
+        $moneyClass = new \Biz\Money\MoneyQuery;
+        $data['account_identity'] = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+        $data['status'] = isset($_POST['status']) ? $_POST['status'] : '';
+        $data['order_id'] = isset($_POST['order_id']) ? $_POST['order_id'] : '';
+        $data['page'] = isset($_POST['page']) ? $_POST['page'] : '';
+        $data['time'] = isset($_POST['time']) ? $_POST['time'] : '';
+        $res = $moneyClass->saveMoneyRecord($data);
+        //echo $res;
+        Render($res, '1', 'success');
+    }
+
+    //提款明细新
+    public function takeMoneyRecord() {
+        $moneyClass = new \Biz\Money\MoneyQuery;
+        $data['account_identity'] = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+        $data['status'] = isset($_POST['status']) ? $_POST['status'] : '';
+        $data['order_id'] = isset($_POST['order_id']) ? $_POST['order_id'] : '';
+        $data['page'] = isset($_POST['page']) ? $_POST['page'] : '';
+        $data['time'] = isset($_POST['time']) ? $_POST['time'] : '';
+        $res = $moneyClass->takeMoneyRecord($data);
+//        dump($res);
+        if (intval($res) < 0) {
+            Render('',$res);
+        }
+        Render($res, '1', 'success');
+    }
+
+
+    /**
+     * 充值列表
+     * @return [type] [description]
+     */
+    public function PCMoneyRecharge() {
+        $moneyClass = new \Biz\Money\MoneyQuery;
+        $data['account_identity'] = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+        $data['id'] = isset($_POST['id']) ? $_POST['id'] : "";
+        $data['num1'] = isset($_POST['num1']) ? $_POST['num1'] : "";
+        $data['num2'] = isset($_POST['num2']) ? $_POST['num2'] : "";
+        $data['time'] = isset($_POST['time']) ? $_POST['time'] : "";
+        $data['page'] = isset($_POST['page']) ? $_POST['page'] : "1";
+        $res = $moneyClass->PCRecharge($data);
+        //echo $res;
+        Render($res, '1', 'success');
+    }
+
+    /**
+     * 提现列表
+     * @return [type] [description]
+     */
+    public function PCMoneyTake() {
+        $moneyClass = new \Biz\Money\MoneyQuery;
+        $data['account_identity'] = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+        $data['id'] = isset($_POST['id']) ? $_POST['id'] : "";
+        $data['num1'] = isset($_POST['num1']) ? $_POST['num1'] : "";
+        $data['num2'] = isset($_POST['num2']) ? $_POST['num2'] : "";
+        $data['time'] = isset($_POST['time']) ? $_POST['time'] : "";
+        $data['page'] = isset($_POST['page']) ? $_POST['page'] : "1";
+        $res = $moneyClass->PCWithdrawals($data);
+        //echo $res;
+        Render($res, '1', 'success');
+    }
+
+    /**
+     * PC用户明细列表
+     * @return [type] [description]
+     */
+    public function PCMoneyList() {
+        $moneyClass = new \Biz\Money\MoneyQuery;
+        $data = array();
+        $data['account_identity'] = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+        $data['id'] = isset($_POST['id']) ? $_POST['id'] : "";
+        $data['num1'] = isset($_POST['num1']) ? $_POST['num1'] : "";
+        $data['num2'] = isset($_POST['num2']) ? $_POST['num2'] : "";
+        $data['time'] = isset($_POST['time']) ? $_POST['time'] : "";
+        $data['page'] = isset($_POST['page']) ? $_POST['page'] : "1";
+        $data['trade_type'] = isset($_POST['trade_type']) ? $_POST['trade_type'] : "";
+        $res = $moneyClass->PcWinning($data);
+        //echo $res;
+        Render($res, '1', 'success');
+    }
+
+
+    public function OGMoney() {
+        $moneyClass = new \Biz\Money\MoneyQuery;
+        $data = array();
+        $kyreturnMoney = 0;
+        $ogreturnMoney = 0;
+        $backMoney = 0;
+        $data['account_identity'] = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+        $a = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+        $data['time'] = isset($_POST['time']) ? $_POST['time'] : date('Y-m-d');
+        if(empty($data['time'])){
+            $data['time'] = date('Y-m-d');
+        }
+        $kywhere[] = array('GameEndTime','>=',$data['time'].' 00:00:00');
+        $kywhere[] = array('GameEndTime','<=',$data['time'].' 23:59:59');
+        $ogwheres[] = array('AddTime','>=',strtotime($data['time'].' 00:00:00'));
+        $ogwheres[] = array('AddTime','<=',strtotime($data['time'].' 23:59:59'));
+        $where[] = array('pass_time','>=',strtotime($data['time'].' 00:00:00'));
+        $where[] = array('pass_time','<=',strtotime($data['time'].' 23:59:59'));
+        $agwhere[] = array('recalcuTime','>=',strtotime($data['time'].' 00:00:00'));
+        $agwhere[] = array('recalcuTime','<=',strtotime($data['time'].' 23:59:59'));
+		$hjwhere[] = array('bet_time','>=',$data['time'].' 00:00:00');
+		$hjwhere[] = array('bet_time','<=',$data['time'].' 23:59:59');
+		
+        $kybetting_money = lm("Kygame_betting_ogrbv", "commons")->where('account_identity',$data['account_identity'])->where($kywhere)->sum('CellScore');
+        $ogbetting_money = lm("Oggame_betting_ogrbv", "commons")->where('account_identity',$data['account_identity'])->where($ogwheres)->sum('BettingAmount');
+        //$agbetting_money = lm("Aggame_betting_ogrbv", "commons")->where('account_identity',$data['account_identity'])->where($agwhere)->sum('validBetAmount');
+        $lcqpbetting_money = lm("Lcqpgame_betting_ogrbv", "commons")->where('account_identity',$data['account_identity'])->where($kywhere)->sum('CellScore');
+        $lybetting_money = lm("Lygame_betting_ogrbv", "commons")->where('account_identity',$data['account_identity'])->where($kywhere)->sum('CellScore');
+		$hjbetting_money = lm("Hjgame_betting_ogrbv", "commons")->where('account_identity',$data['account_identity'])->where($hjwhere)->sum('bet_amount');
+
+
+        $kywin_money = lm("Kygame_betting_ogrbv", "commons")->where('account_identity',$data['account_identity'])->where('Profit','>',0)->where($kywhere)->sum('Profit');
+        $ogwin_money = lm("Oggame_betting_ogrbv", "commons")->where('account_identity',$data['account_identity'])->where('WinLoseAmount','>',0)->where($ogwheres)->sum('WinLoseAmount');
+        //$agwin_money = lm("Aggame_betting_ogrbv", "commons")->where('account_identity',$data['account_identity'])->where('netAmount','>',0)->where($agwhere)->sum('netAmount');
+        $lcqpwin_money = lm("Lcqpgame_betting_ogrbv", "commons")->where('account_identity',$data['account_identity'])->where('Profit','>',0)->where($kywhere)->sum('Profit');
+        $lywin_money = lm("Lygame_betting_ogrbv", "commons")->where('account_identity',$data['account_identity'])->where('Profit','>',0)->where($kywhere)->sum('Profit');
+		$hjwin_money = lm("Hjgame_betting_ogrbv", "commons")->where('account_identity',$data['account_identity'])->where('state',1)->where($hjwhere)->sum('profit');
+
+        $ogreturnMoney = lm("Og_backwater", "commons")->where('account_identity',$data['account_identity'])->where('game_type','Oggame')->where($where)->sum('money');    //返水金额
+        $kyreturnMoney = lm("Og_backwater", "commons")->where('account_identity',$data['account_identity'])->where('game_type','Kygame')->where($where)->sum('money');    //返水金额
+        $lcqpreturnMoney = lm("Og_backwater", "commons")->where('account_identity',$data['account_identity'])->where('game_type','Lcqpgame')->where($where)->sum('money');
+        $lyreturnMoney = lm("Og_backwater", "commons")->where('account_identity',$data['account_identity'])->where('game_type','Lygame')->where($where)->sum('money');    //返水金额
+        //$agreturnMoney = lm("Og_backwater", "commons")->where('account_identity',$data['account_identity'])->where('game_type','Kygame')->where($where)->sum('money');    //返水金额
+		$hjreturnMoney = lm("Og_backwater", "commons")->where('account_identity',$data['account_identity'])->where('game_type','Hjgame')->where($where)->sum('money');
+	
+		$ogwin = $ogwin_money-$ogbetting_money;//赢亏
+        $kywin = $kywin_money-$kybetting_money;//赢亏
+        //$agwin = $agwin_money-$agbetting_money;//赢亏
+        $lcqpwin = $lcqpwin_money-$lcqpbetting_money;//赢亏
+        $lywin = $lywin_money-$lybetting_money;//赢亏
+        $hjwin = $hjwin_money-$hjbetting_money;//赢亏
+        if ($ogreturnMoney < 0) {
+            $ogreturnMoney = 0;
+        }
+        if ($kyreturnMoney < 0) {
+            $kyreturnMoney = 0;
+        }
+        if ($ogwin_money < 0) {
+            $ogwin_money = 0;
+        }
+        if ($kywin_money < 0) {
+            $kywin_money = 0;
+        }
+        if ($kybetting_money < 0) {
+            $kybetting_money = 0;
+        }
+        if ($ogbetting_money < 0) {
+            $ogbetting_money = 0;
+        }
+        // if ($agbetting_money < 0) {
+        //     $agbetting_money = 0;
+        // }
+
+        $lcqpbetting_money = ($lcqpbetting_money<0)? 0 : $lcqpbetting_money;
+        $lybetting_money = ($lybetting_money<0)? 0 : $lybetting_money;
+        // $data = lm('account_detailed', "Commons")->where('account_identity', $a)->first()->toArray();
+
+        $dat = array(
+            'kywin_money' => sprintf("%.2f", $kywin_money),
+            'ogwin_money' => sprintf("%.2f", $ogwin_money),
+            //'agwin_money' => sprintf("%.2f", $agwin_money),
+            'lcqpwin_money' => sprintf("%.2f", $lcqpwin_money),
+            'lywin_money' => sprintf("%.2f", $lywin_money),
+            'hjwin_money' => sprintf("%.2f", $hjwin_money),
+            
+            'kybetting_money' => sprintf("%.2f", $kybetting_money),
+            'ogbetting_money' => sprintf("%.2f", $ogbetting_money),
+            //'agbetting_money' => sprintf("%.2f", $agbetting_money),
+            'lcqpbetting_money' => sprintf("%.2f", $lcqpbetting_money),
+            'lybetting_money' => sprintf("%.2f", $lybetting_money),
+            'hjbetting_money' => sprintf("%.2f", $hjbetting_money),
+            
+  
+            'kyreturnMoney' => sprintf("%.2f", $kyreturnMoney),
+            'ogreturnMoney' => sprintf("%.2f", $ogreturnMoney),
+            'lcqpreturnMoney' => sprintf("%.2f", $lcqpreturnMoney),
+            'lyreturnMoney' => sprintf("%.2f", $lyreturnMoney),
+            //'agreturnMoney' => sprintf("%.2f", $agreturnMoney),
+			'hjreturnMoney' => sprintf("%.2f", $hjreturnMoney),
+            
+            'kywin' => sprintf("%.2f", $kywin),
+            'ogwin' => sprintf("%.2f", $ogwin),
+            //'agwin' => sprintf("%.2f", $agwin),
+            'lcqpwin' => sprintf("%.2f", $lcqpwin),
+            'lywin' => sprintf("%.2f", $lywin),
+            'hjwin' => sprintf("%.2f", $hjwin),
+        );
+        Render($dat, '1', 'success');
+    }
+
+    /**
+     * PC用户明细列表
+     * @return [type] [description]
+     */
+    public function PCNewMoney() {
+        $moneyClass = new \Biz\Money\MoneyQuery;
+        $data = array();
+        $withdrawalsMoney = 0;
+        $rechargeMoney = 0;
+        $betMoney = 0;
+        $winMoney = 0;
+        $profitMoney = 0;
+        $returnMoney = 0;
+        $backMoney = 0;
+        $data['account_identity'] = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+        $a = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+        $data['id'] = isset($_POST['id']) ? $_POST['id'] : "";
+        $data['num1'] = isset($_POST['num1']) ? $_POST['num1'] : "";
+        $data['num2'] = isset($_POST['num2']) ? $_POST['num2'] : "";
+        $data['time'] = isset($_POST['time']) ? $_POST['time'] : date('Y-m-d');//qtx 2018-12-25
+        if(empty($data['time'])){//qtx 2018-12-25
+        	$data['time'] = date('Y-m-d');
+        }
+
+        $withdrawalsMoney = $moneyClass->PCRecharge($data, 1);    //充值金额
+
+        $rechargeMoney = $moneyClass->PCWithdrawals($data, 1);    //提现金额
+        $backMoney = $moneyClass->backWaterMoney($data, 1);    //回水金额
+        $returnMoney = $moneyClass->returnMoney($data, 3);    //返水金额
+        if ($backMoney < 0) {
+            $backMoney = 0;
+        }
+        if ($returnMoney < 0) {
+            $returnMoney = 0;
+        }
+        $data = array();
+        $data['account_identity'] = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+        $data['start'] = isset($_POST['start']) ? $_POST['start'] : "";
+        $data['end'] = isset($_POST['end']) ? $_POST['end'] : "";
+        $data['time'] = isset($_POST['time']) ? $_POST['time'] : date('Y-m-d');//qtx 2018-12-25
+        if(empty($data['time'])){//qtx 2018-12-25
+        	$data['time'] = date('Y-m-d');
+        }
+        //dump($data);
+        $resMoney = $moneyClass->EffectiveBetting($data, 1);
+        $sixresMoney = $moneyClass->EffectivesixBetting($data, 1);
+        $data = lm('account_detailed', "Commons")->where('account_identity', $a)->first()->toArray();
+
+        $dat = array(//qtx 2018-12-19
+            'withdrawalsMoney' => $withdrawalsMoney,
+            'rechargeMoney' => $rechargeMoney,
+            'cash' => $data['cash'],
+            'betMoney' => sprintf("%.2f", $resMoney['countMoney']),
+            'winMoney' => sprintf("%.2f", $resMoney['winMoney']),
+            'profitMoney' => sprintf("%.2f", $resMoney['profitMoney']),
+            'sumbet' => sprintf("%.2f", $resMoney['sumbet']),
+            'noawardbet' => sprintf("%.2f", $resMoney['noawardbet']),
+            'cancelbet' => sprintf("%.2f", $resMoney['cancelbet']),
+            'backMoney' => sprintf("%.2f", $backMoney),
+            'returnMoney' => sprintf("%.2f", $returnMoney),
+            'sixbetMoney' => sprintf("%.2f", $sixresMoney['sixcountMoney']),
+            'sixwinMoney' => sprintf("%.2f", $sixresMoney['sixwinMoney']),
+            'sixprofitMoney' => sprintf("%.2f", $sixresMoney['sixprofitMoney']),
+            'sixsumbet' => sprintf("%.2f", $sixresMoney['sixsumbet']),
+            'sixnoawardbet' => sprintf("%.2f", $sixresMoney['sixnoawardbet']),
+            'sixcancelbet' => sprintf("%.2f", $sixresMoney['sixcancelbet']),
+        );
+        Render($dat, '1', 'success');
+    }
+
+    /**
+     * PC投注记录和追号记录
+     * @return [type] [description]
+     */
+    public function PcBettingRecord() {
+        $moneyClass = new \Biz\Money\MoneyQuery;
+        $data = array();
+        $data['account_identity'] = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+        $data['game'] = isset($_POST['game']) ? $_POST['game'] : "";
+        $data['money_time'] = isset($_POST['money_time']) ? $_POST['money_time'] : "";
+        $data['time1'] = isset($_POST['time1']) ? $_POST['time1'] : "";
+        $data['time2'] = isset($_POST['time2']) ? $_POST['time2'] : "";
+        $data['no'] = isset($_POST['no']) ? $_POST['no'] : "";
+        $data['page'] = isset($_POST['page']) ? $_POST['page'] : "1";
+        $data['status'] = isset($_POST['status']) ? $_POST['status'] : "";
+        $data['id'] = isset($_POST['id']) ? $_POST['id'] : "";
+        $data['order_id'] = isset($_POST['order_id']) ? $_POST['order_id'] : "";
+        $res = $moneyClass->PcBettingRecord($data);
+        //echo $res;
+        Render($res, '1', 'success');
+    }
+
+    /**
+     * PC投注记录和追号记录
+     * @return [type] [description]
+     */
+    public function PcSixlotteryRecord() {
+        $moneyClass = new \Biz\Money\MoneyQuery;
+        $data = array();
+        $data['account_identity'] = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+        $data['game'] = isset($_POST['game']) ? $_POST['game'] : "";
+        $data['money_time'] = isset($_POST['money_time']) ? $_POST['money_time'] : "";
+        $data['time1'] = isset($_POST['time1']) ? $_POST['time1'] : "";
+        $data['time2'] = isset($_POST['time2']) ? $_POST['time2'] : "";
+        $data['no'] = isset($_POST['no']) ? $_POST['no'] : "";
+        $data['page'] = isset($_POST['page']) ? $_POST['page'] : "1";
+        $data['status'] = isset($_POST['status']) ? $_POST['status'] : "";
+        $data['id'] = isset($_POST['id']) ? $_POST['id'] : "";
+        $data['order_id'] = isset($_POST['order_id']) ? $_POST['order_id'] : "";
+        $res = $moneyClass->PcSixlotteryRecord($data);
+        //echo $res;
+        Render($res, '1', 'success');
+    }
+
+    /**
+     * PC塞子游戏投注记录
+     * @return [type] [description]
+     */
+    public function PcDiceBettingRecord() {
+        $moneyClass = new \Biz\Money\MoneyQuery;
+        $data = array();
+        $data['account_identity'] = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+        $data['game'] = isset($_POST['game']) ? $_POST['game'] : "";
+        $data['money_time'] = isset($_POST['money_time']) ? $_POST['money_time'] : "";
+        $data['time1'] = isset($_POST['time1']) ? $_POST['time1'] : "";
+        $data['time2'] = isset($_POST['time2']) ? $_POST['time2'] : "";
+        $data['no'] = isset($_POST['no']) ? $_POST['no'] : "";
+        $data['page'] = isset($_POST['page']) ? $_POST['page'] : "1";
+        $data['status'] = isset($_POST['status']) ? $_POST['status'] : "";
+        $data['id'] = isset($_POST['id']) ? $_POST['id'] : "";
+        $data['order_id'] = isset($_POST['order_id']) ? $_POST['order_id'] : "";
+        $res = $moneyClass->PcDiceBettingRecord($data);
+        //echo $res;
+        Render($res, '1', 'success');
+    }
+
+    /**
+     * PC投注记录和追号记录
+     * @return [type] [description]
+     */
+    public function PcBettingDetails() {
+        $moneyClass = new \Biz\Money\MoneyQuery;
+        $data = array();
+        $data['account_identity'] = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+        $data['game'] = isset($_POST['game']) ? $_POST['game'] : "";
+        $data['money_time'] = isset($_POST['money_time']) ? $_POST['money_time'] : "";
+        $data['time1'] = isset($_POST['time1']) ? $_POST['time1'] : "";
+        $data['time2'] = isset($_POST['time2']) ? $_POST['time2'] : "";
+        $data['no'] = isset($_POST['no']) ? $_POST['no'] : "";
+        $data['page'] = isset($_POST['page']) ? $_POST['page'] : "1";
+        $data['status'] = isset($_POST['status']) ? $_POST['status'] : "";
+        $data['id'] = isset($_POST['id']) ? $_POST['id'] : "";
+        $data['order_id'] = isset($_POST['order_id']) ? $_POST['order_id'] : "";
+        $res = $moneyClass->PcBettingDetails($data);
+        $dat = $moneyClass->dataChange($res);
+        //echo $res;
+        Render($dat, '1', 'success');
+    }
+
+    /**
+     * PC投注记录和追号记录
+     * @return [type] [description]
+     */
+    public function PcSixlotteryDetails() {
+        $moneyClass = new \Biz\Money\MoneyQuery;
+        $data = array();
+        $data['account_identity'] = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+        $data['game'] = isset($_POST['game']) ? $_POST['game'] : "";
+        $data['money_time'] = isset($_POST['money_time']) ? $_POST['money_time'] : "";
+        $data['time1'] = isset($_POST['time1']) ? $_POST['time1'] : "";
+        $data['time2'] = isset($_POST['time2']) ? $_POST['time2'] : "";
+        $data['no'] = isset($_POST['no']) ? $_POST['no'] : "";
+        $data['page'] = isset($_POST['page']) ? $_POST['page'] : "1";
+        $data['status'] = isset($_POST['status']) ? $_POST['status'] : "";
+        $data['id'] = isset($_POST['id']) ? $_POST['id'] : "";
+        $data['order_id'] = isset($_POST['order_id']) ? $_POST['order_id'] : "";
+        $res = $moneyClass->PcSixlotteryDetails($data);
+        $dat = $moneyClass->dataChange($res);
+        //echo $res;
+        Render($dat, '1', 'success');
+    }
+
+    /**
+     * PC塞子投注详情
+     * @return [type] [description]
+     */
+    public function PcDiceBettingDetails() {
+        $moneyClass = new \Biz\Money\MoneyQuery;
+        $data = array();
+        $data['account_identity'] = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+        $data['game'] = isset($_POST['game']) ? $_POST['game'] : "";
+        $data['game_name'] = isset($_POST['game_name']) ? $_POST['game_name'] : "";
+        $data['id'] = isset($_POST['id']) ? $_POST['id'] : "";
+        if ($data['game'] == 'dice') {
+            $res = $moneyClass->DiceSdataChange($data);
+        } else {
+            $res = $moneyClass->DicedataChange($data);
+        }
+
+
+        Render($res, '1', 'success');
+    }
+
+    /*交易类型对应键值*/
+    public function GetTradeType() {
+        $child = array(
+            '1' => '投注',
+            '2' => '追号',
+            '3' => '撤单',
+            '4' => '中奖',
+            '5' => '提现',
+            '6' => '在线充值',
+            '7' => '返水',
+            '8' => '回水',
+            '9' => '管理员扣款',
+            '10' => '佣金提成',
+            '11' => '后台充值',
+            '12' => '活动',
+            '13' => '充值赠送',
+            '14' => '汇款',
+            '15' => '提现冻结',
+            '16' => '红包打赏',
+            '19-1' => '额度转入',
+            '19-2' => '额度转出',
+        );
+        $arr = array(
+            '1' => array(
+                'name' => '全部',
+                'child' => $child,
+            ),
+            '2' => array(
+                'name' => '充值',
+                'child' => array(
+                    '11' => $child['11'],
+                    '6' => $child['6'],
+                    '14' => $child['14'],
+                ),
+            ),
+            '3' => array(
+                'name' => '投注',
+                'child' => array(
+                    '1' => $child['1'],
+                    '2' => $child['2'],
+                    '3' => $child['3'],
+                ),
+            ),
+            '4' => array(
+                'name' => '中奖',
+                'child' => array(
+                    '4' => $child['4'],
+                ),
+            ),
+            '5' => array(
+                'name' => '提现',
+                'child' => array(
+                    '5' => $child['5'],
+                    '9' => $child['9'],
+                ),
+            ),
+            '6' => array(
+                'name' => '额度转账',
+                'child' => array(
+                    '19-1' => $child['19-1'],
+                    '19-2' => $child['19-2'],
+                ),
+            ),
+            '7' => array(
+                'name' => '活动优惠',
+                'child' => array(
+                    '7' => $child['7'],
+                    '8' => $child['8'],
+                    '10' => $child['10'],
+                    '13' => $child['13'],
+                    '12' => $child['12'],
+                    '16' => $child['16'],
+                ),
+            ),
+        );
+        Render($arr, '1', lang()->get('success'));
+    }
+
+    /**
+     * 查询不同资金类型列表
+     */
+    public function Querry() {
+        $status = isset($_POST['status']) ? $_POST['status'] : '';
+        $trade_type = isset($_REQUEST['trade_type']) ? $_REQUEST['trade_type'] : '';
+        $account_identity = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+        $page = isset($_POST['page']) ? $_POST['page'] : '1';
+        $money_time = isset($_REQUEST['money_time']) ? $_REQUEST['money_time'] : '';
+        $field = isset($_POST['field']) ? $_POST['field'] : 'otime';
+        $orderby = isset($_REQUEST['orderby']) ? $_REQUEST['orderby'] : '2';
+
+        $moneyClass = new \Biz\Money\MoneyQuery;
+        if(empty($money_time)){//qtx 2018-12-25
+         	$prevmonth = date("Y-m-d", strtotime("-1 month"));
+        	$money_time = $prevmonth.'~'.date('Y-m-d');
+        }
+        $mtime = explode('~', $money_time);
+        $data = array(
+            'account_identity' => $account_identity,
+            'status' => $status,
+            'trade_type' => $trade_type,
+            'page' => $page,
+            'field' => ($field == 'otime') ? 'money_time' : 'money',
+            'orderby' => ($orderby == 1) ? 'asc' : 'desc',
+            'money_time' => substr($money_time, '0', '19'),
+        );
+        if (count($mtime > 1)) {
+            $data['money_time'] = $mtime;
+        }
+        $res = $moneyClass->Winning($data);
+        //var_dump( $res);
+        if (is_array($res)) {
+            Render($res, '1', lang()->get('success'));
+        } else {
+            Render('', '-400', lang()->get('fail'));
+        }
+    }
+
+    /*统计账户明细汇总*/
+    public function AccountSum() {
+        $trade_type = isset($_REQUEST['trade_type']) ? $_REQUEST['trade_type'] : '';
+        $account_identity = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+        $page = isset($_POST['page']) ? $_POST['page'] : '1';
+        $field = isset($_POST['field']) ? $_POST['field'] : 'otime';
+        $orderby = isset($_POST['orderby']) ? $_POST['orderby'] : '2';
+        $money_time = isset($_REQUEST['money_time']) ? $_REQUEST['money_time'] : '';
+
+        $moneyClass = new \Biz\Money\MoneyQuery;
+        $mtime = explode('~', $money_time);
+        $data = array(
+            'account_identity' => $account_identity,
+            'trade_type' => $trade_type,
+            'page' => $page,
+            'money_time' => substr($money_time, '0', '19'),
+        );
+        if (count($mtime > 1)) {
+            $data['money_time'] = $mtime;
+        }
+        $res = $moneyClass->AccountSum($data);
+        //var_dump( $res);
+        if (is_array($res)) {
+            Render($res, '1', lang()->get('success'));
+        } else {
+            Render('', '-400', lang()->get('fail'));
+        }
+    }
+
+    /**
+     * 资金详情
+     * @return [type] [description]
+     */
+    public function details() {
+        $data['identity'] = isset($_GET['identity']) ? $_GET['identity'] : '';
+        $moneyClass = new \Biz\Money\MoneyQuery;
+        $res = $moneyClass->Lists($data);
+        Render($res, '1', lang()->get('success'));
+    }
+
+    /**
+     * 走势图
+     * @return [type] [description]
+     */
+    public function TrendChart() {
+        $nums = new \Biz\Game\GameQuery();
+        $name = isset($_GET['name']) ? $_GET['name'] : '';
+        $num1 = isset($_POST['num1']) ? $_POST['num1'] : '';
+        $num2 = isset($_POST['num2']) ? $_POST['num2'] : '';
+        $time = isset($_POST['time']) ? $_POST['time'] : '';
+        $page = isset($_POST['page']) ? $_POST['page'] : '1'; //资金类型
+        $limit = isset($_POST['limit']) ? $_POST['limit'] : '20';
+        $datat = [
+            'name' => $name,
+            'num1' => $num1,
+            'num2' => $num2,
+            'time' => $time,
+            'page' => $page,
+            'limit' => $limit,
+
+        ];
+        $data = $nums->TrendChart($datat);
+        $data['page']=$page;
+        //dump(21);
+        Render($data, '1', lang()->get('success'));
+    }
+
+    /**
+     * 投注状态查询
+     * @return [type] [description]
+     */
+    public function BetChart() {
+        $nums = new \Biz\Money\MoneyQuery;
+        $account_identity = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+        $game_name = isset($_GET['game_name']) ? $_GET['game_name'] : '';
+        $no = isset($_POST['no']) ? $_POST['no'] : '';
+        $status = isset($_POST['status']) ? $_POST['status'] : '0';
+        $datat = [
+            'account_identity' => $account_identity,
+            'game_name' => $game_name,
+            'no' => $no,
+            'status' => $status,
+
+        ];
+        if (in_array($game_name, $this->curPrizeGame())) {
+            $data = $nums->CurBetRecord($datat);
+        } else {
+            $data = $nums->NotBetRecord($datat);
+        }
+
+        //dump($data);
+        Render($data, '1', lang()->get('success'));
+    }
+
+    //即时开奖游戏
+    private function curPrizeGame() {
+        return array(
+            'diceone',
+        );
+    }
+
+    /**
+     * 个人盈亏
+     * @return [type] [description]
+     */
+    public function Personal() {
+
+        $now_times = isset($_POST['now_time']) ? $_POST['now_time'] : '';
+        //var_dump($now_times);
+        $account_identity = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+        $data = array(
+            'account_identity' => $account_identity,
+            'now_times' => $now_times,
+        );
+        $moneyClass = new \Biz\Money\MoneyQuery;
+        $res = $moneyClass->Personal($data);
+        Render($res, '1', lang()->get('success'));
+    }
+
+    public function test() {
+        $money_type = isset($_POST['money_type']) ? $_POST['money_type'] : '';
+        $status = isset($_POST['status']) ? $_POST['status'] : '1';
+        $moneyClass = new \Biz\Money\MoneyQuery;
+        $data = [
+            'account_identity' => 'ec4ad43d-6105-e90c-5f3e-38141676c3b6',
+            //'money_type'=>$money_type,
+            //'status'=>$status
+        ];
+        $res = $moneyClass->Winning($data);
+        // dump($res);
+        if (is_array($res)) {
+            Render($res, '1', lang()->get('success'));
+        } else {
+            Render('', '-400', lang()->get('fail'));
+        }
+    }
+
+    //快乐赛宝
+    public function DiceDetails() {
+        $moneyClass = new \Biz\Money\MoneyQuery;
+        $moneyd = new \App\Api\Controller\Specgame;
+        $data = array();
+        $ta = $moneyd->GetOtherUser();
+        $data['account_identity'] = isset($ta['other_user']['account_identity']) ? $ta['other_user']['account_identity'] : $_SESSION['uinfo']['account_identity'];
+        $dat = $moneyClass->DiceBettingDetails($data);
+        Render($dat, '1', 'success');
+
+    }
+
+    public function DiceOneDetails() {
+        $moneyClass = new \Biz\Money\MoneyQuery;
+        $data = array();
+        $data['account_identity'] = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : $_SESSION['uinfo']['account_identity'];
+        $dat = $moneyClass->DiceBettingDetails($data);
+        Render($dat, '1', 'success');
+
+    }
+
+    //PC用户有效投注统计
+    public function BettingRecord() {
+        $moneyClass = new \Biz\Money\MoneyQuery;
+        $data['account_identity'] = isset($_SESSION['uinfo']['account_identity']) ? $_SESSION['uinfo']['account_identity'] : '';
+        $data['start'] = isset($_POST['start']) ? $_POST['start'] : "";
+        $data['end'] = isset($_POST['end']) ? $_POST['end'] : "";
+        $data['page'] = isset($_POST['page']) ? $_POST['page'] : "1";
+        $res = $moneyClass->EffectiveBetting($data);
+        //echo $res;
+        Render($res, '1', 'success');
+    }
+
+    public function getFav() {
+        $uuid = $_SESSION['uinfo']['identity'];
+        $obj = lm('UserSetting', 'api')->where('account_identity', $uuid)->first(['fav_info']);
+        $in = $obj ? json_decode($obj->fav_info) : [];
+        $favs = lm('Game_type', 'commons')->whereIn('table_name', $in)->get(['name', 'table_name', 'icon']);
+        Render($favs, 1);
+    }
+
+    public function setFav() {
+        $uuid = $_SESSION['uinfo']['identity'];
+        $type = intval($_POST['type'] ?? 1);
+        $game_name = trim($_POST['game_name']);
+        $obj = lm('UserSetting', 'api')->where('account_identity', $uuid)->first(['fav_info']);
+        $data = $obj && $obj->fav_info != 'null' ? json_decode($obj->fav_info, 1) : [];
+        if (intval($type) === 0) {
+            if ($key = array_search($game_name, $data)) {
+                array_splice($data, $key, 1);
+            }
+        } elseif ($type === 1) {
+            if (!array_search($game_name, $data)) {
+                array_push($data, $game_name);
+            }
+        }
+        $ret = lm('UserSetting', 'api')->where('account_identity', $uuid)->update(['fav_info' => json_encode($data)]);
+        if ($ret === 1) {
+            $this->getFav();
+        }
+        Render('', -888, '操作失败');
+
+    }
+}

+ 307 - 0
Application/Api/Controller/UserGrade.php

@@ -0,0 +1,307 @@
+<?php
+/*
+ * 用户等级接口
+ * 时间2018-09-07
+ * */
+namespace App\Api\Controller;
+
+use Biz\Account\AccountManager;
+
+//ini_set('display_errors', 1);
+//error_reporting(E_ALL);
+class UserGrade extends BaseController {
+
+    //获取用户下一级流水以及
+    public function nextVip(){
+
+
+        $account = new AccountManager();
+        $userinfo = $account->getCurrentUser ();
+        $userinfo = $userinfo ? $userinfo->toarray () : [];
+        if(empty($userinfo))Render("",-5007);
+        $userid =   $userinfo["account_identity"];
+        if($userinfo["grade"] ==0 || $userinfo["grade"] ==-1){
+            $nextgarade = -2;
+        }else{
+            $nextgarade =   $userinfo["grade"]+1;
+        }
+
+
+        if($nextgarade==-1)$nextgarade=1;
+        $gradeinfo = lm ('UserGrade', 'Api')->orderby("grade","asc")->get(["grade","name","rule_details"]);
+        $gradeinfo  =   $gradeinfo?$gradeinfo->toarray():[];
+        $_flow_next =   0;
+        $_recharge_next =   0;
+        $newuserinfo["grade_name_next"]    =   "";
+        if(count($gradeinfo)<1)Render("",-5007);
+
+        $newuserinfo["name"]    =  $userinfo["account"];
+        $newuserinfo["cash"]    =  $userinfo["cash"];
+        $newuserinfo["open_invitation"]    =  $userinfo["open_invitation"];
+        $newuserinfo["grade"]    =  $userinfo["grade"];
+
+        foreach ($gradeinfo as $v) {
+            if ($v["grade"] == $userinfo["grade"])
+                $newuserinfo["grade_name"] = $v["name"];
+            if ($v["grade"] == $nextgarade) {
+                $newuserinfo["grade_name_next"] = $v["name"];
+                $_recharge_next = isset($v["rule_details"]) ? explode(",", $v["rule_details"])[1] : 0;
+                $_flow_next = isset($v["rule_details"]) ? explode(",", $v["rule_details"])[2] : 0;
+            }
+        }
+        //查询等级规则
+        $nextgradeinfo = lm('UserGrade', 'Api')->select('name', 'rule', 'rule_details')->where('grade', '=', 0)->first();
+
+        if (empty($nextgradeinfo)) {
+            //Render($nextgradeinfo, "-5002", '条件不满足');
+            return '-5002';
+        }
+
+        //升级时间
+        $update_grade_date  =   self::getUserGradeUpdate($userinfo["account_identity"]);
+        //申请通过时间
+        $viptime    =   self::getUserComeVipTime($userinfo["account_identity"])['audittime'];
+
+
+        $save  =   lm("MoneyRecharge","Api")->getPromotionAmount(["account_identity"=>$userid]);
+        //查询统计数据 进行数据累加计算
+        $flow = lm('MoneyFlowCount', 'Api')->where("account_identity", $userid)->orderBy('id', 'desc')->first();
+        $flow = $flow ? $flow->toarray() : [];
+        $last_time = $flow ? $flow['updated_at'] : '';
+        $endtime    =  date('Y-m-d H:i:s', time()-3*24*3600);
+        $startime   =   $last_time? date('Y-m-d H:i:s',strtotime($last_time)-3*24*3600):'2018-01-01 00:00:00';
+
+        //每3天更新一次数据
+        if(time()-strtotime($last_time)>=3*24*3600){
+
+            $zheren =   (new Nologin())->totalUserStatistics($userid,$startime,$endtime);
+            $zheren_update =   $zheren>0?$this->updateMoneyFlowCount($userid,2,$zheren):0;
+
+            $bet = lm("MoneyBuy","Api")->getstreamAmount(["account_identity"=>$userid],$startime,$endtime);
+            $sixbet = lm("SixmoneyBuy","Api")->getsixstreamAmount(["account_identity"=>$userid],$startime,$endtime);
+            $total_pc = $bet + $sixbet;
+            $total_pc_update =   $total_pc>0?$this->updateMoneyFlowCount($userid,1,$total_pc):0;
+        }
+
+        $zheren =   (new Nologin())->totalUserStatistics($userid,$endtime);
+
+        $bet = lm("MoneyBuy","Api")->getstreamAmount(["account_identity"=>$userid],$endtime);
+        $sixbet = lm("SixmoneyBuy","Api")->getsixstreamAmount(["account_identity"=>$userid],$endtime);
+        $total_pc = $bet + $sixbet +$zheren;
+
+
+         $total= lm('MoneyFlowCount','Api')->where(['account_identity'=>$userid,'cycle'=>'alldays'])->sum('total')+$total_pc;
+
+        $newuserinfo["flow"]   =  $total;
+        $newuserinfo["charge"]   =   $save;
+
+        //距下次升级 还需流水
+        $flow_dif    =   $_flow_next-$total;
+        $newuserinfo["flow_dif_next"]  =   $total >= $_flow_next&&$_flow_next>0?0:($flow_dif>0?$flow_dif:0);//小于0则等级达到最大值
+
+        //距下一级充值 还需要 充值
+        $recharge_dif   =   $_recharge_next-$save;
+        $newuserinfo["recharge_dif_next"]   =  $save >= $_recharge_next&&$_recharge_next>0?0:($recharge_dif>0?$recharge_dif:0);//小于0则等级达到最大值
+
+
+        //最高可得彩金
+        $lotter  =   lm ('lottery_money', 'Api')->where ('type', "upgrade")->first ();
+        $lotter  =   $lotter?$lotter->toarray():[];
+        $lotter_money   =   $lotter?json_decode($lotter["conent"],1):[];
+        $max_lotter_money   =   isset($lotter_money["grade"][$nextgarade])?$lotter_money["grade"][$nextgarade]:0;
+        $newuserinfo["lotter_money_next"]   =   $max_lotter_money;
+        $newuserinfo["lotter_money_id"]   =   isset($lotter["id"])?$lotter["id"]:0;
+
+        //条件
+        $date   =   ["all"=>"","year"=>"年","mouth"=>"月","week"=>"周",];
+        foreach ($gradeinfo as $v){
+            if($v["grade"]<1) continue;
+            $row["grade"]    =  $v["name"];
+            $row["lotter_money"]    =  isset($lotter_money["grade"][$v["grade"]])?$lotter_money["grade"][$v["grade"]]:0;
+            $rule   =   explode(",",$v["rule_details"]);
+            $rule[0]    =   isset($date[$rule[0]])?$date[$rule[0]]:"";
+            $row["condition"]   =   $rule;
+
+            $newuserinfo["show_list"][]=$row;
+        }
+
+
+
+        //彩金id
+        $newuserinfo["grade_time"]   =   isset($update_grade_date["create_time"])?$update_grade_date["create_time"]:($viptime?$viptime:$userinfo['register_time']);
+        $_data  =   ['account_identity'=>$userinfo["account_identity"],'grade'=>$userinfo["grade"],'lottery_money_type'=>'upgrade'];
+        $status =  lm("Lottery_money_log","Api")->where($_data)->first();
+        $status =   $status?$status->toarray():[];
+        $newuserinfo["status"]     = isset($status['status'])?$status['status']:-1;
+
+
+        //自动升级
+        lm ('UserGrade', 'Api')->upgrade ($userinfo,$total);
+
+        return $newuserinfo;
+    }
+
+    /**
+     * 更新流水统计记录
+     * @param $uuid
+     * @param $lasttime
+     * @param $type
+     * @param $flow
+     */
+    private function updateMoneyFlowCount($uuid,$type,$flow){
+        $update_flow    =   lm('MoneyFlowCount','Api');
+        $info=   $update_flow->where(["account_identity"=>$uuid,'money_type'=>$type])->first();
+        $info =   $info?$info->toarray():[];
+
+        $update_data =   [
+                "account_identity"=>$uuid,
+                'updated_at'=>date('Y-m-d H:i:s'),
+                'created_at'=>isset($info['created_at'])?$info['created_at']:date('Y-m-d H:i:s'),
+                'total'=>isset($info['total'])?$flow+$info['total']:$flow,
+                'cycle'=>'alldays',
+                'money_type'=>$type
+
+            ];
+
+            $ret = $info?$update_flow->where(["account_identity"=>$uuid,'money_type'=>$type,'cycle'=>'alldays'])->update($update_data):$update_flow->insert($update_data);
+
+            return $ret;
+    }
+
+    private function getLotteryInfo($typeOrid){
+        $info   =   lm("LotterMoney","Api")->where('type',$typeOrid)->whereOr('id',$typeOrid)->first();
+        return $info?$info->toarray():[];
+    }
+
+    public function upGradeStatus(array $data){
+        $actvie =   new Active();
+        return $actvie->getStatus($data);
+    }
+
+    /**
+     * 获取vip申请通过时间
+     */
+    private function getUserComeVipTime($userid){
+        $res    =   lm("user_vip","Api")
+            ->where(["account_identity"=>$userid,"status"=>2])
+            ->get(['audittime'])
+            ->first();
+        return $res?$res->toarray():['audittime'=>''];
+    }
+
+    /**
+     * 获取用户最新晋级信息
+     * @param $userid 用户唯一id
+     */
+     private function getUserGradeUpdate($userid){
+        $res    =   lm("user_log_record","Api")
+                    ->where(["account_identity"=>$userid,"type"=>"promotion"])
+                    ->orderby("id","desc")
+                    ->first();
+        return $res?$res->toarray():[];
+     }
+    /**
+     * 等级升级申请
+     * @return [type] [description]
+     */
+    public function UserUpgrade(){
+         $uinfo = $_SESSION['uinfo'];
+        if (empty($uinfo)) {
+            //Render(null, '-5009','条件不满足');
+            Render("", "-5009", '');
+        }
+
+        //查询等级规则
+        $gradelist = lm ('UserGrade', 'Api')->select ('name', 'rule', 'rule_details')->where ('grade','>',0)->get();
+        $nextgradeinfo = lm ('UserGrade', 'Api')->select ('name', 'rule', 'rule_details')->where ('grade','=',0)->first ();
+        if (empty($nextgradeinfo)) {
+            //Render($nextgradeinfo, "-5002", '条件不满足');
+            Render("", "-5002", '');
+        }
+        if (empty($gradelist)) {
+            //Render($nextgradeinfo, "-5002", '条件不满足');
+            Render("", "-5002", '');
+        }
+        $gradelist = $gradelist ->toArray ();
+        $nextgradeinfo = $nextgradeinfo->toArray ();
+
+        $nextgradeinfo['rule_details'] = explode (',', $nextgradeinfo['rule_details']);
+        //查询统计数据
+        $save = lm ('MoneyRecharge', 'Api')->where('account_identity', $uinfo['account_identity'])->where('status',1)->where('recharge_type','汇款')->where('recharge_type','后台充值')->where('recharge_type','在线充值');
+        $bet = lm ('MoneyBuy', 'Api')->where('account_identity', $uinfo['account_identity'])->where('status','<', 4);
+        $sixbet = lm ('SixmoneyBuy', 'Api')->where ('account_identity', $uinfo['account_identity'])->where('status','<', 4);
+
+        //时间类型条件判断
+        if ($nextgradeinfo['rule_details'][0] == 'year') {
+            $startime = date ('Y-01-01', time ()) . ' 00:00:00';
+            $endtime = date ('Y-12-31', time ()) . ' 23:59:59';
+            $save = $save->where ('complete_time', '>=', $startime)->where ('complete_time', '<=', $endtime);
+            $bet = $bet->where ('money_time', '>=', $startime)->where ('money_time', '<=', $endtime);
+            $sixbet = $sixbet->where ('money_time', '>=', $startime)->where ('money_time', '<=', $endtime);
+        } elseif ($nextgradeinfo['rule_details'][0] == 'month') {
+            $startime = date ('Y-m-01', strtotime (date ('Y', time ()) . '-' . (date ('m', time ()) - 1) . '-01')) . ' 00:00:00';
+            $endtime = date ('Y-m-d', strtotime ("$startime +1 month -1 day")) . ' 23:59:59';
+            $save = $save->where ('complete_time', '>=', $startime)->where ('complete_time', '<=', $endtime);
+            $bet = $bet->where ('money_time', '>=', $startime)->where ('money_time', '<=', $endtime);
+            $sixbet = $sixbet->where ('money_time', '>=', $startime)->where ('money_time', '<=', $endtime);
+        } elseif ($nextgradeinfo['rule_details'][0] == 'week') {
+            $now_day = date ('w', time ()) - 1;
+            $sunday_str = time () - $now_day * 60 * 60 * 24;
+            $sunday = date ('Y-m-d 00:00:00', $sunday_str);
+            $strday_str = time () + (6 - $now_day) * 60 * 60 * 24;
+            $strday = date ('Y-m-d 23:59:59', $strday_str);
+            $save = $save->where ('complete_time', '>=', $sunday)->where ('complete_time', '<=', $strday);
+            $bet = $bet->where ('money_time', '>=', $sunday)->where ('money_time', '<=', $strday);
+            $sixbet = $sixbet->where ('money_time', '>=', $sunday)->where ('money_time', '<=', $strday);
+        } elseif ($nextgradeinfo['rule_details'][0] == 'day') {
+            $firstday = date ('Y-m-d 00:00:00', strtotime ("-" . $nextgradeinfo['rule_details'][3] . " day"));
+            $save = $save->where ('complete_time', '>=', $firstday)->where ('complete_time', '<=', date ('Y-m-d 23:59:59', strtotime ('-1 day')));
+            $bet = $bet->where ('money_time', '>=', $firstday)->where ('money_time', '<=', date ('Y-m-d 23:59:59', strtotime ('-1 day')));
+            $sixbet = $sixbet->where ('money_time', '>=', $firstday)->where ('money_time', '<=', date ('Y-m-d 23:59:59', strtotime ('-1 day')));
+        }elseif($nextgradeinfo['rule_details'][0] == 'ymd'){
+            $firstday = $nextgradeinfo['rule_details'][3].' 00:00:00';
+            $save = $save->where ('complete_time', '>=', $firstday);
+            $bet = $bet->where ('money_time', '>=', $firstday);
+            $sixbet = $sixbet->where ('money_time', '>=', $firstday);
+        }
+
+        $save = $save->sum ('money');
+        $bet = $bet->sum ('money');
+        $sixbet = $sixbet->sum ('money');
+        $total = $bet+$sixbet;
+        $newgrade = 0;
+        foreach($gradelist as $key =>$value){
+            $rule_details = explode(',',$value['rule_details']);
+            if($save >= $rule_details[1] && $total >= $rule_details[2]){
+                $newgrade = $key;
+            }
+        }
+
+        if ($newgrade > 0 && $newgrade > $uinfo['grade']) {
+            $res = lm ('AccountDetail', 'Api')->where ('account_identity', $uinfo['account_identity'])->update (['grade' => $newgrade]);
+            if ($res) {
+                $remark['original_grade'] = $uinfo['grade'];
+                $remark['present_grade'] = $newgrade;
+                $remark['type'] = $nextgradeinfo['rule_details'][0];
+                $remark['save'] = $save;
+                $remark['bet'] = $bet + $sixbet;
+                $data['account_identity'] = $uinfo['account_identity'];
+                $data['remark'] = json_encode ($remark);
+                $data['account_name'] = $uinfo['account'];
+                $data['type'] = 'promotion';
+                $data['create_time'] = date ('Y-m-d H:i:s');
+                lm ('User_log_record', 'Api')->insert ($data);
+                Render($res, "1", '');
+            } else {
+
+                Render($res, "-5007", '');
+            }
+        } else {
+            Render("", "-5003", '');
+        }
+
+    }
+
+
+
+}

+ 27 - 0
Application/Api/Controller/Uuid.php

@@ -0,0 +1,27 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: blade
+ * Date: 2018/6/11
+ * Time: 10:50
+ */
+namespace App\Api\Controller;
+
+ini_set('display_errors', 1);
+
+error_reporting(E_ALL);
+use \BaseController\Controller;
+Class Uuid extends Controller {
+
+    function index(){
+        $table=isset($_GET['table'])?$_GET['table']:'';
+        $field=isset($_GET['field'])?$_GET['field']:'';
+//        $data=S('DB')->select('SELECT * FROM '.$table.' WHERE len('.$field.') > 64');
+        $res=S('DB')->select("UPDATE ".$table." SET '.$field.' = '".UUID()."' WHERE \"length\"(".$field.") < 64 ");
+        if(!$res){
+            return Render('',3001);
+        }
+        return Render('',1);
+
+    }
+}

+ 27 - 0
Application/Api/Lang/AndroidConf.php

@@ -0,0 +1,27 @@
+<?php
+return [
+    '\api\gameCenter\index' => array(
+        "status" => [
+            '-4001' => '-40011',
+            '-4002' => '-40021',
+        ],
+    ),
+    '\payment-PayInterface\Radzhif' => [],
+    'payment/PayInterface/Radzhif' => [],
+    'Api/UserDetails/TakeMoneyRecord' => [
+        'toArr' => 1
+    ],
+    'Api/GameCenter/Lotterytwo' => [
+        'arrFields' => ['tolist']
+    ],
+    'Api/Account/getUserSetting' => [
+    ],
+    'Api/Settings/Query' => [
+        'conv' => [[
+            'destField' => 'multiple',
+            'key' => 'total',
+        ]]
+    ],
+    'Api/Long/GetGameList'=>[
+    ],
+];

+ 5 - 0
Application/Api/Lang/Api-notice.php

@@ -0,0 +1,5 @@
+<?php
+
+return array(
+	'api-notice' => '没有数据',
+);

+ 24 - 0
Application/Api/Lang/Common.php

@@ -0,0 +1,24 @@
+<?php
+return array(
+    'error' => '未知错误',
+	'cash fail' => '提现失败',
+    'Picture files are not supported' => "只支持上传‘jpg’,‘png’,‘gif’ 的格式",
+    'Picture too large' => "只支持上传小于100 KB 的图片",
+    'Upload failure' => "上传失败",
+	'no withdraw data' => '没有提现数据',
+	'notice no identity' => '通知内容没有传入ID',
+	'Content fail data' => '没有获取内容',
+	'type fail get' => '数据类型缺失',
+	'user does not exist' => '用户不存在',
+	'user does login' => '用户未登录',
+    'welcome' => '欢迎',
+    'cash withdrawal less than 100' => '提现金额少于100',
+    'insufficient amount of account' => '账户金额不足',
+    'payment password error' => '支付密码错误',
+    'the bank card is not bound' => '该银行卡未绑定',
+    'you have submitted your application for withdrawal' => '您已提交提现申请,不可频繁提交,请稍候再试',
+    'the application failed' => '申请失败,请重试',
+    'application has been submitted and customer service is under review' => '已提交申请,客服正在审核中',
+    'please enter the modification' => '请输入修改内容',
+);
+?>

+ 474 - 0
Application/Api/Lang/Errors.php

@@ -0,0 +1,474 @@
+<?php
+
+return array(
+    'error-0' => '错误',
+    'error-1' => '成功',
+    'error1' => '成功',
+    'error2' => '追号成功',
+    'api-notice' => '没有数据',
+    'error-4001' => '用户未登录',
+    'error-4101' => '不能使用guset的特殊账号注册',
+    'error-4002' => '用户登录,密码错误',
+    'error-4003' => '登录错误',
+    'error-4004' => '用户已存在',
+    'error-40040' => '用户已存在',
+    'error-4005' => '注册失败',
+    'error-4006' => '两次密码不一致',
+    'error-4007' => '用户账户状态异常',
+    'error-4008' => '登录过期',
+    'error-4009' => '修改密码,原密码错误',
+    'error-4010' => '缺少用户唯一ID',
+    'error-4011' => '用户错误(修改支付密码时,token为空或已过期)',
+    'error-4012' => '未设置支付密码,请先设置支付密码',
+    'error-4013' => '支付密码错误',
+    'error-4014' => '代理用户已存在',
+    'error-4015' => '申请代理用户出错',
+    'error-4016' => '用户注册关联邀请人出错',
+    'error-4017' => '代理用户不存在',
+    'error-4018' => '代理用户登录出错',
+    'error-4019' => '代理用户登录过期',
+    'error-4020' => '获取用户信息失败,请刷新重试',
+    'error-4021' => '代理用户登录密码错误',
+    'error-4022' => '试玩账号有误',
+    'error-4045' => '参数缺失',
+    'error-4025' => '该IP已注册过试玩用户',
+    'error-4026' => '试玩用户不参与活动',
+    'error-4023' => '密码不能为空',
+    'error-4022' => '用户名不能为空',
+    'error-4024' => '银行卡不能为空',
+    'error-4027' => '请输入修改内容',
+    'error-4046' => '未提交订单号',
+    'error-4047' => '获取订单详情失败',
+    'error-40251' => '没有开户行地址',
+    'error-40252' => '缺少开户人信息',
+    'error-40253' => '请填写开户行信息',
+    'error-40254' => '数据处理异常',
+    'error-40255' => '数据异常',
+    'error-40256' => '数据不能全为空',
+    'error-21270' => '特码包3至少选择3个号码',
+    'error-4254' => '投注金额不能低于10元',
+    'error-42540' => '特码包3至少选择3个号码',
+    'error-4101' => '级差代理ID有误',
+    'error-4102' => '级差代理提佣金额有误',
+    'error-4201' => '未获取直属代理信息',
+    'error-4202' => '未获取代理信息',
+    'error-4203' => '未获取代理信息',
+    'error-4204' => '当前余额不足',
+    'error-4205' => '未获取代理信息',
+    'error-4206' => '添加代理提佣信息失败',
+    'error-4207' => '更新代理提佣金额失败',
+    'error-4208' => '暂无代充记录',
+    'error-4209' => '用户不存在',
+    'error-4210' => '插入代充记录失败',
+    'error-4211' => '插入充值记录失败',
+    'error-4212' => '插入充值详情记录失败',
+    'error-4213' => '插入资金详情信息失败',
+    'error-4214' => '更新用户余额失败',
+    'error-4215' => '更新代理用户余额失败',
+    'error-4216' => '资金密码错误',
+    'error-4217' => '您已被列入代理黑名单,不能提佣,详情请咨询客服',
+    'error-4218' => '更新代理用户余额失败',
+    'error-4219' => '代理资金详情添加失败',
+    'error-4220' => '未设置分享链接',
+    'error-4221' => '暂无可结算游戏流水',
+    'error-4222' => '未设置相应佣金比例',
+    'error-4223' => '会员不存在',
+    'error-4224' => '未设置代理等级',
+    'error-4225' => '暂无下级会员',
+    'error-70000' => '今日开奖',
+    'error-4300' =>'手机号码为空',
+    'error-4301' =>'手机号码已存在',
+
+    'error-2001' => '用户未登录',
+    'error-2002' => '开户银行所在地缺失',
+    'error-2003' => '开户银行名称缺失',
+    'error-2004' => '银行卡号缺失',
+    'error-2005' => '银行用户名缺失',
+    'error-2006' => '支付密码缺失',
+    'error-2007' => '两次支付密码输入不一致',
+    'error-2008' => '用户还未设置交易密码,请先设置',
+    'error-2010' => '试玩账号不能绑定银行卡',
+    'error-2033' => '已绑定过银行卡,不需要重复绑定',
+    'error-2009' => '绑定银行卡失败',
+    'error-2013' => '设置交易密码失败',
+    'error-2014' => '提现申请失败',
+    'error-2016' => '失败',
+    'error-2017' => '你已经设置过交易密码',
+    'error-2020' => '支付密码错误',
+    'error-2021' => '账户金额异常',
+    'error-2022' => '账户金额不足',
+    'error-2100' => '充值失败',
+    'error-2101' => '未提交充值信息',
+    'error-2101' => '充值跑马灯获取失败',
+    'error-2102' => '未提交充值金额',
+    'error-2103' => '未提交充值通道ID',
+    'error-2104' => '用户名不合法!',
+    'error-2105' => '没有对应转账卡信息,不能提交!',
+    'error-2111' => '未获取到支付接口信息',
+    'error-2112' => '提现金额少于100',
+    'error-2114' => '该银行卡未绑定',
+    'error-2115' => '获取金额失败',
+    'error-2116' => '投注id缺失',
+    'error-2117' => '投注类型缺失',
+    'error-2118' => '投注游戏名缺失',
+    'error-2119' => '投注游戏期号名缺失',
+    'error-2120' => '投注信息加入失败',
+    'error-2121' => '投注金额获取失败',
+    'error-2122' => '投注号码缺失',
+    'error-2123' => '投注金额获取失败',
+    'error-2124' => '中奖号码缺失',
+    'error-2125' => '缺失订单号',
+    'error-2127' => '投注返水有误',
+    'error-2046' => '未绑定银行卡或未设置资金密码',
+    'error-2047' => '该订单已支付或已过期',
+    'error-2048' => '支付失败',
+    'error-2050' => '您已提交充值申请,不可重复提交',
+    'error-2051' => '您已提交提现申请,不可频繁提交,请稍候再试',
+    'error-2136' => ' 该银行卡已经被绑定过',
+    'error-2137' => ' 您好,单笔存款不能超过100万,请分多笔存入',
+    'error-2138' => '订单有误',
+
+    'error-3200' => '试玩账号不能追号',
+    'error-3201' => '游戏不存在',
+    'error-3202' => '游戏期号不存在',
+    'error-3203	' => '游戏ID未提交',
+    'error-3204	' => '用户ID未提交',
+    'error-3205	' => '投注失败',
+    'error-3206' => '开奖-游戏期号为空',
+    'error-3207' => '开奖-游戏名为空',
+    'error-3208	' => '开奖-游戏期号不存在,或者当前游戏不可开奖或已开过奖,游戏状态不是待开奖',
+    'error-3209	' => '开奖-开奖号码为空',
+    'error-3210	' => '开奖-更新游戏中奖号码出错',
+    'error-3211	' => '开奖-指定编号的游戏或状态不存在可用投注信息',
+    'error-3212	' => '开奖-撤单的游戏名不能为空',
+    'error-3213	' => '开奖-撤单ID不能为空',
+    // 'error-3214' => '开奖-撤单记录不存在',
+    'error-3214' => '已撤单,请勿重复操作!',
+    'error-3215' => '开奖-//更新撤单状态失败',
+    'error-3216' => '查询游戏设置,游戏名不能为空',
+    'error-3217' => '游戏投注信息为空',
+    'error-3218' => '游戏投注信息格式不正确',
+    'error-3219' => '游戏投注-游戏名不能为空',
+    'error-3220' => '当前期游戏数据不存在',
+    'error-3221' => '当前期游戏不存在',
+    'error-3222' => '当前期游戏期数不存在',
+    'error-3223' => '游戏提交投注项名称不符合规定',
+    'error-3224' => '当前游戏单号不存在',
+    'error-3225	' => '当前游戏的游戏设置不存在',
+    'error-3226	' => '试用帐户不能超过2000元',
+    'error-3227	' => '赔率设置-游戏名不能为空',
+    'error-3228' => '游戏已关闭',
+    'error-3229' => '游戏已停盘',
+    'error-3230' => '游戏号码格式有误,开奖失败',
+    'error-3231' => '投注号码有误',
+    'error-3232' => '未提交开奖号码',
+    'error-3233' => '开奖号码有误',
+    'error-3234' => '开奖有误',
+    'error-3235' => '游戏信息不能为空',
+    'error-3236' => '房间名不能为空',
+    'error-3237' => '房间底注不能为空',
+    'error-3238' => '用户未登录',
+    'error-3239' => '创建房间失败',
+    'error-3240' => '暂无房间记录',
+    'error-3241' => '未提交房间信息',
+    'error-3242' => '房间信息不存在',
+    'error-3243' => '房间已满',
+    'error-3244' => '房间暂无庄家',
+    'error-3245' => '该房间需密码访问',
+    'error-3246' => '密码错误',
+    'error-3247' => '进入房间失败',
+    'error-3248' => '房间信息有误',
+    'error-3249' => '未提交用户信息',
+    'error-3250' => '房间记录不存在',
+    'error-3251' => '离开房间失败',
+    'error-3252' => '房间不存在',
+    'error-3253' => '离开房间失败',
+    'error-3254' => '离开房间失败',
+    'error-3255' => '您已进入其他房间,请先退出',
+    'error-3256' => '下注金额不能低于房间底注',
+    'error-3257' => '创建房间数量已达上限',
+    'error-3258' => '您已离开该房间',
+    'error-3259' => '庄家已离开该房间',
+    'error-3260' => '暂无相关房间,可自己创建房间',
+    'error-3261' => '已投注,请等待对方玩家投注',
+    'error-3262' => '玩家不足,不能进行游戏',
+    'error-3263' => '正码过关至少投注两个号码',
+    'error-3264' => '冷热分析-游戏名不能为空',
+    'error-3265' => '冷热分析-游戏期号不能为空',
+    'error-3266' => '冷热分析-无当前游戏开奖数据',
+    'error-3300' => '无游戏存在',
+    'error-3301' => '无数据',
+    'error-3303' => '无该游戏',
+    'error-3304' => '游戏已封盘',
+    'error-3305' => '缺少游戏期数或期数有误',
+    'error-3306' => '缺少追号期数',
+    'error-3310' => '缺少可用期数',
+    'error-3311' => '非法攻击',
+    'error-3312' => '注单添加错误,每次只能选择一中投注方式',
+    'error-3233' => '错误倍率',
+    'error-3234' => '游戏开奖信息不全',
+    'error-3235' => '暂无对应游戏信息',
+    'error-3236' => '游戏还未开盘',
+    'error-3301' => '暂无记录',
+
+    'error-3401' => '投注金额超过投注限额',
+    'error-3402' => '添加投注号码信息失败',
+    'error-3403' => '更新投注号码信息失败',
+    'error-3404' => '添加投注玩法信息失败',
+    'error-3405' => '更新投注玩法信息失败',
+    'error-3406' => '投注金额低于投注限额',
+    'error-3407' => '投注失败',
+    'error-3501' => '未提交游戏信息',
+    'error-3502' => '用户信息有误',
+    'error-3503' => '游戏赔率有误',
+    'error-3601' => '未提交游戏名',
+    'error-3602' => '未提交游戏号码',
+    'error-3603' => '号码有误',
+    'error-3604' => '未获取到相应数据',
+    'error-5001	' => '活动公告无数据',
+    'error-5002' => '数据类型缺失',
+    'error-5003' => '获取一条数据失败',
+    'error-5004' => '没有获取内容',
+    'error-5005' => '通知内容没有传入ID',
+    'error-5006' => '客服休息了,请稍等',
+    'error-5007' => '平台维护参数不能为空',
+    'error-5008' => '平台维护token有误',
+    'error-5009' => '关闭平台维护失败',
+    'error-5010' => '开启平台维护失败',
+    'error-5011' => '平台维护失败',
+    'error-5101' => '不是版本最新,更新后拥有更好体验',
+    'error-5102' => '球类不存在',
+    'error-5103' => '赛事不存在',
+    'error-5104' => '联赛不存在',
+    'error-5105' => '投注额为空',
+    'error-5106' => '赔率为空',
+    'error-5107' => '赔率ID为空',
+    'error-5108' => '该赛事已结束',
+    'error-5109' => '赛事ID为空',
+    'error-5110' => '赔率条件为空',
+    'error-5111' => '赔率唯一ID为空',
+    'error-5112' => '联赛ID为空',
+    'error-5113' => '联赛不存在',
+
+
+
+    'error-40251' => '请填写代理地址',
+    'error-40252' => '请填写开户人姓名',
+    'error-40253' => '情填写开户银行名称',
+    'error-4017' => '代理用户未激活或不存在',
+    'error-4159' => '你输入的条件不足',
+    'error-50001' => '5秒内不能重复投注',
+    'error-4111' => '该银行卡已注册使用',
+    'error-6008' => '数据类型缺失',
+    'error-40451' => '你还未绑定银行卡',
+    'error-141313' => '申请失败,请重试',
+    'error-40452' => "您的代理于 %s 时间提交申请,客服正在审核中",
+    'error-40453' => "已提交申请,客服正在审核中",
+    'error-2255' => '操作失败',
+    'error-2345' => '金额不足',
+    'error-2354' => '申请失败',
+    'error-2346' => '无效的输入金额',
+    'error-404133' => '你的代理账号已被禁用,请联系客服',
+    'error-404123' => '你还不是代理,请绑卡申请',
+    'error-3091' => '该期游戏已开奖,请刷洗页面',
+    'error-2145' => '输入金额有误,只能输入整数金额',
+    'error-3307' => '倍率有误',
+    'error-32103' => '没有可长龙数据',
+    'error-32104' => '没有可投注内容',
+    'error-2048' => '请输入正确的汇款人名称',
+    'error-30012' => '缺少彩金活动id',
+    'error-30013' => '缺少用户信息',
+    'error-30014' => '活动已结束或会员等级不满足条件',
+    'error-30015' => '缺少彩金活动id',
+    'error-30016' => '缺少用户信息',
+    'error-30017' => '活动数据缺失',
+    'error-30018' => '申请彩金失败',
+    'error-30019' => '申请彩金记录不存在',
+    'error-30020' => '你已申请该彩金,请耐心等待彩金发放',
+    'error-30021' => '没有可申请金额',
+    'error-30022' => '用户等级不匹配',
+    'error-30023' => '申请彩金已发放',
+    'error-30024' => '申请彩金已驳回',
+    'error-5001' => '抱歉您暂时不满足条件,请仔细阅读活动说明',
+    'error-5002' => '没有满足的条件',
+
+    'error-50003' => '用户未登录!',
+    'error-50009' => '缺少id!',
+    'error-50010' => '缺少活动!',
+    'error-50011' => '用户未登录!',
+    'error-50013' => '条件不满足!',
+    'error-50014' => '条件不满足!',
+    'error-50016' => '条件不满足!',
+    'error-50017' => '金额没有满足!',
+    'error-50018' => '已申请晋级彩金!',
+    'error-50019' => '条件不满足!',
+    'error-50020' => '用户未登录!',
+    'error-50021' => '缺少金额!',
+    'error-50022' => '缺少彩金!',
+    'error-50023' => '缺少倍数!',
+    'error-50024' => '条件不满足!',
+    'error-50028' => '已经申请完成!',
+    'error-50026' => '申请失败!',
+    'error-50027' => '申请VIP成功!',
+    'error-50025' => '请选择申领等级',
+    'error-50029' => '已经申请VIP',
+    'error-50030' => '找不到订单号',
+    'error-50031' => '没有充值记录',
+    'error-50032' => '活动已错过',
+    'error-50033' => '已投注,不能参加彩金申请',
+    'error-50034' => '已参加过同类彩金活动,不能参加彩金申请',
+    'error-50035' => '请先申请VIP!',
+    'error-50036' => '已经申请VIP',
+    'error-50037' => '未匹配到对应等级',
+    'error-50038' => '同赛事下有多个记录,不能进行串式投注',
+    'error-50039' => '写入串式投注数据失败',
+    'error-50040' => '只支持上传‘jpg’,‘png’,‘gif’ 的格式',
+    'error-50041' => '只支持上传小于100 KB 的图片',
+    'error-50042' => '上传失败',
+
+
+
+    //by blade
+    'error-51000' => '彩金活动查询错误',
+    'error-51001' => '彩金的代码与ID不能为空',
+    'error-51003' => '参数对像不存在',
+    'error-51004' => '彩金id不能为空',
+    'error-51005' => '帐户id不存在',
+    'error-51006' => '彩金不存在',
+    'error-51007' => '提现倍数不存在',
+    'error-51008' => '记录不存在',
+    'error-51009' => '彩金申请id不存在',
+    'error-51010' => '彩金申请被驳回',
+    'error-51011' => '审核失败,请重试',
+    'error-51015' => '不能重复签到',
+    'error-51012' => '已审核处理',
+    'error-51013' => '申请彩金金额不能为0',
+    'error-51017' => '用户不存在',
+    'error-51018' => '系统错误,缺少签到类',
+    'error-51019' => '此会员不能参与签到功能',
+    "error-51020" => "此种类彩金活动不存在",
+    "error-51021" => "此彩金不存在",
+    "error-51022" => "此彩金活动不存在",
+    "error-51023" => "大奖最大金额小于等于最大金额",
+    "error-51024" => "签到缺少用户ID",
+    "error-51025" => "您的会员等级不符合要求",
+    "error-51026" => "申请理财彩金时,您的可用余额不足",
+    "error-51027" => "下级达到标要求的推荐人数不足",
+    "error-51028" => "游戏统计数据不存在",
+    "error-51029" => "提交数据为空",
+    "error-51030" => "获取反水信息失败",
+    "error-51031" => "获取批次投注总额失败",
+    "error-51032" => "反水失败",
+    "error-51034" => "反水比例不存在",
+
+
+    'error-51050' => '缺少彩金类型',
+    'error-51051' => '缺少彩金时间',
+    'error-51052' => '今日已签到',
+    'error-51053' => '已断签',
+    'error-51054' => '缺少签到类型',
+    'error-51055' => '充值金额小于限额,请充值后签到!',//qtx 2018-12-15
+
+    'error-60000' => '手势密码不匹配',
+    'error-60001' => '尚未设置手势密码',
+    'error-60002' => '未开启手势密码',
+    'error-60003' => '保存设置失败,请重试',
+    'error-60004' => '缺少参数',
+    'error-60005' => '无数据',
+
+
+    /***********---7--聊天相关错误**************/
+    'error-7000' => '房间不存在或已关闭',
+    'error-7001' => '数据获取失败',
+    'error-7002' => '没有权限',
+    'error-7003' => '参数为空',
+    'error-7004' => '余额不足',
+    'error-7005' => '超过房间限制',
+    'error-7006' => '红包创建失败',
+    'error-7007' => '创建失败',
+    'error-7008' => '类型错误',
+    'error-7009' => '红包文件创建失败',
+    'error-7010' => '抱歉,您已经领取过该红包',
+    'error-7011' => '您来晚了,红包已经被瓜分完毕',
+    'error-7012' => '红包已失效',
+    'error-7013' => '网络出错,请稍后重试',
+    'error-7014' => '账户异常,红包领取失败',
+    'error-7015' => '打赏者账户余额更新失败,打赏失败',
+    'error-7016' => '被打赏者账户余额更新失败,打赏失败',
+    'error-7017' => '打赏者资金记录操作失败,打赏失败',
+    'error-7018' => '被打赏者资金记录操作失败,打赏失败',
+    'error-7019' => '被打赏者名称不能为空或不存在',
+    'error-7020' => '红包ID不存在',
+    'error-7021' => '当前用户不能进入本代理房间',
+    'error-7022' => '用户当前VIP等级不能进入本房间',
+    'error-7023' => '用户当前VIP等级领取红包个数已用完',
+    'error-70231' => '领取失败,请重试',
+    'error-70241' => '用户当前VIP等级低于房间打赏VIP等级设定',
+    'error-70251' => '用户本次打赏金额超过本房间当日单次最大可打赏额度设定',
+    'error-70261' => '用户当天打赏次超过本房间设定',
+    'error-70161' => '红包ID不存在',
+    'error-70162' => '当前VIP等级在本房间可领个数超出限制',
+    'error-70150' => '红包创建异常',
+    'error-70151' => '您来晚了,红包已全部领取完',
+
+
+    /***************真人相关错误**************/
+    'error-7024' => '用户余额扣除失败',
+    'error-7025' => '资金操作记录写入失败',
+    'error-7026' => '用户余额添加失败',
+    'error-7027' => '资金充值记录写入失败',
+    'error-70141' => '添加充值记录失败',
+    'error-500142' => '添加资金流水失败',
+    'error-500143' => '更新流水差额失败',
+    'error-500144' => '添加充值REMARK记录失败',
+    'error-500145' => '增加用户账户资金失败',
+    'error-500146' => '扣减用户账户资金失败',
+    'error-500147' => '未获取到流水信息',
+
+
+    'error-7028' => '请传入集合',
+    'error-7029' => '未获取到赔率数据',
+    'error-7030' => '未提交用户名',
+    'error-7031' => '缺少用户名前缀',
+    'error-7032' => '注册失败',
+    'error-7033' => '本站用户不存在',
+    'error-7034' => '游戏已关闭',
+    'error-7035' => '金额有误',
+    'error-7036' => '代理账户余额不足',
+    'error-7037' => '插入记录表信息失败',
+    'error-7038' => '更新记录表信息失败',
+    'error-7039' => '注册失败',
+    'error-7040' => '更新记录表信息失败',
+    'error-7041' => '失败或者处理中或者不存在',
+    'error-7042' => '订单号获取失败',
+
+    'error-7043' => '皇家视讯统一错误码',
+    'error-7044' => '数据错误',
+    'error-7045' => '生成红包数据错误',
+    'error-7046' => 'MG电子统一错误码',
+    'error-7047' => '赔率条件不匹配',
+    'error-7048' => '赔率数据不匹配',
+    'error-7049' => '赔率数据过期',
+    'error-7050' => '赔率代码不匹配',
+    'error-7051' => '未获取到赔率记录',
+    'error-7052' => '赔率玩法代码未获取',
+    'error-7053' => '赔率玩法代码无效',
+
+
+    /*
+     * 在线支付相关配置
+     */
+    'error-5999' => '通道开发中',
+    'error-5998' => '通道已关闭',
+    'error-5997' => '参数难签失败!',
+    'error-5996' => '签单被篡改,如有疑问请联系客服!',
+    'error-5995' => '订单信息不完整!',
+    'error-5994' => '订单信息不存在!',
+    'error-5993' => '订单金额不能为0!',
+    'error-5992' => '请求超时,请返回重试!',
+    'error-5991' => '客户信息不存在!',
+    'error-5990' => '用户对本接口不可支付!',
+    'error-5989' => '支付异常!请联系客服!',
+    'error-5988' => '订单未支付',
+
+);

+ 86 - 0
Application/Api/Lang/Faces.php

@@ -0,0 +1,86 @@
+<?php
+$arr = [
+    [
+        'imgId' => 0,
+        'url' => "/static/images/face/0.png",
+        'type' => 0
+    ], [
+        'imgId' => 1,
+        'url' => "/static/images/face/1.png",
+        'type' => 0
+    ],[
+        'imgId' => 2,
+        'url' => "/static/images/face/2.png",
+        'type' => 0
+    ], [
+        'imgId' => 3,
+        'url' => "/static/images/face/3.png",
+        'type' => 0
+    ],[
+        'imgId' => 4,
+        'url' => "/static/images/face/4.png",
+        'type' => 0
+    ], [
+        'imgId' => 5,
+        'url' => "/static/images/face/5.png",
+        'type' => 0
+    ],[
+        'imgId' => 6,
+        'url' => "/static/images/face/6.png",
+        'type' => 0
+    ], [
+        'imgId' => 7,
+        'url' => "/static/images/face/7.png",
+        'type' => 0
+    ],[
+        'imgId' => 8,
+        'url' => "/static/images/face/8.png",
+        'type' => 0
+    ], [
+        'imgId' => 9,
+        'url' => "/static/images/face/9.png",
+        'type' => 0
+    ],[
+        'imgId' => 10,
+        'url' => "/static/images/face/10.png",
+        'type' => 0
+    ], [
+        'imgId' => 11,
+        'url' => "/static/images/face/11.png",
+        'type' => 0
+    ],[
+        'imgId' => 12,
+        'url' => "/static/images/face/12.png",
+        'type' => 0
+    ], [
+        'imgId' => 13,
+        'url' => "/static/images/face/13.png",
+        'type' => 0
+    ],[
+        'imgId' => 14,
+        'url' => "/static/images/face/14.png",
+        'type' => 0
+    ], [
+        'imgId' => 15,
+        'url' => "/static/images/face/15.png",
+        'type' => 0
+    ],[
+        'imgId' => 16,
+        'url' => "/static/images/face/16.png",
+        'type' => 0
+    ], [
+        'imgId' => 17,
+        'url' => "/static/images/face/17.png",
+        'type' => 0
+    ],[
+        'imgId' => 18,
+        'url' => "/static/images/face/18.png",
+        'type' => 0
+    ], [
+        'imgId' => 19,
+        'url' => "/static/images/face/19.png",
+        'type' => 0
+    ]
+];
+
+return ['faces' => $arr];

+ 5 - 0
Application/Api/Lang/Index.php

@@ -0,0 +1,5 @@
+<?php
+return array(
+	'hello world' => '欢迎来到中国',
+	'success' => '成功',
+);

+ 18 - 0
Application/Api/Lang/IosConf.php

@@ -0,0 +1,18 @@
+<?php
+return [
+     'Api/Account/Login' => array(
+        "status" => [
+            '-4001' => '-4025',
+        ],
+    ),
+    '/payment-PayInterface/Radzhif'=>[
+        "status" => [
+            '-4001' => '-4025',
+        ],
+    ],
+    'Api/UserDetails/CToUpgrade'=>[
+//        'toArr'=>1
+    ],
+    'Api/Account/getUserSetting'=>[
+    ],
+];

+ 128 - 0
Application/Api/Lang/OddsTemp.php

@@ -0,0 +1,128 @@
+<?php
+
+/**
+ * 赛事 玩法 赔率 代码
+ */
+
+return array(
+"concede_size" =>"让球大小",
+"concede_home"=>"全场|主队|让球",
+"concede_home_rule"=>"主队全场让球条件",
+"concede_guest"=>"全场|客队|让球",
+"concede_guest_rule"=>"客队全场让球条件",
+"half_concede_home"=>"上半场|主队|让球",
+"half_concede_home_rule"=>"主队上半场让球条件",
+"half_concede_guest"=>"上半场|客队|让球",
+"half_concede_guest_rule"=>"客队上半场让球条件",
+"size_home"=>"全场|主队|大小",
+"size_home_rule"=>"主队大小条件",
+"size_guest"=>"全场|客队|大小",
+"size_guest_rule"=>"客队大小条件",
+"half_size_home"=>"上半场|主队|大小",
+"half_size_home_rule"=>"主队上半场大小条件",
+"half_size_guest"=>"上半场|客队|大小",
+"half_size_guest_rule"=>"客队上半场大小条件",
+
+"capot"=>"独赢",
+"capot_home"=>"全场|主队|独赢",
+"capot_guest"=>"全场|客队|独赢",
+"capot_dogfall"=>"全场|主客平|独赢",
+"half_capot_home"=>"上半场|主队|独赢",
+"half_capot_guest"=>"上半场|客队|独赢",
+"half_capot_dogfall"=>"上半场|主客平|独赢",
+
+"odd_even"=>"入球数单双",
+"odd_even_odd"=>"全场|单",
+"odd_even_even"=>"全场|双",
+"half_odd_even_odd"=>"上半场|单",
+"half_odd_even_even"=>"上半场|双",
+
+"total_goal"=>"总进球数",
+"total_goal_zero"=>"全场|总入球|0-1",
+"total_goal_two"=>"全场|总入球|2-3",
+"total_goal_four"=>"全场|总入球|4-6",
+"total_goal_seven"=>"全场|总入球|7或以上",
+"half_total_goal_zero"=>"全场|总入球|0",
+"half_total_goal_one"=>"全场|总入球|1",
+"half_total_goal_two"=>"全场|总入球|2",
+"half_total_goal_three"=>"全场|总入球|3或以上",
+
+
+"half_full"=>"半场/全场",
+"half_full_home_home"=>"半场/全场 主主",
+"half_full_home_dogfall"=>"半场/全场 主和",
+"half_full_home_guest"=>"半场/全场 主客",
+"half_full_dogfall_home"=>"半场/全场 和主",
+"half_full_dogfall_dogfall"=>"半场/全场 和和",
+"half_full_dogfall_guest"=>"半场/全场 和客",
+"half_full_guest_home"=>"半场/全场 客主",
+"half_full_guest_dogfall"=>"半场/全场 客和",
+"half_full_guest_guest"=>"半场/全场 客客",
+
+"bodan"=>"波胆",
+"bodan_home_one_zero"=>"全场波胆|主队|1-0",
+"bodan_home_two_zero"=>"全场波胆|主队|2-0",
+"bodan_home_two_one"=>"全场波胆|主队|2-1",
+"bodan_home_three_zero"=>"全场波胆|主队|3-2",
+"bodan_home_three_one"=>"全场波胆|主队|3-1",
+"bodan_home_three_two"=>"全场波胆|主队|3-2",
+"bodan_home_four_zero"=>"全场波胆|主队|4-0",
+"bodan_home_four_one"=>"全场波胆|主队|4-1",
+"bodan_home_four_two"=>"全场波胆|主队|4-2",
+"bodan_home_four_three"=>"全场波胆|主队|4-3",
+"bodan_guest_one_zero"=>"全场波胆|客队|1-0",
+"bodan_guest_two_zero"=>"全场波胆|客队|2-0",
+"bodan_guest_two_one"=>"全场波胆|客队|2-1",
+"bodan_guest_three_zero"=>"全场波胆|客队|3-0",
+"bodan_guest_three_one"=>"全场波胆|客队|3-1",
+"bodan_guest_three_two"=>"全场波胆|客队|3-2",
+"bodan_guest_four_zero"=>"全场波胆|客队|4-0",
+"bodan_guest_four_one"=>"全场波胆|客队|4-1",
+"bodan_guest_four_two"=>"全场波胆|客队|4-2",
+"bodan_guest_four_three"=>"全场波胆|客队|4-3",
+"bodan_dogfall_zero_zero"=>"全场波胆|和|0-0",
+"bodan_dogfall_one_one"=>"全场波胆|和|1-1",
+"bodan_dogfall_two_two"=>"全场波胆|和|2-2",
+"bodan_dogfall_three_three"=>"全场波胆|和|3-3",
+"bodan_dogfall_four_four"=>"全场波胆|和|4-4",
+"bodan_other"=>"全场波胆|其他",
+
+"half_bodan_home_one_zero"=>"波胆上半场|主队|1-0",
+"half_bodan_home_two_zero"=>"波胆上半场|主队|2-0",
+"half_bodan_home_two_one"=>"波胆上半场|主队|2-1",
+"half_bodan_home_three_zero"=>"波胆上半场|主队|3-0",
+"half_bodan_home_three_one"=>"波胆上半场|主队|3-1",
+"half_bodan_home_three_two"=>"波胆上半场|主队|3-2",
+"half_bodan_guest_one_zero"=>"波胆上半场|客队|1-0",
+"half_bodan_guest_two_zero"=>"波胆上半场|客队|2-0",
+"half_bodan_guest_two_one"=>"波胆上半场|客队|2-1",
+"half_bodan_guest_three_zero"=>"波胆上半场|客队|3-0",
+"half_bodan_guest_three_one"=>"波胆上半场|客队|3-1",
+"half_bodan_guest_three_two"=>"波胆上半场|客队|3-2",
+"half_bodan_dogfall_zero_zero"=>"波胆上半场|和|0-0",
+"half_bodan_dogfall_one_one"=>"波胆上半场|和|1-1",
+"half_bodan_dogfall_two_two"=>"波胆上半场|和|2-2",
+"half_bodan_dogfall_three_three"=>"波胆上半场|和|3-3",
+"half_bodan_other"=>"波胆上半场|其他",
+
+"first_last_ball"=>"最先/最后进球",
+"first_ball_home"=>"主队|最先进球",
+"first_ball_guest"=>"客队|最先进球",
+"last_ball_home"=>"主队|最后进球",
+"last_ball_guest"=>"客队|最后进球",
+"not_ball"=>"没有进球",
+
+"corner_ball" =>"角球",
+"temaball" =>"球队进球大小",
+"home_size_small" =>"全场|主队|小",
+"home_size_big" =>"全场|主队|大",
+"guest_size_big" =>"全场|客队|大",
+"guest_size_small" =>"全场|客队|小",
+"half_home_size_big" =>"上半场|主队|大",
+"half_home_size_small" =>"上半场|主队|小",
+"half_guest_size_big" =>"上半场|客队|大",
+"half_guest_size_small" =>"上半场|客队|小",
+
+"promotion" =>"会晋级",
+
+);

+ 27 - 0
Application/Api/Lang/TradeType.php

@@ -0,0 +1,27 @@
+<?php
+
+return [
+    '0' => ['title' => '全部', 'key' => 'all'],
+    '1' => ['title' => '投注', 'key' => 'bet'],
+    '2' => ['title' => '追号', 'key' => 'reBet'],
+    '3' => ['title' => '撤单', 'key' => 'cancelBet'],
+    '4' => ['title' => '中奖', 'key' => 'prized'],
+    '5' => ['title' => '提现', 'key' => 'withdraw'],
+    '6' => ['title' => '在线充值', 'key' => 'netPay'],
+    '7' => ['title' => '反水', 'key' => 'backMoney'],
+    '8' => ['title' => '回水', 'key' => 'returnMoney'],
+    '9' => ['title' => '管理员扣款', 'key' => 'sysCost'],
+    '10' => ['title' => '佣金提成', 'key' => 'commission'],
+    '11' => ['title' => '后台充值', 'key' => 'sysRecharge'],
+    '12' => ['title' => '活动', 'key' => 'activity'],
+    '13' => ['title' => '充值赠送', 'key' => 'rechargeGift'],
+    '14' => ['title' => '汇款', 'key' => 'bankMoney'],
+    '15' => ['title' => '提现冻结', 'key' => 'withdraw_frozen'],
+    '16' => ['title' => '红包打赏', 'key' => 'luckyMoney'],
+    '19' => ['title' => '额度转换', 'key' => 'transMoney'],
+    '21' => ['title' => '其它', 'key' => 'oth'],
+    '22' => ['title' => '代理代充', 'key' => 'agentRecharge'],
+    '19-1' => ['title' => '额度转入', 'key' => 'trueGameIn'],
+    '19-2' => ['title' => '额度转出', 'key' => 'trueGameOut'],
+
+];

+ 106 - 0
Application/Api/Model/Account.php

@@ -0,0 +1,106 @@
+<?php
+/**
+ *------Create thems Model------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-06 07:45:06------
+ */
+
+namespace App\Api\Model;
+
+use App\Commons\Model\Money_recharge;
+use Biz\Account\AccountManager;
+use \System\Model;
+
+class Account extends Model
+{
+
+    protected $table = 'account';
+
+    protected function getMoneyRechargeRec(string $account_identity, $activeId, string $type = '')
+    {
+        $m = new Money_recharge();
+        $where = [
+            'account_identity' => $account_identity,
+            'status' => 1
+        ];
+        $betTime = '';
+        switch ($type) {
+            case 'month':
+                $where[] = ['complete_time', '>=', $betTime = date ('Y-m-1')];
+                break;
+            case 'week':
+                $time = date ('Y-m-d');
+                $t = strtotime ($time . ' Sunday');
+                $where[] = ['complete_time', '>=', $betTime = date ('Y-m-d H:i:s', $t - 86400 * 6)];
+                break;
+            default:
+
+                $where[] = ['complete_time', '>=', $betTime = '2018-01-01 00:00:00'];
+        }
+        self::chkBettingRecord ($account_identity, $betTime);
+        return $m->where ($where)->whereIn ('recharge_type', ['后台充值', '汇款', '在线充值'])->orderBy ('apply_time')->first (['money', 'order_id', 'complete_time']);
+    }
+
+    public static function chkFirstRecharge($account_identity, $activeId, $type = '')
+    {
+        $active = Lottery_money::where ('id', $activeId)->first ();
+        // dd($activeId,$active);
+        if (!$active)
+            Render ('', -50016); //找不到该彩金活动
+        $ret1 = self::getMoneyRechargeRec ($account_identity, $activeId, $type);
+        if (!$ret1)
+            Render ('', -50031);//没找到首充记录
+        $content = json_decode ($active->conent, 1);
+        $timeout = $content['fr_time'] ?? 0;
+        $timeouted = strtotime ($ret1->complete_time) >= time () - $timeout * 3600;
+        if (!$timeouted && $timeout)
+            Render ('', -50032);//过期
+        $ret2 = Lottery_money_log::where ('order_id', $ret1->order_id)->first ();
+        if ($ret2) {
+            if ($ret2->status = 0)
+                Render ('', -50035);//申请审核中
+            elseif ($ret2->status = 0)
+                Render ('', -50034);//该订单已参加过活动
+        }
+
+        //验证是否有下注
+        return $ret1;
+    }
+
+    protected function chkBettingRecord($account_identity, $time)
+    {
+        $mb = MoneyBuy::where ('account_identity', $account_identity)->where ('money_time', '>=', $time)->first ();
+        $mb6 = SixmoneyBuy::where ('account_identity', $account_identity)->where ('money_time', '>=', $time)->first ();
+        if ($mb || $mb6)
+            Render ('', -50033);//有下注
+        return 1;
+    }
+
+    public function getAccount($account_identity)
+    {
+        return self::where('identity', $account_identity)->pluck('account');
+    }
+
+    /**
+     * @param string $token
+     * @param string $payPass
+     * @return bool
+     * @throws \Exception
+     */
+    public static function checkPayPwd(string $token, string $payPass): int
+    {
+        $accountManager = new AccountManager();
+        $userId = $accountManager->getCurrentUser()->account_identity;
+        $res = lm('account_bank', 'Commons')->where(['account_identity' => $userId])->first();
+        if (!$res) {
+            // Render('', -2046, lang()->get('missing bankCard'));
+            return -2046;
+        }
+
+        $return = $accountManager->repository->checkOldPayPassword($token, $payPass);
+        return $status = $return['status'];
+
+    }
+
+}

+ 100 - 0
Application/Api/Model/AccountDetail.php

@@ -0,0 +1,100 @@
+<?php
+/**
+ *------Create thems Model------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-12 05:08:18------
+ */
+namespace App\Api\Model;
+
+use \System\Model;
+use Biz\Account\AccountManager;
+
+class AccountDetail extends Model {
+
+    protected $table = 'account_detailed';
+
+    /**
+     * 修改用户基本信息
+     *
+     * @access public
+     * @return String
+     */
+    public function updateUserInfo()
+    {
+        // 获取用户信息
+        $accountManagerClass = new AccountManager;
+        $userInfo = $accountManagerClass -> getCurrentUser();
+        if (empty($userInfo['identity'])) {
+            Render([], '2001', lang('Common','Api') -> get('user does login'));
+        }
+        $updateWhere['account_identity'] = $userInfo['identity'];
+        $updateData = [];
+        // 提取修改数据
+        if (!empty($_POST['email'])) {
+            $updateData['email'] = $_POST['email'];
+        }
+        if (!empty($_POST['phone'])) {
+            $updateData['phone'] = $_POST['phone'];
+        }
+        if (!empty($_POST['img_id'])) {
+            $updateData['img_id'] = $_POST['img_id'];
+            $updateData['img_url'] = '';
+            $oldImg = lm('Account_detailed', 'commons') -> accountDetailed(['img_url'], $updateWhere);
+            // 删除以前的文件
+            unlink(ROOT_PATH . $oldImg -> img_url);
+        }
+        if (!empty($_POST['name'])) {
+            $updateData['name'] = $_POST['name'];
+        }
+        if (empty($updateData)) {
+            Render([], '4027', lang('Common','Api') -> get('please enter the modification'));
+        }
+        return lm('Account_detailed', 'commons') -> updateDetailed($updateWhere, $updateData);
+    }
+
+    /**
+     * 上传用户基本信息头像
+     *
+     * @access public
+     * @return String
+     */
+    public function updateHeader()
+    {
+        // 获取用户信息
+        $accountManagerClass = new AccountManager;
+        $userInfo = $accountManagerClass -> getCurrentUser();
+        if (empty($userInfo['identity'])) {
+            Render([], '2001', lang('Common','Api') -> get('user does login'));
+        }
+        // 规定上传格式
+        $allowedType = ["png", "jpg", "gif"];
+        $allowedExtensions = ["image/jpg","image/jpeg","image/png","image/pjpeg","image/gif","image/bmp","image/x-png"];
+        // 最大为 100 Kb
+        $maxSize = 102400;
+        // 获取上传文件
+        $img = $_FILES['img'];
+        // 获取上传文件格式并转换为小写
+        $imgType = strtolower(substr($img['name'],strrpos($img['name'],".") + 1));
+        // 判断格式是否符合要求
+        if (!in_array($imgType, $allowedType) || !in_array(strtolower($img['type']), $allowedExtensions)) {
+            Render([], '50040', lang('Common','Api') -> get('Picture files are not supported'));
+        }
+        if ($img['size'] > $maxSize) {
+            Render([], '50041', lang('Common','Api') -> get('Picture too large'));
+        }
+        // 修改文件名
+        $imgName = strtotime('now') + rand(10000, 99999);
+        $filePath = ROOT_PATH . '/Public/img/header/';
+        $imgPath = '/Public/img/header/' . $imgName . ".png";
+        if (move_uploaded_file($img['tmp_name'], $filePath . $imgName . ".png")) {
+            $updateWhere['account_identity'] = $userInfo['identity'];
+            $oldImg = lm('Account_detailed', 'commons') -> accountDetailed(['img_url'], $updateWhere);
+            // 删除以前的文件
+            unlink(ROOT_PATH . $oldImg -> img_url);
+            lm('Account_detailed', 'commons') -> updateDetailed($updateWhere, ['img_url' => $imgPath]);
+        } else {
+            Render([], '50042', lang('Common','Api') -> get('Upload failure'));
+        }
+    }
+}

+ 62 - 0
Application/Api/Model/AccountNews.php

@@ -0,0 +1,62 @@
+<?php
+/**
+ *------Create thems Model------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-12 05:08:18------
+ */
+namespace App\Api\Model;
+
+use \System\Model;
+use Biz\Account\AccountManager;
+
+class AccountNews extends Model {
+
+    protected $table = 'account_news';
+
+    /**
+     * 用户消息
+     *
+     * @access public
+     * @return String
+     */
+    public function userNews()
+    {
+        // 获取用户信息
+        $accountManagerClass = new AccountManager;
+        $userInfo = $accountManagerClass -> getCurrentUser();
+        if (empty($userInfo['identity'])) {
+            Render([], '2001', lang('Common','Api') -> get('user does login'));
+        }
+        $accountNewsWhere['account_identity'] = $userInfo['identity'];
+        // 查询条件
+        if (!empty($_POST['read_status'])) {
+            $accountNewsWhere['read_status'] = $_POST['read_status'];
+        }
+        if (!empty($_POST['type'])) {
+            $accountNewsWhere['type'] = $_POST['type'];
+        }
+        // 时间区间
+        $startTime = isset($_POST['startTime'])? $_POST['startTime'] : '1900-01-01 00:00:00';
+        $endTime = isset($_POST['endTime'])? $_POST['endTime'] : '3000-12-12 00:00:00';
+        $accountNewsBetween = ['write_time' => [$startTime, $endTime]];
+        // 当前页
+        $currentPage = isset($_POST['currentPage']) ? $_POST['currentPage'] : "1";
+        // 分页大小
+        $pageSize = isset($_POST['pageSize']) ? $_POST['pageSize'] : "10";
+        // 起始查询位置
+        $begin = ($currentPage - 1) * $pageSize;
+        $accountNewsMdl = lm('account_news', "commons");
+        // 获取消息
+        $accountNewsSlt = ['title', 'identity', 'content', 'details', 'write_time', 'read_status', 'type'];
+        $getMoneyBuyStr = $accountNewsMdl -> accountNews($accountNewsSlt, $accountNewsWhere, $accountNewsBetween, $begin, $pageSize, 1);
+        // 获取消息总数
+        $result['total'] = $accountNewsMdl -> accountNewsTotal($accountNewsWhere, $accountNewsBetween);
+        $result['list'] = $getMoneyBuyStr;
+        // 总页数计算
+        $result['countPage'] = ceil($result['total'] / $pageSize);
+        $result['currentPage'] = $currentPage;
+
+        return $result;
+    }
+}

+ 17 - 0
Application/Api/Model/Advert.php

@@ -0,0 +1,17 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: asus
+ * Date: 2017/6/6
+ * Time: 17:58
+ */
+
+namespace App\Api\Model;
+use \System\Model;
+
+class Advert extends Model {
+	protected $table = 'advert';
+	public function getlist() {
+		return $data = "a";
+	}
+}

+ 14 - 0
Application/Api/Model/Article.php

@@ -0,0 +1,14 @@
+<?php
+/**
+ *------Create thems Model------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-12 05:08:18------
+ */
+namespace App\Api\Model;
+use \System\Model;
+
+class Article extends Model {
+
+	protected $table = 'article';
+}

+ 18 - 0
Application/Api/Model/ArticleType.php

@@ -0,0 +1,18 @@
+<?php
+/**
+ *------Create thems Model------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-12 05:08:18------
+ */
+namespace App\Api\Model;
+use \System\Model;
+
+class ArticleType extends Model {
+
+	protected $table = 'article_type';
+
+    function type(){
+        return   $this->orderBy('sort', 'desc')->get()->toArray();
+    }
+}

+ 14 - 0
Application/Api/Model/BandBank.php

@@ -0,0 +1,14 @@
+<?php
+/**
+ *------Create thems Model------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-12 05:08:18------
+ */
+namespace App\Api\Model;
+use \System\Model;
+
+class BandBank extends Model {
+
+    protected $table = 'band_bank';
+}

+ 17 - 0
Application/Api/Model/Banner.php

@@ -0,0 +1,17 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: asus
+ * Date: 2017/6/6
+ * Time: 17:58
+ */
+
+namespace App\Api\Model;
+use \System\Model;
+
+class Banner extends Model {
+	protected $table = 'banner';
+	public function getlist() {
+		return $data = "a";
+	}
+}

+ 16 - 0
Application/Api/Model/BetStr.php

@@ -0,0 +1,16 @@
+<?php
+/**
+ *------Create thems Model------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-12 05:08:18------
+ */
+namespace App\Api\Model;
+
+use \System\Model;
+use Biz\Account\AccountManager;
+
+class BetStr extends Model {
+
+    protected $table = 'st_bet_str';
+}

+ 15 - 0
Application/Api/Model/Chat_redbag.php

@@ -0,0 +1,15 @@
+<?php
+    /**
+     * Created by PhpStorm.
+     * User: blues
+     * Date: 2018/12/24
+     * Time: 15:22
+     */
+
+    namespace App\Api\Model;
+    use \System\Model;
+
+    class Chat_redbag extends Model
+    {    public $timestamps = true;
+        protected $table = 'chat_redbag';
+    }

+ 242 - 0
Application/Api/Model/Chat_rooms.php

@@ -0,0 +1,242 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: blues
+ * Date: 2018/12/1
+ * Time: 15:06
+ */
+
+namespace App\Api\Model;
+
+use phpDocumentor\Reflection\Types\Mixed_;
+use \System\Model;
+
+
+class Chat_rooms extends Model {
+    public $timestamps = false;
+    protected $table = 'chat_rooms';
+    static $room_info;
+
+    public function getRoomList(int $vip_level) {
+        $cond = ['status' => 1];
+        if ($vip_level === -1) {
+            $vip_level = 0;
+        }
+        if ($vip_level === -2) {
+            $cond['limit_vip'] = -2;
+        } else {
+            $cond['limit_vip'] = ['<=', $vip_level];
+        }
+        return self::where($cond)->whereOr('limit', 0)->get();
+    }
+
+    public function getRoomListByGameName(int $vip_level, string $game_name) {
+        $cond = ['status' => 1];
+        if ($vip_level === -1) {
+            $vip_level = 0;
+        }
+        $cond['game_name'] = $game_name;
+        if ($vip_level === -2) {
+            $cond['limit_vip'] = -2;
+        } else {
+            $cond['limit_vip'] = ['<=', $vip_level];
+        }
+        return self::where($cond)->get();
+    }
+
+    /**
+     * 代理身份校验(必要条件)
+     * @param int $room_id
+     * @param string $account
+     * @return bool
+     */
+    public static function agentCheck(int $room_id, string $account): bool {
+        //代理房间验证
+        if ((new self)->isAdmin(null, $room_id, $_SESSION['uinfo']['account'])) return true;
+        $root_agent = self::getRootAgent($account);
+        if (!self::$room_info) {
+            self::$room_info = self::where('id', $room_id)->first();
+        }
+        $room_info = self::$room_info;
+        if (!$room_info) {
+            return false;
+        }
+        if (intval($room_info->room_type) === 1) {
+            return true;
+        }
+        return $root_agent === $room_info->agentname;
+    }
+
+    /**
+     * VIP等级校验(必要条件)
+     * @param int $room_id
+     * @param int $vip_level
+     * @return bool
+     */
+    public static function vipCheck(int $room_id, int $vip_level): bool {
+        //vip等级验证
+        if ((new self)->isAdmin(null, $room_id, $_SESSION['uinfo']['account'])) return true;
+        if ($vip_level === -1) {
+            $vip_level = 0;
+        }
+        if (!self::$room_info) {
+            self::$room_info = self::where('id', $room_id)->first();
+        }
+
+        $room_level = self::$room_info->limit_vip;
+        if ($room_level === -2) {
+            if ($vip_level === 0 || $vip_level === -1) {
+                return false;
+            }
+            return true;
+        } elseif ($room_level === 0 || $room_level === -1) return true;
+        else
+            return $room_level <= $vip_level;
+    }
+
+    /**
+     * 红包超领校验,true=pass
+     * @param int $room_id
+     * @param string $account_identity
+     * @param int $vip_level
+     * @return bool
+     */
+    public static function overTakeCheck(int $room_id, string $account_identity, int $vip_level): bool {
+        //红包个数验证
+        if ((new self)->isAdmin(null, $room_id, $_SESSION['uinfo']['account'])) return true;
+        $redpackNum = (new LuckyMoneyTake())->where('account_identity', $account_identity)->select('hash')->count();
+        if (!self::$room_info) {
+            self::$room_info = self::where('id', $room_id)->first();
+        }
+        $targetRoom = self::$room_info;
+        $targetLevel = $targetRoom->redbag_grade;//红包限制等级
+        $targetLimit = $targetRoom->redbag_limit;//限制等级会员的红包总可领取个数
+        if ($targetLevel === -2) {
+
+            if ($vip_level === 0 || $vip_level === -1) {
+                return $targetLimit > $redpackNum;
+            } else {
+
+                return true;
+            }
+        } elseif ($targetLevel === 0 || $targetLevel === -1) {
+            return true;
+        } else {
+            if ($targetLevel <= $vip_level) {
+                return true;
+            }
+            return $targetLimit > $redpackNum;
+        }
+    }
+
+    public static function isAgentRoom($room_id) {
+        return self::where('id', $room_id)->first()->room_type === 2 ? true : false;
+    }
+
+    public static function isAgentUser(string $account, $parent_path, int $room_id): bool {
+        if (!self::$room_info) {
+            self::$room_info = self::where('id', $room_id)->first();
+        }
+        if (self::$room_info->room_type !== 2) return true;
+
+        $p_identity = explode(',', $parent_path);
+        $ar = [];
+        if (!empty($p_identity)) {
+            foreach ($p_identity as $key => $val) {
+                $parents = lm('Account', 'Api')->where('identity', $val)->where('account', '!=', 'root')->first(['identity', 'account']);
+                $parents = $parents ? $parents->toarray() : [];
+                if ($parents) array_unshift($ar, $parents['account']);
+            }
+        }
+        $ar[] = $account;
+        return in_array(self::$room_info->agentname, $ar);
+    }
+
+    protected function getRootAgent(string $account_identity): string {
+        $agent = lm('nagent_detailed', 'commons')->where('agent_user', $account_identity)->first(['parent_path', 'parent_id']);
+        $parent_path = $agent->parent_path ?? '';
+        $rootUUID = explode(',', $parent_path)[0];
+        if (!$rootUUID) return '';
+        return lm('Account', 'Api')->where('identity', $rootUUID)->first()->account ?? '';
+    }
+
+    /**
+     * 红包领取规则验证
+     * @param $room_id
+     * @return mixed
+     */
+    public function redPackTakeRule($room_id) {
+        //房间打赏规则
+        $roomInfo = $this
+            ->where('id', $room_id)
+            ->where('status', 1)
+            ->first(['redbag_grade', 'redbag_limit', 'redbag_max_money', 'redbag_max_no']);
+        if (!$roomInfo) {
+            //房间不存在或已关闭
+            return -7000;
+        }
+        if ($this->isAdmin($roomInfo, $room_id, $_SESSION['uinfo']['name'])) return $roomInfo;
+        $uuid = $_SESSION['uinfo']['identity'];
+        //取得当前用户当天领取红包的总个数
+        $luckyMoneyTakeNum = lm('LuckyMoneyTake', 'Api')
+            ->where('room_id', $room_id)
+            ->where('account_identity', $uuid)
+            ->where('time', '>=', strtotime('-1 day'))
+            ->whereIn('type', [0, 1])
+            ->count('id');
+
+        $roomInfo->lucky_money_take_num = $luckyMoneyTakeNum;//今日领取红包的总个数
+
+        $level = $_SESSION['uinfo']['level'];
+        $minLevel = (int)$roomInfo->redbag_grade;
+        if ($minLevel === -2) {
+            $sw = ($level === -2 || $level > 0);
+        } else if ($minLevel > 0) {
+            $sw = ($level >= $minLevel);
+        } else {
+            $sw = !($level === 0 || $level === -1);
+        }
+//        $roomInfo->canTake = $sw;
+        if (!$sw && $luckyMoneyTakeNum >= $roomInfo->redbag_limit) {
+            //可领个数超出限制
+            return -70162;
+        }
+        return $roomInfo;
+
+    }
+
+    /**
+     * 房间用户昵称列表
+     * @param int $room_id
+     * @return array
+     */
+    public function getNickNames(int $room_id): array {
+        $lm = (new Chat_rooms())->where('id', $room_id)->first();
+        $manArr = [];
+        if ($lm) {
+            $mans = trim($lm->nickname_list) . ',';
+            $tmp = explode(',', $mans);
+            foreach ($tmp as $k => $v) {
+                if (!$v) continue;
+                list ($kk, $vv) = explode('||', $v);
+                $manArr[$kk] = $vv;
+            }
+            $manArr['room_mangers_id'] = $lm['room_mangers_id'];
+        }
+        return $manArr;
+    }
+
+    /**
+     * 验证用户是否是管理员
+     * @param $roomObj
+     * @param int $room_id
+     * @param string $user_name
+     * @return mixed
+     */
+    public function isAdmin( $roomObj, int $room_id, string $user_name){
+        $roomObj ?: $roomObj = $this->where('id', $room_id)->first();
+        if (!$roomObj) return false;
+        $admins = explode(',', $roomObj->room_mangers_id);
+        return in_array($user_name, $admins);
+    }
+}

+ 16 - 0
Application/Api/Model/Chat_users.php

@@ -0,0 +1,16 @@
+<?php
+    /**
+     * Created by PhpStorm.
+     * User: Lenovo
+     * Date: 2018/12/4
+     * Time: 17:52
+     */
+
+    namespace App\Api\Model;
+
+    use \System\Model;
+    class Chat_users extends Model
+    {
+        public $timestamps = false;
+        protected $table = 'chat_users';
+    }

+ 14 - 0
Application/Api/Model/Lottery_money.php

@@ -0,0 +1,14 @@
+<?php
+/**
+ *------Create thems Model------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-12 05:08:18------
+ */
+namespace App\Api\Model;
+use \System\Model;
+
+class Lottery_money extends Model
+{
+    protected $table = 'lottery_money';
+}

+ 78 - 0
Application/Api/Model/Lottery_money_log.php

@@ -0,0 +1,78 @@
+<?php
+/**
+ *------Create thems Model------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-12 05:08:18------
+ */
+namespace App\Api\Model;
+use \System\Model;
+
+class Lottery_money_log extends Model {
+
+    protected $table = 'lottery_money_log';
+    protected $fillable = ['status', 'remark','operator','operator_id','flow_record','update_time'];
+
+    //签到返回天数
+    function Signin($params){
+
+    	if(empty($params['lottery_money_id'])){
+    		return -51004;
+    	}
+        $lottery = lm ('lottery_money', 'Api')->where ('id',$params['lottery_money_id'])->first ();
+        if(empty($lottery)){
+            return -51004;
+        }
+        $lottery = $lottery->toArray();
+        $sdefaultDate = date("Y-m-d");
+        //$first =1 表示每周星期一为开始日期 0表示每周日为开始日期
+        $first=1;
+        //获取当前周的第几天 周日是 0 周一到周六是 1 - 6
+        $w=date('w',strtotime($sdefaultDate));
+        //获取本周开始日期,如果$w是0,则表示周日,减去 6 天
+        $week_start=date('Y-m-d',strtotime("$sdefaultDate -".($w ? $w - $first : 6).' days'));
+        //本周结束日期
+        $week_end=date('Y-m-d',strtotime("$week_start +6 days"));
+        $info = lm("Lottery_money_log","Api")->where('lottery_money_type',$lottery['type']);
+    	if(empty($params['account_identity'])){
+    		return -51005;
+    	}else{
+    		$info = $info->where('account_identity',$params['account_identity']);
+    	}
+    	$info = $info->where('create_time','>=',$week_start.' 00:00:00')->where('create_time','<=',$week_end.' 23:59:59')->orderBy('create_time','asc')->get();
+        $info = $info->toArray();
+        foreach ($info as $key => $value) {
+            $info[$key]['week'] = date("w",strtotime($value['create_time']));
+            $info[$key]['time'] = substr($value['create_time'],0,10);
+        }
+        $arr = array();
+        $arr['list'] = $info;
+        if(count($info) >= 7 ){
+            $num = 7;
+        }else{
+            $num = count($info); 
+        }
+        $arr['num'] = $num;
+        return $arr;
+    	 
+    }
+
+    //今日签到
+    function todaySignin($params){
+        if(empty($params['account_identity'])){
+            return -51005;
+        }
+        $info = lm("Lottery_money_log","Api")->where('account_identity',$params['account_identity'])->where('lottery_money_type','sign')->where('create_time','>=',date('Y-m-d 00:00:00',time()))->where('create_time','<=',date('Y-m-d 23:59:59',time()))->first();
+        if(empty($info)){
+            $arr['money'] = 0;
+            $arr['active'] = 0;
+        }else{
+            $info = $info->toArray();
+            $arr['money'] = $info['money'];
+            $arr['active'] = 1;
+            $arr['create_time'] = $info['create_time'];
+        }
+        return $arr;
+    }
+ 
+}

+ 14 - 0
Application/Api/Model/Lottery_type.php

@@ -0,0 +1,14 @@
+<?php
+/**
+ *------Create thems Model------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-12 05:08:18------
+ */
+namespace App\Api\Model;
+use \System\Model;
+
+class Lottery_type extends Model {
+
+    protected $table = 'lottery_type';
+}

+ 156 - 0
Application/Api/Model/LuckyMoney.php

@@ -0,0 +1,156 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Administrator
+ * Date: 2018/12/1
+ * Time: 10:03
+ */
+
+namespace App\Api\Model;
+
+use Biz\Money\LotteryMoneyConfirm;
+use \System\Model;
+
+class LuckyMoney extends Model
+{
+    protected $table = 'lucky_money';
+    private $lm_oid;
+
+    /**
+     * 插入红包发起记录
+     * @param string $account_identity
+     * @param string $lm_oid
+     * @param float $money
+     * @param int $room_id
+     * @param int $num
+     * @param int $type
+     * @param string $message
+     * @return int
+     */
+    public function addLuckyMoneyRec(string $account_identity, string $lm_oid, float $money, int $room_id, int $num, $type = 0, string $message = '')
+    {
+        $data = [
+            'account_identity' => $account_identity,
+            'lm_order_id' => $lm_oid,
+            'money' => $money,
+            'room_id' => $room_id,
+            'num' => $num,
+            'type' => $type,
+            'message' => $message,
+            'created_at' => date('Y-m-d H:i:s')
+        ];
+        $ret = self::insertGetId($data);
+        return $ret > 0 ? $lm_oid : -7030;
+    }
+
+    protected function updateLuckyMoneyRec(int $lm_id, float $take_money, int $take_num, float $ret_money = 0, string $ret_order_id = '')
+    {
+        $data = [
+            'take_money' => $take_money,
+            'take_num' => $take_num,
+        ];
+        if ($ret_money > 0) {
+            $data['return_money'] = $ret_money;
+            $data['return_order_id'] = $ret_order_id;
+        }
+        $data['updated_at'] = time();
+        return $ret = self::where('id', $lm_id)->update($data);
+    }
+
+    /**
+     * 添加红包记录
+     * @param string $account_identity
+     * @param float $money
+     * @param int $num
+     * @param int $room_id
+     * @param int $type
+     * @param string $message 红包祝福语
+     * @param callable $cb_red_pack_file_init
+     * @return mixed
+     */
+    public function handleLuckyMoney(string $account_identity, float $money, int $num, int $room_id, int $type = 0, $message = '', callable $cb_red_pack_file_init)
+    {
+//        $obj = C()->get('AutoLottery');
+        $obj = new LotteryMoneyConfirm();
+        $obj->account_identity = $account_identity;
+        $obj->operation_time = date('Y-m-d H:i:s', time());
+        $account = lm('Account', 'api')->where('identity', $account_identity)->first();
+        if (!$account) {
+            return -51017;//用户不存在
+        }
+        $accountDetail = lm('AccountDetail', 'Api')->where('account_identity', $account_identity)->first();
+        if (!$accountDetail) {
+            return -51017;//用户不存在
+        }
+        $obj->account_name = $account->account;//用户账号
+        $obj->money = $money;//发起金额
+        $obj->money_cash = $accountDetail->cash - $money;
+        $obj->order_id = OrderID();//生成订单号
+        $obj->money_type = 2;//扣款操作
+        $obj->trade_type = 16;//红包打赏;
+        $obj->rate = 1;//流水倍数;
+        $obj->operator = 'system_auto';//审核人
+        _beginTransaction();
+        $updateAccountDetail = $obj->decrAccountDetailMoney($account_identity, $money);
+        if ($updateAccountDetail != 1) {
+//            dd(1111, $updateAccountDetail);
+            _rollback();
+            return $updateAccountDetail;
+            //更新余额失败
+        }
+        $detail = "{$obj->account_name}于{$obj->operation_time}在{$room_id}号房间发起了红包,金额为{$money}元";//备注
+        $opDetail = $obj->addMoneyDetailRec($detail,'发起红包',2);
+
+        if ($opDetail == -50014) {
+//            dd(2222, $opDetail);;
+            _rollback();
+            return $opDetail;
+        }
+        $this->lm_oid = $opDetail;
+        $opLmRec = self::addLuckyMoneyRec($account_identity, $this->lm_oid, $money, $room_id, $num, $type, $message);
+        if ($opLmRec < 0) {
+            //   dd(3333, $updateAccountDetail);
+            _rollback();
+            return $opDetail;
+        }
+        $file = $cb_red_pack_file_init($this->lm_oid, $money, $num, $type);
+        if ($file !== 1) {
+            _rollback();//红包文件创建失败
+            return -7009;
+        }
+
+        //todo:用户操作日志添加
+        _commit();
+        //return $opLmRec;
+//        $ret = self::where('lm_order_id', $opLmRec)->first();
+//        return $ret->lm_order_id;
+        return $opLmRec;
+    }
+
+    public function getHistory(string $account_identity, int $page, int $limit)
+    {
+        $offset = $page * $limit;
+        return $ret = self::where('account_identity', $account_identity)
+            ->orderBy('id', 'desc')
+//            ->select('lm_order_id as lm_id','money','created_at','num')
+            ->limit($offset, $limit)
+            ->get();
+    }
+
+    public function getDetail(string $lm_id)
+    {
+        return $this ->leftJoin('account_detailed','lucky_money.account_identity','=','account_detailed.account_identity')
+            ->where('lucky_money.lm_order_id', $lm_id)
+            ->select('lucky_money.lm_order_id', 'lucky_money.num', 'lucky_money.take_num', 'lucky_money.money', 'lucky_money.take_money', 'lucky_money.message','account_detailed.img_url','account_detailed.img_id')
+            ->first();
+    }
+
+    //检测红包是否存在 anton 2019-01-27
+    public function checkRed($where)
+    {
+         return $this->where('created_at','>=',$where['start'])
+             ->where('created_at','<=',$where['end'])
+             ->where('type','=','3')
+             ->get();
+    }
+}

+ 187 - 0
Application/Api/Model/LuckyMoneyTake.php

@@ -0,0 +1,187 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Administrator
+ * Date: 2018/12/1
+ * Time: 10:03
+ */
+
+namespace App\Api\Model;
+
+use \System\Model;
+
+class LuckyMoneyTake extends Model {
+    protected $table = 'lucky_money_take';
+
+    /**
+     * 插入领取记录到表
+     * @param string $account_identity
+     * @param int $room_id
+     * @param string $lm_id
+     * @param string $lm_oid
+     * @param float $money
+     * @param int $type
+     * @return mixed
+     */
+    public function addLuckyMoneyTake(string $account_identity, int $room_id, string $lm_id, string $lm_oid, float $money, int $type = 0) {
+        $data = [
+            'account_identity' => $account_identity,
+            'money' => $money,
+            'room_id' => $room_id,
+            'lm_id' => $lm_id,
+            'md_order_id' => $lm_oid,
+            'time' => time(),
+            'hash' => md5($room_id . $lm_id . $account_identity),
+            'type' => $type,
+        ];
+        $ret = self::insertGetId($data);
+        return $ret > 0 ? $lm_oid : -7029;
+    }
+
+    /**
+     * 抢红包函数
+     * @param string $account_identity
+     * @param int $room_id
+     * @param string $lm_id
+     * @param float $money
+     * @return string
+     */
+    public function handleLuckyMoneyTake(string $account_identity, int $room_id, string $lm_id, float $money): string {
+        $hash = md5($room_id . $lm_id . $account_identity);
+        $data = self::where('hash', $hash)->first(['md_order_id']);
+        if ($data) return $data->md_order_id;
+        $obj = C()->get('AutoLottery');
+        $obj->account_identity = $account_identity;
+        $obj->operation_time = date('Y-m-d H:i:s', time());
+        $account = lm('Account', 'api')->where('identity', $account_identity)->first();
+        if (!$account) {
+            return -51017;//用户不存在
+        }
+        $accountDetail = lm('AccountDetail', 'Api')->where('account_identity', $account_identity)->first();
+        if (!$accountDetail) {
+            return -51017;//用户不存在
+        }
+        $obj->account_name = $account->account;//用户账号
+        $obj->money = number_format($money, 2,'.','');//充值金额
+        $obj->money_cash = $accountDetail->cash + $money;
+        $obj->order_id = OrderID();//生成订单号
+        $obj->trade_type = 16;//红包打赏;
+        $obj->rate = 0;//流水倍数;
+        $obj->money_type = 1;
+        $obj->operator = 'system_auto';//审核人
+        _beginTransaction();
+        $updateAccountDetail = $obj->incrAccountDetailMoney($account_identity, $money);
+
+        if ($updateAccountDetail != 1) {
+            _rollback();
+//            dd(1111, $updateAccountDetail);
+            return $updateAccountDetail;
+            //更新余额失败
+        }
+
+        $detail = "{$obj->account_name}于{$obj->operation_time}在{$room_id}号房间领取了红包,金额为{$money}元,红包编号为【{$lm_id}】";//备注
+
+        $opDetail = $obj->addMoneyDetailRec($detail, '领取红包', 2);
+        if ($opDetail == -50014) {
+            _rollback();
+//            dd(222, $opDetail, $obj);
+            return $opDetail;
+        }
+
+        $mr = $obj->addMoneyRechargeRec('领取红包', '领取红包', '红包打赏');
+        if (intval($mr) < 0) {
+            _rollback();//资金记录创建失败
+            return intval($mr);
+        }
+        $opLmRec = self::addLuckyMoneyTake($account_identity, $room_id, $lm_id, $opDetail, $money);
+        if ($opLmRec < 0) {
+            _rollback();
+            return $opDetail;
+        }
+        $lm = new LuckyMoney();
+        $lmObj = $lm->where('lm_order_id', $lm_id)->first();
+        if ($lmObj) {
+            $num = $lmObj->num; //红包总个数
+            $take_num = $lmObj->take_num; //红包已被领取个数
+            if ($num > $take_num) {
+                $lmObj->take_num++;
+                $lmObj->take_money += $money;
+                $lmObj->save();
+            } else {
+                _rollback();
+                return -7012; //红包已领完
+            }
+
+        } else {
+            _rollback();
+            return -70161; //红包ID不存在
+        }
+        //todo:用户操作日志添加
+        _commit();
+        return $opLmRec;
+//        return self::where('id', $opLmRec)->first()->md_order_id;
+
+    }
+
+    /**
+     * 用户抢红包历史记录
+     * @param string $account_identity
+     * @param int $page
+     * @param int $limit
+     * @return mixed
+     */
+    public function getHistory(string $account_identity, int $page, int $limit) {
+        $offset = $page * $limit;
+        return $ret = self::where('account_identity', $account_identity)
+            ->orderBy('time', 'desc')
+            ->limit($offset, $limit)
+            ->select($this->table . '.money', $this->table . '.time')
+            ->get();
+    }
+
+    /**
+     * 根据红包ID查询红包领取记录
+     * @param $lm_id
+     * @param $page
+     * @param $limit
+     * @return mixed
+     */
+    public function getHisByLuckyMoneyId($lm_id, $page, $limit) {
+        $ret = $this
+            ->leftJoin('account', "{$this->table}.account_identity", '=', 'account.identity')
+            ->where($this->table . '.lm_id', $lm_id)
+            ->leftJoin('account_detailed', $this->table . '.account_identity', '=', 'account_detailed.account_identity')
+            ->orderBy($this->table . '.time', 'DESC')
+            ->limit($page * $limit, $limit)
+            ->select($this->table . '.money', $this->table . '.time', $this->table . '.room_id', 'account.account',
+                'account_detailed.img_url', 'account_detailed.img_id')
+            ->get()
+            ->toArray();
+        $myInfo = [];
+        if ($ret) {
+            $room_id = $ret[0]['room_id'];
+            $nickNames = (new Chat_rooms())->getNickNames($room_id);
+            $room_mangers_id = $nickNames['room_mangers_id'];
+            unset($nickNames['room_mangers_id']);
+            foreach ($ret as $k => $v) {
+                if ($v['account'] === $_SESSION['uinfo']['account']) {
+                    $myInfo['account'] = $v['account'];
+                    $myInfo['money'] = $v['money'];
+                }
+                if (isset($nickNames[$v['account']])) {
+                    $v['account'] = $nickNames[$v['account']];
+                } else {
+                    if(!in_array($_SESSION['uinfo']['account'],explode(',',$room_mangers_id))){
+                        $strHeader = substr($v['account'], 0, -4);
+                        $strEnd = substr($v['account'], -1);
+                        $v['account'] = $strHeader . '***' . $strEnd;
+                    }
+                    
+                }
+                $ret[$k] = $v;
+            }
+        }
+
+        return ['list' => $ret, 'myInfo' => (Object)$myInfo];
+    }
+}

+ 534 - 0
Application/Api/Model/MoneyBuy.php

@@ -0,0 +1,534 @@
+<?php
+/**
+ *------Create thems Model------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-12 05:08:18------
+ */
+namespace App\Api\Model;
+
+use \System\Model;
+use Biz\Account\AccountManager;
+
+class MoneyBuy extends Model {
+
+    protected $table = 'money_buy';
+
+    //晋级流水统计
+    function getstreamAmount($params=array(),$startime='',$endtime='')
+    {
+
+        if (empty($params['account_identity'])) {
+            return -51005;
+        }
+        $gradeinfo = lm('UserGrade', 'Api')->select('name', 'rule', 'rule_details')->where('grade', '=', 0)->first();
+        if (empty($gradeinfo)) {
+            return -5002;
+        }
+        $gradeinfo = $gradeinfo->toArray();
+        $gradeinfo['rule_details'] = explode(',', $gradeinfo['rule_details']);
+        $bet = lm('MoneyBuy', 'Api')->where('account_identity', $params['account_identity'])->where('status', '<', 4)->where('game_status', '>', 0);
+        $uservip = lm('User_vip', 'Api')->select('audittime')->where('account_identity', $params['account_identity'])->first();
+        if ($gradeinfo['rule_details'][0] == 'year') {
+            $startime = date('Y-01-01', time()) . ' 00:00:00';
+            $endtime = date('Y-12-31', time()) . ' 23:59:59';
+            $bet = $bet->where('money_time', '>=', $startime)->where('money_time', '<=', $endtime);
+        } elseif ($gradeinfo['rule_details'][0] == 'month') {
+            $startime = date('Y-m-01', strtotime(date('Y', time()) . '-' . (date('m', time()) - 1) . '-01')) . ' 00:00:00';
+            $endtime = date('Y-m-d', strtotime("$startime +1 month -1 day")) . ' 23:59:59';
+            $bet = $bet->where('money_time', '>=', $startime)->where('money_time', '<=', $endtime);
+        } elseif ($gradeinfo['rule_details'][0] == 'week') {
+            $now_day = date('W', time()) - 1;
+            $sunday_str = time() - $now_day * 60 * 60 * 24;
+            $sunday = date('Y-m-d 00:00:00', $sunday_str);
+            $strday_str = time() + (6 - $now_day) * 60 * 60 * 24;
+            $strday = date('Y-m-d 23:59:59', $strday_str);
+            $bet = $bet->where('money_time', '>=', $sunday)->where('money_time', '<=', $strday);
+        } elseif ($gradeinfo['rule_details'][0] == 'day') {
+            $firstday = date('Y-m-d 00:00:00', strtotime("-" . $gradeinfo['rule_details'][3] . " day"));
+            $bet = $bet->where('money_time', '>=', $firstday)->where('money_time', '<=', date('Y-m-d 23:59:59', strtotime('-1 day')));
+        } elseif ($gradeinfo['rule_details'][0] == 'ymd') {
+            $firstday = $gradeinfo['rule_details'][3] . ' 00:00:00';
+            $bet = $bet->where('money_time', '>=', $firstday);
+        }
+
+        if(!empty($uservip)){
+        		$bet = $uservip->audittime?$bet->where ('money_time', '>=', $uservip->audittime):$bet;
+        }
+        $bet=$startime?$bet->where ('money_time', '>=', $startime):$bet;
+        $bet=$endtime?$bet->where ('money_time', '<', $endtime):$bet;
+        $bet = $bet->sum('money');
+        return $bet;
+    }
+
+    /**
+     * 单式投注记录
+     *
+     * @access public
+     * @return String
+     */
+    public function singleBetRecord()
+    {
+        // 获取用户信息
+        $accountManagerClass = new AccountManager;
+        $userInfo = $accountManagerClass -> getCurrentUser();
+        if (empty($userInfo['identity'])) {
+            Render([], '2001', lang('Common','Api') -> get('user does login'));
+        }
+        // 用户ID
+        $moneyBuySpxWhere['account_identity'] = $userInfo['identity'];
+        // 时间区间
+        $startTime = isset($_POST['startTime'])? $_POST['startTime'] : '1900-01-01 00:00:00';
+        $endTime = isset($_POST['endTime'])? $_POST['endTime'] : '3000-12-12 00:00:00';
+        $moneyBuySpxBetween = ['money_time' => [$startTime, $endTime]];
+        $moneyBuySpxMdl = lm('money_buy_simplex', "commons");
+        // 获取订单记录
+        $moneyBuySpxSlt = ['batch_id', 'order_id'];
+        $getMoneyBuySpx = $moneyBuySpxMdl -> moneyBuySimplex($moneyBuySpxSlt, $moneyBuySpxWhere, $moneyBuySpxBetween, '', '', 1);
+        // 获取全部订单id
+        $moneyBuyMthOr = [];
+        $allBatchId = array_unique($getMoneyBuySpx, SORT_REGULAR);
+        if (!$allBatchId) {
+            // 获取记录总数
+            $result['total'] = 0;
+            $result['list'] = [];
+            // 总页数计算
+            $result['countPage'] = 1;
+            $result['currentPage'] = 1;
+
+            return $result;
+        }
+        foreach ($allBatchId as $key => $value) {
+            $moneyBuyMthOr[0][$key][0] = 'batch_id';
+            $moneyBuyMthOr[0][$key][1] = $value['batch_id'];
+        }
+        $moneyBuyMthWhere['bet_type'] = 1;
+        // 输赢
+        if (!empty($_POST['result']) && $_POST['result'] == 1) {
+            $moneyBuyMthOr[1][0][0] = 'result';
+            $moneyBuyMthOr[1][0][1] = 1;
+            $moneyBuyMthOr[1][1][0] = 'result';
+            $moneyBuyMthOr[1][1][1] = 3;
+            $moneyBuyMthOr[1][2][0] = 'result';
+            $moneyBuyMthOr[1][2][1] = 2;
+        } elseif (!empty($_POST['result']) && $_POST['result'] == 2) {
+            $moneyBuyMthOr[1][0][0] = 'result';
+            $moneyBuyMthOr[1][0][1] = -1;
+            $moneyBuyMthOr[1][1][0] = 'result';
+            $moneyBuyMthOr[1][1][1] = 4;
+        } elseif ($_POST['result'] === '0') {
+            $moneyBuyMthOr[1][0][0] = 'result';
+            $moneyBuyMthOr[1][0][1] = 0;
+        }
+        // 当前页
+        $currentPage = isset($_POST['currentPage']) ? $_POST['currentPage'] : "1";
+        // 分页大小
+        $pageSize = isset($_POST['pageSize']) ? $_POST['pageSize'] : "10";
+        // 起始查询位置
+        $begin = ($currentPage - 1) * $pageSize;
+        // 获取注单
+        $moneyBuyMthMdl = lm('Money_buy_match', "commons");
+        $moneyBuyMthSlt = ['status', 'bet_money', 'matchResult', 'result', 'home_team',  'batch_id', 'guest_team', 'condition', 'ctime', 'odds', 'odds_name', 'match_id', 'money_buy_match.game_code', 'money_buy_match.odds_code'];
+        $getMoneyBuyMth = $moneyBuyMthMdl -> moneyBuyMatch($moneyBuyMthSlt, $moneyBuyMthWhere, $moneyBuyMthOr, $begin, $pageSize);
+        $allCount = $moneyBuyMthMdl -> moneyBuyMatchTotal($moneyBuyMthWhere, $moneyBuyMthOr);
+        // 获取所有的比赛类型
+        $stGameTypeMdl = lm('StGameType', "commons");
+        $StGameTypeSlt = ['game_code'];
+        $StGameTypeWhr['status'] = 1;
+        $getStGameType = $stGameTypeMdl -> getGameType($StGameTypeSlt, $StGameTypeWhr);
+        $allMatch = [];
+        $allMatchInfo = [];
+        foreach ($getStGameType as $value) {
+            $allMatch[$value->game_code] = [];
+            $allMatchInfo[$value->game_code] = [];
+        }
+        // 循环获取所有的赛事ID
+        foreach ($getMoneyBuyMth as $value) {
+            $allMatch[$value->game_code][] = $value->match_id;
+        }
+        $stCompetitionMdl = lm('St_competition', "commons");
+        // 循环获取所有的赛事信息
+        foreach ($allMatch as $key => $value) {
+            $stCptWhrOr = array_unique($value);
+            $allMatchInfo[$key] = $stCompetitionMdl -> getMatch($key, $stCptWhrOr);
+        }
+        // 循环添加赛事时间
+        foreach ($getMoneyBuyMth as $k => $v) {
+            foreach ($allMatchInfo[$v->game_code] as $key => $value) {
+                if ($v->match_id == $value->id) {
+                    $getMoneyBuyMth[$k]->match_date = $value->match_date;
+                    $getMoneyBuyMth[$k]->match_time = $value->match_time;
+                    $getMoneyBuyMth[$k]->lg_name = $value->name_chinese;
+                }
+            }
+            foreach ($getMoneyBuySpx as $key => $value) {
+                if ($v->batch_id == $value['batch_id']) {
+                    $getMoneyBuyMth[$k]->order_id = $value['order_id'];
+                }
+            }
+        }
+        // 获取可加注所需要的查询条件
+        $commonFunction = C() -> get('commonFunction');
+        $stOddsWheres = [];
+        foreach ($getMoneyBuyMth as $key => $value) {
+            $match_id = $value -> match_id;
+            $odds_code = $value -> odds_code;
+            $gameType = $value -> game_code;
+            $where = [
+                'match_id' => $match_id,
+                'odds_code' => $odds_code,
+            ];
+            // 判断是否重复
+            if (!$commonFunction -> judgeEqual($where, $stOddsWheres[$gameType])) {
+                $stOddsWheres[$gameType][] = $where;
+            }
+        }
+        // 查询数据下所有可加注的游戏
+        $stOddsModel = lm('stOdds','commons');
+        $stOddsSelect = ['match_id', 'odds_code'];
+        $getSstOdds = [];
+        // 循环查询每个运动的可加注游戏  注:由于查询不同表所以必须循环查询
+        foreach ($stOddsWheres as $key => $value) {
+            if ($value) {
+                $getSstOdds[$key] = $stOddsModel -> stOdds($stOddsSelect, $value, $key);
+            }
+        }
+        // 循环添加玩法和判断玩法是否可加注
+        foreach ($getMoneyBuyMth as $key => $value) {
+            $getMoneyBuyMth[$key]->willMoney = $value->bet_money * $value->odds;
+            if ($value->result) {
+                switch (intval($value->result)) {
+                    case 1:
+                        $oddsDiscount = 1 + $value->odds;
+                        break;
+                    case 2:
+                        $oddsDiscount = 1;
+                        break;
+                    case 3:
+                        $oddsDiscount = 1 + $value->odds * 0.5;
+                        break;
+                    case 4:
+                        $oddsDiscount = 0.5;
+                        break;
+                    default:
+                        $oddsDiscount = 0;
+                }
+                $getMoneyBuyMth[$key]->winMoney = $value->bet_money * ($oddsDiscount - 1);
+            } else {
+                $getMoneyBuyMth[$key]->winMoney = 0;
+            }
+            $typeSstOdds = $getSstOdds[$value -> game_code];
+            $thisSstOdds = [
+                'match_id' => $value -> match_id,
+                'odds_code' => $value -> odds_code,
+            ];
+            // 判断如果在数组中则为可加注
+            if (!!$commonFunction->judgeEqual($thisSstOdds, $typeSstOdds)) {
+                $getMoneyBuyMth[$key] -> addBet = 0;
+            } else {
+                $getMoneyBuyMth[$key] -> addBet = 1;
+            }
+        }
+        // 获取记录总数
+        $result['total'] = $allCount;
+        $result['list'] = $getMoneyBuyMth;
+        // 总页数计算
+        $result['countPage'] = ceil($result['total'] / $pageSize);
+        $result['currentPage'] = $currentPage;
+
+        return $result;
+    }
+
+    /**
+     * 串式投注记录
+     *
+     * @access public
+     * @return String
+     */
+    public function stringBetRecord()
+    {
+        // 获取用户信息
+        $accountManagerClass = new AccountManager;
+        $userInfo = $accountManagerClass -> getCurrentUser();
+        if (empty($userInfo['identity'])) {
+            Render([], '2001', lang('Common','Api') -> get('user does login'));
+        }
+        // 用户ID
+        $moneyBuyStrWhere['account_identity'] = $userInfo['identity'];
+        // 输赢
+        if (!empty($_POST['result'])) {
+            $moneyBuyStrWhere['game_status'] = $_POST['result'];
+        }
+        // 时间区间
+        $startTime = isset($_POST['startTime'])? $_POST['startTime'] : '1900-01-01 00:00:00';
+        $endTime = isset($_POST['endTime'])? $_POST['endTime'] : '3000-12-12 00:00:00';
+        $moneyBuyStrBetween = ['money_time' => [$startTime, $endTime]];
+        $moneyBuyStrMdl = lm('money_buy_str', "commons");
+        // 当前页
+        $currentPage = isset($_POST['currentPage']) ? $_POST['currentPage'] : "1";
+        // 分页大小
+        $pageSize = isset($_POST['pageSize']) ? $_POST['pageSize'] : "10";
+        // 起始查询位置
+        $begin = ($currentPage - 1) * $pageSize;
+        // 获取订单记录
+        $moneyBuyStrSlt = ['order_id', 'batch_id', 'gain_money', 'game_status', 'money', 'prize_money', 'money_time'];
+        $getMoneyBuyStr = $moneyBuyStrMdl -> moneyBuyStr($moneyBuyStrSlt, $moneyBuyStrWhere, $moneyBuyStrBetween, $begin, $pageSize, 1);
+        $allCount = $moneyBuyStrMdl -> moneyBuyStrTotal($moneyBuyStrWhere, $moneyBuyStrBetween);
+        // 获取全部订单id
+        $moneyBuyMthOr = [];
+        $allBatchId = array_unique($getMoneyBuyStr, SORT_REGULAR);
+        if (!$allBatchId) {
+            // 获取记录总数
+            $result['total'] = 0;
+            $result['list'] = [];
+            // 总页数计算
+            $result['countPage'] = 1;
+            $result['currentPage'] = 1;
+
+            return $result;
+        }
+        foreach ($allBatchId as $key => $value) {
+            $moneyBuyMthOr[0][$key][0] = 'batch_id';
+            $moneyBuyMthOr[0][$key][1] = $value['batch_id'];
+        }
+        $moneyBuyMthWhere['bet_type'] = 2;
+        // 获取注单
+        $moneyBuyMthMdl = lm('Money_buy_match', "commons");
+        $moneyBuyMthSlt = ['status', 'matchResult', 'bet_money', 'home_team', 'guest_team', 'condition', 'odds', 'odds_name', 'match_id', 'batch_id', 'money_buy_match.game_code', 'money_buy_match.odds_code'];
+        $getMoneyBuyMth = $moneyBuyMthMdl -> moneyBuyMatch($moneyBuyMthSlt, $moneyBuyMthWhere, $moneyBuyMthOr, $begin, $pageSize);
+        // 获取所有的比赛类型
+        $stGameTypeMdl = lm('StGameType', "commons");
+        $StGameTypeSlt = ['game_code'];
+        $StGameTypeWhr['status'] = 1;
+        $getStGameType = $stGameTypeMdl -> getGameType($StGameTypeSlt, $StGameTypeWhr);
+        $allMatch = [];
+        $allMatchInfo = [];
+        foreach ($getStGameType as $value) {
+            $allMatch[$value->game_code] = [];
+            $allMatchInfo[$value->game_code] = [];
+        }
+        // 循环获取所有的赛事ID
+        foreach ($getMoneyBuyMth as $value) {
+            $allMatch[$value->game_code][] = $value->match_id;
+        }
+        $stCompetitionMdl = lm('St_competition', "commons");
+        // 循环获取所有的赛事信息
+        foreach ($allMatch as $key => $value) {
+            $stCptWhrOr = array_unique($value);
+            $allMatchInfo[$key] = $stCompetitionMdl -> getMatch($key, $stCptWhrOr);
+        }
+        // 循环添加赛事时间
+        foreach ($getMoneyBuyMth as $k => $v) {
+            foreach ($allMatchInfo[$v->game_code] as $key => $value) {
+                if ($v->match_id == $value->id) {
+                    $getMoneyBuyMth[$k]->match_date = $value->match_date;
+                    $getMoneyBuyMth[$k]->match_time = $value->match_time;
+                    $getMoneyBuyMth[$k]->lg_name = $value->name_chinese;
+                }
+            }
+        }
+        // 获取可加注所需要的查询条件
+        $commonFunction = C() -> get('commonFunction');
+        $stOddsWheres = [];
+        foreach ($getMoneyBuyMth as $key => $value) {
+            $match_id = $value -> match_id;
+            $odds_code = $value -> odds_code;
+            $gameType = $value -> game_code;
+            $where = [
+                'match_id' => $match_id,
+                'odds_code' => $odds_code,
+            ];
+            // 判断是否重复
+            if (!$commonFunction -> judgeEqual($where, $stOddsWheres[$gameType])) {
+                $stOddsWheres[$gameType][] = $where;
+            }
+        }
+        // 查询数据下所有可加注的游戏
+        $stOddsModel = lm('stOdds','commons');
+        $stOddsSelect = ['match_id', 'odds_code'];
+        $getSstOdds = [];
+        // 循环查询每个运动的可加注游戏  注:由于查询不同表所以必须循环查询
+        foreach ($stOddsWheres as $key => $value) {
+            if ($value) {
+                $getSstOdds[$key] = $stOddsModel -> stOdds($stOddsSelect, $value, $key);
+            }
+        }
+        // 循环添加玩法和判断玩法是否可加注
+        foreach ($getMoneyBuyMth as $key => $value) {
+            $typeSstOdds = $getSstOdds[$value -> game_code];
+            $thisSstOdds = [
+                'match_id' => $value -> match_id,
+                'odds_code' => $value -> odds_code,
+            ];
+            // 判断如果在数组中则为可加注
+            if (!!$commonFunction->judgeEqual($thisSstOdds, $typeSstOdds)) {
+                $getMoneyBuyMth[$key] -> addBet = 0;
+            } else {
+                $getMoneyBuyMth[$key] -> addBet = 1;
+            }
+        }
+        foreach ($getMoneyBuyStr as $key => $value) {
+            // 计算所赢金额.
+            if ($value->gain_money) {
+                $getMoneyBuyStr[$key]->winMoney = $value->gain_money - $value->money;
+            } else {
+                $getMoneyBuyStr[$key]->winMoney = 0;
+            }
+            foreach ($getMoneyBuyMth as $k => $v) {
+                if ($value['batch_id'] == $v['batch_id']) {
+                    $getMoneyBuyStr[$key]['money_buy'][] = $v;
+                }
+            }
+        }
+        // 获取记录总数
+        $result['total'] = $allCount;
+        $result['list'] = $getMoneyBuyStr;
+        // 总页数计算
+        $result['countPage'] = ceil($result['total'] / $pageSize);
+        $result['currentPage'] = $currentPage;
+
+        return $result;
+    }
+
+    /**
+     * 盈亏记录
+     *
+     * @access public
+     * @return String
+     */
+    public function moneyRecord()
+    {
+        // 获取用户信息
+        $accountManagerClass = new AccountManager;
+        $userInfo = $accountManagerClass -> getCurrentUser();
+        if (empty($userInfo['identity'])) {
+            Render([], '2001', lang('Common','Api') -> get('user does login'));
+        }
+        $moneyRecordWhere = array();
+        // 用户ID
+        $moneyRecordWhere['account_identity'] = $userInfo['identity'];
+        $moneyRecordWhere['status'] = 1;
+        $moneyRecordWhere['settle_status'] = 2;
+        if (empty($_POST['result']) === false) {
+            $moneyRecordWhere['game_status'] = empty($_POST['result']);
+        }
+        // 时间区间
+        $startTime = isset($_POST['startTime'])? $_POST['startTime'] : '1900-01-01 00:00:00';
+        $endTime = isset($_POST['endTime'])? $_POST['endTime'] : '3000-12-12 00:00:00';
+        $moneyRecordBetween = [$startTime, $endTime];
+        // 当前页
+        $currentPage = isset($_POST['currentPage']) ? $_POST['currentPage'] : "1";
+        // 分页大小
+        $pageSize = isset($_POST['pageSize']) ? $_POST['pageSize'] : "10";
+        // 起始查询位置
+        $begin = ($currentPage - 1) * $pageSize;
+        $moneyRecord = lm('Money_buy_simplex', "commons");
+        $moneyRecordSelect = ['info_identity', 'trade_id', 'account_identity', 'money', 'money_time', 'money_type'];
+        // 获取盈亏记录
+        $result['list'] = $moneyRecord -> winLoseRecord($moneyRecordWhere, $moneyRecordBetween, $begin, $pageSize);
+        // 获取记录总数
+        $result['total'] = $moneyRecord -> winLoseCount($moneyRecordWhere, $moneyRecordBetween);
+        // 总页数计算
+        $result['countPage'] = ceil($result['total'] / $pageSize);
+        $result['currentPage'] = $currentPage;
+
+        return $result;
+    }
+
+    /**
+     * 统计记录
+     *
+     * @access public
+     * @return String
+     */
+    public function monthRecord()
+    {
+        $accountManagerClass = new AccountManager;
+        $userInfo = $accountManagerClass -> getCurrentUser();
+        if (empty($userInfo['identity'])) {
+            Render([], '2001', lang('Common','Api') -> get('user does login'));
+        }
+        // 用户ID
+        $moneyBuyWhere['account_identity'] = $userInfo['identity'];
+        // 时间区间
+        $endTime = date('Y-m-d H:i:s');
+        if ($userInfo['statisticsTime']) {
+            $startTime = $userInfo['statisticsTime'];
+        } else {
+            $startTime = '1900-01-01 00:00:00';
+        }
+        $moneyBuyBetween = [$startTime, $endTime];
+        $moneyRecordWhere['settle_status'] = 2;
+        // 获取单式投注订单
+        $moneyBuySimplex = lm('money_buy_simplex', "commons");
+        $mnyBuySpxData = $moneyBuySimplex
+            ->select(['order_id', 'money', 'gain_money', 'batch_id'])
+            ->where($moneyBuyWhere)
+            ->whereBetween('settlementTime', $moneyBuyBetween)
+            ->get()
+            ->toArray();
+        // 获取全部订单id
+        $moneyBuyMthOr = [];
+        $allBatchId = array_unique($mnyBuySpxData, SORT_REGULAR);
+        if ($allBatchId) {
+            foreach ($allBatchId as $key => $value) {
+                $moneyBuyMthOr[0][$key][0] = 'batch_id';
+                $moneyBuyMthOr[0][$key][1] = $value['batch_id'];
+            }
+            $moneyBuyMthWhere['bet_type'] = 1;
+            // 获取注单
+            $moneyBuyMthMdl = lm('Money_buy_match', "commons");
+            $moneyBuyMthSlt = ['bet_money', 'odds', 'result'];
+            $getMoneyBuyMth = $moneyBuyMthMdl -> moneyBuyMatchAll($moneyBuyMthSlt, $moneyBuyMthWhere, $moneyBuyMthOr);
+        } else {
+            $getMoneyBuyMth = [];
+        }
+
+        // 获取串式投注订单
+        $moneyBuyStr = lm('money_buy_str', "commons");
+        $mnyBuyStrData = $moneyBuyStr
+            ->select(['order_id', 'money', 'gain_money'])
+            ->where($moneyBuyWhere)
+            ->whereBetween('settlementTime', $moneyBuyBetween)
+            ->get();
+        $winMoney = $userInfo['allWin'];
+        $loseMoney = $userInfo['allLose'];
+        // 单式盈利.
+        foreach ($getMoneyBuyMth as $key => $value) {
+            // 判断订单是否盈利
+            if ($value->result == 1) {
+                $winMoney += $value->bet_money * $value->odds;
+            } else if ($value->result == 3) {
+                $winMoney += $value->bet_money * $value->odds * 0.5;
+            } else if ($value->result == 4) {
+                $loseMoney += $value->bet_money * 0.5;
+            } else if ($value->result == -1) {
+                $loseMoney += $value->bet_money;
+            }
+        }
+        // 串式盈利.
+        foreach ($mnyBuyStrData as $key => $value) {
+            // 判断订单是否盈利
+            if ($value->money >= $value->gain_money) {
+                $loseMoney += $value->money - $value->gain_money;   //本钱减回款
+            } else {
+                $winMoney += $value->gain_money - $value->money;    //回款减本钱
+            }
+        }
+        // 修改用户统计
+        $updateActDtd = [
+          'allWin' => $winMoney,
+          'allLose' => $loseMoney,
+          'statisticsTime' => date('Y-m-d H:i:s'),
+        ];
+        $accountDetailed = lm('account_detailed', "commons");
+        $accountDetailed->where(['account_identity'=>$userInfo['identity']])->update($updateActDtd);
+        $result = [
+            'winMoney' => $winMoney ?? 0,
+            'loseMoney' => $loseMoney ?? 0,
+            'allMoney' => $userInfo['available_cash'],
+        ];
+
+        return $result;
+    }
+}

+ 16 - 0
Application/Api/Model/MoneyBuyDetail.php

@@ -0,0 +1,16 @@
+<?php
+/**
+ *------Create thems Model------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-12 05:08:18------
+ */
+namespace App\Api\Model;
+
+use \System\Model;
+use Biz\Account\AccountManager;
+
+class MoneyBuyDetail extends Model {
+
+    protected $table = 'money_buy_detail';
+}

+ 16 - 0
Application/Api/Model/MoneyBuyMatch.php

@@ -0,0 +1,16 @@
+<?php
+/**
+ *------Create thems Model------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-12 05:08:18------
+ */
+namespace App\Api\Model;
+
+use \System\Model;
+use Biz\Account\AccountManager;
+
+class MoneyBuyMatch extends Model {
+
+    protected $table = 'money_buy_match';
+}

+ 16 - 0
Application/Api/Model/MoneyBuySimplex.php

@@ -0,0 +1,16 @@
+<?php
+/**
+ *------Create thems Model------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-12 05:08:18------
+ */
+namespace App\Api\Model;
+
+use \System\Model;
+use Biz\Account\AccountManager;
+
+class MoneyBuySimplex extends Model {
+
+    protected $table = 'money_buy_simplex';
+}

+ 16 - 0
Application/Api/Model/MoneyBuyStr.php

@@ -0,0 +1,16 @@
+<?php
+/**
+ *------Create thems Model------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-12 05:08:18------
+ */
+namespace App\Api\Model;
+
+use \System\Model;
+use Biz\Account\AccountManager;
+
+class MoneyBuyStr extends Model {
+
+    protected $table = 'money_buy_str';
+}

+ 14 - 0
Application/Api/Model/MoneyCount.php

@@ -0,0 +1,14 @@
+<?php
+/**
+ *------Create thems Model------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-12 05:08:18------
+ */
+namespace App\Api\Model;
+use \System\Model;
+
+class MoneyCount extends Model {
+
+    protected $table = 'money_count';
+}

+ 14 - 0
Application/Api/Model/MoneyDetails.php

@@ -0,0 +1,14 @@
+<?php
+/**
+ *------Create thems Model------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-12 05:08:18------
+ */
+namespace App\Api\Model;
+use \System\Model;
+
+class MoneyDetails extends Model {
+
+    protected $table = 'money_details';
+}

+ 16 - 0
Application/Api/Model/MoneyFlowCount.php

@@ -0,0 +1,16 @@
+<?php
+    /**
+     * Created by PhpStorm.
+     * User: blues
+     * Date: 2019/1/2
+     * Time: 16:56
+     */
+
+    namespace App\Api\Model;
+    use \System\Model;
+
+    class MoneyFlowCount extends Model
+    {
+        public $timestamps = false;
+        protected $table = 'money_flow_count';
+    }

+ 54 - 0
Application/Api/Model/MoneyPrize.php

@@ -0,0 +1,54 @@
+<?php
+/**
+ *------Create thems Model------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-12 05:08:18------
+ */
+namespace App\Api\Model;
+
+use \System\Model;
+use Biz\Account\AccountManager;
+
+class MoneyPrize extends Model {
+    /**
+     * 中奖记录
+     *
+     * @access public
+     * @return String
+     */
+    public function prizeRecord()
+    {
+        // 获取用户信息
+        $accountManagerClass = new AccountManager;
+        $userInfo = $accountManagerClass -> getCurrentUser();
+        if (empty($userInfo['identity'])) {
+            Render([], '2001', lang('Common','Api') -> get('user does login'));
+        }
+        $prizeRecordWhere = array();
+        // 用户ID
+        $prizeRecordWhere['account_identity'] = $userInfo['identity'];
+        $prizeRecordWhere['status'] = 1;
+        // 时间区间
+        $startTime = isset($_POST['startTime'])? $_POST['startTime'] : '1900-01-01 00:00:00';
+        $endTime = isset($_POST['endTime'])? $_POST['endTime'] : '3000-12-12 00:00:00';
+        $prizeRecordBetween = [$startTime, $endTime];
+        // 当前页
+        $currentPage = isset($_POST['currentPage']) ? $_POST['currentPage'] : "1";
+        // 分页大小
+        $pageSize = isset($_POST['pageSize']) ? $_POST['pageSize'] : "10";
+        // 起始查询位置
+        $begin = ($currentPage - 1) * $pageSize;
+        $prizeRecord = lm('money_prize', "commons");
+        //$prizeRecordSelect = ['info_identity', 'trade_id', 'account_identity', 'money', 'money_time', 'money_type'];
+        // 获取盈亏记录
+        $result['list'] = $prizeRecord -> prizeRecord($prizeRecordWhere, $prizeRecordBetween, $begin, $pageSize);
+        // 获取记录总数
+        $result['total'] = $prizeRecord -> prizeRecordTotal($prizeRecordWhere, $prizeRecordBetween);
+        // 总页数计算
+        $result['countPage'] = ceil($result['total'] / $pageSize);
+        $result['currentPage'] = $currentPage;
+
+        return $result;
+    }
+}

+ 151 - 0
Application/Api/Model/MoneyRecharge.php

@@ -0,0 +1,151 @@
+<?php
+/**
+ *------Create thems Model------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-12 05:08:18------
+ */
+namespace App\Api\Model;
+use \System\Model;
+use Biz\Account\AccountManager;
+
+class MoneyRecharge extends Model {
+
+    protected $table = 'money_recharge';
+
+    //晋级充值统计
+
+    /**
+     * @param array $params
+     * @param $time 上传统计时间
+     * @return int
+     */
+    function getPromotionAmount($params=array(),$time=''){
+    	if(empty($params['account_identity'])){
+    		return -51005;
+    	}
+    	$gradeinfo = lm ('UserGrade', 'Api')->select('name', 'rule', 'rule_details')->where('grade', '=', 0)->first();
+        if (empty($gradeinfo)) {
+            return -5002;
+        }
+        $gradeinfo = $gradeinfo->toArray();
+        $gradeinfo['rule_details'] = explode (',', $gradeinfo['rule_details']);
+        $save = lm ('MoneyRecharge', 'Api')->where ('account_identity', $params['account_identity'])->whereIn ('recharge_type', ['汇款','后台充值','在线充值'])->where ('status', 1);
+        $uservip = lm('User_vip', 'Api')->select('audittime')->where('account_identity', $params['account_identity'])->first();
+        if ($gradeinfo['rule_details'][0] == 'year') {
+        	$startime = date ('Y-01-01', time ()) . ' 00:00:00';
+            $endtime = date ('Y-12-31', time ()) . ' 23:59:59';
+            $save = $save->where ('complete_time', '>=', $startime)->where ('complete_time', '<=', $endtime);
+        }elseif ($gradeinfo['rule_details'][0] == 'month') {
+        	$startime = date ('Y-m-01', strtotime (date ('Y', time ()) . '-' . (date ('m', time ()) - 1) . '-01')) . ' 00:00:00';
+            $endtime = date ('Y-m-d', strtotime ("$startime +1 month -1 day")) . ' 23:59:59';
+            $save = $save->where ('complete_time', '>=', $startime)->where ('complete_time', '<=', $endtime);
+        }elseif ($gradeinfo['rule_details'][0] == 'week') {
+        	$now_day = date ('W', time ()) - 1;
+            $sunday_str = time () - $now_day * 60 * 60 * 24;
+            $sunday = date ('Y-m-d 00:00:00', $sunday_str);
+            $strday_str = time () + (6 - $now_day) * 60 * 60 * 24;
+            $strday = date ('Y-m-d 23:59:59', $strday_str);
+            $save = $save->where ('complete_time', '>=', $sunday)->where ('complete_time', '<=', $strday);
+        }elseif ($gradeinfo['rule_details'][0] == 'day') {
+        	$firstday = date ('Y-m-d 00:00:00', strtotime ("-" . $gradeinfo['rule_details'][3] . " day"));
+            $save = $save->where ('complete_time', '>=', $firstday)->where ('complete_time', '<=', date ('Y-m-d 23:59:59', strtotime ('-1 day')));
+        }elseif ($gradeinfo['rule_details'][0] == 'ymd') {
+        	$firstday = $gradeinfo['rule_details'][3] . ' 00:00:00';
+            $save = $save->where ('complete_time', '>=', $firstday);
+        }
+
+        if(!empty($uservip)){
+            $uservip = $uservip->toArray();
+            if(!empty($uservip['audittime'])){
+                $save = $save->where ('complete_time', '>=', $uservip['audittime']);
+            }
+        }
+        $save=$time?$save->where ('complete_time', '>', $time):$save;
+        $save = $save->sum ('money');
+
+        return $save;
+    }
+
+    /**
+     * 充值记录
+     *
+     * @access public
+     * @return String
+     */
+    public function rechargeRecord()
+    {
+        // 获取用户信息
+        $accountManagerClass = new AccountManager;
+        $userInfo = $accountManagerClass -> getCurrentUser();
+        if (empty($userInfo['identity'])) {
+            Render([], '2001', lang('Common','Api') -> get('user does login'));
+        }
+        $rechargeRecordWhere = array();
+        // 用户ID
+        $rechargeRecordWhere['account_identity'] = $userInfo['identity'];
+        $rechargeRecordWhere['status'] = 1;
+        // 时间区间
+        $startTime = isset($_POST['startTime'])? $_POST['startTime'] : '1900-01-01 00:00:00';
+        $endTime = isset($_POST['endTime'])? $_POST['endTime'] : '3000-12-12 00:00:00';
+        $rechargeRecordBetween = [$startTime, $endTime];
+        // 当前页
+        $currentPage = isset($_POST['currentPage']) ? $_POST['currentPage'] : "1";
+        // 分页大小
+        $pageSize = isset($_POST['pageSize']) ? $_POST['pageSize'] : "10";
+        // 起始查询位置
+        $begin = ($currentPage - 1) * $pageSize;
+        $rechargeRecord = lm('money_recharge', "commons");
+        $rechargeRecordSelect = ['id', 'info_identity', 'order_id', 'apply_time', 'money', 'recharge_type', 'money_cash'];
+        // 获取盈亏记录
+        $result['list'] = $rechargeRecord -> rechargeRecord($rechargeRecordSelect, $rechargeRecordWhere, $rechargeRecordBetween, $begin, $pageSize);
+        // 获取记录总数
+        $result['total'] = $rechargeRecord -> rechargeRecordTotal($rechargeRecordWhere, $rechargeRecordBetween);
+        // 总页数计算
+        $result['countPage'] = ceil($result['total'] / $pageSize);
+        $result['currentPage'] = $currentPage;
+
+        return $result;
+    }
+
+    /**
+     * 取款记录
+     *
+     * @access public
+     * @return String
+     */
+    public function moneyOutRecord()
+    {
+        // 获取用户信息
+        $accountManagerClass = new AccountManager;
+        $userInfo = $accountManagerClass -> getCurrentUser();
+        if (empty($userInfo['identity'])) {
+            Render([], '2001', lang('Common','Api') -> get('user does login'));
+        }
+        $moneyTakeWhere = array();
+        // 用户ID
+        $moneyTakeWhere['account_identity'] = $userInfo['identity'];
+        // 时间区间
+        $startTime = isset($_POST['startTime'])? $_POST['startTime'] : '1900-01-01 00:00:00';
+        $endTime = isset($_POST['endTime'])? $_POST['endTime'] : '3000-12-12 00:00:00';
+        $moneyTakeBetween = ['apply_time' => [$startTime, $endTime]];
+        // 当前页
+        $currentPage = isset($_POST['currentPage']) ? $_POST['currentPage'] : "1";
+        // 分页大小
+        $pageSize = isset($_POST['pageSize']) ? $_POST['pageSize'] : "10";
+        // 起始查询位置
+        $begin = ($currentPage - 1) * $pageSize;
+        $moneyTake = lm('Money_take', "commons");
+        $moneyTakeSelect = ['id', 'account_name', 'money', 'apply_time', 'pass_time', 'give_time', 'bank_no', 'bank_info', 'status', 'money_cash'];
+        // 获取提款记录
+        $result['list'] = $moneyTake -> moneyTake($moneyTakeSelect, $moneyTakeWhere, $moneyTakeBetween, $begin, $pageSize);
+        // 获取记录总数
+        $result['total'] = $moneyTake -> moneyTakeTotal($moneyTakeWhere, $moneyTakeBetween);
+        // 总页数计算
+        $result['countPage'] = ceil($result['total'] / $pageSize);
+        $result['currentPage'] = $currentPage;
+
+        return $result;
+    }
+
+}

+ 14 - 0
Application/Api/Model/MoneyRechargeRemark.php

@@ -0,0 +1,14 @@
+<?php
+/**
+ *------Create thems Model------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-12 05:08:18------
+ */
+namespace App\Api\Model;
+use \System\Model;
+
+class MoneyRechargeRemark extends Model {
+
+    protected $table = 'money_recharge_remark';
+}

+ 14 - 0
Application/Api/Model/Payment.php

@@ -0,0 +1,14 @@
+<?php
+/**
+*------Create thems Model------
+*------SCWPHP  Version 1.0.0------
+*------Dev Model Jions------
+*------Create Time 2017-06-28 06:26:31------
+*/
+namespace App\Api\Model;
+use \System\Model;
+class Payment extends Model {
+
+public $timestamps = false;
+protected $table = 'payment';
+}

+ 14 - 0
Application/Api/Model/SetInfo.php

@@ -0,0 +1,14 @@
+<?php
+/**
+ *------Create thems Model------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-12 05:08:18------
+ */
+namespace App\Api\Model;
+use \System\Model;
+
+class SetInfo extends Model {
+
+	protected $table = 'setinfo';
+}

+ 65 - 0
Application/Api/Model/SixmoneyBuy.php

@@ -0,0 +1,65 @@
+<?php
+/**
+ *------Create thems Model------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-12 05:08:18------
+ */
+namespace App\Api\Model;
+use \System\Model;
+
+class SixmoneyBuy extends Model {
+
+    protected $table = 'sixmoney_buy';
+
+    //晋级流水统计
+    function getsixstreamAmount($params=array(),$startime='',$endtime=''){
+    	if(empty($params['account_identity'])){
+    		return -51005;
+    	}
+    	$gradeinfo = lm ('UserGrade', 'Api')->select('name', 'rule', 'rule_details')->where('grade', '=', 0)->first();
+        if (empty($gradeinfo)) {
+            return -5002;
+        }
+        $gradeinfo = $gradeinfo->toArray();
+        $gradeinfo['rule_details'] = explode (',', $gradeinfo['rule_details']);
+        $sixbet = lm ('SixmoneyBuy', 'Api')->where ('account_identity', $params['account_identity'])->where ('status', '<', 4)->where ('game_status', '>', 0);
+        $uservip = lm ('User_vip', 'Api')->select('audittime')->where('account_identity',$params['account_identity'])->first();
+        if ($gradeinfo['rule_details'][0] == 'year') {
+        	$startime = date ('Y-01-01', time ()) . ' 00:00:00';
+            $endtime = date ('Y-12-31', time ()) . ' 23:59:59';
+            $sixbet = $sixbet->where ('money_time', '>=', $startime)->where ('money_time', '<=', $endtime);
+        }elseif ($gradeinfo['rule_details'][0] == 'month') {
+        	$startime = date ('Y-m-01', strtotime (date ('Y', time ()) . '-' . (date ('m', time ()) - 1) . '-01')) . ' 00:00:00';
+            $endtime = date ('Y-m-d', strtotime ("$startime +1 month -1 day")) . ' 23:59:59';
+            $sixbet = $sixbet->where ('money_time', '>=', $startime)->where ('money_time', '<=', $endtime);
+        }elseif ($gradeinfo['rule_details'][0] == 'week') {
+        	$now_day = date ('W', time ()) - 1;
+            $sunday_str = time () - $now_day * 60 * 60 * 24;
+            $sunday = date ('Y-m-d 00:00:00', $sunday_str);
+            $strday_str = time () + (6 - $now_day) * 60 * 60 * 24;
+            $strday = date ('Y-m-d 23:59:59', $strday_str);
+            $sixbet = $sixbet->where ('money_time', '>=', $sunday)->where ('money_time', '<=', $strday);
+        }elseif ($gradeinfo['rule_details'][0] == 'day') {
+        	$firstday = date ('Y-m-d 00:00:00', strtotime ("-" . $gradeinfo['rule_details'][3] . " day"));
+            $sixbet = $sixbet->where ('money_time', '>=', $firstday)->where ('money_time', '<=', date ('Y-m-d 23:59:59', strtotime ('-1 day')));
+        }elseif ($gradeinfo['rule_details'][0] == 'ymd') {
+        	$firstday = $gradeinfo['rule_details'][3] . ' 00:00:00';
+            $sixbet = $sixbet->where ('money_time', '>=', $firstday);
+        }
+        if(!empty($uservip)){
+        	$uservip = $uservip->toArray();
+        	if(!empty($uservip['audittime'])){
+
+        		$sixbet = $sixbet->where ('money_time', '>=', $uservip['audittime']);
+
+        	}
+        }
+        $sixbet=$startime?$sixbet->where ('money_time', '>=', $startime):$sixbet;
+        $sixbet=$endtime?$sixbet->where ('money_time', '<', $endtime):$sixbet;
+        $sixbet = $sixbet->sum ('money');
+
+        return $sixbet;
+
+    }
+}

+ 15 - 0
Application/Api/Model/St_bet_order.php

@@ -0,0 +1,15 @@
+<?php
+namespace App\Sports\Model;
+
+use \System\Model;
+
+/**
+ * Class St_country
+ * @package App\Sports\Model
+ * 地区 洲
+ */
+class St_bet_order extends Model
+{
+
+    protected $table = 'st_bet_order';
+}

+ 21 - 0
Application/Api/Model/St_odds_code.php

@@ -0,0 +1,21 @@
+<?php
+namespace App\Api\Model;
+
+use \System\Model;
+
+/**
+ * Class Account
+ * @package App\Sports\Model
+ * 用户账号
+ */
+class St_odds_code extends Model
+{
+
+    protected $table = 'st_odds_code';
+
+    //获取赔率代码是否存在
+    public static function getOddsCode($odds_code,$game_code){
+        $odds_code = self::where(['odds_code'=>$odds_code,'game_code'=>$game_code])->count();
+        return $odds_code;
+    }
+}

+ 16 - 0
Application/Api/Model/SystemAppupdate.php

@@ -0,0 +1,16 @@
+<?php
+    /**
+     * Created by PhpStorm.
+     * User: Lenovo
+     * Date: 2018/10/30
+     * Time: 15:09
+     */
+
+    namespace App\Api\Model;
+
+    use \System\Model;
+    class SystemAppupdate extends  Model
+    {
+        protected $table = 'system_appupdate';
+
+    }

+ 19 - 0
Application/Api/Model/SystemRed.php

@@ -0,0 +1,19 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Lenovo
+ * Date: 2019/1/21
+ * Time: 14:23
+ */
+namespace App\Api\Model;
+use \System\Model;
+class SystemRed extends Model
+{
+    protected $table = 'system_red';
+    public $incrementing = false;
+
+    public function getRedInfo()
+    {
+        return $this->where('status',1)->get();
+    }
+}

+ 14 - 0
Application/Api/Model/System_routes.php

@@ -0,0 +1,14 @@
+<?php
+/**
+ *------Create thems Model------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-12 05:08:18------
+ */
+namespace App\Api\Model;
+use \System\Model;
+
+class System_routes extends Model
+{
+    protected $table = 'system_routes';
+}

+ 14 - 0
Application/Api/Model/System_routes_category.php

@@ -0,0 +1,14 @@
+<?php
+/**
+ *------Create thems Model------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-12 05:08:18------
+ */
+namespace App\Api\Model;
+use \System\Model;
+
+class System_routes_category extends Model
+{
+    protected $table = 'system_routes_category';
+}

+ 293 - 0
Application/Api/Model/UserGrade.php

@@ -0,0 +1,293 @@
+<?php
+/**
+ *------Create thems Model------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-12 05:08:18------
+ */
+namespace App\Api\Model;
+use App\Api\Controller\Nologin;
+use \System\Model;
+
+class UserGrade extends Model {
+
+    protected $table = 'dc_user_grade';
+
+    //晋级等级
+    function upgrade($todata, $totol_Money=0){
+
+    	if (empty($todata)) {
+            return '-50003';
+        }
+    	$result['data'] = $todata;
+    	if ($result['data']['grade'] == 0 || $result['data']['grade'] == -1) {
+            return '-50019';
+        }
+    	//查询等级规则
+        $gradelist = lm ('UserGrade', 'Api')->select ('name', 'rule','grade', 'rule_details')->orderBy ('grade', 'asc')->get ();
+
+        if (!count($gradelist)) {
+            return '-5002';
+        }
+        $nextgradeinfo  =   $gradelist[0];
+
+        $gradelist = $gradelist->toArray ();
+        $nextgradeinfo = $nextgradeinfo->toArray ();
+        $nextgradeinfo['rule_details'] = explode (',', $nextgradeinfo['rule_details']);
+        $rule_details = $nextgradeinfo['rule_details'];
+        //查询统计数据
+        $params['account_identity'] = $result['data']['account_identity'];
+        $total  =   0;
+        $save = lm ('MoneyRecharge', 'Api')->getPromotionAmount($params);
+        if(!$totol_Money){
+
+            $sixbet = lm ('SixmoneyBuy', 'Api')->getsixstreamAmount($params);
+            $bet = lm ('MoneyBuy', 'Api')->getstreamAmount($params);
+            $zheren =   (new Nologin())->totalUserStatistics($params['account_identity'],'2018-01-01 00:00:00');
+            $total = $bet + $sixbet+$zheren;
+        }else{
+                $total= $totol_Money  ;
+        }
+
+        $newgrade = 0;
+        $gradename = array();
+        foreach ($gradelist as $key => $value) {
+            $rule_details = explode (',', $value['rule_details']);
+
+            if ($save >= $rule_details[1] && $total >= $rule_details[2]) {
+                $newgrade = $value['grade'];
+
+
+            }
+            $gradename[$value['grade']] = $value['name'];
+        }
+
+        if ($newgrade > 0 && $newgrade > $result['data']['grade']) {
+
+            $res = lm ('AccountDetail', 'Api')->where ('account_identity', $result['data']['account_identity'])->update (['grade' => $newgrade]);
+
+            if ($res) {
+                $remark['original_grade'] = $gradename[$result['data']['grade']];
+                $remark['present_grade'] = $gradename[$newgrade];
+                $remark['newgrade'] = $newgrade;
+                $remark['oldgrade'] = $result['data']['grade'];
+                $remark['type'] = $nextgradeinfo['rule_details'][0];
+                $remark['save'] = $save;
+                $remark['bet'] = $bet + $sixbet;
+                $data['account_identity'] = $result['data']['account_identity'];
+                $data['remark'] = json_encode ($remark);
+                $data['account_name'] = $result['data']['account'];
+                $data['type'] = 'promotion';
+                $data['create_time'] = date ('Y-m-d H:i:s');
+                lm ('User_log_record', 'Api')->insert ($data);
+                $Promotiong = lm ('lottery_money', 'Api')->where ('type','upgrade')->first ();
+                if(!empty($Promotiong)){
+                    $Promotiong = $Promotiong->toArray();
+                    $conent = json_decode ($Promotiong['conent']);
+                    if ($conent->setup == 2) {
+                        $this->gold ($todata,$Promotiong['id']);
+                    }
+                }
+                return 1;
+            } else {
+                return '-5007';
+            }
+        } else {
+            return '-5003';
+        }
+    }
+
+    //晋级彩金
+    function gold($todata,$id){
+
+    	if (empty($todata)) {
+            return '-50003';
+        }
+    	$result['data'] = $todata;
+    	if ($result['data']['grade'] == 0 || $result['data']['grade'] == -1) {
+            return '-50019';
+        }
+
+    	$userinfo = $todata;
+        $wherel['type'] = 'upgrade';
+        $wherel['id'] = $id;
+        $Promotiong = lm ('lottery_money', 'Api')->where ($wherel)->first ();
+        if (empty($Promotiong)) {
+            return -50010;
+        }
+        $Promotiong = $Promotiong->toArray ();
+        $conent = json_decode ($Promotiong['conent']);
+        $gradeinfo = lm ('UserGrade', 'Api')->select ('name', 'rule', 'rule_details')->where ('grade', $userinfo['grade'])->first ();
+        if (empty($gradeinfo)) {
+            return -50013;
+        }
+        $gradelist = lm ('UserGrade', 'Api')->select ('name','grade')->orderBy ('grade', 'asc')->get ();
+        if (!count($gradelist)) {
+            return '-5002';
+        }
+        $gradelist = $gradelist->toArray ();
+        $gradename = array();
+        foreach ($gradelist as $key => $value) {
+            $gradename[$value['grade']] = $value['name'];
+        }
+        $gradeinfo = $gradeinfo->toArray ();
+        $gradeinfo['rule_details'] = explode (',', $gradeinfo['rule_details']);
+        $amount = 0;
+        $grade = $conent->grade;
+
+        if (empty($grade)) {
+            return -50014;
+        }
+
+        foreach ($grade as $key => $value) {
+            $gra[$key] = $value;
+        }
+        if ($conent->give_type == 'pre') {
+            $amount = $gradeinfo['rule_details'][2] * $gra[$userinfo['grade']];
+        } else {
+            if (!isset($gra[$userinfo['grade']])) Render ('', "-50014");
+            $amount = $gra[$userinfo['grade']];
+        }
+
+        $where['type'] = 'promotion';
+        $where['account_identity'] = $result['data']['account_identity'];
+        $tograde = lm ('User_log_record', 'Api')->where ($where)->get ();
+        $status = 0;
+        if (!count($tograde)) {
+            return -50013;
+        }
+
+        $tograde = $tograde->toArray ();
+
+        $newremark = array();
+        foreach ($tograde as $key => $value) {
+            $remark = json_decode ($value['remark'], true);
+            if ($remark['newgrade'] == $userinfo['grade']) {
+                $status = 1;
+                if (!empty($remark['oldgrade'])) {
+                    $original_grade = $remark['oldgrade'];
+                } else {
+                    $original_grade = 0;
+                }
+
+                if ($conent->setup == 2) {
+                    $remark['operator'] = 'system';
+                    $remark['update_time'] = date ('Y-m-d H:i:s');
+                }
+
+                $newremark = $remark;
+
+            }else{
+                $original_grade = 0;
+            }
+        }
+        $originalgradeinfo = lm ('UserGrade', 'Api')->select ('name')->where ('grade', $original_grade)->first ();
+        if(!empty($originalgradeinfo)){
+            $originalgradeinfo = $originalgradeinfo->toArray();
+        }else{
+            $originalgradeinfo['name'] = $original_grade;
+        }
+
+        if ($status == 1) {
+            $wheretwo['account_identity'] = $result['data']['account_identity'];
+            $wheretwo['grade'] = $userinfo['grade'];
+            $wheretwo['lottery_money_type'] = $Promotiong['type'];
+            $num = lm ('lottery_money_log', 'Api')->where ($wheretwo)->count ();
+            if ($num == 0) {
+                if ($amount > 0) {
+                    $data['account_identity'] = $result['data']['account_identity'];
+                    $data['grade'] = $userinfo['grade'];
+                    $data['lottery_money_type'] = $Promotiong['type'];
+                    $data['lottery_money_id'] = $Promotiong['id'];
+                    $data['lottery_money_name'] = $Promotiong['name'];
+                    $data['money'] = $amount;
+                    $data['create_time'] = date ('Y-m-d H:i:s');
+                    if ($conent->setup == 2) {
+                        $data['status'] = 1;
+                        $data['operator'] = 'system';
+                        //$setupname = '自动计算';
+                    } else {
+                        $data['status'] = 0;
+                        //$setupname = '手动计算';
+                    }
+                    $data['account_name'] = $result['data']['account'];
+
+                    $data['operator_id'] = 0;
+                    $data['detail'] = sprintf (lang('Userup', 'Api')->get ('promotion'), $result['data']['account'], $gradename[$original_grade], $gradename[$userinfo['grade']], $amount);
+                    $data['flow_record'] = json_encode ($newremark);
+                    if ($conent->setup == 2) {
+                        $recharge['info_identity'] = UUID ();
+                        $recharge['order_id'] = OrderID ();
+                        $recharge['apply_time'] = date ('Y-m-d H:i:s');
+                        $recharge['complete_time'] = date ('Y-m-d H:i:s');
+                        $recharge['money'] = $amount;
+                        $recharge['account_identity'] = $result['data']['account_identity'];
+                        $recharge['account_name'] = $result['data']['account'];
+                        $recharge['status'] = 1;
+                        $recharge['recharge_type'] = '活动充值';
+                        $recharge['sysetem_user'] = 'system';
+                        $recharge['reason'] = '用于活动';
+                        $recharge['money_cash'] = $amount + $result['data']['cash'];
+                        $recharge['remark'] = sprintf (lang('Userup', 'Api')->get ('promotion'), $result['data']['account'], $gradename[$original_grade], $gradename[$userinfo['grade']], $amount);
+
+                        $rechargeremark['order_id'] = $recharge['order_id'];
+                        $rechargeremark['name'] = $result['data']['account'];
+                        $rechargeremark['recharge_time'] = date ('Y-m-d H:i:s');
+                        $rechargeremark['money'] = $recharge['money'];
+                        $rechargeremark['remark'] = sprintf (lang('Userup', 'Api')->get ('promotion'), $result['data']['account'], $gradename[$original_grade], $gradename[$userinfo['grade']], $amount);
+
+                        $details['info_identity'] = UUID ();
+                        $details['trade_id'] = OrderID ();
+                        $details['account_name'] = $result['data']['account'];
+                        $details['account_identity'] = $result['data']['account_identity'];
+                        $details['money'] = $amount;
+                        $details['money_time'] = date ('Y-m-d H:i:s');
+                        $details['money_type'] = 1;
+                        $details['money_cash'] = $amount + $result['data']['cash'];
+                        $details['trade_type'] = 12;
+                        $details['trade_desc'] = sprintf (lang('Userup', 'Api')->get ('promotion'), $result['data']['account'], $gradename[$original_grade], $gradename[$userinfo['grade']], $amount);
+                        $details['sysetem_user'] = '系统';
+                        $details['status'] = 1;
+                        $mess['title'] = '申领彩金提醒';
+                        $mess['content'] = '恭喜'.$result['data']['account'].'您从'.$originalgradeinfo['name'].'升级到'.$gradeinfo['name'].',通过VIP晋级彩金活动申请的彩金'.$amount.'已到账,请查收!';
+                        $mess['type'] = '1';
+                        $mess['formname'] = '系统通知';
+                        $mess['toname'] = $result['data']['account'];
+                        $mess['add_time'] = date('Y-m-d H:i:s');
+                        $mess['add_status'] = '2';
+                        $MoneyQuery = new \Biz\Money\MoneyQuery;
+                        $MoneyHandle = new \Biz\Money\MoneyHandle;
+                        $MoneyQuery->recordWithdraw (1, $result['data']['account_identity'], 0, $amount, $conent->multiple);
+                        lm ('MoneyRecharge', 'Api')->insert ($recharge);
+                        lm ('MoneyDetails', 'Api')->insert ($details);
+                        lm ('MoneyRechargeRemark', 'Api')->insert ($rechargeremark);
+                        lm("message",'commons')->insert($mess);
+                        try {
+                            $re = $MoneyHandle->updateAccountMoney ($result['data']['account_identity'], $amount, 1);
+                            if ($re < 0) {
+                                _rollBack ();
+                            }
+                        } catch (PDOException $e) {
+                            _rollBack ();
+                        }
+                    }
+                    $res = lm ('lottery_money_log', 'Api')->insert ($data);
+                    if ($res) {
+                        return 1;
+                    } else {
+                        return -50016;
+                    }
+                } else {
+                    return -50017;
+                }
+
+            } else {
+                return -50018;
+            }
+
+        } else {
+            return -50019;
+        }
+    }
+
+}

+ 40 - 0
Application/Api/Model/UserSetting.php

@@ -0,0 +1,40 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: scstf
+ * Date: 2018/10/26
+ * Time: 9:18
+ */
+
+namespace App\Api\Model;
+
+use \System\Model;
+
+class UserSetting extends Model
+{
+    protected $table = 'user_setting';
+    public $primaryKey = 'account_identity';
+    public $incrementing = false;
+    public $fillable = ['hand_lock', 'hand_pass', 'sound', 'prize_ani', 'shake_rand','prize_games','win_games'];
+
+    public function getUserSetting($uuid)
+    {
+
+        return ($ret = $this->where ('account_identity', $uuid)->first ()) ? $ret->toArray () : '';
+
+    }
+
+    public function setUserSettings($uuid, $data)
+    {   
+        $us = $this->where ('account_identity', $uuid)->first();
+        if ($us) {
+            return $this->where('account_identity',$uuid)->update($data);
+        }else{
+            $data['account_identity'] = $uuid;
+            return $this->insert($data);
+        }
+    }
+}
+
+
+

+ 14 - 0
Application/Api/Model/User_log_record.php

@@ -0,0 +1,14 @@
+<?php
+/**
+ *------Create thems Model------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-12 05:08:18------
+ */
+namespace App\Api\Model;
+use \System\Model;
+
+class User_log_record extends Model {
+
+    protected $table = 'user_log_record';
+}

+ 14 - 0
Application/Api/Model/User_vip.php

@@ -0,0 +1,14 @@
+<?php
+/**
+ *------Create thems Model------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-12 05:08:18------
+ */
+namespace App\Api\Model;
+use \System\Model;
+
+class User_vip extends Model
+{
+    protected $table = 'user_vip';
+}

+ 112 - 0
Application/Api/Model/Withdraw.php

@@ -0,0 +1,112 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: scstf
+ * Date: 2019/4/18
+ * Time: 14:09
+ */
+
+namespace App\Api\Model;
+
+use \System\Model;
+use Biz\Account\AccountManager;
+
+class Withdraw extends Model
+{
+    /**
+     * 奖记录中
+     *
+     * @access public
+     * @return String
+     */
+    public function withdrawalRequest()
+    {
+        // 获取用户信息
+        $accountManagerClass = new AccountManager;
+        $userInfo = $accountManagerClass -> getCurrentUser();
+        if (empty($userInfo['identity'])) {
+            Render([], '2001', lang('Common','Api') -> get('user does login'));
+        }
+        // 验证提款金额小于一百
+        if (!$_POST['money'] || $_POST['money'] < 100) {
+            Render([], '2112', lang('Common','Api') -> get('cash withdrawal less than 100'));
+        }
+        $accountDetailedWhere = array();
+        // 用户ID
+        $accountDetailedWhere['account_identity'] = $userInfo['identity'];
+        $accountDetailedSelect = ['available_cash', 'cash'];
+        $accountDetailed = lm('account_detailed', "commons");
+        // 获取用户可提现金额
+        $accountInfo = $accountDetailed -> accountDetailed($accountDetailedSelect, $accountDetailedWhere);
+        // 验证提款额度大于可提现余额
+        if($accountInfo['available_cash'] < $_POST['money']) {
+            Render([], '2112', lang('Common','Api') -> get('insufficient amount of account'));
+        }
+        //验证交易密码
+        $accountManagerClass -> verifyPayPwd($userInfo['identity'], $_POST['payPassword']);
+        // 用户银行卡
+        $bankCardWhere['account_identity'] = $userInfo['identity'];
+        $bankCardWhere['bank_number'] = $_POST['bank_number'];
+        $bankCardSelect = ['bank_number', 'account_name', 'bank_address', 'bank_name'];
+        $getBankCardInfo = lm('account_bank', "commons");
+        // 用户是否绑定该银行卡
+        $bankCardInfo = $getBankCardInfo -> bankCard($bankCardSelect, $bankCardWhere);
+        if(!$bankCardInfo['bank_number']) {
+            Render([], '2114', lang('Common','Api') -> get('the bank card is not bound'));
+        }
+        //生成订单id
+        $order_id = OrderID();
+        //提现后总金额
+        $cashMoney = floatval($accountInfo['cash']) - floatval($_POST['money']);
+        //提现后可提现金额
+        $availableCashMoney = floatval($accountInfo['available_cash']) - floatval($_POST['money']);
+        $moneyTakeData = array(
+            'info_identity' => UUID(),
+            'order_id' => $order_id,
+            'account_identity' => $userInfo['identity'],
+            'account_name' => $userInfo['name'],
+            'money' => $_POST['money'],
+            'apply_time' => date('Y-m-d H:i:s', time()),
+            'apply_date' => date('Y-m-d', time()),
+            'bank_info' => $bankCardInfo['bank_name'],
+            'bank_no' => $_POST['bank_number'],
+            'bank_address' => $bankCardInfo['bank_address'],
+            'bank_user' => $bankCardInfo['account_name'],
+            'money_cash' => $cashMoney,
+        );
+        //验证三分钟内不能重复提交提现申请
+        $moneyTake = lm('money_take', 'commons');
+        $takeRecordWhere['account_identity'] = $userInfo['identity'];
+        $takeRecordSelect = ['apply_time'];
+        $moneyTakeInfo = $moneyTake -> takeRecord($takeRecordSelect, $takeRecordWhere);
+        $applyTime = date('Y-m-d H:i:s', time() - 300);
+        if ($moneyTakeInfo) {
+            if (!empty($moneyTakeInfo['apply_time']) && $moneyTakeInfo['apply_time'] >= $applyTime) {
+                Render([], '2051', lang('Common','Api') -> get('you have submitted your application for withdrawal'));
+            }
+        }
+
+        // 添加提现记录
+        _beginTransaction();
+        try {
+            $insertTake = $moneyTake -> insertTake($moneyTakeData);
+            if ($insertTake) {
+                $accountUpdateData = [
+                    'available_cash' => $availableCashMoney,
+                    'cash' => $cashMoney,
+                ];
+                $updateAccountWhere['account_identity'] = $userInfo['identity'];
+                // 修改用户信息表剩余金额
+                $updateResult = $accountDetailed -> updateDetailed($updateAccountWhere, $accountUpdateData);
+                if ($updateResult > 0) {
+                    _commit();
+                    Render([], '40453', lang('Common','Api') -> get('application has been submitted and customer service is under review'));
+                }
+            }
+        } catch (PDOException $e) {
+            _rollBack();
+            Render([], '141313', lang('Common','Api') -> get('the application failed. Please try again'));
+        }
+    }
+
+}

+ 88 - 0
Application/Api/Model/Withdraw_rule.php

@@ -0,0 +1,88 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: scstf
+ * Date: 2018/9/25
+ * Time: 18:09
+ */
+
+namespace App\Api\Model;
+
+use \System\Model;
+
+class Withdraw_rule extends Model
+{
+    protected $table = 'withdraw_rule';
+
+    public static function setRule($idd, $startTime, $endTime, $bettingMoney, $needBettingMoney)
+    {
+        $data = [
+            'account_identity' => $idd,
+            'start_time' => is_int ($startTime) ? $startTime : strtotime ($startTime) ?? time (),
+            'end_time' => is_int ($endTime) ? $endTime : strtotime ($endTime) ?? time (),
+            'bettingMoney' => $bettingMoney,
+            'updated_at' => date ('Y-m-d H:i:s'),
+            'needBettingMoney' => $needBettingMoney,
+            'donate_start' => date ('Y-m-d H:i:s'),
+        ];
+        return self::insertGetId ($data);
+    }
+
+    /**
+     * 更新用户增量流水
+     * @param string $idd 用户账户UUID
+     * @param  $money 父订单金额
+     * @param int $rate 增量倍数
+     * @return int
+     */
+    function updateRule($idd, $money, $rate)
+    {
+        $withdrawRule = new self();
+        $with = $withdrawRule->where ('account_identity', $idd)->first ();
+        $time = date ('Y-m-d H:i:s');
+        $ret = 1;
+        $need = (float)$money * ($rate - 1);//目标流水差额
+        if (!$with) {
+            self::setRule ($idd, $time, $time, 0, $need);
+        } else {
+            $with->increment ('needBettingMoney', $need);//目标流水差额
+            $with->updated_at = date ('Y-m-d H:i:s');
+            $ret = $with->update ();
+        }
+        return $ret;
+    }
+
+    /**
+     * 提现时验证用户的流水记录
+     * @param string $idd 用户账户编号uuid
+     * @return null 没有记录返回NULL,成功返回用户当前有效下注总流水和目标总流水
+     */
+     function check($idd)
+    {
+        $where = ['account_identity' => $idd];
+        $data = self::where ($where)->first (['bettingMoney', 'needBettingMoney', 'donate_start']);
+        if (!$data) return null;
+        $time = $data->donate_start;
+        $bet = (new MoneyBuy())->getBetMoney ($time, $idd);//常规投注
+        $sixBet = (new SixMoneyBuy())::getBetMoney ($time, $idd);//六合投注
+        $data->bettingMoney = $bet + $sixBet;//总投注流水
+        $recharge = Money_recharge::where ('account_identity', $idd)
+            ->where ('complete_time', '>=', $time) //首笔金额发生时间
+            ->where ('status', 1) //订单状态为成功
+            //->whereIn ('trade_type', [11, 14])
+            ->sum (DB::Raw ('money * rate'));//资金表中的流水倍数和
+        $data->needBettingMoney += $recharge;//差额流水+资金表中流水要求=总目标流水
+        return $data;
+    }
+
+    public static function rmRule($idd)
+    {
+        return self::where ('account_identity', $idd)->delete ();
+    }
+
+    public static function getRule($id)
+    {
+        return self::where ('id', $id)->first ();
+    }
+
+}

+ 14 - 0
Application/Api/Model/Xy28_buy.php

@@ -0,0 +1,14 @@
+<?php
+/**
+ *------Create thems Model------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-06 07:45:06------
+ */
+namespace App\Api\Model;
+use \System\Model;
+
+class Xy28_buy extends Model {
+
+	protected $table = 'Xy28_buy';
+}

+ 18 - 0
Application/Commons/Controller/BaseController.php

@@ -0,0 +1,18 @@
+<?php
+/**
+*------Create thems Controller------
+*------SCWPHP  Version 1.0.0------
+*------Dev Model Jions------
+*------Create Time 2017-10-30 13:48:09------
+*/
+namespace App\Commons\Controller;
+class BaseController extends \BaseController\Controller {
+
+	function init(){
+
+	}
+
+	Public function Index(){
+
+	}
+}

+ 49 - 0
Application/Commons/Controller/Validation.php

@@ -0,0 +1,49 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Administrator
+ * Date: 2018/9/7
+ * Time: 17:55
+ */
+
+namespace App\Commons\Controller;
+
+
+class Validation
+{
+    public static function isUser($data, $config = ['cn' => 0, '_' => 1])
+    {
+        $parten = "/^([\x{4e00}-\x{9fa5}\w])+([\x{4e00}-\x{9fa5}\w]\d_)?$/u";
+        return preg_match($parten, $data);
+    }
+
+    public static function isChinease($data)
+    {
+        $patern = "/^[\x{4e00}-\x{9fa5}]+$/u";
+        return preg_match($patern, $data);
+    }
+
+    public static function isWords($data)
+    {
+        $patern = "/^[a-z_A-Z]+$/";
+        return preg_match($patern, $data);
+    }
+
+    public static function isWordWithNumberEnd($data)
+    {
+        $patern = "/^\w+[\-]?[_]?[\w\d]?$/";
+        return preg_match($patern, $data);
+    }
+
+    public static function isEmail($data)
+    {
+        $patern='/^[\d\w]+([_]?[\-]?[\.]?[\d\w]+)?@[\d\w]+[\.]+[\w]{2,4}/';
+        return preg_match($patern,$data);
+    }
+
+    public static function isFloat($data)
+    {
+        $patern = '/^[\d]+\.?\d+$/';
+        return preg_match($patern, $data);
+    }
+}

+ 1008 - 0
Application/Commons/Lang/Common.php

@@ -0,0 +1,1008 @@
+<?php
+
+return array(
+	'HandRecharge' => "手动充值",
+	'killorder' => "撤单",
+	'user does not exist' => '用户不存在',
+	'login successful' => '登录成功',
+	'login error, login again' => '登录出错,重新登录',
+	'password error' => '密码错误',
+	'old password error' => '原密码错误',
+	'update successful' => '修改成功',
+	'the user already exists. Please change it' => '用户已存在,请换一个',
+	'register successful' => '注册成功',
+	'registration failed. please re-registration' => '注册失败,请重新注册',
+	'registration failed' => '注册失败',
+	'no prize msg' => '无最近中奖信息',
+	'success' => '成功',
+	'paraserr' => '请求参数有错误',
+	'sorry, this user does not exist' => '对不起,该用户不存在',
+	'sorry, the account has been disabled' => '对不起,该账号已被禁用',
+	'sorry, the account is unusual' => '对不起,该账号异常',
+	'the two password is different' => '两次密码不一样',
+	'account cannot be empty' => '账号不能为空',
+	'password cannot be empty' => '密码不能为空',
+	'verify that the password is not empty' => '确认密码不能为空',
+	'name is empty' => '真实姓名不能为空',
+	'the cell phone number cannot be empty' => '手机号不能为空',
+	'login expired' => '登录过期',
+	'user error' => '用户错误',
+	'user not login' => '用户未登录',
+	'empty introduce_user' => '介绍人不存在',
+	'no payment password, please set the payment password first' => '没有支付密码,请先设置支付密码',
+
+	'Failed to obtain user information. Please refresh retry' => '获取用户信息失败,请刷新重试',
+
+	'Please bind the bank card' => '请绑定银行卡',
+
+	'Please contact customer service' => '请联系客服修改',
+
+	'bank_address missing' => '银行卡地址缺失',
+
+	'bank_name missing' => '银行名缺失',
+
+	'record has exists' => '您已提交充值记录,不可重复提交',
+
+	'missing bankCard' => '银行卡未绑定',
+
+    'missing Disable' => '银行卡已被禁用',
+
+	'bank_number missing' => '银行卡号缺失',
+
+	'bank_user missing' => '银行卡绑定用户缺失',
+
+	'password missing' => '密码缺失',
+
+	'two password not equal' => '两次密码不一致',
+
+	'pay_pwd not set' => '未设置支付密码',
+
+	'bank success' => '绑定银行卡成功',
+
+	'bank fail' => '绑定银行卡失败',
+
+	'pay_pwd already had' => '已经设置过交易密码',
+
+	'set fail' => '设置交易密码失败',
+
+	'pay_pwd set success' => '设置交易密码成功',
+
+	'account abnormal' => '账号异常',
+
+	'money not enough' => '账户余额不足,请充值',
+
+	'apply fail' => '申请失败',
+
+	'apply success' => '申请成功',
+
+	'betting fail' => '投注失败',
+
+	'chase fail' => '追号失败',
+
+	"success" => "成功",
+	'notWithdrawals' => "未中奖",
+	"fail" => "失败",
+	"audits" => "审核中",
+	"Betting" => "投注",
+	"Betting" => "投注",
+	"ChaseNumber" => "追号",
+	"Withdrawals" => "提现",
+	"Recharge" => "充值",
+	"Defection" => "返水",
+	"DeductMoney" => "扣款",
+	"Winning" => "派彩",
+	"Active" => "活动",
+	"Give" => "充值赠送",
+	"Remit" => "汇款",
+	"backwater" => "回水",
+	"Commission" => "佣金比例",
+	"NoWithdrawals" => "冻结提现",
+	"redget" => "红包打赏",
+	"changemoney" => "额度转账",
+	"agentrecharge" => "代理代充",
+	"win" => "中奖",
+	"notwin" => "未中奖",
+	"audit" => "待开奖",
+	"coler" => "波色",
+	"blend" => "混合",
+	"code" => "数字特码包",
+	"Smalldouble" => "小双",
+	"Bigdouble" => "大双",
+	"Smallsingle" => "小单",
+	"Bigsingle" => "大单",
+	"double" => "双",
+	"single" => "单",
+	"Small" => "小",
+	"Big" => "大",
+	"Notnum" => "无极值",
+	"VeryBig" => "极大",
+	"VerySmall" => "极小",
+	"NotWin" => "未开出",
+	"Win" => "中奖",
+	"ChageOrder" => "撤单",
+	"Chase" => "追号",
+	'missing parm' => '参数缺失',
+
+	'missing data' => '数据被火星人劫持了',
+
+	'get pay failed' => '未获取到支付接口信息',
+
+	'recharge data failed' => '未提交充值信息',
+
+	'recharge apply success' => '充值申请成功,系统将于24小时内处理,请耐心等候',
+
+	'recharge apply failed' => '充值失败,请重试',
+
+	'missing phone' => '请输入电话号码',
+
+	'error phone' => '请输入正确的电话号码!',
+
+	'give your phone' => '请输入自己的电话号码!',
+
+	'agent fail' => '申请代理失败,请联系在线客服!,审核未通过!',
+
+	'give two' => '请勿重复提交!,已申请代理,正在审核。',
+
+	'agent success' => '代理申请成功,申请成功',
+
+	'give one' => '申请已经发出,请耐心等候',
+	'missing game' => '游戏不存在',
+	'append success' => '追号成功',
+	'game is off' => '游戏已关闭',
+
+	'chain' => '冠亚和',
+	'poscode' => '定位胆',
+	'dragon' => 'PK龙虎',
+	'head_one' => '直选前一',
+	'head_two' => '直选前二',
+	'head_three' => '直选前三',
+
+	'chain-3' => '冠亚和-3',
+	'chain-4' => '冠亚和-4',
+	'chain-5' => '冠亚和-5',
+	'chain-6' => '冠亚和-6',
+	'chain-7' => '冠亚和-7',
+	'chain-8' => '冠亚和-8',
+	'chain-9' => '冠亚和-9',
+	'chain-10' => '冠亚和-10',
+	'chain-11' => '冠亚和-11',
+	'chain-12' => '冠亚和-12',
+	'chain-13' => '冠亚和-13',
+	'chain-14' => '冠亚和-14',
+	'chain-15' => '冠亚和-15',
+	'chain-16' => '冠亚和-16',
+	'chain-17' => '冠亚和-17',
+	'chain-18' => '冠亚和-18',
+	'chain-19' => '冠亚和-19',
+	'chain-big' => '冠亚和-大',
+	'chain-small' => '冠亚和-小',
+	'chain-single' => '冠亚和-单',
+	'chain-dobule' => '冠亚和-双',
+	'poscode-1_1' => '定位胆-1_1',
+	'poscode-1_2' => '定位胆-1_2',
+	'poscode-1_3' => '定位胆-1_3',
+	'poscode-1_4' => '定位胆-1_4',
+	'poscode-1_5' => '定位胆-1_5',
+	'poscode-1_6' => '定位胆-1_6',
+	'poscode-1_7' => '定位胆-1_7',
+	'poscode-1_8' => '定位胆-1_8',
+	'poscode-1_9' => '定位胆-1_9',
+	'poscode-1_10' => '定位胆-1_10',
+	'poscode-2_1' => '定位胆-2_1',
+	'poscode-2_2' => '定位胆-2_2',
+	'poscode-2_3' => '定位胆-2_3',
+	'poscode-2_4' => '定位胆-2_4',
+	'poscode-2_5' => '定位胆-2_5',
+	'poscode-2_6' => '定位胆-2_6',
+	'poscode-2_7' => '定位胆-2_7',
+	'poscode-2_8' => '定位胆-2_8',
+	'poscode-2_9' => '定位胆-2_9',
+	'poscode-2_10' => '定位胆-2_10',
+	'poscode-3_1' => '定位胆-3_1',
+	'poscode-3_2' => '定位胆-3_2',
+	'poscode-3_3' => '定位胆-3_3',
+	'poscode-3_4' => '定位胆-3_4',
+	'poscode-3_5' => '定位胆-3_5',
+	'poscode-3_6' => '定位胆-3_6',
+	'poscode-3_7' => '定位胆-3_7',
+	'poscode-3_8' => '定位胆-3_8',
+	'poscode-3_9' => '定位胆-3_9',
+	'poscode-3_10' => '定位胆-3_10',
+	'poscode-4_1' => '定位胆-4_1',
+	'poscode-4_2' => '定位胆-4_2',
+	'poscode-4_3' => '定位胆-4_3',
+	'poscode-4_4' => '定位胆-4_4',
+	'poscode-4_5' => '定位胆-4_5',
+	'poscode-4_6' => '定位胆-4_6',
+	'poscode-4_7' => '定位胆-4_7',
+	'poscode-4_8' => '定位胆-4_8',
+	'poscode-4_9' => '定位胆-4_9',
+	'poscode-4_10' => '定位胆-4_10',
+	'poscode-5_1' => '定位胆-5_1',
+	'poscode-5_2' => '定位胆-5_2',
+	'poscode-5_3' => '定位胆-5_3',
+	'poscode-5_4' => '定位胆-5_4',
+	'poscode-5_5' => '定位胆-5_5',
+	'poscode-5_6' => '定位胆-5_6',
+	'poscode-5_7' => '定位胆-5_7',
+	'poscode-5_8' => '定位胆-5_8',
+	'poscode-5_9' => '定位胆-5_9',
+	'poscode-5_10' => '定位胆-5_10',
+	'poscode-6_1' => '定位胆-6_1',
+	'poscode-6_2' => '定位胆-6_2',
+	'poscode-6_3' => '定位胆-6_3',
+	'poscode-6_4' => '定位胆-6_4',
+	'poscode-6_5' => '定位胆-6_5',
+	'poscode-6_6' => '定位胆-6_6',
+	'poscode-6_7' => '定位胆-6_7',
+	'poscode-6_8' => '定位胆-6_8',
+	'poscode-6_9' => '定位胆-6_9',
+	'poscode-6_10' => '定位胆-6_10',
+	'poscode-7_1' => '定位胆-7_1',
+	'poscode-7_2' => '定位胆-7_2',
+	'poscode-7_3' => '定位胆-7_3',
+	'poscode-7_4' => '定位胆-7_4',
+	'poscode-7_5' => '定位胆-7_5',
+	'poscode-7_6' => '定位胆-7_6',
+	'poscode-7_7' => '定位胆-7_7',
+	'poscode-7_8' => '定位胆-7_8',
+	'poscode-7_9' => '定位胆-7_9',
+	'poscode-7_10' => '定位胆-7_10',
+	'poscode-8_1' => '定位胆-8_1',
+	'poscode-8_2' => '定位胆-8_2',
+	'poscode-8_3' => '定位胆-8_3',
+	'poscode-8_4' => '定位胆-8_4',
+	'poscode-8_5' => '定位胆-8_5',
+	'poscode-8_6' => '定位胆-8_6',
+	'poscode-8_7' => '定位胆-8_7',
+	'poscode-8_8' => '定位胆-8_8',
+	'poscode-8_9' => '定位胆-8_9',
+	'poscode-8_10' => '定位胆-8_10',
+	'poscode-9_1' => '定位胆-9_1',
+	'poscode-9_2' => '定位胆-9_2',
+	'poscode-9_3' => '定位胆-9_3',
+	'poscode-9_4' => '定位胆-9_4',
+	'poscode-9_5' => '定位胆-9_5',
+	'poscode-9_6' => '定位胆-9_6',
+	'poscode-9_7' => '定位胆-9_7',
+	'poscode-9_8' => '定位胆-9_8',
+	'poscode-9_9' => '定位胆-9_9',
+	'poscode-9_10' => '定位胆-9_10',
+	'poscode-10_1' => '定位胆-10_1',
+	'poscode-10_2' => '定位胆-10_2',
+	'poscode-10_3' => '定位胆-10_3',
+	'poscode-10_4' => '定位胆-10_4',
+	'poscode-10_5' => '定位胆-10_5',
+	'poscode-10_6' => '定位胆-10_6',
+	'poscode-10_7' => '定位胆-10_7',
+	'poscode-10_8' => '定位胆-10_8',
+	'poscode-10_9' => '定位胆-10_9',
+	'poscode-10_10' => '定位胆-10_10',
+	'dragon-1v10_big' => 'PK龙虎-1v10龙',
+	'dragon-1v10_small' => 'PK龙虎-1v10虎',
+	'dragon-2v9_big' => 'PK龙虎-2v9龙',
+	'dragon-2v9_small' => 'PK龙虎-2v9虎',
+	'dragon-3v8_big' => 'PK龙虎-3v8龙',
+	'dragon-3v8_small' => 'PK龙虎-3v8虎',
+	'dragon-4v7_big' => 'PK龙虎-4v7龙',
+	'dragon-4v7_small' => 'PK龙虎-4v7虎',
+	'dragon-5v6_big' => 'PK龙虎-5v6龙',
+	'dragon-5v6_small' => 'PK龙虎-5v6虎',
+	'head_one-1' => '前一冠军-1',
+	'head_one-2' => '前一冠军-2',
+	'head_one-3' => '前一冠军-3',
+	'head_one-4' => '前一冠军-4',
+	'head_one-5' => '前一冠军-5',
+	'head_one-6' => '前一冠军-6',
+	'head_one-7' => '前一冠军-7',
+	'head_one-8' => '前一冠军-8',
+	'head_one-9' => '前一冠军-9',
+	'head_one-10' => '前一冠军-10',
+	'head_two-1_1' => '前二冠军-1',
+	'head_two-1_2' => '前二冠军-2',
+	'head_two-1_3' => '前二冠军-3',
+	'head_two-1_4' => '前二冠军-4',
+	'head_two-1_5' => '前二冠军-5',
+	'head_two-1_6' => '前二冠军-6',
+	'head_two-1_7' => '前二冠军-7',
+	'head_two-1_8' => '前二冠军-8',
+	'head_two-1_9' => '前二冠军-9',
+	'head_two-1_10' => '前二冠军-10',
+	'head_two-2_1' => '前二亚军-1',
+	'head_two-2_2' => '前二亚军-2',
+	'head_two-2_3' => '前二亚军-3',
+	'head_two-2_4' => '前二亚军-4',
+	'head_two-2_5' => '前二亚军-5',
+	'head_two-2_6' => '前二亚军-6',
+	'head_two-2_7' => '前二亚军-7',
+	'head_two-2_8' => '前二亚军-8',
+	'head_two-2_9' => '前二亚军-9',
+	'head_two-2_10' => '前二亚军-10',
+	'head_three-1_1' => '前三冠军-1',
+	'head_three-1_2' => '前三冠军-2',
+	'head_three-1_3' => '前三冠军-3',
+	'head_three-1_4' => '前三冠军-4',
+	'head_three-1_5' => '前三冠军-5',
+	'head_three-1_6' => '前三冠军-6',
+	'head_three-1_7' => '前三冠军-7',
+	'head_three-1_8' => '前三冠军-8',
+	'head_three-1_9' => '前三冠军-9',
+	'head_three-1_10' => '前三冠军-10',
+	'head_three-2_1' => '前三亚军-1',
+	'head_three-2_2' => '前三亚军-2',
+	'head_three-2_3' => '前三亚军-3',
+	'head_three-2_4' => '前三亚军-4',
+	'head_three-2_5' => '前三亚军-5',
+	'head_three-2_6' => '前三亚军-6',
+	'head_three-2_7' => '前三亚军-7',
+	'head_three-2_8' => '前三亚军-8',
+	'head_three-2_9' => '前三亚军-9',
+	'head_three-2_10' => '前三亚军-10',
+	'head_three-3_1' => '前三季军-1',
+	'head_three-3_2' => '前三季军-2',
+	'head_three-3_3' => '前三季军-3',
+	'head_three-3_4' => '前三季军-4',
+	'head_three-3_5' => '前三季军-5',
+	'head_three-3_6' => '前三季军-6',
+	'head_three-3_7' => '前三季军-7',
+	'head_three-3_8' => '前三季军-8',
+	'head_three-3_9' => '前三季军-9',
+	'head_three-3_10' => '前三季军-10',
+
+	'mix-1_dobule' => '冠军-双',
+	'mix-1_single' => '冠军-单',
+	'mix-2_dobule' => '亚军-双',
+	'mix-2_single' => '亚军-单',
+	'mix-3_dobule' => '第三名-双',
+	'mix-3_single' => '第三名-单',
+	'mix-4_dobule' => '第四名-双',
+	'mix-4_single' => '第四名-单',
+	'mix-5_dobule' => '第五名-双',
+	'mix-5_single' => '第五名-单',
+	'mix-6_dobule' => '第六名-双',
+	'mix-6_single' => '第六名-单',
+	'mix-7_dobule' => '第七名-双',
+	'mix-7_single' => '第七名-单',
+	'mix-8_dobule' => '第八名-双',
+	'mix-8_single' => '第八名-单',
+	'mix-9_dobule' => '第九名-双',
+	'mix-9_single' => '第九名-单',
+	'mix-10_dobule' => '第十名-双',
+	'mix-10_single' => '第十名-单',
+
+	'mix-1_big' => '冠军-大',
+	'mix-1_small' => '冠军-小',
+	'mix-2_big' => '亚军-大',
+	'mix-2_small' => '亚军-小',
+	'mix-3_big' => '第三名-大',
+	'mix-3_small' => '第三名-小',
+	'mix-4_big' => '第四名-大',
+	'mix-4_small' => '第四名-小',
+	'mix-5_big' => '第五名-大',
+	'mix-5_small' => '第五名-小',
+	'mix-6_big' => '第六名-大',
+	'mix-6_small' => '第六名-小',
+	'mix-7_big' => '第七名-大',
+	'mix-7_small' => '第七名-小',
+	'mix-8_big' => '第八名-大',
+	'mix-8_small' => '第八名-小',
+	'mix-9_big' => '第九名-大',
+	'mix-9_small' => '第九名-小',
+	'mix-10_big' => '第十名-大',
+	'mix-10_small' => '第十名-小',
+
+	'specialCode' => '特码',
+	'color' => '波色',
+	'mix' => '混合',
+	'size' => '豹子',
+	'color-red' => '波色-红',
+	'color-green' => '波色-绿',
+	'color-blue' => '波色-蓝',
+	'mix-small' => '混合-小',
+	'mix-big' => '混合-大',
+	'mix-limitSmall' => '混合-极小',
+	'mix-limitBig' => '混合-极大',
+	'mix-single' => '混合-单',
+	'mix-dobule' => '混合-双',
+	'mix-smallSingle' => '混合-小单',
+	'mix-bigSingle' => '混合-大单',
+	'mix-smallDobule' => '混合-小双',
+	'mix-bigDobule' => '混合-大双',
+	'size-leopard' => '豹子',
+	'specialCode-0' => '特码-0',
+	'specialCode-1' => '特码-1',
+	'specialCode-2' => '特码-2',
+	'specialCode-3' => '特码-3',
+	'specialCode-4' => '特码-4',
+	'specialCode-5' => '特码-5',
+	'specialCode-6' => '特码-6',
+	'specialCode-7' => '特码-7',
+	'specialCode-8' => '特码-8',
+	'specialCode-9' => '特码-9',
+	'specialCode-10' => '特码-10',
+	'specialCode-11' => '特码-11',
+	'specialCode-12' => '特码-12',
+	'specialCode-13' => '特码-13',
+	'specialCode-14' => '特码-14',
+	'specialCode-15' => '特码-15',
+	'specialCode-16' => '特码-16',
+	'specialCode-17' => '特码-17',
+	'specialCode-18' => '特码-18',
+	'specialCode-19' => '特码-19',
+	'specialCode-20' => '特码-20',
+	'specialCode-21' => '特码-21',
+	'specialCode-22' => '特码-22',
+	'specialCode-23' => '特码-23',
+	'specialCode-24' => '特码-24',
+	'specialCode-25' => '特码-25',
+	'specialCode-26' => '特码-26',
+	'specialCode-27' => '特码-27',
+    'specialthree-0' => '特码包3-0',
+    'specialthree-1' => '特码包3-1',
+    'specialthree-2' => '特码包3-2',
+    'specialthree-3' => '特码包3-3',
+    'specialthree-4' => '特码包3-4',
+    'specialthree-5' => '特码包3-5',
+    'specialthree-6' => '特码包3-6',
+    'specialthree-7' => '特码包3-7',
+    'specialthree-8' => '特码包3-8',
+    'specialthree-9' => '特码包3-9',
+    'specialthree-10' => '特码包3-10',
+    'specialthree-11' => '特码包3-11',
+    'specialthree-12' => '特码包3-12',
+    'specialthree-13' => '特码包3-13',
+    'specialthree-14' => '特码包3-14',
+    'specialthree-15' => '特码包3-15',
+    'specialthree-16' => '特码包3-16',
+    'specialthree-17' => '特码包3-17',
+    'specialthree-18' => '特码包3-18',
+    'specialthree-19' => '特码包3-19',
+    'specialthree-20' => '特码包3-20',
+    'specialthree-21' => '特码包3-21',
+    'specialthree-22' => '特码包3-22',
+    'specialthree-23' => '特码包3-23',
+    'specialthree-24' => '特码包3-24',
+    'specialthree-25' => '特码包3-25',
+    'specialthree-26' => '特码包3-26',
+    'specialthree-27' => '特码包3-27',
+
+	/*重庆时时彩玩法名称*/
+	//牛牛
+	'bulls' => '牛牛玩法',
+	'bulls-bulls_1' => '牛一',
+	'bulls-bulls_2' => '牛二',
+	'bulls-bulls_3' => '牛三',
+	'bulls-bulls_4' => '牛四',
+	'bulls-bulls_5' => '牛五',
+	'bulls-bulls_6' => '牛六',
+	'bulls-bulls_7' => '牛七',
+	'bulls-bulls_8' => '牛八',
+	'bulls-bulls_9' => '牛九',
+	'bulls-bulls_not' => '无牛',
+	'bulls-bulls_bulls' => '牛牛',
+	'bulls-big' => '牛大',
+	'bulls-small' => '牛小',
+	'bulls-single' => '牛单',
+	'bulls-dobule' => '牛双',
+
+	//前三
+	'frontthree' => '特殊玩法',
+	'frontthree-order' => '顺子前三',
+	'frontthree-halfbuad' => '半顺前三',
+	'frontthree-leopard' => '豹子前三',
+	'frontthree-buad' => '对子前三',
+	'frontthree-mix6' => '杂六前三',
+	'frontthree-halfbuad-buad' => '顺子对子',
+
+	//中三
+	'middlethree' => '特殊玩法',
+	'middlethree-order' => '顺子中三',
+	'middlethree-halfbuad' => '半顺中三',
+	'middlethree-leopard' => '豹子中三',
+	'middlethree-buad' => '对子中三',
+	'middlethree-mix6' => '杂六中三',
+	'middlethree-halfbuad-buad' => '顺子对子',
+
+	//后三
+	'behindthree' => '特殊玩法',
+	'behindthree-order' => '顺子后三',
+	'behindthree-halfbuad' => '半顺后三',
+	'behindthree-leopard' => '豹子后三',
+	'behindthree-buad' => '对子后三',
+	'behindthree-mix6' => '杂六后三',
+	'behindthree-halfbuad-buad' => '顺子对子',
+
+	//龙虎榜
+	'dragon' => '龙虎榜',
+	'dragon-big' => '龙',
+	'dragon-small' => '虎',
+	'dragon-equal' => '和',
+
+	//前二星
+	'fronttwostar' => '前二星',
+	'fronttwostar-1_0' => '前二星-1_0',
+	'fronttwostar-1_1' => '前二星-1_1',
+	'fronttwostar-1_2' => '前二星-1_2',
+	'fronttwostar-1_3' => '前二星-1_3',
+	'fronttwostar-1_4' => '前二星-1_4',
+	'fronttwostar-1_5' => '前二星-1_5',
+	'fronttwostar-1_6' => '前二星-1_6',
+	'fronttwostar-1_7' => '前二星-1_7',
+	'fronttwostar-1_8' => '前二星-1_8',
+	'fronttwostar-1_9' => '前二星-1_9',
+	'fronttwostar-2_0' => '前二星-2_0',
+	'fronttwostar-2_1' => '前二星-2_1',
+	'fronttwostar-2_2' => '前二星-2_2',
+	'fronttwostar-2_3' => '前二星-2_3',
+	'fronttwostar-2_4' => '前二星-2_4',
+	'fronttwostar-2_5' => '前二星-2_5',
+	'fronttwostar-2_6' => '前二星-2_6',
+	'fronttwostar-2_7' => '前二星-2_7',
+	'fronttwostar-2_8' => '前二星-2_8',
+	'fronttwostar-2_9' => '前二星-2_9',
+
+	//前三星
+	'frontthreestar' => '前三星',
+	'frontthreestar-1_0' => '前三星-1_0',
+	'frontthreestar-1_1' => '前三星-1_1',
+	'frontthreestar-1_2' => '前三星-1_2',
+	'frontthreestar-1_3' => '前三星-1_3',
+	'frontthreestar-1_4' => '前三星-1_4',
+	'frontthreestar-1_5' => '前三星-1_5',
+	'frontthreestar-1_6' => '前三星-1_6',
+	'frontthreestar-1_7' => '前三星-1_7',
+	'frontthreestar-1_8' => '前三星-1_8',
+	'frontthreestar-1_9' => '前三星-1_9',
+	'frontthreestar-2_0' => '前三星-2_0',
+	'frontthreestar-2_1' => '前三星-2_1',
+	'frontthreestar-2_2' => '前三星-2_2',
+	'frontthreestar-2_3' => '前三星-2_3',
+	'frontthreestar-2_4' => '前三星-2_4',
+	'frontthreestar-2_5' => '前三星-2_5',
+	'frontthreestar-2_6' => '前三星-2_6',
+	'frontthreestar-2_7' => '前三星-2_7',
+	'frontthreestar-2_8' => '前三星-2_8',
+	'frontthreestar-2_9' => '前三星-2_9',
+	'frontthreestar-3_0' => '前三星-3_0',
+	'frontthreestar-3_1' => '前三星-3_1',
+	'frontthreestar-3_2' => '前三星-3_2',
+	'frontthreestar-3_3' => '前三星-3_3',
+	'frontthreestar-3_4' => '前三星-3_4',
+	'frontthreestar-3_5' => '前三星-3_5',
+	'frontthreestar-3_6' => '前三星-3_6',
+	'frontthreestar-3_7' => '前三星-3_7',
+	'frontthreestar-3_8' => '前三星-3_8',
+	'frontthreestar-3_9' => '前三星-3_9',
+
+	//后三星
+	'behindthreestar' => '后三星',
+	'behindthreestar-3_0' => '后三星-3_0',
+	'behindthreestar-3_1' => '后三星-3_1',
+	'behindthreestar-3_2' => '后三星-3_2',
+	'behindthreestar-3_3' => '后三星-3_3',
+	'behindthreestar-3_4' => '后三星-3_4',
+	'behindthreestar-3_5' => '后三星-3_5',
+	'behindthreestar-3_6' => '后三星-3_6',
+	'behindthreestar-3_7' => '后三星-3_7',
+	'behindthreestar-3_8' => '后三星-3_8',
+	'behindthreestar-3_9' => '后三星-3_9',
+	'behindthreestar-4_0' => '后三星-4_0',
+	'behindthreestar-4_1' => '后三星-4_1',
+	'behindthreestar-4_2' => '后三星-4_2',
+	'behindthreestar-4_3' => '后三星-4_3',
+	'behindthreestar-4_4' => '后三星-4_4',
+	'behindthreestar-4_5' => '后三星-4_5',
+	'behindthreestar-4_6' => '后三星-4_6',
+	'behindthreestar-4_7' => '后三星-4_7',
+	'behindthreestar-4_8' => '后三星-4_8',
+	'behindthreestar-4_9' => '后三星-4_9',
+	'behindthreestar-5_0' => '后三星-5_0',
+	'behindthreestar-5_1' => '后三星-5_1',
+	'behindthreestar-5_2' => '后三星-5_2',
+	'behindthreestar-5_3' => '后三星-5_3',
+	'behindthreestar-5_4' => '后三星-5_4',
+	'behindthreestar-5_5' => '后三星-5_5',
+	'behindthreestar-5_6' => '后三星-5_6',
+	'behindthreestar-5_7' => '后三星-5_7',
+	'behindthreestar-5_8' => '后三星-5_8',
+	'behindthreestar-5_9' => '后三星-5_9',
+
+	//四星
+	'fourstar' => '四星',
+	'fourstar-5_0' => '四星-5_0',
+	'fourstar-5_1' => '四星-5_1',
+	'fourstar-5_2' => '四星-5_2',
+	'fourstar-5_3' => '四星-5_3',
+	'fourstar-5_4' => '四星-5_4',
+	'fourstar-5_5' => '四星-5_5',
+	'fourstar-5_6' => '四星-5_6',
+	'fourstar-5_7' => '四星-5_7',
+	'fourstar-5_8' => '四星-5_8',
+	'fourstar-5_9' => '四星-5_9',
+	'fourstar-2_0' => '四星-2_0',
+	'fourstar-2_1' => '四星-2_1',
+	'fourstar-2_2' => '四星-2_2',
+	'fourstar-2_3' => '四星-2_3',
+	'fourstar-2_4' => '四星-2_4',
+	'fourstar-2_5' => '四星-2_5',
+	'fourstar-2_6' => '四星-2_6',
+	'fourstar-2_7' => '四星-2_7',
+	'fourstar-2_8' => '四星-2_8',
+	'fourstar-2_9' => '四星-2_9',
+	'fourstar-3_0' => '四星-3_0',
+	'fourstar-3_1' => '四星-3_1',
+	'fourstar-3_2' => '四星-3_2',
+	'fourstar-3_3' => '四星-3_3',
+	'fourstar-3_4' => '四星-3_4',
+	'fourstar-3_5' => '四星-3_5',
+	'fourstar-3_6' => '四星-3_6',
+	'fourstar-3_7' => '四星-3_7',
+	'fourstar-3_8' => '四星-3_8',
+	'fourstar-3_9' => '四星-3_9',
+	'fourstar-4_0' => '四星-4_0',
+	'fourstar-4_1' => '四星-4_1',
+	'fourstar-4_2' => '四星-4_2',
+	'fourstar-4_3' => '四星-4_3',
+	'fourstar-4_4' => '四星-4_4',
+	'fourstar-4_5' => '四星-4_5',
+	'fourstar-4_6' => '四星-4_6',
+	'fourstar-4_7' => '四星-4_7',
+	'fourstar-4_8' => '四星-4_8',
+	'fourstar-4_9' => '四星-4_9',
+
+	//五星
+	'fivestar' => '五星',
+	'fivestar-1_0' => '五星-1_0',
+	'fivestar-1_1' => '五星-1_1',
+	'fivestar-1_2' => '五星-1_2',
+	'fivestar-1_3' => '五星-1_3',
+	'fivestar-1_4' => '五星-1_4',
+	'fivestar-1_5' => '五星-1_5',
+	'fivestar-1_6' => '五星-1_6',
+	'fivestar-1_7' => '五星-1_7',
+	'fivestar-1_8' => '五星-1_8',
+	'fivestar-1_9' => '五星-1_9',
+	'fivestar-2_0' => '五星-2_0',
+	'fivestar-2_1' => '五星-2_1',
+	'fivestar-2_2' => '五星-2_2',
+	'fivestar-2_3' => '五星-2_3',
+	'fivestar-2_4' => '五星-2_4',
+	'fivestar-2_5' => '五星-2_5',
+	'fivestar-2_6' => '五星-2_6',
+	'fivestar-2_7' => '五星-2_7',
+	'fivestar-2_8' => '五星-2_8',
+	'fivestar-2_9' => '五星-2_9',
+	'fivestar-3_0' => '五星-3_0',
+	'fivestar-3_1' => '五星-3_1',
+	'fivestar-3_2' => '五星-3_2',
+	'fivestar-3_3' => '五星-3_3',
+	'fivestar-3_4' => '五星-3_4',
+	'fivestar-3_5' => '五星-3_5',
+	'fivestar-3_6' => '五星-3_6',
+	'fivestar-3_7' => '五星-3_7',
+	'fivestar-3_8' => '五星-3_8',
+	'fivestar-3_9' => '五星-3_9',
+	'fivestar-4_0' => '五星-4_0',
+	'fivestar-4_1' => '五星-4_1',
+	'fivestar-4_2' => '五星-4_2',
+	'fivestar-4_3' => '五星-4_3',
+	'fivestar-4_4' => '五星-4_4',
+	'fivestar-4_5' => '五星-4_5',
+	'fivestar-4_6' => '五星-4_6',
+	'fivestar-4_7' => '五星-4_7',
+	'fivestar-4_8' => '五星-4_8',
+	'fivestar-4_9' => '五星-4_9',
+	'fivestar-5_0' => '五星-5_0',
+	'fivestar-5_1' => '五星-5_1',
+	'fivestar-5_2' => '五星-5_2',
+	'fivestar-5_3' => '五星-5_3',
+	'fivestar-5_4' => '五星-5_4',
+	'fivestar-5_5' => '五星-5_5',
+	'fivestar-5_6' => '五星-5_6',
+	'fivestar-5_7' => '五星-5_7',
+	'fivestar-5_8' => '五星-5_8',
+	'fivestar-5_9' => '五星-5_9',
+
+	//定位胆
+	'poscode' => '定位胆',
+	'poscode-1_0' => '定位胆-1_0',
+	'poscode-2_0' => '定位胆-2_0',
+	'poscode-3_0' => '定位胆-3_0',
+	'poscode-4_0' => '定位胆-4_0',
+	'poscode-5_0' => '定位胆-5_0',
+
+	//天津快乐10
+	//定位胆
+	'poscode-1_11' => '定位胆-1_11',
+	'poscode-1_12' => '定位胆-1_12',
+	'poscode-1_13' => '定位胆-1_13',
+	'poscode-1_14' => '定位胆-1_14',
+	'poscode-1_15' => '定位胆-1_15',
+	'poscode-1_16' => '定位胆-1_16',
+	'poscode-1_17' => '定位胆-1_17',
+	'poscode-1_18' => '定位胆-1_18',
+	'poscode-1_19' => '定位胆-1_19',
+	'poscode-1_20' => '定位胆-1_20',
+
+	'poscode-2_11' => '定位胆-2_11',
+	'poscode-2_12' => '定位胆-2_12',
+	'poscode-2_13' => '定位胆-2_13',
+	'poscode-2_14' => '定位胆-2_14',
+	'poscode-2_15' => '定位胆-2_15',
+	'poscode-2_16' => '定位胆-2_16',
+	'poscode-2_17' => '定位胆-2_17',
+	'poscode-2_18' => '定位胆-2_18',
+	'poscode-2_19' => '定位胆-2_19',
+	'poscode-2_20' => '定位胆-2_20',
+
+	'poscode-3_11' => '定位胆-3_11',
+	'poscode-3_12' => '定位胆-3_12',
+	'poscode-3_13' => '定位胆-3_13',
+	'poscode-3_14' => '定位胆-3_14',
+	'poscode-3_15' => '定位胆-3_15',
+	'poscode-3_16' => '定位胆-3_16',
+	'poscode-3_17' => '定位胆-3_17',
+	'poscode-3_18' => '定位胆-3_18',
+	'poscode-3_19' => '定位胆-3_19',
+	'poscode-3_20' => '定位胆-3_20',
+
+	'poscode-4_11' => '定位胆-4_11',
+	'poscode-4_12' => '定位胆-4_12',
+	'poscode-4_13' => '定位胆-4_13',
+	'poscode-4_14' => '定位胆-4_14',
+	'poscode-4_15' => '定位胆-4_15',
+	'poscode-4_16' => '定位胆-4_16',
+	'poscode-4_17' => '定位胆-4_17',
+	'poscode-4_18' => '定位胆-4_18',
+	'poscode-4_19' => '定位胆-4_19',
+	'poscode-4_20' => '定位胆-4_20',
+
+	'poscode-5_11' => '定位胆-5_11',
+	'poscode-5_12' => '定位胆-5_12',
+	'poscode-5_13' => '定位胆-5_13',
+	'poscode-5_14' => '定位胆-5_14',
+	'poscode-5_15' => '定位胆-5_15',
+	'poscode-5_16' => '定位胆-5_16',
+	'poscode-5_17' => '定位胆-5_17',
+	'poscode-5_18' => '定位胆-5_18',
+	'poscode-5_19' => '定位胆-5_19',
+	'poscode-5_20' => '定位胆-5_20',
+
+	'poscode-6_11' => '定位胆-6_11',
+	'poscode-6_12' => '定位胆-6_12',
+	'poscode-6_13' => '定位胆-6_13',
+	'poscode-6_14' => '定位胆-6_14',
+	'poscode-6_15' => '定位胆-6_15',
+	'poscode-6_16' => '定位胆-6_16',
+	'poscode-6_17' => '定位胆-6_17',
+	'poscode-6_18' => '定位胆-6_18',
+	'poscode-6_19' => '定位胆-6_19',
+	'poscode-6_20' => '定位胆-6_20',
+
+	'poscode-7_11' => '定位胆-7_11',
+	'poscode-7_12' => '定位胆-7_12',
+	'poscode-7_13' => '定位胆-7_13',
+	'poscode-7_14' => '定位胆-7_14',
+	'poscode-7_15' => '定位胆-7_15',
+	'poscode-7_16' => '定位胆-7_16',
+	'poscode-7_17' => '定位胆-7_17',
+	'poscode-7_18' => '定位胆-7_18',
+	'poscode-7_19' => '定位胆-7_19',
+	'poscode-7_20' => '定位胆-7_20',
+
+	'poscode-8_11' => '定位胆-8_11',
+	'poscode-8_12' => '定位胆-8_12',
+	'poscode-8_13' => '定位胆-8_13',
+	'poscode-8_14' => '定位胆-8_14',
+	'poscode-8_15' => '定位胆-8_15',
+	'poscode-8_16' => '定位胆-8_16',
+	'poscode-8_17' => '定位胆-8_17',
+	'poscode-8_18' => '定位胆-8_18',
+	'poscode-8_19' => '定位胆-8_19',
+	'poscode-8_20' => '定位胆-8_20',
+
+	//广西快乐10
+	'定位胆-1_1' => 'poscode-1_1',
+	'定位胆-1_2' => 'poscode-1_2',
+	'定位胆-1_3' => 'poscode-1_3',
+	'定位胆-1_4' => 'poscode-1_4',
+	'定位胆-1_5' => 'poscode-1_5',
+	'定位胆-1_6' => 'poscode-1_6',
+	'定位胆-1_7' => 'poscode-1_7',
+	'定位胆-1_8' => 'poscode-1_8',
+	'定位胆-1_9' => 'poscode-1_9',
+	'定位胆-1_10' => 'poscode-1_10',
+	'定位胆-1_11' => 'poscode-1_11',
+	'定位胆-1_12' => 'poscode-1_12',
+	'定位胆-1_13' => 'poscode-1_13',
+	'定位胆-1_14' => 'poscode-1_14',
+	'定位胆-1_15' => 'poscode-1_15',
+	'定位胆-1_16' => 'poscode-1_16',
+	'定位胆-1_17' => 'poscode-1_17',
+	'定位胆-1_18' => 'poscode-1_18',
+	'定位胆-1_19' => 'poscode-1_19',
+	'定位胆-1_20' => 'poscode-1_20',
+	'定位胆-1_21' => 'poscode-1_21',
+	'定位胆-2_1' => 'poscode-2_1',
+	'定位胆-2_2' => 'poscode-2_2',
+	'定位胆-2_4' => 'poscode-2_4',
+	'定位胆-2_5' => 'poscode-2_5',
+	'定位胆-2_6' => 'poscode-2_6',
+	'定位胆-2_7' => 'poscode-2_7',
+	'定位胆-2_8' => 'poscode-2_8',
+	'定位胆-2_9' => 'poscode-2_9',
+	'定位胆-2_10' => 'poscode-2_10',
+	'定位胆-2_11' => 'poscode-2_11',
+	'定位胆-2_12' => 'poscode-2_12',
+	'定位胆-2_13' => 'poscode-2_13',
+	'定位胆-2_14' => 'poscode-2_14',
+	'定位胆-2_15' => 'poscode-2_15',
+	'定位胆-2_16' => 'poscode-2_16',
+	'定位胆-2_17' => 'poscode-2_17',
+	'定位胆-2_18' => 'poscode-2_18',
+	'定位胆-2_19' => 'poscode-2_19',
+	'定位胆-2_20' => 'poscode-2_20',
+	'定位胆-2_21' => 'poscode-2_21',
+	'定位胆-3_1' => 'poscode-3_1',
+	'定位胆-3_2' => 'poscode-3_2',
+	'定位胆-3_3' => 'poscode-3_3',
+	'定位胆-3_4' => 'poscode-3_4',
+	'定位胆-3_5' => 'poscode-3_5',
+	'定位胆-3_6' => 'poscode-3_6',
+	'定位胆-3_7' => 'poscode-3_7',
+	'定位胆-3_8' => 'poscode-3_8',
+	'定位胆-3_9' => 'poscode-3_9',
+	'定位胆-3_10' => 'poscode-3_10',
+	'定位胆-3_11' => 'poscode-3_11',
+	'定位胆-3_12' => 'poscode-3_12',
+	'定位胆-3_13' => 'poscode-3_13',
+	'定位胆-3_14' => 'poscode-3_14',
+	'定位胆-3_15' => 'poscode-3_15',
+	'定位胆-3_16' => 'poscode-3_16',
+	'定位胆-3_17' => 'poscode-3_17',
+	'定位胆-3_18' => 'poscode-3_18',
+	'定位胆-3_19' => 'poscode-3_19',
+	'定位胆-3_20' => 'poscode-3_10',
+	'定位胆-3_21' => 'poscode-3_21',
+	'定位胆-4_1' => 'poscode-4_1',
+	'定位胆-4_2' => 'poscode-4_2',
+	'定位胆-4_3' => 'poscode-4_3',
+	'定位胆-4_4' => 'poscode-4_4',
+	'定位胆-4_5' => 'poscode-4_5',
+	'定位胆-4_6' => 'poscode-4_6',
+	'定位胆-4_7' => 'poscode-4_7',
+	'定位胆-4_8' => 'poscode-4_8',
+	'定位胆-4_9' => 'poscode-4_9',
+	'定位胆-4_10' => 'poscode-4_10',
+	'定位胆-4_11' => 'poscode-4_11',
+	'定位胆-4_12' => 'poscode-4_12',
+	'定位胆-4_13' => 'poscode-4_13',
+	'定位胆-4_14' => 'poscode-4_14',
+	'定位胆-4_15' => 'poscode-4_15',
+	'定位胆-4_16' => 'poscode-4_16',
+	'定位胆-4_17' => 'poscode-4_17',
+	'定位胆-4_18' => 'poscode-4_18',
+	'定位胆-4_19' => 'poscode-4_19',
+	'定位胆-4_20' => 'poscode-4_20',
+	'定位胆-4_21' => 'poscode-4_21',
+	'定位胆-5_1' => 'poscode-5_1',
+	'定位胆-5_2' => 'poscode-5_2',
+	'定位胆-5_3' => 'poscode-5_3',
+	'定位胆-5_4' => 'poscode-5_4',
+	'定位胆-5_5' => 'poscode-5_5',
+	'定位胆-5_6' => 'poscode-5_6',
+	'定位胆-5_7' => 'poscode-5_7',
+	'定位胆-5_8' => 'poscode-5_8',
+	'定位胆-5_9' => 'poscode-5_9',
+	'定位胆-5_10' => 'poscode-5_10',
+	'定位胆-5_11' => 'poscode-5_11',
+	'定位胆-5_12' => 'poscode-5_12',
+	'定位胆-5_13' => 'poscode-5_13',
+	'定位胆-5_14' => 'poscode-5_14',
+	'定位胆-5_15' => 'poscode-5_15',
+	'定位胆-5_16' => 'poscode-5_16',
+	'定位胆-5_17' => 'poscode-5_17',
+	'定位胆-5_18' => 'poscode-5_18',
+	'定位胆-5_19' => 'poscode-5_19',
+	'定位胆-5_20' => 'poscode-5_20',
+	'定位胆-5_21' => 'poscode-5_21',
+	'龙虎和-龙' => 'dragon-big',
+	'龙虎和-虎' => 'dragon-small',
+	'龙虎和-和' => 'dragon-equal',
+	'总和大' => 'total-big',
+	'总和小' => 'total-small',
+	'总和单' => 'total-single',
+	'总和双' => 'total-dobule',
+	'总和和' => 'total-equal',
+	'前三-顺子' => 'frontthree-order',
+	'前三-半顺' => 'frontthree-halforder',
+	'前三-杂六' => 'frontthree-mix6',
+	'中三-顺子' => 'middlethree-order',
+	'中三-半顺' => 'middlethree-halforder',
+	'中三-杂六' => 'middlethree-mix6',
+	'后三-顺子' => 'lastthree-order',
+	'后三-半顺' => 'lastthree-halforder',
+	'后三-杂六' => 'lastthree-mix6',
+
+	//游戏英文名对应中文
+    'gpxy28'=>'幸运28(高赔)',
+    'gpjnd28'=>'加拿大28(高赔)',
+	'xy28' => '幸运28(返利)',
+	'jnd28' => '加拿大28(返利)',
+	'jspk10' => '三分PK10',
+	'bjpk10' => '北京PK10',
+	'hlsmpk10' => '欢乐赛马',
+	'hlftpk10' => '欢乐飞艇',
+	'xjssc' => '新疆时时彩',
+	'hljssc' => '黑龙江时时彩',
+	'ynssc' => '云南时时彩',
+	'ynhnssc' => '越南河内时时彩',
+	'cqssc' => '重庆时时彩',
+	'tjkl10' => '天津快乐10',
+	'cqkl10' => '幸运农场',
+	'gxkl10' => '广西快乐10',
+	'gdkl10' => '广东快乐10',
+	'pl3' => '排列三',
+	'fc3d' => '福彩3D',
+	'hlj11x5' => '黑龙江11选5',
+	'js11x5' => '江苏11选5',
+	'sd11x5' => '山东11选5',
+	'gd11x5' => '广东11选5',
+	'threessc' => '三分时时彩',
+	'onessc' => '极速分分彩',
+	'onepk10' => '极速赛车',
+	'luckyft' => '幸运飞艇',
+	'shssl' => '上海时时乐',
+	'tjssc' => '天津时时彩',
+	'sixlottery' => '六合彩',
+	'sfsixlottery' => '极速六合彩',
+	'jskuai3' => '江苏骰宝',
+	'hbkuai3' => '湖北快3',
+	'hnkuai3' => '湖南快3',
+	'ahkuai3' => '安徽快3',
+	'gxkuai3' => '广西快3',
+    'shkuai3' =>'上海快3',
+    'onekuai3' =>'极速快3',
+    'one28' => '极速28',
+    'jxkuai3' => '江西快三',
+    'hebkuai3' => '河北快三',
+	'hs28' => '韩式28',
+	'dj28' => '东京28',
+	'dm28' => '丹麦28',
+	'xjp28' => '新加坡28',
+	'tw28' => '台湾28',
+	'txffc' => '腾讯分分彩',
+	'qqffc' => 'QQ分分彩',
+	'ssq' => '双色球',
+
+	//用户资金描述
+	'user betting' => '%s,期号为:%s,%s投注%s元。订单号%s',
+	'user append' => '%s,期号为:%s,%s追号%s元。订单号%s',
+	'user cancel' => '%s,期号为:%s,%s撤单。订单号%s',
+	'user prize' => '%s,期号为:%s,%s中奖%s元。订单号%s',
+	'user take money' => '%s申请提现%s元。订单号%s',
+	'user charge money' => '%s充值%s元。订单号%s',
+	'user back money' => '%s返水%s元。订单号%s',
+	'user return money' => '%s回水%s元。订单号%s',
+	'user cut money' => '%s管理员扣款%s元。订单号%s',
+	'user empty money' => '%s佣金提成%s元。订单号%s',
+	'frozen money' => '系统冻结%s申请提现金额%s元,订单号%s',
+	'cancel prize' => '%s,%s期重新开奖撤销%s中奖金额%s元。订单号%s',
+	'user finance money' => '%s %s理财金额%s元。订单号%s',
+    //
+    'passsword fail'=>'密码录入失败',
+    'add fail'=>'添加用户失败',
+    'add user fail'=>'注册信息详情错误',
+    ''=>'',
+    //默认用户名
+    'default_grade'=>'普通会员',
+
+    //
+    //邀请码提示信息
+    'invitation code error' =>"邀请码错误",
+    //邀请码提示信息
+    'add new agent error' =>"添加代理关系失败",
+    'root does not exist' => 'root代理不存在',
+    'add agent parent error' => '添加代理上下级失败',
+    'register success' => '注册成功'
+);

+ 33 - 0
Application/Commons/Model/Account.php

@@ -0,0 +1,33 @@
+<?php
+/**
+*------Create thems Model------
+*------SCWPHP  Version 1.0.0------
+*------Dev Model Jions------
+*------Create Time 2017-06-13 18:45:24------
+*/
+namespace App\Commons\Model;
+use \System\Model;
+class Account extends Model {
+
+public $timestamps = false;
+protected $table = 'account';
+
+    private function getFeild($num) {
+        $data = array(
+            '1' => 'id',
+            '2' => 'identity',
+            '3' => 'account',
+            '4' => 'status',
+        );
+        return $data[$num];
+    }
+ 
+    function getinfo($value, $type = 1){
+        $key = $this->getFeild($type);
+        $data = $this->where($key, $value)->first();
+        if (!$data) {
+            return -30203000202; 
+        }
+        return $data->toArray();
+    }
+}

+ 15 - 0
Application/Commons/Model/AccountList.php

@@ -0,0 +1,15 @@
+<?php
+/**
+ *------Create thems Model------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-05 09:03:46------
+ */
+namespace App\Commons\Model;
+use \System\Model;
+
+class AccountList extends Model {
+	public $timestamps = false;
+	protected $table = 'account_list';
+
+}

+ 31 - 0
Application/Commons/Model/Account_bank.php

@@ -0,0 +1,31 @@
+<?php
+/**
+ *------Create thems Model------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-12 02:45:54------
+ */
+namespace App\Commons\Model;
+use \System\Model;
+
+class Account_bank extends Model {
+
+	protected $table = 'account_bank';
+
+    /**
+     * 银行卡查询
+     *
+     * @access public
+     * @param mixed $select 查询字段
+     * @param mixed $where 查询条件
+     * @return array JsonString
+     */
+    public function bankCard ($select, $where) {
+        $result = $this
+            -> select($select)
+            -> where($where)
+            -> first();
+
+        return $result;
+    }
+}

+ 159 - 0
Application/Commons/Model/Account_detailed.php

@@ -0,0 +1,159 @@
+<?php
+/**
+ *------Create thems Model------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-05 09:03:48------
+ */
+namespace App\Commons\Model;
+use App\Commons\Controller\Validation;
+use Illuminate\Support\Facades\DB;
+use \System\Model;
+
+class Account_detailed extends Model {
+
+    protected $table = 'account_detailed';
+    public $timestamps = false;
+
+    public function updateLoginStatus($identity) {
+        $account_detailed = [
+            'last_time' => date('Y-m-d H:i:s'),
+            'last_ip' => GETIP(),
+            'statuss' => 2,
+        ];
+        $this->where("account_identity", $identity)->update($account_detailed);
+    }
+     public function getAccountInfos($ids){
+        $data=$this->select('register_time','cash','account_identity')->whereIn('account_identity',$ids)->get();
+        if(!$data){
+            return -1020020022;
+        }
+        return $data->toArray();
+    }
+
+
+    //理财更新方法、扣除理财金额度
+    protected function UpdateFinancecash($params=array()){
+        /*$params = array(
+            'account_identity' => 'dbf53485-fb80-8d1b-a6bf-2d173fc0033e',
+            'account_name' => 'qwer1234',
+            'available_cash' => 1002200,
+            'money' => 100,
+        );*/
+        if (!isset($params['account_identity']) || !isset($params['available_cash'])) {
+            return -4008;
+        }
+        
+        if (!isset($params['money']) || $params['money'] < 1 || !Validation::isFloat ($params['money'])) {
+            return -2115;
+        }
+
+        $params['money'] = floor ($params['money'] * 100) / 100;
+        //获取充值金额
+        $order_id = OrderID ();
+        
+        $rtype = 12;
+        
+        $omoney = new \Biz\Money\MoneyHandle;
+        $checkCash = $omoney->checkWater($params['account_identity'], $params['available_cash']);
+        if($checkCash<0){
+            return $checkCash;
+        }
+        
+        //更新用户余额、插入资金流水
+        $remarks = sprintf(lang()->get('user finance money'), $params['account_name'],'扣除', $params['money'], $order_id);
+        $pstr = "*" . $params['account_identity'] . "*,*" . $params['money'] . "*,*2*,*" . $rtype . "*,*" . $remarks . "*,*11*";
+        $str = "select update_finance_ids('".$pstr."')";
+
+        //$mdin = lm('Money_details', 'commons')->select($str);
+        $mdin = S('DB')->select($str);
+        $mdin = json_encode($mdin);
+        $mdin = json_decode($mdin,1);
+        if(!$mdin || empty($mdin)){
+            return -2100;
+        }
+        return 1;
+    }
+
+    //理财更新方法、增加理财金
+    protected function backFinance($params=array()){
+        /*$params = array(
+            'account_identity' => 'dbf53485-fb80-8d1b-a6bf-2d173fc0033e',
+            'account_name' => 'qwer1234',
+            'available_cash' => 1002200,
+            'money' => 100,
+        );*/
+        if (!isset($params['account_identity']) || !isset($params['available_cash'])) {
+            return -4008;
+        }
+        
+        if (!isset($params['money']) || $params['money'] < 1 || !Validation::isFloat ($params['money'])) {
+            return -2115;
+        }
+
+        $params['money'] = floor ($params['money'] * 100) / 100;
+        //获取充值金额
+        $order_id = OrderID ();
+        
+        $rtype = 12;
+        
+        $omoney = new \Biz\Money\MoneyHandle;
+        $checkCash = $omoney->checkWater($params['account_identity'], $params['available_cash']);
+        if($checkCash<0){
+            return $checkCash;
+        }
+        
+        //更新用户余额、插入资金流水
+        $remarks = sprintf(lang()->get('user finance money'), $params['account_name'],'增加', $params['money'], $order_id);
+        $pstr = "*" . $params['account_identity'] . "*,*" . $params['money'] . "*,*1*,*" . $rtype . "*,*" . $remarks . "*,*12*";
+        $str = "select update_finance_ids('".$pstr."')";
+
+        //$mdin = lm('Account_detailed', 'commons')->select($str);
+        $mdin = S('DB')->select($str);
+        $mdin = json_encode($mdin);
+        $mdin = json_decode($mdin,1);
+        if(!$mdin || empty($mdin)){
+            return -2100;
+        }
+        return 1;
+    }
+
+    public function getUsernum($where=array()){
+        return $this->where($where)->count();
+    }
+
+    /**
+     * 查询用户详情
+     *
+     * @access public
+     * @param mixed $select 查询字段
+     * @param mixed $where 查询条件
+     * @return array JsonString
+     */
+    public function accountDetailed($select, $where) {
+        $result = $this
+            -> select($select)
+            -> where($where)
+            -> first();
+
+        return $result;
+    }
+
+    /**
+     * 修改用户详情
+     *
+     * @access public
+     * @param mixed $where 查询条件
+     * @param mixed $updateData 修改字段
+     * @return array JsonString
+     */
+    public function updateDetailed($where, $updateData) {
+        $result = $this
+            -> where($where)
+            -> update($updateData);
+
+        return $result;
+    }
+
+
+}

+ 95 - 0
Application/Commons/Model/Account_news.php

@@ -0,0 +1,95 @@
+<?php
+/**
+*------Create thems Model------
+*------SCWPHP  Version 1.0.0------
+*------Dev Model Jions------
+*------Create Time 2017-06-23 09:58:34------
+*/
+namespace App\Commons\Model;
+use \System\Model;
+class Account_news extends Model {
+
+    public $timestamps = false;
+    protected $table = 'account_news';
+
+    /**
+     * 用户消息
+     *
+     * @access public
+     * @param mixed $select 查询字段
+     * @param mixed $where 查询条件
+     * @param mixed $between 查询条件区间     ['money_time' => [$startTime, $endTime], ...]
+     * @param mixed $begin 起始查询位置
+     * @param mixed $pageSize 分页大小
+     * @param mixed $toArray 是否专为数组
+     * @param mixed $orderBy 排序字段
+     * @param mixed $join 关联关系      ['article' => 'oney_buy.info_identity = article.identity', ...]
+     * @return array JsonString
+     */
+    public function accountNews($select, $where = '', $between = '', $begin = '', $pageSize = '', $toArray = 0, $orderBy = ['write_time' => 'desc'], $join = '') {
+        // 查询字段
+        $result = $this -> select($select);
+        // 循环关联
+        if (!empty($join)) {
+            foreach ($join as $key => $value) {
+                $result = $result -> join($key, $value);
+            }
+        }
+        // 查询条件
+        if (!empty($where)) {
+            $result = $result -> where($where);
+        }
+        // 循环获取查询区间
+        if (!empty($between)) {
+            foreach ($between as $key => $value) {
+                $result = $result -> whereBetween($key, $value);
+            }
+        }
+        // 查询起始
+        if (strlen($begin)) {
+            $result = $result -> offset($begin);
+        }
+        // 分页大小
+        if (strlen($pageSize)) {
+            $result = $result -> limit($pageSize);
+        }
+        // 循环排序规则
+        foreach ($orderBy as $key => $value) {
+            $result = $result -> orderBy($key, $value);
+        }
+        // 获取数据
+        $result = $result -> get();
+        if ($toArray) {
+            $result = $result -> toArray();
+        }
+
+        return $result;
+    }
+
+    /**
+     * 用户消息条数
+     *
+     * @access public
+     * @param mixed $where 查询条件
+     * @param mixed $between 查询条件区间
+     * @return array JsonString
+     */
+    public function accountNewsTotal($where, $between) {
+        $result = $this;
+        // 查询条件
+        if (!empty($where)) {
+            $result = $result -> where($where);
+        }
+        // 循环获取查询区间
+        if (!empty($between)) {
+            foreach ($between as $key => $value) {
+                $result = $result -> whereBetween($key, $value);
+            }
+        }
+        // 获取数据
+        $result = $result -> count();
+
+        return $result;
+    }
+
+}

+ 46 - 0
Application/Commons/Model/Account_password.php

@@ -0,0 +1,46 @@
+<?php
+/**
+ *------Create thems Model------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-12 02:29:22------
+ */
+namespace App\Commons\Model;
+use \System\Model;
+
+class Account_password extends Model {
+
+	protected $table = 'account_password';
+	public $timestamps = false;
+
+	/**
+	 * 修改用户密码
+	 *
+	 * @param $identity
+	 * @param $pwdData
+	 */
+	public function updatePassword($identity, $pwdData) {
+		$data = ['account_password' => $pwdData['password'], 'encryption' => $pwdData['encryption']];
+		$this->where('account_identity', $identity)->update($data);
+	}
+    //检测密码
+    function checkPassword($account_identity,$password){
+        $pwd=trim($password);
+        if(empty($pwd)){
+            return -1010010122;
+        }
+        $userInfo=$this->where('account_identity',$account_identity)->first();
+        if(trim($userInfo->account_password)!=md5(md5($userInfo->encryption.$pwd))){
+            return -1010010222;
+        }
+        return 1;
+    }
+    //更新
+    function updateData($data,$account_identity){
+	    $res=$this->where('account_identity',$account_identity)->update($data);
+	    if(!$res){
+	        return -1050050122;//修改失败
+        }
+        return 1;
+    }
+}

+ 22 - 0
Application/Commons/Model/Account_token.php

@@ -0,0 +1,22 @@
+<?php
+/**
+ *------Create thems Model------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-05 09:03:46------
+ */
+namespace App\Commons\Model;
+use \System\Model;
+
+class Account_token extends Model {
+	public $timestamps = false;
+	protected $table = 'account_token';
+	//´úÀíÔø¾­ÔÚÏß
+	protected function getTime($timearea,$agent_id){
+        $count=$this->whereBetween('last_time', $timearea)
+            ->join('agent_child','agent_child.account_identity',$this->table.'.account_identity')
+            ->where('agent_child.agent_identity',$agent_id)
+            ->count();
+        return $count;
+    }
+}

+ 14 - 0
Application/Commons/Model/Band_bank.php

@@ -0,0 +1,14 @@
+<?php
+/**
+ *------Create thems Model------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-12 02:27:26------
+ */
+namespace App\Commons\Model;
+use \System\Model;
+
+class Band_bank extends Model {
+
+	protected $table = 'band_bank';
+}

+ 14 - 0
Application/Commons/Model/Bank.php

@@ -0,0 +1,14 @@
+<?php
+/**
+*------Create thems Model------
+*------SCWPHP  Version 1.0.0------
+*------Dev Model Jions------
+*------Create Time 2017-06-21 16:01:32------
+*/
+namespace App\Commons\Model;
+use \System\Model;
+class Bank extends Model {
+
+public $timestamps = false;
+protected $table = 'bank';
+}

+ 22 - 0
Application/Commons/Model/Banner.php

@@ -0,0 +1,22 @@
+<?php
+/**
+*------Create thems Model------
+*------SCWPHP  Version 1.0.0------
+*------Dev Model Jions------
+*------Create Time 2017-06-20 18:41:03------
+*/
+namespace App\Commons\Model;
+use \System\Model;
+class Banner extends Model {
+
+public $timestamps = false;
+protected $table = 'banner';
+
+public function getBanner($where){
+        $data= lm($this->table)->where($where)->where('status','1')->orderBy('sort', 'desc')->get();
+        if ($data){
+            $data=$data->toArray();
+        }
+        return $data;
+    }
+}

+ 15 - 0
Application/Commons/Model/Comendnotice.php

@@ -0,0 +1,15 @@
+<?php
+/**
+*------Create thems Model------
+*------SCWPHP  Version 1.0.0------
+*------Dev Model Jions------
+*------Create Time 2017-06-13 18:45:24------
+*/
+namespace App\Commons\Model;
+use \System\Model;
+class Comendnotice extends Model {
+
+    protected $table = 'comendnotice';
+
+
+}

+ 15 - 0
Application/Commons/Model/Dc_user_grade.php

@@ -0,0 +1,15 @@
+<?php
+/**
+ *------Create thems Model------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-05 09:03:48------
+ */
+namespace App\Commons\Model;
+use \System\Model;
+
+class Dc_user_grade extends Model {
+
+    protected $table = 'dc_user_grade';
+    public $timestamps = false;
+}

+ 15 - 0
Application/Commons/Model/Logfile.php

@@ -0,0 +1,15 @@
+<?php
+/**
+ *------Create thems Model------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-05 09:03:46------
+ */
+namespace App\Commons\Model;
+use \System\Model;
+
+class Logfile extends Model {
+	public $timestamps = false;
+	protected $table = 'logfile';
+
+}

+ 89 - 0
Application/Commons/Model/Message.php

@@ -0,0 +1,89 @@
+<?php
+/**
+ *------Create thems Model------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-21 06:03:42------
+ */
+
+namespace App\Commons\Model;
+
+use \System\Model;
+
+class Message extends Model
+{
+
+
+    public $timestamps = false;
+    protected $table = 'message';
+
+    //lm("message",'commons')->updateMessage();
+    function updateMessage($sender, $reciver, $title, $content, $type)
+    {
+
+        $data['add_time'] = date ('Y-m-d H:i:s');
+
+        $data['formname'] = $sender;
+        $data['toname'] = $reciver;
+        $data['title'] = $title;
+        $data['type'] = $type;
+        $data['content'] = $content;
+
+        //普通消息
+        if ($data['type'] == 2) {
+            $dataName = explode (',', $data['toname']);
+            foreach ($dataName as $v) {
+                $data['toname'] = $v;
+                $this->addNotice ($data);
+            }
+        }
+        //系统消息
+        if ($data['type'] == 1) {
+            $data['formname'] = 'system';
+            $data['toname'] = 'all';
+            $this->addNotice ($data);
+        }
+
+
+        //系统通知
+        if ($data['type'] == 3) {
+            $data['formname'] = 'notice';
+            $data['toname'] = 'all';
+            $this->addNotice ($data);
+
+        }
+
+        //系统通知
+        if ($data['type'] == 4) {
+            $data['formname'] = 'admin';
+            $data['toname'] = 'admin_all';
+            $this->addNotice ($data);
+
+        }
+
+    }
+
+    //添加公告数据
+    function addNotice($data)
+    {
+
+        $res = lm ('message', 'Commons')->insert ($data);
+
+        if (!$res) {
+            return -6030001222;
+        }
+    }
+
+    public function add($title, $content, $from, $to, $type = 1, $addStatus = 2)
+    {
+        $data = ['title' => $title,
+            'content' => $content,
+            'formname' => $from,
+            'toname' => $to,
+            'add_time' => date ('Y-m-d H:i:s'),
+            'type' => $type,
+            'add_status' => $addStatus
+        ];
+        return self::insert ($data);
+    }
+}

+ 14 - 0
Application/Commons/Model/Message_read.php

@@ -0,0 +1,14 @@
+<?php
+/**
+*------Create thems Model------
+*------SCWPHP  Version 1.0.0------
+*------Dev Model Jions------
+*------Create Time 2017-06-21 06:03:42------
+*/
+namespace App\Commons\Model;
+use \System\Model;
+class Message_read extends Model {
+
+public $timestamps = false;
+protected $table = 'message_read';
+}

+ 60 - 0
Application/Commons/Model/Money_buy.php

@@ -0,0 +1,60 @@
+<?php
+/**
+*------Create thems Model------
+*------SCWPHP  Version 1.0.0------
+*------Dev Model Jions------
+*------Create Time 2019-04-15 16:05:26------
+*/
+namespace App\Commons\Model;
+
+use \System\Model;
+
+class Money_buy extends Model {
+
+    // 对象表
+    protected $table = 'money_buy';
+    public $timestamps = false;
+
+    /**
+     * 投注记录
+     *
+     * @access public
+     * @param mixed $select 查询字段
+     * @param mixed $moneyBuyWhere 查询条件
+     * @param mixed $moneyBuyBetween 查询条件区间
+     * @param mixed $begin 起始查询位置
+     * @param mixed $pageSize 分页大小
+     * @param mixed $orderBy 排序字段
+     * @return array JsonString
+     */
+    public function moneyBuy($select, $moneyBuyWhere, $moneyBuyBetween, $begin, $pageSize, $orderBy = 'money_time') {
+        $result = $this
+            //-> join('article','money_buy.info_identity','=','article.identity')
+            -> select($select)
+            -> where($moneyBuyWhere)
+            -> whereBetween('money_time', $moneyBuyBetween)
+            -> offset($begin)
+            -> limit($pageSize)
+            -> orderBy($orderBy)
+            -> get();
+
+        return $result;
+    }
+
+    /**
+     * 投注记录总数
+     *
+     * @access public
+     * @param mixed $moneyBuyWhere 查询条件
+     * @param mixed $moneyBuyBetween 查询条件区间
+     * @return array JsonString
+     */
+    public function moneyBuyTotal($moneyBuyWhere, $moneyBuyBetween) {
+        $result = $this
+            -> where($moneyBuyWhere)
+            -> whereBetween('money_time', $moneyBuyBetween)
+            -> count();
+
+        return $result;
+    }
+}

+ 21 - 0
Application/Commons/Model/Money_buy_detail.php

@@ -0,0 +1,21 @@
+<?php
+/**
+*------Create thems Model------
+*------SCWPHP  Version 1.0.0------
+*------Dev Model Jions------
+*------Create Time 2017-06-13 18:45:24------
+*/
+namespace App\Commons\Model;
+use \System\Model;
+class Money_buy_detail extends Model {
+
+    protected $table = 'money_buy_detail';
+
+    public function  getById($id){
+        return  self::get($id);
+    }
+
+
+
+
+}

+ 186 - 0
Application/Commons/Model/Money_buy_match.php

@@ -0,0 +1,186 @@
+<?php
+/**
+*------Create thems Model------
+*------SCWPHP  Version 1.0.0------
+*------Dev Model Jions------
+*------Create Time 2017-06-13 18:45:24------
+*/
+namespace App\Commons\Model;
+
+use \System\Model;
+
+class Money_buy_match extends Model {
+
+    protected $table = 'money_buy_match';
+
+    /**
+     * 投注记录
+     *
+     * @access public
+     * @param mixed $select 查询字段
+     * @param mixed $where 查询条件
+     * @param mixed $orWhere 关联关系      [[['batch_id', '191'], ['batch_id', '186']],[['id', '55'], ['id', '59']]];
+     * @param mixed $begin 起始查询位置
+     * @param mixed $pageSize 分页大小
+     * @param mixed $orderBy 排序字段
+     * @return array JsonString
+     */
+    public function moneyBuyMatch($select, $where = '', $orWhere = '', $begin = '', $pageSize = '', $orderBy = ['batch_id' => 'desc']) {
+        // 查询字段
+        $result = $this -> select($select)
+        ->join('st_odds_code', function ($join) {
+            $join->on('money_buy_match.odds_code', '=','st_odds_code.odds_code')->on('money_buy_match.game_code', '=','st_odds_code.game_code');
+        });
+        // 查询条件
+        if (!empty($where)) {
+            $result = $result -> where($where);
+        }
+        // 循环获取or查询
+        if (!empty($orWhere)) {
+            foreach ($orWhere as $value) {
+                $result = $result -> where(function($query) use ($value) {
+                    foreach ($value as $k => $v) {
+                        if ($k == 0) {
+                            $query = $query -> where([$v[0] => $v[1]]);
+                        } else {
+                            $query = $query -> orWhere([$v[0] => $v[1]]);
+                        }
+                    }
+                });
+            }
+        }
+        // 查询起始
+        if (strlen($begin)) {
+            $result = $result -> offset($begin);
+        }
+
+        // 分页大小
+        if (strlen($pageSize)) {
+            $result = $result -> limit($pageSize);
+        }
+        // 循环排序规则
+        foreach ($orderBy as $key => $value) {
+            $result = $result -> orderBy($key, $value);
+        }
+        // 获取数据
+        $result = $result -> get();
+
+        return $result;
+    }
+
+    /**
+     * 投注记录
+     *
+     * @access public
+     * @param mixed $select 查询字段
+     * @param mixed $where 查询条件
+     * @param mixed $orWhere 关联关系      [[['batch_id', '191'], ['batch_id', '186']],[['id', '55'], ['id', '59']]];
+     * @param mixed $begin 起始查询位置
+     * @param mixed $pageSize 分页大小
+     * @param mixed $orderBy 排序字段
+     * @return array JsonString
+     */
+    public function moneyBuyMatchAll($select, $where = '', $orWhere = '', $begin = '', $pageSize = '', $orderBy = ['batch_id' => 'desc']) {
+        // 查询字段
+        $result = $this -> select($select);
+        // 查询条件
+        if (!empty($where)) {
+            $result = $result -> where($where);
+        }
+        // 循环获取or查询
+        if (!empty($orWhere)) {
+            foreach ($orWhere as $value) {
+                $result = $result -> where(function($query) use ($value) {
+                    foreach ($value as $k => $v) {
+                        if ($k == 0) {
+                            $query = $query -> where([$v[0] => $v[1]]);
+                        } else {
+                            $query = $query -> orWhere([$v[0] => $v[1]]);
+                        }
+                    }
+                });
+            }
+        }
+        // 查询起始
+        if (strlen($begin)) {
+            $result = $result -> offset($begin);
+        }
+
+        // 分页大小
+        if (strlen($pageSize)) {
+            $result = $result -> limit($pageSize);
+        }
+        // 循环排序规则
+        foreach ($orderBy as $key => $value) {
+            $result = $result -> orderBy($key, $value);
+        }
+        // 获取数据
+        $result = $result -> get();
+
+        return $result;
+    }
+
+    /**
+     * 投注记录
+     *
+     * @access public
+     * @param mixed $where 查询条件
+     * @param mixed $orWhere 关联关系      [[['batch_id', '191'], ['batch_id', '186']],[['id', '55'], ['id', '59']]];
+     * @return array JsonString
+     */
+    public function moneyBuyMatchTotal($where = '', $orWhere = '') {
+        // 查询字段
+        $result = $this;
+        // 查询条件
+        if (!empty($where)) {
+            $result = $result -> where($where);
+        }
+        // 循环获取or查询
+        if (!empty($orWhere)) {
+            foreach ($orWhere as $value) {
+                $result = $result -> where(function($query) use ($value) {
+                    foreach ($value as $k => $v) {
+                        if ($k == 0) {
+                            $query = $query -> where([$v[0] => $v[1]]);
+                        } else {
+                            $query = $query -> orWhere([$v[0] => $v[1]]);
+                        }
+                    }
+                });
+            }
+        }
+        // 获取数据
+        $result = $result -> count();
+
+        return $result;
+    }
+
+    public function  getByDetail($Detailid){
+            $ret = $this->where('money_buy_detail_id' ,$Detailid)->find();
+            return $ret;
+    }
+
+    public  function  getByTypeMatch($type,$matchId){
+          $rets = $this->where(['game_code'=>$type,'match_id'=>$matchId])->find();
+          return $rets;
+    }
+
+    //查找某个订单下是否还有未处理完的订单情况
+    public function    FindByTypeOrderResult($type,$OrderId,$result=0){
+            if (is_string($result)){
+                $ret = $this->where(['game_code'=>$type,'order_id'=>$OrderId,'result'=>$result])->find();
+            }else{
+                $ret = $this->where(['game_code'=>$type,'order_id'=>$OrderId])->whereIn('result',$result)->find();
+            }
+            return $ret;
+    }
+
+    public function  getByBatchId($batch_id){
+            $ret = $this->where('batch_id',$batch_id)->find();
+            return $ret;
+    }
+
+
+
+
+}

+ 140 - 0
Application/Commons/Model/Money_buy_simplex.php

@@ -0,0 +1,140 @@
+<?php
+/**
+*------Create thems Model------
+*------SCWPHP  Version 1.0.0------
+*------Dev Model Jions------
+*------Create Time 2019-04-15 16:05:26------
+*/
+namespace App\Commons\Model;
+
+use \System\Model;
+use Illuminate\Support\Facades\DB;
+use DB as DD;
+
+class Money_buy_simplex extends Model {
+
+    // 对象表
+    protected $table = 'money_buy_simplex';
+    public $timestamps = false;
+
+    /**
+     * 投注记录
+     *
+     * @access public
+     * @param mixed $select 查询字段
+     * @param mixed $where 查询条件
+     * @param mixed $between 查询条件区间     ['money_time' => [$startTime, $endTime], ...]
+     * @param mixed $begin 起始查询位置
+     * @param mixed $pageSize 分页大小
+     * @param mixed $toArray 是否专为数组
+     * @param mixed $orderBy 排序字段
+     * @param mixed $join 关联关系      ['article' => 'oney_buy.info_identity = article.identity', ...]
+     * @return array JsonString
+     */
+    public function moneyBuySimplex($select, $where = '', $between = '', $begin = '', $pageSize = '', $toArray = 0, $orderBy = ['money_time' => 'desc'], $join = '') {
+        // 查询字段
+        $result = $this -> select($select);
+        // 循环关联
+        if (!empty($join)) {
+            foreach ($join as $key => $value) {
+                $result = $result -> join($key, $value);
+            }
+        }
+        // 查询条件
+        if (!empty($where)) {
+            $result = $result -> where($where);
+        }
+        // 循环获取查询区间
+        if (!empty($between)) {
+            foreach ($between as $key => $value) {
+                $result = $result -> whereBetween($key, $value);
+            }
+        }
+        // 查询起始
+        if (strlen($begin)) {
+            $result = $result -> offset($begin);
+        }
+        // 分页大小
+        if (strlen($pageSize)) {
+            $result = $result -> limit($pageSize);
+        }
+        // 循环排序规则
+        foreach ($orderBy as $key => $value) {
+            $result = $result -> orderBy($key, $value);
+        }
+        // 获取数据
+        $result = $result -> get();
+        if ($toArray) {
+            $result = $result -> toArray();
+        }
+
+        return $result;
+    }
+
+    /**
+     * 盈亏记录
+     *
+     * @access public
+     * @param mixed $select 查询字段
+     * @param mixed $where 查询条件
+     * @param mixed $between 查询条件区间     ['money_time' => [$startTime, $endTime], ...]
+     * @param mixed $begin 起始查询位置
+     * @param mixed $pageSize 分页大小
+     * @param mixed $toArray 是否专为数组
+     * @param mixed $orderBy 排序字段
+     * @param mixed $join 关联关系      ['article' => 'oney_buy.info_identity = article.identity', ...]
+     * @return array JsonString
+     */
+    public function winLoseRecord($where, $between, $begin = '', $pageSize = '') {
+        $select = ['money_time', 'gain_money', 'money', 'order_id'];
+        $mnyBuyStrMdl = lm('Money_buy_str', "commons");
+        $mnyBuyStrSql = $mnyBuyStrMdl->select($select)->where($where)->whereBetween('money_time', $between);
+        $mnyBuySpxSql = $this
+            ->select($select)
+            ->where($where)
+            ->whereBetween('money_time', $between)
+            ->unionAll($mnyBuyStrSql)
+            ->offset($begin)
+            ->limit($pageSize)
+            ->orderBy('money_time','DESC')
+            ->get();
+        foreach ($mnyBuySpxSql as $key => $value) {
+            if ($value->gain_money >= $value->money) {
+                $mnyBuySpxSql[$key]->money_type = 1;
+                $mnyBuySpxSql[$key]->money = $value->gain_money - $value->money;
+            } else {
+                $mnyBuySpxSql[$key]->money = $value->money - $value->gain_money;
+            }
+        }
+
+        return $mnyBuySpxSql;
+    }
+
+    /**
+     * 盈亏总数
+     *
+     * @access public
+     * @param mixed $select 查询字段
+     * @param mixed $where 查询条件
+     * @param mixed $between 查询条件区间     ['money_time' => [$startTime, $endTime], ...]
+     * @param mixed $begin 起始查询位置
+     * @param mixed $pageSize 分页大小
+     * @param mixed $toArray 是否专为数组
+     * @param mixed $orderBy 排序字段
+     * @param mixed $join 关联关系      ['article' => 'oney_buy.info_identity = article.identity', ...]
+     * @return array JsonString
+     */
+    public function winLoseCount($where, $between) {
+        $select = ['order_id'];
+        $mnyBuyStrMdl = lm('Money_buy_str', "commons");
+        $mnyBuyStrSql = $mnyBuyStrMdl->select($select)->where($where)->whereBetween('money_time', $between);
+        $mnyBuySpxSql = $this
+            ->select($select)
+            ->where($where)
+            ->whereBetween('money_time', $between)
+            ->unionAll($mnyBuyStrSql)
+            ->get();
+
+        return count($mnyBuySpxSql);
+    }
+}

+ 151 - 0
Application/Commons/Model/Money_buy_str.php

@@ -0,0 +1,151 @@
+<?php
+/**
+*------Create thems Model------
+*------SCWPHP  Version 1.0.0------
+*------Dev Model Jions------
+*------Create Time 2019-04-15 16:05:26------
+*/
+namespace App\Commons\Model;
+
+use \System\Model;
+
+class Money_buy_str extends Model {
+
+    // 对象表
+    protected $table = 'money_buy_str';
+    public $timestamps = false;
+
+    /**
+     * 投注记录
+     *
+     * @access public
+     * @param mixed $select 查询字段
+     * @param mixed $where 查询条件
+     * @param mixed $between 查询条件区间     ['money_time' => [$startTime, $endTime], ...]
+     * @param mixed $begin 起始查询位置
+     * @param mixed $pageSize 分页大小
+     * @param mixed $toArray 是否专为数组
+     * @param mixed $orderBy 排序字段
+     * @param mixed $join 关联关系      ['article' => 'oney_buy.info_identity = article.identity', ...]
+     * @return array JsonString
+     */
+    public function moneyBuyStr($select, $where = '', $between = '', $begin = '', $pageSize = '', $toArray = 0, $orderBy = ['money_time' => 'desc'], $join = '') {
+        // 查询字段
+        $result = $this -> select($select);
+        // 循环关联
+        if (!empty($join)) {
+            foreach ($join as $key => $value) {
+                $result = $result -> join($key, $value);
+            }
+        }
+        // 查询条件
+        if (!empty($where)) {
+            $result = $result -> where($where);
+        }
+        // 循环获取查询区间
+        if (!empty($between)) {
+            foreach ($between as $key => $value) {
+                $result = $result -> whereBetween($key, $value);
+            }
+        }
+        // 查询起始
+        if (strlen($begin)) {
+            $result = $result -> offset($begin);
+        }
+        // 分页大小
+        if (strlen($pageSize)) {
+            $result = $result -> limit($pageSize);
+        }
+        // 循环排序规则
+        foreach ($orderBy as $key => $value) {
+            $result = $result -> orderBy($key, $value);
+        }
+        // 获取数据
+        $result = $result -> get();
+        if ($toArray) {
+            $result = $result -> toArray();
+        }
+
+        return $result;
+    }
+
+    /**
+     * 投注记录总数
+     *
+     * @access public
+     * @param mixed $where 查询条件
+     * @param mixed $between 查询条件区间
+     * @return array JsonString
+     */
+    public function moneyBuyStrTotal($where, $between) {
+        $result = $this;
+        // 查询条件
+        if (!empty($where)) {
+            $result = $result -> where($where);
+        }
+        // 循环获取查询区间
+        if (!empty($between)) {
+            foreach ($between as $key => $value) {
+                $result = $result -> whereBetween($key, $value);
+            }
+        }
+        // 获取数据
+        $result = $result -> count();
+
+        return $result;
+    }
+
+    /**
+     * 投注记录联合查询
+     *
+     * @access public
+     * @param mixed $select 查询字段
+     * @param mixed $moneyBuyWhere 查询条件
+     * @param mixed $orderBy 排序字段
+     * @return array JsonString
+     */
+    public function moneyBuyStrUnion($select, $moneyBuyWhere, $orderBy = 'money_time') {
+        if (empty($moneyBuyWhere)) {
+            return;
+        }
+        $count = count($moneyBuyWhere);
+        $result = [];
+        $unionAll = [];
+        foreach ($moneyBuyWhere as $key => $value) {
+            if ($key === 0) {
+                $unionAll[0] = $this
+                    -> select($select)
+                    -> join('st_bet_str','money_buy_str.bet_str_id','=','st_bet_str.id')
+                    -> where(['order_id' => $value]);
+            } elseif ($key + 1 === $count) {
+                $result = $this
+                    -> select($select)
+                    -> join('st_bet_str','money_buy_str.bet_str_id','=','st_bet_str.id')
+                    -> where(['order_id' => $value])
+                    -> unionAll($unionAll[$key - 1])
+                    -> orderBy($orderBy)
+                    -> get();
+            } else {
+                $unionAll[$key] = $this
+                    -> select($select)
+                    -> join('st_bet_str','money_buy_str.bet_str_id','=','st_bet_str.id')
+                    -> unionAll($unionAll[$key - 1])
+                    -> where(['order_id' => $value]);
+            }
+        }
+
+        return $result;
+    }
+
+    /**
+     *
+     * @access public
+     * @param mixed $batch_id 批次ID
+     * @return array JsonString
+     *
+     * */
+     public  function   getByBatchId($batch_id){
+         $result = $this->where(['batch_id',$batch_id])->get();
+         return $result ;
+     }
+}

+ 22 - 0
Application/Commons/Model/Money_details.php

@@ -0,0 +1,22 @@
+<?php
+/**
+*------Create thems Model------
+*------SCWPHP  Version 1.0.0------
+*------Dev Model Jions------
+*------Create Time 2017-06-28 13:05:26------
+*/
+namespace App\Commons\Model;
+use \System\Model;
+class Money_details extends Model {
+
+public $timestamps = false;
+protected $table = 'money_details';
+    function countUser($timearea, $array) {
+        $data = $this->select('account_name')->whereBetween('money_time', $timearea)->whereIn('trade_type', $array)->groupBy('account_name')->get();
+        if (!$data) {
+            return 0;
+        }
+        $data = $data->toArray();
+        return count($data);
+    }
+}

+ 58 - 0
Application/Commons/Model/Money_prize.php

@@ -0,0 +1,58 @@
+<?php
+/**
+*------Create thems Model------
+*------SCWPHP  Version 1.0.0------
+*------Dev Model Jions------
+*------Create Time 2019-04-15 16:05:26------
+*/
+namespace App\Commons\Model;
+
+use \System\Model;
+
+class Money_prize extends Model {
+
+    // 对象表
+    protected $table = 'money_prize';
+    public $timestamps = false;
+
+    /**
+     * 中奖记录
+     *
+     * @access public
+     * @param mixed $prizeRecordWhere 查询条件
+     * @param mixed $prizeRecordBetween 查询条件区间
+     * @param mixed $begin 起始查询位置
+     * @param mixed $pageSize 分页大小
+     * @param mixed $orderBy 排序字段
+     * @return array JsonString
+     */
+    public function prizeRecord($prizeRecordWhere, $prizeRecordBetween, $begin, $pageSize, $orderBy = 'money_time') {
+        $result = $this
+            //-> join('article','money_prize.info_identity','=','article.identity')
+            -> where($prizeRecordWhere)
+            -> whereBetween('money_time', $prizeRecordBetween)
+            -> offset($begin)
+            -> limit($pageSize)
+            -> orderBy($orderBy)
+            -> get();
+
+        return $result;
+    }
+
+    /**
+     * 中奖记录总数
+     *
+     * @access public
+     * @param mixed $prizeRecordWhere 查询条件
+     * @param mixed $prizeRecordBetween 查询条件区间
+     * @return array JsonString
+     */
+    public function prizeRecordTotal($prizeRecordWhere, $prizeRecordBetween) {
+        $result = $this
+            -> where($prizeRecordWhere)
+            -> whereBetween('money_time', $prizeRecordBetween)
+            -> count();
+
+        return $result;
+    }
+}

+ 209 - 0
Application/Commons/Model/Money_recharge.php

@@ -0,0 +1,209 @@
+<?php
+/**
+*------Create thems Model------
+*------SCWPHP  Version 1.0.0------
+*------Dev Model Jions------
+*------Create Time 2017-06-28 15:23:54------
+*/
+namespace App\Commons\Model;
+use Illuminate\Support\Facades\DB;
+use \System\Model;
+class Money_recharge extends Model {
+
+public $timestamps = false;
+protected $table = 'money_recharge';
+    function countRimitUser($timearea) {
+        $data = $this->select('account_identity')->whereBetween('apply_time', $timearea)->where('recharge_type', '汇款')->groupBy('account_identity')->get();
+        if (!$data) {
+            return 0;
+        }
+        $data = $data->toArray();
+        return count($data);
+    }
+
+
+    //充值方法
+    protected function AddRecharge($params=array()){
+        /*$params = array(
+            'account_identity' => 'dbf53485-fb80-8d1b-a6bf-2d173fc0033e',
+            'account_name' => 'qwer1234',
+            'available_cash' => 1002200,
+            'money' => 100,
+            'name' => 'wxe',
+            'type' => '2',
+            'status' => 2,
+            'rate' => '',
+        );*/
+        if (!isset($params['account_identity']) || !isset($params['available_cash'])) {
+            return -4008;
+        }
+        
+        if (!isset($params['money']) || $params['money'] < 1 || !is_numeric($params['money'])) {
+            return -2115;
+        }
+        $name = isset($params['name']) ? ($params['name']) : '';
+
+        $name = strip_tags (trim ($name));
+        $params['money'] = floor ($params['money'] * 100) / 100;
+        //获取充值金额
+        $order_id = OrderID ();
+        
+        $rtype = 6;
+        $rtypename = $this->RtypeName($rtype);
+        $paytypes = $rtypename;  
+        $paytype = $this->RmethodName($params['type']);
+        
+        _beginTransaction();
+        $omoney = new \Biz\Money\MoneyHandle;
+        $checkCash = $omoney->checkWater($params['account_identity'], $params['available_cash']);
+        if($checkCash<0){
+            return $checkCash;
+        }
+        $allmoney = $params['available_cash'] + $params['money'];
+        
+        //插入充值记录信息
+        $remark = isset($params['remark']) ? strip_tags ($params['remark']) : '';
+        $mrrin = $this->addMreRemark($params['name'],$order_id,$params['money'],$remark,date('Y-m-d H:i:s'));
+        if($mrrin<0){
+            _rollBack();
+            return $mrrin;
+        }
+        $rate = isset($params['rate'])?$params['rate']:'';
+        $status = isset($params['status'])?$params['status']:1;
+        //插入充值信息
+        $mrin = $this->addMoney($params,$order_id,$params['money'],$rtypename,$allmoney,$paytype,$status,$rate);
+        if($mrin<0){
+            _rollBack();
+            return $mrin;
+        }
+
+        //更新用户余额、插入资金流水
+        $remarks = sprintf(lang()->get('user charge money'), $params['account_name'], $params['money'], $order_id);
+        $pstr = "*" . $params['account_identity'] . "*,*" . $params['money'] . "*,*1*,*" . $rtype . "*,*" . $remarks . "*,*" . $order_id . "*";
+        $str = "select update_money_ids('".$pstr."')";
+
+        //插入充值流水信息
+        
+        //$mdin = lm('Money_details', 'commons')->select($str);
+        $mdin = S('DB')->select($str);
+        $mdin = json_encode($mdin);
+        $mdin = json_decode($mdin,1);
+        if(!$mdin || empty($mdin)){
+            _rollBack();
+            return -2100;
+        }
+        _commit();
+        return 1;
+    }
+
+    //插入充值记录信息
+    protected function addMreRemark($name,$order_id,$money,$remark,$time){
+        $rechargeRecord = lm ('money_recharge_remark', 'commons')->select ('id')->where ('name', $name)->where ('money', $money)->where ('recharge_time', $time)->first ();
+        if ($rechargeRecord) {
+            return -2050;
+        }
+        $rechareDate = array(
+            'name' => $name,
+            'order_id' => $order_id,
+            'money' => $money,
+            'remark' => $remark,
+            'recharge_time' => $time,
+        );
+        $dataRow = lm ('money_recharge_remark', 'commons')->insert ($rechareDate);
+        if ($dataRow > 0) {
+           return 1;
+        } else {
+           return -2100;
+        }
+    }
+
+    //插入充值信息
+    protected function addMoney($uinfo,$order_id,$money,$rtypename,$allmoney,$paytype,$status,$rate){
+        $rechareInfo = array(
+            'info_identity' => UUID (),
+            'account_identity' => $uinfo['account_identity'],
+            'account_name' => $uinfo['account_name'],
+            'order_id' => $order_id,
+            'money' => $money,
+            'status' => $status,
+            'recharge_type' => $rtypename,
+            'money_cash' => $allmoney,
+            'apply_time' => date ('Y-m-d H:i:s', time ()),
+            'remark' => $paytype,
+            'rate' => $rate,
+        );
+        $res = lm ('money_recharge', 'commons')->insert ($rechareInfo);
+        if ($res > 0) {
+            return 1;
+        } else {
+            return -2100;
+        }
+    }
+
+    //获取充值类型名
+    protected function RtypeName($key){
+        $arr = array(
+            '6' => '在线充值',
+            '11' => '后台加款',
+            '12' => '活动',
+            '13' => '充值赠送',
+            '14' => '汇款',
+        );
+        return $arr[$key];
+    }
+
+    //获取充值方式名
+    protected function RmethodName($key){
+        $arr = [
+            2 => '微信',
+            3 => '支付宝',
+            4 => 'QQ',
+            5 => '银联',
+            6 => '京东',
+            7 => '多合一'
+        ];
+        return $arr[$key];
+    }
+
+    /**
+     * 充值记录
+     *
+     * @access public
+     * @param mixed $rechargeRecordSelect 查询条件字段
+     * @param mixed $rechargeRecordWhere 查询条件
+     * @param mixed $rechargeRecordBetween 查询条件区间
+     * @param mixed $begin 起始查询位置
+     * @param mixed $pageSize 分页大小
+     * @param mixed $orderBy 排序字段
+     * @return array JsonString
+     */
+    public function rechargeRecord($rechargeRecordSelect, $rechargeRecordWhere, $rechargeRecordBetween, $begin, $pageSize, $orderBy = 'apply_time') {
+        $result = $this
+            -> select($rechargeRecordSelect)
+            -> where($rechargeRecordWhere)
+            -> whereBetween('apply_time', $rechargeRecordBetween)
+            -> offset($begin)
+            -> limit($pageSize)
+            -> orderBy($orderBy)
+            -> get();
+
+        return $result;
+    }
+
+    /**
+     * 充值记录总数
+     *
+     * @access public
+     * @param mixed $rechargeRecordWhere 查询条件
+     * @param mixed $rechargeRecordBetween 查询条件区间
+     * @return array JsonString
+     */
+    public function rechargeRecordTotal($rechargeRecordWhere, $rechargeRecordBetween) {
+        $result = $this
+            -> where($rechargeRecordWhere)
+            -> whereBetween('apply_time', $rechargeRecordBetween)
+            -> count();
+
+        return $result;
+    }
+}

+ 97 - 0
Application/Commons/Model/Money_record.php

@@ -0,0 +1,97 @@
+<?php
+/**
+*------Create thems Model------
+*------SCWPHP  Version 1.0.0------
+*------Dev Model Jions------
+*------Create Time 2019-04-16 13:05:26------
+*/
+namespace App\Commons\Model;
+
+use \System\Model;
+
+class Money_record extends Model {
+
+    // 对象表
+    protected $table = 'money_details';
+    public $timestamps = false;
+
+    /**
+     * 盈亏记录
+     *
+     * @access public
+     * @param mixed $moneyRecordSelect 查询参数
+     * @param mixed $moneyRecordWhere 查询条件
+     * @param mixed $moneyRecordBetween 查询条件区间
+     * @param mixed $begin 起始查询位置
+     * @param mixed $pageSize 分页大小
+     * @param mixed $orderBy 排序字段
+     * @return array JsonString
+     */
+    public function moneyRecord($moneyRecordSelect, $moneyRecordWhere, $moneyRecordBetween, $begin, $pageSize, $orderBy = 'money_time') {
+        $result = $this
+            -> select($moneyRecordSelect)
+            -> where($moneyRecordWhere)
+            -> whereBetween('money_time', $moneyRecordBetween)
+            -> offset($begin)
+            -> limit($pageSize)
+            -> orderBy($orderBy)
+            -> get();
+
+        return $result;
+    }
+
+    /**
+     * 盈亏记录总数
+     *
+     * @access public
+     * @param mixed $moneyRecordWhere 查询条件
+     * @param mixed $moneyRecordBetween 查询条件区间
+     * @return array JsonString
+     */
+    public function moneyRecordTotal($moneyRecordWhere, $moneyRecordBetween) {
+        $result = $this
+            -> where($moneyRecordWhere)
+            -> whereBetween('money_time', $moneyRecordBetween)
+            -> count();
+
+        return $result;
+    }
+
+    /**
+     * 盈亏记录
+     *
+     * @access public
+     * @param mixed $moneyRecordSelect 查询参数
+     * @param mixed $moneyRecordWhere 查询条件
+     * @param mixed $moneyRecordBetween 查询条件区间
+     * @param mixed $orWhere or查询
+     * @return array JsonString
+     */
+    public function moneyRecordAll($moneyRecordSelect, $moneyRecordWhere, $moneyRecordBetween, $orWhere=[]) {
+        $result = $this
+            -> select($moneyRecordSelect)
+            -> where($moneyRecordWhere);
+        if ($moneyRecordBetween) {
+            $result = $result-> whereBetween('money_time', $moneyRecordBetween);
+        }
+        if ($orWhere) {
+            // 循环获取or查询.
+            foreach ($orWhere as $value) {
+                $result = $result->where(
+                    function ($query) use ($value) {
+                        foreach ($value as $k => $v) {
+                            if ($k === 0) {
+                                $query = $query->where([$v[0] => $v[1]]);
+                            } else {
+                                $query = $query->orWhere([$v[0] => $v[1]]);
+                            }
+                        }
+                    }
+                );
+            }
+        }
+        $result = $result->get()->toArray();
+
+        return $result;
+    }
+}

+ 107 - 0
Application/Commons/Model/Money_take.php

@@ -0,0 +1,107 @@
+<?php
+/**
+ *------Create thems Model------
+ *------SCWPHP  Version 1.0.0------
+ *------Dev Model Jions------
+ *------Create Time 2017-06-12 02:45:54------
+ */
+namespace App\Commons\Model;
+use \System\Model;
+
+class Money_take extends Model {
+
+	protected $table = 'money_take';
+
+    /**
+     * 提现记录查询
+     *
+     * @access public
+     * @param mixed $select 查询字段
+     * @param mixed $where 查询条件
+     * @param mixed $orderBy 排序
+     * @param mixed $order 顺序
+     * @return array JsonString
+     */
+    public function takeRecord($select, $where, $orderBy = 'apply_time', $order = 'desc') {
+        $result = $this
+            -> select($select)
+            -> where($where)
+            -> orderBy($orderBy, $order)
+            -> first();
+
+        return $result;
+    }
+
+    /**
+     * 提现记录查询
+     *
+     * @access public
+     * @param mixed $select 查询字段
+     * @param mixed $where 查询条件
+     * @param mixed $between 查询区间 demo: ['apply_time' => [2019-04-19 10:46:35, 2019-04-19 10:46:35],'id'=>[99448,99448]];
+     * @param mixed $begin 起始位置
+     * @param mixed $pageSize 分页大小
+     * @param mixed $orderBy 排序 demo: ['apply_time'=>'desc','id'=>'desc']
+     * @return array JsonString
+     */
+    public function moneyTake($select, $where = '', $between = '', $begin = '', $pageSize = '', $orderBy = '') {
+        $result = $this -> select($select);
+        if (!empty($where)) {
+            $result = $result -> where($where);
+        }
+        if (!empty($between)) {
+            foreach ($between as $key => $value) {
+                $result = $result -> whereBetween($key, $value);
+            }
+        }
+        if (count($begin) && isset($pageSize)) {
+            $result = $result -> offset($begin) -> limit($pageSize);
+        }
+        if (!empty($orderBy)) {
+            foreach ($orderBy as $key => $value) {
+                $result = $result -> orderBy($key, $value);
+            }
+        } else {
+            $result = $result -> orderBy('apply_time', 'desc');
+        }
+        $result = $result -> get();
+
+        return $result;
+    }
+
+    /**
+     * 提现记录总数
+     *
+     * @access public
+     * @param mixed $where 查询条件
+     * @param mixed $between 查询条件区间
+     * @return array JsonString
+     */
+    public function moneyTakeTotal($where, $between) {
+        $result = $this;
+        if (!empty($where)) {
+            $result = $result -> where($where);
+        }
+        if (!empty($between)) {
+            foreach ($between as $key => $value) {
+                $result = $result -> whereBetween($key, $value);
+            }
+        }
+        $result = $result -> count();
+
+        return $result;
+    }
+
+    /**
+     * 添加提现记录
+     *
+     * @access public
+     * @param mixed $data 添加的字段
+     * @return array JsonString
+     */
+    public function insertTake($data) {
+        $result = $this -> insert($data);
+
+        return $result;
+    }
+}

Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff