Ethan 6 жил өмнө
parent
commit
fb93f8bc59

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

@@ -83,7 +83,7 @@ class MoneyBuy extends Model {
         $moneyBuySpxBetween = ['money_time' => [$startTime, $endTime]];
         $moneyBuySpxMdl = lm('money_buy_simplex', "commons");
         // 获取订单记录
-        $moneyBuySpxSlt = ['batch_id'];
+        $moneyBuySpxSlt = ['batch_id', 'order_id'];
         $getMoneyBuySpx = $moneyBuySpxMdl -> moneyBuySimplex($moneyBuySpxSlt, $moneyBuySpxWhere, $moneyBuySpxBetween, '', '', 1);
         // 获取全部订单id
         $moneyBuyMthOr = [];
@@ -131,6 +131,42 @@ class MoneyBuy extends Model {
         $moneyBuyMthSlt = ['status', 'bet_money', 'matchResult', 'result', 'home_team',  'batch_id', 'guest_team', 'condition', 'ctime', 'odds', 'odds_name', 'match_id', 'money_buy_match.game_code', 'money_buy_match.odds_code'];
         $getMoneyBuyMth = $moneyBuyMthMdl -> moneyBuyMatch($moneyBuyMthSlt, $moneyBuyMthWhere, $moneyBuyMthOr, $begin, $pageSize);
         $allCount = $moneyBuyMthMdl -> moneyBuyMatchTotal($moneyBuyMthWhere, $moneyBuyMthOr);
+        // 获取所有的比赛类型
+        $stGameTypeMdl = lm('StGameType', "commons");
+        $StGameTypeSlt = ['game_code'];
+        $StGameTypeWhr['status'] = 1;
+        $getStGameType = $stGameTypeMdl -> getGameType($StGameTypeSlt, $StGameTypeWhr);
+        $allMatch = [];
+        $allMatchInfo = [];
+        foreach ($getStGameType as $value) {
+            $allMatch[$value->game_code] = [];
+            $allMatchInfo[$value->game_code] = [];
+        }
+        // 循环获取所有的赛事ID
+        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) {
+                if ($v->match_id == $value->id) {
+                    $getMoneyBuyMth[$k]->match_date = $value->match_date;
+                    $getMoneyBuyMth[$k]->match_time = $value->match_time;
+                    $getMoneyBuyMth[$k]->lg_name = $value->name_chinese;
+                }
+            }
+            foreach ($getMoneyBuySpx as $key => $value) {
+                if ($v->batch_id == $value['batch_id']) {
+                    $getMoneyBuyMth[$k]->order_id = $value['order_id'];
+                }
+            }
+        }
         // 获取可加注所需要的查询条件
         $commonFunction = C() -> get('commonFunction');
         $stOddsWheres = [];
@@ -235,7 +271,7 @@ class MoneyBuy extends Model {
         // 起始查询位置
         $begin = ($currentPage - 1) * $pageSize;
         // 获取订单记录
-        $moneyBuyStrSlt = ['batch_id', 'gain_money', 'game_status', 'money', 'prize_money', 'money_time'];
+        $moneyBuyStrSlt = ['order_id', 'batch_id', 'gain_money', 'game_status', 'money', 'prize_money', 'money_time'];
         $getMoneyBuyStr = $moneyBuyStrMdl -> moneyBuyStr($moneyBuyStrSlt, $moneyBuyStrWhere, $moneyBuyStrBetween, $begin, $pageSize, 1);
         $allCount = $moneyBuyStrMdl -> moneyBuyStrTotal($moneyBuyStrWhere, $moneyBuyStrBetween);
         // 获取全部订单id
@@ -260,6 +296,37 @@ class MoneyBuy extends Model {
         $moneyBuyMthMdl = lm('Money_buy_match', "commons");
         $moneyBuyMthSlt = ['status', 'matchResult', 'bet_money', 'home_team', 'guest_team', 'condition', 'odds', 'odds_name', 'match_id', 'batch_id', 'money_buy_match.game_code', 'money_buy_match.odds_code'];
         $getMoneyBuyMth = $moneyBuyMthMdl -> moneyBuyMatch($moneyBuyMthSlt, $moneyBuyMthWhere, $moneyBuyMthOr, $begin, $pageSize);
+        // 获取所有的比赛类型
+        $stGameTypeMdl = lm('StGameType', "commons");
+        $StGameTypeSlt = ['game_code'];
+        $StGameTypeWhr['status'] = 1;
+        $getStGameType = $stGameTypeMdl -> getGameType($StGameTypeSlt, $StGameTypeWhr);
+        $allMatch = [];
+        $allMatchInfo = [];
+        foreach ($getStGameType as $value) {
+            $allMatch[$value->game_code] = [];
+            $allMatchInfo[$value->game_code] = [];
+        }
+        // 循环获取所有的赛事ID
+        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) {
+                if ($v->match_id == $value->id) {
+                    $getMoneyBuyMth[$k]->match_date = $value->match_date;
+                    $getMoneyBuyMth[$k]->match_time = $value->match_time;
+                    $getMoneyBuyMth[$k]->lg_name = $value->name_chinese;
+                }
+            }
+        }
         // 获取可加注所需要的查询条件
         $commonFunction = C() -> get('commonFunction');
         $stOddsWheres = [];
@@ -309,7 +376,7 @@ class MoneyBuy extends Model {
             }
             foreach ($getMoneyBuyMth as $k => $v) {
                 if ($value['batch_id'] == $v['batch_id']) {
-                    $getMoneyBuyStr[$key]['money_buy'][$k] = $v;
+                    $getMoneyBuyStr[$key]['money_buy'][] = $v;
                 }
             }
         }

+ 186 - 0
Application/Api/Model/Money_buy_match.php

@@ -0,0 +1,186 @@
+<?php
+/**
+*------Create thems Model------
+*------SCWPHP  Version 1.0.0------
+*------Dev Model Jions------
+*------Create Time 2017-06-13 18:45:24------
+*/
+namespace App\Commons\Model;
+
+use \System\Model;
+
+class 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', 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');
+        });
+        // 查询条件
+        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 $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 moneyBuyMatchAll($select, $where = '', $orWhere = '', $begin = '', $pageSize = '', $orderBy = ['batch_id' => 'desc']) {
+        // 查询字段
+        $result = $this -> select($select);
+        // 查询条件
+        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;
+    }
+
+    public  function  getByTypeMatch($type,$matchId){
+          $rets = $this->where(['game_code'=>$type,'match_id'=>$matchId])->find();
+          return $rets;
+    }
+
+    //查找某个订单下是否还有未处理完的订单情况
+    public function    FindByTypeOrderResult($type,$OrderId,$result=0){
+            if (is_string($result)){
+                $ret = $this->where(['game_code'=>$type,'order_id'=>$OrderId,'result'=>$result])->find();
+            }else{
+                $ret = $this->where(['game_code'=>$type,'order_id'=>$OrderId])->whereIn('result',$result)->find();
+            }
+            return $ret;
+    }
+
+    public function  getByBatchId($batch_id){
+            $ret = $this->where('batch_id',$batch_id)->find();
+            return $ret;
+    }
+
+
+
+
+}