vali %!s(int64=6) %!d(string=hai) anos
pai
achega
604f0c1566

+ 80 - 1
app/Logic/WinfailLogic.php

@@ -298,9 +298,88 @@ class WinfailLogic
             $matword = $winorfalse['matchResult'];
 
             DB::update('update money_buy_match  set "result"=?,matchresult=? where match_id=? and game_code=? and id=?', [$win, $matword, $match_id, $game_code, $mid]);
-            DB::update("update money_buy_simplex  set game_status=$rwin  where  order_id='$order_id' and   game_code='$game_code' and  match_id='$match_id'  ");
         }
+        DB::update("update money_buy_simplex  set game_status=$rwin  where  order_id='$order_id' and   game_code='$game_code' and  match_id='$match_id'  ");
         return true;
     }
 
+
+    //普通单式或串式订单输赢处理
+    public function WinFailOneOrderNomal($order_id, $bet_type = 1)
+    {
+        if ($bet_type == 1) {
+            $orderInfo = DB::table('money_buy_simplex')->where('order_id', $order_id)->first();
+        } else {
+            $orderInfo = DB::table('money_buy_str')->where('order_id', $order_id)->first();
+        }
+
+        $matchArray = DB::table('money_buy_match')->where('order_id', $order_id)->get();
+        if (empty($orderInfo) || empty($matchArray)) {
+            return 0;
+        }
+
+        if ($bet_type) {
+            $game_code = $orderInfo->game_code;
+            $match_id = $orderInfo->match_id;
+            $table = 'st_' . $game_code . '_result';
+            $result = DB::table($table)->where('match_id', $match_id)->get();
+            if (empty($result)) {
+                return 0;
+            }
+        }
+
+        $game_code = $orderInfo->game_code;
+        $match_id = $orderInfo->match_id;
+        $order_id = $orderInfo->order_id;
+
+        $AdapterObj = $this->getAdapterObj($game_code);
+        $RefClass = new  \ReflectionClass($AdapterObj);
+
+        $winorfalsedef = ['result' => 2, 'matchResult' => 'noRuleOrError'];
+        foreach ($matchArray as $matchModel) {
+            if ($bet_type == 2) {
+                $game_code = $matchModel->game_code;
+                $match_id = $matchModel->match_id;
+                $table = 'st_' . $game_code . '_result';
+                $result = DB::table($table)->where('match_id', $match_id)->get();
+                if (empty($result)) {
+                    continue;
+                }
+            }
+
+            $fun1 = $matchModel->odds_code;
+            $fun2 = $matchModel->p_code;
+
+            $mid = $matchModel->id;
+            try {
+                if ($RefClass->hasMethod($fun1)) {
+                    $winorfalse = $AdapterObj->$fun1($matchModel, $result, []);
+                } elseif ($RefClass->hasMethod($fun2)) {
+                    $winorfalse = $AdapterObj->$fun2($matchModel, $result, []);
+                }
+
+            } catch (\Exception $e) {
+                echo 'excetption: ' . print_r([$order_id, $e->getMessage(), $e->getFile(), $e->getLine()], true) . "\n";
+            }
+
+            if (!isset($winorfalse['result']) || !isset($winorfalse['matchResult']) || !in_array($winorfalse['result'], [-1, 1, 2, 3, 4])) {
+                $winorfalse = $winorfalsedef;
+            }
+
+            $win = intval($winorfalse['result']);
+            $rwin = ($win == 1) ? 1 : ($win == -1 ? 2 : 3);
+            $matword = $winorfalse['matchResult'];
+
+            DB::update('update money_buy_match  set "result"=?,matchresult=? where match_id=? and game_code=? and id=?', [$win, $matword, $match_id, $game_code, $mid]);
+        }
+        if ($bet_type == 1) {
+            DB::update("update money_buy_simplex  set game_status=$rwin  where  order_id='$order_id' and   game_code='$game_code' and  match_id='$match_id'  ");
+        } else {
+            DB::update("update money_buy_str  set game_status=$rwin  where  order_id='$order_id' and   game_code='$game_code' and  match_id='$match_id'  ");
+        }
+
+        return 1;
+    }
+
+
 }

+ 0 - 16
datainf/logic/HttpServerOnlySet.php

