Commit aa09b17d authored by zhuwei's avatar zhuwei

Validate 验证

parent 625eb86c
...@@ -357,6 +357,12 @@ class OperationData extends Basic ...@@ -357,6 +357,12 @@ class OperationData extends Basic
header('Access-Control-Allow-Origin:*'); header('Access-Control-Allow-Origin:*');
$params = $this->params; $params = $this->params;
$checkResult = $this->validate($params, "OperationDataValidate.performanceStatistics");
if (true !== $checkResult) {
return $this->response("101", $checkResult);
}
$time_start = $params['time_start']; $time_start = $params['time_start'];
$time_end = $params['time_end']; $time_end = $params['time_end'];
...@@ -401,10 +407,9 @@ class OperationData extends Basic ...@@ -401,10 +407,9 @@ class OperationData extends Basic
} else { } else {
$conditions['site_id'] = $v['site_id']; $conditions['site_id'] = $v['site_id'];
} }
$conditions['site_id'] = $v['site_id'];
$conditions['create_time'] = array( 'between', array( $p_start . " 00:00:00", $p_end . " 23:59:59" ) ); $conditions['create_time'] = array( 'between', array( $p_start . " 00:00:00", $p_end . " 23:59:59" ) );
$performanceSum = $m_total->performanceStatistics($conditions, 1); $performanceSum = $m_total->performanceStatistics($conditions, 1);
$value_['performance'] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0; $value_['performance'] = isset($performanceSum[0]["performance_total"]) ? $performanceSum[0]["performance_total"] : 0;
// 实收 // 实收
...@@ -414,10 +419,9 @@ class OperationData extends Basic ...@@ -414,10 +419,9 @@ class OperationData extends Basic
} else { } else {
$conditions['site_id'] = $v['site_id']; $conditions['site_id'] = $v['site_id'];
} }
$conditions['site_id'] = $v['site_id'];
$conditions['create_time'] = array( 'between', array( $r_p_start . " 00:00:00", $r_p__end . " 23:59:59" ) ); $conditions['create_time'] = array( 'between', array( $r_p_start . " 00:00:00", $r_p__end . " 23:59:59" ) );
$real_performanceSum = $m_total->performanceStatistics($conditions, 2); $real_performanceSum = $m_total->performanceStatistics($conditions, 2);
$value_['real_performance'] = isset($real_performanceSum[0]["num"]) ? $real_performanceSum[0]["num"] : 0; $value_['real_performance'] = isset($real_performanceSum[0]["official_receipts_total"]) ? $real_performanceSum[0]["official_receipts_total"] : 0;
//人数 //人数
...@@ -443,19 +447,6 @@ class OperationData extends Basic ...@@ -443,19 +447,6 @@ class OperationData extends Basic
return $this->response(200, 'success', $return); return $this->response(200, 'success', $return);
} }
function sum($date)
{
// $performance_count = 0;
// $real_performance_count = [];
$people_num_count = [];
foreach ($date as $key => $v) {
foreach ($v['value'] as $month_key => $month_v) {
$people_num_count['people_num'][]= ['index'=>$month_key,'val'=>$month_v['people_num']];
}
}
dump($people_num_count);
return $date;
}
/** /**
* 找出两个日期之间的所有的月份 * 找出两个日期之间的所有的月份
......
<?php
namespace app\index\validate;
use think\Validate;
class OperationDataValidate extends Validate {
protected $rule = [
'time_start' => 'require',
'time_end' => 'require',
'performance_time_start' => 'require|number|gt:0',
'performance_time_end' => 'require|number|gt:0',
'real_performance_time_start' => 'require|number|gt:0',
'real_performance_time_end' => 'require|number|gt:0',
];
protected $message = [
'time_start.require' => 'time_start 不能为空',
'time_end.require' => 'time_end 不能为空',
'performance_time_start.require' => 'performance_time_start 不能为空',
'performance_time_end.require' => 'performance_time_end 不能为空',
'real_performance_time_start.require' => 'real_performance_time_start 不能为空',
'real_performance_time_end.require' => 'real_performance_time_end 不能为空',
'performance_time_start.number' => 'performance_time_start 必须为数字',
'performance_time_end.number' => 'performance_time_end 必须为数字',
'real_performance_time_start.number' => 'real_performance_time_start 必须为数字',
'real_performance_time_end.number' => 'real_performance_time_end 必须为数字',
'performance_time_start.gt' => 'performance_time_start 必须大于0',
'performance_time_end.gt' => 'performance_time_end 必须大于0',
'real_performance_time_start.gt' => 'real_performance_time_start 必须大于0',
'real_performance_time_end.gt' => 'real_performance_time_end 必须大于0',
];
protected $scene = [
'performanceStatistics' => [ 'time_start', 'time_end', 'performance_time_start', 'performance_time_end', 'real_performance_time_start', 'real_performance_time_end' ],
];
}
\ No newline at end of file
...@@ -378,6 +378,7 @@ class TAgentTotalModel extends Model ...@@ -378,6 +378,7 @@ class TAgentTotalModel extends Model
->join("a_agents b", "a.agent_id = b.id", "left") ->join("a_agents b", "a.agent_id = b.id", "left")
->where($where_) ->where($where_)
->select(); ->select();
// dump($this->getLastSql());
return $return; return $return;
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment