示例#1
0
        /// <summary>
        /// 创建推广佣金单
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public string CreateBill(BillApiModel model)
        {
            if (model == null)
            {
                return("");
            }
            LoanMarketGroup      fromGroup  = userGroup.GetUserGroup(Convert.ToInt32(model.FromUserNo));
            LoanMarketGroup      toGroup    = userGroup.GetUserGroup(Convert.ToInt32(model.ToUserNo));
            LoanMarketSpreadBill spreadBill = new LoanMarketSpreadBill()
            {
                No                = model.FromUserNo + "|" + model.ToUserNo + "|" + model.BillType.ToString() + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff"),
                BillType          = model.BillType,
                Amount            = model.Amount,
                Id                = GuidTool.GenerateKey(),
                FromUserNo        = model.FromUserNo,
                FromUserGroupNo   = fromGroup.No.ToString(),
                FromUserGroupName = fromGroup.Name,
                ToUserNo          = model.ToUserNo,
                ToUserGroupNo     = toGroup == null ? "0" : toGroup.No.ToString(),
                ToUserGroupName   = toGroup == null ? "非会员,无用户组" : toGroup.Name,
                CreateTime        = DateTime.Now,
                UpateTime         = DateTime.Now
            };
            string res = bill.CreateBill(spreadBill);

            //增加用户推广佣金
            if (user.UpdateUserWithdrawAmount(Convert.ToInt32(model.FromUserNo), model.Amount) > 0)
            {
                return(res);
            }
            else
            {
                return(string.Empty);
            }
        }
示例#2
0
        /// <summary>
        /// 创建评论
        /// </summary>
        /// <param name="commentListApiModel"></param>
        public void CreateComment(CommentParamModel commentParamModel)
        {
            LoanMarketComment loanMarketComment = new LoanMarketComment()
            {
                CommentUserNo = commentParamModel.CommentUserNo,
                ContentBody   = commentParamModel.ContentBody,
                CreateTime    = DateTime.Now,
                ForumNo       = commentParamModel.ForumNo,
                Id            = GuidTool.GenerateKey(),
                No            = comment.FindComment() == null ? 1 : comment.FindComment().Count + 1
            };

            comment.CreateComment(loanMarketComment);
        }
        /// <summary>
        /// 新增或者修改提现密码
        /// </summary>
        /// <param name="userNo"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public int Save(int userNo, string password)
        {
            LoanMarketUserWithdraw withdraw = db.LoanMarketUserWithdraw.Where(a => a.UserNo == userNo).FirstOrDefault();

            if (withdraw != null && withdraw.UserNo > 0)
            {
                withdraw.WithdrawPassword = password;
                return(db.SaveChanges());
            }
            else
            {
                withdraw                  = new LoanMarketUserWithdraw();
                withdraw.Id               = GuidTool.GenerateKey();
                withdraw.UserNo           = userNo;
                withdraw.WithdrawPassword = password;
                db.LoanMarketUserWithdraw.Add(withdraw);
                return(db.SaveChanges());
            }
        }
示例#4
0
        /// <summary>
        /// 创建推广的用户
        /// </summary>
        /// <param name="userParamModel"></param>
        /// <returns></returns>
        public int CreateSpreadUser(RegisterParamModel userParamModel)
        {
            //判断手机号是否已经存在
            if (user.GetUser(userParamModel.Mobile) != null)
            {
                return(-1);
            }
            LoanMarketUser loanMarketUser = new LoanMarketUser()
            {
                Mobile = userParamModel.Mobile, Password = userParamModel.Password, NickName = userParamModel.NickName, RealName = userParamModel.RealName, Sex = userParamModel.Sex
            };

            loanMarketUser.Id   = GuidTool.GenerateKey();
            loanMarketUser.Icon = "";
            loanMarketUser.Sex  = "";
            var list = user.FindUser();

            loanMarketUser.No             = list == null ? 1 : list.Count + 1;
            loanMarketUser.IsPeculiarUser = 0;
            int userNo = user.CreateUser(loanMarketUser);

            log.Info("创建推广的用户,创建用户成功,新创建的用户编号为:" + userNo);
            if (userNo > 0)
            {
                SpreadBLL spreadBLL = new SpreadBLL();
                if (spreadBLL.CreateSpread(userParamModel.FromUserNo, userNo) > 0)
                {
                    log.Info("创建推广的用户,创建用户成功,绑定上级成功。");
                    return(userNo);
                }
                else
                {
                    log.Info("创建推广的用户,创建用户成功,绑定上级失败。");
                    return(-2);
                }
            }
            else
            {
                log.Info("创建推广的用户,创建用户失败。");
                return(0);
            }
        }
