|
|
@@ -30,6 +30,7 @@ class HttpServerOnlySet
|
|
|
private $PDatas = [];
|
|
|
private $SettlementBaseObj;
|
|
|
private $TaskSqlQueue;
|
|
|
+ private $userMoneyTotal = [];
|
|
|
|
|
|
|
|
|
public function __construct($config)
|
|
|
@@ -110,11 +111,13 @@ class HttpServerOnlySet
|
|
|
private function doSettelement($paras)
|
|
|
{
|
|
|
$begin = microtime(true);
|
|
|
+ $this->userMoneyTotal = [];
|
|
|
|
|
|
try {
|
|
|
list($order_ids, $bettype, $settype, $game_code, $match_id, $change_status) = $this->requestpara($paras);
|
|
|
|
|
|
if (!$this->DataPre($order_ids, $bettype, $settype, $game_code, $match_id, $change_status)) {
|
|
|
+ goto LABDOLAST;
|
|
|
throw new \Exception('没找到订单信息');
|
|
|
}
|
|
|
|
|
|
@@ -154,7 +157,11 @@ class HttpServerOnlySet
|
|
|
$this->ChuanOrder($paras);
|
|
|
}
|
|
|
|
|
|
+ $this->UserTotalMoneySql();
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
+ LABDOLAST:
|
|
|
$this->cgStatus($game_code, $match_id, $change_status);
|
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
@@ -221,16 +228,25 @@ class HttpServerOnlySet
|
|
|
$nowArray = $this->PDatas['settlement_middle_detail_array'][$bet_type];
|
|
|
|
|
|
$ids = [];
|
|
|
+ $userMonsys = [];
|
|
|
foreach ($nowArray as $order => $val) {
|
|
|
$money = abs(floatval($val->money));
|
|
|
if (100 * $money > 1) {
|
|
|
$acc = $val->account_identity;
|
|
|
- $sql = "update account_detailed set cash=cash-$money where identity='$acc' ";
|
|
|
- $this->PushSqlToArray($sql);
|
|
|
+ $userMonsys[$acc] = isset($userMonsys[$acc]) ? $userMonsys[$acc] + $money : $money;
|
|
|
$ids[] = $order;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //一个用户多次变化金额时,合并为一条语名,减少锁表的可能性
|
|
|
+ if (empty($userMonsys)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ foreach ($userMonsys as $account => $money) {
|
|
|
+ $sql = "update account_detailed set cash=cash-$money where identity='$account' ";
|
|
|
+ $this->PushSqlToArray($sql);
|
|
|
+ }
|
|
|
+
|
|
|
if (count($ids) <= 0) {
|
|
|
return true;
|
|
|
}
|
|
|
@@ -242,7 +258,6 @@ class HttpServerOnlySet
|
|
|
$sql = "update settlement_middle_detail set money=0 where order_id in($ids_array) and bet_type=$bet_type ";
|
|
|
$this->PushSqlToArray($sql);
|
|
|
|
|
|
-
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@@ -271,13 +286,13 @@ class HttpServerOnlySet
|
|
|
|
|
|
private function cgStatus($game_code, $match_id, $change_status)
|
|
|
{
|
|
|
+ if (!$change_status) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
$table1 = "st_" . $game_code . "_result";
|
|
|
$table2 = "st_" . $game_code . "_competition";
|
|
|
-
|
|
|
- if ($change_status) {
|
|
|
- $this->PushSqlToArray("update $table1 set status=3 where match_id=$match_id ");
|
|
|
- $this->PushSqlToArray("update $table2 set status=3 where id=$match_id ");
|
|
|
- }
|
|
|
+ $this->PushSqlToArray("update $table1 set status=3 where match_id=$match_id ");
|
|
|
+ $this->PushSqlToArray("update $table2 set status=3 where id=$match_id ");
|
|
|
unset($table1, $table2);
|
|
|
}
|
|
|
|
|
|
@@ -344,7 +359,7 @@ class HttpServerOnlySet
|
|
|
$game_status = $returnMoney > $simplexData->money ? 1 : ($returnMoney == $simplexData->money ? 3 : 2);
|
|
|
// 修改投注表状态及盈亏
|
|
|
$this->PushSqlToArray(["update money_buy_simplex set settle_status=2, game_status=$game_status,gain_money=$returnMoney where order_id='$order_id' "]);
|
|
|
-
|
|
|
+ $this->userMoneyTotal[$account_identity] = isset($this->account_identity[$account_identity]) ? $this->account_identity[$account_identity] + $simplexData->money : $simplexData->money;
|
|
|
$this->WriteOrAddSettlement($game_code, $match_id, $bet_type, $order_id, $account_identity, $returnMoney);
|
|
|
$this->insertData(
|
|
|
$order_id,
|
|
|
@@ -446,6 +461,10 @@ class HttpServerOnlySet
|
|
|
$this->PushSqlToArray(" update money_buy_str set settle_status=2 , game_status=1 , settlementTime='$newTime' , gain_money=$money where order_id = '$order_id'");
|
|
|
|
|
|
$this->WriteOrAddSettlement($this->game_code, $this->match_id, $this->orderType, $order_id, $this->BuyDatasMainModel->account_identity, $money);
|
|
|
+
|
|
|
+ $useraccident = $this->BuyDatasMainModel->account_identity;
|
|
|
+ $this->userMoneyTotal[$useraccident] = isset($this->account_identity[$useraccident]) ? $this->account_identity[$useraccident] + $money : $money;
|
|
|
+
|
|
|
$this->insertData($order_id, $money, $this->BuyDatasMainModel->account_identity, 2, $val->game_code, $this->BuyDatasMainModel->info_identity, $this->BuyDatasMainModel->money, $this->match_id, $account, $money_prize);
|
|
|
|
|
|
return true;
|
|
|
@@ -476,8 +495,8 @@ class HttpServerOnlySet
|
|
|
|
|
|
$this->PushSqlToArray($sql);
|
|
|
|
|
|
- // 修改用余额
|
|
|
- $this->PushSqlToArray("update account_detailed set available_cash=available_cash+$money,cash=cash+$money where account_identity='$account_identity' ");
|
|
|
+ // 修改用余额 在外面合并了,不需要了
|
|
|
+ //$this->PushSqlToArray("update account_detailed set available_cash=available_cash+$money,cash=cash+$money where account_identity='$account_identity' ");
|
|
|
|
|
|
// 新增用户中奖信息
|
|
|
$content = $type == 1 ? '您的单式投注订单' . $order_id . '于' . $money_time . '成功回款' . $returnMoney . '该次投注流程结束,如有疑问请联系客服'
|
|
|
@@ -498,6 +517,16 @@ class HttpServerOnlySet
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ //对同一用户账号资金变化更改合并操作,减少锁表可能
|
|
|
+ private function UserTotalMoneySql()
|
|
|
+ {
|
|
|
+ if (!empty($this->userMoneyTotal)) {
|
|
|
+ foreach ($this->userMoneyTotal as $account_identity => $money) {
|
|
|
+ $this->PushSqlToArray("update account_detailed set available_cash=available_cash+$money,cash=cash+$money where account_identity='$account_identity' ");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
//数据预批量获取
|
|
|
private function DataPre($order_ids, $bettype, $settype, $game_code, $match_id, $change_status)
|