|
|
@@ -100,12 +100,12 @@ class SportsfootController extends Controller {
|
|
|
}
|
|
|
$shuzu = array_values($shuzu);
|
|
|
$warnmore = $shuzu;
|
|
|
- $warnmore[0]['timei'] = 10000;
|
|
|
+ // $warnmore[0]['timei'] = 10000;
|
|
|
}
|
|
|
|
|
|
if($warnmore[0]['timei']!="1970-1-1 0:0:1"){
|
|
|
$request['warnmore'] = $warnmore;
|
|
|
- //$request['warnmore'][0]['rtype'] = $sousuo;
|
|
|
+ // $request['warnmore'][0]['rtype'] = $sousuo;
|
|
|
}else{
|
|
|
$request['warnmore'] = '';
|
|
|
}
|
|
|
@@ -132,6 +132,143 @@ class SportsfootController extends Controller {
|
|
|
|
|
|
//添加编辑危险球
|
|
|
function addwarnonly(Req $req){
|
|
|
+
|
|
|
+
|
|
|
+ //编辑对象值
|
|
|
+ $wid = $req->wid;
|
|
|
+ //赛事id
|
|
|
+ $matchid = $req->match_id;
|
|
|
+ //出现危险球的分钟数
|
|
|
+ $time_i = $req->time_i;
|
|
|
+ //出现危险球的秒数
|
|
|
+ $time_s = $req->time_s;
|
|
|
+ //危险球审核有效时间 秒
|
|
|
+ $timep = $req->time_p;
|
|
|
+ //危险球类型
|
|
|
+ $rtype = $req->warn_type;
|
|
|
+ //验证是否是首次添加危险球
|
|
|
+ $typenum = $req->type_num;
|
|
|
+
|
|
|
+ if(empty($matchid) || empty($time_i) || empty($time_s) || empty($timep) || empty($rtype)) return json_encode(['status'=>2,'msg'=>'设置数据异常']);
|
|
|
+ $model = \App\Models\Stzqresult::where('match_id', $matchid)->select("warn_more","start_time","status")->first()->toArray();
|
|
|
+ if($model['status'] != 2) return json_encode(['status'=>3,'msg'=>'赛事未结束,不能设置危险球']);
|
|
|
+
|
|
|
+ //赛事开赛时间
|
|
|
+ $match_time = $model['start_time'];
|
|
|
+ //危险球出现进行时间 秒
|
|
|
+ $warn_time_s = ($time_i*60)+$time_s;
|
|
|
+ //危险球出现时间 == 开赛时间+进行时间 秒
|
|
|
+ $timei = date('Y-m-d H:i:s',strtotime($match_time)+$warn_time_s);
|
|
|
+
|
|
|
+ //该赛事的单式注单
|
|
|
+ $orders = array();
|
|
|
+ $otherorders = array();
|
|
|
+ $account_identitys = array();
|
|
|
+ $order_ids = array();
|
|
|
+ $order = \App\Models\SportsNoteList::where('match_id',$matchid)->get();
|
|
|
+ if(!empty($order)){
|
|
|
+ for ($c=0; $c < count($order); $c++){
|
|
|
+ if(strtotime($timei) >= strtotime($order[$c]['money_time']) && strtotime($timei)-$timep <= strtotime($order[$c]['money_time'])){
|
|
|
+ $orders[] = $order[$c];
|
|
|
+ $account_identitys[] = $order[$c]['account_identity'];
|
|
|
+ $order_ids[] = $order[$c]['order_id'];
|
|
|
+ }else{
|
|
|
+ $otherorders[] = $order[$c]['id'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //危险球范围外的注单自动审核通过
|
|
|
+ //return $otherorders;
|
|
|
+ if(!empty($otherorders)){
|
|
|
+ \App\Models\SportsNoteList::wherein('id', $otherorders)->update(['roll_ratify' => '1']);
|
|
|
+ }
|
|
|
+
|
|
|
+ //return $account_identitys;
|
|
|
+
|
|
|
+ $sel = json_decode($model['warn_more'],true);
|
|
|
+ $addru = array(
|
|
|
+ array(
|
|
|
+ 'timei'=>$timei,
|
|
|
+ 'timep'=>$timep,
|
|
|
+ 'rtype'=>$rtype,
|
|
|
+ ),
|
|
|
+ );
|
|
|
+
|
|
|
+ if($typenum==10000){
|
|
|
+ if($sel[0]['timei']=="1970-1-1 0:0:1"){
|
|
|
+ //首次添加
|
|
|
+ $res = \App\Models\Stzqresult::where ('match_id', $matchid)->update(['warn_more' => json_encode($addru,JSON_UNESCAPED_UNICODE)]);
|
|
|
+ }else{
|
|
|
+ //再次添加
|
|
|
+ $upnum = array_merge_recursive($sel,$addru);
|
|
|
+ $res = \App\Models\Stzqresult::where ('match_id', $matchid)->update(['warn_more' => json_encode($upnum,JSON_UNESCAPED_UNICODE)]);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ //编辑
|
|
|
+ for ($i=0; $i < count($sel); $i++) {
|
|
|
+ $sel[$wid]['timei'] = $timei;
|
|
|
+ $sel[$wid]['timep'] = $timep;
|
|
|
+ $sel[$wid]['rtype'] = $rtype;
|
|
|
+ }
|
|
|
+ $res = \App\Models\Stzqresult::where ('match_id', $matchid)->update(['warn_more' => json_encode($sel,JSON_UNESCAPED_UNICODE)]);
|
|
|
+ }
|
|
|
+
|
|
|
+ //用戶账户金额
|
|
|
+ $account_money = \App\Models\Account_detailed::wherein('account_identity',$account_identitys)->get();
|
|
|
+ //反水
|
|
|
+ $water_return_money = \App\Models\Money_details::wherein('trade_id',$order_ids)->where('trade_type', '7')->get();
|
|
|
+
|
|
|
+ if(!empty($orders)){
|
|
|
+ for($i=0;$i<count($orders);$i++){
|
|
|
+ for($a=0;$a<count($account_money);$a++){
|
|
|
+ if($orders[$i]['account_identity'] == $account_money[$a]['account_identity']){
|
|
|
+ $available_cash = $account_money[$a]['available_cash'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for($b=0;$b<count($water_return_money);$b++){
|
|
|
+ if($orders[$i]['order_id'] == $water_return_money[$b]['trade_id']){
|
|
|
+ $water_return = $water_return_money[$b]['money'];
|
|
|
+ } else {
|
|
|
+ $water_return = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $new_available_cash = $available_cash + $orders[$i]->money - $orders[$i]->gain_money - $water_return;
|
|
|
+
|
|
|
+ $models = new \App\Models\Money_details();
|
|
|
+ $models->info_identity = UUID();
|
|
|
+ $models->trade_id = $orders[$i]->order_id;
|
|
|
+ $models->account_name = $orders[$i]->account_name;
|
|
|
+ $models->account_identity = $orders[$i]->account_identity;
|
|
|
+ $models->money = abs($orders[$i]->money - $orders[$i]->gain_money - $water_return);
|
|
|
+ $models->money_time = date("Y-m-d H:i:s", time());
|
|
|
+ if ($new_available_cash > $available_cash) {
|
|
|
+ $models->money_type = '1';
|
|
|
+ } else {
|
|
|
+ $models->money_type = '2';
|
|
|
+ }
|
|
|
+ $models->money_cash = $new_available_cash;
|
|
|
+ $models->trade_type = '25';
|
|
|
+ $models->trade_desc = '单式注单审核不通过回款';
|
|
|
+ $models->status = '1';
|
|
|
+ try {
|
|
|
+ DB::beginTransaction();//开启事务
|
|
|
+ \App\Models\SportsNoteList::where('id', $orders[$i]['id'])->update(['roll_ratify' => '-1','status' => '2']);
|
|
|
+ \App\Models\Account_detailed::where('account_identity', $orders[$i]->account_identity)->update(['available_cash' => $new_available_cash, 'cash' => $new_available_cash]);
|
|
|
+ $models->save();
|
|
|
+
|
|
|
+ DB::commit();//提交
|
|
|
+ } catch (Exception $e) {
|
|
|
+ DB::rollback();//回滚
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return responseToJson(1);
|
|
|
+ }
|
|
|
+ //弃用
|
|
|
+ function addwarnonly__(Req $req){
|
|
|
$matchid = $req->matchid;
|
|
|
$wid = $req->wid;//编辑对象值
|
|
|
$timei = $req->timei?$req->timei:"1970-11-1 0:0:1";
|