vali преди 6 години
родител
ревизия
38017e5c48
променени са 1 файла, в които са добавени 41 реда и са изтрити 17 реда
  1. 41 17
      datainf/logic/HttpServerOnlySet.php

+ 41 - 17
datainf/logic/HttpServerOnlySet.php

@@ -118,12 +118,10 @@ class HttpServerOnlySet
             list($order_ids, $bettype, $settype, $game_code, $match_id, $change_status, $is_manual) = $this->requestpara($paras);
 
             if (!$this->DataPre($order_ids, $bettype, $settype, $game_code, $match_id, $change_status, $is_manual)) {
-                $this->cgStatus($game_code, $match_id, $change_status);
                 goto LABDOLAST;
-                //throw new  \Exception('没找到订单信息', 110);
             }
 
-            $this->UndoSettlement();
+            $this->UndoSettlement($order_ids, $bettype, $settype, $game_code, $match_id, $change_status, $is_manual);
 
             while (true) {
                 $order_id = trim(array_shift($order_ids));
@@ -154,18 +152,14 @@ class HttpServerOnlySet
 
                 if ($bettype == 1) {
                     $this->singOrder($paras);
-                    $this->cgStatus($game_code, $match_id, $change_status);
                 } else {
                     $this->ChuanOrder($paras);
-                    $this->cgStatus($game_code, $match_id, $change_status);
                 }
-
                 $this->UserTotalMoneySql();
-
             }
 
             LABDOLAST:
-            //$this->cgStatus($game_code, $match_id, $change_status);
+            $this->cgStatus($game_code, $match_id, $change_status);
 
         } catch (\Exception $e) {
             $this->PDatas = [];
@@ -224,7 +218,7 @@ class HttpServerOnlySet
 
 
     //重结算时,要先扣掉先前发的钱
-    private function UndoSettlement()
+    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;
@@ -244,10 +238,36 @@ class HttpServerOnlySet
             }
         }
 
+        //先前赢过钱的得先扣回来,写流水,再重新计算,
+        $money_time = date("Y-m-d H:i:s");
+        foreach ($nowArray as $tmp_orderid) {
+            $now_order = $this->PDatas['Money_buy_Orders_Array'][$tmp_orderid];
+            if ($now_order->gain_money * 100 > 0 && $now_order->game_status != 2) {
+                $order_id = $now_order->order_id;
+                $account_identity = $now_order->account_identity;
+                $account = $this->PDatas['account_map_array'][$account_identity]->account;
+                $returnMoney = $now_order->gain_money;
+                $info_identity = uuid();
+
+                $trade_desc = '重结算[撤销之前]';
+                $reason = '重结算[撤销之前]';
+                $money_type = 2;
+
+                $user_money_cash = $this->PDatas['account_indentity_map_array'][$account_identity]->cash - $now_order->gain_money;
+                $this->PDatas['account_indentity_map_array'][$account_identity]->cash = $user_money_cash;
+
+                $sql = "insert into money_details(info_identity,trade_id,account_name,account_identity,money,money_time,money_type,money_cash,trade_type,trade_desc,reason,sysetem_user,status)  values(";
+                $sql .= "'$info_identity','$order_id','$account','$account_identity',$returnMoney,'$money_time',$money_type,$user_money_cash,11,'$trade_desc','$reason','系统',1)";
+
+                $this->PushSqlToArray($sql);
+            }
+        }
+
         //一个用户多次变化金额时,合并为一条语名,减少锁表的可能性
         if (empty($userMonsys)) {
             return true;
         }
+
         foreach ($userMonsys as $account => $money) {
             $sql = "update account_detailed  set  cash=cash-$money where identity='$account' ";
             $this->PushSqlToArray($sql);
@@ -264,6 +284,10 @@ class HttpServerOnlySet
         $sql = "update settlement_middle_detail  set  money=0 where order_id in($ids_array) and bet_type=$bet_type ";
         $this->PushSqlToArray($sql);
 
+        $table = ($bettype == 1) ? 'money_buy_simplex' : 'money_buy_str';
+        $sql = "update $table  set  gain_money=0 where order_id in($ids_array) ";
+        $this->PushSqlToArray($sql);
+
         return true;
     }
 
@@ -356,6 +380,12 @@ class HttpServerOnlySet
         if ($simplexData->status == 1) {
             foreach ($matchDatas as $k => $v) {
                 if ($v->result == -1) {
+
+                    if (isset($this->PDatas['money_detail_array'][$order_id])) {
+                        $sql = "update  money_details  set money=0   where account_identity='$account_identity' and trade_id='$order_id' and trade_type=4 ";
+                        $this->PushSqlToArray([$sql]);
+                    }
+
                     continue;
                 }
                 $oddsResult[0]['winOrLose'] = $v->result;
@@ -519,13 +549,8 @@ class HttpServerOnlySet
 
         $this->PDatas['account_mash'][$account_identity] = $this->PDatas['account_mash'][$account_identity] + $returnMoney;
         $user_money_cash = $this->PDatas['account_mash'][$account_identity];
-
-        if (isset($this->PDatas['money_detail_array'][$order_id])) {
-            $sql = "update  money_details  set money=$returnMoney,money_cash=$user_money_cash  where account_identity='$account_identity' and trade_id='$order_id' and trade_type=4 ";
-        } else {
-            $sql = "insert into money_details(info_identity,trade_id,account_name,account_identity,money,money_time,money_type,money_cash,trade_type,trade_desc,reason,sysetem_user,status)  values(";
-            $sql .= "'$info_identity','$order_id','$account','$account_identity',$returnMoney,'$money_time',1,$user_money_cash,4,'$trade_desc','$reason','系统',1)";
-        }
+        $sql = "insert into money_details(info_identity,trade_id,account_name,account_identity,money,money_time,money_type,money_cash,trade_type,trade_desc,reason,sysetem_user,status)  values(";
+        $sql .= "'$info_identity','$order_id','$account','$account_identity',$returnMoney,'$money_time',1,$user_money_cash,4,'$trade_desc','$reason','系统',1)";
 
         $this->PushSqlToArray($sql);
 
@@ -630,7 +655,6 @@ class HttpServerOnlySet
                 $sql_tmp = "update $moneytable set  settle_status=1, gain_money=0  where order_id in ($order_str)  ";
             }
             $this->PushSqlToArray($sql_tmp);
-
         }
 
         $ret = DB::table('money_prize')->whereIn('order_id', $order_ids)->where('money', '>', 0.01)->get();