vali 6 years ago
parent
commit
a194fbaa3e
2 changed files with 113 additions and 4 deletions
  1. 96 3
      app/Logic/UnSettmatchLogic.php
  2. 17 1
      datainf/logic/HttpServerSettelement.php

+ 96 - 3
app/Logic/UnSettmatchLogic.php

@@ -127,7 +127,7 @@ class UnSettmatchLogic
             return;
         }
 
-        if ($order_main->status == 2) {
+        if ($order_main->status != 1) {
             $msg = date("Y-m-d H:i:s") . " 已撤销过的订单(不用处理)!--end:game_code= $game_code  match_id= $match_id order_id=$order_id ";
             $this->backandret($response, 1, '撤销成功!' . $msg, []);
             return;
@@ -135,7 +135,7 @@ class UnSettmatchLogic
 
         foreach ($order_main->matchdatas as $matitem) {
             if ($matitem->order_id == $order_id) {
-                $matitem->result = 2;
+                $matitem->result = 3;
                 $matitem->matchresult = '手动订单取消(平局)';
                 $matitem->save();
             }
@@ -161,7 +161,7 @@ class UnSettmatchLogic
                 goto ERRORCURL;
             } else {
 
-                $order_main->status = 2;
+                $order_main->status = 3;
                 $order_main->settlement_time = date('Y-m-d H:i:s');
                 $order_main->use_mark = '';
                 $order_main->save();
@@ -182,6 +182,83 @@ class UnSettmatchLogic
 
     }
 
+    //撤销串式订单(整个订单撤销)
+    public function UnSettelementOneStringOrder($request, $response, $datas)
+    {
+        $order_id = isset($datas['order_id']) ? trim($datas['order_id']) : 0;
+        $token = isset($datas['token']) ? trim($datas['token']) : '';
+
+        if (empty($order_id) || empty($token)) {
+            SECPARAEORROR:
+            $msg = date("Y-m-d H:i:s") . " 取消赛事处理--参数错误(参数错或为空了)!";
+            unset($datas['token']);
+            $this->backandret($response, 0, $msg, $datas);
+            return false;
+        }
+
+        $order_main = $this->getByOrderString($order_id);
+        if (empty($order_main)) {
+            $msg = date("Y-m-d H:i:s") . " 撤销整个串式要单失败,数据为空.order_id= $order_id ";
+            $this->backandret($response, 0, '撤销失败!' . $msg, []);
+            return;
+        }
+
+        if ($order_main->status == 2 || $order_main->status == 3) {
+            $msg = date("Y-m-d H:i:s") . " 已撤销过的订单(不用处理)!--end:order_id=$order_id ";
+            $this->backandret($response, 1, '撤销成功!' . $msg, []);
+            return;
+        }
+
+        foreach ($order_main->matchdatas as $matitem) {
+            if ($matitem->order_id == $order_id) {
+                $matitem->result = 3;
+                $matitem->matchresult = '手动订单取消(平局)';
+                $matitem->save();
+            }
+        }
+
+        $game_code = $order_main->matchdatas['0']->game_code;
+        $match_id = $order_main->matchdatas['0']->match_id;
+        $dataArr = [
+            'game_code' => $game_code,
+            'match_id' => $match_id,
+            'settype' => 2,
+            'bettype' => 2,
+            'change_status' => 0,
+            'order_ids' => $order_id,
+            'token' => $token,
+        ];
+        $url = 'http://127.0.0.1:9094/Settelement';
+
+        $ret_str = post_curls($url, $dataArr);
+        if (empty($ret_str)) {
+            goto ERRORCURL;
+        } else {
+            $ret = json_decode($ret_str, true);
+            if (empty($ret) || !isset($ret['status']) || $ret['status'] != 1) {
+                goto ERRORCURL;
+            } else {
+
+                $order_main->status = 3;
+                $order_main->settlement_time = date('Y-m-d H:i:s');
+                $order_main->use_mark = '';
+                $order_main->save();
+
+                goto SUCCESSCUL;
+            }
+        }
+
+        ERRORCURL:
+        $msg = date("Y-m-d H:i:s") . " 串式订单取消处理--end:game_code= $game_code  match_id= $match_id .$ret_str  ";
+        $this->backandret($response, 0, '撤销失败!' . $msg, []);
+        return;
+
+        SUCCESSCUL:
+        $msg = date("Y-m-d H:i:s") . " 串式订单取消--end:game_code= $game_code  match_id= $match_id order_id=$order_id ";
+        $this->backandret($response, 1, '撤销成功!' . $msg, []);
+        return;
+    }
+
 
     //返回消息和写日志
     public function backandret($response, $code, $msg, $data, $onlylog = 0)
@@ -374,6 +451,7 @@ class UnSettmatchLogic
         return $rets;
     }
 
+
     //得到 有此赛事的串式订单
     public function getStrOrders($game_code, $match_id, $order_id = 0)
     {
@@ -397,6 +475,21 @@ class UnSettmatchLogic
         return $rets;
     }
 
+    //按订单查询(串式)
+    public function getByOrderString($order_id)
+    {
+        $ret = [];
+        $model2 = new MoneyBuyMatchModel();
+        $rets2 = $model2->getByAttrs([['order_ID', '=', $order_id]]);
+        if (empty($rets2)) {
+            return $ret;
+        }
+        $model = new MoneyBuyStrModel();
+        $rets = $model->with('matchdatas')->where('order_id', $order_id)->first();
+        return $rets;
+    }
+
+
     //获取相关的订单费用及系统赚送的钱(用于返还)
     public function getMoneyDetail($ordesArray)
     {

+ 17 - 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'];
+        $urls = ['WinFail', 'Settelement', 'DoWinFailOneOrder', 'UnSettelement', 'UnsetOneOrder', 'UnsetOneStringOrder'];
 
         $this->httpserver->account->add();
 
@@ -140,16 +140,26 @@ class HttpServerSettelement
             return $this->doSettelementIntoRedis($request, $response, $paras);
         }
 
+        //撤销某个订事所有的订单
         if ($request_uri == 'UnSettelement') {
             $this->dosubcount();
             return $this->UnSettelement($request, $response, $paras);
         }
 
+
+        //撤销某个赛事相关的订单
         if ($request_uri == 'UnsetOneOrder') {
             $this->dosubcount();
             return $this->UnSettelementOneOrder($request, $response, $paras);
         }
 
+        //撤销某个串式的订单
+        if ($request_uri == 'UnsetOneStringOrder') {
+            $this->dosubcount();
+            return $this->UnSettelementOneStringOrder($request, $response, $paras);
+        }
+
+
         return;
     }
 
@@ -300,6 +310,12 @@ class HttpServerSettelement
         UnSettmatchLogic::getInstance()->doUnsetMatchOneOrder($request, $response, $paras);
     }
 
+    //撤销某个串式订单(整个订单)
+    private function UnSettelementOneStringOrder($request, $response, $paras)
+    {
+        UnSettmatchLogic::getInstance()->UnSettelementOneStringOrder($request, $response, $paras);
+    }
+
     private function doSettelementIntoRedis($request, $response, $paras)
     {
         try {