|
@@ -8,13 +8,17 @@ use App\Http\Controllers\Controller;
|
|
use App\Models\CdmsUsers;
|
|
use App\Models\CdmsUsers;
|
|
use App\Models\Docter;
|
|
use App\Models\Docter;
|
|
use App\Models\DocterOrganization;
|
|
use App\Models\DocterOrganization;
|
|
|
|
+use App\Models\DocterSetting;
|
|
|
|
+use App\Models\Doctertimes;
|
|
use App\Models\Order;
|
|
use App\Models\Order;
|
|
use App\Models\Organization;
|
|
use App\Models\Organization;
|
|
use App\Models\PatientRemark;
|
|
use App\Models\PatientRemark;
|
|
use App\Models\Schedule;
|
|
use App\Models\Schedule;
|
|
use App\Models\SchedulePeriod;
|
|
use App\Models\SchedulePeriod;
|
|
|
|
+use App\Models\SelfSchedule;
|
|
use App\Models\SystemConfig;
|
|
use App\Models\SystemConfig;
|
|
use App\Models\TimePeriod;
|
|
use App\Models\TimePeriod;
|
|
|
|
+use App\Models\WeekSchedule;
|
|
use Carbon\Carbon;
|
|
use Carbon\Carbon;
|
|
use EasyWeChat\Factory;
|
|
use EasyWeChat\Factory;
|
|
use Encore\Admin\Facades\Admin;
|
|
use Encore\Admin\Facades\Admin;
|
|
@@ -23,10 +27,13 @@ use mysql_xdevapi\Exception;
|
|
|
|
|
|
class ApiController extends Controller
|
|
class ApiController extends Controller
|
|
{
|
|
{
|
|
|
|
+ //获取订单
|
|
public function getDocter()
|
|
public function getDocter()
|
|
{
|
|
{
|
|
- return Docter::get(['name as text','id'])->toArray();
|
|
|
|
|
|
+ return Docter::pluck(['name','id'])->toArray();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //备注
|
|
public function paitent_remark()
|
|
public function paitent_remark()
|
|
{
|
|
{
|
|
$data['patient_id']= request('patient_id');
|
|
$data['patient_id']= request('patient_id');
|
|
@@ -43,6 +50,7 @@ class ApiController extends Controller
|
|
return redirect('/cdms/nurse_users');
|
|
return redirect('/cdms/nurse_users');
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //发送短信
|
|
public function sendmsg(){
|
|
public function sendmsg(){
|
|
|
|
|
|
$config = [
|
|
$config = [
|
|
@@ -105,7 +113,6 @@ class ApiController extends Controller
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
//获取排班页面
|
|
//获取排班页面
|
|
public function getComSchedule()
|
|
public function getComSchedule()
|
|
{
|
|
{
|
|
@@ -136,6 +143,7 @@ class ApiController extends Controller
|
|
return json_encode(['code'=>601,'msg'=>'缺少必要参数','data'=>'']);
|
|
return json_encode(['code'=>601,'msg'=>'缺少必要参数','data'=>'']);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ return $this->getWeekSchedule();
|
|
$start_time = intval(str_replace('-','',$all_time[0]));
|
|
$start_time = intval(str_replace('-','',$all_time[0]));
|
|
$end_time = intval(str_replace('-','',$all_time[1]));
|
|
$end_time = intval(str_replace('-','',$all_time[1]));
|
|
$first_day = strtotime($all_time[0]);
|
|
$first_day = strtotime($all_time[0]);
|
|
@@ -182,6 +190,7 @@ class ApiController extends Controller
|
|
'sunday'=>false,
|
|
'sunday'=>false,
|
|
]
|
|
]
|
|
];
|
|
];
|
|
|
|
+// return $this->getWeekSchedule();
|
|
|
|
|
|
//周字段映射
|
|
//周字段映射
|
|
$week_arr = ['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];
|
|
$week_arr = ['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];
|
|
@@ -402,6 +411,62 @@ class ApiController extends Controller
|
|
return json_encode(['status'=>200,'msg'=>'插入成功','data'=>count($info)]);
|
|
return json_encode(['status'=>200,'msg'=>'插入成功','data'=>count($info)]);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //设置自己排班
|
|
|
|
+ public function setSelfSchedule()
|
|
|
|
+ {
|
|
|
|
+ $docter_id = request('docter_id');
|
|
|
|
+ $org_id = request('org_id');
|
|
|
|
+ $date = request('date');
|
|
|
|
+ $type = request('type','1,2'); //1 上午,2 下午,3 晚上
|
|
|
|
+ $schedule_type = request('schedule_type');
|
|
|
|
+ $self_setting = DocterSetting::where(['docter_id'=>$docter_id])->first();
|
|
|
|
+ $times = [];
|
|
|
|
+ if(!empty($self_setting)){
|
|
|
|
+ $time_period = object_array(json_decode($self_setting->service_time));
|
|
|
|
+ $times[1] = TimePeriod::where(['docter_id'=>$docter_id])->whereBetween('end_time_period',[intval($time_period[0]['startTime']),intval($time_period[0]['endTime'])])->pluck('id')->toArray();
|
|
|
|
+ $times[2] = TimePeriod::where(['docter_id'=>$docter_id])->whereBetween('end_time_period',[intval($time_period[1]['startTime']),intval($time_period[1]['endTime'])])->pluck('id')->toArray();
|
|
|
|
+ $times[3] = TimePeriod::where(['docter_id'=>$docter_id])->whereBetween('end_time_period',[intval($time_period[2]['startTime']),intval($time_period[2]['endTime'])])->pluck('id')->toArray();
|
|
|
|
+ }
|
|
|
|
+ if(count($times) <3){
|
|
|
|
+ return apiReturn(602,'请设置真确的时间段');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(empty($docter_id) || empty($org_id) || empty('date') || empty($type) || empty($schedule_type)){
|
|
|
|
+ return apiReturn(601,'缺少必要参数');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(strtotime($date) < strtotime('tomorrow')){
|
|
|
|
+ return apiReturn(602,'只能排明天以後的');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $week = date("w",strtotime($date));
|
|
|
|
+ $types = explode(',',$type);
|
|
|
|
+ if(!empty($types)){
|
|
|
|
+ foreach ($types as $t){
|
|
|
|
+ $self_schedule = [
|
|
|
|
+ 'schedule_date'=>$date,
|
|
|
|
+ 'week'=>intval($week),
|
|
|
|
+ 'schedule_type'=>$schedule_type,
|
|
|
|
+ 'organization_id'=>$org_id,
|
|
|
|
+ 'docter_id'=>$docter_id,
|
|
|
|
+ 'type'=>intval($t)
|
|
|
|
+ ];
|
|
|
|
+ foreach ($times[intval($t)] as $id){
|
|
|
|
+ $self_schedule['time_period_id'] = $id;
|
|
|
|
+ $is_have = SelfSchedule::where(['docter_id'=>$docter_id,'organization_id'=>$org_id,'schedule_date'=>$date,'type'=>intval($t),'week'=>$week,'time_period_id'=>$id])->value('id');
|
|
|
|
+ if($is_have) continue;
|
|
|
|
+ SelfSchedule::insert($self_schedule);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $cha = array_diff([1,2,3],$types);
|
|
|
|
+ foreach ($cha as $t){
|
|
|
|
+ SelfSchedule::where(['docter_id'=>$docter_id,'organization_id'=>$org_id,'schedule_date'=>$date,'type'=>intval($t)])->delete();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return apiReturn(200,'ok');
|
|
|
|
+ }
|
|
|
|
+
|
|
//获取用户信息
|
|
//获取用户信息
|
|
public function getScheduleInfo()
|
|
public function getScheduleInfo()
|
|
{
|
|
{
|
|
@@ -467,6 +532,7 @@ class ApiController extends Controller
|
|
return (json_encode(['code'=>200,'msg'=>'ok','data'=>$data]));
|
|
return (json_encode(['code'=>200,'msg'=>'ok','data'=>$data]));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //跟新订单
|
|
public function updateOrder(){
|
|
public function updateOrder(){
|
|
$id = request('id');
|
|
$id = request('id');
|
|
$status = request('status');
|
|
$status = request('status');
|
|
@@ -478,4 +544,294 @@ class ApiController extends Controller
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //更新用戶設置
|
|
|
|
+ public function updateDocterSetting()
|
|
|
|
+ {
|
|
|
|
+ $docter_id = request('docter_id',1);
|
|
|
|
+ if(empty($docter_id)){
|
|
|
|
+ return apiReturn(604,'参数错误');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //添加时间段
|
|
|
|
+ if(2 == 3){
|
|
|
|
+ $data = ['docter_id'=>$docter_id,'am_start'=>'8:30','am_end'=>'11:30','pm_start'=>'12:00','pm_end'=>'15:00','ev_start'=>'19:00','ev_end'=>'22:00','service_time'=>15];
|
|
|
|
+ $amtimes[] = explode(':',$data['am_start']);
|
|
|
|
+ $amtimes[] = explode(':',$data['am_end']);
|
|
|
|
+// $amcha = ($amtimes[1][0] - $amtimes[0][0])*60 +($amtimes[1][1] - $amtimes[0][1]);
|
|
|
|
+// $amCount = $amcha/$data['service_time'];
|
|
|
|
+ $amCount = intval(floor((strtotime($data['am_end']) - strtotime($data['am_start'])) / (60*$data['service_time'])));
|
|
|
|
+
|
|
|
|
+ $pmtimes[] = explode(':',$data['pm_start']);
|
|
|
|
+ $pmtimes[] = explode(':',$data['pm_end']);
|
|
|
|
+ $pmCount =intval(floor((strtotime($data['pm_end']) - strtotime($data['pm_start'])) / (60*$data['service_time'])));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ $evtimes[] = explode(':',$data['ev_start']);
|
|
|
|
+ $evtimes[] = explode(':',$data['ev_end']);
|
|
|
|
+ $evcha = ($evtimes[1][0] - $evtimes[0][0])*60 +($evtimes[1][1] - $evtimes[0][1]);
|
|
|
|
+ $evCount = $evcha/$data['service_time'];
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ for($i=1;$i<=$amCount;$i++){
|
|
|
|
+ $amdata = [
|
|
|
|
+ 'docter_id'=>$docter_id,
|
|
|
|
+ 'start_time_period'=> date('H:i',strtotime($data['am_start']) + ($i-1)*$data['service_time']*60),
|
|
|
|
+ 'end_time_period'=> date('H:i',strtotime($data['am_start']) + $i*$data['service_time']*60),
|
|
|
|
+ ];
|
|
|
|
+ TimePeriod::insert($amdata);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for($i=1;$i<=$pmCount;$i++){
|
|
|
|
+ $pmdata = [
|
|
|
|
+ 'docter_id'=>$docter_id,
|
|
|
|
+ 'start_time_period'=> date('H:i',strtotime($data['pm_start']) + ($i-1)*$data['service_time']*60),
|
|
|
|
+ 'end_time_period'=> date('H:i',strtotime($data['pm_start']) + $i*$data['service_time']*60),
|
|
|
|
+ ];
|
|
|
|
+ TimePeriod::insert($pmdata);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for($i=1;$i<=$evCount;$i++){
|
|
|
|
+ $evdata = [
|
|
|
|
+ 'docter_id'=>$docter_id,
|
|
|
|
+ 'start_time_period'=> date('H:i',strtotime($data['ev_start']) + ($i-1)*$data['service_time']*60),
|
|
|
|
+ 'end_time_period'=> date('H:i',strtotime($data['ev_start']) + $i*$data['service_time']*60),
|
|
|
|
+ ];
|
|
|
|
+ TimePeriod::insert($evdata);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $config = [['startTime'=>"08:30","endTime"=>"11:30"],["startTime"=>"13:30","endTime"=>"16:00"],["startTime"=>"18:30","endTime"=>"19:30"]];
|
|
|
|
+ $setting = [
|
|
|
|
+ 'docter_id'=>$docter_id,
|
|
|
|
+ 'type'=>2,
|
|
|
|
+ 'status'=>2,
|
|
|
|
+ 'show_days'=>7,
|
|
|
|
+ 'service_num'=>7,
|
|
|
|
+ 'service_time'=>json_encode($config)
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ $is_have = DocterSetting::where(['docter_id'=>$docter_id])->value('id');
|
|
|
|
+ if($is_have){
|
|
|
|
+ DocterSetting::where(['docter_id'=>$docter_id])->update($setting);
|
|
|
|
+ } else {
|
|
|
|
+ DocterSetting::insert($setting);
|
|
|
|
+ }
|
|
|
|
+ return apiReturn(200,'ok');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //获取周排班模板
|
|
|
|
+ public function getWeekSchedule()
|
|
|
|
+ {
|
|
|
|
+ $docter_id = request('docter_id',1);
|
|
|
|
+ $org_id = request('org_id',1);
|
|
|
|
+ $type = request('type',2);
|
|
|
|
+ $role = request('role',2);
|
|
|
|
+ if(empty($docter_id) || empty($type)){
|
|
|
|
+ return apiReturn(604,'缺少必要参数');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $docter_id = 1;
|
|
|
|
+ $docter_setting = DocterSetting::where(['docter_id'=>$docter_id,'type'=>$type])->first();
|
|
|
|
+ $times = [];
|
|
|
|
+ if(!empty($docter_setting)){
|
|
|
|
+ $time_period = object_array(json_decode($docter_setting->service_time));
|
|
|
|
+ $times[] = TimePeriod::where(['docter_id'=>$docter_id])->whereBetween('end_time_period',[intval($time_period[0]['startTime']),intval($time_period[0]['endTime'])])->pluck('id')->toArray();
|
|
|
|
+ $times[] = TimePeriod::where(['docter_id'=>$docter_id])->whereBetween('end_time_period',[intval($time_period[1]['startTime']),intval($time_period[1]['endTime'])])->pluck('id')->toArray();
|
|
|
|
+ $times[] = TimePeriod::where(['docter_id'=>$docter_id])->whereBetween('end_time_period',[intval($time_period[2]['startTime']),intval($time_period[2]['endTime'])])->pluck('id')->toArray();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(count($times) < 3){
|
|
|
|
+ dd('no have times');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //周字段映射
|
|
|
|
+ $week_arr = ['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];
|
|
|
|
+ $data = [
|
|
|
|
+ [
|
|
|
|
+ 'date'=>"上午",
|
|
|
|
+ 'monday'=>false,
|
|
|
|
+ 'tuesday'=>false,
|
|
|
|
+ 'wednesday'=>false,
|
|
|
|
+ 'thursday'=>false,
|
|
|
|
+ 'friday'=>false,
|
|
|
|
+ 'saturday'=>false,
|
|
|
|
+ 'sunday'=>false,
|
|
|
|
+ ],
|
|
|
|
+ [
|
|
|
|
+ 'date'=>"下午",
|
|
|
|
+ 'monday'=>false,
|
|
|
|
+ 'tuesday'=>false,
|
|
|
|
+ 'wednesday'=>false,
|
|
|
|
+ 'thursday'=>false,
|
|
|
|
+ 'friday'=>false,
|
|
|
|
+ 'saturday'=>false,
|
|
|
|
+ 'sunday'=>false,
|
|
|
|
+ ],
|
|
|
|
+ [
|
|
|
|
+ 'date'=>"晚上",
|
|
|
|
+ 'monday'=>false,
|
|
|
|
+ 'tuesday'=>false,
|
|
|
|
+ 'wednesday'=>false,
|
|
|
|
+ 'thursday'=>false,
|
|
|
|
+ 'friday'=>false,
|
|
|
|
+ 'saturday'=>false,
|
|
|
|
+ 'sunday'=>false,
|
|
|
|
+ ]
|
|
|
|
+ ];
|
|
|
|
+ if($role == 2){
|
|
|
|
+ for ($i=0;$i<6;$i++){
|
|
|
|
+ for($j=0;$j<=2;$j++){
|
|
|
|
+ $is_self_have = WeekSchedule::where(['docter_id'=>$docter_id,'schedule_type'=>$type,'organization_id'=>$org_id,'week'=>$i+1])->whereIn('time_period_id',$times[$j])->count();
|
|
|
|
+ $is_other_have = WeekSchedule::where(['docter_id'=>$docter_id,'schedule_type'=>$type,'week'=>$i+1])->where('organization_id','!=',$org_id)->whereIn('time_period_id',$times[$j])->count();
|
|
|
|
+ if($is_self_have){
|
|
|
|
+ $data[$j][$week_arr[$i]] = true;
|
|
|
|
+ }
|
|
|
|
+ if($is_other_have){
|
|
|
|
+ $data[$j][$week_arr[$i]] = 'other';
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ for ($i=0;$i<6;$i++){
|
|
|
|
+ for($j=0;$j<=2;$j++){
|
|
|
|
+ $is_self_have = WeekSchedule::where(['docter_id'=>$docter_id,'schedule_type'=>$type,'organization_id'=>$org_id,'week'=>$i+1])->whereIn('time_period_id',$times[$j])->count();
|
|
|
|
+ $is_other_have = WeekSchedule::where(['docter_id'=>$docter_id,'schedule_type'=>$type,'week'=>$i+1])->where('docter_id','!=',$docter_id)->whereIn('time_period_id',$times[$j])->count();
|
|
|
|
+ if($is_self_have){
|
|
|
|
+ $data[$j][$week_arr[$i]] = true;
|
|
|
|
+ }
|
|
|
|
+ if($is_other_have){
|
|
|
|
+ $data[$j][$week_arr[$i]] = 'other';
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $name = Docter::where('id',$docter_id)->value('name');
|
|
|
|
+
|
|
|
|
+ $shcedule_data['docter'] = $data;
|
|
|
|
+ $shcedule_data['name'] = $name;
|
|
|
|
+
|
|
|
|
+ $shcedule_data['role'] = $role;
|
|
|
|
+ $shcedule_data['user_id'] = $docter_id;
|
|
|
|
+
|
|
|
|
+ return apiReturn(200,'ok',$shcedule_data);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //设置周排班模板
|
|
|
|
+ public function setWeekSchedule()
|
|
|
|
+ {
|
|
|
|
+ $docter_id = request('docter_id',1);
|
|
|
|
+ $org_id = request('org_id',1);
|
|
|
|
+ $type = request('type',2);
|
|
|
|
+ if(empty($docter_id) || empty($org_id) || empty($type)){
|
|
|
|
+ return apiReturn(601,'缺少必要参数');
|
|
|
|
+ }
|
|
|
|
+ $docter_setting = DocterSetting::where(['docter_id'=>$docter_id])->first();
|
|
|
|
+ $data = [
|
|
|
|
+ [
|
|
|
|
+ 'date'=>"上午",
|
|
|
|
+ 'monday'=>false,
|
|
|
|
+ 'tuesday'=>true,
|
|
|
|
+ 'wednesday'=>false,
|
|
|
|
+ 'thursday'=>false,
|
|
|
|
+ 'friday'=>true,
|
|
|
|
+ 'saturday'=>false,
|
|
|
|
+ 'sunday'=>false,
|
|
|
|
+ ],
|
|
|
|
+ [
|
|
|
|
+ 'date'=>"下午",
|
|
|
|
+ 'monday'=>false,
|
|
|
|
+ 'tuesday'=>false,
|
|
|
|
+ 'wednesday'=>false,
|
|
|
|
+ 'thursday'=>false,
|
|
|
|
+ 'friday'=>false,
|
|
|
|
+ 'saturday'=>true,
|
|
|
|
+ 'sunday'=>false,
|
|
|
|
+ ],
|
|
|
|
+ [
|
|
|
|
+ 'date'=>"晚上",
|
|
|
|
+ 'monday'=>true,
|
|
|
|
+ 'tuesday'=>true,
|
|
|
|
+ 'wednesday'=>false,
|
|
|
|
+ 'thursday'=>false,
|
|
|
|
+ 'friday'=>false,
|
|
|
|
+ 'saturday'=>false,
|
|
|
|
+ 'sunday'=>false,
|
|
|
|
+ ]
|
|
|
|
+ ];
|
|
|
|
+ if(!empty($docter_setting)){
|
|
|
|
+ $time_period = object_array(json_decode($docter_setting->service_time));
|
|
|
|
+ $times[] = TimePeriod::where(['docter_id'=>$docter_id])->whereBetween('end_time_period',[intval($time_period[0]['startTime']),intval($time_period[0]['endTime'])])->pluck('id')->toArray();
|
|
|
|
+ $times[] = TimePeriod::where(['docter_id'=>$docter_id])->whereBetween('end_time_period',[intval($time_period[1]['startTime']),intval($time_period[1]['endTime'])])->pluck('id')->toArray();
|
|
|
|
+ $times[] = TimePeriod::where(['docter_id'=>$docter_id])->whereBetween('end_time_period',[intval($time_period[2]['startTime']),intval($time_period[2]['endTime'])])->pluck('id')->toArray();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ $week_data = [
|
|
|
|
+ 'schedule_type'=>$type,
|
|
|
|
+ 'organization_id'=>$org_id,
|
|
|
|
+ 'docter_id'=>$docter_id
|
|
|
|
+ ];
|
|
|
|
+ $k = 0;
|
|
|
|
+ DB::beginTransaction();
|
|
|
|
+// $data[0] = array_values(object_array(json_decode($data[0])));
|
|
|
|
+// $data[1] = array_values(object_array(json_decode($data[1])));
|
|
|
|
+// $data[2] = array_values(object_array(json_decode($data[2])));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ $data[0] = array_values($data[0]);
|
|
|
|
+ $data[1] = array_values($data[1]);
|
|
|
|
+ $data[2] = array_values($data[2]);
|
|
|
|
+ try {
|
|
|
|
+ for($i=0;$i<=2;$i++){
|
|
|
|
+ $schedule_data = $data[$i];
|
|
|
|
+ foreach ($schedule_data as $key=>$schedule){
|
|
|
|
+ if($key == 0) continue;
|
|
|
|
+ $week_data ['type'] = $i+1;
|
|
|
|
+ $week_data ['week'] = $key;
|
|
|
|
+ if($schedule == true){
|
|
|
|
+// echo '时间列类型'.($i+1).'----'.$key.'星期数'.'<br>';
|
|
|
|
+ foreach ($times[$i] as $id){
|
|
|
|
+ $week_data['time_period_id'] = $id;
|
|
|
|
+ $is_have = WeekSchedule::where(['docter_id'=>$docter_id,'organization_id'=>$org_id,'schedule_type'=>$type,'type'=>$i+1,'week'=>$key])->where('time_period_id',$id)->value('id');
|
|
|
|
+ $is = $is_have?'有':'沒有';
|
|
|
|
+// echo '时间段id'.$id.'----'.$is.'</br>';
|
|
|
|
+ if($is_have) continue;
|
|
|
|
+ $k++;
|
|
|
|
+ WeekSchedule::insert($week_data);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ $is_have = WeekSchedule::where(['docter_id' => $docter_id, 'organization_id' => $org_id, 'schedule_type' => $type,'type'=>$i+1,'week'=>$key])->whereIn('time_period_id', $times[$i])->value('id');
|
|
|
|
+ if($is_have) WeekSchedule::where(['docter_id' => $docter_id, 'organization_id' => $org_id, 'schedule_type' => $type,'type'=>$i+1,'week'=>$key])->whereIn('time_period_id', $times[$i])->delete();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ DB::commit();
|
|
|
|
+ } catch (\Exception $e){
|
|
|
|
+ DB::rollBack();
|
|
|
|
+ return apiReturn(602,$e->getLine().'行'.$e->getMessage());
|
|
|
|
+ }
|
|
|
|
+ return apiReturn(200,'ok',$k);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function setmonthScheduel()
|
|
|
|
+ {
|
|
|
|
+ $docter_id = request('docter_id',1);
|
|
|
|
+ $org_id = request('org_id',1);
|
|
|
|
+ $type = request('type',2);
|
|
|
|
+ $role = request('role',2);
|
|
|
|
+ $date = request('date');
|
|
|
|
+ if(empty($docter_id) || empty($type)){
|
|
|
|
+ return apiReturn(604,'缺少必要参数');
|
|
|
|
+ }
|
|
|
|
+ $start_time = date('Y-m-d', strtotime($date));
|
|
|
|
+ $end_time = date('Y-m-d',strtotime($date.'+1 month'));
|
|
|
|
+ $self_schedule = SelfSchedule::where(['docter_id'=>$docter_id,'organization_id'=>$org_id])->whereBetween('schedule_date',[$start_time,$end_time])->get()->GroupBy('week')->toArray();
|
|
|
|
+ $week_schedule = WeekSchedule::where(['docter_id'=>$docter_id,'organization_id'=>$org_id])->orderby('week')->distinct('type')->get(['type','week'])->GroupBy('week')->toArray();
|
|
|
|
+ dd($week_schedule);
|
|
|
|
+ $data = $this->getWeekSchedule();
|
|
|
|
+ }
|
|
}
|
|
}
|