|
|
@@ -155,6 +155,77 @@ class UnSettmatchLogic
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ //把一个串式订单 由撤单状态改为 下单状态 (扣钱,写流水,改订单状态)
|
|
|
+ public function RestartStringOneOrder($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 (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']);
|
|
|
+ $this->backandret($response, 0, $msg, $datas);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ $OrderObj = $order_main = $this->getStrOrders($game_code, $match_id, $order_id);
|
|
|
+
|
|
|
+ if (empty($order_main) || empty($order_main->matchdatas)) {
|
|
|
+ goto PARAEORROR;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
+ $order_money = $order_main->money;
|
|
|
+ $fanshuimodel = DB::table('setinfo')->where('identity', '1000')->first();
|
|
|
+ $fanshui = floatval(trim($fanshuimodel->infocontent));
|
|
|
+ $money = $order_money * (1 - $fanshui);
|
|
|
+
|
|
|
+ $Accobj = (new AccountModel())->with('detail')->where('identity', $order_main->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 = 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();
|
|
|
+
|
|
|
+ $nowmoney = $Accobj->detail->cash - $money;
|
|
|
+ DB::update('account_detail')->where('account_identity', $OrderObj->account_identity)->update(['money_cash' => $nowmoney, 'cash' => $nowmoney]);
|
|
|
+
|
|
|
+ $order_main->status = 1;
|
|
|
+ $order_main->settlement_time = date('Y-m-d H:i:s');
|
|
|
+ $order_main->use_mark = '';
|
|
|
+ $order_main->game_status = 0;
|
|
|
+ $order_main->settle_status = 1;
|
|
|
+ $order_main->gain_money = 0;
|
|
|
+ $order_main->save();
|
|
|
+
|
|
|
+ $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)
|
|
|
{
|
|
|
@@ -184,6 +255,8 @@ class UnSettmatchLogic
|
|
|
$moneyDetail->remark = '撤单资金平账处理';
|
|
|
$ret = $moneyDetail->save();
|
|
|
|
|
|
+ $nowmoney = $Accobj->detail->cash + $money;
|
|
|
+ DB::update('account_detail')->where('account_identity', $OrderObj->account_identity)->update(['money_cash' => $nowmoney, 'cash' => $nowmoney]);
|
|
|
|
|
|
return $ret;
|
|
|
}
|
|
|
@@ -194,12 +267,12 @@ class UnSettmatchLogic
|
|
|
$sql = "select sum(money) as msum,money_type from money_details where trade_id='$order_id' group by money_type ";
|
|
|
$rets = DB::select($sql);
|
|
|
|
|
|
- $ulose = $uadd = 0 ;
|
|
|
- foreach ($rets as $val){
|
|
|
- if ($val->money_type==1){
|
|
|
+ $ulose = $uadd = 0;
|
|
|
+ foreach ($rets as $val) {
|
|
|
+ if ($val->money_type == 1) {
|
|
|
$uadd = $val->msum;
|
|
|
}
|
|
|
- if ($val->money_type==2){
|
|
|
+ if ($val->money_type == 2) {
|
|
|
$ulose = $val->msum;
|
|
|
}
|
|
|
}
|