@@ -220,27 +220,11 @@ class HttpServerOnlySet
     //重结算时,要先扣掉先前发的钱
     private function UndoSettlement($order_ids, $bettype, $settype, $game_code, $match_id, $change_status, $is_manual)
     {
-        if (empty($this->PDatas['settlement_middle_detail_array'])) {
-            return true;
-        }
 
         $bet_type = $this->GP('bettype');
         $ids = [];
         $userMonsys = [];
 
-        /*
-         $nowArray = $this->PDatas['settlement_middle_detail_array'][$bet_type];
-
-        foreach ($nowArray as $order => $val) {
-            $money = abs(floatval($val->money));
-            if (100 * $money > 1) {
-                //$acc = $val->account_identity;
-                //$userMonsys[$acc] = isset($userMonsys[$acc]) ? $userMonsys[$acc] + $money : $money;
-                //$ids[] = $order;
-            }
-        }
-        */
-
         //先前赢过钱的得先扣回来,写流水,再重新计算,
         $money_time = date("Y-m-d H:i:s");
 

+ 38 - 1
datainf/logic/HttpServerSettelement.php

@@ -93,7 +93,7 @@ class HttpServerSettelement
         $paras = array_merge(['request_time' => date("H:i:s")], !empty($request->get) ? $request->get : [], !empty($request->post) ? $request->post : []);
 
         $request_uri = substr($request->server['request_uri'], 1);
-        $urls = ['WinFail', 'Settelement', 'DoWinFailOneOrder', 'UnSettelement', 'UnsetOneOrder', 'UnsetOneStringOrder'];
+        $urls = ['WinFail', 'Settelement', 'DoWinFailOneOrder', 'WinFaileOneOrderNomal', 'UnSettelement', 'UnsetOneOrder', 'UnsetOneStringOrder'];
 
         $this->httpserver->account->add();
 
@@ -130,16 +130,24 @@ class HttpServerSettelement
             return $this->doWinFailse($request, $response, $paras);
         }
 
+        //手动改结果单式 订单输赢计算 参数order_id
         if ($request_uri == 'DoWinFailOneOrder') {
             $this->dosubcount();
             return $this->WinFailOneOrder($request, $response, $paras);
         }
 
+        //普通订单输赢计算 参数order_id  bet_type[1单式 2串式]
+        if ($request_uri == 'WinFaileOneOrderNomal') {
+            $this->dosubcount();
+            return $this->WinFailOneOrderNomal($request, $response, $paras);
+        }
+
         if ($request_uri == 'Settelement') {
             $this->dosubcount();
             return $this->doSettelementIntoRedis($request, $response, $paras);
         }
 
+
         //撤销某个订事所有的订单
         if ($request_uri == 'UnSettelement') {
             $this->dosubcount();
@@ -175,10 +183,39 @@ class HttpServerSettelement
         return $tokenvel;
     }
 
+
+    //处理一个非手动的单式或串输赢结果
+    private function WinFailOneOrderNomal($request, $response, $paras)
+    {
+        $orderid = isset($paras['order_id']) ? $paras['order_id'] : '';
+        $bet_type = isset($paras['bet_type']) ? $paras['bet_type'] : 1;
+
+        if (empty($orderid)) {
+            $data = Response::generate('', 10, $paras, 'order_id is empty');
+            $response->end($data);
+            return;
+        }
+
+        $logic_obj = new WinfailLogic();
+        try {
+            $ret = $logic_obj->WinFailOneOrderNomal($orderid, $bet_type);
+            $data = Response::generate('', $ret, ['cost' => (microtime(true) - $request->server['request_time_float'])], $ret ? 'succes ' : 'false');
+        } catch (\Exception $e) {
+            $data = Response::generate('', 10, '', $e->getMessage() . '--' . $e->getFile() . '--' . $e->getLine());
+        }
+
+        unset($logic_obj, $match_datas, $orderInfo);
+        $response->end($data);
+        echo $data . "\n";
+
+    }
+
+
     //对单个订单的赛事结果进行过手动更改的订单,单独进行输赢判断处理
     private function WinFailOneOrder($request, $response, $paras)
     {
         $orderid = isset($paras['order_id']) ? $paras['order_id'] : '';
+
         if (empty($orderid)) {
             $data = Response::generate('', 10, $paras, 'order_id is empty');
             $response->end($data);