瀏覽代碼

追加推送 5/24

彭俊 6 年之前
父節點
當前提交
12625eb2e1

+ 0 - 88
Application/Api/Controller/Betorder.php

@@ -340,94 +340,6 @@ class Betorder extends BaseController{
      * $batch_id 批次号
      */
     public function stringBet($data_str=[],$data_all=[],$userInfo=[],$batch_id=23456){
-//        $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' => '3.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' => '2.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' => '3.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' => '2.94',
-//                'p_code' => 'concede_size',
-//                'ballId' => 'zq',
-//                'match_id' => 3127596,
-//                'condition' => '+0/0.5',
-//                'ganame' => 'concede_size',
-//                'bettingTime' =>'',
-//                'odds_only' => '1dee7e98db303852227cf1e0d8085dfb1555617310.3833947',
-//                'type' => 1,
-//            ]
-//        ];
-
         //验证串式投注是否合法
         $this->verify_stringType($data_all);
         //获取串式 总赛事数量

+ 56 - 10
Application/Api/Model/MoneyBuy.php

@@ -88,6 +88,16 @@ class MoneyBuy extends Model {
         // 获取全部订单id
         $moneyBuyMthOr = [];
         $allBatchId = array_unique($getMoneyBuySpx, SORT_REGULAR);
+        if (!$allBatchId) {
+            // 获取记录总数
+            $result['total'] = 0;
+            $result['list'] = [];
+            // 总页数计算
+            $result['countPage'] = 1;
+            $result['currentPage'] = 1;
+
+            return $result;
+        }
         foreach ($allBatchId as $key => $value) {
             $moneyBuyMthOr[0][$key][0] = 'batch_id';
             $moneyBuyMthOr[0][$key][1] = $value['batch_id'];
@@ -206,6 +216,16 @@ class MoneyBuy extends Model {
         // 获取全部订单id
         $moneyBuyMthOr = [];
         $allBatchId = array_unique($getMoneyBuyStr, SORT_REGULAR);
+        if (!$allBatchId) {
+            // 获取记录总数
+            $result['total'] = 0;
+            $result['list'] = [];
+            // 总页数计算
+            $result['countPage'] = 1;
+            $result['currentPage'] = 1;
+
+            return $result;
+        }
         foreach ($allBatchId as $key => $value) {
             $moneyBuyMthOr[0][$key][0] = 'batch_id';
             $moneyBuyMthOr[0][$key][1] = $value['batch_id'];
@@ -280,6 +300,8 @@ class MoneyBuy extends Model {
      */
     public function moneyRecord()
     {
+        /*$moneyRecord = lm('Money_buy_simplex', "commons");
+        $moneyRecord->aa();*/
         // 获取用户信息
         $accountManagerClass = new AccountManager;
         $userInfo = $accountManagerClass -> getCurrentUser();
@@ -300,12 +322,12 @@ class MoneyBuy extends Model {
         $pageSize = isset($_POST['pageSize']) ? $_POST['pageSize'] : "10";
         // 起始查询位置
         $begin = ($currentPage - 1) * $pageSize;
-        $moneyRecord = lm('money_record', "commons");
+        $moneyRecord = lm('Money_buy_simplex', "commons");
         $moneyRecordSelect = ['info_identity', 'trade_id', 'account_identity', 'money', 'money_time', 'money_type'];
         // 获取盈亏记录
-        $result['list'] = $moneyRecord -> moneyRecord($moneyRecordSelect, $moneyRecordWhere, $moneyRecordBetween, $begin, $pageSize);
+        $result['list'] = $moneyRecord -> winLoseRecord($moneyRecordWhere, $moneyRecordBetween, $begin, $pageSize);
         // 获取记录总数
-        $result['total'] = $moneyRecord -> moneyRecordTotal($moneyRecordWhere, $moneyRecordBetween);
+        $result['total'] = $moneyRecord -> winLoseCount($moneyRecordWhere, $moneyRecordBetween);
         // 总页数计算
         $result['countPage'] = ceil($result['total'] / $pageSize);
         $result['currentPage'] = $currentPage;
@@ -340,10 +362,28 @@ class MoneyBuy extends Model {
         // 获取单式投注订单
         $moneyBuySimplex = lm('money_buy_simplex', "commons");
         $mnyBuySpxData = $moneyBuySimplex
-            ->select(['order_id', 'money', 'gain_money'])
+            ->select(['order_id', 'money', 'gain_money', 'batch_id'])
             ->where($moneyBuyWhere)
             ->whereBetween('settlementTime', $moneyBuyBetween)
-            ->get();
+            ->get()
+            ->toArray();
+        // 获取全部订单id
+        $moneyBuyMthOr = [];
+        $allBatchId = array_unique($mnyBuySpxData, SORT_REGULAR);
+        if ($allBatchId) {
+            foreach ($allBatchId as $key => $value) {
+                $moneyBuyMthOr[0][$key][0] = 'batch_id';
+                $moneyBuyMthOr[0][$key][1] = $value['batch_id'];
+            }
+            $moneyBuyMthWhere['bet_type'] = 1;
+            // 获取注单
+            $moneyBuyMthMdl = lm('Money_buy_match', "commons");
+            $moneyBuyMthSlt = ['bet_money', 'odds', 'result'];
+            $getMoneyBuyMth = $moneyBuyMthMdl -> moneyBuyMatchAll($moneyBuyMthSlt, $moneyBuyMthWhere, $moneyBuyMthOr);
+        } else {
+            $getMoneyBuyMth = [];
+        }
+
         // 获取串式投注订单
         $moneyBuyStr = lm('money_buy_str', "commons");
         $mnyBuyStrData = $moneyBuyStr
@@ -353,14 +393,20 @@ class MoneyBuy extends Model {
             ->get();
         $winMoney = $userInfo['allWin'];
         $loseMoney = $userInfo['allLose'];
-        foreach ($mnyBuySpxData as $key => $value) {
+        // 单式盈利.
+        foreach ($getMoneyBuyMth as $key => $value) {
             // 判断订单是否盈利
-            if ($value->money >= $value->gain_money) {
-                $loseMoney += $value->money - $value->gain_money;   //本钱减回款
-            } else {
-                $winMoney += $value->gain_money - $value->money;    //回款减本钱
+            if ($value->result == 1) {
+                $winMoney += $value->bet_money * $value->odds;
+            } else if ($value->result == 3) {
+                $winMoney += $value->bet_money * $value->odds * 0.5;
+            } else if ($value->result == 4) {
+                $loseMoney += $value->bet_money * 0.5;
+            } else if ($value->result == -1) {
+                $loseMoney += $value->bet_money;
             }
         }
+        // 串式盈利.
         foreach ($mnyBuyStrData as $key => $value) {
             // 判断订单是否盈利
             if ($value->money >= $value->gain_money) {

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

@@ -66,6 +66,58 @@ class Money_buy_match extends Model {
         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;
+    }
+
     /**
      * 投注记录
      *

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

@@ -9,6 +9,7 @@ namespace App\Commons\Model;
 
 use \System\Model;
 use Illuminate\Support\Facades\DB;
+use DB as DD;
 
 class Money_buy_simplex extends Model {
 
@@ -69,4 +70,71 @@ class Money_buy_simplex extends Model {
 
         return $result;
     }
+
+    /**
+     * 盈亏记录
+     *
+     * @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 winLoseRecord($where, $between, $begin = '', $pageSize = '') {
+        $select = ['money_time', 'gain_money', 'money'];
+        $mnyBuyStrMdl = lm('Money_buy_str', "commons");
+        $mnyBuyStrSql = $mnyBuyStrMdl->select($select)->where($where);
+        $mnyBuySpxSql = $this
+            ->select($select)
+            ->where($where)
+            ->unionAll($mnyBuyStrSql)
+            ->whereBetween('money_time', $between)
+            ->offset($begin)
+            ->limit($pageSize)
+            ->orderBy('money_time','DESC')
+            ->get();
+        foreach ($mnyBuySpxSql as $key => $value) {
+            if ($value->gain_money >= $value->money) {
+                $mnyBuySpxSql[$key]->money_type = 1;
+                $mnyBuySpxSql[$key]->money = $value->gain_money - $value->money;
+            } else {
+                $mnyBuySpxSql[$key]->money = $value->money - $value->gain_money;
+            }
+        }
+
+        return $mnyBuySpxSql;
+    }
+
+    /**
+     * 盈亏总数
+     *
+     * @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 winLoseCount($where, $between) {
+        $select = ['order_id'];
+        $mnyBuyStrMdl = lm('Money_buy_str', "commons");
+        $mnyBuyStrSql = $mnyBuyStrMdl->select($select)->where($where);
+        $mnyBuySpxSql = $this
+            ->select($select)
+            ->where($where)
+            ->unionAll($mnyBuyStrSql)
+            ->whereBetween('money_time', $between)
+            ->get();
+
+        return count($mnyBuySpxSql);
+    }
 }

+ 14 - 30
Application/Sports/Controller/MatchList.php

@@ -360,7 +360,6 @@ class  MatchList extends Controller {
             $where = $this->commonFunction->getState($type_code);
 
             $gameData = [];
-
             foreach ($game as $key=>$type){
                 if($type_code != 'StChampion'){
                     $matchModel = $this->commonFunction->getModels($type['game_code']);
@@ -514,38 +513,23 @@ class  MatchList extends Controller {
             $league = [];
             if($oddsType != 'StRollBall'){
                 $where = [
-                    ['home_team','<>',null],
-                    ['guest_team','<>',null],
-                    ['status','<',2],
-                    ['us_time','>',qgmdate('Y-m-d H:i:s', '', -4)],
-                    ['lg_id',$matchData->lg_id],
+                    [$model_match.'.home_team','<>',null],
+                    [$model_match.'.guest_team','<>',null],
+                    [$model_match.'.status','<',2],
+                    [$model_match.'.us_time','>',qgmdate('Y-m-d H:i:s', '', -4)],
+                    [$model_match.'.lg_id',$matchData->lg_id],
+                    [$model_league.'.name_chinese','!=',''],
                 ];
-
-                switch ($oddsType)
-                {
-                    case 'StSoon'://即将
-                        $matchWhere=[['is_morningplate','=',1]];
-                        break;
-                    case 'StToday'://今日
-                        $matchWhere=[['is_today','=',1]];
-                        break;
-                    case 'StMorningPlate'://早盘
-                        $matchWhere=[['is_morningplate','=',1]];
-                        break;
-                    case 'StStringScene'://串场
-                        $matchWhere = [['is_stringscene','=',1]];
-                        break;
-                    case 'home'://首页
-                        $matchWhere = [['is_stringscene','=',1]];
-                        break;
-                    default:
-                        $matchWhere = [];
+                if($oddsType !='home'){
+                   $getState =  $this->commonFunction->getState($oddsType,$model_match);
+                }else{
+                    $getState = [];
                 }
                 $league = lm($model_match,'Sports')
-                    ->select('match_id','home_team','guest_team','status','match_date','match_time')
-                    ->where($this->source)
+                    ->join($model_league,$model_league.'.lg_id',$model_match.'.lg_id')
+                    ->select($model_match.'.match_id',$model_match.'.home_team',$model_match.'.guest_team',$model_match.'.status',$model_match.'.match_date',$model_match.'.match_time')
                     ->where($where)
-                    ->where($matchWhere)
+                    ->where($getState)
                     ->get()
                     ->toarray();
             }
@@ -658,7 +642,7 @@ class  MatchList extends Controller {
                 ->get();
             foreach ($p_code as $k=>$v){
                 $v->below = lm('st_odds_code','Sports')
-                    ->select('odds_code','odds_name')
+                    ->select('game_code','odds_code','odds_name')
                     ->where('p_id',$v['id'])
                     ->get();
             }

+ 41 - 13
Application/Sports/Controller/Sports.php

@@ -32,21 +32,32 @@ class Sports extends Controller{
             $data['all']['code'] = 'today';
             $data['all']['count'] = lm($st_competition,'Sports')
                 ->join($st_league,$st_league.'.lg_id',$st_competition.'.lg_id')
-                ->where(getState('StToday'))
-                ->where($st_competition.'.source',$this->source['source'])
-                ->where($st_competition.'.home_team','<>',null)
-                ->where($st_competition.'.guest_team','<>',null)
-                ->distinct($st_competition.'.match_id')
+                ->where(getState('StToday',$st_competition))
+                ->where([
+                    [$st_competition.'.source',$this->source['source']],
+                    [$st_competition.'.home_team','<>',null],
+                    [$st_competition.'.guest_team','<>',null],
+                    [$st_league.'.name_chinese','<>',null],
+                    [$st_competition.'.status','<',2],
+                    [$st_competition.'.us_time','>',qgmdate('Y-m-d H:i:s', '', -4)]
+                ])
                 ->count('*');
             } else {
                 $data['all']['name'] = '所有赛事';
                 $data['all']['game_code'] = $game_code;
                 $data['all']['code'] = 'all';
                 $data['all']['count'] = lm($st_competition,'Sports')
+                    ->join($st_league,$st_league.'.lg_id',$st_competition.'.lg_id')
                     ->where([[$st_competition.'.status', '<', '2'],
                         [$st_competition.'.source',$this->source['source']]])
-                    ->where($st_competition.'.home_team','<>',null)
-                    ->where($st_competition.'.guest_team','<>',null)
+                    ->where([
+                        [$st_competition.'.source',$this->source['source']],
+                        [$st_competition.'.home_team','<>',null],
+                        [$st_competition.'.guest_team','<>',null],
+                        [$st_league.'.name_chinese','<>',null],
+                        [$st_competition.'.status','<',2],
+                        [$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))
                     ->count('*');
             }
@@ -57,8 +68,14 @@ class Sports extends Controller{
             ->where([[$st_competition.'.status','<',2],[$st_competition.'.source',$this->source]])
             ->where($st_competition.'.us_time','>',qgmdate('Y-m-d H:i:s', '', -4))
             ->where($where)
-            ->where($st_competition.'.home_team','<>',null)
-            ->where($st_competition.'.guest_team','<>',null)
+            ->where([
+                [$st_competition.'.source',$this->source['source']],
+                [$st_competition.'.home_team','<>',null],
+                [$st_competition.'.guest_team','<>',null],
+                [$st_league.'.name_chinese','<>',null],
+                [$st_competition.'.status','<',2],
+                [$st_competition.'.us_time','>',qgmdate('Y-m-d H:i:s', '', -4)]
+            ])
             ->limit($limit_mt)
             ->get();
         if(!empty($data['match'])){
@@ -71,8 +88,14 @@ class Sports extends Controller{
             ->where([[$st_competition.'.status','<',2],[$st_competition.'.source',$this->source]])
             ->where($st_competition.'.us_time','>',qgmdate('Y-m-d H:i:s', '', -4))
             ->where($where)
-            ->where($st_competition.'.home_team','<>',null)
-            ->where($st_competition.'.guest_team','<>',null)
+            ->where([
+                [$st_competition.'.source',$this->source['source']],
+                [$st_competition.'.home_team','<>',null],
+                [$st_competition.'.guest_team','<>',null],
+                [$st_league.'.name_chinese','<>',null],
+                [$st_competition.'.status','<',2],
+                [$st_competition.'.us_time','>',qgmdate('Y-m-d H:i:s', '', -4)]
+            ])
             ->limit($limit_lg)
             ->distinct($st_league.'lg_id')
             ->get();
@@ -87,8 +110,13 @@ class Sports extends Controller{
                     ->where([[$st_competition.'.status','<',2],[$st_competition.'.source',$this->source]])
                     ->where('lg_id',$v['lg_id'])
                     ->where($where)
-                    ->where($st_competition.'.home_team','<>',null)
-                    ->where($st_competition.'.guest_team','<>',null)
+                    ->where([
+                        [$st_competition.'.source',$this->source['source']],
+                        [$st_competition.'.home_team','<>',null],
+                        [$st_competition.'.guest_team','<>',null],
+                        [$st_competition.'.status','<',2],
+                        [$st_competition.'.us_time','>',qgmdate('Y-m-d H:i:s', '', -4)]
+                    ])
                     ->count('*');
             }
         }

+ 15 - 3
Biz/Match/GetmatchData.php

@@ -484,13 +484,25 @@ class GetmatchData {
             foreach ($data as $k=>$v){
                 foreach ($v['matchData'] as $kk=>$vv){
                     //获取赛事下赔率并且分组
-                    $odds = [];
+                    $capot = [];
+                    $total_size = [];
+                    $concede = [];
                     foreach ($oddsData as $kkk=>$vvv) {
                         if ($vv['match_id'] == $vvv['match_id'] and $vvv['sort']==0) {
-                            $odds[] = $vvv;
+                            if($vvv['p_code'] == 'capot'){
+                                $capot[] = $vvv;
+                            }else{
+                                if($vvv['p_code'] == 'total_size'){
+                                    $total_size[] = $vvv;
+                                }
+                                if($vvv['p_code'] == 'concede'){
+                                    $concede[] = $vvv;
+                                }
+                            }
                         }
                     }
-                    $data[$k]['matchData'][$kk]['oddsData'] = $odds;
+                    $concede_size = [$concede[0],$concede[1],$total_size[0],$total_size[1]];
+                    $data[$k]['matchData'][$kk]['oddsData'] = [$concede_size,$capot];
                 }
             }
         }