示例#1
0
        /// <summary>
        /// 订单详情页-付款页
        /// 如果订单超时未支付,再次购买时,不用考虑上个订单是不是从点击广告来的。
        /// </summary>
        /// <param name="id">订单Id</param>
        /// <returns></returns>
        public ActionResult Payment(int id = 0)
        {
            if (id == 0)
            {
                //跳转到订单列表页
                return(RedirectToAction("OwnOrderList"));
            }
            int studentId = GetCurrentUser().StudentId;

            StudentOrderBll            studentOrderBll   = new StudentOrderBll();
            DtoSelectCenterOrderResult courseOrderResult = studentOrderBll.GetOrderInfoForPayment(studentId, id);

            if (courseOrderResult.OrderStatus.Equals((int)StudentOrderStatus.待支付) || courseOrderResult.OrderStatus.Equals((int)StudentOrderStatus.支付中))
            {
                PaymentViewModel model = courseOrderResult.ConvertTo <PaymentViewModel>();
                if (string.IsNullOrEmpty(model.CourseImage))
                {
                    model.CourseImage = defaultCourseImg;
                }
                return(View(model));
            }
            else
            {
                return(RedirectToAction("OrderDetail", new { id = courseOrderResult.OrderId }));
            }
        }
示例#2
0
        /// <summary>
        /// 订单详情页
        /// </summary>
        /// <param name="id">订单Id</param>
        /// <returns></returns>
        public ActionResult OrderDetail(int id = 0)
        {
            if (id == 0)
            {
                //跳转到订单列表页
                return(RedirectToAction("OwnOrderList"));
            }
            int studentId = GetCurrentUser().StudentId;

            StudentOrderBll            studentOrderBll   = new StudentOrderBll();
            DtoSelectCenterOrderResult courseOrderResult = studentOrderBll.GetOrderInfoForDetail(studentId, id);

            OrderDetailViewModel model = courseOrderResult.ConvertTo <OrderDetailViewModel>();
            decimal?baseVoucherAmount  = model.OrderVoucherPayList?.FirstOrDefault(v => v.PayType != (int)StudentOrderPaymnentTypeEnum.优惠券_校区券_支付)?.Amount;

            model.BaseVoucherAmount = baseVoucherAmount.HasValue ? baseVoucherAmount.Value : 0;
            decimal?schoolVoucherAmount = model.OrderVoucherPayList?.FirstOrDefault(v => v.PayType == (int)StudentOrderPaymnentTypeEnum.优惠券_校区券_支付)?.Amount;

            model.SchoolVoucherAmount = schoolVoucherAmount.HasValue ? schoolVoucherAmount.Value : 0;

            //防止用户未点击支付按钮,订单表没计算应付金额
            if (model.PayAmount == 0)
            {
                model.PayAmount = model.OrderAmount - model.BaseVoucherAmount - model.SchoolVoucherAmount;
                model.PayAmount = model.PayAmount > 0 ? model.PayAmount : 0;
            }

            if (model.OrderStatus == (int)StudentOrderStatus.待支付 || model.OrderStatus == (int)StudentOrderStatus.支付中 || model.OrderStatus == (int)StudentOrderStatus.已支付)
            {
                model.IsHaveThisCourse = true;
            }
            else
            {
                //查询用户是否已购买此课程
                var oriOrder = studentOrderBll.GetFinishOrder(studentId, model.CourseId);
                if (oriOrder != null && oriOrder.Yod_Id > 0)
                {
                    model.IsHaveThisCourse = true;
                }
                else
                {
                    model.IsHaveThisCourse = false;
                }
            }

            StudentInfoBll studentInfoBll = new StudentInfoBll();
            DtoStudentInfo student        = studentInfoBll.GetStudentInfo(studentId);
            Regex          regex          = new Regex(@"(\d{3})\d{4}(\d{4})");

            model.StudentAccount = regex.Replace(student.Bst_Phone, "$1****$2");
            model.SchoolName     = student.SchoolName;
            if (string.IsNullOrEmpty(model.CourseImage))
            {
                model.CourseImage = defaultCourseImg;
            }

            return(View(model));
        }