|
|
|
|
@ -53,6 +53,7 @@ class PlanController extends Controller
|
|
|
|
|
public function CancelUsePlan()
|
|
|
|
|
{
|
|
|
|
|
$id =request('id');
|
|
|
|
|
$appointment_number = request('appointment_number');
|
|
|
|
|
$plan=DB::table('plans')->where('id',$id)->first();
|
|
|
|
|
if(!$plan) return \Yz::echoError1("该号源不存在");
|
|
|
|
|
if($plan->status<>2) return \Yz::echoError1("该号源未被占用,无需撤销");
|
|
|
|
|
@ -67,10 +68,40 @@ class PlanController extends Controller
|
|
|
|
|
}
|
|
|
|
|
$u=DB::table('plans')->where(['id'=>$id])->update(['status'=>1]);
|
|
|
|
|
if($u){
|
|
|
|
|
return \Yz::Return(true,'撤销占用成功',['id'=>$id]);
|
|
|
|
|
$msg='撤销占用成功';
|
|
|
|
|
if(isset($appointment_number) and !empty($appointment_number)){
|
|
|
|
|
$tj_del= $this->TjDelete($appointment_number);
|
|
|
|
|
$msg=isset($tj_del['msg'])?$msg.'. 附带通知删除订单:'.$tj_del['msg']:$msg;
|
|
|
|
|
}
|
|
|
|
|
return \Yz::Return(true,$msg,['id'=>$id]);
|
|
|
|
|
}else{
|
|
|
|
|
return \Yz::echoError1("操作失败");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public function TjDelete($appointment_number)
|
|
|
|
|
{
|
|
|
|
|
$order=DB::table('orders')->where(['appointment_number' => $appointment_number])->first();
|
|
|
|
|
if(!!$order){
|
|
|
|
|
if(strpos($order->source, '线下体检预约') === false){
|
|
|
|
|
return ['status'=>false,'msg'=>'非线下预约订单,不能进行删除','data'=>null];
|
|
|
|
|
}
|
|
|
|
|
if($order->status !==1){
|
|
|
|
|
return ['status'=>false,'msg'=>'订单非待预约状态,禁止删除','data'=>null];
|
|
|
|
|
}
|
|
|
|
|
$orderJson = json_encode($order, JSON_UNESCAPED_UNICODE);
|
|
|
|
|
$insert=DB::table('orders_delete')->insert(['order_info' =>$orderJson]);
|
|
|
|
|
if($insert){
|
|
|
|
|
$del=DB::table('orders')->where(['id' => $order->id])->delete();
|
|
|
|
|
if($del){
|
|
|
|
|
return ['status'=>true,'msg'=>'通知删除成功','data'=>['appointment_number' => $appointment_number]];
|
|
|
|
|
}else{
|
|
|
|
|
return ['status'=>false,'msg'=>'删除失败','data'=>null];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
return ['status'=>false,'msg'=>'预约Id不存在','data'=>null];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|