|
...
|
...
|
@@ -6,7 +6,9 @@ use app\common\controller\Frontend; |
|
|
|
use app\school\model\project_appointment\Building as BuildingModel;
|
|
|
|
use app\school\model\project_appointment\AppointmentRule as AppointmentRuleModel;
|
|
|
|
use app\school\model\project_appointment\Room as RoomModel;
|
|
|
|
use app\school\model\project_appointment\Floor as FloorModel;
|
|
|
|
use app\index\model\BuildingEnter;
|
|
|
|
use app\school\model\station\Station;
|
|
|
|
use think\Db;
|
|
|
|
|
|
|
|
class SxBasement extends Frontend
|
|
|
|
{
|
|
...
|
...
|
@@ -25,12 +27,21 @@ class SxBasement extends Frontend |
|
|
|
if($enterRules) {
|
|
|
|
$enterRules['data_url'] = json_decode($enterRules['data_url'],true);
|
|
|
|
}
|
|
|
|
$stationList = ['1' => '工位一','2' => '工位二','3' => '工位三','4' => '工位四','5' => '工位五','6' => '工位六','7' => '工位七','8' => '工位八'];
|
|
|
|
//工位
|
|
|
|
$stationList = Station::alias('a')
|
|
|
|
->field('a.id,a.station_name,count(sa.id) as appoint_count')
|
|
|
|
->join('fa_station_appointment sa','a.id = sa.station_id','LEFT')
|
|
|
|
->where(['a.school_id'=>$this->auth->school_id])
|
|
|
|
->group('a.id')
|
|
|
|
->select();
|
|
|
|
//入驻公司
|
|
|
|
$buildingEnter = BuildingEnter::where(['enter_type' => 2,'status' => 2,'school_id'=>$this->auth->school_id,'user_id' => $this->auth->id])->column('id,enter_project_name');
|
|
|
|
$this->assign('roomTypeList',$roomTypeList);
|
|
|
|
$this->assign('stationList',$stationList);
|
|
|
|
$this->assign('enterRules',$enterRules);
|
|
|
|
$this->assign('buildList',$buildList);
|
|
|
|
$this->assign('roomList',$roomList);
|
|
|
|
$this->assign('buildingEnter',$buildingEnter);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function index()
|
|
...
|
...
|
@@ -46,4 +57,94 @@ class SxBasement extends Frontend |
|
|
|
downloadFile($file_url,$file_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 工位分配提交
|
|
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
|
|
* @throws \think\exception\DbException
|
|
|
|
*/
|
|
|
|
public function stationApply()
|
|
|
|
{
|
|
|
|
$userInfo = $this->auth->getUser();
|
|
|
|
if(!$userInfo) {
|
|
|
|
$this->success('请登入','/index/student_login/index');
|
|
|
|
}
|
|
|
|
$params = $this->request->post();
|
|
|
|
if(!isset($params['station_id']) || empty($params['station_id'])){
|
|
|
|
$this->error('请选择工位');
|
|
|
|
}
|
|
|
|
if(!isset($params['enter_id']) || empty($params['enter_id'])){
|
|
|
|
$this->error('请选择公司');
|
|
|
|
}
|
|
|
|
if(strtotime($params['station_start_time']) <= time()) {
|
|
|
|
$this->error('开始时间请选择未来时间');
|
|
|
|
}
|
|
|
|
$startTime = strtotime($params['station_date'].$params['station_start_time']);
|
|
|
|
$endTime = strtotime($params['station_date'].$params['station_end_time']);
|
|
|
|
|
|
|
|
if($startTime == $endTime) {
|
|
|
|
$this->error('预约开始时间不能等于结束时间');
|
|
|
|
}
|
|
|
|
|
|
|
|
if($endTime <= $startTime) {
|
|
|
|
$this->error('结束时间不能小于开始时间');
|
|
|
|
}
|
|
|
|
$stationInfo = Station::alias('a')
|
|
|
|
->field('a.id,a.station_name,a.capacity,count(sa.id) as appoint_count')
|
|
|
|
->join('fa_station_appointment sa','a.id = sa.station_id','LEFT')
|
|
|
|
->where('a.deletetime',NULL)
|
|
|
|
->where(['a.id' => $params['station_id']])
|
|
|
|
->find();
|
|
|
|
if(!$stationInfo) {
|
|
|
|
$this->error('该工位不存在或已经被下架');
|
|
|
|
}
|
|
|
|
if ($stationInfo['appoint_count']){
|
|
|
|
$this->error('该工位已被预约');
|
|
|
|
}
|
|
|
|
if ($stationInfo['capacity'] < $params['station_user_count']){
|
|
|
|
$this->error("该工位可容纳{$stationInfo['capacity']}人");
|
|
|
|
}
|
|
|
|
$res = Db::table('fa_station_appointment')
|
|
|
|
->whereOr("station_start_time >= {$startTime} AND station_start_time <= {$endTime}")
|
|
|
|
->whereOr("station_start_time <= {$startTime} AND station_end_time >= {$endTime}")
|
|
|
|
->whereOr("station_end_time >= {$startTime} AND station_end_time <= {$endTime}")
|
|
|
|
->having("station_id = {$params['station_id']}")
|
|
|
|
->select();
|
|
|
|
if($res) {
|
|
|
|
$this->error('该时间存在已经被预约,请重新选择');
|
|
|
|
}
|
|
|
|
$params['station_start_time'] = $startTime;
|
|
|
|
$params['station_end_time'] = $endTime;
|
|
|
|
$params['user_id'] = $userInfo['id'];
|
|
|
|
$params['school_id'] = $userInfo['school_id'];
|
|
|
|
$params['createtime'] = time();
|
|
|
|
$result = Db::table('fa_station_appointment')->insert($params);
|
|
|
|
if(!$result) {
|
|
|
|
$this->error('预约失败,请重新尝试');
|
|
|
|
}
|
|
|
|
$this->success('预约成功','/index/sx_basement/index');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 工位列表
|
|
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
|
|
* @throws \think\exception\DbException
|
|
|
|
*/
|
|
|
|
public function station(){
|
|
|
|
$params = $this->request->post();
|
|
|
|
$startTime = strtotime($params['station_date'].$params['station_start_time']);
|
|
|
|
$endTime = strtotime($params['station_date'].$params['station_end_time']);
|
|
|
|
//工位
|
|
|
|
$stationList = Station::alias('a')
|
|
|
|
->field('a.id,a.station_name,count(sa.id) as appoint_count')
|
|
|
|
->join('fa_station_appointment sa','a.id = sa.station_id','LEFT')
|
|
|
|
->whereOr("station_start_time >= {$startTime} AND station_start_time <= {$endTime}")
|
|
|
|
->whereOr("station_start_time <= {$startTime} AND station_end_time >= {$endTime}")
|
|
|
|
->whereOr("station_end_time >= {$startTime} AND station_end_time <= {$endTime}")
|
|
|
|
->where('a.school_id',$this->auth->school_id)
|
|
|
|
->group('a.id')
|
|
|
|
->select();
|
|
|
|
$this->success('查询成功',$stationList);
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|