protected override EmptyResponseData ProcessRequest(DTO.Base.APIRequest <EmptyRequestParameter> pRequest) { var rd = new EmptyResponseData(); var para = pRequest.Parameters; var pointMarkBLL = new X_VipPointMarkBLL(CurrentUserInfo); var pointMarkDetailBLL = new X_VipPointMarkDetailBLL(CurrentUserInfo); DateTime dtNow = DateTime.Now; //当前时间 DateTime startWeek = DateTimeHelper.GetMondayDate(dtNow).Date; //本周周一 DateTime endWeek = DateTimeHelper.GetSundayDate(dtNow).AddDays(1).Date; //本周周日 var pointMarkDeail = pointMarkDetailBLL.GetPointMarkByWeek(CurrentUserInfo.UserID, startWeek, endWeek); if (pointMarkDeail != null) { if (pointMarkDeail.Count > 0)//答题获得积分才处理 { pointMarkDetailBLL.Delete(pointMarkDeail); var pointMarkInfo = pointMarkBLL.QueryByEntity(new X_VipPointMarkEntity() { VipID = CurrentUserInfo.UserID }, null).FirstOrDefault(); if (pointMarkInfo != null) { pointMarkInfo.Count = pointMarkInfo.Count - pointMarkDeail.Count; pointMarkInfo.TotalCount = pointMarkInfo.TotalCount - pointMarkDeail.Count; pointMarkBLL.Update(pointMarkInfo); } } } return(rd); }
protected override EmptyResponseData ProcessRequest(DTO.Base.APIRequest <SetVipPointMarkRP> pRequest) { var rd = new EmptyResponseData(); var para = pRequest.Parameters; var pointMarkBLL = new X_VipPointMarkBLL(CurrentUserInfo); var pointMarkDetailBLL = new X_VipPointMarkDetailBLL(CurrentUserInfo); X_VipPointMarkEntity pointMarkEntity = null; pointMarkEntity = pointMarkBLL.QueryByEntity(new X_VipPointMarkEntity() { VipID = CurrentUserInfo.UserID }, null).FirstOrDefault(); if (pointMarkEntity != null) { if (para.Count > 0) { pointMarkEntity.TotalCount += para.Count; } pointMarkEntity.Count += para.Count; pointMarkBLL.Update(pointMarkEntity); } else { pointMarkEntity = new X_VipPointMarkEntity(); pointMarkEntity.VipID = CurrentUserInfo.UserID; pointMarkEntity.CustomerID = CurrentUserInfo.ClientID; pointMarkEntity.Count = para.Count; pointMarkEntity.TotalCount = para.Count; pointMarkBLL.Create(pointMarkEntity); } X_VipPointMarkDetailEntity detail = new X_VipPointMarkDetailEntity() { VipID = CurrentUserInfo.UserID, Count = para.Count, Source = para.Source, CustomerID = CurrentUserInfo.ClientID }; pointMarkDetailBLL.Create(detail); return(rd); }
protected override GetVipPointMarkRD ProcessRequest(DTO.Base.APIRequest <EmptyRequestParameter> pRequest) { var rd = new GetVipPointMarkRD(); var para = pRequest.Parameters; var pointMarkBLL = new X_VipPointMarkBLL(CurrentUserInfo); var pointMarkDetailBLL = new X_VipPointMarkDetailBLL(CurrentUserInfo); var pointMarkInfo = pointMarkBLL.QueryByEntity(new X_VipPointMarkEntity() { VipID = CurrentUserInfo.UserID }, null).FirstOrDefault(); int count = 0; //当前点数 int totalCount = 0; //累计点数 int weekCount = 0; //本周获得点数 DateTime dtNow = DateTime.Now; //当前时间 DateTime startWeek = DateTimeHelper.GetMondayDate(dtNow).Date; //本周周一 DateTime endWeek = DateTimeHelper.GetSundayDate(dtNow).AddDays(1).Date; //本周周日 string pointMarkId = string.Empty; if (pointMarkInfo != null) { pointMarkId = pointMarkInfo.PointMarkID.ToString(); count = pointMarkInfo.Count.Value; totalCount = pointMarkInfo.TotalCount.Value; var pointMarkDetail = pointMarkDetailBLL.GetPointMarkByWeek(CurrentUserInfo.UserID, startWeek, endWeek); if (pointMarkDetail != null) { weekCount = pointMarkDetail.Count.Value; } } rd.PointMarkID = pointMarkId; rd.Count = count; rd.TotalCount = totalCount; rd.WeekCount = weekCount; return(rd); }
protected override EmptyResponseData ProcessRequest(DTO.Base.APIRequest <ExchangeCouponRP> pRequest) { var rd = new EmptyResponseData(); var para = pRequest.Parameters; var pointMarkBLL = new X_VipPointMarkBLL(CurrentUserInfo); var pointMarkDetailBLL = new X_VipPointMarkDetailBLL(CurrentUserInfo); var activityPrizesBLL = new X_ActivityPrizesBLL(CurrentUserInfo); var activityJoinBLL = new X_ActivityJoinBLL(CurrentUserInfo); var couponBLL = new CouponBLL(CurrentUserInfo); var vipCouponMappingBLL = new VipCouponMappingBLL(CurrentUserInfo); var couponTypeBLL = new CouponTypeBLL(CurrentUserInfo); var activityPrizeInfo = activityPrizesBLL.GetByID(para.PrizesID); if (activityPrizeInfo != null) { //扣减积点 var pointMarkInfo = pointMarkBLL.QueryByEntity(new X_VipPointMarkEntity() { VipID = CurrentUserInfo.UserID }, null).FirstOrDefault(); if (pointMarkInfo != null) { pointMarkInfo.Count = pointMarkInfo.Count - activityPrizeInfo.UsePoint; pointMarkBLL.Update(pointMarkInfo); X_VipPointMarkDetailEntity detail = new X_VipPointMarkDetailEntity() { VipID = CurrentUserInfo.UserID, Count = -activityPrizeInfo.UsePoint, Source = 2,//抽奖兑换 CustomerID = CurrentUserInfo.ClientID }; pointMarkDetailBLL.Create(detail); } //更改参与信息 var activityJoinInfo = activityJoinBLL.QueryByEntity(new X_ActivityJoinEntity() { VipID = CurrentUserInfo.UserID }, new OrderBy[] { new OrderBy { FieldName = "CreateTime", Direction = OrderByDirections.Desc } }).FirstOrDefault(); if (activityJoinInfo != null) { activityJoinInfo.IsExchange = 1; activityJoinBLL.Update(activityJoinInfo); } //兑换优惠券 string couponID = couponBLL.GetUsableCouponID(activityPrizeInfo.CouponTypeID.ToString()); VipCouponMappingEntity vipCouponMappingInfo = new VipCouponMappingEntity() { VIPID = CurrentUserInfo.UserID, CouponID = couponID }; vipCouponMappingBLL.Create(vipCouponMappingInfo); //修改券产品个数 var couponTypeInfo = couponTypeBLL.GetByID(activityPrizeInfo.CouponTypeID); if (couponTypeInfo != null) { couponTypeInfo.IsVoucher = couponTypeInfo.IsVoucher + 1; couponTypeBLL.Update(couponTypeInfo); } } return(rd); }