public async Task <dynamic> ReservateDoctor([FromBody] ReservateDoctorModel model) { try { if (!ModelState.IsValid) { throw new ModelStateException(ModelState); } if (!model.OpId.HasValue) { model.OpId = TryGet <int?>(() => UserSelf.OpId); model.OpMan = TryGet <string>(() => UserSelf.OpManFullMsg); } //姓名 var cust = await _cusSvr.GetCustomerById(model.CustomerId); //科室 var depart = _stationSvr.GetDepartmentById(model.DepartmentId); //医生 var doctor = _docrSvr.Find(model.DoctorId); var workInfo = _docrSvr.GetDoctorOnDutyInfo(model.DoctorId, model.DepartmentId, model.ReservationDate, model.ReservationSlot); var timestr = $"{workInfo.FromTime?.ToString(@"hh\:mm")}—{workInfo.ToTime?.ToString(@"hh\:mm")}"; var add = await _resSvr.AddOneRegister(cust.CustomerID, depart.DepartmentID, model.DoctorId, depart.StationID.Value, model.ReservationDate, model.ReservationSlot, RegistFrom.V20Web , opId : model.OpId, opMan : model.OpMan, rxDoctorId : model.RxDoctorId ); //给用户发送短信 StringBuilder b = new StringBuilder(); b.Append($"尊敬的{cust.CustomerName},请于{model.ReservationDate.ToString("yyyy年MM月dd日")} {timestr} 至{depart.DepartmentName}({doctor.DoctorName})医生处就诊,感谢您的预约。【天使健康】"); Codes.Utility.SMS sms = new Codes.Utility.SMS(); //await new SendVCodeCBL(this).SendVCode(cust.Telephone, b.ToString()); var rlt = await sms.PostSmsInfoAsync(cust.CustomerMobile, b.ToString()); var d = MyDynamicResult(true, ""); d.rltCode = add.HaveRegisted ? "REPET_REGIST" : ""; d.registStatus = add.HaveRegisted ? "请注意,您已经预约了,不能重复预约。先前预约信息如下。" : ""; d.registerId = add.RegisterID; d.registerSeq = add.RegisterSeq; d.customerId = cust.CustomerID; d.customerName = cust.CustomerName; d.customerGender = cust.Gender; d.customerBirthday = cust.Birthday; d.customerPicUrl = cust.PhotoUrlDef.ahDtUtil().GetCustomerImg(cust.Gender); d.stationName = depart.StationName; d.departmentName = depart.DepartmentName; d.doctorName = doctor.DoctorName; d.doctorGender = doctor.Gender; d.doctorTitle = doctor.PostTitleName; d.doctorId = doctor.DoctorId; d.doctorPicUrl = doctor.DoctorPhotoUrl.ahDtUtil().GetDoctorImg(doctor.Gender, imgSizeTypes.HorizThumb); d.reservationDate = model.ReservationDate.ToString("yyyy-MM-dd"); d.timeInfo = timestr; return(d); } catch (Exception ex) { return(MyDynamicResult(ex)); } }
/// <summary> /// 手机预约信息,并返回给用户 /// <returns>成功则返回用户信息</returns> /// </summary> public async Task <IActionResult> Json_GetReservationInfo(int customerID, int departmentID, int doctorId, DateTime reservationDate, int reservationSlot, int?registOpId = null, string registOpMan = "", int?rxDoctorId = null) { try { if (!registOpId.HasValue) { try { registOpId = UserSelf.OpId; registOpMan = UserSelf.OpManFullMsg; } catch { } } //var u = UserLoginData; //姓名 var cust = _db.CHIS_Code_Customer.FirstOrDefault(m => m.CustomerID == customerID); //科室 var depart = _db.vwCHIS_Code_Department.FirstOrDefault(m => m.DepartmentID == departmentID); if (depart == null) { throw new Exception("科室没有找到"); } //医生 var employee = _db.vwCHIS_Code_Doctor.FirstOrDefault(m => m.DoctorId == doctorId); var workInfo = new DoctorCBL(this).GetEmployeeOnDutyInfo(doctorId, reservationDate, reservationSlot); if (workInfo == null) { workInfo = new DoctorCBL(this).InitalEmployeeOnDutyInfo(doctorId, depart.DepartmentID, reservationDate, reservationDate.AddDays(7)).FirstOrDefault(); } var timestr = $"{workInfo.FromTime?.ToString(@"hh\:mm")}—{workInfo.ToTime?.ToString(@"hh\:mm")}"; var add = await _resSvr.AddOneRegister(cust.CustomerID, depart.DepartmentID, doctorId, depart.StationID.Value, reservationDate, reservationSlot, RegistFrom.V20Web , opId : registOpId, opMan : registOpMan, rxDoctorId : rxDoctorId ); //给用户发送短信 StringBuilder b = new StringBuilder(); b.Append($"尊敬的{cust.CustomerName},请于{reservationDate.ToString("yyyy年MM月dd日")} {timestr} 至{depart.DepartmentName}({employee.DoctorName})医生处就诊,感谢您的预约。【天使健康】"); Codes.Utility.SMS sms = new Codes.Utility.SMS(); //await new SendVCodeCBL(this).SendVCode(cust.Telephone, b.ToString()); var rlt = await sms.PostSmsInfoAsync(cust.CustomerMobile, b.ToString()); return(Json(new { rlt = true, msg = "", rltCode = add.HaveRegisted ? "REPET_REGIST" : "", registStatus = add.HaveRegisted ? "请注意,您已经预约了,不能重复预约。先前预约信息如下。" : "", registerId = add.RegisterID, registerSeq = add.RegisterSeq, customer = cust, stationName = depart.StationName, departmentName = depart.DepartmentName, employee = employee, reservationDate = reservationDate.ToString("yyyy-MM-dd"), timeInfo = timestr })); } catch (Exception ex) { return(Json(new { rlt = false, msg = ex.Message })); } }