|
|
@@ -9,8 +9,10 @@
|
|
|
namespace App\Models;
|
|
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
+use App\Lib\Biz\Sport\Common as commonFunction;
|
|
|
use App\Models\MoneyBuyMatch;
|
|
|
use App\Http\Response\Response;
|
|
|
+use App\Http\Model\StZqResult;
|
|
|
|
|
|
class SportsNoteList extends BaseModel
|
|
|
{
|
|
|
@@ -31,7 +33,7 @@ class SportsNoteList extends BaseModel
|
|
|
//->join('money_buy_match','money_buy_match.order_id','=','money_buy_simplex.order_id')
|
|
|
->join('st_' . $type . '_league', 'money_buy_simplex.lg_id', '=', 'st_' . $type . '_league.id')
|
|
|
->select('money_buy_simplex.id', 'money_buy_simplex.account_name', 'money_buy_simplex.is_champion', 'money_buy_simplex.account_identity', 'money_buy_simplex.order_id', 'money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.status', 'money_buy_simplex.money_time', 'money_buy_simplex.settle_status', 'money_buy_simplex.gain_money', 'money_buy_simplex.game_code', 'money_buy_simplex.match_id', 'money_buy_simplex.game_status', 'st_' . $type . '_competition.home_team', 'st_' . $type . '_competition.guest_team', 'st_' . $type . '_competition.match_date', 'st_' . $type . '_competition.match_time', 'st_' . $type . '_competition.lg_id', 'st_' . $type . '_competition.status as match_status', 'money_details.money_cash', 'money_buy_simplex.batch_id', 'st_' . $type . '_league.name_chinese', 'st_' . $type . '_league.last_time')
|
|
|
- ->whereIn('money_buy_simplex.roll_ratify',array(0,1))
|
|
|
+ ->whereIn('money_buy_simplex.roll_ratify', array(0, 1))
|
|
|
->where($where)
|
|
|
//->distinct('money_buy_match.order_id')
|
|
|
->orderby('money_buy_simplex.money_time', 'desc')
|
|
|
@@ -74,10 +76,9 @@ class SportsNoteList extends BaseModel
|
|
|
|
|
|
|
|
|
for ($i = 0; $i < count($data); $i++) {
|
|
|
- if($data[$i]->status==1 && $data[$i]->settle_status == 1){
|
|
|
- $data[$i]->order_status = '投注'.'<br><a class="layui-btn layui-btn-sm invalid" lay-event="detail" pid="id" uri="/admin/SoccerNoteList/invalid/?id=" href="javascript:invalid(\'/admin/SoccerNoteList/invalid/?id=' . $data[$i]->id . '\',\''.$data[$i]->order_id.'\',\''.$data[$i]->name_chinese.'\');"> 作废 </a>';
|
|
|
- }
|
|
|
- else if ($data[$i]->status == 1 && $data[$i]->settle_status != 1) {
|
|
|
+ if ($data[$i]->status == 1 && $data[$i]->settle_status == 1) {
|
|
|
+ $data[$i]->order_status = '投注' . '<br><a class="layui-btn layui-btn-sm invalid" lay-event="detail" pid="id" uri="/admin/SoccerNoteList/invalid/?id=" href="javascript:invalid(\'/admin/SoccerNoteList/invalid/?id=' . $data[$i]->id . '\',\'' . $data[$i]->order_id . '\',\'' . $data[$i]->name_chinese . '\');"> 作废 </a>';
|
|
|
+ } else if ($data[$i]->status == 1 && $data[$i]->settle_status != 1) {
|
|
|
$data[$i]->order_status = '投注';
|
|
|
} else if ($data[$i]->status == 2) {
|
|
|
$data[$i]->order_status = '作废';//.'<br><a class="layui-btn layui-btn-sm audit" lay-event="detail" pid="id" uri="" href="javascript:void(0)" style="background-color: grey;"> 已作废 </a>';
|
|
|
@@ -86,7 +87,7 @@ class SportsNoteList extends BaseModel
|
|
|
}
|
|
|
if ($data[$i]->settle_status == 1) {
|
|
|
$data[$i]->settle_status = '未结算';
|
|
|
- } else{
|
|
|
+ } else {
|
|
|
$data[$i]->settle_status = '已结算';
|
|
|
}
|
|
|
if ($data[$i]->game_status == 0) {
|
|
|
@@ -291,15 +292,15 @@ class SportsNoteList extends BaseModel
|
|
|
$data['all_money'] = 0;
|
|
|
$data['all_prize_money'] = 0;
|
|
|
$data['alraedy_prize_money'] = 0;
|
|
|
- $all_money = $this->join('money_details', 'money_details.info_identity', '=', 'money_buy_simplex.info_identity')->join('st_' . $type . '_competition', 'st_' . $type . '_competition.id', '=', 'money_buy_simplex.match_id')->join('st_' . $type . '_league', 'st_' . $type . '_competition.lg_id', '=', 'st_' . $type . '_league.id')->select('money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.gain_money')->whereIn('money_buy_simplex.roll_ratify',array(0,1))->where('money_buy_simplex.status', '1')->get();
|
|
|
+ $all_money = $this->join('money_details', 'money_details.info_identity', '=', 'money_buy_simplex.info_identity')->join('st_' . $type . '_competition', 'st_' . $type . '_competition.id', '=', 'money_buy_simplex.match_id')->join('st_' . $type . '_league', 'st_' . $type . '_competition.lg_id', '=', 'st_' . $type . '_league.id')->select('money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.gain_money')->whereIn('money_buy_simplex.roll_ratify', array(0, 1))->where('money_buy_simplex.status', '1')->get();
|
|
|
for ($a = 0; $a < count($all_money); $a++) {
|
|
|
$data['all_money'] = $data['all_money'] + $all_money[$a]->money;
|
|
|
}
|
|
|
- $all_prize_money = $this->join('money_details', 'money_details.info_identity', '=', 'money_buy_simplex.info_identity')->join('st_' . $type . '_competition', 'st_' . $type . '_competition.id', '=', 'money_buy_simplex.match_id')->join('st_' . $type . '_league', 'st_' . $type . '_competition.lg_id', '=', 'st_' . $type . '_league.id')->select('money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.gain_money')->whereIn('money_buy_simplex.roll_ratify',array(0,1))->where('money_buy_simplex.status', '1')->get();
|
|
|
+ $all_prize_money = $this->join('money_details', 'money_details.info_identity', '=', 'money_buy_simplex.info_identity')->join('st_' . $type . '_competition', 'st_' . $type . '_competition.id', '=', 'money_buy_simplex.match_id')->join('st_' . $type . '_league', 'st_' . $type . '_competition.lg_id', '=', 'st_' . $type . '_league.id')->select('money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.gain_money')->whereIn('money_buy_simplex.roll_ratify', array(0, 1))->where('money_buy_simplex.status', '1')->get();
|
|
|
for ($a = 0; $a < count($all_prize_money); $a++) {
|
|
|
$data['all_prize_money'] = $data['all_money'] + $all_prize_money[$a]->prize_money;
|
|
|
}
|
|
|
- $alraedy_prize_money = $this->join('money_details', 'money_details.info_identity', '=', 'money_buy_simplex.info_identity')->join('st_' . $type . '_competition', 'st_' . $type . '_competition.id', '=', 'money_buy_simplex.match_id')->join('st_' . $type . '_league', 'st_' . $type . '_competition.lg_id', '=', 'st_' . $type . '_league.id')->select('money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.gain_money')->where('money_buy_simplex.settle_status', '2')->whereIn('money_buy_simplex.roll_ratify',array(0,1))->where('money_buy_simplex.status', '1')->get();
|
|
|
+ $alraedy_prize_money = $this->join('money_details', 'money_details.info_identity', '=', 'money_buy_simplex.info_identity')->join('st_' . $type . '_competition', 'st_' . $type . '_competition.id', '=', 'money_buy_simplex.match_id')->join('st_' . $type . '_league', 'st_' . $type . '_competition.lg_id', '=', 'st_' . $type . '_league.id')->select('money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.gain_money')->where('money_buy_simplex.settle_status', '2')->whereIn('money_buy_simplex.roll_ratify', array(0, 1))->where('money_buy_simplex.status', '1')->get();
|
|
|
for ($a = 0; $a < count($alraedy_prize_money); $a++) {
|
|
|
$data['alraedy_prize_money'] = $data['all_money'] + $alraedy_prize_money[$a]->gain_money;
|
|
|
}
|
|
|
@@ -311,15 +312,15 @@ class SportsNoteList extends BaseModel
|
|
|
//$data['all_money'] = $this->where($where)->sum('money');
|
|
|
// $data['all_prize_money'] = $this->where($where)->sum('prize_money');
|
|
|
// $data['alraedy_prize_money'] = $this->where($where)->where('settle_status','2')->sum('gain_money');
|
|
|
- $all_money = $this->join('money_details', 'money_details.info_identity', '=', 'money_buy_simplex.info_identity')->join('st_zq_competition', 'st_zq_competition.id', '=', 'money_buy_simplex.match_id')->join('st_zq_league', 'st_zq_competition.lg_id', '=', 'st_zq_league.id')->select('money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.gain_money')->whereIn('money_buy_simplex.roll_ratify',array(0,1))->where($where)->where('money_buy_simplex.status', '1')->get();
|
|
|
+ $all_money = $this->join('money_details', 'money_details.info_identity', '=', 'money_buy_simplex.info_identity')->join('st_zq_competition', 'st_zq_competition.id', '=', 'money_buy_simplex.match_id')->join('st_zq_league', 'st_zq_competition.lg_id', '=', 'st_zq_league.id')->select('money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.gain_money')->whereIn('money_buy_simplex.roll_ratify', array(0, 1))->where($where)->where('money_buy_simplex.status', '1')->get();
|
|
|
for ($a = 0; $a < count($all_money); $a++) {
|
|
|
$data['all_money'] = $data['all_money'] + $all_money[$a]->money;
|
|
|
}
|
|
|
- $all_prize_money = $this->join('money_details', 'money_details.info_identity', '=', 'money_buy_simplex.info_identity')->join('st_' . $type . '_competition', 'st_' . $type . '_competition.id', '=', 'money_buy_simplex.match_id')->join('st_' . $type . '_league', 'st_' . $type . '_competition.lg_id', '=', 'st_' . $type . '_league.id')->select('money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.gain_money')->whereIn('money_buy_simplex.roll_ratify',array(0,1))->where($where)->where('money_buy_simplex.status', '1')->get();
|
|
|
+ $all_prize_money = $this->join('money_details', 'money_details.info_identity', '=', 'money_buy_simplex.info_identity')->join('st_' . $type . '_competition', 'st_' . $type . '_competition.id', '=', 'money_buy_simplex.match_id')->join('st_' . $type . '_league', 'st_' . $type . '_competition.lg_id', '=', 'st_' . $type . '_league.id')->select('money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.gain_money')->whereIn('money_buy_simplex.roll_ratify', array(0, 1))->where($where)->where('money_buy_simplex.status', '1')->get();
|
|
|
for ($a = 0; $a < count($all_prize_money); $a++) {
|
|
|
$data['all_prize_money'] = $data['all_prize_money'] + $all_prize_money[$a]->prize_money;
|
|
|
}
|
|
|
- $alraedy_prize_money = $this->join('money_details', 'money_details.info_identity', '=', 'money_buy_simplex.info_identity')->join('st_' . $type . '_competition', 'st_' . $type . '_competition.id', '=', 'money_buy_simplex.match_id')->join('st_' . $type . '_league', 'st_' . $type . '_competition.lg_id', '=', 'st_' . $type . '_league.id')->select('money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.gain_money')->whereIn('money_buy_simplex.roll_ratify',array(0,1))->where('money_buy_simplex.settle_status', '2')->where($where)->where('money_buy_simplex.status', '1')->get();
|
|
|
+ $alraedy_prize_money = $this->join('money_details', 'money_details.info_identity', '=', 'money_buy_simplex.info_identity')->join('st_' . $type . '_competition', 'st_' . $type . '_competition.id', '=', 'money_buy_simplex.match_id')->join('st_' . $type . '_league', 'st_' . $type . '_competition.lg_id', '=', 'st_' . $type . '_league.id')->select('money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.gain_money')->whereIn('money_buy_simplex.roll_ratify', array(0, 1))->where('money_buy_simplex.settle_status', '2')->where($where)->where('money_buy_simplex.status', '1')->get();
|
|
|
for ($a = 0; $a < count($alraedy_prize_money); $a++) {
|
|
|
$data['alraedy_prize_money'] = $data['alraedy_prize_money'] + $alraedy_prize_money[$a]->gain_money;
|
|
|
}
|
|
|
@@ -360,7 +361,7 @@ class SportsNoteList extends BaseModel
|
|
|
// ->join('st_'.$type.'_league','st_'.$type.'_competition.lg_id','=','st_'.$type.'_league.id')
|
|
|
->join('st_' . $type . '_league', 'money_buy_simplex.lg_id', '=', 'st_' . $type . '_league.id')
|
|
|
->select('money_buy_simplex.id', 'money_buy_simplex.account_name', 'money_buy_simplex.is_champion', 'money_buy_simplex.account_identity', 'money_buy_simplex.order_id', 'money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.status', 'money_buy_simplex.money_time', 'money_buy_simplex.settle_status', 'money_buy_simplex.gain_money', 'money_buy_simplex.game_code', 'money_buy_simplex.match_id', 'money_buy_simplex.game_status', 'st_' . $type . '_competition.home_team', 'st_' . $type . '_competition.guest_team', 'st_' . $type . '_competition.match_date', 'st_' . $type . '_competition.match_time', 'st_' . $type . '_competition.lg_id', 'st_' . $type . '_competition.status as match_status', 'money_details.money_cash', 'money_buy_simplex.batch_id', 'st_' . $type . '_league.name_chinese', 'st_' . $type . '_league.last_time')
|
|
|
- ->whereIn('money_buy_simplex.roll_ratify',array(0,1))
|
|
|
+ ->whereIn('money_buy_simplex.roll_ratify', array(0, 1))
|
|
|
->where($where)
|
|
|
->orderby('money_buy_simplex.money_time', 'desc')
|
|
|
->paginate($list);
|
|
|
@@ -404,7 +405,7 @@ class SportsNoteList extends BaseModel
|
|
|
|
|
|
for ($i = 0; $i < count($data); $i++) {
|
|
|
if ($data[$i]->status == 1 && $data[$i]->settle_status == 1) {
|
|
|
- $data[$i]->order_status = '投注' . '<br><a class="layui-btn layui-btn-sm invalid" lay-event="detail" pid="id" uri="/admin/SoccerNoteList/invalid/?id=" href="javascript:invalid(\'/admin/SoccerNoteList/invalid/?id=' . $data[$i]->id . '\',\''.$data[$i]->order_id.'\',\''.$data[$i]->name_chinese.'\');"> 作废 </a>';
|
|
|
+ $data[$i]->order_status = '投注' . '<br><a class="layui-btn layui-btn-sm invalid" lay-event="detail" pid="id" uri="/admin/SoccerNoteList/invalid/?id=" href="javascript:invalid(\'/admin/SoccerNoteList/invalid/?id=' . $data[$i]->id . '\',\'' . $data[$i]->order_id . '\',\'' . $data[$i]->name_chinese . '\');"> 作废 </a>';
|
|
|
} else if ($data[$i]->status == 1 && $data[$i]->settle_status != 1) {
|
|
|
$data[$i]->order_status = '投注';
|
|
|
} else if ($data[$i]->status == 2) {
|
|
|
@@ -619,7 +620,7 @@ class SportsNoteList extends BaseModel
|
|
|
//->join('money_buy_match','money_buy_match.order_id','=','money_buy_simplex.order_id')
|
|
|
->join('st_' . $type . '_league', 'money_buy_simplex.lg_id', '=', 'st_' . $type . '_league.id')
|
|
|
->select('money_buy_simplex.id', 'money_buy_simplex.account_name', 'money_buy_simplex.is_champion', 'money_buy_simplex.account_identity', 'money_buy_simplex.order_id', 'money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.status', 'money_buy_simplex.money_time', 'money_buy_simplex.settle_status', 'money_buy_simplex.gain_money', 'money_buy_simplex.game_code', 'money_buy_simplex.match_id', 'money_buy_simplex.game_status', 'money_buy_simplex.roll_ratify', 'st_' . $type . '_competition.home_team', 'st_' . $type . '_competition.guest_team', 'st_' . $type . '_competition.match_date', 'st_' . $type . '_competition.match_time', 'st_' . $type . '_competition.lg_id', 'st_' . $type . '_competition.status as match_status', 'money_details.money_cash', 'money_buy_simplex.batch_id', 'st_' . $type . '_league.name_chinese', 'st_' . $type . '_league.last_time')
|
|
|
- ->whereIn('money_buy_simplex.roll_ratify',array(-1,2))
|
|
|
+ ->whereIn('money_buy_simplex.roll_ratify', array(-1, 2))
|
|
|
->where($where)
|
|
|
//->distinct('money_buy_match.order_id')
|
|
|
->orderby('money_buy_simplex.money_time', 'desc')
|
|
|
@@ -662,9 +663,9 @@ class SportsNoteList extends BaseModel
|
|
|
|
|
|
|
|
|
for ($i = 0; $i < count($data); $i++) {
|
|
|
- if($data[$i]->status==1 && $data[$i]->settle_status == 1){
|
|
|
- $data[$i]->order_status = '投注'.'<br><a class="layui-btn layui-btn-sm invalid" lay-event="detail" pid="id" uri="/admin/SoccerNoteList/invalid/?id=" href="javascript:invalid(\'/admin/SoccerNoteList/invalid/?id=' . $data[$i]->id . '\',\''.$data[$i]->order_id.'\',\''.$data[$i]->name_chinese.'\');"> 作废 </a>';
|
|
|
- }
|
|
|
+ if ($data[$i]->status == 1 && $data[$i]->settle_status == 1) {
|
|
|
+ $data[$i]->order_status = '投注' . '<br><a class="layui-btn layui-btn-sm invalid" lay-event="detail" pid="id" uri="/admin/SoccerNoteList/invalid/?id=" href="javascript:invalid(\'/admin/SoccerNoteList/invalid/?id=' . $data[$i]->id . '\',\'' . $data[$i]->order_id . '\',\'' . $data[$i]->name_chinese . '\');"> 作废 </a>';
|
|
|
+ }
|
|
|
if ($data[$i]->status == 1 && $data[$i]->settle_status != 1) {
|
|
|
$data[$i]->order_status = '投注';
|
|
|
} else if ($data[$i]->status == 2) {
|
|
|
@@ -877,31 +878,32 @@ class SportsNoteList extends BaseModel
|
|
|
}
|
|
|
|
|
|
//作废赛事下注单处理
|
|
|
- function delorder($matchid,$type){
|
|
|
+ function delorder($matchid, $type)
|
|
|
+ {
|
|
|
//该赛事的单式注单
|
|
|
$account_identitys = array();
|
|
|
$order_ids = array();
|
|
|
- $orders = $this->where('match_id',$matchid)->get();
|
|
|
- if(!empty($orders)){
|
|
|
- for ($c=0; $c < count($orders); $c++){
|
|
|
+ $orders = $this->where('match_id', $matchid)->get();
|
|
|
+ if (!empty($orders)) {
|
|
|
+ for ($c = 0; $c < count($orders); $c++) {
|
|
|
$account_identitys[] = $orders[$c]['account_identitys'];
|
|
|
$order_ids[] = $orders[$c]['order_id'];
|
|
|
}
|
|
|
//用戶账户金额
|
|
|
- $account_money = \App\Models\Account_detailed::wherein('account_identity',$account_identitys)->get();
|
|
|
+ $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();
|
|
|
- for($i=0;$i<count($orders);$i++){
|
|
|
+ $water_return_money = \App\Models\Money_details::wherein('trade_id', $order_ids)->where('trade_type', '7')->get();
|
|
|
+ for ($i = 0; $i < count($orders); $i++) {
|
|
|
//用户余额 默认
|
|
|
$available_cash = '';
|
|
|
- for($a=0;$a<count($account_money);$a++){
|
|
|
- if($orders[$i]['account_identity'] == $account_money[$a]['account_identity']){
|
|
|
+ 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'];
|
|
|
}
|
|
|
}
|
|
|
$water_return = '';
|
|
|
- for($b=0;$b<count($water_return_money);$b++){
|
|
|
- if($orders[$i]['order_id'] == $water_return_money[$b]['trade_id']){
|
|
|
+ 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;
|
|
|
@@ -941,30 +943,113 @@ class SportsNoteList extends BaseModel
|
|
|
}
|
|
|
|
|
|
//该赛事相关的的串关注单做平局处理
|
|
|
- \App\Models\MoneyBuyMatch::where('match_id',$matchid)->where('game_code',$type)->where('bet_type',2)->update(['result'=>2]);
|
|
|
+ \App\Models\MoneyBuyMatch::where('match_id', $matchid)->where('game_code', $type)->where('bet_type', 2)->update(['result' => 2]);
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 滚球投注 获取指定时间内未审核订单
|
|
|
+ */
|
|
|
+ public static function getOrderData($time = 60)
|
|
|
+ {
|
|
|
+
|
|
|
+ $db = new \App\Models\Setinfo();
|
|
|
+ //获取设定需审核时间 秒
|
|
|
+ $handle_time = $db->getInfo(1003)['infocontent'] ?: 90;
|
|
|
+
|
|
|
+ //获取需查询 时间条件 时间戳
|
|
|
+ //时间区间 开始时间
|
|
|
+ $time_unx_s = time() - $time - $handle_time;//-150 秒
|
|
|
+ //时间区间 截止时间
|
|
|
+ $time_unx_e = time() - $handle_time;//-90 秒
|
|
|
+
|
|
|
+ //拼接查询条件
|
|
|
+ $where = [
|
|
|
+ ['money_time', '>', date('Y-m-d H:i:s', $time_unx_s)],
|
|
|
+ ['money_time', '<', date('Y-m-d H:i:s', $time_unx_e)],
|
|
|
+ ['roll_ratify', '=', 2]
|
|
|
+ ];
|
|
|
+ //获取 待处理订单数据
|
|
|
+ $order_data = self::where($where)->SELECT('id', 'match_id', 'account_name', 'account_identity', 'order_id', 'money_time', 'roll_ratify', 'money', 'gain_money')->get()->toArray();
|
|
|
+ if (!empty($order_data)) {
|
|
|
+
|
|
|
+ //获取订单所属赛事id
|
|
|
+ $match_ids = [];
|
|
|
+ foreach ($order_data as $k => $v) {
|
|
|
+ $match_ids[] = $v['match_id'];
|
|
|
+ }
|
|
|
+
|
|
|
+ //去重 获取赛事危险球数据
|
|
|
+ $warn_json_data = StZqResult::whereIn('match_id', $match_ids)->SELECT('match_id', 'warn_more')->get()->toArray();
|
|
|
+
|
|
|
+ //获取审核不通过订单 订单号
|
|
|
+ $order_ids_n = [];
|
|
|
+ //获取审核不通过订单
|
|
|
+ $order_data_n = [];
|
|
|
+ //获取审核通过订单 订单号
|
|
|
+ $order_ids_y = [];
|
|
|
+ //获取审核未通过订单 投注人
|
|
|
+ $account_identitys = [];
|
|
|
+ foreach ($order_data as $k => $v) {
|
|
|
+ //获取每个订单的危险球数据
|
|
|
+ $warn_data = commonFunction::filter_by_value($warn_json_data, 'match_id', $v['match_id']);
|
|
|
+ $warn_data_arr = json_decode($warn_data['warn_more'], true);
|
|
|
+ //投注时间 时间戳
|
|
|
+ $order_time = strtotime($v['money_time']);
|
|
|
+ foreach ($warn_data_arr as $kk => $vv) {
|
|
|
+ //危险球时间 时间戳
|
|
|
+ $warn_time = strtotime($vv['timei']);
|
|
|
+ if ($order_time < $warn_time and ($order_time + $handle_time) > $warn_time) {
|
|
|
+ $order_ids_n[] = $v['order_id'];
|
|
|
+ $account_identitys[] = $v['account_identity'];
|
|
|
+ $order_data_n[] = $v;
|
|
|
+ unset($order_data[$k]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!empty($order_data)) {
|
|
|
+ foreach ($order_data as $k => $v) {
|
|
|
+ $order_ids_y[] = $v['order_id'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!empty($order_ids_n)) {
|
|
|
+ //在审核时间内订单 审核不通过
|
|
|
+ self::HandleMoney_v2($account_identitys, $order_ids_n, $order_data_n);
|
|
|
+ }
|
|
|
+ if (!empty($order_ids_y)) {
|
|
|
+ //在审核时间外订单 审核通过
|
|
|
+ $ret_y = self::whereIn('order_id', $order_ids_y)->update(['roll_ratify' => 1, 'use_mark' => '滚球投注自动审核(危险球)通过']);
|
|
|
+ //如果更新数量小于订单数量 则返回异常
|
|
|
+ if ($ret_y < count($order_ids_y)) throw new \Exception(Response::generate('', Response::HANDLE_ORDER_Y_ERR));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 滚球投注 危险球自动审核
|
|
|
* $match_id int 赛事id
|
|
|
* $warn_data arr 危险球数据
|
|
|
*/
|
|
|
- public static function WarnHandle($match_id=0,$warn_data=[]){
|
|
|
+ public static function WarnHandle($match_id = 0, $warn_data = [])
|
|
|
+ {
|
|
|
|
|
|
- if(!empty($match_id) and !empty($warn_data)){
|
|
|
+ if (!empty($match_id) and !empty($warn_data)) {
|
|
|
$db = new \App\Models\Setinfo();
|
|
|
//获取设定需审核时间 秒
|
|
|
- $handle_time = $db->getInfo(1003)['infocontent']?:90;
|
|
|
+ $handle_time = $db->getInfo(1003)['infocontent'] ?: 90;
|
|
|
//获取赛事下 待审核 滚球投注
|
|
|
$where = [
|
|
|
- ['match_id','=',$match_id],
|
|
|
- ['roll_ratify','=',2]
|
|
|
+ ['match_id', '=', $match_id],
|
|
|
+ ['roll_ratify', '=', 2]
|
|
|
];
|
|
|
- $order_data = self::where($where)->SELECT('id','account_name','account_identity','order_id','money_time','roll_ratify','money','gain_money')->get()->toArray();
|
|
|
- if(!empty($order_data)){
|
|
|
+ $order_data = self::where($where)->SELECT('id', 'account_name', 'account_identity', 'order_id', 'money_time', 'roll_ratify', 'money', 'gain_money')->get()->toArray();
|
|
|
+ if (!empty($order_data)) {
|
|
|
//获取审核不通过订单 订单号
|
|
|
$order_ids_n = [];
|
|
|
//获取审核不通过订单
|
|
|
@@ -973,13 +1058,13 @@ class SportsNoteList extends BaseModel
|
|
|
$order_ids_y = [];
|
|
|
//获取审核未通过订单 投注人
|
|
|
$account_identitys = [];
|
|
|
- foreach($order_data as $k=>$v){
|
|
|
+ foreach ($order_data as $k => $v) {
|
|
|
//投注时间 时间戳
|
|
|
$order_time = strtotime($v['money_time']);
|
|
|
- foreach($warn_data as $kk=>$vv){
|
|
|
+ foreach ($warn_data as $kk => $vv) {
|
|
|
//危险球时间 时间戳
|
|
|
$warn_time = strtotime($vv['find_time']);
|
|
|
- if($order_time < $warn_time and ($order_time+$handle_time) > $warn_time){
|
|
|
+ if ($order_time < $warn_time and ($order_time + $handle_time) > $warn_time) {
|
|
|
$order_ids_n[] = $v['order_id'];
|
|
|
$account_identitys[] = $v['account_identity'];
|
|
|
$order_data_n[] = $v;
|
|
|
@@ -988,138 +1073,140 @@ class SportsNoteList extends BaseModel
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(!empty($order_data)){
|
|
|
- foreach($order_data as $k=>$v){
|
|
|
+ if (!empty($order_data)) {
|
|
|
+ foreach ($order_data as $k => $v) {
|
|
|
$order_ids_y[] = $v['order_id'];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(!empty($order_ids_n)){
|
|
|
+ if (!empty($order_ids_n)) {
|
|
|
//在审核时间内订单 审核不通过
|
|
|
- self::HandleMoney_v2($account_identitys,$order_ids_n,$order_data_n);
|
|
|
+ self::HandleMoney_v2($account_identitys, $order_ids_n, $order_data_n);
|
|
|
}
|
|
|
- if(!empty($order_ids_y)){
|
|
|
+ if (!empty($order_ids_y)) {
|
|
|
//在审核时间外订单 审核通过
|
|
|
- $ret_y = self::whereIn('order_id', $order_ids_y)->update(['roll_ratify' => 1,'use_mark'=>'滚球投注自动审核(危险球)通过']);
|
|
|
+ $ret_y = self::whereIn('order_id', $order_ids_y)->update(['roll_ratify' => 1, 'use_mark' => '滚球投注自动审核(危险球)通过']);
|
|
|
//如果更新数量小于订单数量 则返回异常
|
|
|
- if($ret_y < count($order_ids_y)) throw new \Exception( Response::generate('',Response::HANDLE_ORDER_Y_ERR));
|
|
|
+ if ($ret_y < count($order_ids_y)) throw new \Exception(Response::generate('', Response::HANDLE_ORDER_Y_ERR));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 滚球自动审核 账户资金处理
|
|
|
- * v1
|
|
|
+ * v1
|
|
|
* 当用户下同时只有一个订单退款时 可用
|
|
|
- *
|
|
|
+ *
|
|
|
*/
|
|
|
- public static function HandleMoney($account_identitys=[],$order_ids=[],$orders=[]){
|
|
|
- //用戶账户金额
|
|
|
- $account_money = \App\Models\Account_detailed::whereIn('account_identity',$account_identitys)->SELECT('account_identity','available_cash')->get()->toArray();
|
|
|
- //反水
|
|
|
- $water_return_money = \App\Models\Money_details::whereIn('trade_id',$order_ids)->where('trade_type', '7')->SELECT('trade_id','money')->get()->toArray();
|
|
|
-
|
|
|
- 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;
|
|
|
- }
|
|
|
+ public static function HandleMoney($account_identitys = [], $order_ids = [], $orders = [])
|
|
|
+ {
|
|
|
+ //用戶账户金额
|
|
|
+ $account_money = \App\Models\Account_detailed::whereIn('account_identity', $account_identitys)->SELECT('account_identity', 'available_cash')->get()->toArray();
|
|
|
+ //反水
|
|
|
+ $water_return_money = \App\Models\Money_details::whereIn('trade_id', $order_ids)->where('trade_type', '7')->SELECT('trade_id', 'money')->get()->toArray();
|
|
|
+
|
|
|
+ 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;
|
|
|
+ }
|
|
|
}
|
|
|
//需退回金额 = 投注金额-反水金额
|
|
|
$money = abs($orders[$i]['money'] - $water_return);
|
|
|
//用户剩余金额
|
|
|
- $new_available_cash = $available_cash + $money;
|
|
|
-
|
|
|
- $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 = $money;
|
|
|
- $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 = '滚球投注自动审核(危险球)不通过,退回投注资金:¥'.$money.';订单号:'.$orders[$i]['order_id'].'';
|
|
|
+ $new_available_cash = $available_cash + $money;
|
|
|
+
|
|
|
+ $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 = $money;
|
|
|
+ $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 = '滚球投注自动审核(危险球)不通过,退回投注资金:¥' . $money . ';订单号:' . $orders[$i]['order_id'] . '';
|
|
|
$models->status = '1';
|
|
|
-
|
|
|
+
|
|
|
//更新订单数据
|
|
|
- $ret_order = self::where('id', $orders[$i]['id'])->update(['roll_ratify' => '-1','status' => '2','use_mark'=>'滚球投注自动审核(危险球)不通过']);
|
|
|
- if($ret_order < 1) throw new \Exception( Response::generate('',Response::UP_ORDER_ERR));
|
|
|
+ $ret_order = self::where('id', $orders[$i]['id'])->update(['roll_ratify' => '-1', 'status' => '2', 'use_mark' => '滚球投注自动审核(危险球)不通过']);
|
|
|
+ if ($ret_order < 1) throw new \Exception(Response::generate('', Response::UP_ORDER_ERR));
|
|
|
|
|
|
//更新用户数据
|
|
|
$ret_user = \App\Models\Account_detailed::where('account_identity', $orders[$i]['account_identity'])->update(['available_cash' => $new_available_cash, 'cash' => $new_available_cash]);
|
|
|
- if($ret_user < 1) throw new \Exception( Response::generate('',Response::UP_USER_ERR));
|
|
|
+ if ($ret_user < 1) throw new \Exception(Response::generate('', Response::UP_USER_ERR));
|
|
|
|
|
|
//更新用户资金数据
|
|
|
- if(!$models->save()) throw new \Exception( Response::generate('',Response::UP_MONEY_ERR));
|
|
|
-
|
|
|
- }
|
|
|
+ if (!$models->save()) throw new \Exception(Response::generate('', Response::UP_MONEY_ERR));
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 滚球自动审核 账户资金处理
|
|
|
- * v2
|
|
|
+ * v2
|
|
|
* 处理一个用户下 多个注单退款时的 余额计算
|
|
|
*/
|
|
|
- public static function HandleMoney_v2($account_identitys=[],$order_ids=[],$orders=[]){
|
|
|
-
|
|
|
+ public static function HandleMoney_v2($account_identitys = [], $order_ids = [], $orders = [])
|
|
|
+ {
|
|
|
+
|
|
|
//获取 用户 初始余额
|
|
|
- $account_money = \App\Models\Account_detailed::whereIn('account_identity',$account_identitys)->SELECT('account_identity','available_cash')->get()->toArray();
|
|
|
+ $account_money = \App\Models\Account_detailed::whereIn('account_identity', $account_identitys)->SELECT('account_identity', 'available_cash')->get()->toArray();
|
|
|
//获取 指定注单 反水金额
|
|
|
- $water_return_money = \App\Models\Money_details::whereIn('trade_id',$order_ids)->where('trade_type', '7')->SELECT('trade_id','money')->get()->toArray();
|
|
|
+ $water_return_money = \App\Models\Money_details::whereIn('trade_id', $order_ids)->where('trade_type', '7')->SELECT('trade_id', 'money')->get()->toArray();
|
|
|
|
|
|
- if(!empty($account_money) and !empty($orders) and !empty($water_return_money)){
|
|
|
+ if (!empty($account_money) and !empty($orders) and !empty($water_return_money)) {
|
|
|
//拼接每个注单 反水
|
|
|
- foreach($orders as $k=>$v){
|
|
|
- $v['fanshui'] = self::getFanshui($v['order_id'],$water_return_money);
|
|
|
+ foreach ($orders as $k => $v) {
|
|
|
+ $v['fanshui'] = self::getFanshui($v['order_id'], $water_return_money);
|
|
|
$orders[$k] = $v;
|
|
|
|
|
|
}
|
|
|
|
|
|
- foreach($account_money as $k=>$v){
|
|
|
+ foreach ($account_money as $k => $v) {
|
|
|
//默认 余额 0
|
|
|
$account_identity = 0;
|
|
|
- foreach($orders as $kk=>$vv){
|
|
|
+ foreach ($orders as $kk => $vv) {
|
|
|
//计算当前余额
|
|
|
- if($v['account_identity'] == $vv['account_identity']){
|
|
|
+ if ($v['account_identity'] == $vv['account_identity']) {
|
|
|
//第一个注单 获取用户初始余额
|
|
|
- if($account_identity == 0){
|
|
|
+ if ($account_identity == 0) {
|
|
|
//当前注单余额
|
|
|
$vv['available_cash'] = $v['available_cash'];
|
|
|
//当前注单退款后的余额
|
|
|
- $account_identity = $v['available_cash']+$vv['money']-$vv['fanshui'];
|
|
|
- }else{//其他 获取 上个注单处理后的余额
|
|
|
+ $account_identity = $v['available_cash'] + $vv['money'] - $vv['fanshui'];
|
|
|
+ } else {//其他 获取 上个注单处理后的余额
|
|
|
$vv['available_cash'] = $account_identity;
|
|
|
- $account_identity = $account_identity+$vv['money']-$vv['fanshui'];
|
|
|
+ $account_identity = $account_identity + $vv['money'] - $vv['fanshui'];
|
|
|
}
|
|
|
$orders[$kk] = $vv;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- foreach($orders as $k=>$v){
|
|
|
- //需退回金额 = 投注金额-反水金额
|
|
|
+ foreach ($orders as $k => $v) {
|
|
|
+ //需退回金额 = 投注金额-反水金额
|
|
|
$money = abs($v['money'] - $v['fanshui']);
|
|
|
- //用户剩余金额
|
|
|
+ //用户剩余金额
|
|
|
$new_available_cash = $v['available_cash'] + $money;
|
|
|
$models = new \App\Models\Money_details();
|
|
|
$models->info_identity = UUID();
|
|
|
@@ -1129,35 +1216,36 @@ class SportsNoteList extends BaseModel
|
|
|
$models->money = $money;
|
|
|
$models->money_time = date("Y-m-d H:i:s", time());
|
|
|
$models->money_type = '1';
|
|
|
-
|
|
|
+
|
|
|
$models->money_cash = $new_available_cash;
|
|
|
$models->trade_type = '25';
|
|
|
- $models->trade_desc = '滚球投注自动审核(危险球)不通过,退回投注资金:¥'.$money.';订单号:'.$v['order_id'].'';
|
|
|
+ $models->trade_desc = '滚球投注自动审核(危险球)不通过,退回投注资金:¥' . $money . ';订单号:' . $v['order_id'] . '';
|
|
|
$models->status = '1';
|
|
|
-
|
|
|
+
|
|
|
//更新订单数据
|
|
|
- $ret_order = self::where('id', $v['id'])->update(['roll_ratify' => '-1','status' => '2','use_mark'=>'滚球投注自动审核(危险球)不通过']);
|
|
|
- if($ret_order < 1) throw new \Exception( Response::generate('',Response::UP_ORDER_ERR));
|
|
|
+ $ret_order = self::where('id', $v['id'])->update(['roll_ratify' => '-1', 'status' => '2', 'use_mark' => '滚球投注自动审核(危险球)不通过']);
|
|
|
+ if ($ret_order < 1) throw new \Exception(Response::generate('', Response::UP_ORDER_ERR));
|
|
|
|
|
|
//更新用户数据
|
|
|
$ret_user = \App\Models\Account_detailed::where('account_identity', $v['account_identity'])->update(['available_cash' => $new_available_cash, 'cash' => $new_available_cash]);
|
|
|
- if($ret_user < 1) throw new \Exception( Response::generate('',Response::UP_USER_ERR));
|
|
|
+ if ($ret_user < 1) throw new \Exception(Response::generate('', Response::UP_USER_ERR));
|
|
|
|
|
|
//更新用户资金数据
|
|
|
- if(!$models->save()) throw new \Exception( Response::generate('',Response::UP_MONEY_ERR));
|
|
|
+ if (!$models->save()) throw new \Exception(Response::generate('', Response::UP_MONEY_ERR));
|
|
|
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取注单 反水金额
|
|
|
- * $order_id 订单id str
|
|
|
- * $fanshuiData 反水数据 arr
|
|
|
- */
|
|
|
- public static function getFanshui($order_id='',$fanshuiData=[]){
|
|
|
- foreach($fanshuiData as $k=>$v){
|
|
|
- if($v['trade_id'] == $order_id){
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取注单 反水金额
|
|
|
+ * $order_id 订单id str
|
|
|
+ * $fanshuiData 反水数据 arr
|
|
|
+ */
|
|
|
+ public static function getFanshui($order_id = '', $fanshuiData = [])
|
|
|
+ {
|
|
|
+ foreach ($fanshuiData as $k => $v) {
|
|
|
+ if ($v['trade_id'] == $order_id) {
|
|
|
$fanshui = $v['money'];
|
|
|
}
|
|
|
}
|