/// <summary> /// 学员下订单 /// </summary> public int MakeOrder(int studentId, int courseId) { CourseBll courseBll = new CourseBll(); SchoolBll schoolBll = new SchoolBll(); Yw_Course course = courseBll.GetCourse(courseId); if (course == null || course.Ycs_Status != (int)CourseStatusEnum.已上架) { throw new AbhsException(ErrorCodeEnum.CourseCanNotBuy, AbhsErrorMsg.ConstCourseCanNotBuy); } Bas_School school = schoolBll.GetSchoolByStudent(studentId); if (school == null) { throw new AbhsException(ErrorCodeEnum.StudentNotBindSchool, AbhsErrorMsg.ConstStudentNotBindSchool); } Yw_CoursePrice price = courseBll.GetCoursePrice(courseId, school.Bsl_Level); Yw_StudentOrder order = new Yw_StudentOrder(); order.Yod_CourseId = courseId; order.Yod_OrderNo = GenerateOrderNo(courseId, studentId); order.Yod_OrderTime = DateTime.Now; order.Yod_OrderType = (int)OrderTypeEnum.订单; order.Yod_PayBatchId = 0; order.Yod_ReferOrderId = 0; order.Yod_PayTime = new DateTime(1900, 1, 1); order.Yod_Status = (int)StudentOrderStatus.待支付; order.Yod_StudentId = studentId; order.Yod_UpdateTime = DateTime.Now; order.Yod_Amount = price.Yce_Price; OrderService.Add(order); return order.Yod_Id; }
/// <summary> /// 交易查询 /// </summary> /// <param name="orderId">订单Id</param> /// <param name="payType">支付方式</param> /// <param name="studentId">下单的学生Id</param> /// <returns>如果订单支付成功返回true,否则返回false</returns> public bool OrderQuery(int orderId, CashPayTypeEnum payType, int studentId) { Yw_StudentOrder order = GetStudentOrder(orderId); if (order.Yod_StudentId.Equals(studentId)) { bool result = false; //switch (payType) //{ // case CashPayTypeEnum.微信: // WeChatApi weChatApi = new WeChatApi(); // string outTradeNo = GetOutTradeNo(order.Yod_OrderNo, order.Yod_PayBatchId); // WechatQueryOrderResponse orderQueryResponse = weChatApi.OrderQuery("", orderId, outTradeNo); // if ("SUCCESS".Equals(orderQueryResponse.TradeState)) // { // //以接收微信支付通知为准,此处不再触发支付回调 // //OrderPayCallback(outTradeNo, payType, (decimal)(orderQueryResponse.TotalFee * 1.0 / 100)); // result = true; // } // break; //} result = order.Yod_Status.Equals((int)StudentOrderStatus.已支付); return result; } else { throw new AbhsException(ErrorCodeEnum.NoAuthorize, AbhsErrorMsg.ConstNoAuthorizeViewOrder); } }
/// <summary> /// 选课中心课程详情-预览功能 /// </summary> /// <param name="courseId">课程Id</param> /// <param name="studentId">学生Id</param> /// <returns></returns> public DtoSelectCenterCourseDetailResult GetCourseDetailForPreview(int courseId, int studentId) { DtoSelectCenterCourseDetailResult result = new DtoSelectCenterCourseDetailResult(); DtoCourseSelectCondition condition = new DtoCourseSelectCondition(); condition.StudentId = studentId; DtoSelectCenterCourseDetailObject course = null; Dictionary <string, decimal> voucherDic = null; Yw_StudentOrder order = null; DtoStudentApplySchool applyRecord = null; SchoolBll schBll = new SchoolBll(); Bas_School school = schBll.GetSchoolByStudent(condition.StudentId); if (school != null) { condition.SetSchoolLevel(school.Bsl_Level); condition.SetSchoolId(school.Bsl_Id); course = CourseRepository.GetCourseDetailWithPrice(courseId, condition.SchoolLevel, true); if (course != null && course.CourseId > 0) { DtoSimpleCourse simpleCourse = new DtoSimpleCourse() { CourseId = course.CourseId, Amount = course.CoursePrice, CourseType = course.CourseType, Grade = course.Grade }; voucherDic = GetVoucherDicForUserCourse(new List <DtoSimpleCourse>() { simpleCourse }, condition); //查询用户是否已购买此课程 StudentOrderBll studentOrderBll = new StudentOrderBll(); order = studentOrderBll.GetFinishOrder(condition.StudentId, course.CourseId); } } else { course = CourseRepository.GetCourseDetailWithoutPrice(courseId, true); StudentApplyBll studentApplyBll = new StudentApplyBll(); applyRecord = studentApplyBll.GetApplyByStudentId(condition.StudentId); } if (course != null) { Yw_CourseIntroduction introduction = CourseIntroductionRespository.GetCourseIntroduction(course.CourseId); result = CreateSelectCenterCourseDetailResultItem(course, introduction, school, applyRecord, voucherDic, order); } else { throw new AbhsException(ErrorCodeEnum.CourseNotExists, AbhsErrorMsg.ConstCourseNotExists); } return(result); }
public DtoSelectCenterOrderResult GetOrderInfoForDetail(int studentId, int orderId) { Yw_StudentOrder order = GetStudentOrder(orderId); if (order.Yod_StudentId.Equals(studentId)) { CourseBll courseBll = new CourseBll(); Yw_Course course = courseBll.GetCourse(order.Yod_CourseId); DtoSelectCenterOrderResult result = new DtoSelectCenterOrderResult(); result.StudentId = order.Yod_StudentId; result.CourseId = course.Ycs_Id; result.CourseName = course.Ycs_Name; result.CourseImage = course.Ycs_CoverImage.ToOssPath(); result.Grade = course.Ycs_Grade; result.CourseType = course.Ycs_CourseType; result.LessonCount = course.Ycs_LessonCount; result.Description = course.Ycs_Description; result.OrderId = order.Yod_Id; result.OrderAmount = order.Yod_Amount; result.PayAmount = order.Yod_PayAmount; result.OrderStatus = order.Yod_Status; result.OrderTime = order.Yod_OrderTime; result.OrderNo = order.Yod_OrderNo; List<DtoStudentOrderPay> orderPayList = Service.GetStudentOrderPay(order.Yod_Id, order.Yod_PayBatchId); result.OrderCashPay = orderPayList.FirstOrDefault(p => p.PayType < 200); result.OrderVoucherPayList = orderPayList.Where(p => p.PayType > 200).ToList(); if (result.OrderCashPay != null) { result.PayType = result.OrderCashPay.PayType - 100; result.PayTime = result.OrderCashPay.PayTime; } return result; } else { throw new AbhsException(ErrorCodeEnum.NoAuthorize, AbhsErrorMsg.ConstNoAuthorizeViewOrder); } }
/// <summary> /// 选课中心订单详情页-支付页 /// </summary> /// <param name="studentId">学生Id</param> /// <param name="orderId">订单Id</param> /// <returns></returns> public DtoSelectCenterOrderResult GetOrderInfoForPayment(int studentId, int orderId) { //获取订单信息 //验证订单是否属于当前登录用户 //根据订单Id查询课程信息(名称、图片、年级、课程类型、课时、描述、教材版本) //课程价格显示订单原始金额 Yw_StudentOrder order = GetStudentOrder(orderId); if (order.Yod_StudentId.Equals(studentId)) { CourseBll courseBll = new CourseBll(); Yw_Course course = courseBll.GetCourse(order.Yod_CourseId); DtoSelectCenterOrderResult result = new DtoSelectCenterOrderResult(); result.StudentId = order.Yod_StudentId; result.CourseId = course.Ycs_Id; result.CourseName = course.Ycs_Name; result.CourseImage = course.Ycs_CoverImage.ToOssPath(); result.Grade = course.Ycs_Grade; result.CourseType = course.Ycs_CourseType; result.LessonCount = course.Ycs_LessonCount; result.Description = course.Ycs_Description; result.OrderId = order.Yod_Id; result.OrderAmount = order.Yod_Amount; result.OrderStatus = order.Yod_Status; result.OrderTime = order.Yod_OrderTime; result.OrderNo = order.Yod_OrderNo; return result; } else { throw new AbhsException(ErrorCodeEnum.NoAuthorize, AbhsErrorMsg.ConstNoAuthorizeViewOrder); } }
private DtoSelectCenterCourseDetailResult CreateSelectCenterCourseDetailResultItem(DtoSelectCenterCourseDetailObject obj, Yw_CourseIntroduction introduction, Bas_School school, DtoStudentApplySchool applySchoolRecord = null, Dictionary <string, decimal> voucherDic = null, Yw_StudentOrder order = null) { DtoSelectCenterCourseDetailResult result = new DtoSelectCenterCourseDetailResult(); result.IsBindSchool = (school != null && school.Bsl_Id > 0) ? true : false; result.CourseId = obj.CourseId; result.CourseImage = obj.CourseImage.ToOssPath(); result.CourseName = obj.CourseName; result.CourseType = obj.CourseType; result.Grade = obj.Grade; result.LessonCount = obj.LessonCount; result.Description = obj.Description; result.Introduction = introduction?.Yci_Introduction; result.Arrange = introduction?.Yci_Arrange; if (result.IsBindSchool) { result.SellCount = obj.SellCount; result.CoursePrice = obj.CoursePrice; result.BaseVoucherPrice = voucherDic.ContainsKey(obj.CourseId + "_" + 1) ? voucherDic[obj.CourseId + "_" + 1] : 0; result.SchoolVoucherPrice = voucherDic.ContainsKey(obj.CourseId + "_" + 2) ? voucherDic[obj.CourseId + "_" + 2] : 0; } if (applySchoolRecord != null && applySchoolRecord.Yay_Id > 0) { result.StudentApplySchoolStatus = applySchoolRecord.Yay_Status; result.StudentApplySchoolName = applySchoolRecord.SchoolName; } if (order != null && order.Yod_Id > 0) { result.IsHaveThisCourse = true; } return(result); }