|
|
@@ -41,7 +41,7 @@ class UnSettmatchLogic
|
|
|
goto PARAEORROR;
|
|
|
}
|
|
|
$result = $this->getResult($game_code, $match_id);
|
|
|
- if (empty($match_id) || empty($game_code) || empty($result) || !in_array($game_code, ['zq', 'lq', 'bq', 'wq'])) {
|
|
|
+ if (empty($match_id) || empty($game_code) || empty($result)) {
|
|
|
PARAEORROR:
|
|
|
$msg = date("Y-m-d H:i:s") . " 取消赛事处理--参数错误!\n";
|
|
|
unset($datas['token']);
|
|
|
@@ -96,6 +96,81 @@ class UnSettmatchLogic
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ //撤销单个订单
|
|
|
+ public function doUnsetMatchOneOrder($request, $response, $datas)
|
|
|
+ {
|
|
|
+ $match_id = isset($datas['match_id']) ? intval($datas['match_id']) : 0;
|
|
|
+ $game_code = isset($datas['game_code']) ? trim($datas['game_code']) : '';
|
|
|
+ $order_id = isset($datas['order_id']) ? trim($datas['order_id']) : 0;
|
|
|
+ if (!in_array($game_code, ['zq', 'lq', 'bq', 'wq'])) {
|
|
|
+ goto PARAEORROR;
|
|
|
+ }
|
|
|
+ $result = $this->getResult($game_code, $match_id);
|
|
|
+ if (empty($match_id) || empty($game_code) || empty($result) || empty($order_id)) {
|
|
|
+ PARAEORROR:
|
|
|
+ $msg = date("Y-m-d H:i:s") . " 取消赛事处理--参数错误(参数错或为空了)!\n";
|
|
|
+ unset($datas['token']);
|
|
|
+ $this->backandret($response, 0, $msg, $datas);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ $bet_type = 1;
|
|
|
+ $order_main = $this->getSimpleOrders($game_code, $match_id, $order_id);
|
|
|
+ if (empty($order_main)) {
|
|
|
+ $order_main = $this->getStrOrders($game_code, $match_id, $order_id);
|
|
|
+ $bet_type = 2;
|
|
|
+ }
|
|
|
+ if (empty($order_main) || empty($order_main->matchdatas)) {
|
|
|
+ goto PARAEORROR;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach ($order_main->matchdatas as $matitem) {
|
|
|
+ if ($matitem->order_id == $order_id) {
|
|
|
+ $matitem->result = 2;
|
|
|
+ $matitem->matchresult = '手动订单取消(平局)';
|
|
|
+ $matitem->save();
|
|
|
+ }
|
|
|
+ $order_main->status = 3;
|
|
|
+ $order_main->settlement_time = date('Y-m-d H:i:s');
|
|
|
+ $order_main->save();
|
|
|
+ }
|
|
|
+
|
|
|
+ $dataArr = [
|
|
|
+ 'game_code' => $game_code,
|
|
|
+ 'match_id' => $match_id,
|
|
|
+ 'settype' => 2,
|
|
|
+ 'bettype' => $bet_type,
|
|
|
+ 'change_status' => 0,
|
|
|
+ 'order_ids' => $order_id,
|
|
|
+ ];
|
|
|
+ $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 {
|
|
|
+ goto SUCCESSCUL;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ERRORCURL:
|
|
|
+ $msg = date("Y-m-d H:i:s") . " 取消赛事处理--end:game_code= $game_code match_id= $match_id .$ret_str \n";
|
|
|
+ $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\n";
|
|
|
+ $this->backandret($response, 1, '撤销成功!' . $msg, []);
|
|
|
+ return;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
//返回消息和写日志
|
|
|
public function backandret($response, $code, $msg, $data, $onlylog = 0)
|
|
|
{
|
|
|
@@ -168,6 +243,7 @@ class UnSettmatchLogic
|
|
|
|
|
|
$mModel->save();
|
|
|
$item->status = 3;
|
|
|
+ $item->settlement_time = date('Y-m-d H:i:s');
|
|
|
$item->save();
|
|
|
}
|
|
|
|
|
|
@@ -196,6 +272,7 @@ class UnSettmatchLogic
|
|
|
//这里只把结果改为平局,再提交到旧的重新结算订单接口处理
|
|
|
foreach ($strOrders as $item2) {
|
|
|
$item2->status = 2;
|
|
|
+ $item2->settlement_time = date('Y-m-d H:i:s');
|
|
|
$item2->save();
|
|
|
|
|
|
$mats = $item2->matchdatas;
|
|
|
@@ -204,7 +281,6 @@ class UnSettmatchLogic
|
|
|
$item3->matchresult = '赛事撤销!';
|
|
|
$item3->save();
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
$dataArr = [
|
|
|
@@ -248,10 +324,14 @@ class UnSettmatchLogic
|
|
|
return $ret;
|
|
|
}
|
|
|
|
|
|
- public function changeMatchResult($game_code, $match_id)
|
|
|
+ public function changeMatchResult($game_code, $match_id, $order_id = 0)
|
|
|
{
|
|
|
$table = 'money_buy_match';
|
|
|
- $ret = DB::table($table)->where('match_id', $match_id)->where('game_code', $game_code)->update(['result' => 2, 'matchresult' => '撤单平局!']);
|
|
|
+ if (empty($order_id)) {
|
|
|
+ $ret = DB::table($table)->where('match_id', $match_id)->where('game_code', $game_code)->update(['result' => 2, 'matchresult' => '撤单平局!']);
|
|
|
+ } else {
|
|
|
+ $ret = DB::table($table)->where([['match_id', '=', $match_id], ['game_code', '=', $game_code], ['order_id', '=', $order_id]])->update(['result' => 2, 'matchresult' => '撤单平局.']);
|
|
|
+ }
|
|
|
return $ret;
|
|
|
}
|
|
|
|
|
|
@@ -265,29 +345,38 @@ class UnSettmatchLogic
|
|
|
}
|
|
|
|
|
|
//得到 有此赛事的单式订单
|
|
|
- public function getSimpleOrders($game_code, $match_id)
|
|
|
+ public function getSimpleOrders($game_code, $match_id, $order_id = 0)
|
|
|
{
|
|
|
$model = new MoneyBuySimplexModel();
|
|
|
- $rets = $model->with('matchdatas')->where(['game_code' => $game_code, 'match_id' => $match_id])->get();
|
|
|
+ if (empty($order_id)) {
|
|
|
+ $rets = $model->with('matchdatas')->where(['game_code' => $game_code, 'match_id' => $match_id])->get();
|
|
|
+ } else {
|
|
|
+ $rets = $model->with('matchdatas')->where(['game_code' => $game_code, 'match_id' => $match_id, 'order_id' => $order_id])->first();
|
|
|
+ }
|
|
|
+
|
|
|
return $rets;
|
|
|
}
|
|
|
|
|
|
//得到 有此赛事的串式订单
|
|
|
- public function getStrOrders($game_code, $match_id)
|
|
|
+ public function getStrOrders($game_code, $match_id, $order_id = 0)
|
|
|
{
|
|
|
$model = new MoneyBuyStrModel();
|
|
|
- $model2 = new MoneyBuyMatchModel();
|
|
|
- $rets2 = $model2->getByAttrs([['match_id', '=', $match_id], ['bet_type', '=', 2], ['game_code', '=', $game_code]]);
|
|
|
- $orders = [];
|
|
|
- if ($rets2) {
|
|
|
- foreach ($rets2 as $item) {
|
|
|
- $orders[] = $item->order_id;
|
|
|
+ if (empty($order_id)) {
|
|
|
+ $model2 = new MoneyBuyMatchModel();
|
|
|
+ $rets2 = $model2->getByAttrs([['match_id', '=', $match_id], ['bet_type', '=', 2], ['game_code', '=', $game_code]]);
|
|
|
+ $orders = [];
|
|
|
+ if ($rets2) {
|
|
|
+ foreach ($rets2 as $item) {
|
|
|
+ $orders[] = $item->order_id;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return [];
|
|
|
}
|
|
|
- } else {
|
|
|
- return [];
|
|
|
+ $rets = $model->with('matchdatas')->whereIn('order_id', $orders)->get();
|
|
|
+ return $rets;
|
|
|
}
|
|
|
|
|
|
- $rets = $model->with('matchdatas')->whereIn('order_id', $orders)->get();
|
|
|
+ $rets = $model->with('matchdatas')->where('order_id', $order_id)->find();
|
|
|
return $rets;
|
|
|
}
|
|
|
|