彭俊 6 vuotta sitten
vanhempi
commit
d6d973cdd3

+ 2 - 1
Application/Api/Controller/Account.php

@@ -89,7 +89,6 @@ class Account extends BaseController {
      * token获取用户详情
      */
     public function getAccount() {
-        dd($_SESSION);
         if ($_REQUEST['dbg'] == 1) dd($_SESSION);
         $checkToken = $this->accountManager->checkEffectiveTime();
         if ($checkToken['status'] != 1) {
@@ -236,9 +235,11 @@ class Account extends BaseController {
      */
     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']);
     }

+ 41 - 158
Application/Api/Controller/BetOrder.php

@@ -1,6 +1,6 @@
 <?php
 namespace App\Api\Controller;
-use BaseController\Controller;
+
 use Biz\Money\Moneycopy;
 use Biz\Money\Money;
 use Biz\Account\AccountManager;
@@ -10,143 +10,38 @@ use Biz\Account\AccountManager;
  * User: junghwi
  * Date: 2019/3/21
  */
-class BetOrder extends BaseController{
-
+class Betorder extends BaseController{
     private $order_money = 0; //订单总金额
     private $bet_money = 0; //单个球类投注总金额
-    function init() {
+    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();
     }
-    /*
-     * 投注方法-废弃
-     */
-    public function __bet_order(){
-        $pwd = $_POST['pwd'];
-        $data = [
-            ['game_code'=>'zq','match_id'=>1,'lg_id'=>1,'odds_id'=>'1','bet_amount'=>100,'bet_odds'=>1],
-            ['game_code'=>'zq','match_id'=>1,'lg_id'=>1,'odds_id'=>'1','bet_amount'=>100,'bet_odds'=>1]
-        ];
-        $userInfo = $this->getAgent();//用户信息
-        $bet_amount = 0; //总金额
-        foreach($data as $k => $v){
-            $this->verify_gameType($v['game_code']);
-            $this->verify_match($v['game_code'],$v['match_id']);
-            $this->verify_league($v['game_code'],$v['lg_id']);
-            $this->erify_odds($data['game_code'],$v['odds_id']);
-            if(empty($v['bet_amount'])){
-                Render('', '1002',lang('BetOrder','Api')->get('error-1002'));
-            }
-            if(empty($v['bet_odds'])){
-                Render('', '1003',lang('BetOrder','Api')->get('error-1003'));
-           }
-            $data[$k]['win_amount'] = $v['bet_amount'] * $v['bet_odds'] - $v['bet_amount'];
-            $data[$k]['account_id'] = $userInfo['account_id'];
-            $data[$k]['status'] = 1;
-            $data[$k]['order_number'] = OrderID();
-            $data[$k]['ctime']= $this->time;
-            $data[$k]['utime']= $this->time;
-            $bet_amount += $v['bet_amount'];
-        }
-        //获取用户金额信息
-        $getAccount = $this->MC->getAccount('4ea268f8-fb0f-2b97-dcd8-b7ae68a5c82c');
-        if(!$this->MC->verifyMoney($bet_amount,$getAccount['cash'])){
-            Render('', '1005',lang('BetOrder','Api')->get('error-1005'));
-        }
-        //交易密码验证
-        if(!$this->MC->verifyPayPwd($userInfo['account_identity'],$pwd)){
-            Render('', '1004',lang('BetOrder','Sports')->get('error-1004'));
-        }
-        try {
-            _beginTransaction();//开启事务
-            $extra=[];//扣款信息记录
-            foreach($data as $k => $v){
-                $insert = lm('st_bet_order','Sports')->insert($v);
-                if(!$insert){
-                    Render('','-1005',lang('BetOrder','Api')->get('error-1005'));
-                }
-                $extra['order_number'] = $v['order_number'];
-                $extra['money_type'] = 2;
-                $extra['money_time'] = $v['ctime'];
-                $extra['trade_type'] = 1;
-                $extra['trade_desc'] = $this->MC->getDesc($userInfo['account_id'],$v['bet_amount'],$v['order_number'],1);//描述
-                $extra['reason'] = "";//理由
-                $updateMoney  = $this->MC->updateMoney($userInfo['account_id'],$v['bet_amount'],1,$extra);
-                if($updateMoney!=1){
-                    Render('', $updateMoney,lang('BetOrder','Api')->get($updateMoney));
-                }
-            }
-            _commit();//提交
-            Render('', '1',lang('BetOrder','Api')->get('success'));
-        } catch (Exception $e) {
-            _rollBack();//回滚
-            print $e->getMessage();
-        }
-    }
-    /*
-     * 投注接口
-     */
 
-    public function bet_order(){
+    public function Bet(){
+        $userInfo = $this->getAgent();//获取用户信息
         $data = $_REQUEST['data'];
+//        SELECT * FROM st_zq_odds WHERE "id" = 656437;
+//        $data = [[
+//"bet_amount" => "100",
+//"condition" => "+0/0.5",
+//"game_code" =>  "zq",
+//"match_id" => "3132384",
+//"odds" =>  "0.31",
+//"odds_code" => "concede_size",
+//"odds_id" => 656437,
+//"odds_only"=> "1dee7e98db303852227cf1e0d8085dfb1555617310.3833947"]];
         if(empty($data)){
             Render('', '51029',lang('Errors','Api')->get('error-51029'));
         }
-//        $userInfo =[
-//            "id" => 93985,
-//            "identity"=>"76b04b38-e31b-691b-1eaf-19e8ed1f790a",
-//            "account"=> "181817994081",
-//            "status"=> 1,
-//            "fanshui"=> 1,
-//            "remark"=> "",
-//            "user_type"=> 1,
-//            "account_identity"=> "edfe719d-914b-49b1-3f73-46cae73738c2",
-//            "register_time"=> "2019-04-09 18:16:06",
-//            "register_ip"=>"127.0.0.1",
-//            "last_time"=> "2019-04-12 10:58:12.242624",
-//            "last_ip"=> "127.0.0.1",
-//            "grade"=> 0,
-//            "email"=> "",
-//            "phone"=>"18181799409",
-//            "invitation"=>"",
-//            "available_cash"=> "800.00",
-//            "cash"=>"800.00",
-//            "frozen_cash"=>"0.00",
-//            "open_invitation"=>"93985",
-//            "spread"=>"0",
-//            "placing"=>"0",
-//            "token"=>"lADqQI15550666925cb06f44ad5b6",
-//            "statuss"=>"1",
-//            "ranking"=>null,
-//            "card"=>"5",
-//            "name"=>"junghwi1",
-//            "show"=> "0",
-//            "img_url"=> null,
-//            "qq"=>"",
-//            "register_url"=> "www.weba.com",
-//            "last_url"=> "www.weba.com",
-//            "group_code"=> "0,1,",
-//            "group_name"=> "|普通会员|",
-//            "parent_id"=> null,
-//            "parent_path"=> null,
-//            "level"=> 2,
-//            "finance_cash"=> null,
-//            "img_id"=> null,
-//            "wechat"=> "",
-//            "og_type"=> 1,
-//            "now_game"=> null,
-//            "ip"=>"127.0.0.1",
-//       ];//
-        $userInfo = $this->getAgent();//获取用户信息
         //验证与判断投注了几种
         foreach($data as $k => $v){
             $num = $k + 1;
             $this->verify_gameType($v['game_code'],$num);
-            $this->verify_match($v['game_code'],$v['match_id'],$num);
-            $this->verify_league($v['game_code'],$v['lg_id'],$num);
-            $this->verify_odds($data['game_code'],$v['odds_id'],$v['odds_only'],$v['odds'],$v['condition'],$num);
+            $this->verify_match($v['game_code'],$v['odds_id'],$num);
+//            $this->verify_odds($v['game_code'],$v['odds_id'],$v['odds_only'],$v['odds'],$v['condition'],$num);
             if(empty($v['bet_amount'])){
                 $msg = '第'.$num.'条'.lang('Errors','Api')->get('error-5105');
                 Render([], '5105',$msg);
@@ -217,45 +112,33 @@ class BetOrder extends BaseController{
     }
 
     /**
-     * 验证联赛是否存在
+     * 赛是否存在或结束
      * @param  [type] $game_code 球类代码
-     * @param  [type] $lg_id     联赛ID
+     * @param  [type] $odds_id  赔率ID
      * @param  [type] $num 循环键值
      */
-    public  function verify_league($game_code,$lg_id,$num){
-        if(empty($lg_id)){
-            $msg = '第'.$num.'条'.lang('Errors','Api')->get('error-5104');
-            Render([], '5104',$msg);
+    public  function verify_match($game_code,$odds_id,$num){
+        if(empty($odds_id)){
+            $msg = '第'.$num.'条'.lang('Errors','Api')->get('error-5107');
+            Render([], '5107',$msg);
         }
         //根据球类代码 获取相关model
         $models = getModels($game_code);
-        $model_league = $models['model_match'];
-        $info = lm($model_league,'Sports')->where('id',$lg_id)->first();
-        if(empty($info)){
-            $msg = '第'.$num.'条'.lang('Errors','Api')->get('error-5104');
-            Render([], '5104',$msg);
-        }
-        return $info;
-    }
-
-    /**
-     * 验证赛事是否存在
-     * @param  [type] $game_code 球类代码
-     * @param  [type] $match_id  赛事ID
-     * @param  [type] $num 循环键值
-     */
-    public  function verify_match($game_code,$match_id,$num){
-        if(empty($match_id)){
+        $model_odds = $models['model_odds'];
+        $model_match = $models['model_match'];
+        $info = lm($model_match,'Sports')
+              ->join($model_odds,$model_odds.'.match_id',$model_match.'.match_id')
+              ->select($model_match.'.status')
+              ->where($model_odds.'.id',$odds_id)
+              ->first();
+        if(!$info){
             $msg = '第'.$num.'条'.lang('Errors','Api')->get('error-5103');
             Render([], '5103',$msg);
         }
-        //根据球类代码 获取相关model
-        $models = getModels($game_code);
-        $model_match = $models['model_match'];
-        $info = lm($model_match,'Sports')->where('match_id',$match_id)->first();
-        if(empty($info)){
-            $msg = '第'.$num.'条数据'.lang('Errors','Api')->get('error-5103');
-            Render([], '5103',$msg );
+        $info->toarray();
+        if($info['status'] == 2){
+            $msg = '第'.$num.'条'.lang('Errors','Api')->get('error-5108');
+            Render([], '5108',$msg);
         }
         return $info;
     }
@@ -281,10 +164,10 @@ class BetOrder extends BaseController{
     /**
      * 验证赔率是否存在
      * @param  [type] $game_code 球类代码
-     *  @param  [type] $odds_id 赔率ID
+     *  @param  [type] $odds_id 赔率IDkk
      */
     public function verify_odds($game_code,$odds_id,$odds_only,$odds,$condition,$num){
-        if(empty($odds_id)||$odds_only||$condition||$odds){
+        if(empty($odds_id)||empty($odds_only)||empty($condition)||empty($odds)){
             $msg = '第'.$num.'条数据'.lang('Errors','Api')->get('error-7029');
             Render([], '7029', $msg);
         }
@@ -293,22 +176,22 @@ class BetOrder extends BaseController{
         $model_odds = $models['model_odds'];
         $model_odds_record = $models['model_odds_record'];
         $info = lm($model_odds,'Sports')
-            ->join($model_odds_record,$model_odds_record.'.odds_only',$model_odds.'.odds_only')
+            ->leftjoin($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(!$info){
             $msg = '第'.$num.'条数据'.lang('Errors','Api')->get('error-7029');
-            Render([], '7029', $msg);
+            Render([], '70291', $msg);
         }
         $info->toarray();
         if($odds != $info['odds']){
             $msg = '第'.$num.'条数据'.lang('Errors','Api')->get('error-7029');
-            Render([], '7029', $msg);
+            Render([], '70292', $msg);
         }
         if($condition = $info['condition']){
             $msg = '第'.$num.'条数据'.lang('Errors','Api')->get('error-7029');
-            Render([], '7029', $msg);
+            Render([], '70293', $msg);
         }
         return $info;
     }

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

@@ -14,6 +14,7 @@ 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;
@@ -115,4 +116,27 @@ class UserBuy extends BaseController {
             //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());
+        }
+    }
 }

+ 8 - 1
Application/Api/Lang/Common.php

@@ -8,6 +8,13 @@ return array(
 	'type fail get' => '数据类型缺失',
 	'user does not exist' => '用户不存在',
 	'user does login' => '用户未登录',
-    'welcome'=>'欢迎',
+    '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' => '已提交申请,客服正在审核中',
 );
 ?>

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

@@ -105,6 +105,7 @@ return array(
     'error-2105' => '没有对应转账卡信息,不能提交!',
     'error-2111' => '未获取到支付接口信息',
     'error-2112' => '提现金额少于100',
+    'error-2114' => '该银行卡未绑定',
     'error-2115' => '获取金额失败',
     'error-2116' => '投注id缺失',
     'error-2117' => '投注类型缺失',
@@ -240,6 +241,8 @@ return array(
     'error-5104' => '联赛不存在',
     'error-5105' => '投注额为空',
     'error-5106' => '赔率为空',
+    'error-5107' => '赔率ID为空',
+    'error-5108' => '该赛事已结束',
 
     'error-40251' => '请填写代理地址',
     'error-40252' => '请填写开户人姓名',
@@ -252,6 +255,7 @@ return array(
     'error-40451' => '你还未绑定银行卡',
     'error-141313' => '申请失败,请重试',
     'error-40452' => "您的代理于 %s 时间提交申请,客服正在审核中",
+    'error-40453' => "已提交申请,客服正在审核中",
     'error-2255' => '操作失败',
     'error-2345' => '金额不足',
     'error-2354' => '申请失败',

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

@@ -0,0 +1,126 @@
+<?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'));
+        }
+        //验证交易密码
+        $payPasswordWhere['account_identity'] = $userInfo['identity'];
+        $payPasswordSelect = ['encryption'];
+        $payPassword = lm('pay_password', "commons");
+        // 获取加密盐值
+        $accountPwdInfo = $payPassword -> payPassword($payPasswordSelect, $payPasswordWhere);
+        $pwd = $_POST['payPassword'];
+        $encryptionPwd = md5(md5($accountPwdInfo["encryption"] . $pwd));
+        $verifyPayPwdWhere['account_identity'] = $userInfo['identity'];
+        $verifyPayPwdWhere['pay_password'] = $encryptionPwd;
+        $verifyPayPwdSelect = ['id'];
+        // 验证支付密码
+        $verifyPayPwd = $payPassword -> payPassword($verifyPayPwdSelect, $verifyPayPwdWhere);
+        if (!$verifyPayPwd['id']) {
+            Render([], '2020', lang('Common','Api') -> get('payment password error'));
+        }
+        // 用户银行卡
+        $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'));
+        }
+    }
+
+}

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

@@ -11,4 +11,21 @@ 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;
+    }
 }

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

@@ -122,5 +122,38 @@ class Account_detailed extends Model {
         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;
+    }
+
 
 }

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

@@ -0,0 +1,47 @@
+<?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 $data 添加的字段
+     * @return array JsonString
+     */
+    public function insertTake ($data) {
+        $result = $this -> insert($data);
+
+        return $result;
+    }
+}

+ 18 - 1
Application/Commons/Model/Pay_password.php

@@ -8,5 +8,22 @@
 namespace App\Commons\Model;
 use \System\Model;
 class Pay_password extends Model {
-protected $table = 'pay_password';
+    protected $table = 'pay_password';
+
+    /**
+     * 支付密码查询
+     *
+     * @access public
+     * @param mixed $select 查询字段
+     * @param mixed $where 查询条件
+     * @return array JsonString
+     */
+    public function payPassword ($select, $where) {
+        $result = $this
+            -> select($select)
+            -> where($where)
+            -> first();
+
+        return $result;
+    }
 }

+ 15 - 0
Application/Commons/Model/Wagent_log.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 Wagent_log extends Model {
+
+    protected $table = 'wagent_log';
+
+
+}

+ 3 - 2
Application/InApi/Controller/Index.php

@@ -130,6 +130,7 @@ class Index extends Controller {
 
     //调试地址生成用
     public function  makeurl(){
+
         $remotip = $_SERVER['REMOTE_ADDR'];
         if (!($remotip =='127.0.0.1' || substr($remotip,0,7) == '192.168')){
             //只能在内网调试使用
@@ -150,8 +151,8 @@ class Index extends Controller {
         $string = implode ('$',$strArr);
 	    $key = md5(base64_encode($string).'58f306c11e6a9d4cc74723bb76b17500');
 
-	    //$url = 'http://sports.5gogo.com/Inapi-index/dobusiness?params='.base64_encode($string).'&Key='.$key;
-        $url = 'http://www.kaiyou-dev.com/Inapi-index/dobusiness?params='.base64_encode($string).'&Key='.$key;
+	    $url = 'http://sports.5gogo.com/InApi-index/dobusiness?params='.base64_encode($string).'&Key='.$key;
+        //$url = 'http://www.kaiyou-dev.com/Inapi-index/dobusiness?params='.base64_encode($string).'&Key='.$key;
         Render(['url'=>$url],1,'success');
 
     }

+ 0 - 149
Application/Sports/Controller/BetOrder.php

@@ -1,149 +0,0 @@
-<?php
-namespace App\Sports\Controller;
-use BaseController\Controller;
-use Biz\Money\Moneycopy;
-/*
- * Class Register
- * @package App\Sports\Controller
- * User: junghwi
- * Date: 2019/3/21
- */
-class BetOrder extends Controller{
-
-    function init() {
-        $this->accountInfo = $_SESSION['newdevice'];//
-        $this->time = date('Y-m-d H:i:s',time());
-    }
-
-    public function bet_order(){
-        dd($_SESSION);die;
-        //会员ID
-        $account_id = "1";
-        if(empty($account_id)){
-            Render('','4001',lang('Errors','Sports')->get('error-4001'));
-        }
-        $data = [
-            ['game_code'=>'zq','match_id'=>1,'lg_id'=>1,'odds_id'=>'1','bet_amount'=>100,'bet_odds'=>1],
-            ['game_code'=>'zq','match_id'=>1,'lg_id'=>1,'odds_id'=>'1','bet_amount'=>100,'bet_odds'=>1]
-        ];
-        //支付密码
-        $pwd = $_POST['pwd'];
-        //总金额
-        $bet_amount = 0;
-        //扣款信息
-        $extra=[];
-        foreach($data as $k => $v){
-            self::verify_gameType($v['game_code']);
-            self::verify_match($v['game_code'],$v['match_id']);
-            self::verify_league($v['game_code'],$v['lg_id']);
-            self::verify_odds($data['game_code'],$v['odds_id']);
-            if(empty($v['bet_amount'])){
-                Render('', '1002',lang('BetOrder','Sports')->get('error-1002'));
-            }
-            if(empty($v['bet_odds'])){
-                Render('', '1003',lang('BetOrder','Sports')->get('error-1003'));
-           }
-            $data[$k]['win_amount'] = $v['bet_amount'] * $v['bet_odds'] - $v['bet_amount'];
-            $data[$k]['account_id'] = $account_id;
-            $data[$k]['status'] = 1;
-            $data[$k]['order_number'] = OrderID();
-            $data[$k]['ctime']= $this->time;
-            $data[$k]['utime']= $this->time;
-            $bet_amount += $v['bet_amount'];
-//            $extra=[
-//                ''
-//            ];
-        }
-        $MC =  new Moneycopy();
-        //交易密码验证
-        if(!$MC->verifyPayPwd('4ea268f8-fb0f-2b97-dcd8-b7ae68a5c82c',$pwd)){
-            Render('', '1004',lang('BetOrder','Sports')->get('error-1004'));
-        }
-        //获取用户金额信息
-        $getAccount = $MC->getAccount('4ea268f8-fb0f-2b97-dcd8-b7ae68a5c82c');
-        if(!$MC->verifyMoney($bet_amount,$getAccount['cash'])){
-            Render('', '1005',lang('BetOrder','Sports')->get('error-1005'));
-        }
-        try {
-            _beginTransaction();//开启事务
-            $insert = lm('st_bet_order','Sports')->insert($data);
-            if(!$insert){
-                Render('','-1005',lang('BetOrder','Sports')->get('error-1005'));
-            }
-            $updateMoney  = $MC->updateMoney($account_id,$data['bet_amount'],1);
-            if($updateMoney!=1){
-                Render('', $updateMoney,lang('BetOrder','Sports')->get($updateMoney));
-            }
-            _commit();//提交
-        } catch (Exception $e) {
-            _rollBack();//回滚
-            print $e->getMessage();
-        }
-    }
-
-    /*
-     * 验证联赛是否存在
-     */
-    public static function verify_league($game_code,$lg_id){
-        if(empty($lg_id)){
-            Render([], '1001',lang('BetOrder','Sports')->get('error-1001'));
-        }
-        //根据球类代码 获取相关model
-        $models = getModels($game_code);
-        $model_league = $models['model_match'];
-        $info = lm($model_league,'Sports')->where('id',$lg_id)->first();
-        if(empty($info)){
-            Render([], '1001',lang('BetOrder','Sports')->get('error-1001'));
-        }
-        return $info;
-    }
-    /*
-     * 验证赛事是否存在
-     */
-    public static function verify_match($game_code,$match_id){
-        if(empty($match_id)){
-            Render([], '1001', lang('BetOrder','Sports')->get('error-1001'));
-        }
-        //根据球类代码 获取相关model
-        $models = getModels($game_code);
-        $model_match = $models['model_match'];
-        $info = lm($model_match,'Sports')->where('match_id',$match_id)->first();
-        if(empty($info)){
-            Render([], '1001', lang('BetOrder','Sports')->get('error-1001'));
-        }
-        return $info;
-    }
-    /*
-     * 验证球类是否存在
-     */
-    public static function verify_gameType($game_code){
-        if(empty($game_code)){
-            Render([], '1001', lang('BetOrder','Sports')->get('error-1001'));
-        }
-        $info = lm('GameType','Sports')->where('game_code',$game_code)->first();
-        if(empty($info)){
-            Render([], '1001', lang('BetOrder','Sports')->get('error-1001'));
-        }
-        return $info;
-    }
-
-    /*
-     * 验证赔率是否存在
-     */
-    public static function verify_odds($game_code,$odds_id){
-        if(empty($odds_id)){
-            Render([], '1001', lang('BetOrder','Sports')->get('error-1001'));
-        }
-        //根据球类代码 获取相关model
-        $models = getModels($game_code);
-        $model_odds = $models['model_odds'];
-        $info = lm($model_odds,'Sports')->where('id',$odds_id)->first();
-        if(empty($info)){
-            Render([], '1001', lang('BetOrder','Sports')->get('error-1001'));
-        }
-        return $info;
-    }
-
-
-}
-

+ 6 - 3
Biz/Account/AccountManager.php

@@ -281,7 +281,7 @@ class AccountManager {
      * @return int
      */
     public function refreshToken() {
-        $str_token = $_GET['token'] ? trim($_GET['token']) : '';
+        $str_token = $_POST['token'] ? trim($_POST['token']) : '';
         $token = new TokenManager();
         $userInfo = $token->getAccountInfo($str_token);
         if (count($userInfo) > 0) {
@@ -381,14 +381,16 @@ class AccountManager {
      * @throws \Exception
      */
     public function getCurrentUser() {
-        $token = $_GET['token'];
+        $token = $_POST['token'];
         $token = trim($token, "\"");
+
         $token = trim($token, "'");
+
         $userInfo = lm('account_detailed', 'Commons')->join('account', 'account_detailed.account_identity', '=', 'account.identity')->where('account_detailed.token', $token)->first();
         if (empty($userInfo)) {
             return false;
         }
-        $userInfo->identity = $userInfo->account_identity;
+//        $userInfo->identity = $userInfo->account_identity;
         return $userInfo;
     }
 
@@ -722,6 +724,7 @@ class AccountManager {
         define("OVERTIME", 1800);
 
         if (isCheckToken()) {
+
             $account = $this->getCurrentUser();
             // $identity = $account->account_identity;
 

+ 1 - 1
Biz/Account/Repository/AccountRepository.php

@@ -126,7 +126,7 @@ class AccountRepository {
         }
 		
 		if (!empty($wagent_name)){
-			$accountDetailed['wagent_name'] = $wagent_name,
+			$accountDetailed['wagent_name'] = $wagent_name;
 		}
 		
         $res = lm('account_detailed', 'Commons')->insert($accountDetailed);

+ 62 - 38
Biz/Game/GameLogic.php

@@ -9,7 +9,7 @@
 namespace Biz\Game;
 
 use  Biz\Account\AccountManager;
-use  App\Commons\Model\Money_transfer;
+use  Biz\Game\TranferMoneyLogic ;
 
 class GameLogic
 {
@@ -181,54 +181,49 @@ class GameLogic
             return $ret;
         }
 
-        $type = isset($this->paras['type']) ?  strtoupper(trim($this->paras['type'])) : '';
-        if (!in_array( $type , ['IN','OUT'])){ return $this->makeret(0,'type error!','type error');  }
+        $tlogc = new  TranferMoneyLogic( $accountModel,$this->paras,$this->wagetnModel );
+        $ret = $tlogc->dorun();
 
-        $credit  = isset($this->paras['credit']) ?  floatval(trim($this->paras['credit'])) : 0;
-        if ( $credit <=0 ){   return $this->makeret(0,'credit error','credit error'); }
+        return $ret;
+
+    }
+
+
+    //ConfirmTransferCredit(查询转帐)
+    public function  ConfirmTransferCredit(){
+
+        $accountModel = $this->accountAndPassCheck();
 
-        $billno = isset($this->paras['billno']) ?  strtoupper(trim($this->paras['billno'])) : '';
-        if (empty($billno)){ return $this->makeret(0,'billno empty','billno empty');  }
-        $transferModel = new Money_transfer();
-        $hasexit = $transferModel->findOneByAttr('billno',$billno);
-        if ( $hasexit ){   return $this->makeret(0,'billno exists','billno exists'); }
 
-        $parentinfo = lm('account_detailed', 'commons')->where('account_identity', $accountModel->account_identity)->first();
-        if (empty($parentinfo)) {  return $this->makeret(1,'account_detailed not exists','0');     }
-        $cash = $parentinfo->cash ;
-        if ( $type == 'OUT'  &&  $cash<$credit ){
-            return $this->makeret(0,'no_enough_credit','no_enough_credit');
+        $billno =  isset($this->paras['billno']) ?  trim($this->paras['billno']) : '';
+        if (empty($billno)){
+            $ret = $this->makeret(0,'billno error','0') ;
+            return $ret;
         }
 
-        $transferModel->account_indent = $accountModel->identity;
-        $transferModel->ordernumber = OrderID('transfer_') ;
-        $transferModel->billno = $billno;
-        $transferModel->tradeamount = $credit ;
-        $transferModel->blance = ($type == 'IN') ? $cash + $credit :  $cash - $credit ;
-        $transferModel->type = $type ;
-        $transferModel->tradtype = ($type == 'IN') ? 8 : 9 ;
-        $transferModel->tfrom = 0 ;
-        $transferModel->tto = 0 ;
-        $transferModel->agent_name = $this->wagetnModel->agent_name ;
-        $ret = $transferModel->save();
-
-        if  ($ret){
-            $ret = $this->makeret(1,'success',1) ;
+        $type =  isset($this->paras['type']) ?  strtoupper(trim($this->paras['type'])) : '';
+        if (empty($type) || !in_array($type,['IN','OUT']) ){
+            $ret = $this->makeret(0,'type error','0') ;
+            return $ret;
+        }
+
+        $where = [
+            'account_indent' => $accountModel->identity,
+            'agent_name' => $this->wagetnModel->agent_name,
+            'type' => $type,
+            'billno' => $billno
+        ];
+        $model = lm('Money_transfer','Commons')->where( $where )->first();
+        if ($model){
+            $ret = $this->makeret(1,'success',1);
             return $ret;
         }else{
-            $ret = $this->makeret(0,'false',0) ;
+            $ret = $this->makeret(0,'false',0);
             return $ret;
         }
 
     }
 
-    //ConfirmTransferCredit(查询转帐)
-    public function  ConfirmTransferCredit(){
-
-        $ret = $this->makeret() ;
-        return $ret;
-    }
-
     //TransferGame(进入游戏)
     public function TransferGame(){
 
@@ -247,7 +242,36 @@ class GameLogic
     // GetCashTrade(转帐记录)
     public function   GetCashTrade(){
 
-        $ret = $this->makeret() ;
+        $billno = isset($this->paras['billno']) ?  $this->paras['billno'] : '' ;
+        if (empty($billno)){
+            $ret = $this->makeret(0,'billno empty',0) ;
+            return $ret;
+        }
+
+        $moneyTransferModel = lm('Money_transfer','Commons')->where(['agent_name'=>$this->wagetnModel->agent_name,'billno'=>$billno])->first();
+        if (empty( $moneyTransferModel )){
+            $ret = $this->makeret(0,'no data',0) ;
+            return $ret;
+        }
+        $AccountArray= lm('Account','Commons')->getinfo($moneyTransferModel->account_indent,2);
+        if (empty($AccountArray) ||  !is_array( $AccountArray )){
+            $ret = $this->makeret(0,'account error',0) ;
+            return $ret;
+        }
+
+        $datas = [
+            'Billno'=>$moneyTransferModel->billno,
+            'UserName'=>substr($AccountArray['account'],strlen($this->wagetnModel->agent_pre)),
+            'OrderNumber'=>$moneyTransferModel->billno,
+            'TradeAmount'=>$moneyTransferModel->tradeamount,
+            'Balance'=>$moneyTransferModel->blance,
+            'TradeType'=> trim($moneyTransferModel->type),
+            'From'=>$moneyTransferModel->tfrom,
+            'To'=>$moneyTransferModel->tto,
+            'AddTime'=>$moneyTransferModel->addtime,
+        ];
+
+        $ret = $this->makeret(1,'success',$datas) ;
         return $ret;
     }
 

+ 204 - 0
Biz/Game/TranferMoneyLogic.php

@@ -0,0 +1,204 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Administrator
+ * Date: 2019/4/18
+ * Time: 15:16
+ */
+
+namespace Biz\Game;
+
+use  App\Commons\Model\Money_transfer;
+use  App\Commons\Model\Wagent_log as Wagent_logModel ;
+use  App\Commons\Model\Money_details as Money_detailsModel ;
+
+
+//转账逻辑详细实现
+class TranferMoneyLogic
+{
+    private $accountModel = null ;
+    private $wagentModel = null ;
+    private $transferModel = null ;
+    private $accountDetailModel = null ;
+    private $paras = null ;
+    private $type = null ;
+    private $money = 0 ;
+
+
+    public  function  __construct( $accountModel,$parasArray,$wagetnModel )
+    {
+        $this->accountModel = $accountModel ;
+        $this->wagentModel = $wagetnModel ;
+        $this->paras = $parasArray ;
+    }
+
+    public   function   dorun(){
+        $ret0 = $this->parentCheck() ;
+        if ( $ret0 !== true){
+            return $ret0 ;
+        }
+
+
+        try {
+            _beginTransaction();
+
+            $ret1 =  $this->wagentLogRecord();
+            if (!$ret1){  _rollBack();  return $this->makeret(0,'false_1',0);   }
+
+            $ret2 = $this->wagentRecord();
+            if (!$ret2){  _rollBack();  return $this->makeret(0,'false_2',0);   }
+
+            $ret3 = $this->accountDetailUpdate();
+            if (!$ret3){  _rollBack();  return $this->makeret(0,'false_3',0);   }
+
+            $ret4 = $this->moneyTranferRecord();
+            if (!$ret4){  _rollBack();  return $this->makeret(0,'false_4',0);   }
+
+            $ret5 = $this->moneyDetailInsrt();
+            if (!$ret5){  _rollBack();  return $this->makeret(0,'false_5',0);   }
+
+            _commit();
+            return $this->makeret(1,'success',1);
+
+
+        }catch (\Exception $e){
+            _rollBack();
+            return $this->makeret(0,'false_0'.$e->getMessage(), 0 ) ;
+        }
+
+    }
+
+    //返回数据
+    private function  makeret($status=1,$msg='success',$datas=[]){
+        return [
+            'status'=>$status,
+            'msg'=>$msg,
+            'datas'=>$datas
+        ];
+    }
+
+    //参数检测
+    private function  parentCheck(){
+
+        //IN代表代理账户转入到用户账号       OUT代表用户账号转入到代理账号上
+        $type = isset($this->paras['type']) ?  strtoupper(trim($this->paras['type'])) : '';
+        if (!in_array( $type , ['IN','OUT'])){ return $this->makeret(0,'type error!','type error');  }
+        $this->type = $type ;
+
+        //转账金额不能小于等于0
+        $credit  = isset($this->paras['credit']) ?  floatval(trim($this->paras['credit'])) : 0;
+        if ( $credit <=0 ){   return $this->makeret(0,'credit error','credit error'); }
+        $this->money = $credit ;
+
+        //代理上传的订单号不能为空
+        $billno = isset($this->paras['billno']) ?  trim($this->paras['billno']) : '';
+        if (empty($billno)){ return $this->makeret(0,'billno empty','billno empty');  }
+        //代理上传的订单号不能重复
+        $transferModel = new Money_transfer();
+        $hasexit = $transferModel->findOneByAttr('billno',$billno);
+        if ( $hasexit ){   return $this->makeret(0,'billno exists','billno exists'); }
+        $this->transferModel = $transferModel ;
+
+        //用户详情数据,内有用户余额信息
+        $parentinfo = lm('account_detailed', 'commons')->where('account_identity', $this->accountModel->identity)->first();
+        if (empty($parentinfo)) {  return $this->makeret(1,'account_detailed not exists','0');     }
+        $cash = $parentinfo->cash ;
+        if ( $type == 'OUT'  &&  $cash<$credit ){
+            return $this->makeret(0,'no_enough_credit_user','no_enough_credit');
+        }
+        if (  $type == 'IN' &&  $this->wagentModel->money <$credit ){
+            return $this->makeret(0,'no_enough_credit_agent','no_enough_credit');
+        }
+        $this->accountDetailModel = $parentinfo ;
+
+        return true;
+    }
+
+
+    //代理钱变化日志记录  wageng_log增加
+    private function   wagentLogRecord(){
+        $beforeMoney = intval(trim($this->wagentModel->money)*100);
+        $afterMoney =  ( $this->type == 'IN') ? (($beforeMoney - $this->money*100)/100) : (($beforeMoney + $this->money*100)/100) ;
+
+        $model = new  Wagent_logModel();
+        $model->agent_name = $this->wagentModel->agent_name ;
+        $model->account_identity = $this->accountModel->identity;
+        $model->ordernumber = $this->paras['billno'];
+        $model->credit = $this->money;
+        $model->agent_money_before = $beforeMoney/100;
+        $model->agent_money_after = sprintf("%.2f",$afterMoney) ;
+
+        $ret = $model->save();
+        return    $ret;
+
+    }
+
+    //代理钱更新  wagent表更行
+    private  function  wagentRecord(){
+        $beforeMoney = intval(trim($this->wagentModel->money)*100);
+        $afterMoney =  ( $this->type == 'IN') ? (($beforeMoney - $this->money*100)/100) : (($beforeMoney + $this->money*100)/100) ;
+
+        $this->wagentModel->money = sprintf("%.2f",$afterMoney)   ;
+        $ret =  $this->wagentModel->save();
+        return $ret;
+    }
+
+    //用户余额更新
+    private function accountDetailUpdate(){
+
+        $beforeMoney = intval(trim($this->accountDetailModel->cash)*100 ) ;
+        $afterMoney =  ( $this->type == 'IN') ? (($beforeMoney + $this->money*100)/100) : (($beforeMoney - $this->money*100)/100) ;
+
+        $this->accountDetailModel->cash = sprintf("%.2f",$afterMoney)   ;
+        $ret = $this->accountDetailModel->save();
+
+        return $ret  ;
+
+    }
+
+    //代理转账记录  money_tranfer表增加
+    private function  moneyTranferRecord(){
+
+        $this->transferModel->account_indent = $this->accountModel->identity;
+        $this->transferModel->ordernumber = UUID();
+        $this->transferModel->billno = $this->paras['billno'];
+        $this->transferModel->tradeamount = sprintf("%.2f", $this->money )    ;
+        $this->transferModel->blance = $this->accountDetailModel->cash ;
+        $this->transferModel->type = $this->type ;
+        $this->transferModel->tradtype = ($this->type == 'IN') ? 8 : 9 ;
+        $this->transferModel->tfrom = 0 ;
+        $this->transferModel->tto = 0 ;
+        $this->transferModel->agent_name = $this->wagentModel->agent_name ;
+
+        $ret = $this->transferModel->save();
+
+        return    $ret ;
+
+    }
+
+    //用户流水记录
+    private function  moneyDetailInsrt(){
+
+        $model = new Money_detailsModel();
+        $model->info_identity = UUID();
+        $model->trade_id = $this->paras['billno'] ;
+        $model->account_name = $this->accountModel->account ;
+        $model->account_identity = $this->accountModel->identity ;
+        $model->money = sprintf("%.2f", $this->money )    ; ;
+        $model->money_time = date("Y-m-d H:i:s") ;
+        $model->money_type = ($this->type == 'IN') ?  1 : 2 ;
+        $model->money_cash =  $this->accountDetailModel->cash ;
+        $model->trade_type = ($this->type == 'IN') ?  23 : 24 ;
+        $model->trade_desc = ($this->type == 'IN') ?  '从代理转入': '转出到代理';
+        $model->reason = '代理接口操作';
+        $model->sysetem_user  = 1 ;
+        $model->status = 1 ;
+        $model->out_order_id = $this->transferModel->ordernumber  ;
+        $model->remark = '代理转入转出记录';
+        $ret = $model->save();
+        return $ret ;
+
+    }
+
+
+}

+ 321 - 104
Biz/Match/GetmatchData.php

@@ -7,9 +7,14 @@
  */
 
 namespace Biz\Match;
+use Biz\Match\GetOddsData;
 
 class GetmatchData {
 
+    public function __construct() {
+        $this->getOddsData = new GetOddsData();
+    }
+
     /**
      * @param $ret 提交参数
      * @param $source 数据源条件
@@ -49,10 +54,10 @@ class GetmatchData {
                 if(empty($ret['match_date'])){
                     $match_date = date("Y-m-d");
                 }else{
-                    if($ret['match_date'] == 'other'){
+                    if($ret['match_date'] != 'other'){
                         $match_date = $ret['match_date'];
                     }else{
-                        $match_date = date("Y-m-d");
+                        $match_date = 'other';
                     }
                 }
                 $data = $this->getMorningPlate($source,$models,$where,$lg_id,$search,$match_date);
@@ -67,11 +72,11 @@ class GetmatchData {
                 }
                 if($ret['str_type'] == 2){//冠军盘口
                     $where = getState('StChampion',$model_match);
-                    $data = $this->getChampion($source,$models,$where,$lg_id,$search);
+                    $data = $this->getChampion($source,$models,$where,$lg_id,$search,'StChampion');
                 }
                 break;
             case 'StChampion'://冠军
-                $data = $this->getChampion($source,$models,$where,$lg_id,$search);
+                $data = $this->getChampion($source,$models,$where,$lg_id,$search,$ret['type_code']);
                 break;
             default:
                 throw new \Exception(Render([], '10002', lang('Tips','Sports')->get('PARAM_ERROR')));
@@ -339,7 +344,7 @@ class GetmatchData {
     /**
      * 获取冠军数据
      */
-    public function getChampion($source,$models,$where,$lg_id=0,$search=''){
+    public function getChampion($source,$models,$where,$lg_id=0,$search='',$type_code=''){
 
         //获取model
         $model_odds = $models['model_odds'];
@@ -379,18 +384,18 @@ class GetmatchData {
         }
 
         //获取国家/洲下所有联赛及数量
-        $data = $this->getMatch($source,$model_league,'',$model_odds,$search,$where,'');
+        $data = $this->getMatch($source,$model_league,'',$model_odds,$search,$where,'',$type_code);
         return $data;
     }
 
     /**
      * 获取国家/洲 下联赛
      */
-    public function getMatch($source,$model_league,$model_match='',$model_odds='',$search,$where,$time=''){
+    public function getMatch($source,$model_league,$model_match='',$model_odds='',$search,$where,$time='',$type_code=''){
         //国家下所有联赛
         $country = lm($model_league,"Sports")
             ->leftjoin('st_country','st_country.country_id',$model_league.'.country_id')
-            ->select('st_country.country_id as region_id','st_country.name_chinese as region')
+            ->select('st_country.country_id','st_country.name_chinese as region')
 //            ->select('st_country.country_id as region_id','st_country.name_chinese as region',$model_league.'.lg_id', $model_league.'.name_chinese as league')
             ->distinct('st_country.name_chinese')
             ->where($model_league.'.source',$source['source'])
@@ -400,7 +405,7 @@ class GetmatchData {
         //洲下所有联赛
         $area = lm($model_league,"Sports")
             ->leftjoin('st_area','st_area.id',$model_league.'.area_id')
-            ->select('st_area.id as region_id','st_area.title as region')
+            ->select('st_area.id as area_id','st_area.title as region')
 //            ->select('st_area.id as region_id','st_area.title as region',$model_league.'.lg_id', $model_league.'.name_chinese as league')
             ->distinct('st_area.title')
             ->where($model_league.'.source',$source['source'])
@@ -409,39 +414,33 @@ class GetmatchData {
             ->toArray();
 
 
-        $data = $this->getMatchNum($source,$country,$area,$model_league,$model_match,$model_odds,$where,$search,$time);
+        if($type_code != 'StChampion'){//非冠军赛事
+            $data = $this->getMatchNum($source,$country,$area,$model_league,$model_match,$model_odds,$where,$search,$time);
+        }else{//冠军赛事
+            $data = $this->getMatchStChampionNum($source,$country,$area,$model_league,$model_match,$model_odds,$where,$search,$time);
+        }
 
         return $data;
     }
 
     /**
-     * 获取联赛下赛事/盘口 数量
+     * 获取联赛下赛事 数量
+     * 非冠军盘口
      */
     public function getMatchNum($source,$country,$area,$model_league,$model_match='',$model_odds='',$where,$search,$time='',$type=0){
         //统计国家下联赛-赛事/盘口数量
         if(!empty($country)){
+
             foreach($country as $k => $v) {
                 $country[$k]['league_count'] = lm($model_league, 'Sports')
                     ->select('lg_id', 'name_chinese as league')
                     ->where($source)
-                    ->where('country_id', $v['region_id'])
+                    ->where('country_id', $v['country_id'])
                     ->where($model_league.'.name_chinese','like','%'.$search.'%')
                     ->get()->toarray();
             }
             foreach ($country as $k => $v) {
                 foreach($v['league_count'] as $kk => $vv ){
-                    if(!empty($model_odds)){//冠军玩法,获取赔率盘口数量
-                        $where = getState('StChampion');
-                        $country[$k]['league_count'][$kk]['count'] = lm($model_odds, 'Sports')
-                            ->select("p_code")
-                            ->where($source)
-                            ->where('lg_id',$vv['lg_id'])
-                            ->where($where)
-//                            ->where($model_odds.'.expire_time','>',date("Y-m-d H:i:s"))
-                            ->distinct("p_code")
-                            ->count("p_code");
-                    }
-
                     if(!empty($model_match)){//非冠军玩法,获取联赛下赛事数量
                         if(empty($time)){
                             $country[$k]['league_count'][$kk]['count'] = lm($model_match, 'Sports')
@@ -450,8 +449,8 @@ class GetmatchData {
                                 ->where('lg_id',$vv['lg_id'])
                                 ->where($where)
                                 ->count("*");
-                        }else{
-                            if($time == 'other'){
+                        }else{//今日赛事 下有时间查询
+                            if($time == 'other'){//今日 一周后
                                 $country[$k]['league_count'][$kk]['count'] = lm($model_match, 'Sports')
                                     ->select("match_id")
                                     ->where($source)
@@ -460,13 +459,24 @@ class GetmatchData {
                                     ->where('match_date','>',date("Y-m-d",strtotime("+1weeks",strtotime(date('Y-m-d',time())))))
                                     ->count("*");
                             }else{
-                                $country[$k]['league_count'][$kk]['count'] = lm($model_match, 'Sports')
-                                    ->select("match_id")
-                                    ->where($source)
-                                    ->where('lg_id',$vv['lg_id'])
-                                    ->where($where)
-                                    ->where('match_date','>',date("Y-m-d",strtotime("+1weeks",strtotime(date('Y-m-d',time())))))
-                                    ->count("*");
+                               if($time != date("Y-m-d")){//大于今日
+                                   $country[$k]['league_count'][$kk]['count'] = lm($model_match, 'Sports')
+                                       ->select("match_id")
+                                       ->where($source)
+                                       ->where('lg_id',$vv['lg_id'])
+                                       ->where($where)
+                                       ->where('match_date',$time)
+                                       ->count("*");
+                               }else{//如果是今天,则获取今天未开始
+                                   $country[$k]['league_count'][$kk]['count'] = lm($model_match, 'Sports')
+                                       ->select("match_id")
+                                       ->where($source)
+                                       ->where('lg_id',$vv['lg_id'])
+                                       ->where('is_morningplate','=',1)
+                                       ->where('match_time','>',date("H:i:s", time()))
+                                       ->where('match_date',$time)
+                                       ->count("*");
+                               }
                             }
 
                         }
@@ -484,23 +494,12 @@ class GetmatchData {
                 $area[$k]['league_count'] = lm($model_league, 'Sports')
                     ->select('lg_id', 'name_chinese as league')
                     ->where($source)
-                    ->where('area_id', $v['region_id'])
+                    ->where('area_id', $v['area_id'])
                     ->where($model_league.'.name_chinese','like','%'.$search.'%')
                     ->get()->toarray();
             }
             foreach ($area as $k => $v) {
                 foreach($v['league_count'] as $kk => $vv ){
-                    if(!empty($model_odds)){//冠军玩法,获取赔率盘口数量
-                        $where = getState('StChampion');
-                        $area[$k]['league_count'][$kk]['count'] = lm($model_odds, 'Sports')
-                            ->select("p_code")
-                            ->where($source)
-                            ->where('lg_id',$vv['lg_id'])
-                            ->where($where)
-//                            ->where($model_odds.'.expire_time','>',date("Y-m-d H:i:s"))
-                            ->distinct("p_code")
-                            ->count("p_code");
-                    }
                     if(!empty($model_match)){//非冠军玩法,获取联赛下赛事数量
                         if(empty($time)){
                             $area[$k]['league_count'][$kk]['count'] = lm($model_match, 'Sports')
@@ -510,7 +509,7 @@ class GetmatchData {
                                 ->where($where)
                                 ->count("*");
                         }else {
-                            if ($time == 'other') {
+                            if ($time == 'other') {// 今日 一周后
                                 $area[$k]['league_count'][$kk]['count'] = lm($model_match, 'Sports')
                                     ->select("match_id")
                                     ->where($source)
@@ -518,17 +517,28 @@ class GetmatchData {
                                     ->where($where)
                                     ->where('match_date', '>', date("Y-m-d", strtotime("+1weeks", strtotime(date('Y-m-d', time())))))
                                     ->count("*");
-                            } else {
-                                $area[$k]['league_count'][$kk]['count'] = lm($model_match, 'Sports')
-                                    ->select("match_id")
-                                    ->where($source)
-                                    ->where('lg_id', $vv['lg_id'])
-                                    ->where('match_date','>',date("Y-m-d",strtotime("+1weeks",strtotime(date('Y-m-d',time())))))
-                                    ->where('match_date', $time)
-                                    ->count("*");
+                            } else {//今日 大于今日
+                                if($time != date("Y-m-d")){//如果查询时间不是今天,则大于今天
+                                    $area[$k]['league_count'][$kk]['count'] = lm($model_match, 'Sports')
+                                        ->select("match_id")
+                                        ->where($source)
+                                        ->where('lg_id',$vv['lg_id'])
+                                        ->where($where)
+                                        ->where('match_date',$time)
+                                        ->count("*");
+                                }else{//如果是今天,则获取今天未开始
+                                    $area[$k]['league_count'][$kk]['count'] = lm($model_match, 'Sports')
+                                        ->select("match_id")
+                                        ->where($source)
+                                        ->where('lg_id',$vv['lg_id'])
+                                        ->where('is_morningplate','=',1)
+                                        ->where('match_time','>',date("H:i:s", time()))
+                                        ->where('match_date',$time)
+                                        ->count("*");
+                                }
                             }
                         }
-                        }
+                    }
                     if($area[$k]['league_count'][$kk]['count'] == 0){
                         unset($area[$k]['league_count'][$kk]);
                     }
@@ -546,6 +556,76 @@ class GetmatchData {
         return $data;
     }
 
+    /**
+     * 获取联赛下赛事 数量
+     * 冠军盘口
+     */
+    public function getMatchStChampionNum($source,$country,$area,$model_league,$model_match='',$model_odds='',$where,$search,$time='',$type=0){
+
+        $leagueData = lm($model_league,'Sports')
+            ->select('id','lg_id','name_chinese as league','country_id','area_id')
+            ->get()
+            ->where($source)
+            ->toArray();
+
+        $oddsData = lm($model_odds,'Sports')
+            ->select('id','lg_id','p_code')
+            ->distinct("p_code")//去重
+            ->where($where)
+            ->where($source)
+            ->get()
+            ->toArray();
+
+        //按国家
+        $countryData = [];
+        if(!empty($country) and !empty($leagueData) and($oddsData)){
+            foreach ($country as $k=>$v){
+                if($v['country_id']){
+                    $countryData[$k] = $v;
+                    foreach ($leagueData as $kk=>$vv){
+                        if($v['country_id'] == $vv['country_id']){
+                            $countryData[$k]['league_count'][] = $vv;
+                        }
+                    }
+                }
+            }
+        }
+        //去除无联赛 国家
+        foreach ($countryData as $k=>$v){
+            if(count($v) == 2){
+                unset($countryData[$k]);
+            }
+        }
+
+        //按地区
+        $areaData = [];
+        if(!empty($area) and !empty($leagueData) and($oddsData)){
+            foreach ($area as $k=>$v){
+                if($v['area_id']){
+                    $areaData[$k] = $v;
+                    foreach ($leagueData as $kk=>$vv){
+                        if($v['area_id'] == $vv['area_id']){
+                            $areaData[$k]['league_count'][] = $vv;
+                        }
+                    }
+                }
+            }
+        }
+
+        //去除无联赛 地区
+        foreach ($areaData as $k=>$v){
+            if(count($v) == 2){
+                unset($areaData[$k]);
+            }
+        }
+
+
+        $countryData = array_gj_tt($countryData,$oddsData);
+        $areaData = array_gj_tt($areaData,$oddsData);
+        $data = array_merge($countryData,$areaData);
+        return $data;
+    }
+
     /**
      * 获取联赛下 赛事赔率
      */
@@ -555,8 +635,8 @@ class GetmatchData {
             ->where($source)
             ->where('lg_id',$lg_id)
             ->first();
-        if(!empty($time)){
-            if($time == 'other'){
+        if(!empty($time)){//早盘 按时间查询
+            if($time == 'other'){//早盘 一周后
                 $matchData = lm($model_match,"Sports")
                     ->select($model_match.'.match_id',$model_match.'.tag','match_date',$model_match.'.match_time',$model_match.'.home_team',$model_match.'.guest_team')
                     ->where($source)
@@ -572,20 +652,38 @@ class GetmatchData {
                     ->get()
                     ->toarray();
             }else{
-                $matchData = lm($model_match,"Sports")
-                    ->select($model_match.'.match_id',$model_match.'.tag','match_date',$model_match.'.match_time',$model_match.'.home_team',$model_match.'.guest_team')
-                    ->where($source)
-                    ->where($model_match.'.lg_id',$lg_id)
-                    ->where($where)
-                    ->where('match_date',$time)
-                    ->where(function($query)use ($model_match,$search){
-                        $query->where($model_match.'.home_team','like','%'.$search.'%')
-                            ->orWhere(function($query)use ($model_match,$search) {
-                                $query->where($model_match . '.guest_team', 'like', '%' . $search . '%');
-                            });
-                    })
-                    ->get()
-                    ->toarray();
+                if($time == date('Y-m-d')){//早盘今天
+                    $matchData = lm($model_match,"Sports")
+                        ->select($model_match.'.match_id',$model_match.'.tag','match_date',$model_match.'.match_time',$model_match.'.home_team',$model_match.'.guest_team')
+                        ->where($source)
+                        ->where($model_match.'.lg_id',$lg_id)
+                        ->where('is_morningplate','=',1)
+                        ->where('match_date',$time)
+                        ->where('match_time','>',date("H:i:s", time()))
+                        ->where(function($query)use ($model_match,$search){
+                            $query->where($model_match.'.home_team','like','%'.$search.'%')
+                                ->orWhere(function($query)use ($model_match,$search) {
+                                    $query->where($model_match . '.guest_team', 'like', '%' . $search . '%');
+                                });
+                        })
+                        ->get()
+                        ->toarray();
+                }else{//早盘 今天以后
+                    $matchData = lm($model_match,"Sports")
+                        ->select($model_match.'.match_id',$model_match.'.tag','match_date',$model_match.'.match_time',$model_match.'.home_team',$model_match.'.guest_team')
+                        ->where($source)
+                        ->where($model_match.'.lg_id',$lg_id)
+                        ->where($where)
+                        ->where('match_date',$time)
+                        ->where(function($query)use ($model_match,$search){
+                            $query->where($model_match.'.home_team','like','%'.$search.'%')
+                                ->orWhere(function($query)use ($model_match,$search) {
+                                    $query->where($model_match . '.guest_team', 'like', '%' . $search . '%');
+                                });
+                        })
+                        ->get()
+                        ->toarray();
+                }
             }
 
         }else{
@@ -685,24 +783,31 @@ class GetmatchData {
         }
 
         return $data;
-
     }
 
     /**
-     * 获取欧冠 赛事数据
+     * 获取欧冠  各状态赛事数据
      */
     public function getUEFAChampions($source){
         $model = getModels('gj',1);
+
+        $model_league = $model['model_league'];
+        $leagueData = lm($model_league,'Sports')
+            ->select('name_chinese','lg_id','last_time')
+            ->where($model_league.'.source',$source['source'])
+            ->where($model_league.'.name_chinese','欧洲冠军杯')
+            ->first();
         //获取滚球数据
-        $StRollBall = $this->getUEFAMatchData($model,'StRollBall',$source);
-        //获取滚球数据
-        $StToday = $this->getUEFAMatchData($model,'StToday',$source);
-        //获取滚球数据
-        $StMorningPlate = $this->getUEFAMatchData($model,'StMorningPlate',$source);
-        //获取滚球数据
-        $StChampion = $this->getUEFAMatchData($model,'StChampion',$source);
+        $StRollBall = $this->getUEFAStRollBall($model,'StRollBall',$source,$leagueData->lg_id);
+        //获取今日数据
+        $StToday = $this->getUEFAStToday($model,'StToday',$source,$leagueData->lg_id);
+        //获取早盘数据
+        $StMorningPlate = $this->getUEFAStMorningPlate($model,'StMorningPlate',$source,$leagueData->lg_id);
+        //获取冠军盘口数据
+        $StChampion = $this->getUEFAStChampion($model,'StChampion',$source,$leagueData->lg_id,$leagueData->last_time);
 
         $data = [
+            'leagueName'=> $leagueData->name_chinese,
             'StRollBall'=>[//滚球数据
                 'typeName'=>'滚球',
                 'matchNum'=>count($StRollBall),
@@ -729,43 +834,155 @@ class GetmatchData {
     }
 
     /**
-     * 获取欧冠 各状态赛事及赔率数据
+     * 获取欧冠 滚球数据
      */
-    public function getUEFAMatchData($model,$type_code,$source){
-        $model_league = $model['model_league'];
+    public function getUEFAStRollBall($model,$type_code,$source,$lg_id){
         $model_match = $model['model_match'];
         $model_odds = $model['model_odds'];
+        $model_result = $model['model_result'];
 
         $where = getState($type_code,$model_match);
+        $matchData = lm($model_match,"Sports")
+            ->leftjoin($model_result,$model_result.'.match_id',$model_match.'.match_id')
+            ->select($model_match.'.match_id',$model_match.'.tag','match_date',$model_match.'.match_time',$model_match.'.home_team',$model_match.'.guest_team','home_score','guest_score',$model_result.'.match_time as a_time','match_process')
+            ->where($model_match.'.source',$source['source'])
+            ->where($model_match.'.lg_id',$lg_id)
+            ->where($where)
+            ->get()
+            ->toarray();
 
-        if($type_code != 'StChampion'){
-            $matchData = lm($model_match,'Sports')
-                ->leftjoin($model_league,$model_league.'.lg_id',$model_match.'.lg_id')
-                ->select($model_league.'.name_chinese',$model_match.'.match_id','match_date','match_time','tag','home_team','guest_team')
+        foreach($matchData as $kk => $vv){
+            $oddsData= lm($model_match,"Sports")
+                ->leftjoin($model_odds,$model_odds.'.match_id',$model_match.'.match_id')
+                ->select($model_odds.'.id','p_code','odds_code',$model_odds.'.status','odds','condition','sort')
                 ->where($model_match.'.source',$source['source'])
-                ->where($where)
-                ->where($model_league.'.name_chinese','欧洲冠军杯')
+                ->where([$model_odds.'.match_id' => $vv['match_id'],$model_odds.'.type'=>0])
+//                        ->where($model_odds.'.expire_time','>',date("Y-m-d H:i:s"))
+                ->where(function($query)use ($model_odds){
+                    $query->where($model_odds.'.odds_code','concede_home')
+                        ->orWhere(function($query)use ($model_odds){
+                            $query->where($model_odds.'.odds_code','concede_guest');
+                        })
+                        ->orWhere(function($query)use ($model_odds){
+                            $query->where($model_odds.'.odds_code','size_home');
+                        })
+                        ->orWhere(function($query)use ($model_odds){
+                            $query->where($model_odds.'.odds_code','size_guest');
+                        })
+                        ->orWhere(function($query)use ($model_odds){
+                            $query->where($model_odds.'.odds_code','capot_home');
+                        })
+                        ->orWhere(function($query)use ($model_odds){
+                            $query->where($model_odds.'.odds_code','capot_dogfall');
+                        })
+                        ->orWhere(function($query)use ($model_odds){
+                            $query->where($model_odds.'.odds_code','capot_guest');
+                        });
+                })
+                ->get()
+                ->toarray();
 
-                ->get()->toArray();
+//根据 排序 获取 最新让球/大小玩法赔率
+            $sortData = array_column($oddsData,'sort');
+            array_multisort($sortData,SORT_DESC,$oddsData);
 
-            foreach($matchData as $kk => $vv) {
-                $oddsData = lm($model_match, "Sports")
-                    ->leftjoin($model_odds, $model_odds . '.match_id', $model_match . '.match_id')
-                    ->select($model_odds . '.id','p_code', 'odds_code','odds_only', $model_odds . '.status', 'odds', 'condition', 'sort')
-                    ->where($model_match.'.source',$source['source'])
-                    ->where([$model_odds . '.match_id' => $vv['match_id']])
-//                ->where($model_odds.'.expire_time','>',date("Y-m-d H:i:s"))
-                    ->groupBy($model_odds . '.id','p_code', 'odds_code','odds_only', $model_odds . '.status', 'odds', 'condition', 'sort')
-                    ->orderBy($model_odds . '.id','desc')
-                    ->get()
-                    ->toarray();
-                $matchData[$kk]['oddsData'] = $oddsData;
+            $zu = [];
+            foreach ($oddsData as $key1 =>$item1){
+                $zu[$item1['p_code']][] = $item1;
             }
-        }else{
-            $matchData = [];
+            $c_s = array_slice($zu['concede_size'],0,4);//让球/大小 前四条 放入
+            $capot = $zu['capot'];//独赢
+
+            $matchData[$kk]['oddsData'] = [$c_s,$capot];
+
         }
 
         return $matchData;
     }
 
+    /**
+     * 获取欧冠 今日数据
+     */
+    public function getUEFAStToday($model,$type_code,$source,$lg_id){
+        $model_match = $model['model_match'];
+        $model_odds = $model['model_odds'];
+
+        $where = getState($type_code);
+        $matchData = lm($model_match,'Sports')
+            ->select('match_id','match_date','match_time','tag','home_team','guest_team')
+            ->where($model_match.'.source',$source['source'])
+            ->where($where)
+            ->where('lg_id',$lg_id)
+            ->get()->toArray();
+
+        foreach($matchData as $kk => $vv) {
+            $oddsData = lm($model_match, "Sports")
+                ->leftjoin($model_odds, $model_odds . '.match_id', $model_match . '.match_id')
+                ->select($model_odds . '.id','p_code', 'odds_code','odds_only', $model_odds . '.status', 'odds', 'condition', 'sort')
+                ->where($model_match.'.source',$source['source'])
+                ->where([$model_odds . '.match_id' => $vv['match_id']])
+//                ->where($model_odds.'.expire_time','>',date("Y-m-d H:i:s"))
+                ->groupBy($model_odds . '.id','p_code', 'odds_code','odds_only', $model_odds . '.status', 'odds', 'condition', 'sort')
+                ->orderBy($model_odds . '.id','desc')
+                ->get()
+                ->toarray();
+            $matchData[$kk]['oddsData'] = $oddsData;
+        }
+
+        return $matchData;
+    }
+
+    /**
+     * 获取欧冠 早盘数据
+     */
+    public function getUEFAStMorningPlate($model,$type_code,$source,$lg_id){
+        $model_match = $model['model_match'];
+        $model_odds = $model['model_odds'];
+
+        $where = getState($type_code);
+
+        $matchData = lm($model_match,'Sports')
+            ->select('match_id','match_date','match_time','tag','home_team','guest_team')
+            ->where($model_match.'.source',$source['source'])
+            ->where($where)
+            ->where('lg_id',$lg_id)
+            ->get()->toArray();
+
+        $data = $this->getOddsData->getOddsZQ($matchData,$model_odds,$source);
+
+        return $data;
+    }
+
+    /**
+     * 获取 欧冠 冠军盘口数据
+     */
+    public function getUEFAStChampion($model,$type_code,$source,$lg_id,$last_time=''){
+        $model_odds = $model['model_odds'];
+
+        $where = getState($type_code);
+        $championData = lm($model_odds, 'Sports')
+            ->select("id","lg_id","p_code","odds_code","team","odds","sort","status","odds_only")
+//                ->where($model_odds.'.expire_time','>',date("Y-m-d H:i:s"))
+            ->where($source)
+            ->where('lg_id',$lg_id)
+            ->where($where)
+            ->groupBy("id","lg_id","p_code","odds_code","team","odds","sort","status","odds_only")
+            ->get()->toArray();
+
+        //按p_code分组
+        $p_code=array();
+        foreach($championData as $k=>$v){
+            $p_code[$v['p_code']][]=$v;
+        }
+
+        $data = [];
+        foreach ($p_code as $k1=>$v1){
+            foreach ($v1 as $k2=>$v2){
+                $data[$v2['p_code']]['last_time'] =$last_time;
+                $data[$v2['p_code']][$v2['odds_code']][] = $v2;
+            }
+        }
+        return $data;
+    }
+
 }

+ 2 - 1
Biz/Money/Money.php

@@ -37,7 +37,8 @@ class Money {
 	private $money_details = 'money_details';
 	/**
 	 * 资金记录修改
-	 * @param  string $account_identity 用户id
+	 * @param
+	 * string $account_identity 用户id
 	 * @param  string $money            金额
 	 * @param  订单号 $order_id         订单号
 	 * @param  int    $type             交易类型

+ 62 - 8
Library/Common/function.php

@@ -731,7 +731,7 @@ function getState($type_code,$model_match = ''){
                 break;
             case 'StToday'://今日 今日未开始未结束
                 $where = [
-//                    ['is_today', '=', 1],
+                    ['is_today', '=', 1],
 
 //                    ['type', '=', '1'],
 //                    ['status', '<', '2'],
@@ -743,7 +743,8 @@ function getState($type_code,$model_match = ''){
             case 'StMorningPlate'://早盘
                 $where = [
                     ['is_morningplate', '=', 1],
-
+                    ['match_date','>',date("Y-m-d",time())],
+//                    ['match_time','>',date("H:i:s", time())],
 //                    ['type', '=', '2'],
 //                    ['status', '<', '2'],
 //                    ['utime','>',date("Y-m-d").' 00:00:00']
@@ -751,8 +752,9 @@ function getState($type_code,$model_match = ''){
                 break;
             case 'StStringScene'://串场
                 $where = [
-                      ['is_stringscene', '=', 1],
-
+                    ['is_stringscene', '=', 1],
+//                    ['match_date','>',date("Y-m-d",time())],
+//                    ['match_time','>',date("H:i:s", time())],
 //                    ['type', '=', '3'],
 //                    ['status', '<', '2'],
 //                    ['utime','>',date("Y-m-d").' 00:00:00']
@@ -771,7 +773,6 @@ function getState($type_code,$model_match = ''){
             case 'StRollBall'://滚球 正在进行
                 $where = [
                     [$model_match.'.is_rollball','=',1],
-
                     [$model_match.'.match_date','=',date("Y-m-d")],
                     [$model_match.'.match_time','>',date("H:i:s", time()-(90*60))],
                     [$model_match.'.match_time','<',date("H:i:s", time())]
@@ -789,7 +790,7 @@ function getState($type_code,$model_match = ''){
                 break;
             case 'StToday'://今日 今日未开始未结束
                 $where = [
-//                    [$model_match.'.is_today','=',1],
+                    [$model_match.'.is_today','=',1],
 //                    [$model_match.'.type', '=', '1'],
 //                    [$model_match.'.status', '<', '2'],
                     [$model_match.'.match_date','=',date("Y-m-d")],
@@ -805,7 +806,8 @@ function getState($type_code,$model_match = ''){
             case 'StMorningPlate'://早盘
                 $where = [
                     [$model_match.'.is_morningplate','=',1],
-
+                    [$model_match.'.match_date','>',date("Y-m-d",time())],
+//                    [$model_match.'.match_time','>',date("H:i:s", time())],
 //                    [$model_match.'.type', '=', '2'],
 //                    [$model_match.'.status', '<', '2'],
 //                    [$model_match.'.utime','>',date("Y-m-d").' 00:00:00']
@@ -814,7 +816,8 @@ function getState($type_code,$model_match = ''){
             case 'StStringScene'://串场
                 $where = [
                     [$model_match.'.is_stringscene','=',1],
-
+//                    [$model_match.'.match_date','>',date("Y-m-d",time())],
+//                    [$model_match.'.match_time','>',date("H:i:s", time())],
 //                    [$model_match.'.type', '=', '3'],
 //                    [$model_match.'.status', '<', '2'],
 //                    [$model_match.'.utime','>',date("Y-m-d").' 00:00:00']
@@ -859,3 +862,54 @@ function handleArr($data){
     return array_values($hData);
 }
 
+
+/**
+ * @param $arr
+ * @param $key
+ * @return array
+ * 去除二维数组重复项
+ */
+function array_unset_tt($arr,$key){
+    //建立一个目标数组
+    $res = array();
+    foreach ($arr as $value) {
+        //查看有没有重复项
+        if(isset($res[$value[$key]])){
+            unset($value[$key]);  //有:销毁
+        }else{
+            $res[$value[$key]] = $value;
+        }
+    }
+    return $res;
+}
+
+/**
+* 处理冠军盘口 数组结构
+*/
+function array_gj_tt($data,$oddsData){
+    foreach ($data as $k=>&$v){
+        foreach ($v['league_count'] as $kk=>&$vv){
+            foreach ($oddsData as $kkk=>$vvv){
+                if($vv['lg_id'] == $vvv['lg_id']){
+                    $vv['oddsData'][]=$vvv;
+                }
+            }
+
+            if($vv['oddsData']){
+                $vv['oddsData'] = array_unset_tt($vv['oddsData'],'p_code');
+                $vv['count'] = count($vv['oddsData']);
+                unset($vv['oddsData']);
+            }
+
+            if(count($vv) == 5){
+                unset($v['league_count'][$kk]);
+            }
+        }
+        $v['league_count'] =  array_values($v['league_count']);
+        if(empty($v['league_count'])){
+            unset($data[$k]);
+        }
+    }
+
+    return array_values($data);
+}