Files
duolamaojiazhen/application/api/controller/Calendar.php
2026-01-08 17:55:47 +04:00

43 lines
1.6 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?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);
}
}