/// <summary> /// 激活会员(外用) /// </summary> /// <param name="memberid"></param> /// <param name="phone"></param> /// <param name="activecode"></param> /// <returns></returns> public string ActiveMember(int memberid, string phone, string activecode, bool isauto, int souceid = 0) { string result = "0"; if (isauto) { activecode = ActiveCodeDAL.GetRedamActiveCode(1); } MemberInfoModel member = null; if (memberid != 0) { member = MemberInfoDAL.GetNotActiveMember(memberid); } if (!string.IsNullOrWhiteSpace(phone)) { member = MemberInfoDAL.GetMember(phone); } if (member == null) { result = "0无此会员"; return(result); } if (member.MStatus != 1) { result = "0会员状态不正确"; return(result); } ActiveCodeModel activecodemodel = ActiveCodeDAL.GetActiveCodeExtendModel(activecode); if (activecodemodel == null) { result = @"0无此激活码"; return(result); } if (activecodemodel.AType == 2) { result = @"0激活码类型选择不正确"; return(result); } if (activecodemodel.AStatus == 10) { result = @"0激活码已经使用"; return(result); } if (activecodemodel.AMStatus == 3) { result = @"0激活码已经过期"; return(result); } using (TransactionScope scope = new TransactionScope()) { //更改会员的状态 int rowcount = MemberInfoDAL.UpdateStatus(member.ID, 2); if (rowcount < 1) { result = "0更新会员状态失败"; return(result); } //更改激活码的状态 rowcount = ActiveCodeDAL.UpdateStatus(activecodemodel.ID, 10); if (rowcount < 1) { result = "0更新激活码状态失败"; return(result); } if (activecodemodel.MID > 0) { //更改会员机会码的使用状态 if (souceid > 0) { rowcount = ActiveCodeDAL.UpdateMemberActiveCodeToUse(souceid, member.MobileNum, activecodemodel.ActivationCode); if (rowcount < 1) { result = "0更新会员激活码表状态失败"; return(result); } } else { rowcount = ActiveCodeDAL.UpdateMemberActiveStatus(activecodemodel.MID, 2); if (rowcount < 1) { result = "0更新会员激活码表状态失败"; return(result); } } //插入使用日志 ActiveCodeLogModel logmodel = new ActiveCodeLogModel(); logmodel.ActiveCode = activecodemodel.ActivationCode; logmodel.Addtime = DateTime.Now; logmodel.AID = activecodemodel.ID; logmodel.MemberID = activecodemodel.MemberID; logmodel.MemberName = activecodemodel.MemberName; logmodel.MemberPhone = activecodemodel.MemberPhone; logmodel.Remark = "为会员:" + member.MobileNum + " 激活"; rowcount = OperateLogDAL.AddActiveCodeLog(logmodel); if (rowcount < 1) { result = "0写入日志失败"; return(result); } } scope.Complete(); result = "1"; } return(result); }
/// <summary> /// 添加一条提供帮助单据 /// </summary> public string AddHelpeOrder(HelpeOrderModel model) { string result = "0"; string minhelpamont = SystemConfigs.GetminHelpAmont(); //得到最小的提供帮助限制 string maxhelpamont = SystemConfigs.GetmaxHelpAmont(); //得到最大的提供帮助限制 string interest = SysAdminConfigDAL.GetConfigsByID(5); //得到排单后的利率 string inteistlist = SysAdminConfigDAL.GetConfigsByID(11); //得到领导奖利率 decimal reinteist = SysAdminConfigDAL.GetConfigsByID(16).ParseToDecimal(10); //得到首次推荐的利率 decimal maxcount = SysAdminConfigDAL.GetConfigsByID(17).ParseToInt(1); //得到每日最大排单数 MemberExtendInfoModel meinfo = MemberExtendInfoDAL.GetMemberExtendInfo(model.MemberID); int helpcount = HelpeOrderDAL.GetTodayHelpCount(model.MemberID); if (model.Amount < minhelpamont.ParseToDecimal(0)) { return("0超出了平台规定的最小规定值"); } if (model.Amount > maxhelpamont.ParseToDecimal(0)) { return("0超出了平台规定的最大规定值"); } if (helpcount >= maxcount) { return("0今天已经提供过帮助"); } bool isfirst = false;//默认不是第一次 if (meinfo == null) { isfirst = true; } else { isfirst = meinfo.MemberHelpCount == 0; } if (string.IsNullOrWhiteSpace(model.ActiveCode)) { return("0没有填写排单币"); } ActiveCodeModel activemodel = ActiveCodeDAL.GetActiveCodeExtendModel(model.ActiveCode); if (activemodel == null)//没有该激活码信息为失败 { return("0排单币无效"); } if (activemodel.AStatus == 10)//改激活码已使用为失败 { return("0排单币已经被使用"); } if (model.Amount % 100 > 0) { return("0提供金额应为100的整数倍"); } ReMemberRelationModel remember = ReMemberRelationDAL.GetReMemberRelation(model.MemberID); using (TransactionScope scope = new TransactionScope()) { //更改激活码的使用状态 int rowcount = ActiveCodeDAL.UpdateStatus(activemodel.ID, 10); if (rowcount < 1) { return("0操作失败"); } rowcount = ActiveCodeDAL.UpdateMemberActiveToUse(model.MemberID, model.OrderCode, model.ActiveCode); if (rowcount < 1) { return("0操作失败"); } //插入激活码的使用日志 ActiveCodeLogModel aclogmodel = new ActiveCodeLogModel(); aclogmodel.ActiveCode = model.ActiveCode; aclogmodel.AID = model.ActiveCodeID; aclogmodel.MemberID = model.MemberID; aclogmodel.MemberName = model.MemberName; aclogmodel.MemberPhone = model.MemberPhone; aclogmodel.Remark = "会员:" + model.MemberName + " 使用排单币:" + model.ActiveCode + " 进行排单"; rowcount = OperateLogDAL.AddActiveCodeLog(aclogmodel); if (rowcount < 1) { return("0操作失败"); } //更改会员的资金信息和利率 decimal dinterest = 1; if (!string.IsNullOrWhiteSpace(interest)) { if (!decimal.TryParse(interest, out dinterest)) { return("0操作失败"); } } //rowcount = MemberCapitalDetailDAL.UpdateMemberStaticCapital(model.MemberID, model.Amount, dinterest,model.MemberName,model.MemberPhone); rowcount = MemberCapitalDetailDAL.UpdateMemberStaticFreezeMoneyAndinster(model.MemberID, model.Amount, dinterest, model.MemberName, model.MemberPhone); if (rowcount < 1) { return("0操作失败"); } //插入表记录 model.IsFristOrder = isfirst ? 1 : 0; int orderid = dal.AddHelpeOrder(model); if (orderid < 1) { return("0操作失败"); } //更新会员的统计信息 rowcount = MemberExtendInfoDAL.Update(model.MemberID, model.Amount); if (rowcount < 1) { return("0操作失败"); } //插入会员的资金变动纪录 AmountChangeLogModel logmodel = new AmountChangeLogModel(); logmodel.MemberID = model.MemberID; logmodel.MemberName = model.MemberName; logmodel.MemberPhone = model.MemberPhone; logmodel.OrderCode = model.OrderCode; logmodel.OrderID = orderid; logmodel.ProduceMoney = model.Amount; logmodel.Remark = "会员:" + model.MemberPhone + " 申请提供帮助 " + model.Amount.ToString() + "元"; logmodel.Type = 1; rowcount = OperateLogDAL.AddAmountChangeLog(logmodel); if (rowcount < 1) { return("0操作失败"); } //为推荐人添加领导奖 rowcount = MemberCapitalDetailDAL.PaymentLeaderPrize(model.MemberID, model.Amount, inteistlist, model.OrderCode, orderid); if (rowcount < 1) { return("0操作失败"); } //若此会员第一次排单,则给推荐人奖励 if (isfirst) { rowcount = MemberCapitalDetailDAL.UpdateMemberDynamicFreezeMoney(remember.MemberID, (model.Amount * reinteist / 100), remember.MemberTruthName, remember.MemberPhone); if (rowcount < 1) { return("0操作失败"); } LeaderAmountModel leadermodel = new LeaderAmountModel();//插入领导奖记录 leadermodel.OrderID = orderid; leadermodel.OrderCode = model.OrderCode; leadermodel.MemberPhone = remember.MemberPhone; leadermodel.MemberName = remember.MemberTruthName; leadermodel.MemberID = remember.MemberID; leadermodel.LType = 1; leadermodel.Amount = (model.Amount * reinteist / 100); rowcount = MemberCapitalDetailDAL.AddLeaderAmount(leadermodel); if (rowcount < 1) { return("0操作失败"); } AmountChangeLogModel logmodel1 = new AmountChangeLogModel(); logmodel1.MemberID = remember.MemberID; logmodel1.MemberName = remember.MemberTruthName; logmodel1.MemberPhone = remember.MemberPhone; logmodel1.OrderCode = model.OrderCode; logmodel1.OrderID = orderid; logmodel1.ProduceMoney = (model.Amount * reinteist / 100); logmodel1.Remark = "会员:" + remember.MemberPhone + " 得到来自 " + model.MemberPhone + "的首单推荐奖(已冻结)" + (model.Amount * reinteist / 100).ToString() + "元"; logmodel1.Type = 3; rowcount = OperateLogDAL.AddAmountChangeLog(logmodel1); if (rowcount < 1) { return("0操作失败"); } } try { UserBehaviorLogModel log = new UserBehaviorLogModel(); log.AOrderCode = ""; log.BehaviorSource = 1; log.BehaviorType = 2; log.HOrderCode = model.OrderCode; log.MemberID = model.MemberID; log.MemberName = model.MemberName; log.MemberPhone = model.MemberPhone; log.ProcAmount = model.Amount; log.Remark = "会员:" + model.MemberPhone + "提供帮助单号为:" + model.OrderCode; rowcount = UserBehaviorLogDAL.AddUserBehaviorLog(log); } catch { } scope.Complete(); result = "1"; } return(result); }