Example #1
0
        MessageCode Tran_InvestDeposit(PayUserEntity payUser, InvestManagerEntity investInfo, int point, DbTransaction transaction)
        {
            if (!InvestManagerMgr.Update(investInfo, transaction))
            {
                return(MessageCode.NbUpdateFail);
            }
            int returnCode = -2;

            PayUserMgr.ConsumePoint(payUser.Account, investInfo.ManagerId, (int)EnumConsumeSourceType.InvestDeposit,
                                    Guid.NewGuid().ToString(), point, DateTime.Now, payUser.RowVersion, ref returnCode, transaction);
            if (returnCode != (int)MessageCode.PaySuccess)
            {
                return(MessageCode.NbUpdateFail);
            }
            return(MessageCode.Success);
        }
Example #2
0
        /// <summary>
        /// GetById
        /// </summary>
        /// <param name="account">account</param>
        /// <returns>PayUserEntity</returns>
        /// <remarks>2016/6/17 10:28:37</remarks>
        public PayUserEntity GetById(System.String account)
        {
            var database = new SqlDatabase(this.ConnectionString);

            DbCommand commandWrapper = database.GetStoredProcCommand("P_PayUser_GetById");

            database.AddInParameter(commandWrapper, "@Account", DbType.AnsiString, account);


            PayUserEntity obj = null;

            using (IDataReader reader = database.ExecuteReader(commandWrapper))
            {
                if (reader.Read())
                {
                    obj = LoadSingleRow(reader);
                }
            }
            return(obj);
        }
Example #3
0
        /// <summary>
        /// GetPointByManagerId
        /// </summary>
        /// <param name="managerId">managerId</param>
        /// <returns>PayUserEntity</returns>
        /// <remarks>2016/6/17 10:28:37</remarks>
        public PayUserEntity GetPointByManagerId(System.Guid managerId)
        {
            var database = new SqlDatabase(this.ConnectionString);

            DbCommand commandWrapper = database.GetStoredProcCommand("C_Pay_GetPointByManagerId");

            database.AddInParameter(commandWrapper, "@ManagerId", DbType.Guid, managerId);


            PayUserEntity obj = null;

            using (IDataReader reader = database.ExecuteReader(commandWrapper))
            {
                if (reader.Read())
                {
                    obj = LoadSingleRow(reader);
                }
            }
            return(obj);
        }
Example #4
0
        public InvestInfoResponse InvestDepositMonth(Guid managerId)
        {
            var investInfo = InvestManagerMgr.GetById(managerId);

            if (investInfo == null)
            {
                return(ResponseHelper.Create <InvestInfoResponse>(MessageCode.InvalidArgs));
            }
            investInfo.DepositCount++;
            if (investInfo.DepositCount > 0)
            {
                investInfo.Once = true;
            }
            if (investInfo.TheMonthly)
            {
                investInfo.ExpirationTime = investInfo.ExpirationTime.AddDays(30);
            }
            else
            {
                investInfo.TheMonthly     = true;
                investInfo.MonthlyTime    = DateTime.Today;
                investInfo.ExpirationTime = DateTime.Today.AddDays(30);
                investInfo.ReceivedCount  = 0;
            }
            List <int>    restitution = CacheFactory.ActivityCache.BuildRestitution(investInfo.StepStatus);
            PayUserEntity payUser     = PayCore.Instance.GetPayUser(managerId);

            if (payUser.TotalPoint < _investDepositMonthly)
            {
                return(ResponseHelper.Create <InvestInfoResponse>(MessageCode.NbPointShortage));
            }
            var code = Save_TranInvestDeposit(payUser, investInfo, _investDepositMonthly);

            if (code != MessageCode.Success)
            {
                return(ResponseHelper.Create <InvestInfoResponse>(code));
            }
            return(BuildInvestInfoResponse(investInfo, restitution, investInfo.StepStatus, payUser, _investDepositMonthly));
        }
