添加日历

This commit is contained in:
2026-01-08 17:55:47 +04:00
parent 7c34efae5c
commit e658c2a0fd

View File

@@ -0,0 +1,43 @@
<?php
namespace app\api\controller;
use think\Db;
class Calendar extends ApiBase
{
public function index()
{
$date = $this->request->post("date");
if (!$date) {
return $this->_error("日期不能为空");
}
//查询这个时间的服务
$service = Db::name('order_exe')->where('date', $date)->where('abnormal', 0)->select();
$serviceDate = [];
if ($service) {
//查询到有数据,就去找服务人员
foreach ($service as $v) {
if ($v['staff_id'] != null) {
$staffName = Db::name('staff')->where('id', $v['staff_id'])
->where('onwork', 1)
->where('leave', 1)
->find();
if ($staffName){
$startTime = date('H:i', strtotime($v['start_time']));
$timeoutTime = date('H:i', strtotime($v['timeout']));
$timeRange = $startTime . '-' . $timeoutTime;
$serviceDate[] = [
'date' => $v['date'],
'staff_name' => $staffName['name'],
'addtime' => $v['addtime'] == 1 ? '上午' : ($v['addtime'] == 2 ? '下午' : ''), //1表示上午2表示下午
'serviceTime' => $timeRange,
'xq' => $v['xq'],
];
}
}
}
}
return $this->_success("成功", $serviceDate);
}
}