/// <summary> /// 退回用户订单发放的积分 /// </summary> /// <param name="partUserInfo">用户信息</param> /// <param name="orderInfo">订单信息</param> /// <param name="payCredits">支付积分</param> /// <param name="rankCredits">等级积分</param> /// <param name="operatorId">操作人</param> /// <param name="returnTime">退回时间</param> public static void ReturnUserOrderSendCredits(ref PartUserInfo partUserInfo, OrderInfo orderInfo, int payCredits, int rankCredits, int operatorId, DateTime returnTime) { partUserInfo.PayCredits -= payCredits; partUserInfo.RankCredits -= rankCredits; int userRid = UserRanks.GetUserRankByCredits(partUserInfo.RankCredits).UserRid; if (userRid != partUserInfo.UserRid) { partUserInfo.UserRid = userRid; } else { userRid = 0; } CreditLogInfo creditLogInfo = new CreditLogInfo(); creditLogInfo.Uid = orderInfo.Uid; creditLogInfo.PayCredits = -1 * payCredits; creditLogInfo.RankCredits = -1 * rankCredits; creditLogInfo.Action = (int)CreditAction.ReturnOrderSend; creditLogInfo.ActionCode = orderInfo.Oid; creditLogInfo.ActionTime = returnTime; creditLogInfo.ActionDes = "收回订单发放的积分:" + orderInfo.OSN; creditLogInfo.Operator = operatorId; SendCredits(userRid, creditLogInfo); }
/// <summary> /// 初始化用户 /// </summary> /// <param name="userName">用户名</param> /// <param name="uNamePrefix">用户名前缀</param> /// <param name="regionId">区域id</param> /// <returns></returns> private static UserInfo InitUser(string userName, string uNamePrefix, int regionId) { UserInfo userInfo = new UserInfo(); userInfo.Salt = Randoms.CreateRandomValue(6); userInfo.Password = Users.CreateUserPassword(Randoms.CreateRandomValue(32, false), userInfo.Salt); userInfo.StoreId = 0; //无店铺 userInfo.MallAGid = 1; //非管理员组 userInfo.UserName = GetValidUserName(userName, uNamePrefix); userInfo.Email = string.Empty; userInfo.Mobile = string.Empty; userInfo.NickName = StringHelper.SubString(userName, 20); userInfo.Avatar = ""; userInfo.PayCredits = 0; userInfo.RankCredits = 0; userInfo.VerifyEmail = 0; userInfo.VerifyMobile = 0; userInfo.UserRid = UserRanks.GetUserRankByCredits(userInfo.PayCredits).UserRid;//根据积分判读用户等级 userInfo.LiftBanTime = new DateTime(1900, 1, 1); userInfo.LastVisitTime = DateTime.Now; userInfo.LastVisitIP = WebHelper.GetIP(); userInfo.LastVisitRgId = regionId; userInfo.RegisterTime = DateTime.Now; userInfo.RegisterIP = WebHelper.GetIP(); userInfo.RegisterRgId = regionId; userInfo.Gender = 0; userInfo.RealName = string.Empty; userInfo.Bday = new DateTime(1900, 1, 1); userInfo.IdCard = string.Empty; userInfo.RegionId = 0; userInfo.Address = string.Empty; userInfo.Bio = string.Empty; return(userInfo); }
/// <summary> /// 发放登录积分 /// </summary> /// <param name="partUserInfo">用户信息</param> /// <param name="loginTime">登录时间</param> /// <param name="oldTime">上次发放登录积分时间</param> /// <param name="newTime">本次发放登录积分时间</param> public static void SendLoginCredits(ref PartUserInfo partUserInfo, DateTime loginTime, DateTime oldTime, out DateTime newTime) { newTime = oldTime; if (_creditconfiginfo.LoginPayCredits > 0 || _creditconfiginfo.LoginRankCredits > 0) { if (loginTime.Date <= oldTime.Date) { return; } if (!IsSendTodayLoginCredit(partUserInfo.Uid, DateTime.Now)) { newTime = loginTime; int surplusPayCredits = GetDaySurplusPayCredits(partUserInfo.Uid, loginTime.Date); int surplusRankCredits = GetDaySurplusRankCredits(partUserInfo.Uid, loginTime.Date); if (surplusPayCredits == 0 && surplusRankCredits == 0) { return; } int payCredits = 0; int rankCredits = 0; if (surplusPayCredits > 0) { payCredits = surplusPayCredits < _creditconfiginfo.LoginPayCredits ? surplusPayCredits : _creditconfiginfo.LoginPayCredits; } else if (surplusPayCredits == -1) { payCredits = _creditconfiginfo.LoginPayCredits; } if (surplusRankCredits > 0) { rankCredits = surplusRankCredits < _creditconfiginfo.LoginRankCredits ? surplusRankCredits : _creditconfiginfo.LoginRankCredits; } else if (surplusRankCredits == -1) { rankCredits = _creditconfiginfo.LoginRankCredits; } partUserInfo.PayCredits += payCredits; partUserInfo.RankCredits += rankCredits; partUserInfo.UserRid = UserRanks.GetUserRankByCredits(partUserInfo.RankCredits).UserRid; CreditLogInfo creditLogInfo = new CreditLogInfo(); creditLogInfo.Uid = partUserInfo.Uid; creditLogInfo.PayCredits = payCredits; creditLogInfo.RankCredits = rankCredits; creditLogInfo.Action = (int)CreditAction.Login; creditLogInfo.ActionCode = 0; creditLogInfo.ActionTime = loginTime; creditLogInfo.ActionDes = "登录赠送积分"; creditLogInfo.Operator = 0; SendCredits(partUserInfo.UserRid, creditLogInfo); } } }
/// <summary> /// 发放评价商品积分 /// </summary> /// <param name="partUserInfo">用户信息</param> /// <param name="orderProductInfo">订单商品</param> /// <param name="reviewTime">评价时间</param> public static int SendReviewProductCredits(ref PartUserInfo partUserInfo, OrderProductInfo orderProductInfo, DateTime reviewTime) { if (_creditconfiginfo.ReviewProductPayCredits > 0 || _creditconfiginfo.ReviewProductRankCredits > 0) { int surplusPayCredits = GetDaySurplusPayCredits(partUserInfo.Uid, reviewTime.Date); int surplusRankCredits = GetDaySurplusRankCredits(partUserInfo.Uid, reviewTime.Date); if (surplusPayCredits == 0 && surplusRankCredits == 0) { return(0); } int payCredits = 0; int rankCredits = 0; if (surplusPayCredits > 0) { payCredits = surplusPayCredits < _creditconfiginfo.ReviewProductPayCredits ? surplusPayCredits : _creditconfiginfo.ReviewProductPayCredits; } else if (surplusPayCredits == -1) { payCredits = _creditconfiginfo.ReviewProductPayCredits; } if (surplusRankCredits > 0) { rankCredits = surplusRankCredits < _creditconfiginfo.ReviewProductRankCredits ? surplusRankCredits : _creditconfiginfo.ReviewProductRankCredits; } else if (surplusRankCredits == -1) { rankCredits = _creditconfiginfo.ReviewProductRankCredits; } partUserInfo.PayCredits += payCredits; partUserInfo.RankCredits += rankCredits; int userRid = UserRanks.GetUserRankByCredits(partUserInfo.RankCredits).UserRid; if (userRid != partUserInfo.UserRid) { partUserInfo.UserRid = userRid; } else { userRid = 0; } CreditLogInfo creditLogInfo = new CreditLogInfo(); creditLogInfo.Uid = partUserInfo.Uid; creditLogInfo.PayCredits = payCredits; creditLogInfo.RankCredits = rankCredits; creditLogInfo.Action = (int)CreditAction.ReviewProduct; creditLogInfo.ActionCode = orderProductInfo.Oid; creditLogInfo.ActionTime = reviewTime; creditLogInfo.ActionDes = "评价商品:" + orderProductInfo.Name; creditLogInfo.Operator = 0; SendCredits(userRid, creditLogInfo); return(payCredits); } return(0); }
/// <summary> /// 发放完成订单积分 /// </summary> /// <param name="partUserInfo">用户信息</param> /// <param name="orderInfo">订单信息</param> /// <param name="orderProductList">订单商品列表</param> /// <param name="completeTime">完成时间</param> public static void SendCompleteOrderCredits(ref PartUserInfo partUserInfo, OrderInfo orderInfo, List <OrderProductInfo> orderProductList, DateTime completeTime) { if (_creditconfiginfo.CompleteOrderPayCredits > 0 || _creditconfiginfo.CompleteOrderRankCredits > 0) { int surplusPayCredits = GetDaySurplusPayCredits(partUserInfo.Uid, completeTime.Date); int surplusRankCredits = GetDaySurplusRankCredits(partUserInfo.Uid, completeTime.Date); if (surplusPayCredits == 0 && surplusRankCredits == 0) { return; } int payCredits = 0; int rankCredits = 0; int tempPayCredits = (int)Math.Floor(orderInfo.OrderAmount * _creditconfiginfo.CompleteOrderPayCredits / 100); int tempRankCredits = (int)Math.Floor(orderInfo.OrderAmount * _creditconfiginfo.CompleteOrderRankCredits / 100); if (surplusPayCredits > 0) { payCredits = surplusPayCredits < tempPayCredits ? surplusPayCredits : tempPayCredits; } else if (surplusPayCredits == -1) { payCredits = tempPayCredits; } if (surplusRankCredits > 0) { rankCredits = surplusRankCredits < tempRankCredits ? surplusRankCredits : tempRankCredits; } else if (surplusRankCredits == -1) { rankCredits = tempRankCredits; } partUserInfo.PayCredits += payCredits; partUserInfo.RankCredits += rankCredits; int userRid = UserRanks.GetUserRankByCredits(partUserInfo.RankCredits).UserRid; if (userRid != partUserInfo.UserRid) { partUserInfo.UserRid = userRid; } else { userRid = 0; } CreditLogInfo creditLogInfo = new CreditLogInfo(); creditLogInfo.Uid = partUserInfo.Uid; creditLogInfo.PayCredits = payCredits; creditLogInfo.RankCredits = rankCredits; creditLogInfo.Action = (int)CreditAction.CompleteOrder; creditLogInfo.ActionCode = orderInfo.Oid; creditLogInfo.ActionTime = completeTime; creditLogInfo.ActionDes = "完成订单:" + orderInfo.OSN; creditLogInfo.Operator = 0; SendCredits(userRid, creditLogInfo); } }
/// <summary> /// 发放完善用户信息积分 /// </summary> /// <param name="partUserInfo">用户信息</param> /// <param name="completeTime">完成时间</param> public static void SendCompleteUserInfoCredits(ref PartUserInfo partUserInfo, DateTime completeTime) { if ((_creditconfiginfo.CompleteUserInfoPayCredits > 0 || _creditconfiginfo.CompleteUserInfoRankCredits > 0) && !IsSendCompleteUserInfoCredit(partUserInfo.Uid)) { int surplusPayCredits = GetDaySurplusPayCredits(partUserInfo.Uid, completeTime.Date); int surplusRankCredits = GetDaySurplusRankCredits(partUserInfo.Uid, completeTime.Date); if (surplusPayCredits == 0 && surplusRankCredits == 0) { return; } int payCredits = 0; int rankCredits = 0; if (surplusPayCredits > 0) { payCredits = surplusPayCredits < _creditconfiginfo.CompleteUserInfoPayCredits ? surplusPayCredits : _creditconfiginfo.CompleteUserInfoPayCredits; } else if (surplusPayCredits == -1) { payCredits = _creditconfiginfo.CompleteUserInfoPayCredits; } if (surplusRankCredits > 0) { rankCredits = surplusRankCredits < _creditconfiginfo.CompleteUserInfoRankCredits ? surplusRankCredits : _creditconfiginfo.CompleteUserInfoRankCredits; } else if (surplusRankCredits == -1) { rankCredits = _creditconfiginfo.CompleteUserInfoRankCredits; } partUserInfo.PayCredits += payCredits; partUserInfo.RankCredits += rankCredits; int userRid = UserRanks.GetUserRankByCredits(partUserInfo.RankCredits).UserRid; if (userRid != partUserInfo.UserRid) { partUserInfo.UserRid = userRid; } else { userRid = 0; } CreditLogInfo creditLogInfo = new CreditLogInfo(); creditLogInfo.Uid = partUserInfo.Uid; creditLogInfo.PayCredits = payCredits; creditLogInfo.RankCredits = rankCredits; creditLogInfo.Action = (int)CreditAction.CompleteUserInfo; creditLogInfo.ActionCode = 0; creditLogInfo.ActionTime = completeTime; creditLogInfo.ActionDes = "完善用户信息"; creditLogInfo.Operator = 0; SendCredits(userRid, creditLogInfo); } }
/// <summary> /// 发放验证手机积分 /// </summary> /// <param name="partUserInfo">用户信息</param> /// <param name="verifyTime">验证时间</param> public static void SendVerifyMobileCredits(ref PartUserInfo partUserInfo, DateTime verifyTime) { if (partUserInfo.VerifyMobile == 0 && (_creditconfiginfo.VerifyMobilePayCredits > 0 || _creditconfiginfo.VerifyMobileRankCredits > 0)) { int surplusPayCredits = GetDaySurplusPayCredits(partUserInfo.Uid, verifyTime.Date); int surplusRankCredits = GetDaySurplusRankCredits(partUserInfo.Uid, verifyTime.Date); if (surplusPayCredits == 0 && surplusRankCredits == 0) { return; } int payCredits = 0; int rankCredits = 0; if (surplusPayCredits > 0) { payCredits = surplusPayCredits < _creditconfiginfo.VerifyMobilePayCredits ? surplusPayCredits : _creditconfiginfo.VerifyMobilePayCredits; } else if (surplusPayCredits == -1) { payCredits = _creditconfiginfo.VerifyMobilePayCredits; } if (surplusRankCredits > 0) { rankCredits = surplusRankCredits < _creditconfiginfo.VerifyMobileRankCredits ? surplusRankCredits : _creditconfiginfo.VerifyMobileRankCredits; } else if (surplusRankCredits == -1) { rankCredits = _creditconfiginfo.VerifyMobileRankCredits; } partUserInfo.PayCredits += payCredits; partUserInfo.RankCredits += rankCredits; int userRid = UserRanks.GetUserRankByCredits(partUserInfo.RankCredits).UserRid; if (userRid != partUserInfo.UserRid) { partUserInfo.UserRid = userRid; } else { userRid = 0; } CreditLogInfo creditLogInfo = new CreditLogInfo(); creditLogInfo.Uid = partUserInfo.Uid; creditLogInfo.PayCredits = payCredits; creditLogInfo.RankCredits = rankCredits; creditLogInfo.Action = (int)CreditAction.VerifyMobile; creditLogInfo.ActionCode = 0; creditLogInfo.ActionTime = verifyTime; creditLogInfo.ActionDes = "验证用户手机"; creditLogInfo.Operator = 0; SendCredits(userRid, creditLogInfo); } }
/// <summary> /// 发放注册积分 /// </summary> /// <param name="userInfo">用户信息</param> /// <param name="verifyTime">注册时间</param> public static void SendRegisterCredits(ref UserInfo userInfo, DateTime registerTime) { if (_creditconfiginfo.RegisterPayCredits > 0 || _creditconfiginfo.RegisterRankCredits > 0) { int surplusPayCredits = GetDaySurplusPayCredits(userInfo.Uid, registerTime.Date); int surplusRankCredits = GetDaySurplusRankCredits(userInfo.Uid, registerTime.Date); if (surplusPayCredits == 0 && surplusRankCredits == 0) { return; } int payCredits = 0; int rankCredits = 0; if (surplusPayCredits > 0) { payCredits = surplusPayCredits < _creditconfiginfo.RegisterPayCredits ? surplusPayCredits : _creditconfiginfo.RegisterPayCredits; } else if (surplusPayCredits == -1) { payCredits = _creditconfiginfo.RegisterPayCredits; } if (surplusRankCredits > 0) { rankCredits = surplusRankCredits < _creditconfiginfo.RegisterRankCredits ? surplusRankCredits : _creditconfiginfo.RegisterRankCredits; } else if (surplusRankCredits == -1) { rankCredits = _creditconfiginfo.RegisterRankCredits; } userInfo.PayCredits += payCredits; userInfo.RankCredits += rankCredits; int userRid = UserRanks.GetUserRankByCredits(userInfo.RankCredits).UserRid; if (userRid != userInfo.UserRid) { userInfo.UserRid = userRid; } else { userRid = 0; } CreditLogInfo creditLogInfo = new CreditLogInfo(); creditLogInfo.Uid = userInfo.Uid; creditLogInfo.PayCredits = payCredits; creditLogInfo.RankCredits = rankCredits; creditLogInfo.Action = (int)CreditAction.Register; creditLogInfo.ActionCode = 0; creditLogInfo.ActionTime = registerTime; creditLogInfo.ActionDes = "注册赠送积分"; creditLogInfo.Operator = 0; SendCredits(userRid, creditLogInfo); } }
/// <summary> /// 管理员发放积分 /// </summary> /// <param name="partUserInfo">用户信息</param> /// <param name="payCredits">支付积分</param> /// <param name="rankCredits">等级积分</param> /// <param name="sendUid">发放用户id</param> /// <param name="sendTime">发放时间</param> public static void AdminSendCredits(PartUserInfo partUserInfo, int payCredits, int rankCredits, int sendUid, DateTime sendTime) { partUserInfo.UserRid = UserRanks.GetUserRankByCredits(partUserInfo.RankCredits + rankCredits).UserRid; CreditLogInfo creditLogInfo = new CreditLogInfo(); creditLogInfo.Uid = partUserInfo.Uid; creditLogInfo.PayCredits = payCredits; creditLogInfo.RankCredits = rankCredits; creditLogInfo.Action = (int)CreditAction.AdminSend; creditLogInfo.ActionTime = sendTime; creditLogInfo.ActionCode = 0; creditLogInfo.ActionDes = "管理员发放"; creditLogInfo.Operator = sendUid; SendCredits(partUserInfo.UserRid, creditLogInfo); }
/// <summary> /// 发放登陆积分 /// </summary> /// <param name="partUserInfo">用户信息</param> /// <param name="loginTime">登陆时间</param> public static void SendLoginCredits(ref PartUserInfo partUserInfo, DateTime loginTime) { if (_creditconfiginfo.LoginPayCredits > 0 || _creditconfiginfo.LoginRankCredits > 0) { DateTime slcTime = TypeHelper.StringToDateTime(WebHelper.UrlDecode(MallUtils.GetBMACookie("slctime")), loginTime.Date.AddDays(-2)); if (loginTime.Date <= slcTime.Date) { return; } if (!IsSendTodayLoginCredit(partUserInfo.Uid, DateTime.Now)) { MallUtils.SetBMACookie("slctime", WebHelper.UrlEncode(loginTime.ToString())); int surplusPayCredits = GetDaySurplusPayCredits(partUserInfo.Uid, loginTime.Date); int surplusRankCredits = GetDaySurplusRankCredits(partUserInfo.Uid, loginTime.Date); if (surplusPayCredits == 0 && surplusRankCredits == 0) { return; } int payCredits = 0; int rankCredits = 0; if (surplusPayCredits > 0) { payCredits = surplusPayCredits < _creditconfiginfo.LoginPayCredits ? surplusPayCredits : _creditconfiginfo.LoginPayCredits; } else if (surplusPayCredits == -1) { payCredits = _creditconfiginfo.LoginPayCredits; } if (surplusRankCredits > 0) { rankCredits = surplusRankCredits < _creditconfiginfo.LoginRankCredits ? surplusRankCredits : _creditconfiginfo.LoginRankCredits; } else if (surplusRankCredits == -1) { rankCredits = _creditconfiginfo.LoginRankCredits; } partUserInfo.PayCredits += payCredits; partUserInfo.RankCredits += rankCredits; int userRid = UserRanks.GetUserRankByCredits(partUserInfo.RankCredits).UserRid; if (userRid != partUserInfo.UserRid) { partUserInfo.UserRid = userRid; } else { userRid = 0; } CreditLogInfo creditLogInfo = new CreditLogInfo(); creditLogInfo.Uid = partUserInfo.Uid; creditLogInfo.PayCredits = payCredits; creditLogInfo.RankCredits = rankCredits; creditLogInfo.Action = (int)CreditAction.Login; creditLogInfo.ActionCode = 0; creditLogInfo.ActionTime = loginTime; creditLogInfo.ActionDes = "登陆赠送积分"; creditLogInfo.Operator = 0; SendCredits(userRid, creditLogInfo); } } }