Ejemplo n.º 1
0
        public UserBalanceInfo QueryUserBalance(string userId)
        {
            var manager = new UserBalanceManager();
            var balance = manager.QueryUserBalance(userId);

            if (balance == null)
            {
                throw new ArgumentException("用户账户不存在");
            }
            return(new UserBalanceInfo
            {
                UserId = balance.UserId,
                FillMoneyBalance = balance.FillMoneyBalance,
                BonusBalance = balance.BonusBalance,
                CommissionBalance = balance.CommissionBalance,
                FreezeBalance = balance.FreezeBalance,
                ExpertsBalance = balance.ExpertsBalance,
                RedBagBalance = balance.RedBagBalance,
                IsSetPwd = balance.IsSetPwd,
                NeedPwdPlace = balance.NeedPwdPlace,
                CurrentDouDou = balance.CurrentDouDou,
                UserGrowth = balance.UserGrowth,
                CPSBalance = balance.CPSBalance,
                BalancePwd = balance.Password,
            });
        }
Ejemplo n.º 2
0
        public void SetBalancePasswordNeedPlace(string userId, string password, string placeList)
        {
            var balanceManager = new UserBalanceManager();
            var entity         = balanceManager.QueryUserBalance(userId);

            if (entity.IsSetPwd)
            {
                password = Encipherment.MD5(string.Format("{0}{1}", password, _gbKey)).ToUpper();
                if (string.IsNullOrEmpty(password) || !password.Equals(entity.Password))
                {
                    throw new LogicException("输入资金密码错误");
                }
            }
            else
            {
                throw new LogicException("必须先设置资金密码");
            }
            entity.NeedPwdPlace = placeList;
            balanceManager.UpdateUserBalance(entity);
        }
Ejemplo n.º 3
0
        public void SetBalancePassword(string userId, string oldPassword, bool isSetPwd, string newPassword, string placeList)
        {
            var balanceManager = new UserBalanceManager();
            var entity         = balanceManager.QueryUserBalance(userId);

            if (entity.IsSetPwd)
            {
                oldPassword = Encipherment.MD5(string.Format("{0}{1}", oldPassword, _gbKey)).ToUpper();
                if (string.IsNullOrEmpty(oldPassword) || !oldPassword.Equals(entity.Password))
                {
                    throw new LogicException("输入资金密码错误");
                }
            }
            if (isSetPwd && !entity.IsSetPwd)
            {
                entity.NeedPwdPlace = placeList;
            }
            entity.IsSetPwd = isSetPwd;
            entity.Password = Encipherment.MD5(string.Format("{0}{1}", newPassword, _gbKey)).ToUpper();
            balanceManager.UpdateUserBalance(entity);
        }
