彭俊 6 anni fa
parent
commit
4026e02cbe
1 ha cambiato i file con 107 aggiunte e 1 eliminazioni
  1. 107 1
      Application/Api/Controller/Betorder.php

+ 107 - 1
Application/Api/Controller/Betorder.php

@@ -829,7 +829,7 @@ class Betorder extends BaseController{
      * $userInfo 用户数据
      * $batch_id 批次号
      */
-    public function stringBet($data_str=[],$data_all=[],$userInfo=[],$batch_id=0){
+    public function stringBet__($data_str=[],$data_all=[],$userInfo=[],$batch_id=0){
         //验证串式投注是否合法
         $this->verify_stringType($data_all);
         //获取串式 总赛事数量
@@ -928,6 +928,112 @@ class Betorder extends BaseController{
             Render('','3205',lang('errors','Api')->get('error-3205'));
         }
 
+        return true;
+    }
+    public function stringBet($data_str=[],$data_all=[],$userInfo=[],$batch_id=0){
+        //验证串式投注是否合法
+        $this->verify_stringType($data_all);
+        //获取串式 总赛事数量
+        $groupNum = count($data_all);//总数量
+
+        $orderData = [];
+        foreach ($data_str as $k=>$v){
+            //字符串替换
+            $str = str_ireplace("串","_",$v['type']);
+            //获取type 3_12
+            $after = substr($str,strpos($str,"_")+1);
+            //当前串式 值
+            $sonNum = substr($str,0,strrpos($str,"_"));
+            //获取倍数
+            if((int)$after == 1){
+                $multiple = $this->getMultiple($groupNum,(int)$sonNum);
+            }else{
+                $multiple =(int)$after;
+            }
+
+            //获取当前串式投注金额及可赢金额
+            if($after == 1){
+                $money_all = $this->getmakeMoney((int)$sonNum,$v['bet_amount'],$multiple,$data_all,$after);
+            }else{
+                $money_all = $this->getStrAllMoney((int)$sonNum,$v['bet_amount'],$multiple,$data_all,$after);
+            }
+            //投注金额
+            $moneyData = $money_all['moneyData'];
+            //可赢金额
+            $prize_money = $money_all['prize_money'];
+            $uuid = UUID();
+            $orderID = OrderID('T');
+
+            $orderData[$k]['info_identity'] = $uuid;
+            $orderData[$k]['account_name'] = $userInfo['account'];
+            $orderData[$k]['account_identity'] = $userInfo['account_identity'];
+            $orderData[$k]['order_id'] = $orderID;
+            $orderData[$k]['game_no'] = "";
+            $orderData[$k]['money'] = $moneyData;//$pay_money//总投注金额
+            $orderData[$k]['money_time'] = $this->time;//下注时间
+            $orderData[$k]['prize_money'] = $prize_money;//$expect_money ;//预期总可赢金额
+            $orderData[$k]['str_type'] = $v['type'];//串式类型
+            $orderData[$k]['batch_id'] = $batch_id;//批次号
+            $orderData[$k]['wait_match_num'] = count($data_all);//批次号
+
+            //写资金变动表
+            $insertMoney  = $this->M->insertMoney($userInfo['account_identity'],$moneyData,$orderID,1,"",$uuid,$userInfo);
+            if($insertMoney!=1){
+                Render('', $insertMoney,lang('Errors','Api')->get('error'.$insertMoney));
+            }
+            $this->M->fanshui($userInfo['account_identity'],$userInfo['account'],$moneyData,$orderID);//反水
+
+            //===处理赛事数据===
+            foreach ($data_all as $kk=>$vv){
+                $getModels = $this->commonFunction->getModels($vv['ballId']);
+                $model_match = $getModels['model_match'];
+    
+                //获取是否是滚球投注
+                $is_rolling = 0;
+    
+                if($vv['match_type'] == 'StRollBall'){
+                    $is_rolling = 1;
+                }
+                $matchData[] = [
+                    'batch_id'=>$batch_id,
+                    'odds_id'=>$vv['id'],
+                    'home_team'=>$vv['home_team'],
+                    'guest_team'=>$vv['guest_team'],
+                    'condition'=>$vv['condition'],
+                    'odds'=>$vv['odds'],
+                    'odds_code'=>$vv['odds_code'],
+                    'p_code'=>$vv['p_code'],
+                    'odds_only'=>$vv['odds_only'],
+                    'status'=>0,
+                    'match_id'=>$vv['match_id'],
+                    'game_code'=>$vv['ballId'],
+                    'lg_id'=> $vv['lg_id'],
+                    'ctime'=>$this->time,//写入时间
+                    'utime' => $this->time,
+                    'bet_type'=>2,
+                    'is_rolling'=>$is_rolling,
+                    'order_id'=> $orderID,
+                ];
+            }
+            //写赔率数据表
+            $moneyBuyMatch = lm('MoneyBuyMatch','Api')->insert($matchData);
+            if(!$moneyBuyMatch){
+                Render('','3205',lang('errors','Api')->get('error-3205'));
+            }
+
+            //===end===
+        }
+
+        //写注单 表
+        $moneyBuy = lm('MoneyBuyStr','Api')->insert($orderData);
+
+        if(!$moneyBuy){
+            Render('','3205',lang('errors','Api')->get('error-3205'));
+        }
+
+
+       
+
         return true;
     }