示例#5
0
        /// <summary>
        /// 创建帖子
        /// </summary>
        public void CreateForum(ForumDetailApiModel detail)
        {
            detail.No = forum.FindForumList().Count + 1;
            LoanMarketForum loanMarketForum = new LoanMarketForum()
            {
                ContentBody  = detail.ContentBody,
                CreateTime   = DateTime.Now,
                CreateUserNo = detail.CreateUserNo,
                Id           = GuidTool.GenerateKey(),
                Title        = detail.Title,
                Type         = detail.Type,
                No           = detail.No,
                UpdateTime   = DateTime.Now,
                ViewCount    = 0,
                CommentCount = 0,
                LikeCount    = 0
            };

            forum.CreateForum(loanMarketForum);
        }
示例#6
0
        /// <summary>
        /// 创建提现申请
        /// </summary>
        /// <returns></returns>
        public int Create(WithdrawApplyApiModel applyModel)
        {
            if (applyModel == null)
            {
                return(0);
            }
            if (applyModel.UserNo <= 0)
            {
                return(0);
            }
            LoanMarketWithdrawApply model = new LoanMarketWithdrawApply();

            model.Id     = GuidTool.GenerateKey();
            model.Amount = applyModel.Amount;
            model.ApplyWithwrawAmount = applyModel.ApplyWithwrawAmount;
            model.CreateTime          = DateTime.Now;
            model.Status     = "提交申请";
            model.UpdateTime = DateTime.Now;
            model.UserNo     = applyModel.UserNo;
            UserBLL      userBLL  = new UserBLL();
            UserApiModel userInfo = userBLL.GetUserInfo(applyModel.UserNo);

            model.UserNickName = userInfo.NickName;
            model.UserRealName = userInfo.RealName;
            model.ZFBAccount   = applyModel.ZFBAccount;
            int          res = withdrawApply.Create(model);
            UserApiModel updateUserWithdrawAmount = new UserApiModel()
            {
                No             = applyModel.UserNo,
                WithdrawAmount = applyModel.Amount - applyModel.ApplyWithwrawAmount
            };

            if (userBLL.UpdateWithdrawAmount(updateUserWithdrawAmount) > 0)
            {
                return(res);
            }
            else
            {
                return(0);
            }
        }
示例#7
0
        /// <summary>
        /// 创建用户
        /// </summary>
        /// <param name="userParamModel"></param>
        /// <returns></returns>
        public int CreateUser(UserParamModel userParamModel)
        {
            //判断手机号是否已经存在
            if (user.GetUser(userParamModel.Mobile) != null)
            {
                return(-1);
            }
            LoanMarketUser loanMarketUser = new LoanMarketUser()
            {
                Mobile = userParamModel.Mobile, Password = userParamModel.Password, NickName = userParamModel.NickName, RealName = userParamModel.RealName, Sex = userParamModel.Sex
            };

            loanMarketUser.Id   = GuidTool.GenerateKey();
            loanMarketUser.Icon = "";
            loanMarketUser.Sex  = "";
            var list = user.FindUser();

            loanMarketUser.No             = list == null ? 1 : list.Count + 1;
            loanMarketUser.IsPeculiarUser = 0;
            return(user.CreateUser(loanMarketUser));
        }
