彭俊 6 年 前
コミット
8f419e717c

+ 27 - 3
Application/Api/Controller/Betorder.php

@@ -5,6 +5,7 @@ use Biz\Money\Moneycopy;
 use Biz\Money\Money;
 use Biz\Account\AccountManager;
 use App\Api\Model\St_odds_code as odds_codeModel;
+use App\Api\Model\Dc_user_grade;
 /*
  * Class Register
  * @package App\Api\Controller
@@ -211,7 +212,8 @@ class Betorder extends BaseController{
     }
 
     public function Bet(){
-        /* 模拟单式数据
+        // 模拟单式数据
+        /*
         $get_data = [
             'data'=>[
                 [
@@ -242,8 +244,9 @@ class Betorder extends BaseController{
                 ]
             ],
             
-            'token'=>'Zowv7715649767885d47a6945b98f',
-            'bet_money'=>1
+            'token'=>'leNQX315656035465d5136da9967c',
+            'bet_money'=>900,
+            'bet_money_arr'=>[100,200,300],
 
         ];
         */
@@ -333,11 +336,18 @@ class Betorder extends BaseController{
             $token = $get_data['token'];
             $bet_money = $get_data['bet_money'];
             $data = $get_data['data'];
+            $bet_money_arr = $get_data['bet_money_arr'];
         }else{
             $data = $_REQUEST['data'];
             $bet_money = $_REQUEST['bet_money'];
             $token = $_REQUEST['token'];
+            $bet_money_arr = $_REQUEST['bet_money_arr'];
         }
+        /*
+        $data = $get_data['data'];
+        $bet_money = $get_data['bet_money'];
+        $token = $get_data['token'];
+        */
 
          //验证用户token
          $userInfo = $this->getAgent($token);
