浏览代码

追加推送

彭俊 6 年之前
父节点
当前提交
c0c0c464d7

+ 8 - 10
Application/Api/Controller/Account.php

@@ -59,6 +59,14 @@ class Account extends BaseController {
         Render($result['data'], $result['status'], $result['msg']);
     }
 
+    /**
+     * 用户修改支付密码
+     */
+    public function resetPayPassword() {
+        $result = $this -> accountManager -> savePayPassword();
+        Render($result['data'], $result['status'], $result['msg']);
+    }
+
     /**
      * 用户注册
      */
@@ -157,16 +165,6 @@ class Account extends BaseController {
         Render($result['data'], $result['status'], $result['msg']);
     }
 
-
-    /**
-     * 修改支付密码
-     */
-    public function resetPayPassword() {
-        $_POST['token'] = isset($_GET['token']) ? $_GET['token'] : '';
-        $result = $this->accountManager->updatePayPassword($_POST);
-        Render($result['data'], $result['status'], $result['msg']);
-    }
-
     /**
      * 申请代理用户
      */

+ 484 - 73
Application/Api/Controller/BetOrder.php

@@ -11,85 +11,239 @@ use Biz\Account\AccountManager;
  * Date: 2019/3/21
  */
 class Betorder extends BaseController{
-    private $order_money = 0; //订单总金额
-    private $bet_money = 0; //单个球类投注总金
+
+    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();
     }
+    /**
+     * 单式串式分类
+     * @param  [array] $res 投注数据
+     * @return  [array] $data
+     *
+     */
+    public function Classify(array $res){
+        if(empty($res)){
+            Render('', '7003',lang('Errors','Api')->get('error-7003'));
+        }
+//        $res = [
+//            [
+//                "type" => 1,
+//                'index' => 0,
+//                'bet_amount'=> 2000
+//            ],
+//            [
+//                "type" => 1,
+//                'index' => 1,
+//                'bet_amount'=> 2000
+//            ],
+//            [
+//                "type" => 1,
+//                'index' => 2,
+//                'bet_amount'=> 2000
+//            ],
+//            [
+//                [
+//                    'id'=>656437,
+//                    'home_team' => "阿尔艾利开罗",
+//                    'guest_team' => '金字塔',
+//                    'name' => '阿尔艾利开罗',
+//                    'odds' => 0.31,
+//                    'p_code' => 'concede_size',
+//                    'ballId' => 'zq',
+//                    'match_id' => 3132384,
+//                    'condition' => '+0/0.5',
+//                    'odds_code' => 'concede_size',
+//                    'bettingTime' => '',
+//                    'odds_only' => '1dee7e98db303852227cf1e0d8085dfb1555617310.3833947',
+//                    'type' => 1
+//                ],
+//                [
+//                    'id'=>656437,
+//                    'home_team' => "阿尔艾利开罗",
+//                    'guest_team' => '金字塔',
+//                    'name' => '阿尔艾利开罗',
+//                    'odds' => 0.31,
+//                    'p_code' => 'concede_size',
+//                    'ballId' => 'zq',
+//                    'match_id' => 3132384,
+//                    'condition' => '+0/0.5',
+//                    'ganame' => 'concede_size',
+//                    'bettingTime' => '',
+//                    'odds_only' => '1dee7e98db303852227cf1e0d8085dfb1555617310.3833947',
+//                    'type' => 1
+//                ],
+//                [
+//                    'id'=>656437,
+//                    'home_team' => "阿尔艾利开罗",
+//                    'guest_team' => '金字塔',
+//                    'name' => '阿尔艾利开罗',
+//                    'odds' => 0.31,
+//                    'p_code' => 'concede_size',
+//                    'ballId' => 'zq',
+//                    'match_id' => 3132384,
+//                    'condition' => '+0/0.5',
+//                    'odds_code' => 'concede_size',
+//                    'bettingTime' => '',
+//                    'odds_only' => '1dee7e98db303852227cf1e0d8085dfb1555617310.3833947',
+//                    'type' => 1
+//                ],
+//            ]
+//        ];
+        $data['single'] = [];//单式
+        $data['bunch'] = [];//串式
+        $last[] = $res[count($res)-1];
+        unset($res[count($res)-1]);
+        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;
+    }
 
