|
|
@@ -20,6 +20,7 @@ use App\Models\MoneyBuyStr as MoneyBuyStrModel;
|
|
|
use App\Models\MoneyBuyMatch as MoneyBuyMatchModel;
|
|
|
use App\Models\Money_details as MoneyDetailsModel;
|
|
|
use App\Models\Setinfo as SetinfoModel;
|
|
|
+use App\Models\Account as AccountModel;
|
|
|
|
|
|
|
|
|
//按赛事撤销操作(批量优化版)
|
|
|
@@ -103,13 +104,8 @@ class UnSettmatchLogic
|
|
|
$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;
|
|
|
- $token = isset($datas['token']) ? trim($datas['token']) : '';
|
|
|
|
|
|
- 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) || empty($token)) {
|
|
|
+ if (empty($match_id) || empty($game_code) || empty($order_id) || !in_array($game_code, ['zq', 'lq', 'bq', 'wq'])) {
|
|
|
PARAEORROR:
|
|
|
$msg = date("Y-m-d H:i:s") . " 取消赛事处理--参数错误(参数错或为空了)!";
|
|
|
unset($datas['token']);
|
|
|
@@ -136,54 +132,76 @@ class UnSettmatchLogic
|
|
|
|
|
|
foreach ($order_main->matchdatas as $matitem) {
|
|
|
if ($matitem->order_id == $order_id) {
|
|
|
- $matitem->result = 2;
|
|
|
- $matitem->matchresult = '手动订单取消(平局)';
|
|
|
+ $matitem->result = 0;
|
|
|
+ $matitem->matchresult = '';
|
|
|
$matitem->save();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- $dataArr = [
|
|
|
- 'game_code' => $game_code,
|
|
|
- 'match_id' => $match_id,
|
|
|
- 'settype' => 2,
|
|
|
- 'bettype' => $bet_type,
|
|
|
- 'change_status' => 0,
|
|
|
- 'order_ids' => $order_id,
|
|
|
- 'token' => $token,
|
|
|
- ];
|
|
|
- $url = 'http://127.0.0.1:9094/Settelement';
|
|
|
+ $this->CancelOneOrder($order_main);
|
|
|
+ DB::table('settlement_middle_detail')->where('order_id', $order_id)->update(['money' => 0]);
|
|
|
|
|
|
- $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 {
|
|
|
- sleep(2);
|
|
|
- $order_main->status = 3;
|
|
|
- $order_main->settlement_time = date('Y-m-d H:i:s');
|
|
|
- $order_main->use_mark = '';
|
|
|
- $order_main->game_status = 2;
|
|
|
- $order_main->save();
|
|
|
+ $order_main->status = 2;
|
|
|
+ $order_main->settlement_time = '';
|
|
|
+ $order_main->use_mark = '';
|
|
|
+ $order_main->game_status = 0;
|
|
|
+ $order_main->settle_status = 1;
|
|
|
+ $order_main->gain_money = 0;
|
|
|
+ $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 CancelOneOrder($OrderObj)
|
|
|
+ {
|
|
|
+ //撤单时应该为用户加钱还是扣钱 >0加钱 <0扣钱 ==0不用操作
|
|
|
+ $money = $this->CountDetailsTounSet($OrderObj->order_id);
|
|
|
+ if ($money == 0) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ $Accobj = (new AccountModel())->with('detail')->where('identity', $OrderObj->account_identity)->first();
|
|
|
+
|
|
|
+ $moneyDetail = new MoneyDetailsModel();
|
|
|
+ $moneyDetail->info_identity = UUID();
|
|
|
+ $moneyDetail->trade_id = $OrderObj->order_id;
|
|
|
+ $moneyDetail->account_name = $Accobj->account;
|
|
|
+ $moneyDetail->account_identity = $OrderObj->account_identity;
|
|
|
+ $moneyDetail->money = abs($money);
|
|
|
+ $moneyDetail->money_time = date("Y-m-d H:i:s");
|
|
|
+ $moneyDetail->money_type = $money > 0 ? 1 : 2;
|
|
|
+ $moneyDetail->money_cash = $Accobj->detail->cash + $money;
|
|
|
+ $moneyDetail->trade_type = 11;
|
|
|
+ $moneyDetail->trade_desc = '撤单资金平账处理';
|
|
|
+ $moneyDetail->reason = '撤单资金平账处理';
|
|
|
+ $moneyDetail->status = 1;
|
|
|
+ $moneyDetail->sysetem_user = 'system';
|
|
|
+ $moneyDetail->out_order_id = $OrderObj->order_id;
|
|
|
+ $moneyDetail->remark = '撤单资金平账处理';
|
|
|
+ $ret = $moneyDetail->save();
|
|
|
+
|
|
|
+
|
|
|
+ return $ret;
|
|
|
+ }
|
|
|
+
|
|
|
+ //统计流水表中 所有此订单的 出入总计,用于撤销订单使用
|
|
|
+ public function CountDetailsTounSet($order_id)
|
|
|
+ {
|
|
|
+ $sql = "select sum(money) as msum,money_type from money_details where trade_id='$order_id' group by money_type ";
|
|
|
+ $rets = DB::select($sql);
|
|
|
+ $ret = $rets['0'];
|
|
|
+
|
|
|
+ $uadd = $ret['1'];
|
|
|
+ $ulose = $ret['2'];
|
|
|
+ $return = $ulose - $uadd;
|
|
|
+ return $return;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
//撤销串式订单(整个订单撤销)
|
|
|
public function UnSettelementOneStringOrder($request, $response, $datas)
|
|
|
{
|