Parcourir la source

新增推送 4/24

彭俊 il y a 6 ans
Parent
commit
ff1e3df808

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

@@ -15,6 +15,7 @@ use Biz\Account\AccountManager;
 use Biz\Common\Common;
 use Biz\Game\GameList;
 use System\Lang;
+use App\Api\Model\AccountDetail;
 
 
 class Account extends BaseController {
@@ -686,4 +687,26 @@ class Account extends BaseController {
         }
         Render($data, 1);
     }
+
+    /**
+     * 修改用户基本信息
+     *
+     * @access public
+     * @return array JsonString
+     */
+    public function updateUserInfo() {
+        $code = 0;
+        $msg = lang('Common','Api') -> get('error');
+        try{
+            $accountDetailClass = new AccountDetail();
+            // 修改用户基本信息
+            $result = $accountDetailClass -> updateUserInfo();
+            $code = 1;
+            $msg = lang('Index','Api') -> get('success');
+
+            Render($result, $code, $msg);
+        } catch (Exception $e) {
+            Render([], $code, $msg);
+        }
+    }
 }

+ 226 - 242
Application/Api/Controller/BetOrder.php

@@ -29,74 +29,21 @@ class Betorder extends BaseController{
         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 ($last as $k =>$v){
+            foreach ($v as $kk =>$vv){
+                //验证赛事是否存在
+                $this->verify_match($vv['ballId'],$vv['match_id'],$kk+1);
+                //验证球类代码是否有效
+                $this->verify_gameType($vv['ballId'],$kk+1);
+                //验证赛事下赔率玩法是否有效
+//                $this->verify_odds($vv['ballId'],$vv['id'],$vv['odds_only'],$vv['odds'],$vv['condition'],$kk+1);
+            }
+        }
+
         foreach($res as $k => $v){
             //根据类型分组
             if($v['type'] == '1'){
@@ -108,7 +55,6 @@ class Betorder extends BaseController{
         if(!empty($data['bunch'])){
             $data['bunch'] = array_merge_recursive($data['bunch'],$last);
         }
-
         return $data;
     }
 
@@ -144,6 +90,7 @@ class Betorder extends BaseController{
         if(empty($data)||empty($userInfo)||empty($game_code)||empty($OrderID)||empty($UUID)){
             Render('', '7003',lang('Errors','Api')->get('error-7003'));
         }
+        $money = 0; //总投注额
         foreach($data as $k => $v){
             $bet_money = 0; //单个球类单条总投注金额
             $prize_money = 0; //可赢额
@@ -151,6 +98,7 @@ class Betorder extends BaseController{
             foreach($v as $kk => $vv){
                 $bet_money += $vv['bet_amount'];
                 $prize_money += ($vv['odds']-1)*$bet_money;
+                $money += $vv['bet_amount'];
             }
             $order =[
                 'info_identity' => $UUID,
@@ -169,12 +117,10 @@ class Betorder extends BaseController{
             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;
+        }
+        $insertMoney  = $this->M->insertMoney($userInfo['account_identity'],$money,$OrderID,1,"",$UUID,$userInfo);
+        if($insertMoney!=1){
+            Render('', $insertMoney,lang('Errors','Api')->get('error'.$insertMoney));
         }
     }
     /**
@@ -190,13 +136,12 @@ class Betorder extends BaseController{
         //验证与判断投注了几种
         foreach($res as $k => $v){
             $num = $k + 1;
-            $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);
+//            $this->verify_match($v['ballId'],$v['match_id'],$num);
+////            $this->verify_odds($v['ballId'],$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->simplex_money += $v['bet_amount'];
             //根据类型分组
             if(!isset($res[$v['ballId']])){
                 $res[$v['ballId']][] = $v;
@@ -225,14 +170,15 @@ class Betorder extends BaseController{
     public function Bet(){
         $userInfo = $this->getAgent();//获取用户信息
         $data = $_REQUEST['data'];
-        if(empty($data)){
+        $bet_money = $_REQUEST['bet_money'];
+        if(empty($data)||empty($bet_money)){
             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'));
-//        }
+        //获取用户金额信息
+        if(!$this->M->verifyMoney($bet_money,$userInfo['cash'])){
+            Render('', '4204',lang('Errors','Api')->get('error-4204'));
+        }
+//assAss
         //执行数据插入
         try {
             _beginTransaction();//开启事务
@@ -242,7 +188,7 @@ class Betorder extends BaseController{
             }
             if(!empty($data['bunch'])){
                 $data_all = $data['bunch'][count($data['bunch'])-1];//获取最后一个数组
-                $data['bunch'] = array_pop($data['bunch'][count($data['bunch'])-1]);//删除最后一个元素
+                unset($data['bunch'][count($data['bunch'])-1]);//删除最后一个元素
                 $this->stringBet($data['bunch'],$data_all,$userInfo);
             }
             _commit();//提交
@@ -268,49 +214,27 @@ class Betorder extends BaseController{
     /**
      * 赛事是否存在或结束
      * @param  [type] $game_code 球类代码
-     * @param  [type] $odds_id  赔率ID
+     * @param  [type] $match_id  赔率ID
      * @param  [type] $num 循环键值
-     * $type_str 串式类型
+     * $@param  [type]type_str 串式
      */
-    public  function verify_match($game_code,$match_id='',$num,$type_str = ''){
-        if(empty($odds_id)){
-            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);
-            }
+    public  function verify_match($game_code,$match_id,$num = 1){
+        if(empty($match_id)){
+                $msg = '第'.$num.'条'.lang('Errors','Api')->get('error-5109');
+                Render([], '5109',$msg);
         }
-
         //根据球类代码 获取相关model
         $models = getModels($game_code);
-        $model_odds = $models['model_odds'];
         $model_match = $models['model_match'];
         $info = lm($model_match,'Sports')
             ->select('status')
-//            ->where('status', '<', '2')
-//            ->where('us_time','>',qgmdate('Y-m-d H:i:s','', -4))
+            ->where('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){
-            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);
-            }
+            $msg = '第'.$num.'条'.lang('Errors','Api')->get('error-5103');
+            Render([], '5103',$msg);
         }
         return $info;
     }
@@ -319,28 +243,16 @@ class Betorder extends BaseController{
      * 验证球类是否存在
      * @param  [type] $game_code 球类代码
      * @param  [type] $num 第几条
-     * $type_str 串式类型
      */
-    public  function verify_gameType($game_code,$num,$type_str=''){
+    public  function verify_gameType($game_code,$num){
         if(empty($game_code)){
-            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);
-            }
-
+            $msg = '第'.$num.'条数据'.lang('Errors','Api')->get('error-5102');
+            Render([], '5102', $msg);
         }
         $info = lm('GameType','Sports')->where('game_code',$game_code)->first();
         if(empty($info)){
-            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);
-            }
+            $msg = '第' . $num . '条数据' . lang('Errors', 'Api')->get('error-5102');
+            Render([], '5102', $msg);
         }
         return $info;
     }
@@ -350,34 +262,39 @@ class Betorder extends BaseController{
      * @param  [type] $game_code 球类代码
      *  @param  [type] $odds_id 赔率IDkk
      */
-    public function verify_odds($game_code,$odds_id,$odds_only,$odds,$condition,$num){
+    public function verify_odds($game_code,$odds_id,$odds_only,$odds,$condition,$num = 1){
         if(empty($odds_id)||empty($odds_only)||empty($condition)||empty($odds)){
             $msg = '第'.$num.'条数据'.lang('Errors','Api')->get('error-7029');
             Render([], '7029', $msg);
         }
+
         //根据球类代码 获取相关model
         $models = getModels($game_code);
         $model_odds = $models['model_odds'];
         $model_odds_record = $models['model_odds_record'];
-        $info = lm($model_odds,'Sports')
-            ->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)
+        $odds_info = lm($model_odds,'Sports')
+            ->select('odds','condition')
+            ->where('id',$odds_id)
+            ->first();
+        $odds_record = lm($model_odds_record,'Sports')
+            ->select('odds','condition')
+            ->where('odds_only',$odds_only)
             ->first();
-        if(!$info){
+        if(empty($odds_info)||empty($odds_record)){
             $msg = '第'.$num.'条数据'.lang('Errors','Api')->get('error-7029');
             Render([], '70291', $msg);
         }
-        $info->toarray();
-        if($odds != $info['odds']){
+        $odds_info = $odds_info->toarray();
+        $odds_record = $odds_record->toarray();
+        if($odds != $odds_info['odds']||$odds != $odds_record['odds']){
             $msg = '第'.$num.'条数据'.lang('Errors','Api')->get('error-7029');
             Render([], '70292', $msg);
         }
-        if($condition = $info['condition']){
+        if($condition = $odds_info['condition']||$condition = $odds_record['condition']){
             $msg = '第'.$num.'条数据'.lang('Errors','Api')->get('error-7029');
             Render([], '70293', $msg);
         }
-        return $info;
+        return $odds_info;
     }
 
     /**
@@ -387,75 +304,92 @@ class Betorder extends BaseController{
      * $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,
-            ]
-        ];
+//        $userInfo = $this->getAgent();
+//        dd($userInfo);
+//        //所有串式数据
+//        $data_str = [
+//            [
+//                'type'=>'4串1',//串式名称
+//                'odds'=>'',//当前串式赔率
+//                'bet_amount'=> 1,
+//            ],
+//            [
+//                'type'=>'3串1',//串式名称
+//                'odds'=>'',//当前串式赔率
+//                'bet_amount'=> 1,
+//            ],
+//            [
+//                'type'=>'2串1',//串式名称
+//                'odds'=>'',//当前串式赔率
+//                'bet_amount'=> 1,
+//            ],
+//            [
+//                'type'=>'4串11',//串式名称
+//                'odds'=>'',//当前串式赔率
+//                'bet_amount'=> 1,
+//            ],
+//        ];
+//
+//        $data_all = [
+//            [
+//                'id' => 887529,
+//                'home_team' => '阿尔艾利开罗',
+//                'guest_team' => '金字塔',
+//                'name' => '阿尔艾利开罗',
+//                'odds' => '2.02',
+//                '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.01',
+//                '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.94',
+//                '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'));
@@ -464,14 +398,6 @@ class Betorder extends BaseController{
         //验证串式投注是否合法
         $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'));
@@ -480,6 +406,7 @@ class Betorder extends BaseController{
 
         $orderData = [];
         $orderID = OrderID();
+        $all_money=[];//所有投注金额
         foreach ($data_str as $k=>$v){
             //字符串替换
             $str = str_ireplace("串","_",$v['type']);
@@ -495,28 +422,42 @@ class Betorder extends BaseController{
             }
 
             //获取当前串式投注金额及可赢金额
-            $money_all = $this->makeMoney((int)$sonNum,$v['bet_amount'],$multiple,$data_all,$after);
-
+            if($after == 1){
+                $money_all = $this->getmakeMoney((int)$sonNum,$v['bet_amount'],$multiple,$data_all,$after);
+            }else{
+                $money_all = $this->getStrAllMoney((int)$sonNum,$v['bet_amount'],$multiple,$data_all,$after);
+            }
             //投注金额
             $moneyData = $money_all['moneyData'];
+            //所有投注金额
+            $all_money[] = $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;
+            $orderData['game_name'] = $v['type'];
+            $orderData['info_identity'] = $uuid;
+            $orderData['account_name'] = $userInfo['account'];
+            $orderData['account_identity'] = $userInfo['account_identity'];
+            $orderData['order_id'] = $orderID;
+            $orderData['game_no'] = "";
+            $orderData['money'] = $moneyData;
+            $orderData['bet_str_id'] = $bet_ttr_id;//投注数据
+            $orderData['money_time'] = $this->time;//下注时间
+            $orderData['prize_money'] = $prize_money;//可赢金额
+
+            $ret = lm('MoneyBuyStr','Api')->insert($orderData);
+
+            if(!$ret){
+                Render('','-1005',lang('errors','Api')->get('error-3205'));
+            }
+        }
+        $insertMoney  = $this->M->insertMoney($userInfo['account_identity'],array_sum($all_money),$orderID,1,"",$uuid,$userInfo);
+        if($insertMoney!=1){
+            Render('', $insertMoney,lang('Errors','Api')->get('error'.$insertMoney));
+        }
+
+        return true;
     }
 
     /**
@@ -540,13 +481,6 @@ class Betorder extends BaseController{
         return $group/$son;
     }
 
-    /**
-     * 计算串式投注 赔率
-     */
-    public function getOddsStr(){
-
-    }
-
     /**
      * @param int $sonNum 当前串式数量
      * @param int $bet_amount 当前串式投注额
@@ -555,7 +489,7 @@ class Betorder extends BaseController{
      * @return mixed
      * 计算当前串式投注总额、可赢总额
      */
-    public function makeMoney($sonNum=0,$bet_amount=0,$multiple=0,$data_all=[],$after = 0){
+    public function getmakeMoney($sonNum=0,$bet_amount=0,$multiple=0,$data_all=[],$after = 0){
         $allNum = count($data_all);//所有数量
         $odds_all = [];//所有投注项数据
         foreach ($data_all as $k=>$v){
@@ -579,9 +513,31 @@ class Betorder extends BaseController{
             $odds = (array_sum($odds))-(count($odds));
 
             //获取可赢金额
-            $data['prize_money'] =  floor($bet_amount*($odds)*100)/100;//保留两位小数
+            $data['prize_money'] =  floor($bet_amount*($odds)*100)/100;
+        }
+
+        return $data;
+    }
+
+    /**
+     * 获取所有可用串式  N场赛事 2串1,3串1...N串1,N<11
+     * 并计算 其投注可赢金额
+     */
+    public function getStrAllMoney($sonNum=0,$bet_amount=0,$multiple=0,$data_all=[],$after = 0){
+        $d = [];
+        for ($i=2;$i<($sonNum+1);$i++){
+            $d[] = $i;
         }
 
+        foreach ($d as $k=>$v){
+            $multiple = $this->getMultiple($sonNum,$v);
+            $money[] = $this->getmakeMoney($v,$bet_amount,$multiple,$data_all,1);
+        }
+        $data=array();
+        foreach($money as $k=>$v){
+            $data['moneyData']+=$v['moneyData'];
+            $data['prize_money']+=$v['prize_money'];
+        }
         return $data;
     }
 
@@ -606,5 +562,33 @@ class Betorder extends BaseController{
             }
         }
     }
+
+    /**
+     * 更新投注项相关数据
+     */
+    public function getBetData(){
+        $data = $_REQUEST;
+//        $data = [['game_code'=>'zq','match_id'=>3095448,'odds_id'=>623078],['game_code'=>'zq','match_id'=>3095448,'odds_id'=>623078]];
+        foreach ($data as $k=>$v){
+            $getModels = getModels($v['game_code']);
+            $model_match = $getModels['model_match'];
+            $model_odds = $getModels['model_odds'];
+
+            $oddsData = lm($model_match,"Sports")
+                ->join($model_odds,$model_odds.'.match_id',$model_match.'.match_id')
+                ->select($model_match.'.match_id',$model_match.'.match_date',$model_match.'.home_team',$model_match.'.guest_team',$model_odds.'.id as odds_id',$model_odds.'.p_code',$model_odds.'.odds_code',$model_odds.'.condition',$model_odds.'.odds',$model_odds.'.odds_only',$model_odds.'.status',$model_odds.'.sort')
+                ->where($model_match.'.source',$this->source)
+                ->where($model_match.'.match_id',$v['match_id'])
+                ->where($model_odds.'.id',$v['odds_id'])
+                //->where($model_odds.'.expire_time','>',date("Y-m-d H:i:s"))
+                ->first();
+            $oddsData->game_code = $v['game_code'];
+
+            $betData[] = $oddsData;
+        }
+
+        Render($betData, '1', lang('Tips','Sports')->get('success'));
+    }
+
 }
 

+ 26 - 4
Application/Api/Controller/UserBuy.php

@@ -32,9 +32,9 @@ class UserBuy extends BaseController {
      * @return array JsonString
      */
     public function bettingRecord() {
-        $code = 0;
+        /*$code = 0;
         $msg = lang('Common','Api') -> get('error');
-        try{
+        try{*/
             $moneyBuyClass = new MoneyBuy();
             // 获取下注信息
             $result = $moneyBuyClass -> bettingRecord();
@@ -42,10 +42,10 @@ class UserBuy extends BaseController {
             $msg = lang('Index','Api') -> get('success');
 
             Render($result, $code, $msg);
-        } catch (Exception $e) {
+        /*} catch (Exception $e) {
             Render([], $code, $msg);
             //Render([], $code, $e->getMessage());
-        }
+        }*/
     }
 
     /**
@@ -94,6 +94,28 @@ class UserBuy extends BaseController {
         }
     }
 
+    /**
+     * 取款记录
+     *
+     * @access public
+     * @return array JsonString
+     */
+    public function moneyOutRecord() {
+        $code = 0;
+        $msg = lang('Common','Api') -> get('error');
+        try{
+            $moneyRechargeClass = new MoneyRecharge();
+            // 获取取款记录
+            $result = $moneyRechargeClass -> moneyOutRecord();
+            $code = 1;
+            $msg = lang('Index','Api') -> get('success');
+
+            Render($result, $code, $msg);
+        } catch (Exception $e) {
+            Render([], $code, $msg);
+        }
+    }
+
     /**
      * 中奖记录
      *

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

@@ -16,5 +16,6 @@ return array(
     'you have submitted your application for withdrawal' => '您已提交提现申请,不可频繁提交,请稍候再试',
     'the application failed' => '申请失败,请重试',
     'application has been submitted and customer service is under review' => '已提交申请,客服正在审核中',
+    'please enter the modification' => '请输入修改内容',
 );
 ?>

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

@@ -36,6 +36,7 @@ return array(
     'error-4023' => '密码不能为空',
     'error-4022' => '用户名不能为空',
     'error-4024' => '银行卡不能为空',
+    'error-4027' => '请输入修改内容',
     'error-4046' => '未提交订单号',
     'error-4047' => '获取订单详情失败',
     'error-40251' => '没有开户行地址',
@@ -243,6 +244,8 @@ return array(
     'error-5106' => '赔率为空',
     'error-5107' => '赔率ID为空',
     'error-5108' => '该赛事已结束',
+    'error-5109' => '赛事ID为空',
+
 
     'error-40251' => '请填写代理地址',
     'error-40252' => '请填写开户人姓名',

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

@@ -6,9 +6,46 @@
  *------Create Time 2017-06-12 05:08:18------
  */
 namespace App\Api\Model;
+
 use \System\Model;
+use Biz\Account\AccountManager;
 
 class AccountDetail extends Model {
 
     protected $table = 'account_detailed';
+
+    /**
+     * 修改用户基本信息
+     *
+     * @access public
+     * @return String
+     */
+    public function updateUserInfo()
+    {
+        // 获取用户信息
+        $accountManagerClass = new AccountManager;
+        $userInfo = $accountManagerClass -> getCurrentUser();
+        if (empty($userInfo['identity'])) {
+            Render([], '2001', lang('Common','Api') -> get('user does login'));
+        }
+        $updateWhere['account_identity'] = $userInfo['identity'];
+        $updateData = [];
+        // 提取修改数据
+        if (!empty($_POST['email'])) {
+            $updateData['email'] = $_POST['email'];
+        }
+        if (!empty($_POST['phone'])) {
+            $updateData['phone'] = $_POST['phone'];
+        }
+        if (!empty($_POST['img_id'])) {
+            $updateData['img_id'] = $_POST['img_id'];
+        }
+        if (!empty($_POST['name'])) {
+            $updateData['name'] = $_POST['name'];
+        }
+        if (empty($updateData)) {
+            Render([], '4027', lang('Common','Api') -> get('please enter the modification'));
+        }
+        lm('Account_detailed', 'commons') -> updateDetailed($updateWhere, $updateData);
+    }
 }

+ 88 - 12
Application/Api/Model/MoneyBuy.php

@@ -102,8 +102,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;
+        $endTime = isset($_POST['endTime'])? $_POST['endTime'] : '3000-12-12 00:00:00';
         $moneyBuyBetween = [$startTime, $endTime];
         // 当前页
         $currentPage = isset($_POST['currentPage']) ? $_POST['currentPage'] : "1";
@@ -112,20 +111,97 @@ class MoneyBuy extends Model {
         // 起始查询位置
         $begin = ($currentPage - 1) * $pageSize;
         $moneyBuy = lm('money_buy', "commons");
+        $moneyBuyStr = lm('money_buy_str', "commons");
         // 获取投注记录
-        $getMoneyBuy = $moneyBuy -> moneyBuy($moneyBuyWhere, $moneyBuyBetween, $begin, $pageSize);
-        // 获取记录总数
-        $result['total'] = count($getMoneyBuy);
-        // 循环分配数据到查询条件
-        foreach ($getMoneyBuy as $key => $value) {
-            $codeInfo = json_decode($value->codes);
+        $moneyBuySelect = ['game_status', 'money', 'codes', 'money_time'];
+        $getMoneyBuy = $moneyBuy -> moneyBuy($moneyBuySelect, $moneyBuyWhere, $moneyBuyBetween, $begin, $pageSize);
+        $moneyBuyStrSelect = ['game_status', 'money', 'bet_str_all', 'money_time'];
+        $getMoneyBuyStr = $moneyBuyStr -> moneyBuyStr($moneyBuyStrSelect, $moneyBuyWhere, $moneyBuyBetween, $begin, $pageSize);
+        // 两数组重组排序
+        $allMoneyBuy = [];
+        $allCount = count($getMoneyBuy) + count($getMoneyBuyStr);
+        $n = 0;
+        $m = 0;
+        for ($i = 1; $i <= $allCount; $i++) {
+            if ($getMoneyBuy[$n]->money_time >= $getMoneyBuyStr[$m]->money_time) {
+                $allMoneyBuy[] = $getMoneyBuy[$n];
+                $n++;
+            } else {
+                $allMoneyBuy[] = $getMoneyBuyStr[$m];
+                $m++;
+            }
+        }
+        // 获取游戏类型
+        $StGameTypeModel = lm('StGameType','commons');
+        $getGameTypeWhere['status'] = 1;
+        $getGameTypeSelect = ['game_code'];
+        $getGameType = $StGameTypeModel -> getGameType($getGameTypeSelect, $getGameTypeWhere);
+        $stOddsWheres = [];
+        foreach ($getGameType as $value) {
+            $stOddsWheres[$value['game_code']] = '';
+        }
+        // 获取可加注所需要的查询条件
+        foreach ($allMoneyBuy as $key => $value) {
+            $codeInfo = [];
+            if ($value->codes) {
+                $codeInfo = json_decode($value->codes);
+            } elseif ($value->bet_str_all) {
+                $codeInfo = json_decode($value->bet_str_all);
+            }
+            foreach ($codeInfo as $k => $v) {
+                $match_id = $v->match_id;
+                $odds_code = $v->odds_code;
+                $ballId = $v->ballId;
+                $where = [
+                    'match_id' => $match_id,
+                    'odds_code' => $odds_code,
+                ];
+                // 判断是否重复
+                if(!judgeEqual($where, $stOddsWheres[$ballId])){
+                    $stOddsWheres[$ballId][] = $where;
+                }
+            }
+        }
+        // 查询数据下所有可加注的游戏
+        $stOddsModel = lm('stOdds','commons');
+        $stOddsSelect = ['match_id', 'odds_code'];
+        $getSstOdds = [];
+        foreach ($stOddsWheres as $key => $value) {
+            if ($value) {
+                $getSstOdds[$key] = $stOddsModel -> stOdds($stOddsSelect, $value, $key)->toArray();;
+            }
+        }
+        // 循环添加玩法和判断玩法是否可加注
+        $stOddsCodeModel = lm('StOddsCode','commons');
+        foreach ($allMoneyBuy as $key => $value) {
+            $codeInfo = [];
+            if ($value->codes) {
+                $codeInfo = json_decode($value->codes);
+            } elseif ($value->bet_str_all) {
+                $codeInfo = json_decode($value->bet_str_all);
+            }
             foreach ($codeInfo as $k => $v) {
-                $gameType = lang('OddsTemp','Api') -> get($v->odds_code);
+                $stOddsCodeWhere['odds_code'] = $v->odds_code;
+                // 添加玩法
+                $gameType = $stOddsCodeModel -> stOddsCode($stOddsCodeWhere);
                 $codeInfo[$k]->gameType = $gameType;
+                $typeSstOdds = $getSstOdds[$v->ballId];
+                $thisSstOdds = [
+                    'match_id' => $v->match_id,
+                    'odds_code' => $v->odds_code,
+                ];
+                // 判断如果在数组中则为可加注
+                if (!judgeEqual($thisSstOdds, $typeSstOdds)) {
+                    $codeInfo[$k]->addBet = 0;
+                } else {
+                    $codeInfo[$k]->addBet = 1;
+                }
             }
-            $getMoneyBuy[$key]['codes'] = json_encode($codeInfo);
+            $allMoneyBuy[$key]->codes = json_encode($codeInfo);
         }
-        $result['list'] = $getMoneyBuy;
+        // 获取记录总数
+        $result['total'] = $allCount;
+        $result['list'] = $allMoneyBuy;
         // 总页数计算
         $result['countPage'] = ceil($result['total'] / $pageSize);
         $result['currentPage'] = $currentPage;
@@ -153,7 +229,7 @@ class MoneyBuy extends Model {
         $moneyRecordWhere['status'] = 1;
         // 时间区间
         $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");
+        $endTime = isset($_POST['endTime'])? $_POST['endTime'] : '3000-12-12 00:00:00';
         $moneyRecordBetween = [$startTime, $endTime];
         // 当前页
         $currentPage = isset($_POST['currentPage']) ? $_POST['currentPage'] : "1";

+ 1 - 1
Application/Api/Model/MoneyPrize.php

@@ -31,7 +31,7 @@ class MoneyPrize extends Model {
         $prizeRecordWhere['status'] = 1;
         // 时间区间
         $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");
+        $endTime = isset($_POST['endTime'])? $_POST['endTime'] : '3000-12-12 00:00:00';
         $prizeRecordBetween = [$startTime, $endTime];
         // 当前页
         $currentPage = isset($_POST['currentPage']) ? $_POST['currentPage'] : "1";

+ 41 - 1
Application/Api/Model/MoneyRecharge.php

@@ -87,7 +87,7 @@ class MoneyRecharge extends Model {
         $rechargeRecordWhere['status'] = 1;
         // 时间区间
         $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");
+        $endTime = isset($_POST['endTime'])? $_POST['endTime'] : '3000-12-12 00:00:00';
         $rechargeRecordBetween = [$startTime, $endTime];
         // 当前页
         $currentPage = isset($_POST['currentPage']) ? $_POST['currentPage'] : "1";
@@ -108,4 +108,44 @@ class MoneyRecharge extends Model {
         return $result;
     }
 
+    /**
+     * 取款记录
+     *
+     * @access public
+     * @return String
+     */
+    public function moneyOutRecord()
+    {
+        // 获取用户信息
+        $accountManagerClass = new AccountManager;
+        $userInfo = $accountManagerClass -> getCurrentUser();
+        if (empty($userInfo['identity'])) {
+            Render([], '2001', lang('Common','Api') -> get('user does login'));
+        }
+        $moneyTakeWhere = array();
+        // 用户ID
+        $moneyTakeWhere['account_identity'] = $userInfo['identity'];
+        // 时间区间
+        $startTime = isset($_POST['startTime'])? $_POST['startTime'] : '1900-01-01 00:00:00';
+        $endTime = isset($_POST['endTime'])? $_POST['endTime'] : '3000-12-12 00:00:00';
+        $moneyTakeBetween = ['apply_time' => [$startTime, $endTime]];
+        // 当前页
+        $currentPage = isset($_POST['currentPage']) ? $_POST['currentPage'] : "1";
+        // 分页大小
+        $pageSize = isset($_POST['pageSize']) ? $_POST['pageSize'] : "10";
+        // 起始查询位置
+        $begin = ($currentPage - 1) * $pageSize;
+        $moneyTake = lm('Money_take', "commons");
+        $moneyTakeSelect = ['id', 'account_name', 'money', 'apply_time', 'pass_time', 'give_time', 'bank_no', 'bank_info', 'status', 'money_cash'];
+        // 获取提款记录
+        $result['list'] = $moneyTake -> moneyTake($moneyTakeSelect, $moneyTakeWhere, $moneyTakeBetween, $begin, $pageSize);
+        // 获取记录总数
+        $result['total'] = count($result['list']);
+        // 总页数计算
+        $result['countPage'] = ceil($result['total'] / $pageSize);
+        $result['currentPage'] = $currentPage;
+
+        return $result;
+    }
+
 }

+ 3 - 1
Application/Commons/Model/Money_buy.php

@@ -19,6 +19,7 @@ class Money_buy extends Model {
      * 投注记录
      *
      * @access public
+     * @param mixed $select 查询字段
      * @param mixed $moneyBuyWhere 查询条件
      * @param mixed $moneyBuyBetween 查询条件区间
      * @param mixed $begin 起始查询位置
@@ -26,9 +27,10 @@ class Money_buy extends Model {
      * @param mixed $orderBy 排序字段
      * @return array JsonString
      */
-    public function moneyBuy($moneyBuyWhere, $moneyBuyBetween, $begin, $pageSize, $orderBy = 'money_time') {
+    public function moneyBuy($select, $moneyBuyWhere, $moneyBuyBetween, $begin, $pageSize, $orderBy = 'money_time') {
         $result = $this
             //-> join('article','money_buy.info_identity','=','article.identity')
+            -> select($select)
             -> where($moneyBuyWhere)
             -> whereBetween('money_time', $moneyBuyBetween)
             -> offset($begin)

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

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

+ 39 - 2
Application/Commons/Model/Money_take.php

@@ -22,7 +22,7 @@ class Money_take extends Model {
      * @param mixed $order 顺序
      * @return array JsonString
      */
-    public function takeRecord ($select, $where, $orderBy = 'apply_time', $order = 'desc') {
+    public function takeRecord($select, $where, $orderBy = 'apply_time', $order = 'desc') {
         $result = $this
             -> select($select)
             -> where($where)
@@ -32,6 +32,43 @@ class Money_take extends Model {
         return $result;
     }
 
+    /**
+     * 提现记录查询
+     *
+     * @access public
+     * @param mixed $select 查询字段
+     * @param mixed $where 查询条件
+     * @param mixed $between 查询区间 demo: ['apply_time' => [2019-04-19 10:46:35, 2019-04-19 10:46:35],'id'=>[99448,99448]];
+     * @param mixed $begin 起始位置
+     * @param mixed $pageSize 分页大小
+     * @param mixed $orderBy 排序 demo: ['apply_time'=>'desc','id'=>'desc']
+     * @return array JsonString
+     */
+    public function moneyTake($select, $where = '', $between = '', $begin = '', $pageSize = '', $orderBy = '') {
+        $result = $this -> select($select);
+        if (!empty($where)) {
+            $result = $result -> where($where);
+        }
+        if (!empty($between)) {
+            foreach ($between as $key => $value) {
+                $result = $result -> whereBetween($key, $value);
+            }
+        }
+        if (count($begin) && isset($pageSize)) {
+            $result = $result -> offset($begin) -> limit($pageSize);
+        }
+        if (!empty($orderBy)) {
+            foreach ($orderBy as $key => $value) {
+                $result = $result -> orderBy($key, $value);
+            }
+        } else {
+            $result = $result -> orderBy('apply_time', 'desc');
+        }
+        $result = $result -> get();
+
+        return $result;
+    }
+
     /**
      * 添加提现记录
      *
@@ -39,7 +76,7 @@ class Money_take extends Model {
      * @param mixed $data 添加的字段
      * @return array JsonString
      */
-    public function insertTake ($data) {
+    public function insertTake($data) {
         $result = $this -> insert($data);
 
         return $result;

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

@@ -0,0 +1,33 @@
+<?php
+/**
+*------Create thems Model------
+*------SCWPHP  Version 1.0.0------
+*------Dev Model Jions------
+*------Create Time 2019-04-15 16:05:26------
+*/
+namespace App\Commons\Model;
+
+use \System\Model;
+
+class StGameType extends Model {
+    protected $table = 'st_game_type';
+
+    /**
+     * 获取赛事类型
+     *
+     * @access public
+     * @param mixed $select 查询字段
+     * @param mixed $where 查询条件
+     * @param mixed $orderBy 排序字段
+     * @return array JsonString
+     */
+    public function getGameType($select, $where, $orderBy = 'game_code') {
+        $result = $this
+            -> select($select)
+            -> where($where)
+            -> orderBy($orderBy)
+            -> get();
+
+        return $result;
+    }
+}

+ 50 - 0
Application/Commons/Model/StOdds.php

@@ -0,0 +1,50 @@
+<?php
+/**
+*------Create thems Model------
+*------SCWPHP  Version 1.0.0------
+*------Dev Model Jions------
+*------Create Time 2019-04-15 16:05:26------
+*/
+namespace App\Commons\Model;
+
+use \System\Model;
+
+class StOdds extends Model {
+    protected $table = '';
+
+    /**
+     * 获取赛事玩法是否还存在
+     *
+     * @access public
+     * @param mixed $select 查询字段
+     * @param mixed $wheres 查询条件
+     * @param mixed $type 运动类型
+     * @return array JsonString
+     */
+    public function stOdds($select, $wheres, $type) {
+        $this->table = 'st_'. $type .'_odds';
+        $count = count($wheres);
+        $result = [];
+        $unionAll = [];
+        foreach ($wheres as $key => $value) {
+            if ($key === 0) {
+                $unionAll[0] = $this
+                    -> select($select)
+                    -> where($value);
+            } elseif ($key + 1 === $count) {
+                $result = $this
+                    -> select($select)
+                    -> where($value)
+                    -> unionAll($unionAll[$key - 1])
+                    -> get();
+            } else {
+                $unionAll[$key] = $this
+                    -> select($select)
+                    -> unionAll($unionAll[$key - 1])
+                    -> where($value);
+            }
+        }
+
+        return $result;
+    }
+}

+ 30 - 0
Application/Commons/Model/StOddsCode.php

@@ -0,0 +1,30 @@
+<?php
+/**
+*------Create thems Model------
+*------SCWPHP  Version 1.0.0------
+*------Dev Model Jions------
+*------Create Time 2019-04-15 16:05:26------
+*/
+namespace App\Commons\Model;
+
+use \System\Model;
+
+class StOddsCode extends Model {
+    protected $table = 'st_odds_code';
+
+    /**
+     * 获取玩法
+     *
+     * @access public
+     * @param mixed $where 查询条件
+     * @return array JsonString
+     */
+    public function stOddsCode($where) {
+        $result = $this
+            -> select('odds_name')
+            -> where($where)
+            -> first();
+
+        return $result['odds_name'];
+    }
+}

+ 2 - 2
Application/Commons/Model/Wagent.php

@@ -12,8 +12,8 @@ class Wagent extends Model {
 protected $table = 'wagent';
 
     function getByName($name){
-        $data = $this->where('agent_name', $name)->first();
-
+       $data = $this->where('agent_name', $name)->first();
+       
         if (!$data) {
             return false;
         }

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

@@ -12,6 +12,7 @@ use BaseController\Controller;
 use Biz\Game\GameLogic;
 use App\Commons\Model\Wagent;
 
+
 class Index extends Controller {
     //用户上传参数数组;
     private $paras = [] ;
@@ -157,8 +158,6 @@ class Index extends Controller {
         }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');
 

+ 3 - 3
Application/Sports/Controller/HomeMatch.php

@@ -17,10 +17,10 @@ class HomeMatch extends Controller {
      */
     public function highMatch (){
         $ret  = lm("st_zq_competition","Sports")
-            ->join('st_zq_league','st_zq_league.id','=','st_zq_competition.lg_id')
-            ->select('st_zq_league.id','st_zq_league.name_chinese','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')
+            ->join('st_zq_league','st_zq_league.lg_id','=','st_zq_competition.lg_id')
+            ->select('st_zq_league.lg_id','st_zq_league.name_chinese','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')
             ->limit(3)
-            ->where('st_zq_competition.recommend',1)
+            ->where('recommend',1)
             ->get();
 
         $data = [

+ 0 - 10
Application/Sports/Controller/MatchList.php

@@ -824,16 +824,6 @@ class  MatchList extends Controller {
      * 获取球类-玩法-赔率代码
      */
     public function getOddsCode(){
-        $game_code = lm('GameType', 'Sports')->select('game_code')->where('status',1)->get()->toArray();
-
-//        $oddsCodeData = [];
-//        foreach ($game_code as $k =>$v){
-//            $oddsCodeData[$v['game_code']] = lm('st_odds_code','Sports')
-//                ->select('id','p_id','odds_code','odds_name','type')
-//                ->where('game_type', 'like', '%' . $v['game_code'] . '%')
-////                ->groupBy('id','p_id','odds_code','odds_name','type')
-//                ->get()->toarray();
-//        }
 
         $p_code = lm('st_odds_code','Sports')
                 ->select('id','p_id','odds_code','odds_name','type')

+ 3 - 3
Application/Sports/Controller/Sports.php

@@ -47,7 +47,7 @@ class Sports extends Controller{
             ->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($st_competition.'.us_time','>',qgmdate('Y-m-d H:i:s', '', -4))
             ->where($where)
             ->limit($limit_mt)
             ->get();
@@ -60,7 +60,7 @@ class Sports extends Controller{
             ->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($st_competition.'.us_time','>',qgmdate('Y-m-d H:i:s', '', -4))
             ->where($where)
             ->limit($limit_lg)
             ->distinct($st_league.'lg_id')
@@ -88,7 +88,7 @@ class Sports extends Controller{
         $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);
+        $data = array_merge_recursive($zq,$lq,$bq,$wq);
         Render($data,'1', lang('Tips','Sports')->get('success'));
     }
 }

+ 2 - 1
Biz/Game/GameLogic.php

@@ -138,9 +138,10 @@ class GameLogic
     public function GetBalance(){
 
         $accountModel= $this->accountAndPassCheck();
-        $account_identity = $accountModel->account_indentity;
+        $account_identity = $accountModel->identity;
 
         $parentinfo = lm('account_detailed', 'commons')->where('account_identity', $account_identity)->first();
+
         if (empty($parentinfo)) {
             return $this->makeret(1,'账号记录不存在','0');
         }

+ 3 - 5
Biz/Game/SportbetRecordLogic.php

@@ -38,15 +38,10 @@ class SportbetRecordLogic
     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;
@@ -64,6 +59,9 @@ class SportbetRecordLogic
             $this->Setval('updatetime',$buyModel->money_time);
             $this->Setval('validamount',$buyModel->money);
             $this->Setval('tztype',$buyModel->game_name);
+            $this->Setval('orderid',$buyModel->order_id);
+
+
             $this->Setval('iscancel',($buyModel->status==4) ? 1 : 0 );
 
             switch ( strtolower($buyModel->game_name) ){

+ 6 - 2
Biz/Game/TranferMoneyLogic.php

@@ -148,8 +148,12 @@ class TranferMoneyLogic
 
         $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)   ;
+
+        $beforeMoney = intval(trim($this->accountDetailModel->available_cash)*100 ) ;
+        $afterMoney =  ( $this->type == 'IN') ? (($beforeMoney + $this->money*100)/100) : (($beforeMoney - $this->money*100)/100) ;
+        $this->accountDetailModel->available_cash = sprintf("%.2f",$afterMoney)   ;
+
         $ret = $this->accountDetailModel->save();
 
         return $ret  ;
@@ -160,7 +164,7 @@ class TranferMoneyLogic
     private function  moneyTranferRecord(){
 
         $this->transferModel->account_indent = $this->accountModel->identity;
-        $this->transferModel->ordernumber = UUID();
+        $this->transferModel->ordernumber = date("YmdHis").uniqid();
         $this->transferModel->billno = $this->paras['billno'];
         $this->transferModel->tradeamount = sprintf("%.2f", $this->money )    ;
         $this->transferModel->blance = $this->accountDetailModel->cash ;

+ 5 - 2
Biz/Match/GetmatchData.php

@@ -541,8 +541,9 @@ class GetmatchData {
 
         $leagueData = lm($model_league,'Sports')
             ->select('id','lg_id','name_chinese as league','country_id','area_id')
-            ->get()
             ->where($source)
+            ->where($model_league.'.name_chinese','like','%'.$search.'%')
+            ->get()
             ->toArray();
 
         $oddsData = lm($model_odds,'Sports')
@@ -740,15 +741,17 @@ class GetmatchData {
                     ->select('match_id','home_team','guest_team','match_time')
                     ->where($source)
                     ->where($where)
+//                    ->limit(6)
                     ->get()->toArray();
+                $matchNum = count($matchData);
 
+                $matchData = array_slice($matchData,0,6);
                 foreach ($matchData as $key1 => $item1){
                     //获取等待时间
                     $wait_time = ceil(((strtotime($item1['match_time']))-time())/60);
                     $matchData[$key1]['wait_time'] = $wait_time;
                 }
 
-                $matchNum = count($matchData);
                 if($matchNum > 0){
                     $data[$item['game_code']]['matchData'] = $matchData;
                     $data[$item['game_code']]['matchNum'] = $matchNum;

+ 25 - 1
Library/Common/function.php

@@ -934,6 +934,31 @@ function qgmdate($dateformat = 'Y-m-d H:i:s', $timestamp = '', $timeoffset = 8)
     return $result;
 }
 
+
+/**
+ * 判断二维数组是否包含一维数组
+ * @param mixed $arr 查询条件
+ * @param mixed $arrs 运动类型
+ * @return string
+ */
+function judgeEqual($arr, $arrs){
+    foreach ($arrs as $value) {
+        if (count($value) === count($arr)) {
+            $a = 0;
+            foreach ($value as $key => $v) {
+                $a++;
+                if ($v != $arr[$key]) {
+                    break;
+                }
+                if ($a == count($key)) {    // 到最后一个元素都没有出现不相等,就说明这两个数组相等。
+                    return true;
+                }
+            }
+        }
+    }
+    return false;
+}
+
 // 排列
 function arrangement($a, $m) {
     $r = array();
@@ -999,4 +1024,3 @@ function C1($n, $m) {
     return A1($n, $m)/factorial($m);
 }
 
-