vali 6 vuotta sitten
vanhempi
commit
c80db82ac7
1 muutettua tiedostoa jossa 46 lisäystä ja 2 poistoa
  1. 46 2
      app/Lib/Settlement/SettlementWinFail.php

+ 46 - 2
app/Lib/Settlement/SettlementWinFail.php

@@ -96,6 +96,50 @@ class SettlementWinFail
         }
     }
 
+
+    //只处理某个订单下面的某场比赛的输赢结果
+    public function ProcWinInfoByOneOrder($match_id, $order_id, $bet_type = 1)
+    {
+        if ($bet_type == 1) {
+            $buyModel = DB::table('money_buy_simplex')->where(['order_id' => $order_id, 'match_id' => $match_id])->first();
+            if (empty($buyModel)) {
+                throw  new  \Exception('没找到订单记录.' . $match_id . '-' . $order_id . '-' . $bet_type);
+            }
+            $matchModes = DB::table('money_buy_match')->where(['batch_id' => $buyModel->batch_id, 'match_id' => $match_id, 'bet_type' => 1])->get();
+            if (count($matchModes) <= 0) {
+                throw  new  \Exception('无match记录' . $match_id . '-' . $order_id . '-' . $bet_type);
+            }
+        } else {
+            $buyModel = DB::table('money_buy_str')->where(['order_id' => $order_id])->first();
+            if (empty($buyModel)) {
+                throw  new  \Exception('没找到订单记录' . $match_id . '-' . $order_id . '-' . $bet_type);
+            }
+            $matchModes = DB::table('money_buy_match')->where(['batch_id' => $buyModel->batch_id, 'match_id' => $match_id, 'bet_type' => 2])->get();
+            if (count($matchModes) <= 0) {
+                throw  new  \Exception('无match记录' . $match_id . '-' . $order_id . '-' . $bet_type);
+            }
+        }
+
+        $this->gameType = $matchModes['0']->game_code;
+        $this->match_id = $match_id;
+
+        $this->setAdapterObj($this->gameType);
+        $this->RefClass = new  \ReflectionClass($this->AdapterObj);
+        $this->getCompResult($this->gameType, $match_id);
+        if (empty($this->resultModel)) {
+            throw  new  \Exception("没有比赛记录,操作中止!" . $this->gameType . '-' . $match_id);
+        }
+
+        foreach ($matchModes as $sval) {
+            $winorfalse = $this->winOrfalseInfo($sval);
+            $wininfo = $winorfalse['result'];
+            $matchinfo = $winorfalse['matchResult'];
+            $this->makesql_up_buymatch_winorfalse($sval->id, $wininfo, date("Y-m-d H:i:s"), $matchinfo);
+        }
+        return $this->makeData();
+    }
+
+
     //单式订单结算处理
     private function Settlement_simplex($game_type, $match_id)
     {
@@ -130,7 +174,7 @@ class SettlementWinFail
                     $matchinfo = $winorfalse['matchResult'];
                     $this->makesql_up_buymatch_winorfalse($sval->id, $wininfo, date("Y-m-d H:i:s"), $matchinfo);
                     $gs_val = ($wininfo == 1) ? 1 : ($wininfo == -1 ? 2 : 3);
-                    DB::table('money_buy_simplex')->where(['batch_id' => $sval->batch_id, 'game_code' => $sval->game_code])->update(['game_status' => $gs_val]);
+                    DB::table('money_buy_simplex')->where(['batch_id' => $sval->batch_id, 'match_id' => $sval->match_id, 'game_code' => $sval->game_code])->update(['game_status' => $gs_val]);
                 }
             }
         }
@@ -358,7 +402,7 @@ class SettlementWinFail
         $table = 'st_' . $game_code . '_competition';
         $ret = DB::table($table)->where('id', $batch_id)->first();
         if (count($ret) <= 0) {
-            throw new  \Exception('根据比赛ID获取赛事数据有误-'.$game_code.'-'.$batch_id);
+            throw new  \Exception('根据比赛ID获取赛事数据有误-' . $game_code . '-' . $batch_id);
         }
         $this->CompostionDatas[$game_code][$batch_id] = $ret;
         return $ret;