Ver Fonte

异常处理

彭俊 há 6 anos atrás
pai
commit
89f2aeaf71

+ 25 - 13
Application/Api/Model/MoneyBuy.php

@@ -339,19 +339,23 @@ class MoneyBuy extends Model {
         // 时间区间
         $startTime = isset($_POST['startTime'])? $_POST['startTime'] : '1900-01-01 00:00:00';
         $endTime = isset($_POST['endTime'])? $_POST['endTime'] : '3000-12-12 00:00:00';
+
         $moneyBuyStrBetween = ['money_time' => [$startTime, $endTime]];
         $moneyBuyStrMdl = lm('money_buy_str', "commons");
         // 当前页
         $currentPage = isset($_POST['currentPage']) ? $_POST['currentPage'] : "1";
         // 分页大小
-        $pageSize = isset($_POST['pageSize']) ? $_POST['pageSize'] : "10";
+        $pageSize = isset($_POST['pageSize']) ? $_POST['pageSize'] : '10';
+
         // 起始查询位置
         $begin = ($currentPage - 1) * $pageSize;
         // 获取订单记录
         $moneyBuyStrSlt = ['order_id', 'batch_id', 'gain_money','status as order_status','settle_status','game_status', 'money', 'prize_money', 'money_time'];
         $getMoneyBuyStr = $moneyBuyStrMdl -> moneyBuyStr($moneyBuyStrSlt, $moneyBuyStrWhere, $moneyBuyStrBetween, $begin, $pageSize, 1);
+
         $allCount = $moneyBuyStrMdl -> moneyBuyStrTotal($moneyBuyStrWhere, $moneyBuyStrBetween);
         // 获取全部订单id
+        $order_ids = array_column($getMoneyBuyStr,'order_id');
         $moneyBuyMthOr = [];
         $allBatchId = array_unique($getMoneyBuyStr, SORT_REGULAR);
         if (!$allBatchId) {
@@ -364,20 +368,20 @@ class MoneyBuy extends Model {
 
             return $result;
         }
-        // foreach ($allBatchId as $key => $value) {
-        //     $moneyBuyMthOr[0][$key][0] = 'batch_id';
-        //     $moneyBuyMthOr[0][$key][1] = $value['batch_id'];
-        // }
         foreach ($allBatchId as $key => $value) {
-            $moneyBuyMthOr[0][$key][0] = 'order_id';
-            $moneyBuyMthOr[0][$key][1] = $value['order_id'];
+            $moneyBuyMthOr[0][$key][0] = 'batch_id';
+            $moneyBuyMthOr[0][$key][1] = $value['batch_id'];
         }
+        // foreach ($allBatchId as $key => $value) {
+        //     $moneyBuyMthOr[0][$key][0] = 'order_id';
+        //     $moneyBuyMthOr[0][$key][1] = $value['order_id'];
+        // }
       
         // 获取注单
         $moneyBuyMthWhere['bet_type'] = 2;
         $moneyBuyMthMdl = lm('Money_buy_match', "commons");
         $moneyBuyMthSlt = ['status', 'matchresult', 'bet_money', 'home_team', 'guest_team', 'condition', 'odds', 'odds_name', 'match_id', 'batch_id','order_id', 'money_buy_match.game_code', 'money_buy_match.odds_code'];
-        $getMoneyBuyMth = $moneyBuyMthMdl -> moneyBuyMatch($moneyBuyMthSlt, $moneyBuyMthWhere, $moneyBuyMthOr, $begin, $pageSize);
+        $getMoneyBuyMth = $moneyBuyMthMdl -> moneyBuyMatch($moneyBuyMthSlt, $moneyBuyMthWhere, $moneyBuyMthOr, $begin, $pageSize='','',$order_ids);
         // 获取所有的比赛类型
         $stGameTypeMdl = lm('StGameType', "commons");
         $StGameTypeSlt = ['game_code'];
@@ -393,12 +397,14 @@ class MoneyBuy extends Model {
         foreach ($getMoneyBuyMth as $value) {
             $allMatch[$value->game_code][] = $value->match_id;
         }
+
         $stCompetitionMdl = lm('St_competition', "commons");
         // 循环获取所有的赛事信息
         foreach ($allMatch as $key => $value) {
             $stCptWhrOr = array_unique($value);
             $allMatchInfo[$key] = $stCompetitionMdl -> getMatch($key, $stCptWhrOr);
         }
+
         // 循环添加赛事时间
         foreach ($getMoneyBuyMth as $k => $v) {
             foreach ($allMatchInfo[$v->game_code] as $key => $value) {
@@ -421,9 +427,11 @@ class MoneyBuy extends Model {
                 'odds_code' => $odds_code,
             ];
             // 判断是否重复
-            if (!$commonFunction -> judgeEqual($where, $stOddsWheres[$gameType])) {
-                $stOddsWheres[$gameType][] = $where;
-            }
+            // if (!$commonFunction -> judgeEqual($where, $stOddsWheres[$gameType])) {
+            //     $stOddsWheres[$gameType][] = $where;
+            // }
+            $stOddsWheres[$gameType][] = $where;
+
         }
         // 查询数据下所有可加注的游戏
         $stOddsModel = lm('stOdds','commons');
@@ -435,7 +443,9 @@ class MoneyBuy extends Model {
                 $getSstOdds[$key] = $stOddsModel -> stOdds($stOddsSelect, $value, $key);
             }
         }
+
         // 循环添加玩法和判断玩法是否可加注
+        /*
         foreach ($getMoneyBuyMth as $key => $value) {
             $typeSstOdds = $getSstOdds[$value -> game_code];
             $thisSstOdds = [
@@ -449,6 +459,7 @@ class MoneyBuy extends Model {
                 $getMoneyBuyMth[$key] -> addBet = 1;
             }
         }
+        */
         foreach ($getMoneyBuyStr as $key => $value) {
             // 计算所赢金额.
             if ($value->gain_money) {
@@ -470,11 +481,12 @@ class MoneyBuy extends Model {
                 $getMoneyBuyStr[$key]->settle_status = -1;//结算状态 无效                  
             }
         }
+
         // 获取记录总数
         $result['total'] = $allCount;
         $result['list'] = $getMoneyBuyStr;
         // 总页数计算
-        $result['countPage'] = ceil($result['total'] / $pageSize);
+        $result['countPage'] = ceil($result['total'] / 10);
         $result['currentPage'] = $currentPage;
 
         return $result;
@@ -509,7 +521,7 @@ class MoneyBuy extends Model {
         // 当前页
         $currentPage = isset($_POST['currentPage']) ? $_POST['currentPage'] : "1";
         // 分页大小
-        $pageSize = isset($_POST['pageSize']) ? $_POST['pageSize'] : "10";
+        $pageSize = isset($_POST['pageSize']) ? $_POST['pageSize'] : 10;
         // 起始查询位置
         $begin = ($currentPage - 1) * $pageSize;
         $moneyRecord = lm('Money_buy_simplex', "commons");

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

@@ -23,6 +23,7 @@ class Money_buy_match extends Model {
      * @param mixed $begin 起始查询位置
      * @param mixed $pageSize 分页大小
      * @param mixed $orderBy 排序字段
+     * $order_ids  arr 订单id
      * @return array JsonString
      */
    
@@ -71,6 +72,70 @@ class Money_buy_match extends Model {
         return $result;
     }
 
+    /**
+     * 按注单id查询
+     */
+    public function moneyBuyMatch_v1($select, $where = '', $orWhere = '', $begin = '', $pageSize = '', $orderBy = ['order_id' => 'desc'],$order_ids = []) {
+        // 查询字段
+        $result = $this -> select($select)
+        // ->join('st_odds_code', 'st_odds_code.odds_code', '=', 'money_buy_match.odds_code')
+        // ->join('st_odds_code', 'st_odds_code.game_code', '=', 'money_buy_match.game_code')
+        ->join('st_odds_code', function ($join) {
+            $join->on('money_buy_match.odds_code', '=','st_odds_code.odds_code')->on('money_buy_match.game_code', '=','st_odds_code.game_code');
+        })
+        // ->where($where)
+        ->whereIn('order_id',$order_ids)
+        // ->limit($pageSize)
+        ->orderBy('order_id', 'desc')
+        // ->offset($begin)
+        ->get();
+        
+        
+        
+        //            ->join('money_details', 'money_details.info_identity', '=', 'money_buy_simplex.info_identity')
+
+        /*
+        // 查询条件
+        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;
+    }
+
+
     /**
      * 投注记录
      *