-    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"]];
+    /**
+     * 根据赛事ID分组
+     * @param  [array] $data 球类数据
+     * @return  [array] $data
+     */
+    public function Group_ball($data = []){
         if(empty($data)){
-            Render('', '51029',lang('Errors','Api')->get('error-51029'));
+            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] $data 单式投注数据
+     * @param  [array] $userInfo 用户信息
+     * @param  [type] $game_code 球类代码
+     * @return  [int] 1 成功 其他失败
+     */
+    public function Simplex_bet_insert($data,$userInfo,$game_code,$OrderID,$UUID){
+        if(empty($data)||empty($userInfo)||empty($game_code)||empty($OrderID)||empty($UUID)){
+            Render('', '7003',lang('Errors','Api')->get('error-7003'));
+        }
+        foreach($data as $k => $v){
+            $bet_money = 0; //单个球类单条总投注金额
+            $prize_money = 0; //可赢额
+            //统计该球类投注总额
+            foreach($v as $kk => $vv){
+                $bet_money += $vv['bet_amount'];
+                $prize_money += ($vv['odds']-1)*$bet_money;
+            }
+            $order =[
+                'info_identity' => $UUID,
+                'account_name' => $userInfo['account'],
+                'account_identity' => $userInfo['account_identity'],
+                'order_id' => $OrderID,
+                'game_name' => $game_code,
+                'game_no'  => "",
+                'match_id' => $k,
+                'prize_money'=> $prize_money,
+                'money' => $bet_money, //投注金额
+                'codes' => json_encode($v,true), //投注信息json
+                'money_time' => $this->time,
+            ];
+            $insert = lm('MoneyBuy','Api')->insert($order);
+            if(!$insert){
+                Render('','-1005',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));
+            }
+            $bet_money = 0; //初始化
+            $prize_money = 0;
+        }
+    }
+    /**
+     * 单式投注数据处理
+     * @param  [array] $res 单式投注数据
+     * @return  [int] 1 成功 其他失败
+     *
+     */
+    public function Simplex_bet(array $res,array $userInfo){
+        if(empty($res)||empty($userInfo)){
+            Render('', '7003',lang('Errors','Api')->get('error-7003'));
+        }
+        //验证与判断投注了几种
+        foreach($res as $k => $v){
             $num = $k + 1;
-            $this->verify_gameType($v['game_code'],$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);
+            $this->verify_match($v['game_code'],$v['match_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);
             }
-            //所需付款总金额计算
-            $this->order_money += $v['bet_amount'];
+            $this->simplex_money += $v['bet_amount'];
             //根据类型分组
-            if(!isset($data[$v['game_code']])){
-                $data[$v['game_code']][] = $v;
-                unset($data[$k]);
+            if(!isset($res[$v['ballId']])){
+                $res[$v['ballId']][] = $v;
+                unset($res[$k]);
             }else{
-                $data[$v['game_code']][] = $v;
-                unset($data[$k]);
+                $res[$v['ballId']][] = $v;
+                unset($res[$k]);
             }
         }
-        //获取用户金额信息
-        if(!$this->M->verifyMoney($this->order_money,$userInfo['cash'])){
-            Render('', '4204',lang('Errors','Api')->get('error-4204'));
+        $OrderID = OrderID();//生成订单ID
+        $UUID = UUID(); //生成信息ID
+        //球类联赛分类并且插入数据库
+        $zq = $this->Group_ball($res['zq']);
+        if(!empty($zq)) $this->Simplex_bet_insert($zq,$userInfo,'zq',$OrderID,$UUID);
+
+        $lq = $this->Group_ball($res['lq']);
+        if(!empty($lq)) $this->Simplex_bet_insert($zq,$userInfo,'lq',$OrderID,$UUID);
+
+        $bq = $this->Group_ball($res['bq']);
+        if(!empty($bq)) $this->Simplex_bet_insert($zq,$userInfo,'bq',$OrderID,$UUID);
+
+        $wq = $this->Group_ball($res['wq']);
+        if(!empty($wq)) $this->Simplex_bet_insert($zq,$userInfo,'wq',$OrderID,$UUID);
+    }
+
+    public function Bet(){
+        $userInfo = $this->getAgent();//获取用户信息
+        $data = $_REQUEST['data'];
+        if(empty($data)){
+            Render('', '51029',lang('Errors','Api')->get('error-51029'));
         }
+//        $order_money = $this->simplex_money; //+ $xxx;
+//        //获取用户金额信息
+//        if(!$this->M->verifyMoney($order_money,$userInfo['cash'])){
+//            Render('', '4204',lang('Errors','Api')->get('error-4204'));
+//        }
         //执行数据插入
         try {
             _beginTransaction();//开启事务
-            foreach($data as $k => $v){
-                //统计该球类投注总额
-                foreach($v as $kk => $vv){
-                    $this->bet_money += $vv['bet_amount'];
-                }
-                $OrderID = OrderID();
-                $order =[
-                    'info_identity' => UUID(),
-                    'account_name' => $userInfo['account'],
-                    'account_identity' => $userInfo['account_identity'],
-                    'order_id' => $OrderID,
-                    'game_name' => $k,
-                    'game_no'  => "",
-                    'money' => $this->bet_money, //投注金额
-                    'codes' => json_encode($v,true), //投注信息json
-                    'money_time' => $this->time,
-                ];
-                $insert = lm('MoneyBuy','Api')->insert($order);
-                if(!$insert){
-                    Render('','-1005',lang('errors','Api')->get('error-3205'));
-                }
-                $insertMoney  = $this->M->insertMoney($userInfo['account_identity'],$this->bet_money,$OrderID,1,"",$userInfo);
-                if($insertMoney!=1){
-                    Render('', $insertMoney,lang('Errors','Api')->get('error'.$insertMoney));
-                }
-                $this->bet_money = 0;
+            $data = $this->Classify($data);
+            if(!empty($data['single'])){
+                $this->Simplex_bet($data['single'],$userInfo);//单式数据处理
+            }
+            if(!empty($data['bunch'])){
+                $data_all = $data['bunch'][count($data['bunch'])-1];//获取最后一个数组
+                $data['bunch'] = array_pop($data['bunch'][count($data['bunch'])-1]);//删除最后一个元素
+                $this->stringBet($data['bunch'],$data_all,$userInfo);
             }
             _commit();//提交
             Render('', '1',lang('Errors','Api')->get('error-1'));
@@ -116,29 +270,47 @@ class Betorder extends BaseController{
      * @param  [type] $game_code 球类代码
      * @param  [type] $odds_id  赔率ID
      * @param  [type] $num 循环键值
+     * $type_str 串式类型
      */
-    public  function verify_match($game_code,$odds_id,$num){
+    public  function verify_match($game_code,$match_id='',$num,$type_str = ''){
         if(empty($odds_id)){
-            $msg = '第'.$num.'条'.lang('Errors','Api')->get('error-5107');
-            Render([], '5107',$msg);
+            if($type_str){
+                $msg = '串式投注'.$type_str.':第'.$num.'条投注'.lang('Errors','Api')->get('error-5107');
+                Render([], '5107',$msg);
+            }else{
+                $msg = '第'.$num.'条'.lang('Errors','Api')->get('error-5107');
+                Render([], '5107',$msg);
+            }
         }
+
         //根据球类代码 获取相关model
         $models = getModels($game_code);
         $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);
+            ->select('status')
+//            ->where('status', '<', '2')
+//            ->where('us_time','>',qgmdate('Y-m-d H:i:s','', -4))
+            ->where('match_id',$match_id)
+            ->first();
+        if(empty($info)){
+            if($type_str){
+                $msg = '串式投注'.$type_str.':第'.$num.'条投注'.lang('Errors','Api')->get('error-5103');
+                Render([], '5103',$msg);
+            }else{
+                $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);
+            if($type_str){
+                $msg = '串式投注'.$type_str.':第'.$num.'条投注'.lang('Errors','Api')->get('error-5108');
+                Render([], '5108',$msg);
+            }else{
+                $msg = '第'.$num.'条'.lang('Errors','Api')->get('error-5108');
+                Render([], '5108',$msg);
+            }
         }
         return $info;
     }
@@ -147,16 +319,28 @@ class Betorder extends BaseController{
      * 验证球类是否存在
      * @param  [type] $game_code 球类代码
      * @param  [type] $num 第几条
+     * $type_str 串式类型
      */
-    public  function verify_gameType($game_code,$num){
+    public  function verify_gameType($game_code,$num,$type_str=''){
         if(empty($game_code)){
-            $msg = '第'.$num.'条数据'.lang('Errors','Api')->get('error-5102');
-            Render([], '5102', $msg);
+            if($type_str){
+                $msg = '串式投注'.$type_str.':第'.$num.'条投注'.lang('Errors','Api')->get('error-5102');
+                Render([], '5102',$msg);
+            }else{
+                $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);
+            if($type_str){
+                $msg = '串式投注'.$type_str.':第'.$num.'条投注'.lang('Errors','Api')->get('error-5102');
+                Render([], '5102',$msg);
+            }else {
+                $msg = '第' . $num . '条数据' . lang('Errors', 'Api')->get('error-5102');
+                Render([], '5102', $msg);
+            }
         }
         return $info;
     }
@@ -195,5 +379,232 @@ class Betorder extends BaseController{
         }
         return $info;
     }
+
+    /**
+     * 处理串式投注
+     * $data_str 各串式 数据
+     * $data_all 所有赛事 数据
+     * $userInfo 用户数据
+     */
+    public function stringBet($data_str=[],$data_all=[],$userInfo=[]){
+        //所有串式数据
+        $data_str = [
+            [
+                'type'=>'4串1',//串式名称
+                'odds'=>'',//当前串式赔率
+                'bet_amount'=> 1,
+            ],
+        ];
+
+        $data_all = [
+            [
+                'id' => 887529,
+                'home_team' => '阿尔艾利开罗',
+                'guest_team' => '金字塔',
+                'name' => '阿尔艾利开罗',
+                'odds' => '1.97',
+                'p_code' => 'concede_size',
+                'ballId' => 'zq',
+                'match_id' => 3129809,
+                'condition' => '+0/0.5',
+                'ganame' => 'concede_size',
+                'bettingTime' =>'',
+                'odds_only' => '1dee7e98db303852227cf1e0d8085dfb1555617310.3833947',
+                'type' => 1,
+            ],
+            [
+                'id' => 887472,
+                'home_team' => '阿尔艾利开罗',
+                'guest_team' => '金字塔',
+                'name' => '阿尔艾利开罗',
+                'odds' => '1.84',
+                'p_code' => 'concede_size',
+                'ballId' => 'zq',
+                'match_id' => 3124863,
+                'condition' => '+0/0.5',
+                'ganame' => 'concede_size',
+                'bettingTime' =>'',
+                'odds_only' => '1dee7e98db303852227cf1e0d8085dfb1555617310.3833947',
+                'type' => 1,
+            ],[
+                'id' => 887451,
+                'home_team' => '阿尔艾利开罗',
+                'guest_team' => '金字塔',
+                'name' => '阿尔艾利开罗',
+                'odds' => '2.05',
+                'p_code' => 'concede_size',
+                'ballId' => 'zq',
+                'match_id' => 3133254,
+                'condition' => '+0/0.5',
+                'ganame' => 'concede_size',
+                'bettingTime' =>'',
+                'odds_only' => '1dee7e98db303852227cf1e0d8085dfb1555617310.3833947',
+                'type' => 1,
+            ],[
+                'id' => 887450,
+                'home_team' => '阿尔艾利开罗',
+                'guest_team' => '金字塔',
+                'name' => '阿尔艾利开罗',
+                'odds' => '1.83',
+                'p_code' => 'concede_size',
+                'ballId' => 'zq',
+                'match_id' => 3127596,
+                'condition' => '+0/0.5',
+                'ganame' => 'concede_size',
+                'bettingTime' =>'',
+                'odds_only' => '1dee7e98db303852227cf1e0d8085dfb1555617310.3833947',
+                'type' => 1,
+            ]
+        ];
+
+        if(empty($data_all)){
+            Render($data_all, '1', lang('Tips','Sports')->get('success'));
+        }
+
+        //验证串式投注是否合法
+        $this->verify_stringType($data_all);
+
+        foreach ($data_all as $k =>$v){
+            //验证赛事是否存在
+//            $this->verify_match($v['ballId'],$v['id'],$k+1,$v['match_id']);
+//
+//            //验证球类代码是否有效
+//            $this->verify_gameType($v['ballId'],$k+1);
+        }
+
+        //写入串式投注 所有数据 json_encode($oddsData,true)
+        $bet_ttr_id = lm('BetStr','Api')->insertGetId(['bet_str_all'=>json_encode($data_all,true)]);
+        if($bet_ttr_id < 1) Render([], '50039',lang('Errors','Api')->get('error-50039'));
+        //获取串式 总赛事数量
+        $groupNum = count($data_all);//总数量
+
+        $orderData = [];
+        $orderID = OrderID();
+        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;
+            }
+
+            //获取当前串式投注金额及可赢金额
+            $money_all = $this->makeMoney((int)$sonNum,$v['bet_amount'],$multiple,$data_all,$after);
+
+            //投注金额
+            $moneyData = $money_all['moneyData'];
+            //可赢金额
+            $prize_money = $money_all['prize_money'];
+
+            $uuid = UUID();
+            $orderData[$k]['game_name'] = $v['type'];
+            $orderData[$k]['info_identity'] = $uuid;
+            $orderData[$k]['account_name'] = 'pengjun123';//$userInfo['account'];
+            $orderData[$k]['account_identity'] = 'c0ad12b7-d13f-969a-ccd2-e71473bc971b';//$userInfo['account_identity'];
+            $orderData[$k]['order_id'] = $orderID;
+            $orderData[$k]['game_no'] = "";
+            $orderData[$k]['money'] = $moneyData;
+            $orderData[$k]['bet_str_id'] = $bet_ttr_id;//投注数据
+            $orderData[$k]['money_time'] = $this->time;//下注时间
+            $orderData[$k]['prize_money'] = $prize_money;//可赢金额
+        }
+
+        $ret = lm('MoneyBuyStr','Api')->insert($orderData);//true
+        return $ret;
+    }
+
+    /**
+     * 计算串式投注 倍率
+     * $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;
+    }
+
+    /**
+     * 计算串式投注 赔率
+     */
+    public function getOddsStr(){
+
+    }
+
+    /**
+     * @param int $sonNum 当前串式数量
+     * @param int $bet_amount 当前串式投注额
+     * @param int $multiple 当前串式倍数
+     * @param array $data_all 当前注单 所有投注数据
+     * @return mixed
+     * 计算当前串式投注总额、可赢总额
+     */
+    public function makeMoney($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'];
+        }
+        //投注总额
+        $data['moneyData'] = (double)$bet_amount*(double)$multiple;
+        if($sonNum == $allNum and (int)$after ==1){//N场赛事  N串一
+            //获取所有赛事赔率乘积
+            $odds = array_product($odds_all);
+            //获取可赢金额
+            $data['prize_money'] =  floor($bet_amount*($odds-1)*100)/100;//保留两位小数
+        }
+
+        if($sonNum < $allNum and (int)$after ==1){//例:N场赛事 <N串一
+            $group = combination($odds_all, $sonNum);
+
+            foreach ($group as $k=>$v){
+                $odds[] = array_product($v);
+            }
+            $odds = (array_sum($odds))-(count($odds));
+
+            //获取可赢金额
+            $data['prize_money'] =  floor($bet_amount*($odds)*100)/100;//保留两位小数
+        }
+
+        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);
+                }
+            }
+        }
+    }
 }
 

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

