vali 6 年之前
父节点
当前提交
ddd6bfa775
共有 2 个文件被更改,包括 35 次插入13 次删除
  1. 28 12
      app/Logic/WinfailLogic.php
  2. 7 1
      datainf/logic/HttpServerSettelement.php

+ 28 - 12
app/Logic/WinfailLogic.php

@@ -135,35 +135,50 @@ class WinfailLogic
 
     public function getOddsTypeData($game_code, $match_id)
     {
-        $ret = DB::table('money_buy_match')->select("p_code", "odds_code", "condition", "bet_type")->where(['game_code' => $game_code, 'match_id' => $match_id])->groupBy('p_code', 'odds_code', 'condition', 'bet_type')->get();
+        $ret = DB::table('money_buy_match')->select("p_code", "odds_code", "condition", "bet_type", "is_champion", "lg_id")->where(['match_id' => $match_id, 'game_code' => $game_code])->groupBy('p_code', 'odds_code', 'condition', 'bet_type', 'is_champion')->get();
         return $ret;
     }
 
 
-    public function doLogic($matchModel, $result)
+    //胜负判断    NotiematchModel赛事结束通知model   $result普通赛事结果对像数组[冠军赛事下可能为空]    $GJresult冠军赛事结果对像数组[非冠军赛事为空]
+    public function doLogic($NotiematchModel, $result, $GJresult)
     {
-        $game_code = $matchModel->game_code;
-        $match_id = $matchModel->match_id;
+        $game_code = $NotiematchModel->game_code;
+        $match_id = $NotiematchModel->match_id;
         $AdapterObj = $this->getAdapterObj($game_code);
         $groupDatas = $this->getOddsTypeData($game_code, $match_id);
         $fristRet = $this->getFristRecord($game_code, $match_id, $groupDatas);
         $RefClass = new  \ReflectionClass($AdapterObj);
-        $noticeId = $matchModel->id;
+        $noticeId = $NotiematchModel->id;
         $nowtime = date("Y-m-d H:i:s");
 
         $winorfalsedef = ['result' => 2, 'matchResult' => 'noRuleOrError'];
         foreach ($fristRet as $matchModel) {
+            $is_champion = $matchModel->is_champion;
             $fun1 = $matchModel->odds_code;
             $fun2 = $matchModel->p_code;
 
+            if ($is_champion == 0) {
+                //普通赛事
+                $resultTypeNow = $result;
+                if (empty($resultTypeNow)) {
+                    throw  new  \Exception("赛事结果不能为空! --lg_id=" . $matchModel->game_code . '_' . $matchModel->lg_id);
+                }
+            } else {
+                //冠军赛事;
+                $resultTypeNow = $GJresult;
+                if (empty($resultTypeNow)) {
+                    throw  new  \Exception("冠军赛事结果不能为空! --lg_id=" . $matchModel->game_code . '_' . $matchModel->lg_id);
+                }
+            }
+
             try {
                 if ($RefClass->hasMethod($fun1)) {
-                    $winorfalse = $AdapterObj->$fun1($matchModel, $result, []);
+                    $winorfalse = $AdapterObj->$fun1($matchModel, $resultTypeNow, []);
                 } elseif ($RefClass->hasMethod($fun2)) {
-                    $winorfalse = $AdapterObj->$fun2($matchModel, $result, []);
+                    $winorfalse = $AdapterObj->$fun2($matchModel, $resultTypeNow, []);
                 }
             } catch (\Exception $e) {
-
             }
             if (!isset($winorfalse['result']) || !isset($winorfalse['matchResult']) || !in_array($winorfalse['result'], [-1, 1, 2, 3, 4])) {
                 $winorfalse = $winorfalsedef;
@@ -177,12 +192,12 @@ class WinfailLogic
             $condition = $matchModel->condition;
             $bet_type = $matchModel->bet_type;
 
-            DB::update('update money_buy_match  set "result"=?,matchresult=? where match_id=? and game_code=? and odds_code=? and p_code=? and  condition=?', [$win, $matword, $match_id, $game_code, $odds_code, $p_code, $condition]);
-            $sql = "select batch_id from money_buy_match where match_id=$match_id and game_code='$game_code' and  p_code='$p_code'and  odds_code='$odds_code'and  condition='$condition' ";
+            DB::update('update money_buy_match  set "result"=?,matchresult=? where match_id=? and game_code=? and odds_code=? and p_code=? and  condition=? and is_champion=?', [$win, $matword, $match_id, $game_code, $odds_code, $p_code, $condition, $is_champion]);
+            $sql = "select batch_id from money_buy_match where match_id=$match_id and game_code='$game_code' and  p_code='$p_code'and  odds_code='$odds_code'and  condition='$condition' and is_champion=$is_champion ";
             if ($bet_type == 1) {
                 DB::update("update money_buy_simplex  set game_status=$rwin  where game_code='$game_code' and  match_id=$match_id and  batch_id in ( $sql)");
             } else {
-                DB::update("update money_buy_simplex  set game_status=$rwin  where batch_id in ( $sql)");
+                DB::update("update money_buy_str  set game_status=$rwin  where batch_id in ( $sql)");
             }
         }
         DB::update("update  comendnotice set  status=1,result=1,done_time='$nowtime',pcount=pcount+1  where  id=$noticeId ");
@@ -197,8 +212,9 @@ class WinfailLogic
             $p_code = $val->p_code;
             $odds_code = $val->odds_code;
             $condition = $val->condition;
+            $is_champion = $val->is_champion;
 
-            $ret = DB::table('money_buy_match')->where(['game_code' => $game_code, 'match_id' => $match_id, 'p_code' => $p_code, 'odds_code' => $odds_code, 'condition' => $condition])->first();
+            $ret = DB::table('money_buy_match')->where(['match_id' => $match_id, 'game_code' => $game_code, 'p_code' => $p_code, 'odds_code' => $odds_code, 'condition' => $condition, 'is_champion' => $is_champion])->first();
             $return[] = $ret;
         }
         return $return;

+ 7 - 1
datainf/logic/HttpServerSettelement.php

@@ -212,6 +212,8 @@ class HttpServerSettelement
         $notice = isset($paras['noticeid']) ? $paras['noticeid'] : 0;
         $id = intval($notice);
 
+        DB::beginTransaction();
+
         try {
             $noticeModel = $logic_obj->getNoticeDate($id);
             $result = $logic_obj->getCompResult($noticeModel->game_code, $noticeModel->match_id);
@@ -241,15 +243,19 @@ class HttpServerSettelement
                 goto ENDLABLE;
             }
 
-            $logic_obj->doLogic($noticeModel, $result);
+            $logic_obj->doLogic($noticeModel, $result, [$gjModel]);
 
             ENDLABLE:
+
+            DB::commit();
             unset($logic_obj, $noticeModel, $AdapterObj, $result, $moneySimples, $matchs_1, $matchs_2, $RefClass);
             $data = Response::generate('', 1, ['cost' => (microtime(true) - $request->server['request_time_float'])], 'succes ');
             echo $data . "\n";
             $response->end($data);
         } catch (\Exception $e) {
+            DB::rollBack();
             unset($logic_obj);
+
             $data = Response::generate('', 10, '', $e->getMessage() . '--' . $e->getFile() . '--' . $e->getLine());
             echo $data . "\n";
             $response->end($data);