private void AddPointDetail(Hidistro.Entities.Members.MemberInfo member, string orderId, int points, int?deductionPoints, PointTradeType pType, DbTransaction dbTran) { PointDetailInfo pointDetailInfo = new PointDetailInfo(); pointDetailInfo.OrderId = orderId; pointDetailInfo.UserId = member.UserId; pointDetailInfo.TradeDate = DateTime.Now; pointDetailInfo.TradeType = pType; switch (pType) { case PointTradeType.Bounty: pointDetailInfo.Increased = points; pointDetailInfo.Points = points + member.Points; break; case PointTradeType.ShoppingDeduction: pointDetailInfo.Reduced = (deductionPoints.HasValue ? deductionPoints.Value : 0); pointDetailInfo.Points = member.Points - (deductionPoints.HasValue ? deductionPoints.Value : 0); break; } if (pointDetailInfo.Points > 2147483647) { pointDetailInfo.Points = 2147483647; } if (pointDetailInfo.Points < 0) { pointDetailInfo.Points = 0; } if (pointDetailInfo.Increased > 0 || pointDetailInfo.Reduced > 0) { BaseDao baseDao = new BaseDao(); baseDao.Add(pointDetailInfo, dbTran); member.Points = pointDetailInfo.Points; } }
public static bool CutNeedPoint(int needPoint, string orderId, PointTradeType pType, int userId) { Hidistro.Entities.Members.MemberInfo user = Users.GetUser(userId); if (user != null) { PointDetailInfo pointDetailInfo = new PointDetailInfo(); pointDetailInfo.OrderId = orderId; pointDetailInfo.UserId = user.UserId; pointDetailInfo.TradeDate = DateTime.Now; pointDetailInfo.TradeType = pType; pointDetailInfo.Reduced = needPoint; pointDetailInfo.Points = user.Points - needPoint; pointDetailInfo.Remark = "订单 " + orderId; if (pointDetailInfo.Points > 2147483647 || pointDetailInfo.Points < 0) { pointDetailInfo.Points = 0; } if (new PointDetailDao().Add(pointDetailInfo, null) > 0) { user.Points = pointDetailInfo.Points; return(true); } } return(false); }
public static object GoSign(MemberInfo User) { if (new PromotionDao().IsTodaySigned(User.UserId))//如果今天已经签到过,则不执行签到方法 { return(-11); } if (new PromotionDao().GoSignToday(User.UserId)) //成功签到后发送积分 { //获取签到送积分规则 DataTable ruleDT = GetSignRule(); string[] dayList = ruleDT.Rows[0]["NeedDays"].ToString().Split(','); string[] pointList = ruleDT.Rows[0]["SendPoints"].ToString().Split(','); int sendPoint = 0; int continuitySignCounts = GetContinuitySignCounts(User.UserId); //根据规则和当前连续签到的日期计算送出的积分数量 continuitySignCounts = continuitySignCounts == 0 ? 1 : continuitySignCounts; for (int i = 0; i < dayList.Length; i++) { //如果当前签到天数能被设置好的天数整除,则按照相应的索引加积分 if (continuitySignCounts % Convert.ToInt32(dayList[i]) == 0) { sendPoint = sendPoint + Convert.ToInt32(pointList[i]); } } //实例化积分实体类 PointDetailInfo point = new PointDetailInfo { OrderId = "签到送积分", UserId = User.UserId, TradeDate = DateTime.Now, TradeType = PointTradeType.Bounty, Increased = sendPoint, Points = User.Points + sendPoint }; if ((point.Points > 0x7fffffff) || (point.Points < 0)) { point.Points = 0; } //送积分 try { new PointDetailDao().AddPointDetail(point); //积分detail表 User.Points = User.Points + sendPoint; MemberHelper.UpdateNoLog(User); //积分主表 return(sendPoint); } catch (Exception ex) { return(ex.Message.ToString()); } HiCache.Remove(string.Format("DataCache-Member-{0}", User.UserId)); } else { return(-1); } }
public bool UpdatePointDetail(PointDetailInfo point) { DbCommand sqlStringCommand = this.database.GetSqlStringCommand("update Ecshop_PointDetails set Points= case when Points - @Points > 0 then Points - @Points else 0 end where UserId=@UserId and OrderId=@OrderId"); this.database.AddInParameter(sqlStringCommand, "OrderId", DbType.String, point.OrderId); this.database.AddInParameter(sqlStringCommand, "UserId", DbType.Int32, point.UserId); this.database.AddInParameter(sqlStringCommand, "Points", DbType.Int32, point.Points); return(this.database.ExecuteNonQuery(sqlStringCommand) > 0); }
private static void ReducedPoint(OrderInfo order, MemberInfo member) { PointDetailInfo info = new PointDetailInfo(); info.OrderId = order.OrderId; info.UserId = member.UserId; info.TradeDate = DateTime.Now; info.TradeType = PointTradeType.Refund; info.Reduced = new int?(order.Points); info.Points = member.Points - info.Reduced.Value; new PointDetailDao().AddPointDetail(info); }
public bool AddPointDetail(PointDetailInfo point) { DbCommand sqlStringCommand = this.database.GetSqlStringCommand("INSERT INTO Ecshop_PointDetails (OrderId,UserId, TradeDate, TradeType, Increased, Reduced, Points, Remark)VALUES(@OrderId,@UserId, @TradeDate, @TradeType, @Increased, @Reduced, @Points, @Remark)"); this.database.AddInParameter(sqlStringCommand, "OrderId", DbType.String, point.OrderId); this.database.AddInParameter(sqlStringCommand, "UserId", DbType.Int32, point.UserId); this.database.AddInParameter(sqlStringCommand, "TradeDate", DbType.DateTime, point.TradeDate); this.database.AddInParameter(sqlStringCommand, "TradeType", DbType.Int32, (int)point.TradeType); this.database.AddInParameter(sqlStringCommand, "Increased", DbType.Int32, point.Increased.HasValue ? point.Increased.Value : 0); this.database.AddInParameter(sqlStringCommand, "Reduced", DbType.Int32, point.Reduced.HasValue ? point.Reduced.Value : 0); this.database.AddInParameter(sqlStringCommand, "Points", DbType.Int32, point.Points); this.database.AddInParameter(sqlStringCommand, "Remark", DbType.String, point.Remark); return(this.database.ExecuteNonQuery(sqlStringCommand) > 0); }
private static void UpdateUserAccount(OrderInfo order) { MemberInfo member = new MemberDao().GetMember(order.UserId); if (member != null) { MemberDao dao = new MemberDao(); PointDetailInfo point = new PointDetailInfo { OrderId = order.OrderId, UserId = member.UserId, TradeDate = DateTime.Now, TradeType = PointTradeType.Bounty, Increased = new int?(order.Points), Points = order.Points + member.Points }; if ((point.Points > 0x7fffffff) || (point.Points < 0)) { point.Points = 0x7fffffff; } PointDetailDao dao2 = new PointDetailDao(); dao2.AddPointDetail(point); member.Expenditure += order.GetTotal(); member.OrderNumber++; dao.Update(member); int historyPoint = dao2.GetHistoryPoint(member.UserId); List <MemberGradeInfo> memberGrades = new MemberGradeDao().GetMemberGrades() as List <MemberGradeInfo>; MemberGradeInfo memberGrade = MemberHelper.GetMemberGrade(member.GradeId); if ((memberGrade == null) || (memberGrade.Points <= historyPoint)) { foreach (MemberGradeInfo info4 in from item in memberGrades orderby item.Points descending select item) { if (member.GradeId == info4.GradeId) { break; } if (info4.Points <= historyPoint) { member.GradeId = info4.GradeId; dao.Update(member); break; } } } } }
public bool BatchEditPoints(PointDetailInfo model, string userIds, Hashtable ht) { string[] array = userIds.Split(','); StringBuilder stringBuilder = new StringBuilder(); int? nullable = (model.Increased == 0) ? (-model.Reduced) : model.Increased; for (int i = 0; i < array.Length; i++) { stringBuilder.Append("INSERT INTO Hishop_PointDetails(OrderId,UserId, TradeDate, TradeType, Increased, Reduced, Points, Remark)"); stringBuilder.AppendFormat(" VALUES('',{0}, GETDATE(), {1}, {2}, {3}, (SELECT Points FROM aspnet_Members WHERE UserId={0})+({4}), '{5}');", array[i], (int)model.TradeType, model.Increased, model.Reduced, nullable, ht[array[i]]); } DbCommand sqlStringCommand = base.database.GetSqlStringCommand(stringBuilder.ToString()); int num = base.database.ExecuteNonQuery(sqlStringCommand); return(num > 0); }
public static void ReturnNeedPointOnClosed(string orderId, int needPoint, MemberInfo member) { PointDetailInfo pointDetailInfo = new PointDetailInfo(); pointDetailInfo.OrderId = orderId; pointDetailInfo.UserId = member.UserId; pointDetailInfo.TradeDate = DateTime.Now; pointDetailInfo.TradeType = PointTradeType.Refund; pointDetailInfo.Remark = "订单 " + orderId + " 关闭,退回礼品兑换的积分"; pointDetailInfo.Increased = needPoint; pointDetailInfo.Points = member.Points + pointDetailInfo.Increased; if (pointDetailInfo.Increased > 0) { PointDetailDao pointDetailDao = new PointDetailDao(); pointDetailDao.Add(pointDetailInfo, null); member.Points = pointDetailInfo.Points; MemberDao memberDao = new MemberDao(); int historyPoint = pointDetailDao.GetHistoryPoint(member.UserId, null); memberDao.ChangeMemberGrade(member.UserId, member.GradeId, historyPoint, null); } }
private static bool AddPoints(MemberInfo member, int points, PointTradeType type) { PointDetailDao pointDetailDao = new PointDetailDao(); PointDetailInfo pointDetailInfo = new PointDetailInfo(); pointDetailInfo.UserId = member.UserId; pointDetailInfo.TradeDate = DateTime.Now; pointDetailInfo.TradeType = type; pointDetailInfo.Increased = points; pointDetailInfo.Points = points + member.Points; if (pointDetailInfo.Points > 2147483647) { pointDetailInfo.Points = 2147483647; } if (pointDetailInfo.Points < 0) { pointDetailInfo.Points = 0; } pointDetailInfo.Remark = "评论获得积分"; member.Points = pointDetailInfo.Points; return(pointDetailDao.Add(pointDetailInfo, null) > 0); }
/// <summary> /// add@20150921 by jh /// 提交订单时,扣除积分 /// </summary> /// <param name="needPoint"></param> /// <param name="orderId"></param> /// <returns></returns> public static bool CutNeedPoint(int needPoint, string orderId) { MemberInfo user = MemberProcessor.GetCurrentMember(); PointDetailInfo point = new PointDetailInfo { OrderId = orderId, UserId = user.UserId, TradeDate = DateTime.Now, TradeType = PointTradeType.Change, Reduced = new int?(needPoint), Points = user.Points - needPoint }; if ((point.Points > 0x7fffffff) || (point.Points < 0)) { point.Points = 0; } if (new PointDetailDao().AddPointDetail(point)) { return(true); } return(false); }
private static void ReturnPointOnClosed(string orderId, int?deductionPoints, MemberInfo member) { if (deductionPoints.HasValue && deductionPoints > 0) { PointDetailInfo pointDetailInfo = new PointDetailInfo(); pointDetailInfo.OrderId = orderId; pointDetailInfo.UserId = member.UserId; pointDetailInfo.TradeDate = DateTime.Now; pointDetailInfo.TradeType = PointTradeType.Refund; pointDetailInfo.Remark = "订单 " + orderId + " 删除,还原抵扣的积分"; pointDetailInfo.Increased = (deductionPoints.HasValue ? deductionPoints.Value : 0); pointDetailInfo.Points = member.Points + pointDetailInfo.Increased; if (pointDetailInfo.Increased > 0) { PointDetailDao pointDetailDao = new PointDetailDao(); pointDetailDao.Add(pointDetailInfo, null); member.Points = pointDetailInfo.Points; MemberDao memberDao = new MemberDao(); int historyPoint = pointDetailDao.GetHistoryPoint(member.UserId, null); memberDao.ChangeMemberGrade(member.UserId, member.GradeId, historyPoint, null); } } }
protected void btnSubmitPoint_Click(object sender, EventArgs e) { ManagerHelper.CheckPrivilege(Privilege.UpdateMemberPoint); MemberInfo user = Users.GetUser(this.userId); if (user == null) { base.GotoResourceNotFound(); } else { int num = 0; int num2 = 0; if (this.radAdd.Checked) { if (string.IsNullOrEmpty(this.txtAddPoints.Text) || !int.TryParse(this.txtAddPoints.Text.Trim(), out num)) { this.ShowMsg("要增加的积分数不能为空且为正数", false); return; } if (num <= 0) { this.ShowMsg("请输入大于0的积分数", false); return; } } else if (this.RadMinus.Checked) { if (string.IsNullOrEmpty(this.txtMinusPoints.Text) || !int.TryParse(this.txtMinusPoints.Text.Trim(), out num2)) { this.ShowMsg("要减少的积分数不能为空且为正数", false); return; } if (num2 <= 0) { this.ShowMsg("请输入大于0的积分数", false); return; } if (num2 > user.Points) { this.ShowMsg("会员【" + user.UserName + "】的积分不足,请调整要减去的积分", false); this.Page.ClientScript.RegisterStartupScript(base.GetType(), "msg", "<script>onRadioClick(2);</script>"); return; } } PointDetailInfo pointDetailInfo = new PointDetailInfo(); pointDetailInfo.OrderId = ""; pointDetailInfo.UserId = this.userId; pointDetailInfo.TradeDate = DateTime.Now; pointDetailInfo.TradeType = PointTradeType.AdministratorUpdate; if (this.radAdd.Checked) { pointDetailInfo.Increased = num; pointDetailInfo.Points = num + user.Points; } else if (this.RadMinus.Checked) { pointDetailInfo.Reduced = num2; pointDetailInfo.Points = user.Points - num2; } if (pointDetailInfo.Points > 2147483647) { pointDetailInfo.Points = 2147483647; } if (pointDetailInfo.Points < 0) { pointDetailInfo.Points = 0; } pointDetailInfo.Remark = "操作员:" + HiContext.Current.Manager.UserName + " " + this.txtRemark.Text.Trim(); PointDetailDao pointDetailDao = new PointDetailDao(); if (pointDetailDao.Add(pointDetailInfo, null) > 0) { user.Points = pointDetailInfo.Points; MemberDao memberDao = new MemberDao(); int historyPoint = pointDetailDao.GetHistoryPoint(this.userId, null); memberDao.ChangeMemberGrade(this.userId, user.Points, historyPoint, null); Users.ClearUserCache(this.userId, user.SessionId); base.CloseWindow(null); } else { this.ShowMsg("操作失败", false); } } }
//点睛教育需求:返佣同时得积分 public static bool UpdateDistributorPoints(OrderInfo order) { bool flag = false; //代理商的积分 DistributorsInfo currentDistributor = GetDistributorInfo(order.ReferralUserId); //当前1级分销商分销信息 DistributorsInfo currentAgent = GetDistributorInfo(currentDistributor.AgentPath.ToInt()); //当前代理商分销信息 MemberInfo distributorLevel1Info = MemberProcessor.GetMember(currentDistributor.UserId); //当前1级分销商用户信息 MemberInfo agentInfo = MemberProcessor.GetMember(currentAgent.UserId); //当前代理商用户信息 //获取一级返佣和代理商返佣 decimal commision = 0m; foreach (LineItemInfo info in order.LineItems.Values) { commision += info.ItemsCommission; } //一级分销商可得的积分 int pointLevel1 = Convert.ToInt32(commision / 20); int agentCommisionRate = Convert.ToInt32(DistributorGradeBrower.GetAgentGradeInfo(currentAgent.AgentGradeId).FirstCommissionRise);//当前代理商的分佣百分比 //当前代理商可得的积分 int pointAgent = Convert.ToInt32((order.GetTotal() / 100 * agentCommisionRate) / 20); //判断该用户是否关注了公众号,如果没有关注,则积分给代理商. if (!(distributorLevel1Info != null && WxSubscribe(distributorLevel1Info.OpenId))) { pointAgent = pointAgent + pointLevel1; } //给1级分销商增加积分 MemberDao dao4 = new MemberDao(); distributorLevel1Info.Points = distributorLevel1Info.Points + pointLevel1; PointDetailInfo pointDistributorLevel1 = new PointDetailInfo { OrderId = order.OrderId, UserId = order.ReferralUserId, TradeDate = DateTime.Now, TradeType = PointTradeType.Bounty, Increased = pointLevel1, Points = distributorLevel1Info.Points }; if ((pointDistributorLevel1.Points > 0x7fffffff) || (pointDistributorLevel1.Points < 0)) { pointDistributorLevel1.Points = 0x7fffffff; } PointDetailDao dao5 = new PointDetailDao(); dao5.AddPointDetail(pointDistributorLevel1); dao4.Update(distributorLevel1Info); //给代理商增加积分 MemberDao dao6 = new MemberDao(); agentInfo.Points = agentInfo.Points + pointAgent; PointDetailInfo pointAgentInfo = new PointDetailInfo { OrderId = order.OrderId, UserId = order.ReferralUserId, TradeDate = DateTime.Now, TradeType = PointTradeType.Bounty, Increased = pointAgent, Points = agentInfo.Points }; if ((pointAgentInfo.Points > 0x7fffffff) || (pointAgentInfo.Points < 0)) { pointAgentInfo.Points = 0x7fffffff; } PointDetailDao dao7 = new PointDetailDao(); dao5.AddPointDetail(pointAgentInfo); dao4.Update(agentInfo); return(flag); }
public static bool UserPayOrder(OrderInfo order) { OrderDao dao = new OrderDao(); order.OrderStatus = OrderStatus.BuyerAlreadyPaid; order.PayDate = new DateTime?(DateTime.Now); bool flag = dao.UpdateOrder(order, null); if (flag) { dao.UpdatePayOrderStock(order.OrderId); foreach (LineItemInfo info in order.LineItems.Values) { ProductDao dao2 = new ProductDao(); ProductInfo productDetails = dao2.GetProductDetails(info.ProductId); productDetails.SaleCounts += info.Quantity; productDetails.ShowSaleCounts += info.Quantity; dao2.UpdateProduct(productDetails, null); } MemberInfo member = GetMember(order.UserId); if (member == null) { return(flag); } MemberDao dao3 = new MemberDao(); PointDetailInfo point = new PointDetailInfo { OrderId = order.OrderId, UserId = member.UserId, TradeDate = DateTime.Now, TradeType = PointTradeType.Bounty, Increased = new int?(order.Points), Points = order.Points + member.Points }; if ((point.Points > 0x7fffffff) || (point.Points < 0)) { point.Points = 0x7fffffff; } PointDetailDao dao4 = new PointDetailDao(); dao4.AddPointDetail(point); member.Expenditure += order.GetTotal(); member.OrderNumber++; dao3.Update(member); Messenger.OrderPayment(member, order.OrderId, order.GetTotal()); int historyPoint = dao4.GetHistoryPoint(member.UserId); List <MemberGradeInfo> memberGrades = new MemberGradeDao().GetMemberGrades() as List <MemberGradeInfo>; foreach (MemberGradeInfo info5 in from item in memberGrades orderby item.Points descending select item) { if (member.GradeId == info5.GradeId) { return(flag); } if (info5.Points <= historyPoint) { member.GradeId = info5.GradeId; dao3.Update(member); return(flag); } } } return(flag); }
public static bool UserPayOrder(OrderInfo order) { OrderDao dao = new OrderDao(); order.OrderStatus = OrderStatus.BuyerAlreadyPaid; order.PayDate = new DateTime?(DateTime.Now); bool flag = dao.UpdateOrder(order, null); string str = ""; if (flag) { dao.UpdatePayOrderStock(order.OrderId); foreach (LineItemInfo info in order.LineItems.Values) { ProductDao dao2 = new ProductDao(); str = str + "'" + info.SkuId + "',"; ProductInfo productDetails = dao2.GetProductDetails(info.ProductId); productDetails.SaleCounts += info.Quantity; productDetails.ShowSaleCounts += info.Quantity; dao2.UpdateProduct(productDetails, null); } if (!string.IsNullOrEmpty(str)) { dao.UpdateItemsStatus(order.OrderId, 2, str.Substring(0, str.Length - 1)); } if (!string.IsNullOrEmpty(order.ActivitiesId)) { new ActivitiesDao().UpdateActivitiesTakeEffect(order.ActivitiesId); } MemberInfo member = GetMember(order.UserId); if (member == null) { return(flag); } MemberDao dao4 = new MemberDao(); PointDetailInfo point = new PointDetailInfo { OrderId = order.OrderId, UserId = member.UserId, TradeDate = DateTime.Now, TradeType = PointTradeType.Bounty, Increased = new int?(order.Points), Points = order.Points + member.Points }; if ((point.Points > 0x7fffffff) || (point.Points < 0)) { point.Points = 0x7fffffff; } PointDetailDao dao5 = new PointDetailDao(); dao5.AddPointDetail(point); member.Expenditure += order.GetTotal(); member.OrderNumber++; dao4.Update(member); Messenger.OrderPayment(member, order.OrderId, order.GetTotal()); int historyPoint = dao5.GetHistoryPoint(member.UserId); MemberGradeInfo memberGrade = GetMemberGrade(member.GradeId); if ((memberGrade != null) && (memberGrade.Points > historyPoint)) { return(flag); } List <MemberGradeInfo> memberGrades = new MemberGradeDao().GetMemberGrades() as List <MemberGradeInfo>; foreach (MemberGradeInfo info6 in from item in memberGrades orderby item.Points descending select item) { if (member.GradeId == info6.GradeId) { return(flag); } if (info6.Points <= historyPoint) { member.GradeId = info6.GradeId; dao4.Update(member); return(flag); } } } return(flag); }
public static CouponActionStatus AddCouponItemInfo(MemberInfo user, int couponId) { CouponInfo eFCoupon = CouponHelper.GetEFCoupon(couponId); if (eFCoupon == null) { return(CouponActionStatus.NotExists); } if (user == null) { return(CouponActionStatus.InconsistentInformationUser); } if (eFCoupon.ClosingTime < DateTime.Now) { return(CouponActionStatus.Overdue); } int couponSurplus = CouponHelper.GetCouponSurplus(couponId); if (couponSurplus <= 0) { return(CouponActionStatus.InadequateInventory); } int couponObtainNum = CouponHelper.GetCouponObtainNum(couponId, user.UserId); if (couponObtainNum >= eFCoupon.UserLimitCount && eFCoupon.UserLimitCount > 0) { return(CouponActionStatus.CannotReceive); } if (eFCoupon.ObtainWay == 2) { int points = user.Points; PointDetailInfo pointDetailInfo = new PointDetailInfo(); pointDetailInfo.OrderId = string.Empty; pointDetailInfo.UserId = user.UserId; pointDetailInfo.TradeDate = DateTime.Now; pointDetailInfo.TradeType = PointTradeType.ChangeCoupon; pointDetailInfo.Increased = 0; pointDetailInfo.Reduced = eFCoupon.NeedPoint; pointDetailInfo.Points = points - eFCoupon.NeedPoint; if (pointDetailInfo.Points < 0) { return(CouponActionStatus.PointNotEnough); } if (new PointDetailDao().Add(pointDetailInfo, null) <= 0) { return(CouponActionStatus.UnknowError); } user.Points = pointDetailInfo.Points; } CouponItemInfo couponItemInfo = new CouponItemInfo(); couponItemInfo.UserId = user.UserId; couponItemInfo.UserName = user.UserName; couponItemInfo.CanUseProducts = eFCoupon.CanUseProducts; couponItemInfo.CouponId = eFCoupon.CouponId; couponItemInfo.CouponName = eFCoupon.CouponName; couponItemInfo.OrderUseLimit = eFCoupon.OrderUseLimit; couponItemInfo.Price = eFCoupon.Price; couponItemInfo.StartTime = eFCoupon.StartTime; couponItemInfo.ClosingTime = eFCoupon.ClosingTime; couponItemInfo.UseWithGroup = eFCoupon.UseWithGroup; couponItemInfo.UseWithPanicBuying = eFCoupon.UseWithPanicBuying; couponItemInfo.UseWithFireGroup = eFCoupon.UseWithFireGroup; couponItemInfo.ClaimCode = Guid.NewGuid().ToString(); couponItemInfo.GetDate = DateTime.Now; return(CouponHelper.AddCouponItem(couponItemInfo)); }
public static bool ManageWinningResult(int UserId, ActivityInfo Info, int AwardGrade, ref int FreeTimes) { lock (ActivityHelper.oWinning) { Database database = DatabaseFactory.CreateDatabase(); ActivityDao activityDao = new ActivityDao(); using (DbConnection dbConnection = database.CreateConnection()) { dbConnection.Open(); DbTransaction dbTransaction = dbConnection.BeginTransaction(); try { bool flag = false; bool flag2 = false; ActivityJoinStatisticsInfo activityJoinStatisticsInfo = activityDao.GetCurrUserActivityStatisticsInfo(UserId, Info.ActivityId, dbTransaction); MemberInfo memberInfo = new MemberDao().Get <MemberInfo>(UserId); if (activityJoinStatisticsInfo != null) { if (Info.ResetType == 2) { DateTime lastJoinDate = activityJoinStatisticsInfo.LastJoinDate; if (DateTime.Now.Date == lastJoinDate.Date) { if (activityJoinStatisticsInfo.FreeNum < Info.FreeTimes) { flag = true; activityJoinStatisticsInfo.FreeNum++; FreeTimes = Info.FreeTimes - activityJoinStatisticsInfo.FreeNum; } else { activityJoinStatisticsInfo.IntegralTotal += Info.ConsumptionIntegral; activityJoinStatisticsInfo.IntegralNum++; FreeTimes = 0; } } else { flag = true; activityJoinStatisticsInfo.FreeNum = 1; FreeTimes = Info.FreeTimes - 1; } } else if (activityJoinStatisticsInfo.FreeNum < Info.FreeTimes) { flag = true; activityJoinStatisticsInfo.FreeNum++; FreeTimes = Info.FreeTimes - activityJoinStatisticsInfo.FreeNum; } else { activityJoinStatisticsInfo.IntegralTotal += Info.ConsumptionIntegral; activityJoinStatisticsInfo.IntegralNum++; FreeTimes = 0; } } else { flag2 = true; activityJoinStatisticsInfo = new ActivityJoinStatisticsInfo(); activityJoinStatisticsInfo.ActivityId = Info.ActivityId; activityJoinStatisticsInfo.UserId = UserId; if (Info.FreeTimes > 0) { flag = true; activityJoinStatisticsInfo.FreeNum = 1; activityJoinStatisticsInfo.IntegralTotal = 0; activityJoinStatisticsInfo.IntegralNum = 0; FreeTimes = Info.FreeTimes - 1; } else { activityJoinStatisticsInfo.IntegralTotal = Info.ConsumptionIntegral; activityJoinStatisticsInfo.IntegralNum = 1; activityJoinStatisticsInfo.FreeNum = 0; FreeTimes = 0; } } activityJoinStatisticsInfo.JoinNum++; activityJoinStatisticsInfo.LastJoinDate = DateTime.Now; bool flag3 = false; CouponInfo couponInfo = null; GiftInfo giftInfo = null; ActivityAwardItemInfo activityAwardItemInfo = null; if (AwardGrade > 0) { activityAwardItemInfo = activityDao.GetActivityItem(Info.ActivityId, AwardGrade, dbTransaction); if (activityAwardItemInfo.WinningNum < activityAwardItemInfo.AwardNum) { if (activityAwardItemInfo.PrizeType == 2) { couponInfo = new CouponDao().Get <CouponInfo>(activityAwardItemInfo.PrizeValue); if (couponInfo != null) { int couponSurplus = new CouponDao().GetCouponSurplus(activityAwardItemInfo.PrizeValue); if (couponSurplus > 0 && couponInfo.ClosingTime > DateTime.Now) { flag3 = true; } } } else if (activityAwardItemInfo.PrizeType == 3) { giftInfo = new GiftDao().Get <GiftInfo>(activityAwardItemInfo.PrizeValue); if (giftInfo != null) { flag3 = true; } } else { flag3 = true; } } } else { flag3 = false; } if (!flag) { PointDetailInfo pointDetailInfo = new PointDetailInfo(); pointDetailInfo.Increased = 0; pointDetailInfo.OrderId = ""; pointDetailInfo.Points = memberInfo.Points - Info.ConsumptionIntegral; pointDetailInfo.Reduced = Info.ConsumptionIntegral; pointDetailInfo.Remark = "抽奖消耗积分"; pointDetailInfo.SignInSource = 0; pointDetailInfo.TradeDate = DateTime.Now; if (Info.ActivityType == 1) { pointDetailInfo.TradeType = PointTradeType.JoinRotaryTable; } else if (Info.ActivityType == 3) { pointDetailInfo.TradeType = PointTradeType.JoinSmashingGoldenEgg; } else { pointDetailInfo.TradeType = PointTradeType.JoinScratchCard; } pointDetailInfo.UserId = UserId; if (new PointDetailDao().Add(pointDetailInfo, dbTransaction) <= 0) { dbTransaction.Rollback(); return(false); } } if (!flag3) { if (flag2) { if (activityDao.Add(activityJoinStatisticsInfo, dbTransaction) <= 0) { dbTransaction.Rollback(); } } else if (!activityDao.UpdateActivityStatisticsInfo(activityJoinStatisticsInfo, dbTransaction)) { dbTransaction.Rollback(); } dbTransaction.Commit(); return(false); } activityJoinStatisticsInfo.WinningNum++; if (flag2) { if (activityDao.Add(activityJoinStatisticsInfo, dbTransaction) <= 0) { dbTransaction.Rollback(); } } else if (!activityDao.UpdateActivityStatisticsInfo(activityJoinStatisticsInfo, dbTransaction)) { dbTransaction.Rollback(); } activityAwardItemInfo.WinningNum++; if (!activityDao.Update(activityAwardItemInfo, dbTransaction)) { dbTransaction.Rollback(); return(false); } UserAwardRecordsInfo userAwardRecordsInfo = new UserAwardRecordsInfo(); userAwardRecordsInfo.ActivityId = Info.ActivityId; if (activityAwardItemInfo.PrizeType == 2) { userAwardRecordsInfo.AwardName = couponInfo.CouponName; userAwardRecordsInfo.AwardDate = DateTime.Now; userAwardRecordsInfo.Status = 2; CouponItemInfo couponItemInfo = new CouponItemInfo(); couponItemInfo.UserId = UserId; couponItemInfo.UserName = memberInfo.UserName; couponItemInfo.CanUseProducts = couponInfo.CanUseProducts; couponItemInfo.ClosingTime = couponInfo.ClosingTime; couponItemInfo.CouponId = couponInfo.CouponId; couponItemInfo.CouponName = couponInfo.CouponName; couponItemInfo.OrderUseLimit = couponInfo.OrderUseLimit; couponItemInfo.Price = couponInfo.Price; couponItemInfo.StartTime = couponInfo.StartTime; couponItemInfo.UseWithGroup = couponInfo.UseWithGroup; couponItemInfo.UseWithPanicBuying = couponInfo.UseWithPanicBuying; couponItemInfo.UseWithFireGroup = couponInfo.UseWithFireGroup; couponItemInfo.GetDate = DateTime.Now; couponItemInfo.ClaimCode = Guid.NewGuid().ToString(); if (new CouponDao().Add(couponItemInfo, dbTransaction) <= 0) { dbTransaction.Rollback(); return(false); } } else if (activityAwardItemInfo.PrizeType == 3) { userAwardRecordsInfo.AwardDate = null; userAwardRecordsInfo.AwardName = giftInfo.Name; userAwardRecordsInfo.AwardPic = giftInfo.ThumbnailUrl160; userAwardRecordsInfo.Status = 1; } else { userAwardRecordsInfo.AwardName = activityAwardItemInfo.PrizeValue + "积分"; userAwardRecordsInfo.AwardDate = DateTime.Now; userAwardRecordsInfo.Status = 2; PointDetailInfo pointDetailInfo2 = new PointDetailInfo(); pointDetailInfo2.Increased = activityAwardItemInfo.PrizeValue; pointDetailInfo2.OrderId = ""; if (flag) { pointDetailInfo2.Points = memberInfo.Points + activityAwardItemInfo.PrizeValue; } else { pointDetailInfo2.Points = memberInfo.Points - Info.ConsumptionIntegral + activityAwardItemInfo.PrizeValue; } pointDetailInfo2.Reduced = 0; pointDetailInfo2.Remark = "抽奖获得积分"; pointDetailInfo2.SignInSource = 0; pointDetailInfo2.TradeDate = DateTime.Now; if (Info.ActivityType == 1) { pointDetailInfo2.TradeType = PointTradeType.JoinRotaryTable; } else if (Info.ActivityType == 3) { pointDetailInfo2.TradeType = PointTradeType.JoinSmashingGoldenEgg; } else { pointDetailInfo2.TradeType = PointTradeType.JoinScratchCard; } pointDetailInfo2.UserId = UserId; if (new PointDetailDao().Add(pointDetailInfo2, dbTransaction) <= 0) { dbTransaction.Rollback(); return(false); } } userAwardRecordsInfo.AwardGrade = AwardGrade; userAwardRecordsInfo.AwardId = activityAwardItemInfo.AwardId; userAwardRecordsInfo.CreateDate = DateTime.Now; userAwardRecordsInfo.PrizeType = activityAwardItemInfo.PrizeType; userAwardRecordsInfo.PrizeValue = activityAwardItemInfo.PrizeValue; userAwardRecordsInfo.UserId = UserId; if (activityDao.Add(userAwardRecordsInfo, dbTransaction) <= 0) { dbTransaction.Rollback(); return(false); } dbTransaction.Commit(); return(true); } catch (Exception ex) { dbTransaction.Rollback(); Globals.WriteLog("ActivityLog.txt", "Methed:ManageWinningResult , Id:" + Info.ActivityId + " , Msg:" + ex.Message); return(false); } finally { dbConnection.Close(); } } } }
protected void btnSubmitBatchPoint_Click(object sender, EventArgs e) { ManagerHelper.CheckPrivilege(Privilege.UpdateMemberPoint); if (string.IsNullOrEmpty(this.userIds)) { base.GotoResourceNotFound(); } else { Hashtable hashtable = new Hashtable(); if (this.grdSelectedUsers.Items.Count > 0) { int num = 0; int num2 = 0; if (this.radAdd.Checked) { if (string.IsNullOrEmpty(this.txtAddPoints.Text) || !int.TryParse(this.txtAddPoints.Text.Trim(), out num)) { this.ShowMsg("要增加的积分数不能为空且为正数", false); return; } if (num <= 0) { this.ShowMsg("请输入大于0的积分数", false); return; } } else if (this.RadMinus.Checked) { if (string.IsNullOrEmpty(this.txtMinusPoints.Text) || !int.TryParse(this.txtMinusPoints.Text.Trim(), out num2)) { this.ShowMsg("要减少的积分数不能为空且为正数", false); return; } if (num2 <= 0) { this.ShowMsg("请输入大于0的积分数", false); return; } string[] array = this.userIds.Split(','); for (int i = 0; i < array.Length; i++) { MemberInfo user = Users.GetUser(int.Parse(array[i])); if (num2 > user.Points) { this.ShowMsg("会员【" + user.UserName + "】的积分不足,请调整要减去的积分", false); this.Page.ClientScript.RegisterStartupScript(base.GetType(), "msg", "<script>onRadioClick(2);</script>"); return; } } } PointDetailInfo pointDetailInfo = new PointDetailInfo(); pointDetailInfo.OrderId = ""; pointDetailInfo.TradeType = PointTradeType.AdministratorUpdate; if (this.radAdd.Checked) { pointDetailInfo.Increased = num; pointDetailInfo.Reduced = 0; } else if (this.RadMinus.Checked) { pointDetailInfo.Reduced = num2; pointDetailInfo.Increased = 0; } foreach (RepeaterItem item in this.grdSelectedUsers.Items) { TextBox textBox = item.FindControl("txtListRemark") as TextBox; HiddenField hiddenField = item.FindControl("hidUserId") as HiddenField; string text = textBox.Text; if (string.IsNullOrEmpty(textBox.Text)) { text = this.txtRemark.Text; } text = "操作员:" + HiContext.Current.Manager.UserName + " " + text; hashtable.Add(hiddenField.Value, text); } PointDetailDao pointDetailDao = new PointDetailDao(); if (pointDetailDao.BatchEditPoints(pointDetailInfo, this.userIds, hashtable)) { string[] array2 = this.userIds.Split(','); string[] array3 = array2; foreach (string s in array3) { MemberDao memberDao = new MemberDao(); int userId = 0; if (int.TryParse(s, out userId)) { MemberInfo user2 = Users.GetUser(userId); if (this.radAdd.Checked) { user2.Points += num; } else if (this.RadMinus.Checked) { int num3 = user2.Points - num2; user2.Points = ((num3 >= 0) ? num3 : 0); } int historyPoint = pointDetailDao.GetHistoryPoint(int.Parse(s), null); memberDao.ChangeMemberGrade(userId, user2.Points, historyPoint, null); if (user2 != null) { Users.ClearUserCache(userId, user2.SessionId); } } } base.CloseWindow(null); } else { this.ShowMsg("批量操作失败", false); } } } }