/// <summary> /// 添加系统用户 /// </summary> /// <param name="command"></param> public void Execute(AddUserCommand command) { var sysMember = new SysMember(); sysMember.Mapp(command); var check = sysMember.ValidateUserInfo(); if (!check.success) { command.Result.Status = false; command.Result.Msg = check.msg; return; } //加密密码 sysMember.DesPwd(); if (memberRepository.Exist(sysMember.Account)) { command.Result.Status = false; command.Result.Msg = "用户登录名已存在!"; return; } command.RolesCmd.ForEach(r => { sysMember.AddRole(r.id, r.name); }); var rlt = memberRepository.AddMember(sysMember); command.Result.Status = rlt.success; command.Result.Msg = rlt.msg; }
public bool SaveChange(SysMember entity) { var snapshot = GetById(entity.ID); var rlt = _baseQueryRepository.Context.Ado.UseTran(() => { var userTemp = new sys_member(); userTemp.Mapp(entity); var success = _baseQueryRepository.Context.Updateable(userTemp) .Where(it => it.ID == entity.ID) .ExecuteCommand();//主表 snapshot.Roles.Where(r => !entity.Roles.Exists(rr => rr.ID == r.ID)).ToList().ForEach(r => { _baseQueryRepository.Context.Ado.ExecuteCommand("delete from sys_member_roles_link where mid=@mid and rid=@rid;" , new { mid = entity.ID, rid = r.ID }); }); entity.Roles.Where(r => !snapshot.Roles.Exists(rr => rr.ID == r.ID)).ToList().ForEach(r => { var smrlink = new sys_member_roles_link() { ID = IdWorker.NextId(), mid = entity.ID, rid = r.ID }; _baseQueryRepository.Context.Insertable(smrlink).ExecuteCommand(); }); }); return(true); }
protected bool CheckData() { string message; bool isSuccess = true; if (!string.IsNullOrEmpty(txtMyFriend.Text)) { _rUser = UserBLL.GetUserByPhoneNum(txtMyFriend.Text.Trim()); if (_rUser == null) { lblRMember.InnerHtml = "你输入的推荐人不存在!"; AddRedColorStyle(lblRMember); _rUser = null; isSuccess = false; } else if (_rUser.CompanyId > 0) { lblRMember.InnerHtml = ("你输入的推荐人账号是商家账号"); AddRedColorStyle(lblRMember); _rUser = null; isSuccess = false; } } if (!UserBLL.CheckUserName(this.txtMemberPhone.Text, out message)) { this.lblPhoneInfo.InnerHtml = (message); AddRedColorStyle(lblPhoneInfo); isSuccess = false; } if (!UserBLL.CheckUserPwd(this.txtMemberPwd1.Text, out message)) { this.lblPwd1Info.InnerHtml = (message); AddRedColorStyle(lblPwd1Info); isSuccess = false; } if (string.Compare(this.txtMemberPwd1.Text, this.txtMemberPwd2.Text) != 0) { this.lblPwd2Info.InnerHtml = ("两次输入的密码不同!"); AddRedColorStyle(lblPwd2Info); isSuccess = false; } //if (!SubSonic.Sugar.Validation.IsEmail(txtMemberEmail.Text)) // LogMessage("电子邮箱的格式不正确!"); //if (string.IsNullOrEmpty(txtMemberName.Text)) // LogMessage("会员名不能为空!"); if (UserBLL.CheckUserExist(txtMemberPhone.Text)) { this.lblPhoneInfo.InnerHtml = ("该手机已经注册"); AddRedColorStyle(lblPhoneInfo); isSuccess = false; } return isSuccess; }
/// <summary> /// 用户启用停用 /// </summary> /// <param name="command"></param> public void Execute(EnableUserCommand command) { SysMember sysMember = memberRepository.GetById(command.Id); sysMember.Enable((short)command.State); memberRepository.SaveChange(sysMember); command.Result = new CommandResult() { Status = true }; }
/// <summary> /// 管理员重置用户密码 /// </summary> /// <param name="command"></param> public void Execute(ReSetPwdCommand command) { SysMember sysMember = memberRepository.GetById(command.Id); sysMember.ReSetPwd(Common.CryptoHelper.TripleDesEncrypting(Const.AppSettings.DefaultPwd)); memberRepository.SaveChange(sysMember); command.Result = new CommandResult() { Status = true }; }
/// <summary> /// 修改密码 /// </summary> /// <param name="command"></param> public void Execute(ChangePwdCommand command) { SysMember sysMember = memberRepository.GetById(command.Id); sysMember.ChangePwd(command.pwd, command.opwd); memberRepository.SaveChange(sysMember); command.Result = new CommandResult() { Status = true, Msg = "修改密码成功!" }; }
/// <summary> /// 用户登录后 持久化指令 Token /// </summary> /// <param name="command"></param> public void Execute(LoginRecordCommand command) { SysMember sysMember = memberRepository.GetById(command.Id); sysMember.SetProfile(command.Token); memberRepository.SaveChange(sysMember); command.Result = new CommandResult() { Status = true }; }
/// <summary> /// 保存用户角色 /// </summary> /// <param name="command"></param> public void Execute(SaveUserRoleCommand command) { SysMember sysMember = memberRepository.GetById(command.Id); sysMember.RemoveAllRole(); command.UserRole.ForEach(r => { sysMember.AddRole(r.ID, r.name); }); //var rlt = sysMember.AddRoles(command.UserRole); memberRepository.SaveChange(sysMember); command.Result = new CommandResult() { Status = true }; }
public (bool success, string msg) AddMember(SysMember sysMember) { var rlt = _baseQueryRepository.Context.Ado.UseTran(() => { var userTemp = new sys_member(); userTemp.Mapp(sysMember); _baseQueryRepository.Context.Insertable(userTemp).ExecuteCommand(); sysMember.Roles.ForEach(role => { var mrlink = new Model.sys_member_roles_link { ID = IdWorker.NextId(), mid = userTemp.ID, rid = role.ID }; _baseQueryRepository.Context.Insertable(mrlink).ExecuteCommand(); }); }); return(rlt.IsSuccess, rlt.IsSuccess ? null : rlt.ErrorMessage); }
private string UserGradeInfo(SysMember member) { if (!string.IsNullOrEmpty(_userGradeInfo)) return _userGradeInfo; _userGradeInfo = UserBLL.UserGradeInfo(member); return _userGradeInfo; }
bool SaveMemberCompany(DataRow row, SysMember user) { if (user.IsNew || CompanyBLL.CheckIsOwnerUser(user.Id, CurrentUser.CompanyId.Value)) return false; new SysMemberCompany { MemberCompanyCompanyID = CurrentUser.CompanyId.Value, MemberCompanyMemberID = user.Id, MemberCompanyDate = DateTime.Now, MemberGrade = GetMemberGrade(Utilities.ToString(row[ColumnMap[SysCompanyMemberGrade.GradeNameColumn]])) }.Save( ); return true; }
public static int ReplyFaceBook(int faceBookID, SysMember replyUser, string replyContent, out string message) { int code = -1; SysCompanyFaceBook faceBook = SysCompanyFaceBook.FetchByID(faceBookID); if (faceBook == null) { message = "评论内容不存在."; goto lbl_return; } var fbType = Formatter.ToEnum<FaceBookType>(faceBook.FaceBookBizType); if (fbType == FaceBookType.Eleooo) { if (!replyUser.AdminRoleId.HasValue || replyUser.AdminRoleId.Value <= 0) { message = "吐槽内容,只有管理员才能回复."; goto lbl_return; } } else if (fbType == FaceBookType.OrderMeal) { if (replyUser.CompanyId != faceBook.FaceBookBizID && replyUser.AdminRoleId.Value <= 0) { message = "你不能回复不属于你的评论."; goto lbl_return; } } if (string.IsNullOrEmpty(replyContent)) { message = "请输入回复内容"; goto lbl_return; } faceBook.ReplyDate = DateTime.Now; faceBook.ReplyMemberID = replyUser.Id; faceBook.ReplyMemo = replyContent; faceBook.IsRead = false; faceBook.Save( ); message = "回复成功"; lbl_return: return code; }
public static void ClickCompanyMealItem(SysCompany company, SysMember user, SysCompanyItem item, Order order, decimal userLastOrderSum) { Payment p = null; Func<SysMemberItem> fnNew = ( ) => { item.ItemClicked = Utilities.ToInt(item.ItemClicked) + 1; item.Save( ); if (item.ItemPoint.HasValue && item.ItemPoint.Value > 0) { p = new Payment { PaymentCode = string.Empty, PaymentCompanyID = item.CompanyID, PaymentDate = order.OrderDate, PaymentEmail = string.Empty, PaymentMemberID = user.Id, PaymentOrderID = order.Id, PaymentStatus = 1, PaymentType = (int)PaymentType.CompanyItem }; } return new SysMemberItem( ) { PaymentID = 0, CompanyID = company.Id, CompanyItemID = item.ItemID, MemberID = user.Id, OrderID = order.Id }; }; Func<SysMemberItem> fnOld = ( ) => { var memberItem = GetMemberMealItemByOrderId(order.Id, user.Id); if (memberItem != null) p = Payment.FetchByID(memberItem.PaymentID); return memberItem; }; SysMemberItem data = fnOld( ) ?? fnNew( ); data.ItemDate = order.OrderDate; data.OrderDate = order.OrderDate; data.OrderSum = userLastOrderSum; data.ItemPoint = item.ItemPoint; data.ItemStatus = (int)MemberCompanyItemStatus.InProgress; data.SetDate = null; data.IsCanModifiedDate = true; if (p != null) { if (item.ItemPoint.HasValue && item.ItemPoint.Value > 0) { p.PaymentMemo = string.Format("抢购【{0}】的优惠项目,并使用{1:0.00}个积分消费", company.CompanyName, item.ItemPoint); p.PaymentSum = -item.ItemPoint.Value; p.Save( ); data.PaymentID = p.Id; } else { Payment.Delete(p.Id); data.PaymentID = 0; } } data.Save( ); }
public static void RewardMemberPointForOrderMeal(SysMember user, SysCompany company, Order order) { if (Formatter.ToEnum<OrderType>(order.OrderType.Value) != OrderType.OrderMeal) return; decimal point = CalcRewardMemberPointForOrderMeal(order,company); if (point <= 0) return; string memo = "在【{0}】订餐消费{1:0.00}元,您获奖励{2:0.00}个积分"; //处理消费赠送积分 Payment p = OrderMealBLL.GetOrderMealPayment(order, order.OrderMemberID); if (p == null) p = new Payment { PaymentDate = order.OrderDate, PaymentCode = order.OrderCode, PaymentCompanyID = UserBLL.MainCompanyAccount.Id, PaymentEmail = string.Empty, PaymentMemberID = user.Id, PaymentMemo = string.Format(memo, company.CompanyName, order.OrderSumOk, point), PaymentOrderID = order.Id, PaymentStatus = 1, PaymentSum = point, PaymentType = (int)PaymentType.ConsumeGive }; else { p.PaymentMemo = string.Format(memo, company.CompanyName, order.OrderSumOk, point); p.PaymentSum = point; } p.Save( ); UpdateOrderPoint(order.Id, point); RewardMemberPoint(user, order); //r.PaymentID = p.Id; //r.ValidateWhenSaving = false; //r.Save( ); }
public static bool UserHasArea(SysMember user) { return !(string.IsNullOrEmpty(user.AreaDepth1) && string.IsNullOrEmpty(user.AreaDepth2) && string.IsNullOrEmpty(user.AreaDepth3)); }
internal static SysCompany MemberToCompany(SysMember member) { if (member != null && member.CompanyId > 0) { SysCompany company = AppContextBase.Context.Company != null && member.CompanyId == AppContextBase.Context.Company.Id ? AppContextBase.Context.Company : SysCompany.FetchByID(member.CompanyId); if (company == null) goto lbl_null; if (company.DirtyColumns.Count > 0) company.MarkClean(); company.MarkOld(); company.CompanyAddress = member.MemberAddress1; company.CompanyCity = member.MemberCity; company.CompanyLocation = member.MemberLocation; company.CompanyArea = member.MemberArea; company.AreaDepth = member.AreaDepth1; company.CompanyEmail = member.MemberEmail; return company; } lbl_null: return null; }
bool ValidateMember( ) { string phoneNum = hdnMemberPhone.Value; if (string.IsNullOrEmpty(phoneNum)) { lblMemberInfo.InnerHtml = "会员账号不能为空!"; txtMemberPhone.Focus( ); return false; } user = UserBLL.GetUserByPhoneNum(hdnMemberPhone.Value); if (user == null) { lblMemberInfo.InnerHtml = "你输入的会员账号不存在! "; txtMemberPhone.Focus( ); return false; } if (user.CompanyId > 0) { lblMemberInfo.InnerHtml = "你不能用此账号进行充值,此账号属于商家账号!"; txtMemberPhone.Focus( ); return false; } //if (user.MemberGrade != null) //{ // cbMemberGrade.SelectedIndex = Utilities.ToInt(user.MemberGrade); //} return true; }
public void InitCashData( ) { _cashData = null; CashUser = null; PhoneNum = string.Empty; }
public static DataTable GetUserInfoDataTable(SysMember user) { DataTable dtUserInfo = SubSonic.Utilities.EntityFormat.GetUserInfoTable(); dtUserInfo.Rows.Add(ResBLL.GetColumnRes(SysMember.MemberPhoneNumberColumn), user.MemberPhoneNumber); dtUserInfo.Rows.Add(ResBLL.GetColumnRes(SysMember.MemberFullnameColumn), user.MemberFullname); //SysCompany company = SysCompany.FetchByID(user.MemberCompanyID); //if (company != null) // dtUserInfo.Rows.Add(AppRes.GetColumnRes(SysCompany.CompanyNameColumn),company.CompanyName); //if (user.MemberGrade > 0) //{ // SysCompanyMemberGrade grade = SysCompanyMemberGrade.FetchByID(user.MemberGrade); // if (grade != null) // dtUserInfo.Rows.Add(AppRes.GetColumnRes(SysCompanyMemberGrade.GradeNameColumn), grade.GradeName); //} dtUserInfo.Rows.Add(ResBLL.GetColumnRes(SysMember.MemberBalanceCashColumn), user.MemberBalanceCash); dtUserInfo.Rows.Add(ResBLL.GetColumnRes(SysMember.MemberBalanceColumn), user.MemberBalance); return dtUserInfo; }
public int SaveCash(SysMember user, SysMemberCash cash, out string message) { message = string.Empty; try { if (cash.CashSum <= 0) { message = "充值金额不能小于零"; return -1; } if (cash.CashPoint == null) cash.CashPoint = 0; if (cash.CashRate == null) cash.CashRate = 0; return ServiceProvider.Service.SaveCash(cash, user, out message); } catch (Exception ex) { message = ex.Message; return -1; } }
public static string UserGradeInfo(SysMember member) { string result = string.Empty; if (member == null) goto lbl_return; if (member.CompanyId > 0) { result = "商家账号"; goto lbl_return; } result = GradeBLL.GetUserCurrentGrade(AppContextBase.Context.Company.Id, member.Id); if (string.IsNullOrEmpty(result) || result == "0") { result = (CompanyBLL.CheckIsOwnerUser(member.Id, AppContextBase.Context.Company.Id)) ? "本店会员" : "外来会员"; } lbl_return: return result; }
public static bool CanClickCompanyMealItem(SysCompany company, SysMember user, SysCompanyItem item, int orderId, out decimal userLastOrderSum, out string message) { userLastOrderSum = 0; if (item == null || user == null || company.Id != item.CompanyID) { message = "参数错误!"; goto lbl_end; } userLastOrderSum = UserBLL.GetUserAvgOrderSum(user.Id); int result = CompanyItemBLL.ExecuteCheckFunc(user.Id, item.ItemID, userLastOrderSum, orderId); if (result < 0) { message = ItemCheckResult.ContainsKey(result) ? ItemCheckResult[result] : "你无权抢购此优惠项目!"; goto lbl_end; } //判断会员积分是否足够 decimal point = DB.Select(SysMember.Columns.MemberBalance).From<SysMember>( ) .Where(SysMember.IdColumn).IsEqualTo(user.Id) .ExecuteScalar<decimal>( ); if (item.ItemPoint.HasValue && point < item.ItemPoint.Value) { message = "您的账户积分不足,无法抢购此优惠"; goto lbl_end; } message = string.Empty; return true; lbl_end: return false; }
public static int UserLogin(string txtUserName, string txtUserPass, SubSystem subSys, LoginSystem sys, out SysMember loginUser) { loginUser = null; int id = 0; if (txtUserName.Length <= 9) int.TryParse(txtUserName, out id); SqlQuery query = null; if (id > 0) query = DB.Select().From<SysMember>() .Where(SysMember.IdColumn).IsEqualTo(id); else query = DB.Select().From<SysMember>() .Where(SysMember.MemberPhoneNumberColumn).IsEqualTo(txtUserName); if (subSys == SubSystem.Company) query.And(SysMember.CompanyIdColumn).IsGreaterThan(0); SysMemberCollection users = query.ExecuteAsCollection<SysMemberCollection>(); if (users == null || users.Count == 0) return 1; bool bPass = false; SysMember user = null; foreach (SysMember item in users) { string enPass = Utilities.DESEncrypt(txtUserPass); bPass = Utilities.Compare(item.MemberPwd, txtUserPass) || Utilities.Compare(item.MemberPwd, enPass); if (bPass) { if (Utilities.Compare(item.MemberPwd, txtUserPass)) item.MemberPwd = enPass; user = item; break; } } if (!bPass) return 2; if (user.MemberRoleId == null) user.MemberRoleId = 0; if (user.CompanyRoleId == null) user.CompanyRoleId = 0; if (user.AdminRoleId == null) user.AdminRoleId = 0; int roleId = 0; switch (subSys) { case SubSystem.Admin: roleId = Convert.ToInt32(user.AdminRoleId); break; case SubSystem.Member: roleId = Convert.ToInt32(user.MemberRoleId); break; case SubSystem.Company: roleId = Convert.ToInt32(user.CompanyRoleId); break; } if (GetUserRoleAssignmentById(roleId) == null) { return 3; } if (user.MemberStatus != 1) { return 4; } user.ValidateWhenSaving = false; user.LastLoginSubSys = (int)subSys; user.LastLoginDate = DateTime.Now; user.Save(user.Id); if (sys != LoginSystem.Mobile) Utilities.LoginSigIn(user.Id, subSys, sys); loginUser = user; return 0; }
public static void RewardMemberPoint(SysMember user, Order order) { //if (AppContextBase.Context.CompanyType.HasValue && AppContextBase.Context.CompanyType.Value != CompanyType.UnionCompany) // return; if (!user.MemberPid.HasValue || user.MemberPid.Value <= 0) return; SysMember rUser = SysMember.FetchByID(user.MemberPid); if (rUser == null || rUser.CompanyId > 0) return; SysReward reward = Reward; if (reward == null) return; //是否在推广期内注册 bool isCanReward = user.MemberDate.Value >= reward.RewardDate.Value && user.MemberDate.Value < reward.RewardEndDate.Value.AddDays(1); if (!isCanReward) return; //是否一直有效 if (reward.RewardFlag.HasValue && reward.RewardFlag.Value == 0) { var query = DB.Select( ).From<SysMemberReward>( ) .Where(SysMemberReward.OrderMemberIDColumn).IsEqualTo(user.Id) .And(SysMemberReward.RewardMemberIDColumn).IsEqualTo(rUser.Id); if (query.GetRecordCount( ) > 0) return; } decimal point = order.OrderSumOk.Value * (RewardRate / 100M); if (point <= 0) return; string companyName = CompanyBLL.GetCompanyName(order.OrderSellerID); string memo = "好友{0}在【{1}】消费{2:0.00}元,您获奖励{3:0.00}个积分"; SysMemberReward r; Payment p; TryGetMemberReward(order, rUser.Id, out r, out p); if (r == null) r = new SysMemberReward( ); if (p == null) p = new Payment( ); r.OrderCompanyID = order.OrderSellerID; r.OrderID = order.Id; r.OrderMemberID = user.Id; r.OrderSumOk = order.OrderSumOk.Value; r.RewardMemberID = rUser.Id; r.RewardPoint = point; r.RewardDate = order.OrderDate; p.PaymentDate = order.OrderDate; p.PaymentCode = string.Empty; p.PaymentCompanyID = UserBLL.MainCompanyAccount.Id; p.PaymentEmail = string.Empty; p.PaymentMemberID = rUser.Id; p.PaymentMemo = string.Format(memo, CompanyBLL.EnUserPhoe(user.MemberPhoneNumber), companyName, order.OrderSumOk, point); p.PaymentOrderID = order.Id; p.PaymentStatus = 1; p.PaymentSum = point; p.PaymentType = (int)PaymentType.Reward; p.Save( ); r.PaymentID = p.Id; r.ValidateWhenSaving = false; r.Save( ); }
protected bool SaveData() { SysMember rUser = GetRUser(); int pid = rUser != null ? rUser.Id : 0; SysMember user = new SysMember { MemberAddress1 = string.Empty, MemberAddress2 = string.Empty, MemberBalance = 0, MemberBalanceCash = 0, MemberBirthday = null, MemberCompanyID = UserBLL.MainCompanyAccount.Id, MemberCountry = null, MemberDate = DateTime.Now, MemberEmail = null, MemberFinger = null, MemberFullname = null, MemberGrade = 0, MemberMemo = null, MemberPhoneNumber = txtMemberPhone.Text.Trim(), MemberPid = pid, MemberPwd = Utilities.DESEncrypt(txtMemberPwd1.Text.Trim()), MemberRoleId = UserBLL.GetDefaultUseRole((int)SubSystem.Member), MemberSex = null, MemberState = null, MemberStatus = 1, MemberSum = 0, MemberZip = null, LastLoginDate = null, LastLoginSubSys = 0, AdminRoleId = 0, CompanyId = 0, CompanyRoleId = 0, AreaDepth1 = null, AreaDepth2 = null, AreaDepth3 = null, AreaModifyDate = null, MemberCity = Utilities.ToInt(AreaSelector.Selector1.GetSelectedValue(0)), MemberArea = AreaSelector.GetSelectedLocation2(), MemberLocation = AreaSelector.GetSelectedLocation3(), ValidateWhenSaving = false, MemberMsnPhone = txtMemberPhone.Text.Trim() }; user.Save(0); //auto login website SysMember loginUser; UserBLL.UserLogin(user.Id.ToString(), txtMemberPwd1.Text.Trim(), SubSystem.Member, LoginSystem.Web, out loginUser); return true; }
public static bool CheckUserFinger(SysMember user, string strFinger) { return FingerMatch.Match2Fp(user.MemberFinger, strFinger); }
public static bool CancelCompanyItem(SysMember user, SysCompanyItem companyItem, SysMemberItem memberItem, out string message) { message = string.Empty; if (companyItem == null || user == null || memberItem == null) { message = "参数错误!"; goto lbl_end; } if (companyItem.IsCanDel.HasValue && companyItem.IsCanDel.Value != 1) { message = "本单不支持退订"; goto lbl_end; ; } if (memberItem.ItemStatus == (int)MemberCompanyItemStatus.Completed) { message = "此单你已经消费 ,不能再退订"; goto lbl_end; } TransactionScope ts = null; SharedDbConnectionScope ss = null; try { ts = new TransactionScope( ); ss = new SharedDbConnectionScope( ); if (memberItem.PaymentID.HasValue) Payment.Delete(memberItem.PaymentID.Value); SysMemberItem.Delete(memberItem.ItemID); companyItem.ItemClicked = companyItem.ItemClicked.Value - 1; companyItem.Save( ); ts.Complete( ); message = "退订成功"; return true; } catch (Exception ex) { message = ex.Message; Logging.Log("CompanyItemBLL->CancelCompanyItem", ex, true); } finally { ss.Dispose( ); ts.Dispose( ); } lbl_end: return false; }
public static bool CheckUserPwd(SysMember user, string strPwd) { string enPass = Utilities.DESEncrypt(strPwd); return user != null && !string.IsNullOrEmpty(strPwd) && (Utilities.Compare(enPass, user.MemberPwd) || Utilities.Compare(strPwd, user.MemberPwd)); }
public static bool ClickCompanyItem(SysCompany company, SysMember user, DateTime dtDate, SysCompanyItem item, out int memberItemID, out string message) { memberItemID = 0; if (item == null || user == null) { message = "参数错误!"; goto lbl_end; } if (item.ItemClicked >= item.ItemAmount) { message = "已经达到了最大可{ItemType}的数量"; goto lbl_end; } //check ItemLimitOnce if (CheckCompanyItemOnceLimit(company.Id, user.Id)) { message = ItemCheckResult[-3]; goto lbl_end; } decimal userLastOrderSum = UserBLL.GetUserLastMonthOrderSum(user.Id); int result = CompanyItemBLL.ExecuteCheckFunc(user.Id, item.ItemID, userLastOrderSum); if (result < 0) { message = ItemCheckResult.ContainsKey(result) ? ItemCheckResult[result] : "你无权{ItemType}此优惠项目!"; goto lbl_end; } //判断会员积分是否足够 decimal point = DB.Select(SysMember.Columns.MemberBalance).From<SysMember>( ) .Where(SysMember.IdColumn).IsEqualTo(user.Id) .ExecuteScalar<decimal>( ); if (item.ItemPoint.HasValue && point < item.ItemPoint.Value) { message = "您的账户积分余额不足,无法{ItemType}^_^"; goto lbl_end; } SysMemberItem data = new SysMemberItem { CompanyID = item.CompanyID, CompanyItemID = item.ItemID, ItemDate = dtDate, OrderDate = DateTime.Now, MemberID = user.Id, OrderSum = userLastOrderSum, ItemPoint = item.ItemPoint, ItemStatus = (int)MemberCompanyItemStatus.InProgress, SetDate = null, IsCanModifiedDate = true, PaymentID = 0, OrderID = 0 }; TransactionScope ts = new TransactionScope( ); SharedDbConnectionScope ss = new SharedDbConnectionScope( ); try { if (item.ItemPoint.HasValue && item.ItemPoint.Value > 0) { Payment p = new Payment { PaymentCode = string.Empty, PaymentCompanyID = item.CompanyID, PaymentDate = data.OrderDate.Value, PaymentEmail = string.Empty, PaymentMemberID = user.Id, PaymentMemo = string.Format("抢购【{0}】的优惠项目,并使用{1:0.00}个积分消费", company.CompanyName, item.ItemPoint.Value), PaymentOrderID = 0, PaymentStatus = 2, PaymentSum = -item.ItemPoint.Value, PaymentType = (int)PaymentType.CompanyItem }; p.Save( ); data.PaymentID = p.Id; } data.Save( ); item.ItemClicked = Utilities.ToInt(item.ItemClicked) + 1; item.Save( ); OrderBLL.UpdateBalance( ); ts.Complete( ); message = "{ItemType}成功"; memberItemID = data.ItemID; return true; } catch (Exception ex) { message = "{ItemType}失败:" + ex.Message; Logging.Log("CompanyItemBLL->ClickCompanyItem", ex, true); } finally { ss.Dispose( ); ts.Dispose( ); } lbl_end: return false; }
public static SysMember CompanyToMember(SysCompany company) { var query = DB.Select().From<SysMember>() .Where(SysMember.CompanyIdColumn).IsEqualTo(company.Id); SysMember user = query.ExecuteSingle<SysMember>(); if (user != null) { if (user.DirtyColumns.Count > 0) user.MarkClean(); user.MemberPhoneNumber = company.CompanyTel; user.MarkOld(); user.MemberEmail = company.CompanyEmail; user.MemberAddress1 = company.CompanyAddress; user.MemberCity = company.CompanyCity; user.MemberLocation = company.CompanyLocation; user.AreaDepth1 = company.AreaDepth; user.AreaDepth2 = null; user.AreaDepth3 = null; user.AreaModifyDate = null; user.MemberArea = company.CompanyArea; user.MemberStatus = company.CompanyStatus; } else { user = new SysMember(); user.MarkNew(); user.MemberAddress1 = company.CompanyAddress; user.MemberAddress2 = string.Empty; user.MemberBalance = 0; user.MemberBalanceCash = 0; user.MemberBirthday = null; user.MemberCity = company.CompanyCity; user.MemberCompanyID = company.Id; user.MemberCountry = null; user.MemberDate = company.CompanyDate; user.MemberEmail = company.CompanyEmail; user.MemberFinger = null; user.MemberFullname = company.CompanyName; user.MemberGrade = 0; user.MemberMemo = null; user.MemberPhoneNumber = company.CompanyTel; user.MemberPid = 0; user.MemberPwd = company.CompanyPwd; user.MemberRoleId = 0; user.MemberSex = null; user.MemberState = null; user.MemberStatus = company.CompanyStatus; user.MemberSum = 0; user.MemberZip = null; user.LastLoginDate = null; user.LastLoginSubSys = 0; user.AdminRoleId = 0; user.CompanyId = company.Id; user.MemberLocation = company.CompanyLocation; user.AreaDepth1 = company.AreaDepth; user.AreaDepth2 = null; user.AreaDepth3 = null; user.AreaModifyDate = null; user.MemberArea = company.CompanyArea; user.CompanyRoleId = UserBLL.GetDefaultUseRole((int)SubSystem.Company); } return user; }
private static bool SaveOrder(SysCompany company, SysMemberItem mItem, SysCompanyItem cItem, SysMember user, out string message) { message = string.Empty; //Order order = new Order //{ // OrderCode = OrderBLL.GetOrderCode(company), // OrderCard = string.Empty, // OrderDate = DateTime.Now, // OrderDateDeliver = DateTime.Now, // OrderDateUpload = DateTime.Now, // OrderMemberID = user.Id, // OrderMemo = string.Empty, // OrderProduct = "优惠消费", // OrderQty = 0, // OrderRateSale = 0, // OrderRate = 0, // OrderPoint = 0, // OrderSellerID = company.Id, // OrderStatus = 1, // OrderSum = cItem.ItemSum, // OrderSumOk = cItem.ItemSum, // OrderPay = 0, // OrderPayCash = 0, // OrderPayPoint = mItem.ItemPoint, // OrderType = (int)OrderType.CompanyItem //}; TransactionScope ts = new TransactionScope( ); SharedDbConnectionScope ss = new SharedDbConnectionScope( ); try { //order.Save( ); //if (mItem.ItemPoint.HasValue && mItem.ItemPoint.Value > 0) //{ // new Payment // { // PaymentCode = order.OrderCode, // PaymentCompanyID = company.Id, // PaymentDate = order.OrderDate, // PaymentEmail = string.Empty, // PaymentMemberID = user.Id, // PaymentMemo = string.Format("{0}抢购{1}的优惠项目,并且使用{2}个积分抵扣", user.MemberPhoneNumber, company.CompanyName, -mItem.ItemPoint.Value), // PaymentOrderID = order.Id, // PaymentStatus = 1, // PaymentSum = -mItem.ItemPoint.Value, // PaymentType = (int)PaymentType.CompanyItem // }.Save( ); //} //如果是联盟商家则更新积分状态 CompanyType companyType = Formatter.ToEnum<CompanyType>(company.CompanyType); Payment p = Payment.FetchByID(mItem.PaymentID.Value); if (p != null) { p.PaymentStatus = 1; p.Save( ); } mItem.ItemStatus = (int)MemberCompanyItemStatus.Completed; mItem.SetDate = DateTime.Now; mItem.Save( ); cItem.ItemUsed = Utilities.ToInt(cItem.ItemUsed) + 1; cItem.Save( ); OrderBLL.UpdateBalance( ); ts.Complete( ); message = string.Format("结算成功,{0}使用{1}个积分购得{2}", user.MemberFullname, mItem.ItemPoint, cItem.ItemTitle); return true; } catch (Exception ex) { message = ex.Message; return false; } finally { ss.Dispose( ); ts.Dispose( ); } }
public static void DeleteUser(SysMember user) { if (user == null) return; }
void SaveMemberCash(DataRow row, SysMember user) { decimal dBalanceCash = row.Table.Columns.Contains(ColumnMap[SysMember.MemberBalanceCashColumn]) ? Utilities.ToDecimal(row[ColumnMap[SysMember.MemberBalanceCashColumn]]) : 0M, dBalancePoint = row.Table.Columns.Contains(ColumnMap[SysMember.MemberBalanceColumn]) ? Utilities.ToInt(row[ColumnMap[SysMember.MemberBalanceColumn]]) : 0M, dMemberRate = (row.Table.Columns.Contains(ColumnMap[SysMemberCash.CashRateColumn]) ? Utilities.ToDecimal(row[ColumnMap[SysMemberCash.CashRateColumn]]) : 0M) / 100M; decimal dCashRateSale = 0M; if (row.Table.Columns.Contains(ColumnMap[SysMemberCash.CashRateSaleColumn])) dCashRateSale = Utilities.ToDecimal(row[ColumnMap[SysMemberCash.CashRateSaleColumn]]) / 100M; if (dBalanceCash > 0) { SysMemberCash cash = new SysMemberCash { CashCompanyID = CurrentUser.CompanyId, CashMemberID = user.Id, CashDate = DateTime.Now, CashMemo = GetMemberGrade(Utilities.ToString(row[ColumnMap[SysCompanyMemberGrade.GradeNameColumn]])).ToString( ), CashOrderID = -1, CashSum = dBalanceCash, CashRate = dMemberRate, CashPoint = 0, CashRateSale = dCashRateSale }; cash.Save( ); new PaymentCash { PaymentCashCode = string.Empty, PaymentCashCompanyID = CurrentUser.CompanyId, PaymentCashMemberID = user.Id, PaymentCashDate = DateTime.Now, PaymentMemo = string.Format("在【{0}】已经成功导入{1:0.00}元储值", AppContext.Context.Company.CompanyName, dBalanceCash.ToString("###0.00")), PaymentOrderID = cash.CashID, PaymentStatus = 1, PaymentCashSum = dBalanceCash, PaymentType = (int)PaymentCashType.Import }.Save( ); } if (dBalancePoint > 0) { new Payment { PaymentCode = string.Empty, PaymentCompanyID = CurrentUser.CompanyId, PaymentMemberID = user.Id, PaymentDate = DateTime.Now, PaymentMemo = string.Format("在【{0}】已经成功导入{1:0.00}个积分", AppContext.Context.Company.CompanyName, dBalancePoint.ToString("###0.00")), PaymentOrderID = 0, PaymentStatus = 1, PaymentSum = dBalancePoint, PaymentType = (int)PaymentType.Import, PaymentEmail = string.Empty }.Save( ); } }
//public static string MemberCash_info(decimal cashSum) //{ // //宋江 本店会员,有0元储值,4.40个积分 // //const string MEMBERCASH_INFO_2 = "<b>{0}</b> 是{1},{3}元储值可以消费,有{2}个积分,但无法在本店充值。"; // const string MEMBERCASH_INFO_1 = "<b>{0}</b> {1},有{3}元储值,{2}个积分"; // //if (AppContextBase.Context.Company.CompanyType == 4 && cashSum > 0) // // return MEMBERCASH_INFO_2; // //else // return MEMBERCASH_INFO_1; //} public static bool GetMemberForCash(SysMember user, out string message) { return GetMemberForOrder(user, out message); //message = string.Empty; //if (user == null) //{ // message = "用户账号不存在!"; // return false; //} //if (user.CompanyId > 0) //{ // message = "此账号属于商家账号,不允许充值!"; // return false; //} //CompanyType cmpType = Formatter.ToEnum<CompanyType>(AppContextBase.Context.Company.CompanyType); //if (cmpType != CompanyType.UnionCompany) //{ // message = "您暂无权限使用该功能"; // return false; //} ////合作方式为积分合作,无法使用储值功能 ////if (AppContextBase.Context.Company.CompanyFlag == 1) ////{ //// message = "与乐多分的合作方式为积分合作,无法使用储值功能"; //// return false; ////} //var query = DB.Select("sum(CashSum)").From<SysMemberCash>( ) // .Where(SysMemberCash.CashMemberIDColumn).IsEqualTo(user.Id) // .And(SysMemberCash.CashCompanyIDColumn).IsEqualTo(AppContextBase.Context.Company.Id); //decimal dCashSum = query.ExecuteScalar<decimal>( ); //message = string.Format(MemberCash_info(dCashSum), user.MemberFullname, // UserGradeInfo(user), // user.MemberBalance, dCashSum); //user.MemberBalanceCash = dCashSum; //return true; }
SysMember SaveMemberData(DataRow row) { string phoneNum = Utilities.ToString(row[ORIG_PHONENUMBER]); SysMember user = UserBLL.GetUserByPhoneNum(phoneNum); if (user == null) { user = new SysMember( ); user.MarkNew( ); foreach (TableSchema.TableColumn col in SysMember.Schema.Columns) { if (col.IsReadOnly || col.AutoIncrement || col.IsReservedColumn) continue; if (col == SysMember.MemberCompanyIDColumn) user.SetColumnValue(col.ColumnName, CurrentUser.CompanyId); else if (col == SysMember.MemberPhoneNumberColumn) user.SetColumnValue(col.ColumnName, phoneNum); else if (col == SysMember.MemberDateColumn) user.SetColumnValue(col.ColumnName, DateTime.Now); else if (col == SysMember.MemberGradeColumn) user.SetColumnValue(col.ColumnName, GetMemberGrade(Utilities.ToString(row[ColumnMap[SysCompanyMemberGrade.GradeNameColumn]]))); else if (col == SysMember.MemberRoleIdColumn) user.SetColumnValue(col.ColumnName, UserBLL.GetDefaultUseRole((int)SubSystem.Member)); else if (col == SysMember.MemberSexColumn) user.SetColumnValue(col.ColumnName, GetMemberSex(Utilities.ToString(row[ColumnMap[col]]))); else if (ColumnMap.ContainsKey(col)) user.SetColumnValue(col.ColumnName, row[ColumnMap[col]]); else if (col == SysMember.AdminRoleIdColumn) user.AdminRoleId = 0; else if (col == SysMember.CompanyIdColumn) user.CompanyId = 0; else if (col == SysMember.CompanyRoleIdColumn) user.CompanyRoleId = 0; else if (col == SysMember.MemberStatusColumn) user.MemberStatus = 1; else if (col == SysMember.MemberCityColumn) user.MemberCity = AppContext.Context.Company.CompanyCity; else if (col == SysMember.MemberAreaColumn) user.MemberArea = AppContext.Context.Company.CompanyArea; else if (col == SysMember.MemberLocationColumn) user.MemberLocation = AppContext.Context.Company.CompanyLocation; else if (col == SysMember.AreaDepth1Column) user.AreaDepth1 = AppContext.Context.Company.AreaDepth; else if (col == SysMember.AreaDepth2Column) user.AreaDepth2 = null; else if (col == SysMember.AreaDepth3Column) user.AreaDepth3 = null; else if (col == SysMember.AreaModifyDateColumn) user.AreaModifyDate = null; else if (col == SysMember.MemberMsnPhoneColumn) user.MemberMsnPhone = user.MemberPhoneNumber; else user.SetColumnValue(col.ColumnName, col.DefaultValue); } user.Save( ); } else { user.MarkOld( ); } return user; }
public static bool GetMemberForOrder(SysMember user, out string message) { message = string.Empty; if (user == null) { message = "用户账号不存在!"; return false; } if (user.CompanyId > 0) { message = "此账号属于商家账号,不允许结算和储值!"; return false; } if (AppContextBase.Context.CompanyType.Value != CompanyType.UnionCompany && AppContextBase.Context.CompanyType.Value != CompanyType.SpecialCompany) { message = "您暂无权限使用该功能"; return false; } user.MemberBalanceCash = GetUserBalanceCash(user.Id, AppContextBase.Context.Company.Id); string result = GradeBLL.GetUserCurrentGrade(AppContextBase.Context.Company.Id, user.Id); if (string.IsNullOrEmpty(result) || result == "0") { result = string.Format("属性:{0} 级别:普通会员", (user.MemberCompanyID == AppContextBase.Context.Company.Id) ? "本店会员" : "外来会员"); } else result = string.Format("属性:本店会员 级别:{0}", result); message = result; return true; }
private bool ValidateFieldData( ) { decimal _dRate = Utilities.ToDecimal(rblCompanyRate.UniqueID); int index = Rates.IndexOf(_dRate); if (index >= 0) rblCompanyRate.SelectedIndex = index; txtOrderSumOk.Text = BasePage.Params[txtOrderSumOk.UniqueID]; if (string.IsNullOrEmpty(hdnMemberPhone.Value)) { lblMemberInfo.InnerHtml = "会员账号不能为空!"; return false; } user = UserBLL.GetUserByPhoneNum(hdnMemberPhone.Value); if (user == null) { lblMemberInfo.InnerHtml = "你输入的会员账号不存在! "; txtMemberPhone.Focus( ); return false; } if (user.CompanyId > 0) { lblMemberInfo.InnerHtml = "你不能用此账号进行消费,此账号属于商家账号!"; return false; } if (payment != "1") { if (string.IsNullOrEmpty(txtMemberPwd.Text)) { lblMemberPwdInfo.InnerText = "会员密码不能为空!"; txtMemberPwd.Focus( ); return false; } if (!UserBLL.CheckUserPwd(user, txtMemberPwd.Text.Trim( )) && !UserBLL.CheckUserFinger(user, txtMemberPwd.Text.Trim( ))) { lblMemberPwdInfo.InnerHtml = "会员密码或指纹不正确!"; txtMemberPwd.Focus( ); return false; } } if (string.IsNullOrEmpty(txtOrderSum.Text)) { lblOrderSumInfo.InnerHtml = "会员消费金额不能为空!"; return false; } if (!decimal.TryParse(txtOrderSum.Text, out dOrderSum) || dOrderSum <= 0) { lblOrderSumInfo.InnerHtml = "会员消费金额不正确,不能小于或等于0"; return false; } //if (string.IsNullOrEmpty(txtOrderSumOk.Text)) //{ // lblOrderSumOkInfo.InnerHtml = "会员实际消费金额不能为空!"; // return false; //} //if (!decimal.TryParse(txtOrderSumOk.Text, out dOrderSumOk) || dOrderSumOk < 0) //{ // lblOrderSumOkInfo.InnerHtml = "会员实际消费金额不正确,不能小于零!"; // return false; //} if (string.IsNullOrEmpty(txtMemberRateSale.Text)) txtMemberRateSale.Text = "0"; decimal.TryParse(txtMemberRateSale.Text, out dRateSale); if (dRateSale < 0 || dRateSale >= 100) { lblMemberRateSale.InnerHtml = "消费折扣输入不正确,请输入1-99之间的数!"; return false; } string sCompanyRate = BasePage.Params[rblCompanyRate.UniqueID]; string sCompanyRates = "," + CurContext.Company.CompanyRate; if (!string.IsNullOrEmpty(sCompanyRate) && !string.IsNullOrEmpty(sCompanyRates)) { if (!decimal.TryParse(sCompanyRate, out dCompanyRate) || !(sCompanyRates.Contains(sCompanyRate + ",") || sCompanyRates.Contains("," + sCompanyRate)) || dCompanyRate < 0) { if (dCompanyRate != _dRate) { lblCompanyRateInfo.InnerHtml = "你输入的积分比例不正确!"; return false; } } } dPayPoint = Formatter.Low(this.hdnMemberBalance.Value); dPayCash = Formatter.Low(this.hdnMemberBalanceCash.Value); dOrderSumOk = dRateSale > 0 && dRateSale < 100 ? Formatter.CalcSumOk(dOrderSum * dRateSale / 100M) : dOrderSum; txtOrderSumOk.Text = dOrderSumOk.ToString("#####0.##"); return true; }
public static SysMember GetOrNewMemberByPhoneNumber(string phoneNumber, SysCompany company, out bool isNew) { SysMember user = GetUserByPhoneNum(phoneNumber); isNew = user == null; if (isNew) { user = new SysMember() { MemberPhoneNumber = phoneNumber, MemberPwd = phoneNumber.Substring(phoneNumber.Length - 6, 6), MemberAddress1 = null, MemberAddress2 = null, MemberBalance = 0, MemberBalanceCash = 0, MemberBirthday = null, MemberCity = 0, MemberCompanyID = MainAccount.CompanyId, MemberCountry = "中国", MemberDate = DateTime.Now, MemberEmail = null, MemberFinger = null, MemberFullname = null, MemberGrade = 0, AreaDepth1 = null, MemberArea = company.CompanyArea, MemberLocation = company.CompanyLocation, MemberMemo = null, MemberPid = -1, MemberRoleId = 2, AdminRoleId = 0, CompanyId = 0, CompanyRoleId = 0, MemberSex = null, MemberState = null, MemberStatus = 1, MemberSum = 0, MemberZip = null, AreaDepth2 = null, AreaDepth3 = null, AreaModifyDate = null, LastLoginDate = null, LastLoginSubSys = 0, }; user.Save(); } else if (!Utilities.Compare(user.MemberMsnPhone, phoneNumber)) { user.MemberMsnPhone = phoneNumber; user.Save(); } return user; }