公司流水统计查询
This commit is contained in:
parent
60fc4f00b9
commit
7ff66a407c
@ -35,9 +35,9 @@ class AccountLogLists extends BaseApiDataLists
|
||||
public function queryWhere()
|
||||
{
|
||||
// 指定用户
|
||||
if(isset($this->params['user_id']) && $this->params['user_id'] > 0){
|
||||
$where[] =['user_id','=', $this->params['user_id']];
|
||||
}else{
|
||||
if (isset($this->params['user_id']) && $this->params['user_id'] > 0) {
|
||||
$where[] = ['user_id', '=', $this->params['user_id']];
|
||||
} else {
|
||||
$where[] = ['user_id', '=', $this->userId];
|
||||
}
|
||||
|
||||
@ -52,10 +52,10 @@ class AccountLogLists extends BaseApiDataLists
|
||||
}
|
||||
// 变动时间
|
||||
if (!empty($this->params['time'])) {
|
||||
$date= strtotime($this->params['time']);
|
||||
$date = strtotime($this->params['time']);
|
||||
$startTime = $date - 3600; // 获取该日期零点的时间戳
|
||||
$endTime = $date + 86400; // 获取该日期24小时后的时间戳
|
||||
$where[] = ['create_time', 'between time',[$startTime, $endTime]];
|
||||
$where[] = ['create_time', 'between time', [$startTime, $endTime]];
|
||||
}
|
||||
return $where;
|
||||
}
|
||||
@ -107,9 +107,16 @@ class AccountLogLists extends BaseApiDataLists
|
||||
public function company_lists(): array
|
||||
{
|
||||
$field = 'change_type,change_amount,action,create_time,remark,user_id';
|
||||
$where=[
|
||||
'company_id'=>$this->params['company_id']
|
||||
$where[] = [
|
||||
'company_id' => $this->params['company_id']
|
||||
];
|
||||
// 变动时间
|
||||
if (!empty($this->params['time'])) {
|
||||
$date = strtotime($this->params['time']);
|
||||
$startTime = $date - 3600; // 获取该日期零点的时间戳
|
||||
$endTime = $date + 86400; // 获取该日期24小时后的时间戳
|
||||
$where[] = ['create_time', 'between time', [$startTime, $endTime]];
|
||||
}
|
||||
$lists = UserAccountLog::field($field)
|
||||
->where($where)
|
||||
->with(['userInfo'])
|
||||
@ -133,15 +140,15 @@ class AccountLogLists extends BaseApiDataLists
|
||||
*/
|
||||
public function company_year_count()
|
||||
{
|
||||
$where=[
|
||||
'company_id'=>$this->params['company_id'],
|
||||
'action'=>1,
|
||||
$where = [
|
||||
'company_id' => $this->params['company_id'],
|
||||
'action' => 1,
|
||||
];
|
||||
$where2=[
|
||||
'company_id'=>$this->params['company_id'],
|
||||
'action'=>2,
|
||||
$where2 = [
|
||||
'company_id' => $this->params['company_id'],
|
||||
'action' => 2,
|
||||
];
|
||||
$data = [['month'=>date('Y').'-01'],['month'=>date('Y').'-02'],['month'=>date('Y').'-03'],['month'=>date('Y').'-04'],['month'=>date('Y').'-05'],['month'=>date('Y').'-06'],['month'=>date('Y').'-07'],['month'=>date('Y').'-08'],['month'=>date('Y').'-09'],['month'=>date('Y').'-10'],['month'=>date('Y').'-11'],['month'=>date('Y').'-12']];
|
||||
$data = [['month' => date('Y') . '-01'], ['month' => date('Y') . '-02'], ['month' => date('Y') . '-03'], ['month' => date('Y') . '-04'], ['month' => date('Y') . '-05'], ['month' => date('Y') . '-06'], ['month' => date('Y') . '-07'], ['month' => date('Y') . '-08'], ['month' => date('Y') . '-09'], ['month' => date('Y') . '-10'], ['month' => date('Y') . '-11'], ['month' => date('Y') . '-12']];
|
||||
$year = date('Y');
|
||||
$change_amount_1 = UserAccountLog::whereYear('create_time', $year)
|
||||
->where($where)
|
||||
@ -150,31 +157,31 @@ class AccountLogLists extends BaseApiDataLists
|
||||
->order('month')
|
||||
->select();
|
||||
$change_amount_2 = UserAccountLog::whereYear('create_time', $year)
|
||||
->where($where2)
|
||||
->field('DATE_FORMAT(FROM_UNIXTIME(create_time), "%Y-%m") as month, SUM(change_amount) as total')
|
||||
->where($where2)
|
||||
->field('DATE_FORMAT(FROM_UNIXTIME(create_time), "%Y-%m") as month, SUM(change_amount) as total')
|
||||
->group('month')
|
||||
->order('month')
|
||||
->select();
|
||||
foreach($data as $k=>$v){
|
||||
foreach($change_amount_1 as $key=>$val){
|
||||
if($v['month'] == $val['month']){
|
||||
foreach ($data as $k => $v) {
|
||||
foreach ($change_amount_1 as $key => $val) {
|
||||
if ($v['month'] == $val['month']) {
|
||||
$data[$k]['income'] = $val['total'];
|
||||
if(!isset($data[$k]['expenditure'])){
|
||||
if (!isset($data[$k]['expenditure'])) {
|
||||
$data[$k]['expenditure'] = 0;
|
||||
}
|
||||
$data[$k]['income'] = $val['total'];
|
||||
}
|
||||
}
|
||||
foreach($change_amount_2 as $key=>$val){
|
||||
if($v['month'] == $val['month']){
|
||||
foreach ($change_amount_2 as $key => $val) {
|
||||
if ($v['month'] == $val['month']) {
|
||||
$data[$k]['expenditure'] = $val['total'];
|
||||
if(!isset($data[$k]['income'])){
|
||||
if (!isset($data[$k]['income'])) {
|
||||
$data[$k]['income'] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
$data[$k]['remark']='任务收益';
|
||||
if(!isset($data[$k]['income'])||!isset($data[$k]['expenditure'])){
|
||||
$data[$k]['remark'] = '任务收益';
|
||||
if (!isset($data[$k]['income']) || !isset($data[$k]['expenditure'])) {
|
||||
unset($data[$k]);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user