@@ -312,6 +312,10 @@ return array(
     'error-50035' => '请先申请VIP!',
     'error-50036' => '已经申请VIP',
     'error-50037' => '未匹配到对应等级',
+    'error-50038' => '同赛事下有多个记录,不能进行串式投注',
+    'error-50039' => '写入串式投注数据失败',
+
+
 
     //by blade
     'error-51000' => '彩金活动查询错误',

+ 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';
+}

+ 14 - 3
Application/Api/Model/MoneyBuy.php

@@ -90,7 +90,7 @@ class MoneyBuy extends Model {
         }
         // 开奖状态
         if (!empty($_POST['status'])) {
-            $moneyBuyWhere['status'] = $_POST['status'];
+            $moneyBuyWhere['game_status'] = $_POST['status'];
         }
         // 序号
         if (!empty($_POST['id'])) {
@@ -103,6 +103,7 @@ class MoneyBuy extends Model {
         // 时间区间
         $startTime = isset($_POST['startTime'])? $_POST['startTime'] : '1900-01-01 00:00:00';
         $endTime = isset($_POST['endTime'])? $_POST['endTime'] : date("Y-m-d H:m:s");
+        //print_r($endTime);die;
         $moneyBuyBetween = [$startTime, $endTime];
         // 当前页
         $currentPage = isset($_POST['currentPage']) ? $_POST['currentPage'] : "1";
@@ -112,9 +113,19 @@ class MoneyBuy extends Model {
         $begin = ($currentPage - 1) * $pageSize;
         $moneyBuy = lm('money_buy', "commons");
         // 获取投注记录
-        $result['list'] = $moneyBuy -> moneyBuy($moneyBuyWhere, $moneyBuyBetween, $begin, $pageSize);
+        $getMoneyBuy = $moneyBuy -> moneyBuy($moneyBuyWhere, $moneyBuyBetween, $begin, $pageSize);
         // 获取记录总数
-        $result['total'] = count($result['list']);
+        $result['total'] = count($getMoneyBuy);
+        // 循环分配数据到查询条件
+        foreach ($getMoneyBuy as $key => $value) {
+            $codeInfo = json_decode($value->codes);
+            foreach ($codeInfo as $k => $v) {
+                $gameType = lang('OddsTemp','Api') -> get($v->odds_code);
+                $codeInfo[$k]->gameType = $gameType;
+            }
+            $getMoneyBuy[$key]['codes'] = json_encode($codeInfo);
+        }
+        $result['list'] = $getMoneyBuy;
         // 总页数计算
         $result['countPage'] = ceil($result['total'] / $pageSize);
         $result['currentPage'] = $currentPage;

+ 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';
+}

+ 2 - 16
Application/Api/Model/Withdraw.php

@@ -14,7 +14,7 @@ use Biz\Account\AccountManager;
 class Withdraw extends Model
 {
     /**
-     * 奖记录
+     * 奖记录
      *
      * @access public
      * @return String
@@ -43,21 +43,7 @@ class Withdraw extends Model
             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'));
-        }
+        $accountManagerClass -> verifyPayPwd($userInfo['identity'], $_POST['payPassword']);
         // 用户银行卡
         $bankCardWhere['account_identity'] = $userInfo['identity'];
         $bankCardWhere['bank_number'] = $_POST['bank_number'];

+ 16 - 0
Application/Commons/Model/Pay_password.php

@@ -26,4 +26,20 @@ class Pay_password extends Model {
 
         return $result;
     }
+
+    /**
+     * 支付密码修改
+     *
+     * @access public
+     * @param mixed $where 查询条件
+     * @param mixed $updateData 修改字段
+     * @return array JsonString
+     */
+    public function updatePayPassword ($where, $updateData) {
+        $result = $this
+            -> where($where)
+            -> update($updateData);
+
+        return $result;
+    }
 }

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

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

@@ -67,6 +67,7 @@ class Index extends Controller {
             'ua' => 'UpdateAccount',
             'gvvi' => 'GetVideoVendorId',
             'gsvi' => 'GetSportVendorId',
+            'atin' => 'AutoLogin',
         ];
 	    return $maps;
     }
@@ -151,8 +152,14 @@ 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;
+	    if (isset($_REQUEST['debug'])){
+            $url = 'http://www.kaiyou-dev.com/InApi-index/dobusiness?params='.base64_encode($string).'&Key='.$key;
+        }else{
+            $url = 'http://sports.5gogo.com/InApi-index/dobusiness?params='.base64_encode($string).'&Key='.$key;
+        }
+	    //$url = 'http://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');
 
     }

+ 21 - 9
Application/Sports/Controller/MatchList.php

@@ -44,7 +44,6 @@ class  MatchList extends Controller {
              ->join('st_zq_league','st_zq_league.lg_id','st_zq_competition.lg_id')
              ->where('st_zq_competition.source',$this->source['source'])
              ->where('st_zq_competition.match_date','tomorrow')
-             ->where('st_zq_competition.status','0')
              ->count('*');
         //受欢迎的欧洲赛事
          $data['info'][2]['name'] = '受欢迎的欧洲赛事';
@@ -55,6 +54,7 @@ class  MatchList extends Controller {
              ->where('st_area.code',"Europe")
              ->where('st_zq_league.hot',0)
              ->where('st_zq_competition.status','<',2)
+             ->where('st_zq_competition.us_time','>',qgmdate('Y-m-d H:i:s', '', -4))
              ->where('st_zq_competition.source',$this->source['source'])
              ->count('*');
 
@@ -71,6 +71,7 @@ class  MatchList extends Controller {
                      ->Orwhere('st_country.name_english','=','Australia');
              })
              ->where('st_zq_competition.status','<',2)
+             ->where('st_zq_competition.us_time','>',qgmdate('Y-m-d H:i:s', '', -4))
              ->where('st_zq_competition.source',$this->source['source'])
              ->count('*');
          //查询北美,南美赛事
@@ -84,6 +85,7 @@ class  MatchList extends Controller {
                     ->Orwhere('st_area.code','=', "North_America");
             })
             ->where('st_zq_competition.status', '<', '2')
+             ->where('st_zq_competition.us_time','>',qgmdate('Y-m-d H:i:s', '', -4))
             ->where('st_area.source',$this->source['source'])
             ->count('*');
          //国际赛事
