Esempio n. 1
0
        public InvestInfoResponse InvestInfo(Guid managerId)
        {
            var manager = ManagerCore.Instance.GetManager(managerId);

            if (manager == null)
            {
                return(ResponseHelper.InvalidParameter <InvestInfoResponse>());
            }
            var investInfo = InvestManagerMgr.GetById(managerId);

            if (investInfo == null)
            {
                investInfo = InnerBuildEntity(managerId);
            }
            if (investInfo.TheMonthly && DateTime.Today > investInfo.ExpirationTime)
            {
                investInfo.TheMonthly = false;
            }
            string stepStatus    = investInfo.StepStatus;
            string newStepStatus = Rebuild(stepStatus, manager.Level);

            investInfo.StepStatus = newStepStatus;
            if (!InvestManagerMgr.Update(investInfo))
            {
                return(ResponseHelper.Create <InvestInfoResponse>(MessageCode.NbUpdateFail));
            }
            List <int>    restitution = CacheFactory.ActivityCache.BuildRestitution(stepStatus);
            PayUserEntity payUser     = PayUserMgr.GetById(manager.Account);

            return(BuildInvestInfoResponse(investInfo, restitution, newStepStatus, payUser, 0));
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="managerId"></param>
        /// <param name="index">0-6</param>
        /// <returns></returns>
        public InvestInfoResponse ReceiveBindPoint(Guid managerId, int index)
        {
            var manager = ManagerCore.Instance.GetManager(managerId);

            if (manager == null)
            {
                return(ResponseHelper.InvalidParameter <InvestInfoResponse>());
            }
            var investInfo = InvestManagerMgr.GetById(managerId);

            if (investInfo == null)
            {
                return(ResponseHelper.InvalidParameter <InvestInfoResponse>());
            }
            string stepStatus = investInfo.StepStatus;
            var    status     = BuildReceiveStatus(stepStatus);

            if (status[index] != "1")
            {
                return(ResponseHelper.InvalidParameter <InvestInfoResponse>());
            }
            List <int> restitution      = CacheFactory.ActivityCache.BuildRestitution(stepStatus);
            int        receiveBindPoint = restitution[index];

            restitution[index] = 0;
            string[] ss        = stepStatus.Split('|');
            string[] newStatus = new string[4];
            for (int i = 0; i < ss.Length; i++)
            {
                string[] st = ss[i].Split(',');
                for (int j = 0; j < st.Length; j++)
                {
                    if (st[index] == "1")
                    {
                        st[index] = "2";
                    }
                }
                newStatus[i] = ReBuildCurStepStatus(st);
            }
            var           newStepStatus = RebuildStepStatus(newStatus);
            PayUserEntity payUser       = PayCore.Instance.GetPayUser(managerId);

            payUser.BindPoint    += receiveBindPoint;
            investInfo.StepStatus = newStepStatus;
            var code = Save_TranReceiveBindPoint(payUser, investInfo);

            if (code != MessageCode.Success)
            {
                return(ResponseHelper.Create <InvestInfoResponse>(code));
            }
            //ChatHelper.SendBindPoint(manager.Idx, payUser.BindPoint);
            return(BuildInvestInfoResponse(investInfo, restitution, newStepStatus, payUser, 0));
        }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="managerId"></param>
        /// <param name="step">1-4</param>
        /// <returns></returns>
        public InvestInfoResponse InvestDeposit(Guid managerId, int step)
        {
            var manager = ManagerCore.Instance.GetManager(managerId);

            if (manager == null)
            {
                return(ResponseHelper.InvalidParameter <InvestInfoResponse>());
            }
            var investInfo = InvestManagerMgr.GetById(managerId);

            if (investInfo == null)
            {
                return(ResponseHelper.InvalidParameter <InvestInfoResponse>());
            }
            string stepStatus = investInfo.StepStatus;
            var    curStep    = GetCurStepStr(stepStatus, step);

            if (curStep[0].ToInt32() > 0)
            {
                return(ResponseHelper.Create <InvestInfoResponse>(MessageCode.InvestDeposited));
            }
            var           configList = CacheFactory.ActivityCache.GetInvestEntityList(step);
            int           needPoint  = configList[0].Point;
            PayUserEntity payUser    = PayCore.Instance.GetPayUser(managerId);

            if (payUser.TotalPoint < needPoint)
            {
                return(ResponseHelper.Create <InvestInfoResponse>(MessageCode.NbPointShortage));
            }
            for (int i = 0; i < configList.Count; i++)
            {
                if (manager.Level >= configList[i].Lv)
                {
                    curStep[i] = "1";
                }
            }
            var newStepStatus = RebuildStepStatus(stepStatus, curStep, step);

            investInfo.StepStatus = newStepStatus;
            investInfo.Deposit   += needPoint;

            var code = Save_TranInvestDeposit(payUser, investInfo, needPoint);

            if (code != MessageCode.Success)
            {
                return(ResponseHelper.Create <InvestInfoResponse>(code));
            }
            List <int> restitution = CacheFactory.ActivityCache.BuildRestitution(newStepStatus);

            //ChatHelper.SendUpdateManagerInfoPop(manager, true, payUser.TotalPoint);
            return(BuildInvestInfoResponse(investInfo, restitution, newStepStatus, payUser, needPoint));
        }
Esempio n. 4
0
        MessageCode Tran_ReceiveBindPoint(PayUserEntity payUser, InvestManagerEntity investInfo,
                                          DbTransaction transaction)
        {
            if (!InvestManagerMgr.Update(investInfo, transaction))
            {
                return(MessageCode.NbUpdateFail);
            }

            if (!PayUserMgr.Update(payUser, transaction))
            {
                return(MessageCode.NbUpdateFail);
            }
            return(MessageCode.Success);
        }
Esempio n. 5
0
        public InvestInfoResponse ReceiveBindPointPerDay(Guid managerId, bool once)
        {
            var manager = ManagerCore.Instance.GetManager(managerId);

            if (manager == null)
            {
                return(ResponseHelper.InvalidParameter <InvestInfoResponse>());
            }
            PayUserEntity payUser    = PayCore.Instance.GetPayUser(managerId);
            var           investInfo = InvestManagerMgr.GetById(managerId);

            if (investInfo == null)
            {
                return(ResponseHelper.Create <InvestInfoResponse>(MessageCode.InvalidArgs));
            }
            if (!investInfo.TheMonthly && DateTime.Today > investInfo.ExpirationTime)
            {
                return(ResponseHelper.Create <InvestInfoResponse>(MessageCode.InvalidArgs));
            }
            int totalCount = (investInfo.ExpirationTime - investInfo.MonthlyTime).Days;
            int oddCount   = (investInfo.ExpirationTime - DateTime.Today).Days;

            if (once && investInfo.Once && investInfo.DepositCount > 0)
            {
                var bindPoint = _investDeposit * investInfo.DepositCount;
                payUser.BindPoint      += bindPoint;
                investInfo.Once         = false;
                investInfo.DepositCount = 0;
            }
            else
            {
                if (investInfo.ReceivedCount > (totalCount - oddCount))
                {
                    return(ResponseHelper.Create <InvestInfoResponse>(MessageCode.InvestGetTomorrow));
                }
                payUser.BindPoint += 100;
                investInfo.ReceivedCount++;
            }

            var code = Save_TranReceiveBindPoint(payUser, investInfo);

            if (code != MessageCode.Success)
            {
                return(ResponseHelper.Create <InvestInfoResponse>(code));
            }
            List <int> restitution = CacheFactory.ActivityCache.BuildRestitution(investInfo.StepStatus);

            //ChatHelper.SendBindPoint(manager.Idx, payUser.BindPoint);
            return(BuildInvestInfoResponse(investInfo, restitution, investInfo.StepStatus, payUser, 0));
        }
Esempio n. 6
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);
        }
Esempio n. 7
0
        InvestManagerEntity InnerBuildEntity(Guid managerId)
        {
            InvestManagerEntity entity = new InvestManagerEntity();

            entity.ManagerId      = managerId;
            entity.Deposit        = 0;
            entity.StepStatus     = "0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0";
            entity.TheMonthly     = false;
            entity.MonthlyTime    = DateTime.Today;
            entity.ExpirationTime = DateTime.Today;
            entity.Once           = false;
            entity.ReceivedCount  = 0;
            entity.RowTime        = DateTime.Now;
            entity.DepositCount   = 0;
            InvestManagerMgr.Insert(entity);
            return(entity);
        }
Esempio n. 8
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));
        }