Example #5
0
        InvestInfoResponse BuildInvestInfoResponse(InvestManagerEntity investInfo, List <int> restitution, string newStepStatus, PayUserEntity payUser, int depositPoint)
        {
            var response = ResponseHelper.CreateSuccess <InvestInfoResponse>();

            response.Data = new InvestInfoEntity();

            response.Data.Deposit       = investInfo.Deposit;
            response.Data.Restitution   = restitution;
            response.Data.ReceiveStatus = BuildReceiveStatus(newStepStatus);
            response.Data.Once          = investInfo.Once;

            if (DateTime.Today > investInfo.ExpirationTime)
            {
                response.Data.TotalCount   = 0;
                response.Data.ReceiveCount = 0;
            }
            else
            {
                response.Data.TotalCount   = (investInfo.ExpirationTime - investInfo.MonthlyTime).Days;
                response.Data.ReceiveCount = investInfo.ReceivedCount;
            }

            if (investInfo.TheMonthly)
            {
                response.Data.DayCount = (DateTime.Today - investInfo.MonthlyTime).Days + 1;
            }
            else
            {
                response.Data.DayCount = 0;
            }
            if (payUser == null)
            {
                response.Data.BindPoint = 0;
            }
            else
            {
                response.Data.BindPoint = payUser.BindPoint;
                //ChatHelper.SendUpdateManagerInfoPop(investInfo.ManagerId, payUser.TotalPoint - depositPoint, true);
            }

            return(response);
        }
Example #6
0
        public static bool Update(PayUserEntity payUserEntity, DbTransaction trans = null, string zoneId = "")
        {
            var provider = new PayUserProvider(zoneId);

            return(provider.Update(payUserEntity, trans));
        }
Example #7
0
        public static void ChargeAfter(string account, int point, int needPoint, DateTime curTime, decimal cash,
                                       int vipExp)
        {
            try
            {
                PayContinuingMgr.UpdateContinueday(account, point, needPoint, curTime.Date.AddDays(-1), curTime.Date,
                                                   curTime);
            }
            catch (Exception ex)
            {
                SystemlogMgr.Error("ChargeUpContinue", ex);
            }
            var  payUser  = PayUserMgr.GetById(account);
            bool isInsert = false;

            if (payUser == null)
            {
                isInsert = true;
                payUser  = new PayUserEntity(account, 0, 0, cash, DateTime.Now, new byte[0], point, 0);
            }
            else
            {
                payUser.TotalCash  += cash;
                payUser.ChargePoint = point;
            }
            try
            {
                if (isInsert)
                {
                    if (!PayUserMgr.Insert(payUser))
                    {
                        SystemlogMgr.Error("charetUpPayUser", "统计钱失败", "Account:" + account + "_Cash" + cash);
                    }
                }
                else
                {
                    if (!PayUserMgr.Update(payUser))
                    {
                        SystemlogMgr.Error("charetUpPayUser", "统计钱失败", "Account:" + account + "_Cash" + cash);
                    }
                }
            }
            catch (Exception ex)
            {
                SystemlogMgr.Error("charetUpPayUser" + cash, ex);
            }
            var manager = ManagerCore.Instance.GetManager(account);

            try
            {
                if (manager != null)
                {
                    var curScore   = vipExp;
                    var vipManager = VipManagerMgr.GetById(manager.Idx);
                    if (vipManager != null)
                    {
                        curScore         += vipManager.VipExp;
                        vipManager.VipExp = curScore;
                        VipManagerMgr.Update(vipManager);
                    }
                    else
                    {
                        vipManager = new VipManagerEntity(manager.Idx, curScore, DateTime.Now, DateTime.Now,
                                                          DateTime.Now);
                        VipManagerMgr.Insert(vipManager);
                    }

                    var newlevel = CacheFactory.VipdicCache.GetVipLevel(curScore);
                    if (newlevel > manager.VipLevel)
                    {
                        manager.VipLevel = newlevel;
                        ManagerUtil.SaveManagerData(manager);
                        ManagerCore.Instance.DeleteCache(manager.Idx);
                    }
                    // ChatHelper.SendUpdateManagerInfoPop(manager.Idx, payUser.TotalPoint, true, manager.VipLevel);

                    ActivityExThread.Instance.Charge(manager.Idx, account, vipExp);
                    ActivityExThread.Instance.Charge(manager.Idx, vipExp);
                }
            }
            catch (Exception ex)
            {
                SystemlogMgr.Error("ChargeUpVip", ex);
            }
        }
