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 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); } } }
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); } } } }