TaskSystem/app/api/controller/TaskController.php

71 lines
2.8 KiB
PHP
Raw Normal View History

2023-08-05 16:14:43 +08:00
<?php
namespace app\api\controller;
2023-08-16 15:44:36 +08:00
use app\common\model\Company;
2023-08-16 16:34:11 +08:00
use app\common\model\informationg\UserInformationg;
2023-08-05 16:14:43 +08:00
use app\common\model\task\Task;
2023-08-16 14:56:25 +08:00
use app\common\model\user\User;
2023-08-05 16:14:43 +08:00
class TaskController extends BaseApiController{
public function lists(){
$param = Request()->param();
[$page, $limit] = $this->getPage();
2023-08-15 16:40:33 +08:00
if($this->userInfo['admin_id']!=0){
2023-08-05 16:14:43 +08:00
$where[]=['company_id','=',$this->userInfo['company_id']];
2023-08-15 16:40:33 +08:00
}else{
2023-08-16 14:56:25 +08:00
$is_captain=User::where('id',$this->userId)->value('is_captain');
if($is_captain==1){
$where[]=['type','=',31];
}else{
$where[]=['director_uid','=',$this->userId];
}
2023-08-15 17:41:31 +08:00
// $where[]=['status','in',[1,2,3,5]];
2023-08-05 16:14:43 +08:00
}
2023-08-15 17:27:02 +08:00
if(isset($param['date_time']) && $param['date_time']!=''){
$time=strtotime($param['date_time']);
$end=$time+86399;
$where[]=['start_time','between',[$time,$end]];
}else{
$time=strtotime(date('Y-m-d'));
$end=$time+86399;
$where[]=['start_time','between',[$time,$end]];
}
2023-08-15 18:06:11 +08:00
if(isset($param['status']) && $param['status']>0){
$where[]=['status','=',$param['status']];
}
2023-08-05 16:14:43 +08:00
$res=Task::where($where)
2023-08-05 16:25:03 +08:00
->field(['id', 'title','money','template_id','director_uid', 'company_id', 'start_time', 'end_time', 'director_uid', 'type', 'status', 'content','extend'])
2023-08-05 16:14:43 +08:00
->page($page,25)
2023-08-15 18:01:24 +08:00
->order(['id' => 'desc','status'=>'asc'])
2023-08-16 15:54:30 +08:00
->select()->toArray();
foreach($res as $k=>$item){
if($item['type']==33){
2023-08-16 15:44:36 +08:00
$company = Company::where('id', $item['company_id'])->field('id,deposit,company_money,user_id,day_count,company_type,province,city,area,street,village,brigade')->find(); // 可能要判断预存金是否满足
2023-08-16 15:54:30 +08:00
$find=App(RemoteController::class)->shang_date_total_price($company);
if($find!=false){
$res[$k]['extend']['transaction']=$find;
2023-08-16 15:44:36 +08:00
}else{
2023-08-16 15:54:30 +08:00
$res[$k]['extend']['transaction']='';
2023-08-16 15:44:36 +08:00
}
}
2023-08-16 15:54:30 +08:00
}
2023-08-05 16:14:43 +08:00
return $this->success('ok', $res);
}
2023-08-16 16:34:11 +08:00
public function informationg_list(){
$parmas=Request()->param();
$find=Task::where('id',$parmas['id'])->find();
if($find['type']==31){
$ids=$find['extend']['informationg']['ids'];
2023-08-16 16:45:39 +08:00
$list= UserInformationg::where('id','in',$ids)
->field('id,name,phone,sex,age,update_time,
area_id,area_id area_name,street_id,street_id street_name,village_id,village_id village_name,brigade_id,brigade_id brigade_name,address'
)->select()->toArray();
2023-08-16 16:34:11 +08:00
}else{
$list=[];
}
return $this->success('ok',$list);
}
2023-08-05 16:14:43 +08:00
}