Ejemplo n.º 4
0
        public string ChangePassword(string userId)
        {
            var r                      = new Random(DateTime.Now.Millisecond);
            var password               = r.Next(100000, 999999).ToString();
            var encodePassword         = Encipherment.MD5(string.Format("{0}{1}", password, _gbKey)).ToUpper();
            var password_balance       = r.Next(100000, 999999).ToString();
            var encodePassword_balance = Encipherment.MD5(string.Format("{0}{1}", password_balance, _gbKey)).ToUpper();

            try
            {
                DB.Begin();

                var user = GetLocalLoginByUserId(userId);
                if (user == null)
                {
                    throw new LogicException("用户不存在或不是本地注册用户,不能修改密码。请确定是否是通过支付宝或QQ帐号进行登录,如有疑问,请联系客服。");
                }
                user.Password = encodePassword;

                DB.GetDal <E_Login_Local>().Update(user);

                var balanceManage = new UserBalanceManager();
                var b             = balanceManage.QueryUserBalance(userId);
                b.Password = encodePassword_balance;
                balanceManage.UpdateUserBalance(b);
                DB.Commit();
            }
            catch (Exception ex)
            {
                DB.Rollback();
                throw ex;
            }


            return(string.Format("{0}|{1}", password, password_balance));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 申请提现
        /// 计算申请金额是否可提现,返回计算结果
        /// </summary>
        public CheckWithdrawResult RequestWithdraw_Step1(string userId, decimal requestMoney)
        {
            var balanceManager = new UserBalanceManager();
            var fundManager    = new FundManager();
            var userManager    = new UserManager();
            var maxTimes       = 3;
            var currentTimes   = fundManager.QueryTodayWithdrawTimes(userId);

            if (currentTimes >= maxTimes)
            {
                throw new LogicException(string.Format("每日只能提现{0}次", maxTimes));
            }
            var user = userManager.LoadUser(userId);

            if (user == null)
            {
                throw new LogicException("用户不存在 - " + userId);
            }
            var userBalance = balanceManager.QueryUserBalance(userId);

            if (userBalance == null)
            {
                throw new LogicException("用户帐户不存在 - " + userId);
            }

            //奖金+佣金+名家
            var can_tx_money = userBalance.BonusBalance + userBalance.CommissionBalance + userBalance.ExpertsBalance;

            //正常提现
            if (can_tx_money >= requestMoney)
            {
                return(new CheckWithdrawResult
                {
                    WithdrawCategory = WithdrawCategory.General,
                    RequestMoney = requestMoney,
                    ResponseMoney = requestMoney,
                    Summary = string.Format("申请提现{0:N2}元,到账{0:N2}元。", requestMoney),
                });
            }

            var payoutMoney = requestMoney - can_tx_money;

            if (userBalance.FillMoneyBalance < payoutMoney)
            {
                return(new CheckWithdrawResult
                {
                    WithdrawCategory = WithdrawCategory.Error,
                    RequestMoney = requestMoney,
                    ResponseMoney = 0,
                    Summary = "可用充值金额不足",
                });
            }

            #region  处理充值金额的消费,直接扣5%



            var percent = decimal.Parse(new CacheDataBusiness().QueryCoreConfigFromRedis("WithdrawAboutFillMoney.CutPercent"));
            //收取5%手续费
            var cutFree = payoutMoney * percent / 100;

            return(new CheckWithdrawResult
            {
                RequestMoney = requestMoney,
                ResponseMoney = requestMoney - cutFree,
                WithdrawCategory = WithdrawCategory.Compulsory,
                Summary = string.Format("提现金额中包含充值金额,需要扣除{0}%手续费{1:N2}元,实际到账{2:N2}元", percent, cutFree, requestMoney - cutFree),
            });

            #endregion
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 申请提现
        /// 实际添加提现记录,扣除用户资金
        /// </summary>
        public void RequestWithdraw_Step2(Withdraw_RequestInfo info, string userId, string balancepwd)
        {
            var userManager = new UserBalanceManager();
            var fundManager = new FundManager();
            var user        = userManager.QueryUserRegister(userId);

            if (!user.IsEnable)
            {
                throw new LogicException("用户已禁用");
            }
            //资金密码判断
            string  place       = "Withdraw";
            decimal payoutMoney = info.RequestMoney;
            var     userBalance = userManager.QueryUserBalance(userId);

            if (userBalance == null)
            {
                throw new LogicException("用户帐户不存在 - " + userId);
            }
            if (userBalance.IsSetPwd && !string.IsNullOrEmpty(userBalance.NeedPwdPlace))
            {
                if (userBalance.NeedPwdPlace == "ALL" || userBalance.NeedPwdPlace.Split('|', ',').Contains(place))
                {
                    balancepwd = Encipherment.MD5(string.Format("{0}{1}", balancepwd, _gbKey)).ToUpper();
                    if (!userBalance.Password.ToUpper().Equals(balancepwd))
                    {
                        throw new LogicException("资金密码输入错误");
                    }
                }
            }
            var totalMoney = userBalance.FillMoneyBalance + userBalance.BonusBalance + userBalance.CommissionBalance + userBalance.ExpertsBalance;

            if (totalMoney < payoutMoney)
            {
                throw new LogicException(string.Format("用户总金额小于 {0:N2}元。", payoutMoney));
            }
            var orderId      = BettingHelper.GetWithdrawId();
            var maxTimes     = 3;
            var currentTimes = fundManager.QueryTodayWithdrawTimes(userId);

            if (currentTimes >= maxTimes)
            {
                throw new LogicException(string.Format("每日只能提现{0}次", maxTimes));
            }
            DB.Begin();
            try
            {
                var resonseMoney = 0M;

                BusinessHelper businessHelper = new BusinessHelper();
                var            category       = businessHelper.Payout_To_Frozen_Withdraw(fundManager, userManager, userBalance, BusinessHelper.FundCategory_RequestWithdraw, userId, orderId, info.RequestMoney
                                                                                         , string.Format("申请提现:{0:N2}元", info.RequestMoney), "Withdraw", balancepwd, out resonseMoney);


                fundManager.AddWithdraw(new C_Withdraw
                {
                    OrderId        = orderId,
                    BankCardNumber = info.BankCardNumber,
                    BankCode       = info.BankCode,
                    BankName       = info.BankName,
                    BankSubName    = info.BankSubName,
                    CityName       = info.CityName,
                    RequestTime    = DateTime.Now,
                    ProvinceName   = info.ProvinceName,
                    UserId         = userId,
                    RequestMoney   = info.RequestMoney,
                    WithdrawAgent  = (int)info.WithdrawAgent,
                    Status         = (int)WithdrawStatus.Requesting,

                    WithdrawCategory = (int)category,
                    ResponseMoney    = resonseMoney,
                });

                //查询到账金额
                //var wi = GetWithdrawById(orderId);


                //判断DP是否可用
                var cacheDataBusiness = new CacheDataBusiness();
                var iscoreConfigInfo  = cacheDataBusiness.QueryCoreConfigByKey("DP.Isvailable");
                //获取当前系统时间(4-5点DP关闭)
                var      datetime    = System.DateTime.Now;
                var      nowHourAndM = datetime.ToString("t");
                var      datestar    = cacheDataBusiness.QueryCoreConfigByKey("DP.StartTime");
                var      dateend     = cacheDataBusiness.QueryCoreConfigByKey("DP.EndTime");
                DateTime dstar       = Convert.ToDateTime(datestar.ConfigValue);
                DateTime dend        = Convert.ToDateTime(dateend.ConfigValue);

                if (iscoreConfigInfo.ConfigValue == "1")
                {
                    if (datetime <= dstar || datetime >= dend)
                    {
                        //发送消息到DP
                        //判断是否发送到DP
                        String htmls = info.BankName;
                        //获取Dp提现最大限额
                        var coreConfigInfo = cacheDataBusiness.QueryCoreConfigByKey("DP.WithdrawHigthMoney");
                        //获取Dp给的公司编码
                        var coreConfigInfoC = cacheDataBusiness.QueryCoreConfigByKey("DP.Companyid");
                        //获取DP给的key
                        var ck = cacheDataBusiness.QueryCoreConfigByKey("DP.Key");
                        //获取DP访问路径
                        var     cw = cacheDataBusiness.QueryCoreConfigByKey("DP.WebUrl");
                        decimal withdrawHigthMoney = decimal.Parse(coreConfigInfo.ConfigValue);
                        //var writer = Common.Log.LogWriterGetter.GetLogWriter();
                        //writer.Write("关于DP日志", "关于DP日志", Common.Log.LogType.Information, "关于DP日志", "withdrawHigthMoney===============" + withdrawHigthMoney);

                        String str = String.Format("BankCardNumber=" + info.BankCardNumber + ",BankCode=" + info.BankCode + ",BankName=" + info.BankName + ",BankSubName=" + info.BankSubName + ",CityName=" + info.CityName + ",ProvinceName=" + info.ProvinceName + ",RequestMoney=" + info.RequestMoney + ",userRealName=" + info.userRealName + ",WithdrawAgent=" + info.WithdrawAgent + "");
                        //writer.Write("输出参数写测试用例", "输出参数写测试用例", Common.Log.LogType.Information, "输出参数写测试用例", "输出参数写测试用例===============" + str);
                        WithdrawApplyInfo wai = new WithdrawApplyInfo();
                        wai.company_order_num  = orderId;
                        wai.company_user       = userId;
                        wai.card_name          = info.userRealName;
                        wai.card_num           = info.BankCardNumber;
                        wai.issue_bank_name    = info.BankName;
                        wai.issue_bank_address = info.BankSubName;
                        wai.memo = "";
                        String amount = resonseMoney.ToString();
                        wai.amount = Math.Round(decimal.Parse(amount), 2);

                        wai.company_id = Int32.Parse(coreConfigInfoC.ConfigValue);
                        String  dpresult    = null;
                        decimal dpHighmoney = decimal.Parse(coreConfigInfo.ConfigValue);
                        if (info.RequestMoney < withdrawHigthMoney)
                        {
                            if (htmls.Contains("工商银行"))
                            {
                                int bankid = (int)BankCode.ICBC;
                                wai.bank_id = bankid.ToString();
                            }
                            else if (htmls.Contains("招商银行"))
                            {
                                int bankid = (int)BankCode.CMB;
                                wai.bank_id = bankid.ToString();
                            }
                            else if (htmls.Contains("建设银行"))
                            {
                                int bankid = (int)BankCode.CCB;
                                wai.bank_id = bankid.ToString();
                            }
                            else if (htmls.Contains("农业银行"))
                            {
                                int bankid = (int)BankCode.ABC;
                                wai.bank_id = bankid.ToString();
                            }
                            else if (htmls.Contains("中国银行"))
                            {
                                int bankid = (int)BankCode.BOC;
                                wai.bank_id = bankid.ToString();
                            }
                            else if (htmls.Contains("交通银行"))
                            {
                                int bankid = (int)BankCode.BCM;
                                wai.bank_id = bankid.ToString();
                            }

                            else if (htmls.Contains("中国民生银行") || htmls.Contains("民生银行"))
                            {
                                int bankid = (int)BankCode.CMBC;
                                wai.bank_id = bankid.ToString();
                            }

                            else if (htmls.Contains("中信银行"))
                            {
                                int bankid = (int)BankCode.ECC;
                                wai.bank_id = bankid.ToString();
                            }
                            else if (htmls.Contains("浦东发展银行") || htmls.Contains("浦发") || htmls.Contains("浦东"))
                            {
                                int bankid = (int)BankCode.SPDB;
                                wai.bank_id = bankid.ToString();
                            }
                            else if (htmls.Contains("邮政储蓄") || htmls.Contains("中国邮政"))
                            {
                                int bankid = (int)BankCode.PSBC;
                                wai.bank_id = bankid.ToString();
                            }

                            else if (htmls.Contains("光大银行"))
                            {
                                int bankid = (int)BankCode.CEB;
                                wai.bank_id = bankid.ToString();
                            }

                            else if (htmls.Contains("平安银行"))
                            {
                                int bankid = (int)BankCode.PINGAN;
                                wai.bank_id = bankid.ToString();
                            }
                            else if (htmls.Contains("广东发展银行") || htmls.Contains("广发银行"))
                            {
                                int bankid = (int)BankCode.CGB;
                                wai.bank_id = bankid.ToString();
                            }
                            else if (htmls.Contains("华夏银行"))
                            {
                                int bankid = (int)BankCode.HXB;
                                wai.bank_id = bankid.ToString();
                            }

                            else if (htmls.Contains("兴业银行"))
                            {
                                int bankid = (int)BankCode.CIB;
                                wai.bank_id = bankid.ToString();
                            }
                            else
                            {
                                var pListe = new List <string>();
                                pListe.Add(string.Format("{0}={1}", "[OrderId]", orderId));
                                pListe.Add(string.Format("{0}={1}", "[UserName]", user.DisplayName));
                                pListe.Add(string.Format("{0}={1}", "[RequestMoney]", info.RequestMoney));
                                pListe.Add(string.Format("{0}={1}", "[ResponseMoney]", resonseMoney));
                                //发送短信
                                new SiteMessageControllBusiness().DoSendSiteMessage(userId, "", "ON_User_Request_Withdraw", pListe.ToArray());
                                DB.Commit();
                                //刷新余额
                                BusinessHelper.RefreshRedisUserBalance(userId);
                                return;
                            }
                            dpresult = Withdrawal(wai, ck.ConfigValue, cw.ConfigValue);
                            if (dpresult == null || dpresult == "")
                            {
                                DB.Rollback();
                                throw new Exception("服务繁忙,请稍后重试,如多次尝试失败,请在客服服务时间内联系在线客服咨询");
                            }
                        }
                    }
                }

                #region 发送站内消息:手机短信或站内信
                var pList = new List <string>();
                pList.Add(string.Format("{0}={1}", "[OrderId]", orderId));
                pList.Add(string.Format("{0}={1}", "[UserName]", ""));
                pList.Add(string.Format("{0}={1}", "[RequestMoney]", info.RequestMoney));
                pList.Add(string.Format("{0}={1}", "[ResponseMoney]", resonseMoney));
                //发送短信
                new SiteMessageControllBusiness().DoSendSiteMessage(userId, "", "ON_User_Request_Withdraw", pList.ToArray());

                #endregion

                DB.Commit();
                //刷新余额
                BusinessHelper.RefreshRedisUserBalance(userId);
            }
            catch (Exception ex)
            {
                DB.Rollback();
                throw ex;
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        ///  用户支出,申请提现
        /// </summary>
        public WithdrawCategory Payout_To_Frozen_Withdraw(string category, string userId, string orderId, decimal payoutMoney,
                                                          string summary, string place, string password, out decimal responseMoney)
        {
            var requestMoney = payoutMoney;

            if (payoutMoney <= 0M)
            {
                throw new Exception("消费金额不能小于0.");
            }
            //查询帐户余额
            var balanceManager = new UserBalanceManager();
            var fundManager    = new FundManager();
            //资金密码判断
            var userBalance = balanceManager.QueryUserBalance(userId);

            if (userBalance == null)
            {
                throw new Exception("用户帐户不存在 - " + userId);
            }
            if (userBalance.IsSetPwd && !string.IsNullOrEmpty(userBalance.NeedPwdPlace))
            {
                if (userBalance.NeedPwdPlace == "ALL" || userBalance.NeedPwdPlace.Split('|', ',').Contains(place))
                {
                    password = Encipherment.MD5(string.Format("{0}{1}", password, _gbKey)).ToUpper();
                    if (!userBalance.Password.ToUpper().Equals(password))
                    {
                        throw new Exception("资金密码输入错误");
                    }
                }
            }
            var totalMoney = userBalance.FillMoneyBalance + userBalance.BonusBalance + userBalance.CommissionBalance + userBalance.ExpertsBalance;

            if (totalMoney < payoutMoney)
            {
                throw new Exception(string.Format("用户总金额小于 {0:N2}元。", payoutMoney));
            }

            var payDetailList = new List <PayDetail>();

            payDetailList.Add(new PayDetail
            {
                AccountType = AccountType.Freeze,
                PayMoney    = payoutMoney,
                PayType     = PayType.Payin,
            });
            //冻结资金明细
            fundManager.AddFundDetail(new C_Fund_Detail
            {
                Category      = category,
                CreateTime    = DateTime.Now,
                KeyLine       = orderId,
                OrderId       = orderId,
                AccountType   = (int)AccountType.Freeze,
                PayMoney      = payoutMoney,
                PayType       = (int)PayType.Payin,
                Summary       = summary,
                UserId        = userId,
                BeforeBalance = userBalance.FreezeBalance,
                AfterBalance  = userBalance.FreezeBalance + payoutMoney,
                OperatorId    = userId,
            });

            //userBalance.FreezeBalance += payoutMoney;

            #region 正常提现

            //奖金+佣金+名家
            var currentPayout = 0M;
            if (userBalance.BonusBalance > 0M && payoutMoney > 0M)
            {
                //奖金参与支付
                currentPayout = userBalance.BonusBalance >= payoutMoney ? payoutMoney : userBalance.BonusBalance;
                payoutMoney  -= currentPayout;
                payDetailList.Add(new PayDetail
                {
                    AccountType = AccountType.Bonus,
                    PayMoney    = currentPayout,
                    PayType     = PayType.Payout,
                });
                fundManager.AddFundDetail(new C_Fund_Detail
                {
                    Category      = category,
                    CreateTime    = DateTime.Now,
                    KeyLine       = orderId,
                    OrderId       = orderId,
                    AccountType   = (int)AccountType.Bonus,
                    PayMoney      = currentPayout,
                    PayType       = (int)PayType.Payout,
                    Summary       = summary,
                    UserId        = userId,
                    BeforeBalance = userBalance.BonusBalance,
                    AfterBalance  = userBalance.BonusBalance - currentPayout,
                    OperatorId    = userId,
                });

                //userBalance.BonusBalance -= currentPayout;
            }
            if (userBalance.CommissionBalance > 0M && payoutMoney > 0M)
            {
                //佣金参与支付
                currentPayout = userBalance.CommissionBalance >= payoutMoney ? payoutMoney : userBalance.CommissionBalance;
                payoutMoney  -= currentPayout;
                payDetailList.Add(new PayDetail
                {
                    AccountType = AccountType.Commission,
                    PayMoney    = currentPayout,
                    PayType     = PayType.Payout,
                });
                fundManager.AddFundDetail(new C_Fund_Detail
                {
                    Category      = category,
                    CreateTime    = DateTime.Now,
                    KeyLine       = orderId,
                    OrderId       = orderId,
                    AccountType   = (int)AccountType.Commission,
                    PayMoney      = currentPayout,
                    PayType       = (int)PayType.Payout,
                    Summary       = summary,
                    UserId        = userId,
                    BeforeBalance = userBalance.CommissionBalance,
                    AfterBalance  = userBalance.CommissionBalance - currentPayout,
                    OperatorId    = userId,
                });
                //userBalance.CommissionBalance -= currentPayout;
            }
            if (userBalance.ExpertsBalance > 0M && payoutMoney > 0M)
            {
                //名家参与支付
                currentPayout = userBalance.ExpertsBalance >= payoutMoney ? payoutMoney : userBalance.ExpertsBalance;
                payoutMoney  -= currentPayout;
                payDetailList.Add(new PayDetail
                {
                    AccountType = AccountType.Experts,
                    PayMoney    = currentPayout,
                    PayType     = PayType.Payout,
                });
                fundManager.AddFundDetail(new C_Fund_Detail
                {
                    Category      = category,
                    CreateTime    = DateTime.Now,
                    KeyLine       = orderId,
                    OrderId       = orderId,
                    AccountType   = (int)AccountType.Experts,
                    PayMoney      = currentPayout,
                    PayType       = (int)PayType.Payout,
                    Summary       = summary,
                    UserId        = userId,
                    BeforeBalance = userBalance.ExpertsBalance,
                    AfterBalance  = userBalance.ExpertsBalance - currentPayout,
                    OperatorId    = userId,
                });
                //userBalance.ExpertsBalance -= currentPayout;
            }

            #endregion

            responseMoney = requestMoney;
            var payCategory = WithdrawCategory.Compulsory;
            if (payoutMoney <= 0M)
            {
                payCategory = WithdrawCategory.General;
            }
            else
            {
                //使用充值金额扣款
                if (userBalance.FillMoneyBalance < payoutMoney)
                {
                    throw new Exception("可用充值金额不足");
                }

                #region 异常提现

                //收取5%手续费
                var percent    = decimal.Parse(new CacheDataBusiness().QueryCoreConfigFromRedis("WithdrawAboutFillMoney.CutPercent"));
                var counterFee = payoutMoney * percent / 100;
                //到帐金额
                responseMoney = requestMoney - counterFee;

                //手续费明细
                fundManager.AddFundDetail(new C_Fund_Detail
                {
                    Category      = BusinessHelper.FundCategory_RequestWithdrawCounterFee,
                    CreateTime    = DateTime.Now,
                    KeyLine       = orderId,
                    OrderId       = orderId,
                    AccountType   = (int)AccountType.FillMoney,
                    PayMoney      = counterFee,
                    PayType       = (int)PayType.Payout,
                    Summary       = summary,
                    UserId        = userId,
                    BeforeBalance = userBalance.FillMoneyBalance,
                    AfterBalance  = userBalance.FillMoneyBalance - counterFee,
                    OperatorId    = userId,
                });
                //userBalance.FillMoneyBalance -= counterFee;

                //到帐金额
                var resMoney = payoutMoney - counterFee;
                //写充值金额的扣款资金明细
                fundManager.AddFundDetail(new C_Fund_Detail
                {
                    Category      = category,
                    CreateTime    = DateTime.Now,
                    KeyLine       = orderId,
                    OrderId       = orderId,
                    AccountType   = (int)AccountType.FillMoney,
                    PayMoney      = resMoney,
                    PayType       = (int)PayType.Payout,
                    Summary       = summary,
                    UserId        = userId,
                    BeforeBalance = userBalance.FillMoneyBalance,
                    AfterBalance  = userBalance.FillMoneyBalance - resMoney,
                    OperatorId    = userId,
                });
                //userBalance.FillMoneyBalance -= resMoney;

                payDetailList.Add(new PayDetail
                {
                    AccountType = AccountType.FillMoney,
                    PayMoney    = counterFee + resMoney,
                    PayType     = PayType.Payout,
                });

                #endregion
            }
            //balanceManager.UpdateUserBalance(userBalance);
            PayToUserBalance(userId, payDetailList.ToArray());

            return(payCategory);
        }
Ejemplo n.º 8
0
        public bool User_AfterLogin(string userId, string loginFrom, string loginIp, DateTime loginTime)
        {
            if (string.IsNullOrEmpty(userId))
            {
                return(false);
            }
            var date = DateTime.Today.ToString("yyyyMMdd");
            //注册当前登录不送红包
            var user = new UserBalanceManager().QueryUserRegister(userId);

            if (user.CreateTime.ToString("yyyyMMdd") == date)
            {
                return(false);
            }


            var bizRealName = new RealNameAuthenticationBusiness();
            var realName    = bizRealName.GetAuthenticatedRealName(userId);

            if (realName == null)
            {
                return(false);
            }
            var bizMoible = new MobileAuthenticationBusiness();
            var mobile    = bizMoible.GetAuthenticatedMobile(userId);

            if (mobile == null || !mobile.IsSettedMobile)
            {
                return(false);
            }

            var manager = new A20150919Manager();
            var record  = manager.QueryA20150919_已绑定身份和手机的用户登录送红包(userId, date);

            if (record != null)
            {
                return(false);
            }

            //var old = manager.QueryByUserId(userId);
            //if (old == null) return;
            //if (!old.IsBindRealName) return;
            //if (!old.IsBindMobile) return;

            decimal giveMoney = decimal.Parse(ActivityCache.QueryActivityConfig("ActivityConfig.BindedUserLoginGiveRedBag"));

            if (user.VipLevel >= 0)
            {
                var config = ActivityCache.QueryActivityConfig(string.Format("ActivityConfig.BindedUserLoginGiveRedBagV{0}", user.VipLevel));
                if (config != null)
                {
                    try
                    {
                        giveMoney = decimal.Parse(config);
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            if (giveMoney > 0)
            {
                BusinessHelper.Payin_To_Balance(AccountType.RedBag, BusinessHelper.FundCategory_Activity, userId, Guid.NewGuid().ToString("N"), giveMoney
                                                , string.Format("绑定身份和手机后,VIP{1} 每天登录赠送红包{0}元", giveMoney, user.VipLevel), RedBagCategory.Activity);
                manager.AddA20150919_已绑定身份和手机的用户登录送红包(new E_A20150919_已绑定身份和手机的用户登录送红包
                {
                    CreateTime      = DateTime.Now,
                    UserId          = userId,
                    LoginDate       = date,
                    GiveRedBagMoney = giveMoney,
                });
                return(true);
            }
            return(false);
        }
        public void AddAuthenticationRealName(string authFrom, string userId, string realName, string cardType, string idCardNumber, string createBy, bool checkRepet)
        {
            var manager = new UserRealNameManager();

            if (checkRepet)
            {
                var other = manager.QueryUserRealName(idCardNumber);
                if (other != null)
                {
                    throw new LogicException(string.Format("此证件号【{0}】已被其他用户认证。", idCardNumber));
                }
                //var other2 = manager.QueryUserRealNameByName(realName);
                //if (other2 != null)
                //    throw new ArgumentException("对不起,由于系统检测到您的姓名已被绑定,请联系在线客服为您人工绑定,给您带来的不便敬请谅解,此绑定不影响您的正常购彩和提现。");
            }

            var entity = GetAuthenticatedRealName(userId);

            if (entity != null)
            {
                entity.RealName         = realName;
                entity.IdCardNumber     = idCardNumber;
                entity.IsSettedRealName = true;
                manager.UpdateUserRealName(entity);
                //throw new ArgumentException(string.Format("此用户已于【{0:yyyy-MM-dd HH:mm:ss}】进行过实名认证", entity.CreateTime));
            }
            else
            {
                if (entity == null)
                {
                    entity = new E_Authentication_RealName
                    {
                        UserId           = userId,
                        AuthFrom         = authFrom,
                        RealName         = realName,
                        CardType         = cardType,
                        IdCardNumber     = idCardNumber,
                        IsSettedRealName = true,
                        CreateBy         = createBy,
                        UpdateBy         = createBy,
                    };
                    manager.AddUserRealName(entity);
                }
                else
                {
                    throw new LogicException(string.Format("此用户已于【{0:yyyy-MM-dd HH:mm:ss}】进行过实名认证", entity.CreateTime));
                }
            }

            //修改vip等级
            var balanceManager = new UserBalanceManager();
            var user           = balanceManager.QueryUserRegister(userId);

            user.VipLevel = 1;
            balanceManager.UpdateUserRegister(user);

            var gv  = new TaskListManager();
            var old = gv.QueryTaskListByCategory(userId, TaskCategory.RealName);

            if (old == null)
            {
                var orderId = Guid.NewGuid().ToString("N");
                //增加成长值
                //BusinessHelper.Payin_UserGrowth("实名认证", orderId, userId, 200, "完成实名认证获得200点成长值");
                var UserTaskRecord = new E_UserTaskRecord
                {
                    OrderId      = orderId,
                    CurrentTime  = DateTime.Now.ToString("yyyyMMdd"),
                    CreateTime   = DateTime.Now,
                    TaskName     = "实名认证",
                    TaskCategory = (int)TaskCategory.RealName,
                    UserId       = userId,
                };
                gv.AddUserTaskRecord(UserTaskRecord);
                //赠送成长值记录
                var addTaskList = new E_TaskList
                {
                    UserId       = userId,
                    OrderId      = Guid.NewGuid().ToString("N"),
                    Content      = "完成实名认证获得200点成长值",
                    ValueGrowth  = 200,
                    CurrentTime  = DateTime.Now.ToString("yyyyMMdd"),
                    TaskCategory = (int)TaskCategory.RealName,
                    VipLevel     = 0,
                    IsGive       = true,
                    TaskName     = "实名认证",
                    CreateTime   = DateTime.Now,
                };
                gv.AddTaskList(addTaskList);
            }
        }