public JsonResult UnBookRecord(FormCollection fc) { var nextBookSuccessStudentIds = new List<int>(); var bookRecordId = Utility.CommonHelper.To<int>(fc["UnBookRecordId"]); var unbookReason = fc["UnBookRecordReason"]; var result = StudyBLL.UnBookRecord(bookRecordId, LoginUserManager.CurrLoginUser.UserId, unbookReason, false, ref nextBookSuccessStudentIds); //发送排队学员订课成功短信 if (result.Status == 100 && nextBookSuccessStudentIds.Any()) { var bookRecordInfo = StudyBLL.GetBookRecordById(bookRecordId); var arrangeCourseInfo = StudyBLL.GetArrangeCourseById(bookRecordInfo.ArrangeCourseId); var classroomName = string.Empty; //课程 var currCourse = string.Format("{0} {1}", arrangeCourseInfo.ProductLevelCourseTypeCourse.ProductLevelCourseType.ProductLevel.EName, arrangeCourseInfo.ProductLevelCourseTypeCourse.Course.CName); //上课时间 var openCourseTime = string.Format("{0} {1} {2}-{3}", arrangeCourseInfo.BeginTime.ToString("MM-dd"), Eme.Utility.DateTimeHelper.GetCnWeekByDateTime(arrangeCourseInfo.BeginTime), arrangeCourseInfo.BeginTime.ToString("HH:mm"), arrangeCourseInfo.EndTime.ToString("HH:mm")); //教师 var teachInfo = string.Empty; foreach (var tr in arrangeCourseInfo.TeachRecord.Where(p => p.Status == ConvertEnum.StatusTypeForActive)) { foreach (var tu in tr.Teacher.User.UserInfo) { teachInfo = string.Format("{0} {1}", tu.EName, tu.CName == tu.EName ? "" : tu.CName).Trim().Split(' ')[0]; } } //教室 if (!string.IsNullOrWhiteSpace(arrangeCourseInfo.Classroom.ClassroomName)) { classroomName = arrangeCourseInfo.Classroom.ClassroomName; } else { classroomName = "网络课程"; } foreach (var bookStudentId in nextBookSuccessStudentIds) { var userInfo = UserBLL.GetUserInfoByStudentId(bookStudentId); var studentInfo = StudentBLL.GetStudentById(bookStudentId); //开始发送站内消息 if (studentInfo.SA != null) { EmeBLL.CreateMessageForQueueBooking(bookRecordId, userInfo.Mobile.Trim(), studentInfo.SA, bookStudentId); } else { EmeBLL.CreateMessageForQueueBooking(bookRecordId, userInfo.Mobile.Trim(), studentInfo.CC, bookStudentId); } var sendMsg = string.Format("亲,您排队预定的课程已经预定成功。课程:{0} 时间:{1} 教师:{2} 教室:{3}。我们的老师将会等候您的到来,记得要准时出席哦!", currCourse, openCourseTime, teachInfo, classroomName); #region 添加webChat 提醒功能! var sendWebChatMsgFlag = true; var webChatApi = new WebChat<Dictionary<string, string>>(); var sendParam = JsonHelper.ToJson(new { // SERVICE_NAME_JSON = "BusiWXSendWechatMassage", UserPhone = userInfo.Mobile.Trim(), Content = sendMsg, KEY = Global.WebChatServiceKey }); var sendWebChatMsgResult = webChatApi.Send(Global.WebChatServiceUrl, sendParam); if (sendWebChatMsgResult["ResultCode"].Equals("false", StringComparison.CurrentCultureIgnoreCase)) { sendWebChatMsgFlag = false; } SysLogHelper.LogInfo("SendWebChatMessage_Start"); SysLogHelper.LogInfo(sendParam); SysLogHelper.LogInfo("Result:" + sendWebChatMsgResult["ResultMessage"] + " send webchat flag:" + sendWebChatMsgFlag); SysLogHelper.LogInfo("SendWebChatMessage_End"); #endregion //if (!sendWebChatMsgFlag) { List<SmsModel> smsList = new List<SmsModel>(); smsList.Add(new SmsModel { SystemCode = "EME", RecordId = bookRecordId.ToString(), Mobile = userInfo.Mobile.Trim(), Serial = "890", Message = sendMsg, SmsId = DateTime.Now.Ticks }); ISmsApi sms = new SmsApi(); SmsResult ret = sms.Send(smsList); var logmsg = JsonHelper.ToJson(smsList); //增加日志 SysLogHelper.LogInfo("SendSms_Start"); SysLogHelper.LogInfo(logmsg); SysLogHelper.LogInfo("Result:" + ret.Msg); SysLogHelper.LogInfo("SendSms_End"); } ////开始发送短信 //if (!string.IsNullOrWhiteSpace(userInfo.Mobile)) //{ // List<SmsModel> smsList = new List<SmsModel>(); // smsList.Add(new SmsModel // { // SystemCode = "EME", // RecordId = bookRecordId.ToString(), // Mobile = userInfo.Mobile.Trim(), // Serial = "890", // Message = "亲,您排队预定的课程已经预定成功。课程:" + currCourse + // " 时间:" + openCourseTime + " 教师:" + teachInfo + " 教室:" + classroomName + // "。我们的老师将会等候您的到来,记得要准时出席哦!", // SmsId = DateTime.Now.Ticks // }); //ISmsApi sms = new SmsApi(); //SmsResult ret = sms.Send(smsList); ////增加日志 //var logmsg = JsonHelper.ToJson(smsList); //SysLogHelper.LogInfo("SendSms_Start"); //SysLogHelper.LogInfo(logmsg); //SysLogHelper.LogInfo("Result:" + ret.Msg); //SysLogHelper.LogInfo("SendSms_End"); //} } } return Json(new { status = result.Status == 100 }, JsonRequestBehavior.DenyGet); }
public bool UnBookRecord(int bookRecordId) { var nextBookSuccessStudentIds = new List<int>(); var unbookReason = "换门类退订"; var result = StudyBLL.UnBookRecord(bookRecordId, LoginUserManager.CurrLoginUser.UserId, unbookReason, false, ref nextBookSuccessStudentIds); //发送排队学员订课成功短信 if (result.Status == 100 && nextBookSuccessStudentIds.Any()) { var bookRecordInfo = StudyBLL.GetBookRecordById(bookRecordId); var arrangeCourseInfo = StudyBLL.GetArrangeCourseById(bookRecordInfo.ArrangeCourseId); var classroomName = string.Empty; //课程 var currCourse = string.Format("{0} {1}", arrangeCourseInfo.ProductLevelCourseTypeCourse.ProductLevelCourseType.ProductLevel.EName, arrangeCourseInfo.ProductLevelCourseTypeCourse.Course.CName); //上课时间 var openCourseTime = string.Format("{0} {1} {2}-{3}", arrangeCourseInfo.BeginTime.ToString("MM-dd"), Eme.Utility.DateTimeHelper.GetCnWeekByDateTime(arrangeCourseInfo.BeginTime), arrangeCourseInfo.BeginTime.ToString("HH:mm"), arrangeCourseInfo.EndTime.ToString("HH:mm")); //教师 var teachInfo = string.Empty; foreach (var tr in arrangeCourseInfo.TeachRecord.Where(p => p.Status == ConvertEnum.StatusTypeForActive)) { foreach (var tu in tr.Teacher.User.UserInfo) { teachInfo = string.Format("{0} {1}", tu.EName, tu.CName == tu.EName ? "" : tu.CName).Trim().Split(' ')[0]; } } //教室 if (!string.IsNullOrWhiteSpace(arrangeCourseInfo.Classroom.ClassroomName)) { classroomName = arrangeCourseInfo.Classroom.ClassroomName; } else { classroomName = "网络课程"; } foreach (var bookStudentId in nextBookSuccessStudentIds) { var userInfo = UserBLL.GetUserInfoByStudentId(bookStudentId); var studentInfo = StudentBLL.GetStudentById(bookStudentId); //开始发送站内消息 if (studentInfo.SA != null) { EmeBLL.CreateMessageForQueueBooking(bookRecordId, userInfo.Mobile.Trim(), studentInfo.SA, bookStudentId); } else { EmeBLL.CreateMessageForQueueBooking(bookRecordId, userInfo.Mobile.Trim(), studentInfo.CC, bookStudentId); } //开始发送短信 if (!string.IsNullOrWhiteSpace(userInfo.Mobile)) { List<SmsModel> smsList = new List<SmsModel>(); smsList.Add(new SmsModel { SystemCode = "EME", RecordId = bookRecordId.ToString(), Mobile = userInfo.Mobile.Trim(), Serial = "890", Message = "亲,您排队预定的课程已经预定成功。课程:" + currCourse + " 时间:" + openCourseTime + " 教师:" + teachInfo + " 教室:" + classroomName + "。我们的老师将会等候您的到来,记得要准时出席哦!", SmsId = DateTime.Now.Ticks }); ISmsApi sms = new SmsApi(); SmsResult ret = sms.Send(smsList); //增加日志 var logmsg = JsonHelper.ToJson(smsList); SysLogHelper.LogInfo("SendSms_Start"); SysLogHelper.LogInfo(logmsg); SysLogHelper.LogInfo("Result:" + ret.Msg); SysLogHelper.LogInfo("SendSms_End"); } } } return true; }