diff --git a/Application/Admin/Controller/CompanyStatementController.class.php b/Application/Admin/Controller/CompanyStatementController.class.php index 4a42f8c3c..48a3e1825 100644 --- a/Application/Admin/Controller/CompanyStatementController.class.php +++ b/Application/Admin/Controller/CompanyStatementController.class.php @@ -1159,23 +1159,12 @@ class CompanyStatementController extends ThinkController // ||$value['statement_begin_time']<=$start_time && $value['statement_end_time'] >= $end_time) // { - $statementInfo = json_decode($value['statement_info'],true);; - if ($value['company_type'] == 2) { - - foreach ($statementInfo as $sk => $sv) { - $statementInfos = $sv['game_list']; - foreach ($statementInfos as $k => $v) { - if (strtotime(str_replace('.','-',$v['statement_end_time'])) >= $start_time && strtotime(str_replace('.','-',$v['statement_end_time']))<=$end_time - ||strtotime(str_replace('.','-',$v['statement_begin_time']))>=$start_time && strtotime(str_replace('.','-',$v['statement_begin_time']))<=$end_time - ||strtotime(str_replace('.','-',$v['statement_begin_time']))<=$start_time && strtotime(str_replace('.','-',$v['statement_end_time'])) >= $end_time) { - if (in_array($v['relation_game_id'], $relation_game_data)) { - $this->ajaxReturn(['status' => 0, 'data' => [], 'msg' => "《{$v['game_name']}》在日期:{$_REQUEST['time_start']}-{$_REQUEST['time_end']}有结算过的部分,请重新选择"]); - } - } - } - } - } else { - foreach ($statementInfo as $k => $v) { + $statementInfo = json_decode($value['statement_info'],true);; + if ($value['company_type'] == 2) { + + foreach ($statementInfo as $sk => $sv) { + $statementInfos = $sv['game_list']; + foreach ($statementInfos as $k => $v) { if (strtotime(str_replace('.','-',$v['statement_end_time'])) >= $start_time && strtotime(str_replace('.','-',$v['statement_end_time']))<=$end_time ||strtotime(str_replace('.','-',$v['statement_begin_time']))>=$start_time && strtotime(str_replace('.','-',$v['statement_begin_time']))<=$end_time ||strtotime(str_replace('.','-',$v['statement_begin_time']))<=$start_time && strtotime(str_replace('.','-',$v['statement_end_time'])) >= $end_time) { @@ -1185,6 +1174,17 @@ class CompanyStatementController extends ThinkController } } } + } else { + foreach ($statementInfo as $k => $v) { + if (strtotime(str_replace('.','-',$v['statement_end_time'])) >= $start_time && strtotime(str_replace('.','-',$v['statement_end_time']))<=$end_time + ||strtotime(str_replace('.','-',$v['statement_begin_time']))>=$start_time && strtotime(str_replace('.','-',$v['statement_begin_time']))<=$end_time + ||strtotime(str_replace('.','-',$v['statement_begin_time']))<=$start_time && strtotime(str_replace('.','-',$v['statement_end_time'])) >= $end_time) { + if (in_array($v['relation_game_id'], $relation_game_data)) { + $this->ajaxReturn(['status' => 0, 'data' => [], 'msg' => "《{$v['game_name']}》在日期:{$_REQUEST['time_start']}-{$_REQUEST['time_end']}有结算过的部分,请重新选择"]); + } + } + } + } // } @@ -1207,7 +1207,7 @@ class CompanyStatementController extends ThinkController $radioMap['_string'] = "start_time < {$end_time}"; } $map['tab_spend.pay_status'] = 1; - $map['pay_way'] = ['egt',0]; +// $map['pay_way'] = ['egt',0]; $data = M("spend","tab_") ->field("pay_amount,relation_game_id,relation_game_name,payed_time") @@ -1257,81 +1257,92 @@ class CompanyStatementController extends ThinkController ->where(['relation_game_id'=>['in',$rvalue]]) ->find(); - $handleData[$_REQUEST['company_id']]['company_id'] = $_REQUEST['company_id']; - $handleData[$_REQUEST['company_id']]['company_name'] = $companyData['company_name']; - $handleData[$_REQUEST['company_id']]['begin_time'][] = strtotime(I('time_start')); - $handleData[$_REQUEST['company_id']]['end_time'][] = strtotime(I('time_end')) + 86399; - $handleData[$_REQUEST['company_id']]['relation_game_id'][] = $rvalue; - $handleData[$_REQUEST['company_id']]['relation_game_name'][] = $game_name['relation_game_name']; - $handleData[$_REQUEST['company_id']]['ratio'][] = $handleRadioMould[$rvalue]['ratio']?$handleRadioMould[$rvalue]['ratio']:0; - $handleData[$_REQUEST['company_id']]['turnover_ratio'][] = $handleRadioMould[$rvalue]['turnover_ratio']; + $handleData[$_REQUEST['company_id']]['company_id'] = $_REQUEST['company_id']; + $handleData[$_REQUEST['company_id']]['company_name'] = $companyData['company_name']; + $handleData[$_REQUEST['company_id']]['begin_time'][] = strtotime(I('time_start')); + $handleData[$_REQUEST['company_id']]['end_time'][] = strtotime(I('time_end')) + 86399; + $handleData[$_REQUEST['company_id']]['relation_game_id'][] = $rvalue; + $handleData[$_REQUEST['company_id']]['relation_game_name'][] = $game_name['relation_game_name']; + $handleData[$_REQUEST['company_id']]['ratio'][] = $handleRadioMould[$rvalue]['ratio']?$handleRadioMould[$rvalue]['ratio']:0; + $handleData[$_REQUEST['company_id']]['turnover_ratio'][] = $handleRadioMould[$rvalue]['turnover_ratio']; } } - foreach ($radioData as $key => $value) { + foreach ($relation_game_data as $rk => $rv) { + unset($radioMap['tab_company_game_ratio.relation_game_id']); + $radioMap['tab_company_game_ratio.relation_game_id'] = $rv; + $radioGameRatios = M("company_game_ratio","tab_") + ->field("tab_company_game_ratio.*,game.relation_game_name") + ->join("left join ({$game_data}) game on tab_company_game_ratio.relation_game_id=game.relation_game_id") + ->where($radioMap) + ->order("begin_time ASC") + ->select(); - if (strtotime(I('time_start')) <= $value['begin_time']) { - $handleData[$_REQUEST['company_id']]['begin_time'][] = $value['begin_time']; - } else { - $handleData[$_REQUEST['company_id']]['begin_time'][] = strtotime(I('time_start')); - } - if (strtotime(I('time_end')) > $value['end_time'] && $value['end_time']!=0) { - $handleData[$_REQUEST['company_id']]['end_time'][] = $value['end_time']; - } else { - $handleData[$_REQUEST['company_id']]['end_time'][] = strtotime(I('time_end')) + 86399; - } - $handleData[$_REQUEST['company_id']]['company_id'] = $_REQUEST['company_id']; - $handleData[$_REQUEST['company_id']]['company_name'] = $companyData['company_name']; - $handleData[$_REQUEST['company_id']]['relation_game_id'][] = $value['relation_game_id']; - $handleData[$_REQUEST['company_id']]['relation_game_name'][] = $value['relation_game_name']; - $handleData[$_REQUEST['company_id']]['ratio'][] = $value['ratio']; - $handleData[$_REQUEST['company_id']]['turnover_ratio'][] = $value['turnover_ratio']; - $num++; - - //如果结算时间小于比例开始时间 - if ($key == 0) { - if (strtotime(I('time_start')) < $value['begin_time']) { - $handleData[$_REQUEST['company_id']]['company_id'] = $_REQUEST['company_id']; - $handleData[$_REQUEST['company_id']]['company_name'] = $companyData['company_name']; - $handleData[$_REQUEST['company_id']]['begin_time'][] = strtotime(I('time_start')); - $handleData[$_REQUEST['company_id']]['end_time'][] = $value['begin_time']-1; - $handleData[$_REQUEST['company_id']]['relation_game_id'][] = $value['relation_game_id']; - $handleData[$_REQUEST['company_id']]['relation_game_name'][] = $value['relation_game_name']; - $handleData[$_REQUEST['company_id']]['ratio'][] = $handleRadioMould[$value['relation_game_id']]['ratio']?$handleRadioMould[$value['relation_game_id']]['ratio']:0; - $handleData[$_REQUEST['company_id']]['turnover_ratio'][] = $handleRadioMould[$value['relation_game_id']]['turnover_ratio']; + foreach ($radioGameRatios as $key => $value) { + if (strtotime(I('time_start')) <= $value['begin_time']) { + $handleData[$_REQUEST['company_id']]['begin_time'][] = $value['begin_time']; + } else { + $handleData[$_REQUEST['company_id']]['begin_time'][] = strtotime(I('time_start')); } - } + if (strtotime(I('time_end')) > $value['end_time'] && $value['end_time']!=0) { + $handleData[$_REQUEST['company_id']]['end_time'][] = $value['end_time']; + } else { + $handleData[$_REQUEST['company_id']]['end_time'][] = strtotime(I('time_end')) + 86399; + } + $handleData[$_REQUEST['company_id']]['company_id'] = $_REQUEST['company_id']; + $handleData[$_REQUEST['company_id']]['company_name'] = $companyData['company_name']; + $handleData[$_REQUEST['company_id']]['relation_game_id'][] = $value['relation_game_id']; + $handleData[$_REQUEST['company_id']]['relation_game_name'][] = $value['relation_game_name']; + $handleData[$_REQUEST['company_id']]['ratio'][] = $value['ratio']; + $handleData[$_REQUEST['company_id']]['turnover_ratio'][] = $value['turnover_ratio']; + $num++; + + //如果结算时间小于比例开始时间 + if ($key == 0) { + if (strtotime(I('time_start')) < $value['begin_time']) { + $handleData[$_REQUEST['company_id']]['company_id'] = $_REQUEST['company_id']; + $handleData[$_REQUEST['company_id']]['company_name'] = $companyData['company_name']; + $handleData[$_REQUEST['company_id']]['begin_time'][] = strtotime(I('time_start')); + $handleData[$_REQUEST['company_id']]['end_time'][] = $value['begin_time']-1; + $handleData[$_REQUEST['company_id']]['relation_game_id'][] = $value['relation_game_id']; + $handleData[$_REQUEST['company_id']]['relation_game_name'][] = $value['relation_game_name']; + $handleData[$_REQUEST['company_id']]['ratio'][] = $handleRadioMould[$value['relation_game_id']]['ratio']?$handleRadioMould[$value['relation_game_id']]['ratio']:0; + $handleData[$_REQUEST['company_id']]['turnover_ratio'][] = $handleRadioMould[$value['relation_game_id']]['turnover_ratio']; - if(!$radioData[$key+1]) { + } + } - if (strtotime(I('time_end')) > $value['end_time'] && $value['end_time']!=0) { - $handleData[$_REQUEST['company_id']]['company_id'] = $_REQUEST['company_id']; - $handleData[$_REQUEST['company_id']]['company_name'] = $companyData['company_name']; - $handleData[$_REQUEST['company_id']]['begin_time'][] = $value['end_time'] + 1; - $handleData[$_REQUEST['company_id']]['end_time'][] = strtotime(I('time_end'))-86399; - $handleData[$_REQUEST['company_id']]['relation_game_id'][] = $value['relation_game_id']; - $handleData[$_REQUEST['company_id']]['relation_game_name'][] = $value['relation_game_name']; - $handleData[$_REQUEST['company_id']]['ratio'][] = $handleRadioMould[$value['relation_game_id']]['ratio']?$handleRadioMould[$value['relation_game_id']]['ratio']:0; - $handleData[$_REQUEST['company_id']]['turnover_ratio'][] = $handleRadioMould[$value['relation_game_id']]['turnover_ratio']; + if(!$radioData[$key+1]) { + + if (strtotime(I('time_end')) > $value['end_time'] && $value['end_time']!=0) { + $handleData[$_REQUEST['company_id']]['company_id'] = $_REQUEST['company_id']; + $handleData[$_REQUEST['company_id']]['company_name'] = $companyData['company_name']; + $handleData[$_REQUEST['company_id']]['begin_time'][] = $value['end_time'] + 1; + $handleData[$_REQUEST['company_id']]['end_time'][] = strtotime(I('time_end'))-86399; + $handleData[$_REQUEST['company_id']]['relation_game_id'][] = $value['relation_game_id']; + $handleData[$_REQUEST['company_id']]['relation_game_name'][] = $value['relation_game_name']; + $handleData[$_REQUEST['company_id']]['ratio'][] = $handleRadioMould[$value['relation_game_id']]['ratio']?$handleRadioMould[$value['relation_game_id']]['ratio']:0; + $handleData[$_REQUEST['company_id']]['turnover_ratio'][] = $handleRadioMould[$value['relation_game_id']]['turnover_ratio']; + } } - } - //如果结算时间中有时间段间隔 - if ($radioData[$key+1]) { - if ($radioData[$key+1]['begin_time'] != ($value['end_time']+1)) { - $handleData[$_REQUEST['company_id']]['company_id'] = $_REQUEST['company_id']; - $handleData[$_REQUEST['company_id']]['company_name'] = $companyData['company_name']; - $handleData[$_REQUEST['company_id']]['begin_time'][] = $value['end_time'] + 1; - $handleData[$_REQUEST['company_id']]['end_time'][] = $radioData[$key+1]['begin_time'] - 1; - $handleData[$_REQUEST['company_id']]['relation_game_id'][] = $value['relation_game_id']; - $handleData[$_REQUEST['company_id']]['relation_game_name'][] = $value['relation_game_name']; - $handleData[$_REQUEST['company_id']]['ratio'][] = $handleRadioMould[$value['relation_game_id']]['ratio']?$gameRatioMould['ratio']:0; - $handleData[$_REQUEST['company_id']]['turnover_ratio'][] = $handleRadioMould[$value['relation_game_id']]['turnover_ratio']; + //如果结算时间中有时间段间隔 + if ($radioData[$key+1]) { + if ($radioData[$key+1]['begin_time'] != ($value['end_time']+1)&&$value['end_time']!=0) { + $handleData[$_REQUEST['company_id']]['company_id'] = $_REQUEST['company_id']; + $handleData[$_REQUEST['company_id']]['company_name'] = $companyData['company_name']; + $handleData[$_REQUEST['company_id']]['begin_time'][] = $value['end_time'] + 1; + $handleData[$_REQUEST['company_id']]['end_time'][] = $radioData[$key+1]['begin_time'] - 1; + $handleData[$_REQUEST['company_id']]['relation_game_id'][] = $value['relation_game_id']; + $handleData[$_REQUEST['company_id']]['relation_game_name'][] = $value['relation_game_name']; + $handleData[$_REQUEST['company_id']]['ratio'][] = $handleRadioMould[$value['relation_game_id']]['ratio']?$gameRatioMould['ratio']:0; + $handleData[$_REQUEST['company_id']]['turnover_ratio'][] = $handleRadioMould[$value['relation_game_id']]['turnover_ratio']; + } } } } -// dump($handleData);die(); + foreach ($handleData as $key => $value) { $handleData[$key]['row'] = 0; $timeArr = $value['begin_time']; @@ -1495,7 +1506,7 @@ class CompanyStatementController extends ThinkController $amount_time['promote_id'] = '-1'; } $amount_time['tab_spend.pay_status'] = 1; - $amount_time['pay_way'] = ['egt',0]; +// $amount_time['pay_way'] = ['egt',0]; foreach ($statement_info as $k => $v) {