Beispiel #1
0
        ///// <summary>
        ///// 作者:Ark
        ///// 时间:2014-07-31
        ///// 描述:用户预订课
        ///// </summary>
        ///// <param name="userId">(学员)用户编号</param>        
        ///// <param name="productLevelId">产品级别编号(当前排课)</param>
        ///// <param name="arrangeCourseId">排课编号</param>
        ///// <param name="bookUserId">订课人编号</param>
        ///// <returns></returns>
        //public ResultTiper BookCourseByUserId(int userId, int productLevelId, int arrangeCourseId, int bookUserId)
        //{
        //    return BookCourseByUserId(userId, productLevelId, arrangeCourseId, bookUserId, false);
        //}
        /// <summary>
        /// 作者:Ark
        /// 时间:2014-07-31
        /// 描述:用户退订课
        /// 更新时间:2015-07-06
        /// 作者:kylin
        /// 描述:添加微信提醒
        /// </summary>
        /// <param name="bookRecordId"></param>
        /// <param name="unBookUserId"></param>
        /// <param name="unBookReason"></param>
        /// <returns></returns>
        public string UnBookCourseByUserId(string unbookCourseParams)
        {
            try
            {
                var nextBookSuccessStudentIds = new List<int>();
                var sendWebChatMsgFlag = true;
                var unbookCourseModel = JsonHelper.FromJson<UnbookCourseModel>(unbookCourseParams);
                var ret = StudyBLL.UnBookRecord(unbookCourseModel.BookRecordId,
                    unbookCourseModel.UnBookUserId,
                    unbookCourseModel.UnBookReason,
                    unbookCourseModel.IsForce,
                    ref nextBookSuccessStudentIds,
                    ConvertEnum.BookSourceForEmeMini); // false默认不强制退订

                if (ret.Status == 100 && nextBookSuccessStudentIds.Any())
                {

                    var bookRecordInfo = StudyBLL.GetBookRecordById(unbookCourseModel.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);

                        var sendMsg = string.Format("亲,您排队预定的课程已经预定成功。课程:{0} 时间:{1}  教师:{2}  教室:{3}。我们的老师将会等候您的到来,记得要准时出席哦!",
                   currCourse, openCourseTime, teachInfo, classroomName);

                        #region 添加webChat 提醒功能!

                        //微信服务号提醒
                        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"]);
                        SysLogHelper.LogInfo("SendWebChatMessage_End");

                        #endregion
                    }
                }

                return JsonHelper.ToJson(new
                {
                    ResultCode = ret.Status == 100 ? "000000" : string.Format("000{0}", ret.Status),
                    ResultMessage = string.Format("{0} {1}", ret.Msg, (sendWebChatMsgFlag && ret.Status == 100) ? "微信通知成功" : "微信通知失败")
                });
            }
            catch (Exception ex)
            {
                SysLogHelper.LogInfo("eme系统异常========Start:>");

                SysLogHelper.LogInfo("Erro Request Params:>");
                SysLogHelper.LogInfo(unbookCourseParams);

                SysLogHelper.LogInfo("Erro Message:>");
                SysLogHelper.LogInfo(ex.Message);
                SysLogHelper.LogInfo("InnerException:>");
                SysLogHelper.LogInfo(ex.Message);
                SysLogHelper.LogInfo("StackTrace:>");
                SysLogHelper.LogInfo(ex.StackTrace);

                return JsonHelper.ToJson(new
                {
                    ResultCode = string.Format("000111"),
                    ResultMessage = string.Format("eme系统异常,Message:{0};InnerException:{1};StackTrace:{2}", ex.Message, ex.InnerException, ex.StackTrace)
                });
            }
        }
        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);
        }
Beispiel #3
0
        ///// <summary>
        ///// 作者:Ark
        ///// 时间:2014-07-31
        ///// 描述:用户预订课
        ///// </summary>
        ///// <param name="userId">(学员)用户编号</param>        
        ///// <param name="productLevelId">产品级别编号(当前排课)</param>
        ///// <param name="arrangeCourseId">排课编号</param>
        ///// <param name="bookUserId">订课人编号</param>
        ///// <returns></returns>
        //public ResultTiper BookCourseByUserId(int userId, int productLevelId, int arrangeCourseId, int bookUserId)
        //{
        //    return BookCourseByUserId(userId, productLevelId, arrangeCourseId, bookUserId, false);
        //}
        /// <summary>
        /// 作者:Ark
        /// 时间:2014-07-31
        /// 描述:用户退订课
        /// 更新时间:2015-07-06
        /// 作者:kylin
        /// 描述:添加微信提醒
        /// </summary>
        /// <param name="bookRecordId"></param>
        /// <param name="unBookUserId"></param>
        /// <param name="unBookReason"></param>
        /// <returns></returns>
        public string UnBookCourseByUserId(string unbookCourseParams)
        {
            var nextBookSuccessStudentIds = new List<int>();
            var sendWebChatMsgFlag = false;
            var unbookCourseModel = JsonHelper.FromJson<UnbookCourseModel>(unbookCourseParams);
            var ret = StudyBLL.UnBookRecord(unbookCourseModel.BookRecordId,
                unbookCourseModel.UnBookUserId,
                unbookCourseModel.UnBookReason,
                unbookCourseModel.IsForce,
                ref nextBookSuccessStudentIds,
                ConvertEnum.BookSourceForEmeMini); // false默认不强制退订

            if (ret.Status == 100 && nextBookSuccessStudentIds.Any())
            {

                var bookRecordInfo = StudyBLL.GetBookRecordById(unbookCourseModel.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);

                    var sendMsg = string.Format("亲,您排队预定的课程已经预定成功。课程:{0} 时间:{1}  教师:{2}  教室:{3}。我们的老师将会等候您的到来,记得要准时出席哦!",
               currCourse, openCourseTime, teachInfo, classroomName);

                    #region 添加webChat 提醒功能!

                    sendWebChatMsgFlag = false;
                    var userBranchIds = UserBLL.GetUserBranch(userInfo.UserId);
                    foreach (var branchId in userBranchIds)
                    {
                        if (Global.WebChatServiceBranchIds.Contains(CommonHelper.To<string>(branchId.BranchId)))
                        {
                            sendWebChatMsgFlag = true;
                            break;
                        }
                    }

                    if (sendWebChatMsgFlag) //针对试点中心尝试方式 服务号提醒
                    {
                        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"] == "Fale")
                        {
                            sendWebChatMsgFlag = false;
                        }

                        SysLogHelper.LogInfo("SendWebChatMessage_Start");
                        SysLogHelper.LogInfo(sendParam);
                        SysLogHelper.LogInfo("Result:" + sendWebChatMsgResult["ResultMessage"]);
                        SysLogHelper.LogInfo("SendWebChatMessage_End");
                    }
                    #endregion
                }
            }

            return JsonHelper.ToJson(new
            {
                ResultCode = ret.Status == 100 ? "000000" : string.Format("000{0}", ret.Status),
                ResultMessage = string.Format("msg:{0} alertRes:{1}", ret.Msg, sendWebChatMsgFlag ? "微信通知成功" : "微信通知成功")
            });
        }