@@ -349,6 +359,20 @@ class Betorder extends BaseController{
         if(!$this->M->verifyMoney($bet_money,$userInfo['cash'])){
             Render('', '4204',lang('Errors','Api')->get('error-4204'));
         }
+
+        //===追加验证用户投注金额限额===
+        if(empty($bet_money_arr)) Render('', '3605',lang('Errors','Api')->get('error-3605'));
+        //获取当前用户分组名称
+        $substr = substr($userInfo['group_name'],strpos($userInfo['group_name'],'|')+1);
+        $role_name = substr($substr, 0, -1);
+        //获取用户分组的投注限额
+        $bet_money_limit = Dc_user_grade::get_bet_money_limit($role_name);
+        foreach($bet_money_arr as $k=>$v){
+            if($v < $bet_money_limit->lower_limit)  Render('', '3406',lang('Errors','Api')->get('error-3406'));
+            if($v > $bet_money_limit->upper_limit)  Render('', '3401',lang('Errors','Api')->get('error-3401'));
+        }
+        //===end==
+
         $batch_id = strtotime(date('Y-m-d H:i:s',time())).mt_rand('1','99');//批量ID
         //执行数据插入
         try {

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

@@ -225,6 +225,7 @@ return array(
     'error-3602' => '未提交游戏号码',
     'error-3603' => '号码有误',
     'error-3604' => '未获取到相应数据',
+    'error-3605' => '未获取到盘口投注金额',
     'error-5001	' => '活动公告无数据',
     'error-5002' => '数据类型缺失',
     'error-5003' => '获取一条数据失败',

+ 24 - 0
Application/Api/Model/Dc_user_grade.php

@@ -0,0 +1,24 @@
+<?php
+namespace App\Api\Model;
+
+use \System\Model;
+
+/**
+ * Class St_country
+ * @package App\Sports\Model
+ * 会员分组 
+ */
+class Dc_user_grade extends Model
+{
+
+    protected $table = 'dc_user_grade';
+
+    //根据分组名称 获取投注限额
+    public static function get_bet_money_limit($grade_name){
+        $limit = self::select('grade','name','lower_limit','upper_limit')
+                    ->where('name', $grade_name)
+                    ->first();
+
+        return  $limit;
+    }
+}

+ 45 - 4
Application/Sports/Controller/Head.php

@@ -12,6 +12,8 @@ use App\Sports\Model\St_wq_odds as WQoddsModel;
 use App\Sports\Model\St_bq_odds as BQoddsModel;
 use App\Sports\Model\St_zq_league as leagueModel;
 
+use Biz\Match\GetmatchData;
+use Biz\Match\GetOddsData;
 
 /**
  * Class Head
@@ -22,6 +24,8 @@ use App\Sports\Model\St_zq_league as leagueModel;
 class Head extends Controller{
     public function init() {
         $this->commonFunction =  C()->get('commonFunction');
+        $this->getTypeData = new GetmatchData();
+        $this->getOddsData = new GetOddsData();
 
     }
 
@@ -36,8 +40,13 @@ class Head extends Controller{
 
     }
 
+
     //获取各状态下所有赛事数量
-    public function __typeList(){
+    public function typeList(){
+        $this->typeList_v2();
+    }
+
+    public function typeList_v1(){
         //获取所有未结束赛事
         $where = [
             ['status','<','2']
@@ -133,8 +142,7 @@ class Head extends Controller{
     }
 
 
-    //重写方法
-    public function typeList(){
+    public function typeList_v2(){
         //获取所有未结束赛事
         $where = [
             ['status','<','2']
@@ -178,10 +186,12 @@ class Head extends Controller{
         $StStringScene = [];
         //按状态条件分装数组
         foreach ($matchAll as $kk=>$vv){
+            /*
             //滚球
             if($vv['status'] < 2 and $vv['match_date'] == date("Y-m-d") and $vv['match_time'] > date("H:i:s", time()-(90*60)) and $vv['match_time'] < date("H:i:s", time())){
                 $StRollBall[] = $vv;
             }
+            */
             //即将
             if($vv['status'] == '0' and $vv['match_date'] == date("Y-m-d") and $vv['match_time'] < date("H:i:s", strtotime("+2 hour")) and $vv['match_time'] > date("H:i:s", time())){
                 $StSoon[] = $vv;
@@ -204,7 +214,8 @@ class Head extends Controller{
         foreach ($type as $k=>$v){
             switch ($v['type_code']) {
                 case 'StRollBall'://滚球
-                    $type[$k]['matchNum'] = count($StRollBall);
+                    // $type[$k]['matchNum'] = count($StRollBall);
+                    $type[$k]['matchNum'] = $this->getRollBallNum();
                     break;
                 case 'StSoon'://即将
                     $type[$k]['matchNum'] = count($StSoon);
@@ -228,4 +239,34 @@ class Head extends Controller{
         Render($type, '1', lang('Tips','Sports')->get('success'));
 
     }
+
+    /**
+     * 获取各球类滚球数量
+     */
+    public function getRollBallNum(){
+        $ret = lm('GameType', 'Sports')->select('id','game_code')->where('status',1)->get()->toArray();
+
+        //滚球赛事数量
+        $matchNum = [];
+        foreach($ret as $k=>$v){
+            if($v['game_code'] != 'gj'){
+                //根据球类代码 获取相关model
+                $models = $this->commonFunction->getModels($v['game_code']);
+                $model_match = $models['model_match'];
+                //获取 不同状态的查询条件
+                $where = $this->commonFunction->getState('StRollBall',$model_match,$v['game_code']);
+                //获取滚球数据
+                $match_data= $this->getTypeData->getRollBall('',$models,$where,$v);
+                if(!empty($match_data)){
+                    foreach($match_data as $kk=>$vv){
+                        $matchNum[] = $vv['matchNum'];
+                    }
+                }
+            }
+
+        }
+        $matchNum = array_sum($matchNum);
+
+        return $matchNum;
+    }
 }

+ 8 - 0
Biz/Account/AccountManager.php

@@ -5,6 +5,7 @@ namespace Biz\Account;
 use App\Commons\Model\Money_recharge;
 use Biz\Account\Repository\AccountRepository;
 use Biz\TokenManager;
+use App\Api\Model\Dc_user_grade;
 
 /**
  * Created by PhpStorm.
@@ -106,6 +107,13 @@ class AccountManager {
 //                    }
 
                     $userInfo[0]['remark'] = str_replace("%","",$userInfo[0]['remark']);
+                    //获取当前用户分组名称
+                    $substr = substr($userInfo[0]['group_name'],strpos($userInfo[0]['group_name'],'|')+1);
+                    $role_name = substr($substr, 0, -1);
+                    //获取用户分组的投注限额
+                    $bet_money_limit = Dc_user_grade::get_bet_money_limit($role_name);
+                    $userInfo[0]['bet_money_limit'] = ['lower_limit'=>$bet_money_limit->lower_limit,'upper_limit'=>$bet_money_limit->upper_limit];
+
                     $result = ['data' => $userInfo, 'status' => 1, 'msg' => lang()->get('login successful')];
                     return $result;
                 } catch (Exception $e) {