Example #8
0
        MessageCode Tran_SaveAttachment(DbTransaction transaction, List <MailInfoEntity> mails, ItemPackageFrame package, NbManagerEntity manager, int coin, int sophicate, int point, int prestige, int bindPoint, int addGoldBar, Guid managerId, int addluckyCoin, int addGameCoin)
        {
            var orderId = mails[0].Idx.ToString();

            foreach (var mail in mails)
            {
                if (!MailInfoMgr.Update(mail, transaction))
                {
                    return(MessageCode.NbUpdateFail);
                }
            }
            if (package != null)
            {
                if (!package.Save(transaction))
                {
                    return(MessageCode.NbUpdateFail);
                }
            }

            if (coin > 0)
            {
                var code = ManagerCore.Instance.AddCoin(manager, coin, EnumCoinChargeSourceType.MailAttachment, orderId, transaction);
                if (code != MessageCode.Success)
                {
                    return(MessageCode.NbUpdateFail);
                }
            }
            if (sophicate > 0)
            {
                int resultSophisticate = manager.Sophisticate;
                if (!NbManagerMgr.AddSophisticate(manager.Idx, sophicate, ref resultSophisticate, transaction))
                {
                    return(MessageCode.NbUpdateFail);
                }
            }
            if (point > 0)
            {
                var code = PayCore.Instance.AddBonus(manager.Account, point, EnumChargeSourceType.MailAttachment,
                                                     orderId, transaction);
                if (code != MessageCode.Success)
                {
                    return(MessageCode.NbUpdateFail);
                }
            }
            if (bindPoint > 0)
            {
                var payUser = PayUserMgr.GetById(manager.Account);
                if (payUser == null)
                {
                    payUser           = new PayUserEntity();
                    payUser.Account   = manager.Account;
                    payUser.BindPoint = bindPoint;
                    payUser.RowTime   = DateTime.Now;
                    payUser.IsNew     = true;
                }
                else
                {
                    payUser.BindPoint += bindPoint;
                }
                if (payUser.IsNew)
                {
                    if (!PayUserMgr.Insert(payUser, transaction))
                    {
                        return(MessageCode.NbUpdateFail);
                    }
                }
                else
                {
                    if (!PayUserMgr.Update(payUser, transaction))
                    {
                        return(MessageCode.NbUpdateFail);
                    }
                }
            }
            if (addGoldBar > 0)
            {
                var goldBarManager = ScoutingGoldbarMgr.GetById(managerId);
                if (goldBarManager == null)
                {
                    goldBarManager = new ScoutingGoldbarEntity(managerId, addGoldBar, 0, 0, 0, DateTime.Now,
                                                               DateTime.Now);
                    if (!ScoutingGoldbarMgr.Insert(goldBarManager, transaction))
                    {
                        return(MessageCode.NbUpdateFail);
                    }
                }
                else
                {
                    goldBarManager.GoldBarNumber = goldBarManager.GoldBarNumber + addGoldBar;
                    if (!ScoutingGoldbarMgr.Update(goldBarManager, transaction))
                    {
                        return(MessageCode.NbUpdateFail);
                    }
                }
                GoldbarRecordEntity record = new GoldbarRecordEntity(0, managerId, true, addGoldBar, (int)EnumCoinChargeSourceType.MailAttachment, DateTime.Now);
                GoldbarRecordMgr.Insert(record);
            }
            if (addluckyCoin > 0)
            {
                if (!TurntableManagerMgr.AddLuckyCoin(managerId, addluckyCoin, transaction))
                {
                    return(MessageCode.NbUpdateFail);
                }
            }
            if (addGameCoin > 0)
            {
                if (!PenaltykickManagerMgr.AddGameCurrency(managerId, addGameCoin, transaction))
                {
                    return(MessageCode.NbUpdateFail);
                }
            }

            return(MessageCode.Success);
        }