Explorar el Código

追加推送 5/6

彭俊 hace 6 años
padre
commit
805d3e64e0

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

@@ -16,6 +16,7 @@ use Biz\Common\Common;
 use Biz\Game\GameList;
 use System\Lang;
 use App\Api\Model\AccountDetail;
+use App\Api\Model\AccountNews;
 
 
 class Account extends BaseController {
@@ -701,6 +702,32 @@ class Account extends BaseController {
             $accountDetailClass = new AccountDetail();
             // 修改用户基本信息
             $result = $accountDetailClass -> updateUserInfo();
+            if ($result) {
+                $code = 1;
+                $msg = lang('Index','Api') -> get('success');
+
+                Render($result, $code, $msg);
+            } else {
+                Render([], $code, $msg);
+            }
+        } catch (Exception $e) {
+            Render([], $code, $msg);
+        }
+    }
+
+    /**
+     * 用户消息
+     *
+     * @access public
+     * @return array JsonString
+     */
+    public function userNews() {
+        $code = 0;
+        $msg = lang('Common','Api') -> get('error');
+        try{
+            $accountDetailClass = new AccountNews();
+            // 获取用户消息
+            $result = $accountDetailClass -> userNews();
             $code = 1;
             $msg = lang('Index','Api') -> get('success');
 
@@ -709,4 +736,30 @@ class Account extends BaseController {
             Render([], $code, $msg);
         }
     }
+
+    /**
+     * 上传用户头像
+     *
+     * @access public
+     * @return array JsonString
+     */
+    public function updateHeader() {
+        $code = 0;
+        $msg = lang('Common','Api') -> get('error');
+        try{
+            $accountDetailClass = new AccountDetail();
+            // 修改用户基本信息
+            $result = $accountDetailClass -> updateHeader();
+            if ($result) {
+                $code = 1;
+                $msg = lang('Index','Api') -> get('success');
+
+                Render($result, $code, $msg);
+            } else {
+                Render([], $code, $msg);
+            }
+        } catch (Exception $e) {
+            Render([], $code, $msg);
+        }
+    }
 }

+ 21 - 83
Application/Api/Controller/BetOrder.php

