public Response SaveWaitPay(CoachStudentMoney obj, User currentUser) { Response rsp = new Response(); //生成 待支付订单 var vipUse = new VipUse(); vipUse.Id = Ext.NewId(); vipUse.MasterType = MasterType.STUDENTPAYFORBOOTCAMP.Id; vipUse.MasterId = obj.Id; vipUse.CityId = obj.CityId; vipUse.VenueId = ""; vipUse.CostTypeId = CostType.COACHCOST.Id; vipUse.TotalAmount = obj.ThenMoney; vipUse.Discount = 1; vipUse.Amount = obj.ThenMoney * vipUse.Discount; vipUse.PayState = PayState.PAY.Id;//待支付 vipUse.IsOwnCreate = true; vipUse.Remark = "购买了集训课"; vipUse.UserId = currentUser.Id; vipUse.CreatorId = currentUser.Id; vipUse.CreateDate = DateTime.Now; rsp.Tag = VipHelper.SaveVipUse(vipUse); rsp.IsSuccess = true; return(rsp); }
public Response Execute(User currentUser, string request) { var req = JsonConvert.DeserializeObject <Request <GetCoachRelatedFilter> >(request); string sql = ""; sql = @" SELECT ISNULL(SUM(Amount),0) AS Amount FROM dbo.CoachStudentMoney WHERE StudentUserId=@StudentUserId AND Deadline>GETDATE() /*没过期*/ AND CourseTypeId!='027005' /*剔除集训课余额*/ "; var cmd = CommandHelper.CreateText <CoachStudentMoney>(FetchType.Fetch, sql); cmd.Params.Add("@StudentUserId", req.Filter.CurrentUserId); var result = DbContext.GetInstance().Execute(cmd); CoachStudentMoney obj = result.FirstEntity <CoachStudentMoney>(); if (obj.Amount == 0) { result.Tag = false; } else { result.Tag = true; } result.Entities.Clear(); return(result); }
public string CanJoin(CoachStudentMoney obj) { string sql = @" SELECT * FROM dbo.CoachBootcamp WHERE Id=@id "; var cmd = CommandHelper.CreateText <CoachBootcamp>(FetchType.Fetch, sql); cmd.Params.Add("@id", obj.CoachBootcampId); var result = DbContext.GetInstance().Execute(cmd); var coachBootcamp = result.FirstEntity <CoachBootcamp>(); if (coachBootcamp == null) { return("记录已不存在, 不能报名"); } if (coachBootcamp.State == CoachDic.BootcampUnpublish) { return("课程未发布,不能报名"); } else if (coachBootcamp.State == CoachDic.BootcampFinished) { return("课程已截止,不能报名"); } if (coachBootcamp.JoinDeadline < DateTime.Now) { return("课程报名截止时间已过,不能报名"); } return(""); }
public Response Execute(User currentUser, string request) { var req = JsonConvert.DeserializeObject <Request <GetCoachRelatedFilter> >(request); var sql = @" --私教 SELECT a.CoachId AS CourseNameId, dbo.fn_GetUserName(b.Id) AS CourseName, a.CourseTypeName, a.CourseTypeId, SUM(a.Amount) AS Amount, CoachCode=b.Code, BigCourseUnitPrice=c.Price, d.Grade AS CoachGrade FROM dbo.CoachStudentMoney a LEFT JOIN dbo.UserAccount b ON a.CoachId=b.Id LEFT JOIN dbo.CoachBigCourseInfo c ON a.BigCourseInfoId=c.Id LEFT JOIN dbo.Coach d ON a.CoachId=d.Id WHERE StudentUserId=@StudentId AND a.CoachId!='' GROUP BY a.CoachId ,b.Id,a.CourseTypeName,a.CourseTypeId,b.Code,c.Price,d.Grade UNION --大课 SELECT a.BigCourseInfoId AS CourseNameId, c.Name AS CourseName, a.CourseTypeName, a.CourseTypeId, SUM(a.Amount) AS Amount, CoachCode=b.Code, BigCourseUnitPrice=c.Price, d.Grade AS CoachGrade FROM dbo.CoachStudentMoney a LEFT JOIN dbo.UserAccount b ON a.CoachId=b.Id LEFT JOIN dbo.CoachBigCourseInfo c ON a.BigCourseInfoId=c.Id LEFT JOIN dbo.Coach d ON a.CoachId=d.Id WHERE StudentUserId=@StudentId AND a.BigCourseInfoId!='' AND Deadline > GETDATE() GROUP BY a.BigCourseInfoId ,c.Name,a.CourseTypeName,a.CourseTypeId,b.Code,c.Price,d.Grade "; var cmd = CommandHelper.CreateText <CoachStudentMoney>(FetchType.Fetch, sql); cmd.Params.Add("@StudentId", req.Filter.StudentId); var result = DbContext.GetInstance().Execute(cmd); foreach (var item in result.Entities) { CoachStudentMoney obj = item as CoachStudentMoney; if (obj.CourseTypeId == CoachDic.PrivateCourse) { obj.CoachUnitPrice = CoachHelper.Instance.GetCoachUnitPrice("75", obj.CoachGrade); } } return(result); }
//处理大课的最小截止日期和剩余次数 public void DealBigCourseDeadline(Response result, Request <GetCoachRelatedFilter> req) { foreach (var item in result.Entities) { CoachStudentMoney obj = item as CoachStudentMoney; if (obj.CourseTypeId == CoachDic.BigCourse) { var bigCourseMin = GetBigCourseMin(req.Filter.StudentId); if (bigCourseMin != null) { obj.BigCourseMinDeadline = bigCourseMin.BigCourseMinDeadline; } } } }
/// <summary> /// 为学员充值集训余额次数 /// </summary> /// <returns></returns> public void SaveSealedCoachStudentMoney(CoachBootcampStudent coachBootcampStudent, CoachBootcamp bootcamp) { Response rsp = new Response(); CoachStudentMoney obj = new CoachStudentMoney(); obj.StudentUserId = coachBootcampStudent.StudentId; obj.Amount = bootcamp.CourseCount; obj.ThenTotalAmount = bootcamp.CourseCount; obj.IsPay = true; obj.CourseTypeId = CoachDic.BootcampCourse; obj.CourseTypeName = "集训课"; obj.CoachBootcampId = coachBootcampStudent.CoachBootcampId; obj.Deadline = (DateTime)bootcamp.EndTime; obj.RowState = RowState.Added; obj.TrySetNewEntity(); List <EntityBase> entites = new List <EntityBase>(); entites.Add(obj); rsp = DbContext.GetInstance().Execute(CommandHelper.CreateSave(entites)); SystemHelper.CheckResponseIfError(rsp); }
//处理大课的最小截止日期和剩余次数 public void DealBigCourseDeadline(List <EntityBase> list, Response result, Request <GetCoachRelatedFilter> req) { foreach (var item in result.Entities) { CoachStudentMoney obj = item as CoachStudentMoney; if (obj.CourseTypeId == CoachDic.BigCourse) { var bigCourseMin = GetBigCourseMin(req.Filter.StudentId); if (bigCourseMin != null) { obj.BigCourseMinDeadline = bigCourseMin.BigCourseMinDeadline; obj.BigCourseMinDeadlineCount = bigCourseMin.BigCourseMinDeadlineCount; } } if (obj.CourseTypeId == CoachDic.BigCourse && result.Entities.Count > 0 && obj.Amount == 0 && obj.TotalAmount == 0) { continue; } list.Add(obj as EntityBase); } }
//获取之前的购买记录 public CoachCourse GetPreviousBuyRecord(string reservedPersonId, string courseType, string courseNameId) { string sql = ""; if (courseType == CoachDic.BigCourse) { sql = @" SELECT TOP 1 a.*, b.Name AS VenueName, c.Name AS CourseGoalName FROM dbo.CoachStudentMoney a LEFT JOIN dbo.Venue b ON a.VenueId =b.Id LEFT JOIN dbo.SysDic c ON a.CourseGoalCode=c.Code AND c.Code!='' WHERE BigCourseInfoId=@BigCourseInfoId AND StudentUserId=@StudentUserId ORDER BY a.CreateDate DESC "; } else if (courseType == CoachDic.PrivateCourse) { sql = @" SELECT TOP 1 a.*, b.Name AS VenueName, c.Name AS CourseGoalName, d.Code AS CoachCode FROM dbo.CoachStudentMoney a LEFT JOIN dbo.Venue b ON a.VenueId =b.Id LEFT JOIN dbo.SysDic c ON a.CourseGoalCode=c.Code AND c.Code!='' LEFT JOIN dbo.UserAccount d ON a.CoachId=d.Id WHERE a.CoachId=@CoachId AND StudentUserId=@StudentUserId ORDER BY a.CreateDate DESC "; } var cmd = CommandHelper.CreateText <CoachStudentMoney>(FetchType.Fetch, sql); cmd.Params.Add("@BigCourseInfoId", courseNameId); cmd.Params.Add("@StudentUserId", reservedPersonId); cmd.Params.Add("@CoachId", courseNameId); var result = DbContext.GetInstance().Execute(cmd); CoachStudentMoney coachStudentMoney = result.FirstEntity <CoachStudentMoney>(); CoachCourse coachCourse = new CoachCourse(); if (coachStudentMoney != null) { //获取 CoachCourse对象信息 coachCourse.VenueId = coachStudentMoney.VenueId; coachCourse.VenueName = coachStudentMoney.VenueName; coachCourse.StudentRemark = coachStudentMoney.StudentRemark; coachCourse.CourseGoalCode = coachStudentMoney.CourseGoalCode; coachCourse.CourseGoalName = coachStudentMoney.CourseGoalName; coachCourse.Type = coachStudentMoney.CourseTypeId; coachCourse.CoachCode = coachStudentMoney.CoachCode; coachCourse.CoachId = coachStudentMoney.CoachId; coachCourse.BigCourseId = coachStudentMoney.BigCourseInfoId; //获取CoachCoursePersonInfo对象信息 CoachCoursePersonInfo coachCoursePersonInfo = new CoachCoursePersonInfo(); var frequentStudentObj = GetFrequentStudent(coachStudentMoney.FrequentStudentId); if (frequentStudentObj != null) { coachCoursePersonInfo.FrequentStudentId = frequentStudentObj.Id; coachCoursePersonInfo.StudentName = frequentStudentObj.Name; coachCoursePersonInfo.StudentMobile = frequentStudentObj.Mobile; coachCourse.CoursePersonInfoList.Add(coachCoursePersonInfo); } } return(coachCourse); }