示例#1
0
        /// <summary>
        /// 得到会员的扩展信息
        /// </summary>
        /// <param name="MemberID"></param>
        /// <returns></returns>
        public static MemberExtendInfoModel GetMemberExtendInfo(int MemberID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select *  ");
            strSql.Append("  from MemberExtendInfo ");
            strSql.Append(" where MemberID=@MemberID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@MemberID", SqlDbType.Int)
            };
            parameters[0].Value = MemberID;
            MemberExtendInfoModel model = new MemberExtendInfoModel();
            DataSet ds = helper.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["MemberID"].ToString() != "")
                {
                    model.MemberID = int.Parse(ds.Tables[0].Rows[0]["MemberID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["LastHelperTime"].ToString() != "")
                {
                    model.LastHelperTime = ds.Tables[0].Rows[0]["LastHelperTime"].ToString().ParseToDateTime(DateTime.Now);
                }
                if (ds.Tables[0].Rows[0]["MemberHelpCount"].ToString() != "")
                {
                    model.MemberHelpCount = ds.Tables[0].Rows[0]["MemberHelpCount"].ToString().ParseToInt(0);
                }
                if (ds.Tables[0].Rows[0]["LastHelpMoney"].ToString() != "")
                {
                    model.LastHelpMoney = decimal.Parse(ds.Tables[0].Rows[0]["LastHelpMoney"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
示例#2
0
        /// <summary>
        /// 添加会员初始化信息
        /// </summary>
        /// <param name="model"></param>
        public static int AddModelExtendinfo(MemberExtendInfoModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into MemberExtendInfo(");
            strSql.Append("MemberID,LastHelperTime,MemberHelpCount,LastHelpMoney");
            strSql.Append(") values (");
            strSql.Append("@MemberID,@LastHelperTime,@MemberHelpCount,@LastHelpMoney");
            strSql.Append(") ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@MemberID",        SqlDbType.Int),
                new SqlParameter("@LastHelperTime",  SqlDbType.DateTime),
                new SqlParameter("@MemberHelpCount", SqlDbType.Int),
                new SqlParameter("@LastHelpMoney",   SqlDbType.Decimal)
            };
            parameters[0].Value = model.MemberID;
            parameters[1].Value = model.LastHelperTime;
            parameters[2].Value = model.MemberHelpCount;
            parameters[3].Value = model.LastHelpMoney;
            return(helper.ExecuteSql(strSql.ToString(), parameters));
        }
示例#3
0
        /// <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);
        }
示例#4
0
        /// <summary>
        ///注册会员(已追加注册返还金额功能)
        /// </summary>
        public string AddMemberInfo(MemberInfoModel model)
        {
            string result = "1";
            string value  = SysAdminConfigDAL.GetConfigsByID(4);//得到注册返还金额

            #region 验证用户真实姓名 和手机
            int rows = MemberInfoDAL.GetMemberCountInfoByName(model.TruethName.Trim());
            if (rows > 2)
            {
                return("0用户姓名重复");
            }
            rows = MemberInfoDAL.GetMemberCountInfoByMobile(model.MobileNum.Trim());
            if (rows > 0)
            {
                return("0手机号已被注册");
            }
            //rows = MemberInfoDAL.GetMemberCountInfoByAlipayNum(model.AliPayNum.Trim());
            //if (rows > 0)
            //{
            //    return "0支付宝ID已被注册";
            //}
            rows = MemberInfoDAL.GetMemberCountInfoByAliPayName(model.AliPayName.Trim());
            if (rows > 0)
            {
                return("0支付宝账户已被注册");
            }
            #endregion
            using (TransactionScope scope = new TransactionScope())
            {
                int memberid = dal.AddMemberInfo(model);
                if (memberid < 1)
                {
                    return("0注册失败");
                }
                decimal amont = 0;
                if (!string.IsNullOrWhiteSpace(value))
                {
                    if (!decimal.TryParse(value, out amont))
                    {
                        return("0注册失败");
                    }
                    int row = MemberCapitalDetailDAL.UpdateMemberStaticFreezeMoney(memberid, amont, model.TruethName, model.MobileNum);
                    if (row < 1)
                    {
                        return("0注册失败");
                    }
                }
                //返还激活码金额
                AmountChangeLogModel logmodel = new AmountChangeLogModel();
                logmodel.MemberID     = memberid;
                logmodel.MemberName   = model.TruethName;
                logmodel.MemberPhone  = model.MobileNum;
                logmodel.ProduceMoney = amont;
                logmodel.Remark       = "会员注册激活码" + amont.ToString() + "元";
                logmodel.Type         = 5;
                int rowcount = OperateLogDAL.AddAmountChangeLog(logmodel);
                if (rowcount < 1)
                {
                    return("0注册失败");
                }
                if (model.MemberPhone != model.MobileNum)
                {
                    //插入推荐人信息表
                    MemberInfoModel soucemember = MemberInfoDAL.GetMember(model.MemberPhone);
                    if (soucemember.MStatus == 3)
                    {
                        return("0推荐人账户被冻结");
                    }
                    ReMemberRelationModel remodel = new ReMemberRelationModel();
                    remodel.MemberID         = soucemember.ID;
                    remodel.MemberTruthName  = soucemember.TruethName;
                    remodel.MemberPhone      = soucemember.MobileNum;
                    remodel.RecommMID        = memberid;
                    remodel.RecommMPhone     = model.MobileNum;
                    remodel.RecommMTruthName = model.TruethName;
                    rowcount = ReMemberRelationDAL.AddReMemberRelation(remodel);
                    if (rowcount < 1)
                    {
                        return("0注册失败");
                    }
                }
                //初始化会员扩展信息表
                MemberExtendInfoModel extendinfo = new MemberExtendInfoModel();
                extendinfo.MemberID        = memberid;
                extendinfo.MemberHelpCount = 0;
                extendinfo.LastHelpMoney   = 0;
                extendinfo.LastHelperTime  = DateTime.Now.AddYears(-1);
                rowcount = MemberExtendInfoDAL.AddModelExtendinfo(extendinfo);
                if (rowcount < 1)
                {
                    return("0注册失败");
                }
                scope.Complete();
                result = "1";
            }
            return(result);
        }
示例#5
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public string AddAcceptHelpOrder(AcceptHelpOrderModel model)
        {
            string result = "0";
            MemberCapitalDetailModel moneydetail = MemberCapitalDetailDAL.GetMemberStaticCapital(model.MemberID);
            int rows = AcceptHelpOrderDAL.GetNotFinishOrderByMember(model.MemberID);

            if (rows > 0)
            {
                return("0还有未完成的接受帮助单据");
            }
            string maxacceptamont = SystemConfigs.GetmaxAcceptAmont(); //得到最大的接受帮助限制
            string minacceptamont = SystemConfigs.GetminAcceptAmont(); //得到最小的接受帮助限制

            if (model.Amount > maxacceptamont.ParseToDecimal(0))
            {
                return("0超出了平台规定的最大接受值");
            }
            if (model.Amount < minacceptamont.ParseToDecimal(0))
            {
                return("0超出了平台规定的最小接受值");
            }
            int daynum = SysAdminConfigBLL.GetConfigValue(24).ParseToInt(15);
            MemberExtendInfoModel extentmember = MemberExtendInfoDAL.GetMemberExtendInfo(model.MemberID);

            if (DateTime.Now < extentmember.LastHelperTime.AddDays(daynum))
            {
                return("0会员提供帮助单据仍处于冻结期");
            }
            using (TransactionScope scope = new TransactionScope())
            {
                //插入表
                int orderid = dal.AddAcceptHelpOrder(model);
                if (orderid < 1)
                {
                    return("0操作失败");
                }
                //扣减会员的相应金额记录
                int rowcount = 0;
                if (model.SourceType == 1)
                {
                    if (moneydetail.StaticCapital < model.Amount)
                    {
                        return("0操作失败");
                    }
                    rowcount = MemberCapitalDetailDAL.DeductionMemberStaticCapital(model.MemberID, 0 - model.Amount, 0);
                    //清空会员的利率(不判断结果,不排除没有这样单据的可能,因为存在特殊账户)
                    int rowcounts = HelpeOrderDAL.UpdateCurrentInterestToClear(model.MemberID);
                }
                else
                {
                    if (moneydetail.DynamicFunds < model.Amount)
                    {
                        return("0操作失败");
                    }
                    rowcount = MemberCapitalDetailDAL.DeductionMemberDynamicFunds(model.MemberID, 0 - model.Amount, 0);
                }
                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 = 0 - model.Amount;
                logmodel.Remark       = "会员:" + model.MemberPhone + " 申请接受帮助 " + model.Amount.ToString() + "元";
                logmodel.Type         = 1;
                rowcount = OperateLogDAL.AddAmountChangeLog(logmodel);
                if (rowcount < 1)
                {
                    return("0操作失败");
                }
                try
                {
                    UserBehaviorLogModel log = new UserBehaviorLogModel();
                    log.AOrderCode     = model.OrderCode;
                    log.BehaviorSource = 1;
                    log.BehaviorType   = 3;
                    log.HOrderCode     = "";
                    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);
        }