@@ -31,88 +31,23 @@ 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
-//            ],
-//            [
-//                'type' => '3串1',
-//                'odds' => 16.299205,
-//                'bet_amount' =>'bet_amount'
-//            ],
-//            [
-//                [
-//                    'id'=>656437,
-//                    'home_team' => "阿尔艾利开罗",
-//                    'guest_team' => '金字塔',
-//                    'name' => '阿尔艾利开罗',
-//                    'odds' => 0.31,
-//                    'p_code' => 'concede_size',
-//                    'ballId' => 'zq',
-//                    'odds_code' => 'concede_size',
-//                    'match_id' => 313238,
-//                    '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',
-//                    'ganame' => 'concede_size',
-//                    'bettingTime' => '',
-//                    'odds_only' => '1dee7e98db303852227cf1e0d8085dfb1555617310.3833947',
-//                    'type' => 1
-//                ],
-//                [
-//                    'id'=>656431,
-//                    '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
-//                ],
-//            ]
-//        ];
         $data['single'] = [];//单式
         $data['bunch'] = [];//串式
         $last[] = $res[count($res)-1];
         unset($res[count($res)-1]);
         foreach ($last as $k =>$v){
             foreach ($v as $kk =>$vv){
+                $num = $kk+1;
                 //验证赛事是否存在
-                $this->verify_match($vv['ballId'],$vv['match_id'],$kk+1);
+                $this->verify_match($vv['ballId'],$vv['match_id'],$num);
                 //验证球类代码是否有效
-                $this->verify_gameType($vv['ballId'],$kk+1);
+                $this->verify_gameType($vv['ballId'],$num);
                 //验证赛事下赔率玩法是否有效
-//                $this->verify_odds($vv['ballId'],$vv['record_id'],$vv['odds'],$vv['condition'],$kk+1);
+                $this->verify_odds($vv['ballId'],$vv['odds_only'],$vv['odds'],$vv['condition'],$num);
+//                if(empty($vv['condition'])){
+//                    $msg = '第'.$num.'条'.lang('Errors','Api')->get('error-5110');
+//                    Render([], '5110',$msg);
+//                }
             }
         }
         foreach($res as $k => $v){
@@ -165,7 +100,7 @@ class Betorder extends BaseController{
             $num = $k + 1;
             if(empty($v['bet_amount'])){
                 $msg = '第'.$num.'条'.lang('Errors','Api')->get('error-5105');
-                Render([], '5105',$msg);
+                Render([], '510511111',$msg);
             }
             //根据类型分组
             if(!isset($res[$v['ballId']])){
@@ -302,6 +237,7 @@ class Betorder extends BaseController{
      * @param  [type] $match_id  赔率ID
      * @param  [type] $num 循环键值
      * $@param  [type]type_str 串式
+     *
      */
     public  function verify_match($game_code,$match_id,$num = 1){
         if(empty($match_id)){
@@ -314,7 +250,8 @@ class Betorder extends BaseController{
         $info = lm($model_match,'Sports')
             ->select('status')
             ->where('status', '<', '2')
-            ->where('us_time','>',qgmdate('Y-m-d H:i:s','', -4))
+//            ->where('us_time','>',qgmdate('Y-m-d H:i:s','', -4))
+            ->where('source','hg3535')
             ->where('match_id',$match_id)
             ->first();
         if(empty($info)){
@@ -346,9 +283,10 @@ class Betorder extends BaseController{
      * 验证赔率是否存在
      * @param  [type] $game_code 球类代码
      *  @param  [type] $odds_id 赔率IDkk
+     *
      */
-    public function verify_odds($game_code,$record_id,$odds,$condition,$num = 1){
-        if(empty($record_id)||empty($condition)||empty($odds)){
+    public function verify_odds($game_code,$odds_only,$odds,$condition,$num = 1){
+        if(empty($odds_only)                   ||empty($odds)){
             $msg = '第'.$num.'条数据'.lang('Errors','Api')->get('error-7029');
             Render([], '7029', $msg);
         }
@@ -358,9 +296,9 @@ class Betorder extends BaseController{
         $model_odds_record = $models['model_odds_record'];
 
         $odds_info = lm($model_odds,'Sports')
-            ->join($model_odds_record,$model_odds_record.'.id',$model_odds.'.record_id')
+            ->join($model_odds_record,$model_odds_record.'.odds_only',$model_odds.'.odds_only')
             ->select($model_odds_record.'.odds',$model_odds_record.'.condition')
-            ->where($model_odds.'.record_id',$record_id)
+            ->where($model_odds.'.odds_only',$odds_only)
             ->first();
         if(empty($odds_info)){
             $msg = '第'.$num.'条数据'.lang('Errors','Api')->get('error-7029');
@@ -371,7 +309,7 @@ class Betorder extends BaseController{
             $msg = '第'.$num.'条数据'.lang('Errors','Api')->get('error-7029');
             Render([], '70292', $msg);
         }
-        if($condition = $odds_info['condition']){
+        if($condition != $odds_info['condition']){
             $msg = '第'.$num.'条数据'.lang('Errors','Api')->get('error-7029');
             Render([], '70293', $msg);
         }
@@ -552,7 +490,7 @@ class Betorder extends BaseController{
                 'status'=>0,
                 'match_id'=>$vv['match_id'],
                 'game_code'=>$vv['ballId'],
-                'lg_id'=>lm($model_match,"Sports")->select('lg_id')->where('match_id',$vv['match_id'])->first()->lg_id,
+                'lg_id'=> $vv['lg_id'],//lm($model_match,"Sports")->select('lg_id')->where('match_id',$vv['match_id'])->first()->lg_id,
                 'ctime'=>$this->time,//写入时间
                 'utime' => $this->time,
                 'bet_type'=>2
@@ -608,7 +546,7 @@ class Betorder extends BaseController{
             //获取所有赛事赔率乘积
             $odds = array_product($odds_all);
             //获取可赢金额
-            $data['prize_money'] =  floor($bet_amount*($odds-1)*100)/100;//保留两位小数
+            $data['prize_money'] =  floor($bet_amount*$odds*100)/100;//保留两位小数
         }
 
         if($sonNum < $allNum and (int)$after ==1){//例:N场赛事 <N串一
@@ -620,7 +558,7 @@ 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;

+ 9 - 6
Application/Api/Controller/UserBuy.php

@@ -32,20 +32,23 @@ 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();
+            if ($_POST['type'] == 2) {
+                $result = $moneyBuyClass -> stringBetRecord();
+            } else {
+                $result = $moneyBuyClass -> singleBetRecord();
+            }
             $code = 1;
             $msg = lang('Index','Api') -> get('success');
 
             Render($result, $code, $msg);
-        /*} catch (Exception $e) {
+        } catch (Exception $e) {
             Render([], $code, $msg);
-            //Render([], $code, $e->getMessage());
-        }*/
+        }
     }
 
     /**

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

@@ -245,6 +245,8 @@ return array(
     'error-5107' => '赔率ID为空',
     'error-5108' => '该赛事已结束',
     'error-5109' => '赛事ID为空',
+    'error-5110' => '赔率条件为空',
+
 
 
     'error-40251' => '请填写代理地址',
@@ -351,6 +353,7 @@ return array(
     "error-51030" => "获取反水信息失败",
     "error-51031" => "获取批次投注总额失败",
     "error-51032" => "反水失败",
+    "error-51034" => "反水比例不存在",
 
 
     'error-51050' => '缺少彩金类型',

+ 40 - 1
Application/Api/Model/AccountDetail.php

@@ -39,6 +39,7 @@ class AccountDetail extends Model {
         }
         if (!empty($_POST['img_id'])) {
             $updateData['img_id'] = $_POST['img_id'];
+            $updateData['img_url'] = '';
         }
         if (!empty($_POST['name'])) {
             $updateData['name'] = $_POST['name'];
@@ -46,6 +47,44 @@ class AccountDetail extends Model {
         if (empty($updateData)) {
             Render([], '4027', lang('Common','Api') -> get('please enter the modification'));
         }
-        lm('Account_detailed', 'commons') -> updateDetailed($updateWhere, $updateData);
+        return lm('Account_detailed', 'commons') -> updateDetailed($updateWhere, $updateData);
+    }
+
+    /**
+     * 上传用户基本信息头像
+     *
+     * @access public
+     * @return String
+     */
+    public function updateHeader()
+    {
+        // 获取用户信息
+        $accountManagerClass = new AccountManager;
+        $userInfo = $accountManagerClass -> getCurrentUser();
+        if (empty($userInfo['identity'])) {
+            Render([], '2001', lang('Common','Api') -> get('user does login'));
+        }
+        $updateWhere['account_identity'] = $userInfo['identity'];
+        $avatar = $request->file('avatar')->store('/public/' . date('Y-m-d') . '/avatars');
+        echo json_encode($input);die;
+        $updateData = [];
+        // 提取修改数据
+        if (!empty($_POST['email'])) {
+            $updateData['email'] = $_POST['email'];
+        }
+        if (!empty($_POST['phone'])) {
+            $updateData['phone'] = $_POST['phone'];
+        }
+        if (!empty($_POST['img_id'])) {
+            $updateData['img_id'] = $_POST['img_id'];
+            $updateData['img_url'] = '';
+        }
+        if (!empty($_POST['name'])) {
+            $updateData['name'] = $_POST['name'];
+        }
+        if (empty($updateData)) {
+            Render([], '4027', lang('Common','Api') -> get('please enter the modification'));
+        }
+        return lm('Account_detailed', 'commons') -> updateDetailed($updateWhere, $updateData);
     }
 }

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

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

+ 159 - 96
Application/Api/Model/MoneyBuy.php

@@ -62,12 +62,12 @@ class MoneyBuy extends Model {
     }
 
     /**
-     * 投注记录
+     * 单式投注记录
      *
      * @access public
      * @return String
      */
-    public function bettingRecord()
+    public function singleBetRecord()
     {
         // 获取用户信息
         $accountManagerClass = new AccountManager;
@@ -75,133 +75,196 @@ class MoneyBuy extends Model {
         if (empty($userInfo['identity'])) {
             Render([], '2001', lang('Common','Api') -> get('user does login'));
         }
-        $moneyBuyWhere = array();
         // 用户ID
-        $moneyBuyWhere['account_identity'] = $userInfo['identity'];
-        // 游戏名称英文
-        if (!empty($_POST['game'])) {
-            $moneyBuyWhere['game_name'] = $_POST['game'];
+        $moneyBuySpxWhere['account_identity'] = $userInfo['identity'];
+        // 时间区间
+        $startTime = isset($_POST['startTime'])? $_POST['startTime'] : '1900-01-01 00:00:00';
+        $endTime = isset($_POST['endTime'])? $_POST['endTime'] : '3000-12-12 00:00:00';
+        $moneyBuySpxBetween = ['money_time' => [$startTime, $endTime]];
+        $moneyBuySpxMdl = lm('money_buy_simplex', "commons");
+        // 获取订单记录
+        $moneyBuySpxSlt = ['batch_id'];
+        $getMoneyBuySpx = $moneyBuySpxMdl -> moneyBuySimplex($moneyBuySpxSlt, $moneyBuySpxWhere, $moneyBuySpxBetween, '', '', 1);
+        // 获取全部订单id
+        $moneyBuyMthOr = [];
+        $allBatchId = array_unique($getMoneyBuySpx, SORT_REGULAR);
+        foreach ($allBatchId as $key => $value) {
+            $moneyBuyMthOr[0][$key][0] = 'batch_id';
+            $moneyBuyMthOr[0][$key][1] = $value['batch_id'];
         }
-        // 下注时间
-        //$moneyBuyWhere['money_time'] = isset($_POST['money_time']) ? $_POST['money_time'] : "";
-        // 游戏期号
-        if (!empty($_POST['no'])) {
-            $moneyBuyWhere['game_no'] = $_POST['no'];
+        $moneyBuyMthWhere['bet_type'] = 1;
+        // 输赢
+        if (!empty($_POST['result']) && $_POST['result'] == 1) {
+            $moneyBuyMthOr[1][0][0] = 'result';
+            $moneyBuyMthOr[1][0][1] = 1;
+            $moneyBuyMthOr[1][1][0] = 'result';
+            $moneyBuyMthOr[1][1][1] = 3;
+            $moneyBuyMthOr[1][2][0] = 'result';
+            $moneyBuyMthOr[1][2][1] = 2;
+        } elseif (!empty($_POST['result']) && $_POST['result'] == 2) {
+            $moneyBuyMthOr[1][0][0] = 'result';
+            $moneyBuyMthOr[1][0][1] = -1;
+            $moneyBuyMthOr[1][1][0] = 'result';
+            $moneyBuyMthOr[1][1][1] = 4;
         }
-        // 开奖状态
-        if (!empty($_POST['status'])) {
-            $moneyBuyWhere['game_status'] = $_POST['status'];
+        // 当前页
+        $currentPage = isset($_POST['currentPage']) ? $_POST['currentPage'] : "1";
+        // 分页大小
+        $pageSize = isset($_POST['pageSize']) ? $_POST['pageSize'] : "10";
+        // 起始查询位置
+        $begin = ($currentPage - 1) * $pageSize;
+        // 获取注单
+        $moneyBuyMthMdl = lm('Money_buy_match', "commons");
+        $moneyBuyMthSlt = ['status', 'bet_money', 'home_team', 'guest_team', 'condition', 'odds', 'odds_name', 'match_id', 'game_type', 'money_buy_match.odds_code'];
+        $getMoneyBuyMth = $moneyBuyMthMdl -> moneyBuyMatch($moneyBuyMthSlt, $moneyBuyMthWhere, $moneyBuyMthOr, $begin, $pageSize);
+        $allCount = $moneyBuyMthMdl -> moneyBuyMatchTotal($moneyBuyMthWhere, $moneyBuyMthOr);
+        // 获取可加注所需要的查询条件
+        $commonFunction = C() -> get('commonFunction');
+        $stOddsWheres = [];
+        foreach ($getMoneyBuyMth as $key => $value) {
+            $match_id = $value -> match_id;
+            $odds_code = $value -> odds_code;
+            $gameType = $value -> game_type;
+            $where = [
+                'match_id' => $match_id,
+                'odds_code' => $odds_code,
+            ];
+            // 判断是否重复
+            if (!$commonFunction -> judgeEqual($where, $stOddsWheres[$gameType])) {
+                $stOddsWheres[$gameType][] = $where;
+            }
         }
-        // 序号
-        if (!empty($_POST['id'])) {
-            $moneyBuyWhere['id'] = $_POST['id'];
+        // 查询数据下所有可加注的游戏
+        $stOddsModel = lm('stOdds','commons');
+        $stOddsSelect = ['match_id', 'odds_code'];
+        $getSstOdds = [];
+        // 循环查询每个运动的可加注游戏  注:由于查询不同表所以必须循环查询
+        foreach ($stOddsWheres as $key => $value) {
+            if ($value) {
+                $getSstOdds[$key] = $stOddsModel -> stOdds($stOddsSelect, $value, $key);
+            }
+        }
+        // 循环添加玩法和判断玩法是否可加注
+        foreach ($getMoneyBuyMth as $key => $value) {
+            $typeSstOdds = $getSstOdds[$value -> game_type];
+            $thisSstOdds = [
+                'match_id' => $value -> match_id,
+                'odds_code' => $value -> odds_code,
+            ];
+            // 判断如果在数组中则为可加注
+            if (!!$commonFunction->judgeEqual($thisSstOdds, $typeSstOdds)) {
+                $getMoneyBuyMth[$key] -> addBet = 0;
+            } else {
+                $getMoneyBuyMth[$key] -> addBet = 1;
+            }
+        }
+        // 获取记录总数
+        $result['total'] = $allCount;
+        $result['list'] = $getMoneyBuyMth;
+        // 总页数计算
+        $result['countPage'] = ceil($result['total'] / $pageSize);
+        $result['currentPage'] = $currentPage;
+
+        return $result;
+    }
+
+    /**
+     * 串式投注记录
+     *
+     * @access public
+     * @return String
+     */
+    public function stringBetRecord()
+    {
+        // 获取用户信息
+        $accountManagerClass = new AccountManager;
+        $userInfo = $accountManagerClass -> getCurrentUser();
+        if (empty($userInfo['identity'])) {
+            Render([], '2001', lang('Common','Api') -> get('user does login'));
         }
-        // 订单id
-        if (!empty($_POST['order_id'])) {
-            $moneyBuyWhere['order_id'] = $_POST['order_id'];
+        // 用户ID
+        $moneyBuyStrWhere['account_identity'] = $userInfo['identity'];
+        // 输赢
+        if (!empty($_POST['result'])) {
+            $moneyBuyStrWhere['game_status'] = $_POST['result'];
         }
         // 时间区间
         $startTime = isset($_POST['startTime'])? $_POST['startTime'] : '1900-01-01 00:00:00';
         $endTime = isset($_POST['endTime'])? $_POST['endTime'] : '3000-12-12 00:00:00';
-        $moneyBuyBetween = [$startTime, $endTime];
+        $moneyBuyStrBetween = ['money_time' => [$startTime, $endTime]];
+        $moneyBuyStrMdl = lm('money_buy_str', "commons");
         // 当前页
         $currentPage = isset($_POST['currentPage']) ? $_POST['currentPage'] : "1";
         // 分页大小
         $pageSize = isset($_POST['pageSize']) ? $_POST['pageSize'] : "10";
         // 起始查询位置
         $begin = ($currentPage - 1) * $pageSize;
-        $moneyBuy = lm('money_buy', "commons");
-        $moneyBuyStr = lm('money_buy_str', "commons");
-        // 获取投注记录
-        $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']] = '';
+        // 获取订单记录
+        $moneyBuyStrSlt = ['batch_id', 'money'];
+        $getMoneyBuyStr = $moneyBuyStrMdl -> moneyBuyStr($moneyBuyStrSlt, $moneyBuyStrWhere, $moneyBuyStrBetween, $begin, $pageSize, 1);
+        $allCount = $moneyBuyStrMdl -> moneyBuyStrTotal($moneyBuyStrWhere, $moneyBuyStrBetween);
+        // 获取全部订单id
+        $moneyBuyMthOr = [];
+        $allBatchId = array_unique($getMoneyBuyStr, SORT_REGULAR);
+        foreach ($allBatchId as $key => $value) {
+            $moneyBuyMthOr[0][$key][0] = 'batch_id';
+            $moneyBuyMthOr[0][$key][1] = $value['batch_id'];
         }
+        $moneyBuyMthWhere['bet_type'] = 2;
+        // 获取注单
+        $moneyBuyMthMdl = lm('Money_buy_match', "commons");
+        $moneyBuyMthSlt = ['status', 'bet_money', 'home_team', 'guest_team', 'condition', 'odds', 'odds_name', 'match_id', 'batch_id', 'game_type', 'money_buy_match.odds_code'];
+        $getMoneyBuyMth = $moneyBuyMthMdl -> moneyBuyMatch($moneyBuyMthSlt, $moneyBuyMthWhere, $moneyBuyMthOr, $begin, $pageSize);
         // 获取可加注所需要的查询条件
-        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;
-                }
+        $commonFunction = C() -> get('commonFunction');
+        $stOddsWheres = [];
+        foreach ($getMoneyBuyMth as $key => $value) {
+            $match_id = $value -> match_id;
+            $odds_code = $value -> odds_code;
+            $gameType = $value -> game_type;
+            $where = [
+                'match_id' => $match_id,
+                'odds_code' => $odds_code,
+            ];
+            // 判断是否重复
+            if (!$commonFunction -> judgeEqual($where, $stOddsWheres[$gameType])) {
+                $stOddsWheres[$gameType][] = $where;
             }
         }
         // 查询数据下所有可加注的游戏
         $stOddsModel = lm('stOdds','commons');
         $stOddsSelect = ['match_id', 'odds_code'];
         $getSstOdds = [];
+        // 循环查询每个运动的可加注游戏  注:由于查询不同表所以必须循环查询
         foreach ($stOddsWheres as $key => $value) {
             if ($value) {
-                $getSstOdds[$key] = $stOddsModel -> stOdds($stOddsSelect, $value, $key)->toArray();;
+                $getSstOdds[$key] = $stOddsModel -> stOdds($stOddsSelect, $value, $key);
             }
         }
         // 循环添加玩法和判断玩法是否可加注
-        $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 ($getMoneyBuyMth as $key => $value) {
+            $typeSstOdds = $getSstOdds[$value -> game_type];
+            $thisSstOdds = [
+                'match_id' => $value -> match_id,
+                'odds_code' => $value -> odds_code,
+            ];
+            // 判断如果在数组中则为可加注
+            if (!!$commonFunction->judgeEqual($thisSstOdds, $typeSstOdds)) {
+                $getMoneyBuyMth[$key] -> addBet = 0;
+            } else {
+                $getMoneyBuyMth[$key] -> addBet = 1;
             }
-            foreach ($codeInfo as $k => $v) {
-                $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;
+        }
+        foreach ($getMoneyBuyStr as $key => $value) {
+            foreach ($getMoneyBuyMth as $k => $v) {
+                if ($value['batch_id'] == $v['batch_id']) {
+                    $getMoneyBuyStr[$key]['money_buy'][$k] = $v;
                 }
             }
-            $allMoneyBuy[$key]->codes = json_encode($codeInfo);
         }
         // 获取记录总数
         $result['total'] = $allCount;
-        $result['list'] = $allMoneyBuy;
+        $result['list'] = $getMoneyBuyStr;
         // 总页数计算
         $result['countPage'] = ceil($result['total'] / $pageSize);
         $result['currentPage'] = $currentPage;
@@ -242,7 +305,7 @@ class MoneyBuy extends Model {
         // 获取盈亏记录
         $result['list'] = $moneyRecord -> moneyRecord($moneyRecordSelect, $moneyRecordWhere, $moneyRecordBetween, $begin, $pageSize);
         // 获取记录总数
-        $result['total'] = count($result['list']);
+        $result['total'] = $moneyRecord -> moneyRecordTotal($moneyRecordWhere, $moneyRecordBetween);
         // 总页数计算
         $result['countPage'] = ceil($result['total'] / $pageSize);
         $result['currentPage'] = $currentPage;

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

@@ -44,7 +44,7 @@ class MoneyPrize extends Model {
         // 获取盈亏记录
         $result['list'] = $prizeRecord -> prizeRecord($prizeRecordWhere, $prizeRecordBetween, $begin, $pageSize);
         // 获取记录总数
-        $result['total'] = count($result['list']);
+        $result['total'] = $prizeRecord -> prizeRecordTotal($prizeRecordWhere, $prizeRecordBetween);
         // 总页数计算
         $result['countPage'] = ceil($result['total'] / $pageSize);
         $result['currentPage'] = $currentPage;

+ 2 - 2
Application/Api/Model/MoneyRecharge.php

@@ -100,7 +100,7 @@ class MoneyRecharge extends Model {
         // 获取盈亏记录
         $result['list'] = $rechargeRecord -> rechargeRecord($rechargeRecordSelect, $rechargeRecordWhere, $rechargeRecordBetween, $begin, $pageSize);
         // 获取记录总数
-        $result['total'] = count($result['list']);
+        $result['total'] = $rechargeRecord -> rechargeRecordTotal($rechargeRecordWhere, $rechargeRecordBetween);
         // 总页数计算
         $result['countPage'] = ceil($result['total'] / $pageSize);
         $result['currentPage'] = $currentPage;
@@ -140,7 +140,7 @@ class MoneyRecharge extends Model {
         // 获取提款记录
         $result['list'] = $moneyTake -> moneyTake($moneyTakeSelect, $moneyTakeWhere, $moneyTakeBetween, $begin, $pageSize);
         // 获取记录总数
-        $result['total'] = count($result['list']);
+        $result['total'] = $moneyTake -> moneyTakeTotal($moneyTakeWhere, $moneyTakeBetween);
         // 总页数计算
         $result['countPage'] = ceil($result['total'] / $pageSize);
         $result['currentPage'] = $currentPage;

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

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

+ 83 - 2
Application/Commons/Model/Account_news.php

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

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

@@ -13,6 +13,94 @@ class Money_buy_match extends Model {
 
     protected $table = 'money_buy_match';
 
+    /**
+     * 投注记录
+     *
+     * @access public
+     * @param mixed $select 查询字段
+     * @param mixed $where 查询条件
+     * @param mixed $orWhere 关联关系      [[['batch_id', '191'], ['batch_id', '186']],[['id', '55'], ['id', '59']]];
+     * @param mixed $begin 起始查询位置
+     * @param mixed $pageSize 分页大小
+     * @param mixed $orderBy 排序字段
+     * @return array JsonString
+     */
+    public function moneyBuyMatch($select, $where = '', $orWhere = '', $begin = '', $pageSize = '', $orderBy = ['batch_id' => 'desc']) {
+        // 查询字段
+        $result = $this -> select($select)
+                -> join('st_odds_code', 'money_buy_match.odds_code', 'st_odds_code.odds_code');
+        // 查询条件
+        if (!empty($where)) {
+            $result = $result -> where($where);
+        }
+        // 循环获取or查询
+        if (!empty($orWhere)) {
+            foreach ($orWhere as $value) {
+                $result = $result -> where(function($query) use ($value) {
+                    foreach ($value as $k => $v) {
+                        if ($k == 0) {
+                            $query = $query -> where([$v[0] => $v[1]]);
+                        } else {
+                            $query = $query -> orWhere([$v[0] => $v[1]]);
+                        }
+                    }
+                });
+            }
+        }
+        // 查询起始
+        if (strlen($begin)) {
+            $result = $result -> offset($begin);
+        }
+
+        // 分页大小
+        if (strlen($pageSize)) {
+            $result = $result -> limit($pageSize);
+        }
+        // 循环排序规则
+        foreach ($orderBy as $key => $value) {
+            $result = $result -> orderBy($key, $value);
+        }
+        // 获取数据
+        $result = $result -> get();
+
+        return $result;
+    }
+
+    /**
+     * 投注记录
+     *
+     * @access public
+     * @param mixed $where 查询条件
+     * @param mixed $orWhere 关联关系      [[['batch_id', '191'], ['batch_id', '186']],[['id', '55'], ['id', '59']]];
+     * @return array JsonString
+     */
+    public function moneyBuyMatchTotal($where = '', $orWhere = '') {
+        // 查询字段
+        $result = $this;
+        // 查询条件
+        if (!empty($where)) {
+            $result = $result -> where($where);
+        }
+        // 循环获取or查询
+        if (!empty($orWhere)) {
+            foreach ($orWhere as $value) {
+                $result = $result -> where(function($query) use ($value) {
+                    foreach ($value as $k => $v) {
+                        if ($k == 0) {
+                            $query = $query -> where([$v[0] => $v[1]]);
+                        } else {
+                            $query = $query -> orWhere([$v[0] => $v[1]]);
+                        }
+                    }
+                });
+            }
+        }
+        // 获取数据
+        $result = $result -> count();
+
+        return $result;
+    }
+
     public function  getByDetail($Detailid){
             $ret = $this->where('money_buy_detail_id' ,$Detailid)->find();
             return $ret;

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

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

+ 97 - 20
Application/Commons/Model/Money_buy_str.php

@@ -20,23 +20,51 @@ class Money_buy_str extends Model {
      *
      * @access public
      * @param mixed $select 查询字段
-     * @param mixed $moneyBuyWhere 查询条件
-     * @param mixed $moneyBuyBetween 查询条件区间
+     * @param mixed $where 查询条件
+     * @param mixed $between 查询条件区间     ['money_time' => [$startTime, $endTime], ...]
      * @param mixed $begin 起始查询位置
      * @param mixed $pageSize 分页大小
+     * @param mixed $toArray 是否专为数组
      * @param mixed $orderBy 排序字段
+     * @param mixed $join 关联关系      ['article' => 'oney_buy.info_identity = article.identity', ...]
      * @return array JsonString
      */
-    public function moneyBuyStr($select, $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();
+    public function moneyBuyStr($select, $where = '', $between = '', $begin = '', $pageSize = '', $toArray = 0, $orderBy = ['money_time' => 'desc'], $join = '') {
+        // 查询字段
+        $result = $this -> select($select);
+        // 循环关联
+        if (!empty($join)) {
+            foreach ($join as $key => $value) {
+                $result = $result -> join($key, $value);
+            }
+        }
+        // 查询条件
+        if (!empty($where)) {
+            $result = $result -> where($where);
+        }
+        // 循环获取查询区间
+        if (!empty($between)) {
+            foreach ($between as $key => $value) {
+                $result = $result -> whereBetween($key, $value);
+            }
+        }
+        // 查询起始
+        if (strlen($begin)) {
+            $result = $result -> offset($begin);
+        }
+        // 分页大小
+        if (strlen($pageSize)) {
+            $result = $result -> limit($pageSize);
+        }
+        // 循环排序规则
+        foreach ($orderBy as $key => $value) {
+            $result = $result -> orderBy($key, $value);
+        }
+        // 获取数据
+        $result = $result -> get();
+        if ($toArray) {
+            $result = $result -> toArray();
+        }
 
         return $result;
     }
@@ -45,15 +73,66 @@ class Money_buy_str extends Model {
      * 投注记录总数
      *
      * @access public
+     * @param mixed $where 查询条件
+     * @param mixed $between 查询条件区间
+     * @return array JsonString
+     */
+    public function moneyBuyStrTotal($where, $between) {
+        $result = $this;
+        // 查询条件
+        if (!empty($where)) {
+            $result = $result -> where($where);
+        }
+        // 循环获取查询区间
+        if (!empty($between)) {
+            foreach ($between as $key => $value) {
+                $result = $result -> whereBetween($key, $value);
+            }
+        }
+        // 获取数据
+        $result = $result -> count();
+
+        return $result;
+    }
+
+    /**
+     * 投注记录联合查询
+     *
+     * @access public
+     * @param mixed $select 查询字段
      * @param mixed $moneyBuyWhere 查询条件
-     * @param mixed $moneyBuyBetween 查询条件区间
+     * @param mixed $orderBy 排序字段
      * @return array JsonString
      */
-    public function moneyBuyTotal($moneyBuyWhere, $moneyBuyBetween) {
-        $result = $this
-            -> where($moneyBuyWhere)
-            -> whereBetween('money_time', $moneyBuyBetween)
-            -> count();
+    public function moneyBuyStrUnion($select, $moneyBuyWhere, $orderBy = 'money_time') {
+        if (empty($moneyBuyWhere)) {
+            return;
+        }
+        $count = count($moneyBuyWhere);
+        $result = [];
+        $unionAll = [];
+        foreach ($moneyBuyWhere as $key => $value) {
+            if ($key === 0) {
+                $unionAll[0] = $this
+                    -> select($select)
+                    -> join('st_bet_str','money_buy_str.bet_str_id','=','st_bet_str.id')
+                    -> where(['order_id' => $value]);
+            } elseif ($key + 1 === $count) {
+                $result = $this
+                    -> select($select)
+                    -> join('st_bet_str','money_buy_str.bet_str_id','=','st_bet_str.id')
+                    -> where(['order_id' => $value])
+                    -> unionAll($unionAll[$key - 1])
+                    -> orderBy($orderBy)
+                    -> get();
+            } else {
+                $unionAll[$key] = $this
+                    -> select($select)
+                    -> join('st_bet_str','money_buy_str.bet_str_id','=','st_bet_str.id')
+                    -> unionAll($unionAll[$key - 1])
+                    -> where(['order_id' => $value]);
+            }
+        }
 
         return $result;
     }
@@ -69,6 +148,4 @@ class Money_buy_str extends Model {
          $result = $this->where(['batch_id',$batch_id])->get();
          return $result ;
      }
-
-
 }

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

@@ -38,4 +38,21 @@ class Money_prize extends Model {
 
         return $result;
     }
+
+    /**
+     * 中奖记录总数
+     *
+     * @access public
+     * @param mixed $prizeRecordWhere 查询条件
+     * @param mixed $prizeRecordBetween 查询条件区间
+     * @return array JsonString
+     */
+    public function prizeRecordTotal($prizeRecordWhere, $prizeRecordBetween) {
+        $result = $this
+            -> where($prizeRecordWhere)
+            -> whereBetween('money_time', $prizeRecordBetween)
+            -> count();
+
+        return $result;
+    }
 }

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

@@ -189,4 +189,21 @@ protected $table = 'money_recharge';
 
         return $result;
     }
+
+    /**
+     * 充值记录总数
+     *
+     * @access public
+     * @param mixed $rechargeRecordWhere 查询条件
+     * @param mixed $rechargeRecordBetween 查询条件区间
+     * @return array JsonString
+     */
+    public function rechargeRecordTotal($rechargeRecordWhere, $rechargeRecordBetween) {
+        $result = $this
+            -> where($rechargeRecordWhere)
+            -> whereBetween('apply_time', $rechargeRecordBetween)
+            -> count();
+
+        return $result;
+    }
 }

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

@@ -69,6 +69,29 @@ class Money_take extends Model {
         return $result;
     }
 
+    /**
+     * 提现记录总数
+     *
+     * @access public
+     * @param mixed $where 查询条件
+     * @param mixed $between 查询条件区间
+     * @return array JsonString
+     */
+    public function moneyTakeTotal($where, $between) {
+        $result = $this;
+        if (!empty($where)) {
+            $result = $result -> where($where);
+        }
+        if (!empty($between)) {
+            foreach ($between as $key => $value) {
+                $result = $result -> whereBetween($key, $value);
+            }
+        }
+        $result = $result -> count();
+
+        return $result;
+    }
+
     /**
      * 添加提现记录
      *

+ 18 - 11
Application/Sports/Controller/MatchList.php

@@ -116,7 +116,7 @@ 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))
+             ->where($st_competition.'.us_time','>',qgmdate('Y-m-d H:i:s', '', -4))
              ->count('*');
          $data['info'][1]['name'] = '今日赛事';
          $data['info'][1]['code'] = 'today';
@@ -498,7 +498,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))
+            ->where($st_competition.'.us_time','>',qgmdate('Y-m-d H:i:s', '', -4))
             ->get()
             ->toArray();
 
@@ -512,7 +512,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))
+            ->where($st_competition.'.us_time','>',qgmdate('Y-m-d H:i:s', '', -4))
             ->get()
             ->toArray();
         //统计国家联赛下的赛事
@@ -624,6 +624,7 @@ class  MatchList extends Controller {
             $gameData = [];
 
             foreach ($game as $key=>$type){
+
                 if($type_code != 'StChampion'){
                     $matchModel = $this->commonFunction->getModels($type['game_code']);
                     $matchNum = lm($matchModel['model_match'], 'Sports')
@@ -688,19 +689,22 @@ class  MatchList extends Controller {
             switch ($oddsType)
             {
                 case 'StRollBall'://滚球
-                    $oddsTypeWhere = [[$model_odds.'.is_rollball','=',1],];
+                    $oddsTypeWhere = [[$model_odds.'.is_rollball','=',1]];
                     break;
                 case 'StSoon'://即将
-                    $oddsTypeWhere = [[$model_odds.'.is_morningplate','=',1],];
+                    $oddsTypeWhere = [[$model_odds.'.is_morningplate','=',1]];
                     break;
                 case 'StToday'://今日
-                    $oddsTypeWhere = [[$model_odds.'.is_today','=',1],];
+                    $oddsTypeWhere = [[$model_odds.'.is_today','=',1]];
                     break;
                 case 'StMorningPlate'://早盘
-                    $oddsTypeWhere = [[$model_odds.'.is_morningplate','=',1],];
+                    $oddsTypeWhere = [[$model_odds.'.is_morningplate','=',1]];
                     break;
                 case 'StStringScene'://串场
-                    $oddsTypeWhere = [[$model_odds.'.is_stringscene','=',1],];
+                    $oddsTypeWhere = [[$model_odds.'.is_stringscene','=',1]];
+                    break;
+                case 'home'://首页
+                    $oddsTypeWhere = [[$model_odds.'.is_stringscene','=',1]];
                     break;
                 default:
                     $oddsTypeWhere = [];
@@ -733,12 +737,15 @@ class  MatchList extends Controller {
 
             $oddsTypeWhere = $this->getOddsTypeWhere($model_odds,$oddsType);
             $oddsData = lm($model_odds, 'Sports')
-                ->select('id','odds_only','p_code','odds_code',$model_odds.'.status','odds','condition','sort','source','utime')
+                ->select('sort','p_code','id','odds_only','odds_code',$model_odds.'.status','odds','condition','sort','source','utime')
                 ->where($this->source)
                 ->where($oddsTypeWhere)
 //                ->where($model_odds.'.expire_time','>',date("Y-m-d H:i:s"))
                 ->where([$model_odds.'.match_id'=>$matchID,$model_odds.'.type'=>0])//,$model_odds.'.expire_time'=>$utime
-                ->groupBy('id','odds_only','p_code','odds_code',$model_odds.'.status','odds','condition','sort','source','utime')
+                ->orderBy('sort', 'desc')
+                ->orderBy('p_code','desc')
+                ->orderBy('odds_code','desc')
+                //->groupBy('sort','p_code','id','odds_only','odds_code',$model_odds.'.status','odds','condition','sort','source','utime')
                 ->get()->toArray();
 
             $matchData = lm($model_match, 'Sports')
@@ -749,7 +756,7 @@ class  MatchList extends Controller {
                 ->first();
 //                ->toarray();
 
-            if(empty($matchData)) Render([], '1', lang('Tips','Sports')->get('success'));
+            if(empty($matchData)) Render(null, '1', lang('Tips','Sports')->get('success'));
 
             $matchData->ptime = '';//赛事进行时间
             $matchData->match_score = '';//赛事比分

+ 20 - 15
Biz/Common/CommonFunction.php

@@ -698,10 +698,12 @@ class CommonFunction {
             switch ($type_code){
                 case 'StRollBall'://滚球 正在进行
                     $where = [
-                        ['is_rollball','=',1],
-                        ['match_date','=',date("Y-m-d")],
-                        ['match_time','>',date("H:i:s", time()-(90*60))],
-                        ['match_time','<',date("H:i:s", time())]
+                        ['status','=','1'],
+
+//                        ['is_rollball','=',1],
+//                        ['match_date','=',date("Y-m-d")],
+//                        ['match_time','>',date("H:i:s", time()-(90*60))],
+//                        ['match_time','<',date("H:i:s", time())]
                     ];
                     break;
                 case 'StSoon'://即将 今日两小时内开始
@@ -728,7 +730,7 @@ class CommonFunction {
                 case 'StMorningPlate'://早盘
                     $where = [
                         ['is_morningplate', '=', 1],
-                        ['us_time','>',qgmdate('Y-m-d H:i:s', '', -4)],
+                        ['us_time','>',$this->qgmdate('Y-m-d H:i:s', '', -4)],
 //                    ['match_date','>',date("Y-m-d",time())],
 //                    ['match_time','>',date("H:i:s", time())],
 //                    ['type', '=', '2'],
@@ -739,7 +741,7 @@ class CommonFunction {
                 case 'StStringScene'://串场
                     $where = [
                         ['is_stringscene', '=', 1],
-                        ['us_time','>',qgmdate('Y-m-d H:i:s', '', -4)],
+                        ['us_time','>',$this->qgmdate('Y-m-d H:i:s', '', -4)],
 
 //                    ['match_date','>',date("Y-m-d",time())],
 //                    ['match_time','>',date("H:i:s", time())],
@@ -760,10 +762,13 @@ class CommonFunction {
             switch ($type_code){
                 case 'StRollBall'://滚球 正在进行
                     $where = [
-                        [$model_match.'.is_rollball','=',1],
-                        [$model_match.'.match_date','=',date("Y-m-d")],
-                        [$model_match.'.match_time','>',date("H:i:s", time()-(90*60))],
-                        [$model_match.'.match_time','<',date("H:i:s", time())]
+//                        [$model_match.'.is_rollball','=',1],
+                        [$model_match.'.status','=','1'],
+//                        [$model_match.'.status','>','0'],
+
+//                        [$model_match.'.match_date','=',date("Y-m-d")],
+//                        [$model_match.'.match_time','>',date("H:i:s", time()-(90*60))],
+//                        [$model_match.'.match_time','<',date("H:i:s", time())]
                     ];
                     break;
                 case 'StSoon'://即将 今日两小时内开始
@@ -793,7 +798,7 @@ class CommonFunction {
                 case 'StMorningPlate'://早盘
                     $where = [
                         [$model_match.'.is_morningplate','=',1],
-                        [$model_match.'.us_time','>',qgmdate('Y-m-d H:i:s', '', -4)],
+                        [$model_match.'.us_time','>',$this->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'],
@@ -804,7 +809,7 @@ class CommonFunction {
                 case 'StStringScene'://串场 查询串场状态为1 开赛时间大于当前时间
                     $where = [
                         [$model_match.'.is_stringscene','=',1],
-                        [$model_match.'.us_time','>',qgmdate('Y-m-d H:i:s', '', -4)],
+                        [$model_match.'.us_time','>',$this->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())],
@@ -886,7 +891,7 @@ class CommonFunction {
                 }
 
                 if($vv['oddsData']){
-                    $vv['oddsData'] = array_unset_tt($vv['oddsData'],'p_code');
+                    $vv['oddsData'] = $this->array_unset_tt($vv['oddsData'],'p_code');
                     $vv['count'] = count($vv['oddsData']);
                     unset($vv['oddsData']);
                 }
@@ -958,7 +963,7 @@ class CommonFunction {
             if ($m == 1) {
                 $r[] = $t;
             } else {
-                $c = arrangement($b, $m-1);
+                $c = $this->arrangement($b, $m-1);
                 foreach ($c as $v) {
                     $r[] = array_merge($t, $v);
                 }
@@ -983,7 +988,7 @@ class CommonFunction {
                 $r[] = $t;
             } else {
                 $b = array_slice($a, $i+1);
-                $c = combination($b, $m-1);
+                $c = $this->combination($b, $m-1);
                 foreach ($c as $v) {
                     $r[] = array_merge($t, $v);
                 }

+ 1 - 1
Biz/Match/GetOddsData.php

@@ -38,7 +38,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($model_match.'.us_time','>',qgmdate('Y-m-d H:i:s', '', -4))
             ->where('status','<',2)
             ->where(function($query)use ($model_match,$search){
                 $query->where($model_match.'.home_team','like','%'.$search.'%')

+ 5 - 5
Biz/Match/GetmatchData.php

@@ -372,12 +372,12 @@ class GetmatchData {
                 ->where('lg_id',$lg_id)
                 ->first()->last_time;
             $championData = lm($model_odds, 'Sports')
-                ->select("id","lg_id","p_code","odds_code","team","odds","sort","status","odds_only")
+                ->select("id","lg_id","match_id","p_code","odds_code","team","odds","sort","status","odds_only")
 //                ->where($model_odds.'.expire_time','>',date("Y-m-d H:i:s"))
                 ->where($source)
                 ->where('lg_id',$lg_id)
                 ->where($where)
-                ->groupBy("id","lg_id","p_code","odds_code","team","odds","sort","status","odds_only")
+                ->groupBy("id","lg_id","match_id","p_code","odds_code","team","odds","sort","status","odds_only")
                 ->get()->toArray();
 
             //按p_code分组
@@ -452,6 +452,7 @@ class GetmatchData {
                     ->where($model_league.'.name_chinese','like','%'.$search.'%')
                     ->get()->toarray();
             }
+
             foreach ($country as $k => $v) {
                 foreach($v['league_count'] as $kk => $vv ){
                     if(!empty($model_match)){//非冠军玩法,获取联赛下赛事数量
@@ -488,7 +489,6 @@ class GetmatchData {
                 }
             }
         }
-
         //统计 地区 联赛-赛事/盘口数量
         if(!empty($area)){
             foreach($area as $k => $v) {
@@ -995,12 +995,12 @@ class GetmatchData {
 
         $where = $this->commonFunction->getState($type_code);
         $championData = lm($model_odds, 'Sports')
-            ->select("id","lg_id","p_code","odds_code","team","odds","sort","status","odds_only")
+            ->select("id","lg_id","match_id","p_code","odds_code","team","odds","sort","status","odds_only")
 //                ->where($model_odds.'.expire_time','>',date("Y-m-d H:i:s"))
             ->where($source)
             ->where('lg_id',$lg_id)
             ->where($where)
-            ->groupBy("id","lg_id","p_code","odds_code","team","odds","sort","status","odds_only")
+            ->groupBy("id","lg_id","match_id","p_code","odds_code","team","odds","sort","status","odds_only")
             ->get()->toArray();
 
         //按p_code分组

+ 20 - 29
Biz/Money/Money.php

@@ -78,6 +78,7 @@ class Money {
 			if($insertDetail !=1){
 				return $insertDetail;
 			}
+			$this->fanshui($account_identity,$account['account'],$money,$order_id);//反水
 		}
 		return '1';
 	}
@@ -235,43 +236,33 @@ class Money {
 	 * 反水
 	 * @param  string $account_identity 用户唯一ID
 	 * @param  string  $account 用户名
-	 * @param  string  $batch_id 批量号
+	 * @param  string  $bet_money 投注总金额
 	 */
-	public function fanshui($account_identity,$account,$batch_id){
+	public function fanshui($account_identity,$account,$bet_money,$order_id){
+		if(empty($bet_money)){
+			Render('', '5105222222',lang('Errors','Api')->get('error-5105'));
+		}
 		//查询是否可以反水
 		$account_info = lm('Account','Api')->where([['identity',$account_identity],['account',$account]])->first();
 		if(!$account_info){
 			Render('', '51030',lang('Errors','Api')->get('error-51030'));
 		}
+		//查询反水比例
+		$Setinfo = lm('SetInfo','Api')->where([['infoname','fanshui'],['status',1]])->first();
+		if(!$Setinfo){
+			Render('', '51034',lang('Errors','Api')->get('error-51034'));
+		}
 		$account_info->toArray();
+		$Setinfo->toArray();
 		if($account_info['fanshui'] == 1){
-			//查询计算当前批次号投注总金额
-			$simplex = lm("MoneyBuySimplex",'Api')->select('money')->where('batch_id',$batch_id)->get();//单式
-			$str = lm("MoneyBuyStr",'Api')->select('money')->where('batch_id',$batch_id)->get();//串式
-			$simplex_money = 0;
-			if(!empty($simplex)){
-				$simplex->toArray();
-				foreach($simplex as $k => $v){
-					$simplex_money += $v['money'];
-				}
-			}
-			$str_money = 0;
-			if(!empty($str)){
-				$str->toArray();
-				foreach($str as $k => $v){
-					$str_money += $v['money'];
-				}
-			}
-			$bet_money  = $str_money + $simplex_money;
-			if($bet_money != 0 ){
-				//执行插入金额详情与用户余额加反水
-				$order_id = OrderID(); //订单ID
-				$UUID = UUID(); //信息ID
-				$type = 7; //反水
-				$res = $this->insertMoney($account_identity, $bet_money, $order_id, $type, $game_no = '',$UUID,$account_info);
-				if($res != 1){
-					Render('', $res,lang('Errors','Api')->get('error'.$res));
-				}
+			//执行插入金额详情与用户余额加反水
+//			$order_id = OrderID(); //订单ID
+			$UUID = UUID(); //信息ID
+			$type = 7; //反水
+			$bet_money  = $bet_money * $Setinfo['infocontent']; //计算反水额
+			$res = $this->insertMoney($account_identity, $bet_money, $order_id, $type, $game_no = '',$UUID,$account_info);
+			if($res != 1){
+				Render('', $res,lang('Errors','Api')->get('error'.$res));
 			}
 		}
 	}