示例#8
0
 /// <summary>
 /// 创建推广记录
 /// </summary>
 /// <param name="fromUserNo"></param>
 /// <param name="toUserNo"></param>
 /// <returns></returns>
 public int CreateSpread(int fromUserNo, int toUserNo)
 {
     spread.CreateSpread(new Models.LoanMarketSpread()
     {
         Id = GuidTool.GenerateKey(), FromUserNo = fromUserNo, ToUserNo = toUserNo, CreateTime = DateTime.Now, UpdateTime = DateTime.Now
     });
     try
     {
         //fromUser  是否是会员
         LoanMarketUser userInfo = user.GetUser(fromUserNo);
         if (userInfo.IsPeculiarUser == 1)
         {
             #region 会员升级
             //fromUset  所属组的升级条件
             LoanMarketGroup group = userGroup.GetUserGroup(fromUserNo);
             if (group != null)
             {
                 //fromUser  已经推广人数
                 int alreadySpreadUserCount = GetSpreadCount(fromUserNo);
                 if (alreadySpreadUserCount >= Convert.ToInt32(group.UpCondition))
                 {
                     //fromUser  进行升级
                     userGroup.UpdateUserGroup(fromUserNo, (int)group.ParentNo);
                 }
                 else
                 {
                     log.Info("不满足升级条件。" + fromUserNo);
                 }
             }
             else
             {
                 log.Info("创建推广记录SpreadBLL-CreateSpread:根据用户No查询不到所属组。" + fromUserNo);
             }
             #endregion
             #region 创建推广返佣单
             //推广人返佣30(直推)
             BillApiModel fromUserBillModel = new BillApiModel()
             {
                 Amount     = 30,
                 FromUserNo = fromUserNo.ToString(),
                 ToUserNo   = toUserNo.ToString(),
                 BillType   = (int)BillTypeEnum.直推
             };
             string fromUserBillNo = billBLL.CreateBill(fromUserBillModel);
             if (!string.IsNullOrEmpty(fromUserBillNo))
             {
                 log.Info("推广返佣单,直推人返佣单创建成功。" + fromUserNo);
             }
             else
             {
                 log.Info("推广返佣单,直推人返佣单创建失败。" + fromUserNo);
             }
             //推广人所属上级代理返佣
             List <LoanMarketSpread> leaders = spread.FindUserLeaders(fromUserNo);
             if (leaders != null && leaders.Count > 0)
             {
                 foreach (LoanMarketSpread item in leaders)
                 {
                     //上级代理的用户编号
                     int leaderUserNo = item.FromUserNo;
                     //获取上级代理所属组
                     LoanMarketGroup leaderUserGroup = userGroup.GetUserGroup(leaderUserNo);
                     //获取上级代理应返佣金
                     decimal      amount          = GetSpreadAmountByUserGroupNo(leaderUserGroup.No);
                     BillApiModel leaderBillModel = new BillApiModel()
                     {
                         Amount     = amount,
                         FromUserNo = leaderUserNo.ToString(),
                         ToUserNo   = toUserNo.ToString(),
                         BillType   = (int)BillTypeEnum.级代理
                     };
                     string leaderBillNo = billBLL.CreateBill(leaderBillModel);
                     if (!string.IsNullOrEmpty(leaderBillNo))
                     {
                         log.Info("推广返佣单,上级代理返佣单创建成功。" + JsonConvert.SerializeObject(leaderBillModel));
                     }
                     else
                     {
                         log.Info("推广返佣单,上级代理返佣单创建失败。" + JsonConvert.SerializeObject(leaderBillModel));
                     }
                 }
             }
             else
             {
                 log.Info("推广返佣金,推广人无上级代理." + fromUserNo);
             }
             #endregion
         }
         else
         {
             //非会员,不会升级,也无推广费用
             log.Info("创建推广记录SpreadBLL-CreateSpread:非会员,不会升级,也无推广费用." + fromUserNo);
         }
     }
     catch (Exception e)
     {
         log.Info("创建推广记录SpreadBLL-CreateSpread异常,异常信息为:" + e.Message + ".用户:" + fromUserNo);
     }
     return(1);
 }