@@ -94,6 +96,7 @@ class  MatchList extends Controller {
              ->join('st_zq_competition','st_zq_competition.lg_id','st_zq_league.id')
             ->where('st_area.code',"world")
              ->where('st_zq_competition.status', '<', '2')
+             ->where('st_zq_competition.us_time','>',qgmdate('Y-m-d H:i:s', '', -4))
             ->where('st_area.source',$this->source['source'])
             ->count('*');
          return $data;
@@ -112,13 +115,13 @@ class  MatchList extends Controller {
          $data['info'][0]['count'] =lm($st_competition,'Sports')
              ->where([[$st_competition.'.status', '<', '2'],
              [$st_competition.'.source',$this->source['source']]])
+             ->where('st_zq_competition.us_time','>',qgmdate('Y-m-d H:i:s', '', -4))
              ->count('*');
          $data['info'][1]['name'] = '今日赛事';
          $data['info'][1]['code'] = 'today';
          $data['info'][1]['count']=lm($st_competition,'Sports')
-             ->where([['match_date','today'],
-                 [$st_competition.'.status', '<', '2'],
-                 [$st_competition.'.source',$this->source['source']]])
+             ->where($st_competition.'.source',$this->source['source'])
+             ->where(getState('StToday',$st_competition))
              ->count('*');
         return $data;
     }
@@ -170,7 +173,8 @@ class  MatchList extends Controller {
                 $where =[
                     ['st_area.code','Europe'],[$st_league.'.hot',0],
                     [$st_competition.'.status', '<', '2'],
-                    [$st_competition.'.source',$this->source['source']]
+                    [$st_competition.'.source',$this->source['source']],
+                    [$st_competition.'.us_time','>',qgmdate('Y-m-d H:i:s', '', -4)]
                 ];
                 //欧洲最受欢迎的赛事
                 $data = lm($st_competition,'Sports')
@@ -187,6 +191,7 @@ class  MatchList extends Controller {
                 $where = [
                     [$st_competition.'.status', '<', '2'],
                     [$st_competition.'.source',$this->source['source']],
+                    [$st_competition.'.us_time','>',qgmdate('Y-m-d H:i:s', '', -4)]
                 ];
                 $Orwhere  = function ($query) {
                     $query->Orwhere('st_area.code','=','Asian')
@@ -209,7 +214,8 @@ class  MatchList extends Controller {
             case $code == 'south_north':
                 $where = [
                     [$st_competition.'.status', '<', '2'],
-                    [$st_competition.'.source',$this->source['source']]
+                    [$st_competition.'.source',$this->source['source']],
+                    [$st_competition.'.us_time','>',qgmdate('Y-m-d H:i:s', '', -4)]
                 ];
                 $Orwhere = function ($query) {
                     $query->Orwhere('st_area.code','=', "South_America")
@@ -231,7 +237,7 @@ class  MatchList extends Controller {
                 $where = [
                     [$st_competition.'.match_date','tomorrow'],
                     [$st_competition.'.status',0],
-                    [$st_competition.'.source',$this->source['source']]
+                    [$st_competition.'.source',$this->source['source']],
                 ];
                 //明日赛事
                 $data = lm($st_competition,'Sports')
@@ -247,7 +253,8 @@ class  MatchList extends Controller {
                  $where = [
                      ['st_area.code', "world"],
                      [$st_competition.'.status','<','2'],
-                     [$st_competition.'.source',$this->source['source']]
+                     [$st_competition.'.source',$this->source['source']],
+                     [$st_competition.'.us_time','>',qgmdate('Y-m-d H:i:s', '', -4)]
                  ];
             //国际赛事
             $data = lm($st_competition,'Sports')
@@ -263,7 +270,8 @@ class  MatchList extends Controller {
             case $code == 'all':
                 $where = [
                     [$st_competition.'.status','<', '2'],
-                    [$st_competition.'.source',$this->source['source']]
+                    [$st_competition.'.source',$this->source['source']],
+                    [$st_competition.'.us_time','>',qgmdate('Y-m-d H:i:s', '', -4)]
                     ];
                 //所有赛事
                 $data = lm($st_competition,'Sports')
@@ -471,6 +479,7 @@ class  MatchList extends Controller {
             ->where($st_league.'.name_chinese','like','%'.$search.'%')
             ->where($where)
             ->where($st_competition.'.status', '<', '2')
+            ->where('st_zq_competition.us_time','>',qgmdate('Y-m-d H:i:s', '', -4))
             ->get()
             ->toArray();
 
@@ -484,6 +493,7 @@ class  MatchList extends Controller {
             ->where($st_league.'.name_chinese','like','%'.$search.'%')
             ->where($where)
             ->where($st_competition.'.status', '<', '2')
+            ->where('st_zq_competition.us_time','>',qgmdate('Y-m-d H:i:s', '', -4))
             ->get()
             ->toArray();
         //统计国家联赛下的赛事
@@ -503,6 +513,7 @@ class  MatchList extends Controller {
                         ->where($where)
                         ->where('lg_id',$vv['lg_id'])
                         ->where('status', '<', '2')
+                        ->where('us_time','>',qgmdate('Y-m-d H:i:s', '', -4))
                         ->count();
                     if($country[$k]['league_count'][$kk]['count'] == 0){
                         unset($country[$k]['league_count'][$kk]);
@@ -527,6 +538,7 @@ class  MatchList extends Controller {
                         ->where($this->source)
                         ->where($where)
                         ->where('status', '<', '2')
+                        ->where('us_time','>',qgmdate('Y-m-d H:i:s', '', -4))
                         ->where('lg_id',$vv['lg_id'])
                         ->count();
                     if($area[$k]['league_count'][$kk]['count'] == 0){

+ 66 - 138
Application/Sports/Controller/Sports.php

@@ -4,163 +4,91 @@ use BaseController\Controller;
 /**
  * Class Register
  * @package App\Sports\Controller
-     * User: junghwi
+ * User: junghwi
  * Date: 2019/3/21
  */
 class Sports extends Controller{
 
-    function init() {
-        $this->date = date('Y-m-d');//当前日期时间戳
-    }
-    /*
-       * 首页体育-足球比赛数据
-       */
-    private function football(){
+    /**
+     * 首页体育-球类比赛数据方法
+     * @param  [type] $game_code  球类代码
+     * @param  [array] $where 球类额外条件
+     * @param  [int]  $limit_mt  赛事显示条数 默认3条
+     * @param  [int]  $limit_lg  联赛显示条数 默认3条
+     * @return [array] $data
+     */
+    private function Sports_info($game_code,$where,$limit_mt = 3,$limit_lg = 3){
         $data=[];
-        $data['name'] = '足球';
+        $data['name'] = lm('GameType','Sports')->where('game_code',$game_code)->value('game_name');
         $data['game_code'] = 'zq';
-        //查询今日正在进行的和未开始的足球比赛
-        $data['match'] = lm("st_zq_competition","Sports")
-            ->leftjoin('st_zq_odds','st_zq_odds.match_id','=','st_zq_competition.match_id')
-            ->leftjoin('st_zq_league','st_zq_league.id','=','st_zq_competition.lg_id')
-            ->select('st_zq_competition.match_id','st_zq_competition.home_team','st_zq_competition.guest_team','st_zq_competition.match_date','st_zq_competition.match_time')
-            ->where('st_zq_competition.match_date',$this->date)
-            ->where('st_zq_league.source',$this->source)
-            ->whereIn('st_zq_competition.status',['0','1'])
-            ->limit('2')
-            ->get();
-        //今日联赛
-        $lg_id = lm('st_zq_competition','Sports')->select('lg_id')->where('source',$this->source)->where(['match_date'=>$this->date])->distinct('lg_id')->get()->toarray();
-        if (!empty($lg_id)) {
-            foreach($lg_id as $k => $v){
-                $data['league'][$k]['lg_id'] = $v['lg_id'];
-                $data['league'][$k]['name'] = lm('st_zq_league','Sports')->where('lg_id',$v['lg_id'])->where('source',$this->source)->value('name_chinese');
-                $data['league'][$k]['count'] = lm('st_zq_competition','Sports')->where('source',$this->source)->where('lg_id',$v['lg_id'])->count();
+        //===查询该球类Models===
+        $getModels = getModels($game_code);
+        $st_league = $getModels['model_league'];
+        $st_competition = $getModels['model_match'];
+        //查询足球早盘其他球的所有赛事
+        if ($data['game_code'] == 'zq'){
+            $data['today']['name'] ='今日赛事';
+            $data['today']['count'] = lm('st_zq_competition','Sports')
+                ->join('st_zq_league','st_zq_league.lg_id','st_zq_competition.lg_id')
+                ->where(getState('StToday'))
+                ->where('st_zq_competition.source',$this->source['source'])
+                ->distinct('st_zq_competition.match_id')
+                ->count('*');
+            } else {
+                $data['all']['name'] = '所有赛事';
+                $data['today']['count'] = lm($st_competition,'Sports')
+                    ->where([[$st_competition.'.status', '<', '2'],
+                        [$st_competition.'.source',$this->source['source']]])
+                    ->where('st_zq_competition.us_time','>',qgmdate('Y-m-d H:i:s', '', -4))
+                    ->count('*');
             }
-        }else {
-            $data['league'] =[];
-        }
-        return $data;
-    }
-
-    /*
-   * 首页体育-篮球比赛数据
-   */
-    private function basketball(){
-        $data=[];
-        $data['name']='篮球';
-        $data['game_code'] = 'lq';
-        //查询今日正在进行的和未开始的足球比赛/2
-        $data['match']  = lm("st_lq_competition","Sports")
-            ->leftjoin('st_lq_odds','st_lq_odds.match_id','=','st_lq_competition.match_id')
-            ->leftjoin('st_lq_league','st_lq_league.id','=','st_lq_competition.lg_id')
-            ->select('st_lq_competition.match_id','st_lq_competition.home_team','st_lq_competition.guest_team','st_lq_competition.match_date','st_lq_competition.match_time')
-            ->where('st_lq_competition.match_date',$this->date)
-            ->where('st_lq_competition.source',$this->source)
-            ->whereIn('st_lq_competition.status',['0','1'])
-            ->limit('2')
+        //查询正在进行的和未开始的球类比赛
+        $data['match'] = lm($st_competition,"Sports")
+            ->join($st_league,$st_league.'.lg_id',$st_competition.'.lg_id')
+            ->select($st_competition.'.match_id',$st_competition.'.home_team',$st_competition.'.guest_team',$st_competition.'.match_date',$st_competition.'.match_time')
+            ->where([[$st_competition.'.status','<',2],[$st_competition.'.source',$this->source]])
+//            ->where($st_competition.'.us_time','>',qgmdate('Y-m-d H:i:s', '', -4))
+            ->where($where)
+            ->limit($limit_mt)
             ->get();
-        //今日联赛
-        $lg_id = lm('st_lq_competition','Sports')->select('lg_id')->where('source',$this->source)->where(['match_date'=>$this->date])->distinct('lg_id')->get()->toarray();
-        if (!empty($lg_id)) {
-            foreach($lg_id as $k => $v){
-                $data['league'][$k]['lg_id'] = $v['lg_id'];
-                $data['league'][$k]['name'] = lm('st_lq_league','Sports')
-                    ->where($this->source)
-                    ->where('lg_id',$v['lg_id'])
-                    ->value('name_chinese');
-                $data['league'][$k]['count'] = lm('st_lq_league','Sports')
-                    ->where($this->source)
-                    ->where('lg_id',$v['lg_id'])
-                    ->count();
-            }
-        }else {
-            $data['league'] =[];
+        if(!empty($data['match'])){
+            $data['match'] = $data['match']->toarray();
         }
-        return $data;
-    }
 
-    /*
-       * 首页体育-网球比赛数据
-       */
-    private function tennis(){
-        $data=[];
-        $data['name']='网球';
-        $data['game_code'] = 'wq';
-        //查询今日正在进行的和未开始的足球比赛/2
-        $data['match'] = lm("st_wq_competition","Sports")
-            ->leftjoin('st_wq_odds','st_wq_odds.match_id','=','st_wq_competition.match_id')
-            ->leftjoin('st_wq_league','st_wq_league.id','=','st_wq_competition.lg_id')
-            ->select('st_wq_competition.match_id','st_wq_competition.home_team','st_wq_competition.guest_team','st_wq_competition.match_date','st_wq_competition.match_time')
-            ->where('st_wq_competition.match_date',$this->date)
-            ->where('st_wq_competition.source',$this->source)
-            ->whereIn('st_wq_competition.status',['0','1'])
-            ->limit('2')
-            ->get();
-        //今日联赛
-        $lg_id = lm('st_wq_competition','Sports')->select('lg_id')->where('source',$this->source)->where(['match_date'=>$this->date])->distinct('lg_id')->get()->toarray();
-        if (!empty($lg_id)) {
-            foreach($lg_id as $k => $v){
-                $data['league'][$k]['lg_id'] = $v['lg_id'];
-                $data['league'][$k]['name'] = lm('st_wq_league','Sports')
-                    ->where('source',$this->source)
-                    ->where('lg_id',$v['lg_id'])
-                    ->value('name_chinese');
-                $data['league'][$k]['count'] = lm('st_wq_competition','Sports')
-                    ->where('source',$this->source)
-                    ->where('lg_id',$v['lg_id'])
-                    ->count();
-            }
-        }else {
-            $data['league'] =[];
-        }
-        return $data;
-    }
-    /*
-    * 首页体育-棒球比赛数据
-    */
-    private function baseball(){
-        $data=[];
-        $data['name']='棒球';
-        $data['game_code'] = 'bq';
-        //查询今日正在进行的和未开始的足球比赛/2
-        $data['match'] = lm("st_bq_competition","Sports")
-            ->leftjoin('st_bq_odds','st_bq_odds.match_id','=','st_bq_competition.match_id')
-            ->leftjoin('st_bq_league','st_bq_league.id','=','st_bq_competition.lg_id')
-            ->select('st_bq_competition.match_id','st_bq_competition.home_team','st_bq_competition.guest_team','st_bq_competition.match_date','st_bq_competition.match_time')
-            ->where('st_bq_competition.match_date',$this->date)
-            ->where('st_bq_competition.source',$this->source)
-            ->whereIn('st_bq_competition.status',['0','1'])
-            ->limit('2')
+        //获取正在进行的和未开始联赛
+        $data['league'] = lm($st_competition,"Sports")
+            ->join($st_league,$st_league.'.lg_id',$st_competition.'.lg_id')
+            ->select($st_league.'.lg_id',$st_league.'.name_chinese')
+            ->where([[$st_competition.'.status','<',2],[$st_competition.'.source',$this->source]])
+//            ->where($st_competition.'.us_time','>',qgmdate('Y-m-d H:i:s', '', -4))
+            ->where($where)
+            ->limit($limit_lg)
+            ->distinct($st_league.'lg_id')
             ->get();
-        //今日联赛
-        $lg_id = lm('st_bq_competition','Sports')->select('lg_id')->where('source',$this->source)->where(['match_date'=>$this->date])->distinct('lg_id')->get()->toarray();
-        if (!empty($lg_id)) {
-            foreach($lg_id as $k => $v){
-                $data['league'][$k]['lg_id'] = $v['lg_id'];
-                $data['league'][$k]['name'] = lm('st_bq_league','Sports')
-                    ->where('source',$this->source)
-                    ->where('lg_id',$v['lg_id'])
-                    ->value('name_chinese');
-                $data['league'][$k]['count'] = lm('st_bq_competition','Sports')
-                    ->where('source',$this->source)
+        if (!empty($data['league'])) {
+            $data['league'] = $data['league']->toarray();
+            foreach($data['league'] as $k => $v){
+                //统计当前联赛下的联赛
+                $data['league'][$k]['count'] = lm($st_competition,'Sports')
+                    ->where([[$st_competition.'.status','<',2],[$st_competition.'.source',$this->source]])
                     ->where('lg_id',$v['lg_id'])
-                    ->count();
+                    ->where($where)
+                    ->count('*');
             }
-        }else {
-            $data['league'] =[];
         }
         return $data;
     }
+
     /*
-     * 返回数据
+     * 获取首页体育信息数据接口
      */
     public  function  data(){
-        $lq[] = $this->basketball();
-        $wq[] = $this->tennis();
-        $bq[] = $this->baseball();
-        $zq[] = $this->football();
-        $data = array_add($zq,$lq,$wq,$bq);
+        $where = [];//球类额外条件
+        $lq[] = $this->Sports_info('lq',$where);
+        $wq[] = $this->Sports_info('wq',$where);
+        $bq[] = $this->Sports_info('bq',$where);
+        $zq[] = $this->Sports_info('zq',$where);
+        $data = array_merge_recursive($lq,$wq,$bq,$zq);
         Render($data,'1', lang('Tips','Sports')->get('success'));
     }
 }

+ 86 - 17
Biz/Account/AccountManager.php

@@ -352,6 +352,7 @@ class AccountManager {
         /*if ($r = $this->repository->checkPassword($newPassword, $againPassword)) {
             return $r;
         }*/
+        // 验证密码
         if ($this -> checkPassword($userInfo, $oldPassword)) {
             // 密码加密
             $pwdData = GenPassword($newPassword);
@@ -365,6 +366,91 @@ class AccountManager {
 
     }
 
+    /**
+     * 修改用户支付密码
+     *
+     * @access public
+     * @param mixed oldPassword旧密码
+     * @param mixed newPassword新密码
+     * @return array JsonString
+     * @throws \Exception
+     */
+    public function savePayPassword() {
+        $userInfo = $this -> getCurrentUser();
+        // 判断用户登录
+        if (empty($userInfo)) {
+            $result = ['status' => -4001, 'msg' => lang() -> get('user does not exist')];
+            return $result;
+        }
+        // 验证用户状态
+        if ($row = $this -> repository -> checkAccountStatus($userInfo)) {
+            return $row;
+        };
+        $oldPayPassword = strip_tags($_POST['oldPayPassword']);
+        $newPayPassword = strip_tags($_POST['newPayPassword']);
+        // 验证两次密码是否一致
+        /*if ($r = $this->repository->checkPassword($newPassword, $againPassword)) {
+            return $r;
+        }*/
+        // 验证交易密码
+        $this -> verifyPayPwd($userInfo['identity'], $oldPayPassword);
+        // 获取新支付密码加密
+        $pwdData = GenPassword($newPayPassword);
+        // 修改支付密码
+        $upPayPwdWhere['account_identity'] = $userInfo['identity'];
+        $upPayPwdData['pay_password'] = $pwdData['password'];
+        $upPayPwdData['encryption'] = $pwdData['encryption'];
+        lm('pay_password', 'Commons') -> updatePayPassword($upPayPwdWhere, $upPayPwdData);
+        $result = ['status' => 1, 'msg' => lang()->get('update successful')];
+
+        return $result;
+    }
+
+    /**
+     * 验证交易密码
+     *
+     * @access public
+     * @param mixed $identity 用户id
+     * @param mixed $payPassword 支付密码
+     * @return String
+     * @throws \Exception
+     */
+    public function verifyPayPwd($identity, $payPassword) {
+        $payPasswordWhere['account_identity'] = $identity;
+        $payPasswordSelect = ['encryption'];
+        $payPasswordMd = lm('pay_password', "commons");
+        // 获取加密盐值
+        $accountPwdInfo = $payPasswordMd -> payPassword($payPasswordSelect, $payPasswordWhere);
+        $encryptionPwd = md5(md5($accountPwdInfo["encryption"] . $payPassword));
+        $verifyPayPwdWhere['account_identity'] = $identity;
+        $verifyPayPwdWhere['pay_password'] = $encryptionPwd;
+        $verifyPayPwdSelect = ['id'];
+        // 验证支付密码
+        $verifyPayPwd = $payPasswordMd -> payPassword($verifyPayPwdSelect, $verifyPayPwdWhere);
+        if (!$verifyPayPwd['id']) {
+            Render([], '2020', lang('Common','Api') -> get('payment password error'));
+        }
+        return 1;
+    }
+
+
+    /**
+     * 修改用户交易密码
+     *
+     * @return array
+     * @throws \Exception
+     */
+    public function updatePayPassword($post) {
+        $checkPassword = $this->repository->checkOldPayPassword($post['token'], strip_tags($post['oldPassword']));
+        if ($checkPassword['status'] != 1) {
+            return $checkPassword;
+        };
+        $payPassword = GenPassword(strip_tags($post['pay_password']));
+        lm('pay_password', 'Commons')->where('account_identity', $checkPassword['account_identity'])->update(['pay_password' => $payPassword['password'], 'encryption' => $payPassword['encryption']]);
+        $result = ['status' => 1, 'msg' => lang()->get('update successful')];
+        return $result;
+    }
+
     public function chHeadImg($imgUrl, $imgId) {
         $userInfo = $this->getCurrentUser();
         $uuid = $userInfo->account_identity;
@@ -746,23 +832,6 @@ class AccountManager {
         return ['status' => 1];
     }
 
-    /**
-     * 修改用户交易密码
-     *
-     * @return array
-     * @throws \Exception
-     */
-    public function updatePayPassword($post) {
-        $checkPassword = $this->repository->checkOldPayPassword($post['token'], strip_tags($post['oldPassword']));
-        if ($checkPassword['status'] != 1) {
-            return $checkPassword;
-        };
-        $payPassword = GenPassword(strip_tags($post['pay_password']));
-        lm('pay_password', 'Commons')->where('account_identity', $checkPassword['account_identity'])->update(['pay_password' => $payPassword['password'], 'encryption' => $payPassword['encryption']]);
-        $result = ['status' => 1, 'msg' => lang()->get('update successful')];
-        return $result;
-    }
-
     /**
      * 用户退出
      *

+ 109 - 6
Biz/Game/GameLogic.php

@@ -9,7 +9,12 @@
 namespace Biz\Game;
 
 use  Biz\Account\AccountManager;
-use  Biz\Game\TranferMoneyLogic ;
+use  Biz\Game\TranferMoneyLogic;
+use  App\Commons\Model\Wagent_clientgame_log as Wagent_clientgame_logModel;
+use  Illuminate\Database\Capsule\Manager as DB;
+use Biz\Game\SportbetRecordLogic ;
+
+
 
 class GameLogic
 {
@@ -224,21 +229,87 @@ class GameLogic
 
     }
 
-    //TransferGame(进入游戏)
+    //TransferGame(进入游戏)(记录登陆日志,并自动登陆一次,返回用户登陆信息)
     public function TransferGame(){
 
-        $ret = $this->makeret() ;
-        return $ret;
+        $this->accountAndPassCheck();
+        $datas = [
+            'agent_name' => $this->paras['agent'],
+            'domain' => isset($this->paras['domain']) ?  trim(  $this->paras['domain'] ) : '',
+            'userame' => $this->wagetnModel->agent_pre.$this->paras['username'],
+            'gametype' =>  isset($this->paras['gametype']) ?  trim(  $this->paras['gametype'] ) : '',
+            'gamekind' =>  isset($this->paras['gamekind']) ?  trim(  $this->paras['gamekind'] ) : '',
+            'iframe' =>  isset($this->paras['iframe']) ?  trim(  $this->paras['iframe'] ) : -1 ,
+            'platformname' =>  isset($this->paras['platformname']) ?  trim(  $this->paras['platformname'] ) : '',
+            'ip'=> GETIP(),
+        ];
+        $model = new Wagent_clientgame_logModel();
+        $ret = $model->insert($datas);
+        if ( $ret ){
+            $username = $this->wagetnModel->agent_pre.$this->paras['username'];
+            $ac = new AccountManager();
+            $ret2 = $ac->login($username , $this->paras['password']);
+
+            if ( isset($ret2['status']) &&  $ret2['status']==1 && isset( $ret2['data']['0']['token'] ) ){
+                return $this->makeret(1,$ret2['msg'],['ret'=>0,'token'=>$ret2['data']['0']['token']]);
+            }else{
+                return $this->makeret(0,'false',0);
+            }
+
+        }else{
+            return $this->makeret(0,'false',0);
+        }
+
     }
 
 
     //GetReport(获取报表数据)
     public function   GetReport(){
+        $this->accountAndPassCheck();
+        $datetart = isset($this->paras['datestart']) ? trim($this->paras['datestart']) : '';
+        $dateends = isset($this->paras['dateend']) ? trim($this->paras['dateend']) : '';
+        if (empty($datetart) ||  empty($dateends)){
+            return  $this->makeret(0,'begin or endtime is empty',0);
+        }
+        $retstr = '/^(\d{4}-\d{2}-\d{2})$/';
+        if ( !preg_match($retstr,$datetart) || !preg_match($retstr,$dateends)){
+            return  $this->makeret(0,'date fromat error',0);
+        }
+        $username = $this->wagetnModel->agent_pre.$this->paras['username'];
+        $ret = $this->getMoneyBuyData($username ,$datetart , $dateends );
+
+        $retlast['sports']['UserName'] = $this->paras['username'];
+        $retlast['sports']['BettingTime'] = intval($ret['counts']);
+        $retlast['sports']['BettingAmount'] = intval($ret['money']);
+        $retlast['sports']['BettingEffectiveAmount'] = intval($ret['prize_money']);
+        $retlast['sports']['BettingLoseWin'] = intval($ret['money']  -  $ret['prize_money']) ;
+
+        return $this->makeret(1,'success',$retlast);
+    }
+    //获取某人体育游戏的统计数据
+    public  function   getMoneyBuyData($account,$databegin,$dataend){
+        $db = $GLOBALS['DB'] ;
+        $ret1 = $db->select("select  count(id) as counts,sum(money) as money, sum(prize_money) as  money_buy   from  money_buy  where account_name=:account and  status in (1,2) and  money_time>=:timebegin and money_time<=:timeend  group by account_name ;",['account'=>$account,'timebegin'=>$databegin,'timeend'=>$dataend]);
+        $ret2 = $db->select("select  count(id) as counts,sum(money) as money, sum(prize_money) as  money_buy   from  money_buy_str  where account_name=:account and  status in (1,2) and  money_time>=:timebegin and money_time<=:timeend  group by account_name ;",['account'=>$account,'timebegin'=>$databegin,'timeend'=>$dataend]);
+
+        $ret = ['counts'=>0,'money'=>0,'prize_money'=>0] ;
+        if ($ret1){
+            $ret['counts'] += $ret1['0']['count'];
+            $ret['money'] += $ret1['0']['money'];
+            $ret['prize_money'] += $ret1['0']['prize_money'];
+        }
+
+        if ($ret2){
+            $ret['counts'] += $ret2['0']['count'];
+            $ret['money'] += $ret2['0']['money'];
+            $ret['prize_money'] += $ret2['0']['prize_money'];
+        }
 
-        $ret = $this->makeret() ;
         return $ret;
     }
 
+
+
     // GetCashTrade(转帐记录)
     public function   GetCashTrade(){
 
@@ -287,9 +358,22 @@ class GameLogic
 
     //GetSportsBettingRecordByVendor(体育投注记录)
     public function   GetSportsBettingRecordByVendor(){
+        $vendorid = isset($this->paras['vendorid']) ?  trim( $this->paras['vendorid'] ) : 0 ;
+        $isjs = isset($this->paras['isjs']) ?  intval( $this->paras['isjs'] ) : 0 ;
 
+        if (empty($vendorid)){
+            $ret = $this->makeret(0,'paretn error',0) ;
+            return $ret;
+        }
 
-        $ret = $this->makeret() ;
+        $logic = new  SportbetRecordLogic($this->wagetnModel , $vendorid , $isjs);
+        $ret =  $logic->dorun();
+
+        if (!$ret){
+            return $this->makeret(0,'false',0);
+        }else{
+            return $this->makeret(1,'success', $ret) ;
+        }
         return $ret;
     }
 
@@ -371,4 +455,23 @@ class GameLogic
     }
 
 
+    //代理帮用户请求一次登陆操作,如果成功有用户有效token值
+    public function AutoLogin(){
+        $this->accountAndPassCheck();
+
+        $username = $this->wagetnModel->agent_pre.$this->paras['username'];
+        $ac = new AccountManager();
+        $ret2 = $ac->login($username , $this->paras['password']);
+
+        if ( isset($ret2['status']) &&  $ret2['status']==1 && isset( $ret2['data']['0']['token'] ) ){
+            return $this->makeret(1,$ret2['msg'],['ret'=>0,'token'=>$ret2['data']['0']['token']]);
+        }else{
+            return $this->makeret(0,'false',0);
+        }
+
+
+    }
+
+
+
 }

+ 194 - 0
Biz/Game/SportbetRecordLogic.php

@@ -0,0 +1,194 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Administrator
+ * Date: 2019/4/23
+ * Time: 14:36
+ */
+
+namespace Biz\Game;
+
+
+//获取某个代理下的体育项目订单相关的数据
+class SportbetRecordLogic
+{
+    //代理Model
+    private  $wagentModel = '';
+    //订单ID
+    private  $vendorid =  null ;
+    //是否结算
+    private  $isjs = 0 ;
+    //返回数据
+    private  $retDataArray  = [] ;
+    //db obj ;
+    private  $db ;
+    //
+    private  $buyModel = null ;
+
+    public function  __construct($wagModel,$vendorid,$isjs)
+    {
+        $this->wagentModel = $wagModel;
+        $this->vendorid = $vendorid;
+        $this->isjs = ($isjs==1) ? 2 : 1  ;
+        $this->retDataArray = $this->getDefaultBackData();
+        $this->db = $GLOBALS['DB'] ;
+    }
+
+
+    public  function  dorun(){
+        $buyModel = lm("Money_buy",'Commons')->where(['order_id'=>$this->vendorid,'settle_status'=>$this->isjs])->first();
+
+        //$buyModel = lm("Money_buy",'Commons')->where(['order_id'=>$this->vendorid,'settle_status'=>$this->isjs])->toSql();
+        //var_dump([$buyModel,$this->vendorid,$this->isjs]);exit ;
+
+        if ( !$buyModel ) { return  false; }
+        $this->buyModel = $buyModel ;
+
+
+
+
+        $this->Batchsetval();
+        $ret = $this->retDataArray;
+        return  $ret;
+    }
+
+    //批量设置数据
+    public function Batchsetval(){
+        $buyModel = $this->buyModel ;
+        if ($buyModel){
+            $this->Setval('isjs',$buyModel->settle_status==2 ? 1 :0);
+            $this->Setval('tzmoney',$buyModel->money);
+            //$this->Setval('username',strlen($this->wagentModel->agent_pre)>0 ?  (substr($buyModel->account_name,strlen($this->wagentModel->agent_pre))): substr($buyModel->account_name ) );
+            $this->Setval('username',$buyModel->account_name );
+            $this->Setval('win',($buyModel->settle_status==2) ? $buyModel->prize_money : 0 );
+            $this->Setval('updatetime',$buyModel->money_time);
+            $this->Setval('validamount',$buyModel->money);
+            $this->Setval('tztype',$buyModel->game_name);
+            $this->Setval('iscancel',($buyModel->status==4) ? 1 : 0 );
+
+            switch ( strtolower($buyModel->game_name) ){
+                case  'zq':
+                    $this->Setval('sportid', 0);
+                    break;
+                case 'lq':
+                    $this->Setval('sportid', 3);
+                    break;
+                case 'wq':
+                    $this->Setval('sportid', 1);
+                    break;
+                default;
+                    $this->Setval('sportid', 16);
+            }
+
+            if ($buyModel->settle_status==2  &&  intval($buyModel->prize_money)==0){      $this->Setval('lose', $buyModel->money );   }
+
+
+
+            $tmpArray = json_decode($buyModel->codes,true);
+            if ( is_array($tmpArray) &&  isset($tmpArray['0']) ){
+                $tmpArray = $tmpArray['0'];
+                if ( isset($tmpArray['bettingTime']) &&  $tmpArray['bettingTime']!='' &&  $buyModel->settle_status==2){
+                    $this->Setval('thisdate',$tmpArray['bettingTime']);
+                    $this->Setval('balltime',$tmpArray['bettingTime']);
+                }
+                if ( isset($tmpArray['odds']) &&  $tmpArray['odds']!='' ){  $this->Setval('odds',$tmpArray['curpl']); }
+                if ( isset($tmpArray['match_id']) &&  $tmpArray['match_id']!='' ){  $this->Setval('matchid',$tmpArray['match_id']); }
+            }
+        }
+
+
+    }
+
+
+    //设置返回参数值
+    private  function   Setval($key,$val=''){
+        if  (isset($this->retDataArray[$key])){
+            $this->retDataArray[$key] = $val;
+        }
+    }
+
+    //返回数据
+    private   function  makeret($status=1,$msg='success',$datas=[]){
+        return [
+            'status'=>$status,
+            'msg'=>$msg,
+            'datas'=>$datas
+        ];
+    }
+
+    /*
+     * ballid	场次id号
+        balltime	结算时间
+        curpl	赔率
+        ds	单双
+        dxc	大小个数
+        isbk	无用
+        iscancel	是否取消
+        isdanger	是否危险球
+        isjs	是否结算,1表示结算,0表示未结算
+        lose	输的钱
+        matchid	联赛id号
+        moneyrate	会员使用的货币比率
+        orderid	注单号
+        redcard	红牌
+        result	赛事结果
+        rowguid	唯一性id号,自动生成,orderid为每个平台的id号,多平台可能不唯一
+        rqc	让球个数
+        rqteam	让球队伍,比如主队让球H,客对让球A
+        sportid	下注球类id号
+        tballtime	走地时间
+        thisdate	结算日期
+        truewin	0.5赢半,1全赢,-0.5输半,-1输,0和
+        tzip	投注ip,IBC不提供,为空就行
+        tzmoney	下注金额
+        tzteam	下注队伍,比如主队H,客队A
+        tztype	下注类别
+        updatetime	下注时间
+        username	会员名
+        win	赢的钱
+        zdbf	走地比分
+        content	下注中文简体内容,需要用UrlDecode解码
+        vendorid	注单更新顺序号
+        validamount	有效投注额
+     *
+     * */
+    private  function  getDefaultBackData(){
+        $array = [
+            "ballid"=>'',
+            "balltime"=>'',
+            "curpl"=>'',
+            "ds"=>'',
+            "dxc"=>'',
+            "isbk"=>'',
+            "iscancel"=>'',
+            "isdanger"=>'',
+            "isjs"=>'',
+            "lose"=>'',
+            "matchid"=>'',
+            "moneyrate"=>'',
+            "orderid"=>'',
+            "redcard"=>'',
+            "result"=>'',
+            "rowguid"=>'',
+            "rqc"=>'',
+            "rqteam"=>'',
+            "sportid"=>'',
+            "tballtime"=>'',
+            "thisdate"=>'',
+            "truewin"=>'',
+            "tzip"=>'',
+            "tzmoney"=>'',
+            "tzteam"=>'',
+            "tztype"=>'',
+            "updatetime"=>'',
+            "username"=>'',
+            "win"=>'',
+            "zdbf"=>'',
+            "content"=>'',
+            "vendorid"=>'',
+            "validamount"=>'',
+        ];
+        return $array ;
+    }
+
+}

+ 1 - 0
Biz/Match/GetOddsData.php

@@ -32,6 +32,7 @@ class GetOddsData {
             ->where($source)
             ->where(['lg_id'=>$data['leagueID']])
             ->where($whereDate)
+            ->where('st_zq_competition.us_time','>',qgmdate('Y-m-d H:i:s', '', -4))
             ->where('status','<',2)
             ->get()->toArray();
         if(empty($matchData))  throw new \Exception(Render([], '10004', lang('Tips','Sports')->get('PARAM_ERROR')));

+ 45 - 46
Biz/Match/GetmatchData.php

@@ -449,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)
@@ -459,26 +459,14 @@ class GetmatchData {
                                     ->where('match_date','>',date("Y-m-d",strtotime("+1weeks",strtotime(date('Y-m-d',time())))))
                                     ->count("*");
                             }else{
-                               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("*");
-                               }
+                                $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("*");
                             }
-
                         }
                     }
                     if($country[$k]['league_count'][$kk]['count'] == 0){
@@ -518,24 +506,13 @@ class GetmatchData {
                                     ->where('match_date', '>', date("Y-m-d", strtotime("+1weeks", strtotime(date('Y-m-d', 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("*");
-                                }
+                                $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("*");
                             }
                         }
                     }
@@ -789,6 +766,10 @@ class GetmatchData {
      * 获取欧冠  各状态赛事数据
      */
     public function getUEFAChampions($source){
+        //根据搜索查询
+        if(!empty($_GET['search'])){
+            $search = $_GET['search'];
+        }
         $model = getModels('gj',1);
 
         $model_league = $model['model_league'];
@@ -798,11 +779,11 @@ class GetmatchData {
             ->where($model_league.'.name_chinese','欧洲冠军杯')
             ->first();
         //获取滚球数据
-        $StRollBall = $this->getUEFAStRollBall($model,'StRollBall',$source,$leagueData->lg_id);
+        $StRollBall = $this->getUEFAStRollBall($model,'StRollBall',$source,$leagueData->lg_id,$search);
         //获取今日数据
-        $StToday = $this->getUEFAStToday($model,'StToday',$source,$leagueData->lg_id);
+        $StToday = $this->getUEFAStToday($model,'StToday',$source,$leagueData->lg_id,$search);
         //获取早盘数据
-        $StMorningPlate = $this->getUEFAStMorningPlate($model,'StMorningPlate',$source,$leagueData->lg_id);
+        $StMorningPlate = $this->getUEFAStMorningPlate($model,'StMorningPlate',$source,$leagueData->lg_id,$search);
         //获取冠军盘口数据
         $StChampion = $this->getUEFAStChampion($model,'StChampion',$source,$leagueData->lg_id,$leagueData->last_time);
 
@@ -836,7 +817,7 @@ class GetmatchData {
     /**
      * 获取欧冠 滚球数据
      */
-    public function getUEFAStRollBall($model,$type_code,$source,$lg_id){
+    public function getUEFAStRollBall($model,$type_code,$source,$lg_id,$search=''){
         $model_match = $model['model_match'];
         $model_odds = $model['model_odds'];
         $model_result = $model['model_result'];
@@ -848,6 +829,12 @@ class GetmatchData {
             ->where($model_match.'.source',$source['source'])
             ->where($model_match.'.lg_id',$lg_id)
             ->where($where)
+            ->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();
 
@@ -882,7 +869,7 @@ class GetmatchData {
                 ->get()
                 ->toarray();
 
-//根据 排序 获取 最新让球/大小玩法赔率
+            //根据 排序 获取 最新让球/大小玩法赔率
             $sortData = array_column($oddsData,'sort');
             array_multisort($sortData,SORT_DESC,$oddsData);
 
@@ -903,7 +890,7 @@ class GetmatchData {
     /**
      * 获取欧冠 今日数据
      */
-    public function getUEFAStToday($model,$type_code,$source,$lg_id){
+    public function getUEFAStToday($model,$type_code,$source,$lg_id,$search=''){
         $model_match = $model['model_match'];
         $model_odds = $model['model_odds'];
 
@@ -913,6 +900,12 @@ class GetmatchData {
             ->where($model_match.'.source',$source['source'])
             ->where($where)
             ->where('lg_id',$lg_id)
+            ->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();
 
         foreach($matchData as $kk => $vv) {
@@ -935,7 +928,7 @@ class GetmatchData {
     /**
      * 获取欧冠 早盘数据
      */
-    public function getUEFAStMorningPlate($model,$type_code,$source,$lg_id){
+    public function getUEFAStMorningPlate($model,$type_code,$source,$lg_id,$search=''){
         $model_match = $model['model_match'];
         $model_odds = $model['model_odds'];
 
@@ -946,6 +939,12 @@ class GetmatchData {
             ->where($model_match.'.source',$source['source'])
             ->where($where)
             ->where('lg_id',$lg_id)
+            ->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();
 
         $data = $this->getOddsData->getOddsZQ($matchData,$model_odds,$source);

+ 4 - 5
Biz/Money/Money.php

@@ -44,9 +44,8 @@ class Money {
 	 * @param  int    $type             交易类型
 	 * @return [type]                   [description]
 	 */
-	public function insertMoney($account_identity, $money, $order_id, $type, $game_no = '',$account=array())
+	public function insertMoney($account_identity, $money, $order_id, $type, $game_no = '',$UUID,$account=array())
 	{
-
 		//_beginTransaction();
 		//获取用户信息
 		if(empty($account)){
@@ -75,7 +74,7 @@ class Money {
 			return $updateAccountMoney;
 		}else {
 			//插入资金详情
-			$insertDetail = $this->insertDetail($account_identity, $order_id, $money, $nowMoney, $type,$account);
+			$insertDetail = $this->insertDetail($account_identity, $order_id, $money, $nowMoney, $type,$UUID,$account);
 			if($insertDetail !=1){
 				return $insertDetail;
 			}
@@ -116,7 +115,7 @@ class Money {
 	 * @param  [type] $type       交易类型的数字表示
 	 * @return [type]             [description]
 	 */
-	public function insertDetail($account_identity, $order_id, $money, $nowMoney, $type,$account)
+	public function insertDetail($account_identity, $order_id, $money, $nowMoney, $type,$UUID,$account)
 	{
 		//获取用户信息
 		if(empty($account)){
@@ -126,7 +125,7 @@ class Money {
 		$m_type = $this->getMtype($type);
         $trade_desc = $this->getDesc($account['account'], $money, $order_id, $type);
 		$data2 = array(
-			'info_identity' => UUID(),
+			'info_identity' => $UUID,
 			'trade_id' => $order_id,
 			'account_name' => $account['account'],
 			'account_identity' => $account_identity,

+ 91 - 4
Library/Common/function.php

@@ -743,7 +743,8 @@ function getState($type_code,$model_match = ''){
             case 'StMorningPlate'://早盘
                 $where = [
                     ['is_morningplate', '=', 1],
-                    ['match_date','>',date("Y-m-d",time())],
+                    ['us_time','>',qgmdate('Y-m-d H:i:s', '', -4)],
+//                    ['match_date','>',date("Y-m-d",time())],
 //                    ['match_time','>',date("H:i:s", time())],
 //                    ['type', '=', '2'],
 //                    ['status', '<', '2'],
@@ -753,6 +754,8 @@ function getState($type_code,$model_match = ''){
             case 'StStringScene'://串场
                 $where = [
                     ['is_stringscene', '=', 1],
+                    ['us_time','>',qgmdate('Y-m-d H:i:s', '', -4)],
+
 //                    ['match_date','>',date("Y-m-d",time())],
 //                    ['match_time','>',date("H:i:s", time())],
 //                    ['type', '=', '3'],
@@ -784,7 +787,6 @@ function getState($type_code,$model_match = ''){
                     [$model_match.'.match_date','=',date("Y-m-d")],
                     [$model_match.'.match_time','<',date("H:i:s", strtotime("+2 hour"))],
                     [$model_match.'.match_time','>',date("H:i:s", time())]
-
 //                    [$model_match.'.utime','>',date("Y-m-d").' 00:00:00']
                 ];
                 break;
@@ -806,16 +808,19 @@ 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.'.us_time','>',qgmdate('Y-m-d H:i:s', '', -4)],
+//                    [$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']
                 ];
                 break;
-            case 'StStringScene'://串场
+            case 'StStringScene'://串场 查询串场状态为1 开赛时间大于当前时间
                 $where = [
                     [$model_match.'.is_stringscene','=',1],
+                    [$model_match.'.us_time','>',qgmdate('Y-m-d H:i:s', '', -4)],
+
 //                    [$model_match.'.match_date','>',date("Y-m-d",time())],
 //                    [$model_match.'.match_time','>',date("H:i:s", time())],
 //                    [$model_match.'.type', '=', '3'],
@@ -913,3 +918,85 @@ function array_gj_tt($data,$oddsData){
 
     return array_values($data);
 }
+
+/**
+ * 时间格式化
+ * @param string $dateformat 时间格式
+ * @param int $timestamp 时间戳
+ * @param int $timeoffset 时区偏差 默认8 北京时间 -4美东时间
+ * @return string
+ */
+function qgmdate($dateformat = 'Y-m-d H:i:s', $timestamp = '', $timeoffset = 8) {
+    if(empty($timestamp)) {
+        $timestamp = time();
+    }
+    $result = gmdate($dateformat, $timestamp + $timeoffset * 3600);
+    return $result;
+}
+
+// 排列
+function arrangement($a, $m) {
+    $r = array();
+
+    $n = count($a);
+    if ($m <= 0 || $m > $n) {
+        return $r;
+    }
+
+    for ($i=0; $i<$n; $i++) {
+        $b = $a;
+        $t = array_splice($b, $i, 1);
+        if ($m == 1) {
+            $r[] = $t;
+        } else {
+            $c = arrangement($b, $m-1);
+            foreach ($c as $v) {
+                $r[] = array_merge($t, $v);
+            }
+        }
+    }
+
+    return $r;
+}
+
+// 组合
+function combination($a, $m) {
+    $r = array();
+
+    $n = count($a);
+    if ($m <= 0 || $m > $n) {
+        return $r;
+    }
+
+    for ($i=0; $i<$n; $i++) {
+        $t = array($a[$i]);
+        if ($m == 1) {
+            $r[] = $t;
+        } else {
+            $b = array_slice($a, $i+1);
+            $c = combination($b, $m-1);
+            foreach ($c as $v) {
+                $r[] = array_merge($t, $v);
+            }
+        }
+    }
+
+    return $r;
+}
+
+// 阶乘
+function factorial($n) {
+    return array_product(range(1, $n));
+}
+
+// 排列数
+function A1($n, $m) {
+    return factorial($n)/factorial($n-$m);
+}
+
+// 组合数
+function C1($n, $m) {
+    return A1($n, $m)/factorial($m);
+}
+
+