|
|
|
@ -33,32 +33,33 @@ class PlanController extends Controller
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$model = DB::table('plan_model as a')->where(['a.id' => $params['model_id'], 'a.is_del' => 0, 'a.status' => 1])->first();
|
|
|
|
$model = DB::table('plan_model as a')->where(['a.id' => $params['model_id'], 'a.is_del' => 0, 'a.status' => 1])->first();
|
|
|
|
if (!$model) return \Yz::echoError1('模板不可用');
|
|
|
|
if (!$model) return \Yz::echoError1('模板不可用');
|
|
|
|
$planType = DB::table('plan_type as a')->where(['a.id' => $model->plan_type, 'a.is_del' => 0, 'a.status' => 1])->first();
|
|
|
|
// $planType = DB::table('plan_type as a')->where(['a.id' => $model->plan_type, 'a.is_del' => 0, 'a.status' => 1])->first();
|
|
|
|
if (!$planType) return \Yz::echoError1('号源类型不可用');
|
|
|
|
// if (!$planType) return \Yz::echoError1('号源类型不可用');
|
|
|
|
//查询此时间段内是否有已经生成的号源
|
|
|
|
//查询此时间段内是否有已经生成的号源
|
|
|
|
$cha=DB::table('plans')->whereBetween('date',$Info['dateRange'])->get();
|
|
|
|
$cha = DB::table('plans')->whereBetween('date', $Info['dateRange'])->get();
|
|
|
|
if(count($cha)>0){
|
|
|
|
if (count($cha) > 0) {
|
|
|
|
return \Yz::return(false,'号源重复',['list'=>$cha]);
|
|
|
|
return \Yz::return(false, '号源重复', ['list' => $cha]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//获取模板的全部时间点
|
|
|
|
//获取模板的全部时间点
|
|
|
|
$s=new TimeService();
|
|
|
|
// $s=new TimeService();
|
|
|
|
$timelist=$s->TimePointsArr($model->start_time,$model->end_time,$model->interval_time);
|
|
|
|
// $timelist=$s->TimePointsArr($model->start_time,$model->end_time,$model->interval_time);
|
|
|
|
if(count($timelist)<1) return \Yz::echoError1('模板时间点不能为空');
|
|
|
|
$timelist = DB::table('plan_model_time')->where(['model_id' => $params['model_id']])->get();
|
|
|
|
|
|
|
|
if (count($timelist) < 1) return \Yz::echoError1('模板时间点不能为空');
|
|
|
|
$startDate = new DateTime($Info['dateRange'][0]);
|
|
|
|
$startDate = new DateTime($Info['dateRange'][0]);
|
|
|
|
$endDate = new DateTime($Info['dateRange'][1]);
|
|
|
|
$endDate = new DateTime($Info['dateRange'][1]);
|
|
|
|
$currentDate = $startDate;
|
|
|
|
$currentDate = $startDate;
|
|
|
|
$success_count=0;
|
|
|
|
$success_count = 0;
|
|
|
|
while ($currentDate <= $endDate) {
|
|
|
|
while ($currentDate <= $endDate) {
|
|
|
|
//循环生成
|
|
|
|
//循环生成
|
|
|
|
$date_ymd=$currentDate->format('Y-m-d');
|
|
|
|
$date_ymd = $currentDate->format('Y-m-d');
|
|
|
|
//判断节假日是否生成
|
|
|
|
//判断节假日是否生成
|
|
|
|
$s_day=DB::table('plan_holiday')->select('*','type as tp')->where(['date'=>$date_ymd])->first();
|
|
|
|
$s_day = DB::table('plan_holiday')->select('*', 'type as tp')->where(['date' => $date_ymd])->first();
|
|
|
|
if(!!$s_day){
|
|
|
|
if (!!$s_day) {
|
|
|
|
if($s_day->tp==1 and $params['workday_create']===0){
|
|
|
|
if ($s_day->tp == 1 and $params['workday_create'] === 0) {
|
|
|
|
$currentDate->modify('+1 day');
|
|
|
|
$currentDate->modify('+1 day');
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($s_day->tp==2 and $params['holiday_create']===0){
|
|
|
|
if ($s_day->tp == 2 and $params['holiday_create'] === 0) {
|
|
|
|
$currentDate->modify('+1 day');
|
|
|
|
$currentDate->modify('+1 day');
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -67,95 +68,145 @@ class PlanController extends Controller
|
|
|
|
//获取星期几 星期1=1 星期日=7
|
|
|
|
//获取星期几 星期1=1 星期日=7
|
|
|
|
$dayOfWeek = $currentDate->format('N');
|
|
|
|
$dayOfWeek = $currentDate->format('N');
|
|
|
|
//如果星期匹配上了
|
|
|
|
//如果星期匹配上了
|
|
|
|
if(in_array($dayOfWeek, $params['week'])) {
|
|
|
|
if (in_array($dayOfWeek, $params['week'])) {
|
|
|
|
foreach ($timelist as $key=>$time){
|
|
|
|
foreach ($timelist as $key => $time) {
|
|
|
|
$type=1; //正常
|
|
|
|
$planType=null;
|
|
|
|
if(in_array($key,json_decode($model->y_number,true))){
|
|
|
|
if(isset( $time->plan_type_id)){
|
|
|
|
$type=0;//预留
|
|
|
|
$planType = DB::table('plan_type as a')->where(['a.id' => $time->plan_type_id, 'a.is_del' => 0, 'a.status' => 1])->first();
|
|
|
|
}
|
|
|
|
if (!$planType) return \Yz::echoError1('号源类型不可用');
|
|
|
|
$data=[
|
|
|
|
}
|
|
|
|
'model_id'=>$model->id,
|
|
|
|
|
|
|
|
'date'=>$date_ymd,
|
|
|
|
|
|
|
|
'week'=>$dayOfWeek,
|
|
|
|
|
|
|
|
'time'=>$time,
|
|
|
|
|
|
|
|
'type'=>$type,
|
|
|
|
|
|
|
|
'plan_number'=>implode('', explode(':', $time)),
|
|
|
|
|
|
|
|
'is_vip'=>$planType->is_vip,
|
|
|
|
|
|
|
|
'use_type'=>$planType->use_type,
|
|
|
|
|
|
|
|
'sex'=>$planType->sex,
|
|
|
|
|
|
|
|
'checkup_type_id'=>$planType->checkup_type_id,
|
|
|
|
|
|
|
|
'amount_limit1'=>$planType->amount_limit1,
|
|
|
|
|
|
|
|
'amount_limit2'=>$planType->amount_limit2,
|
|
|
|
|
|
|
|
'hospital_id'=>$model->hospital_id,
|
|
|
|
|
|
|
|
'status'=>1,
|
|
|
|
|
|
|
|
'is_del'=>0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
];
|
|
|
|
$data = [
|
|
|
|
$i=DB::table('plans')->insert($data);
|
|
|
|
'model_id' => $model->id,
|
|
|
|
if($i){
|
|
|
|
'date' => $date_ymd,
|
|
|
|
$success_count++;
|
|
|
|
'week' => $dayOfWeek,
|
|
|
|
}
|
|
|
|
'time' => $time->time,
|
|
|
|
}
|
|
|
|
'type' => $time->type,
|
|
|
|
|
|
|
|
'plan_number' => implode('', explode(':', $time->time)),
|
|
|
|
|
|
|
|
'is_vip' => empty($planType)?null: $planType->is_vip,
|
|
|
|
|
|
|
|
'use_type' => empty($planType)?null:$planType->use_type,
|
|
|
|
|
|
|
|
'sex' => empty($planType)?null:$planType->sex,
|
|
|
|
|
|
|
|
'checkup_type_id' => empty($planType)?null:$planType->checkup_type_id,
|
|
|
|
|
|
|
|
'amount_limit1' =>empty($planType)?null: $planType->amount_limit1,
|
|
|
|
|
|
|
|
'amount_limit2' =>empty($planType)?null: $planType->amount_limit2,
|
|
|
|
|
|
|
|
'hospital_id' => $model->hospital_id,
|
|
|
|
|
|
|
|
'status' => 1,
|
|
|
|
|
|
|
|
'is_del' => 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
$i = DB::table('plans')->insert($data);
|
|
|
|
|
|
|
|
if ($i) {
|
|
|
|
|
|
|
|
$success_count++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 日期加一天
|
|
|
|
// 日期加一天
|
|
|
|
$currentDate->modify('+1 day');
|
|
|
|
$currentDate->modify('+1 day');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($success_count>0){
|
|
|
|
if ($success_count > 0) {
|
|
|
|
return \Yz::Return(true,'',['success_count'=>$success_count]);
|
|
|
|
return \Yz::Return(true, '', ['success_count' => $success_count]);
|
|
|
|
}else{
|
|
|
|
} else {
|
|
|
|
return \Yz::echoError1('没有计划被创建');
|
|
|
|
return \Yz::echoError1('没有计划被创建');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function GetList()
|
|
|
|
public function GetList()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$page =request('page');
|
|
|
|
$page = request('page');
|
|
|
|
$pageSize =request('pageSize');
|
|
|
|
$pageSize = request('pageSize');
|
|
|
|
$searchInfo=request('searchInfo');
|
|
|
|
$searchInfo = request('searchInfo');
|
|
|
|
$list=DB::table('plans as a')
|
|
|
|
$list = DB::table('plans as a')
|
|
|
|
// ->leftJoin('plan_type as b','a.plan_type','=','b.id')
|
|
|
|
// ->leftJoin('plan_type as b','a.plan_type','=','b.id')
|
|
|
|
// ->select('a.*','b.name as plan_type_name')
|
|
|
|
// ->select('a.*','b.name as plan_type_name')
|
|
|
|
->where(['a.is_del'=>0]);
|
|
|
|
->where(['a.is_del' => 0]);
|
|
|
|
if(!isset($searchInfo['date'])){
|
|
|
|
if (!isset($searchInfo['date'])) {
|
|
|
|
$searchInfo['date']=date('Y-m-d');
|
|
|
|
$searchInfo['date'] = date('Y-m-d');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$list=$list->where(['a.date'=>$searchInfo['date']]);
|
|
|
|
$list = $list->where(['a.date' => $searchInfo['date']]);
|
|
|
|
$count=$list->count();
|
|
|
|
$count = $list->count();
|
|
|
|
$list=$list ->orderBy('a.id', 'asc')->get();
|
|
|
|
$list = $list->orderBy('a.id', 'asc')->get();
|
|
|
|
return \Yz::Return(true,'查询完成',['list'=>$list,'count'=>$count,'date'=> $searchInfo['date']]);
|
|
|
|
return \Yz::Return(true, '查询完成', ['list' => $list, 'count' => $count, 'date' => $searchInfo['date']]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function GetDetail()
|
|
|
|
public function GetDetail()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$id =request('id');
|
|
|
|
$id = request('id');
|
|
|
|
$info=DB::table('plans')->where(['id'=>$id])->first();
|
|
|
|
$info = DB::table('plans')->where(['id' => $id])->first();
|
|
|
|
if(!!$info){
|
|
|
|
if (!!$info) {
|
|
|
|
$info->checkup_type_id=json_decode($info->checkup_type_id,true);
|
|
|
|
if(empty($info->checkup_type_id)){
|
|
|
|
return \Yz::Return(true,'查询完成',['info'=>$info]);
|
|
|
|
$info->checkup_type_id='[]';
|
|
|
|
}else{
|
|
|
|
}
|
|
|
|
|
|
|
|
$info->checkup_type_id = json_decode($info->checkup_type_id, true);
|
|
|
|
|
|
|
|
return \Yz::Return(true, '查询完成', ['info' => $info]);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
return \Yz::echoError1('查询失败');
|
|
|
|
return \Yz::echoError1('查询失败');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//更新保存
|
|
|
|
//更新保存
|
|
|
|
public function Save()
|
|
|
|
public function Save()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$info =request('info');
|
|
|
|
$info = request('info');
|
|
|
|
if(isset($info['id'])){
|
|
|
|
if (isset($info['id'])) {
|
|
|
|
$info['checkup_type_id']= isset($Info['checkup_type_id']) ? json_encode($Info['checkup_type_id']) : null;
|
|
|
|
$info['checkup_type_id'] = isset($info['checkup_type_id']) ? json_encode($info['checkup_type_id']) : null;
|
|
|
|
$u=DB::table('plans')->where(['id'=>$info['id']])->update([
|
|
|
|
|
|
|
|
|
|
|
|
$u = DB::table('plans')->where(['id' => $info['id']])->update([
|
|
|
|
|
|
|
|
'is_vip' => $info['is_vip'],
|
|
|
|
|
|
|
|
'use_type' => $info['use_type'],
|
|
|
|
|
|
|
|
'sex' => $info['sex'],
|
|
|
|
|
|
|
|
'checkup_type_id' => $info['checkup_type_id'],
|
|
|
|
|
|
|
|
'amount_limit1' => $info['amount_limit1'],
|
|
|
|
|
|
|
|
'amount_limit2' => $info['amount_limit2'],
|
|
|
|
|
|
|
|
'status' => $info['status'],
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
if ($u) {
|
|
|
|
|
|
|
|
return \Yz::Return(true, '保存成功', []);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return \Yz::echoError1('操作失败');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//批量更新号源类型
|
|
|
|
|
|
|
|
public function BatchUpdatePlanType(){
|
|
|
|
|
|
|
|
$ids = request('ids');
|
|
|
|
|
|
|
|
$type = request('type');
|
|
|
|
|
|
|
|
$info = request('info');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$cha =DB::table('plans')->whereIn('id', $ids)->where(['status'=>2])->get();
|
|
|
|
|
|
|
|
if(count($cha) >0){
|
|
|
|
|
|
|
|
return \Yz::echoError1('有号源被占用,不能执行此操作');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if($type==0){
|
|
|
|
|
|
|
|
$data=[
|
|
|
|
|
|
|
|
'is_vip'=>null,
|
|
|
|
|
|
|
|
'use_type'=>null,
|
|
|
|
|
|
|
|
'sex'=>null,
|
|
|
|
|
|
|
|
'checkup_type_id'=>[],
|
|
|
|
|
|
|
|
'amount_limit1'=>null,
|
|
|
|
|
|
|
|
'amount_limit2'=>null,
|
|
|
|
|
|
|
|
'type'=>0,
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if($type==1){
|
|
|
|
|
|
|
|
if(empty($info['checkup_type_id'])) return \Yz::echoError1('体检类型不能为空');
|
|
|
|
|
|
|
|
$data=[
|
|
|
|
'is_vip'=>$info['is_vip'],
|
|
|
|
'is_vip'=>$info['is_vip'],
|
|
|
|
'use_type'=>$info['use_type'],
|
|
|
|
'use_type'=>$info['use_type'],
|
|
|
|
'sex'=>$info['sex'],
|
|
|
|
'sex'=>$info['sex'],
|
|
|
|
'checkup_type_id'=>$info['checkup_type_id'],
|
|
|
|
'checkup_type_id'=>$info['checkup_type_id'],
|
|
|
|
'amount_limit1'=>$info['amount_limit1'],
|
|
|
|
'amount_limit1'=>isset($info['amount_limit1'])?$info['amount_limit1']:0,
|
|
|
|
'amount_limit2'=>$info['amount_limit2'],
|
|
|
|
'amount_limit2'=>isset($info['amount_limit2'])?$info['amount_limit2']:0,
|
|
|
|
'status'=>$info['status'],
|
|
|
|
'type'=>1,
|
|
|
|
]);
|
|
|
|
];
|
|
|
|
if($u){
|
|
|
|
|
|
|
|
return \Yz::Return(true,'保存成功',[]);
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
return \Yz::echoError1('操作失败');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$u=DB::table('plans')->whereIn('id', $ids)->update($data);
|
|
|
|
|
|
|
|
if ($u){
|
|
|
|
|
|
|
|
return \Yz::Return(true, '操作成功', []);
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
return \Yz::echoError1('操作失败');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|