Exemplo n.º 1
0
        //DataTable dt 投资记录视图 V_hx_Bid_records_borrowing_target
        /// <summary>
        /// 投资后按照常规活动进行奖励发放(常规投资、邀请奖励)
        /// </summary>
        /// <param name="dt"></param>
        protected internal void SendBonusAfterInvest(DataTable dt, string targetPlatform)
        {
            if (dt.Rows.Count <= 0)
            {
                return;
            }
            //投资金额
            decimal investAmt  = decimal.Parse(dt.Rows[0]["investment_amount"].ToString());
            int     registerid = int.Parse(dt.Rows[0]["investor_registerid"].ToString());
            string  targetid   = dt.Rows[0]["targetid"].ToString();
            //string OrdId = dt.Rows[0]["OrdId"].ToString();
            int bid_records_id = int.Parse(dt.Rows[0]["bid_records_id"].ToString());
            int life_of_loan   = int.Parse(dt.Rows[0]["life_of_loan"].ToString());
            int unit_day       = int.Parse(dt.Rows[0]["unit_day"].ToString());

            if (unit_day == 1)
            {
                life_of_loan = life_of_loan >= 6 ? 6 : (life_of_loan < 3 ? 1 : 3);
            }
            if (unit_day == 3)
            {
                life_of_loan = (life_of_loan / 30) >= 6 ? 6 : ((life_of_loan / 30) < 3 ? ((life_of_loan / 30) >= 1 ? 1 : -1) : 3);
            }
            string borrowing_title = dt.Rows[0]["borrowing_title"].ToString();
            string userName        = dt.Rows[0]["username"].ToString();
            //string mobile = dt.Rows[0]["mobile"].ToString();
            string invcode = dt.Rows[0]["invitationcode"].ToString();
            //本次投标使用的奖励金额
            decimal bonusAmt = decimal.Parse(dt.Rows[0]["bonusAmt"].ToString());
            //项目总借款金额
            decimal borrowing_balance = decimal.Parse(dt.Rows[0]["borrowing_balance"].ToString());//??

            LogInfo.WriteLog(" /*此处加入活动*/:" + targetid + ";投资人:" + registerid);
            B_bonus_account_water bbaw = new B_bonus_account_water();
            /*此处加入活动*/
            int invcount = B_usercenter.GetInvestCountByUserid(registerid);//投资次数

            //ActFacade act = new ActFacade();
            #region 活动奖励
            if (invcount == 1)
            {
                #region 首次投资活动奖励
                List <hx_UserAct> hut = GeneralInvestActBonus(registerid, targetPlatform, investAmt - bonusAmt, bid_records_id, 1, life_of_loan);
                if (hut.Count > 0)//合并到奖励中
                {
                    foreach (hx_UserAct item in hut)
                    {
                        if (item.RewTypeID > 1) //现金转账时做过处理,这里无需再处理
                        {
                            #region MyRegion  记录奖励流水表
                            string awardDescription = string.Format("首次投资成功获得{0}{1}", item.Amt.ToString(), GetBunusDescription(item.RewTypeID));
                            AddBonusAccoutWater(item.UserAct, registerid, decimal.Parse(item.Amt.ToString()), awardDescription);
                            #endregion

                            #region MyRegion  发送系统消息
                            string MContext = string.Format("首次投资{0}金额为{1},获得{2}{3}如有问题可咨询创利投的客服!", borrowing_title, investAmt, item.Amt.ToString(), GetBunusDescription(item.RewTypeID));
                            AddSytemMessage(registerid, "首次投资成功", MContext);
                            #endregion
                        }
                    }
                }
                #endregion
            }
            else if (invcount >= 2)
            {
                #region 续投活动奖励
                List <hx_UserAct> hutw = GeneralInvestActBonus(registerid, targetPlatform, investAmt - bonusAmt, bid_records_id, 6, life_of_loan);
                if (hutw.Count > 0)
                {
                    foreach (hx_UserAct item in hutw)
                    {
                        if (item.RewTypeID > 1) //现金转账时做过处理,这里无需再处理
                        {
                            #region MyRegion  奖励流水
                            string awardDescription = string.Format("续投成功获得{0}{1}", item.Amt.ToString(), GetBunusDescription(item.RewTypeID));
                            AddBonusAccoutWater(item.UserAct, registerid, decimal.Parse(item.Amt.ToString()), awardDescription);
                            #endregion MyRegion  奖励流水

                            #region MyRegion  系统消息
                            string MContext = string.Format("续投{0}金额为{1},获得{2}{3}如有问题可咨询创利投的客服!", borrowing_title, investAmt, item.Amt.ToString(), GetBunusDescription(item.RewTypeID));
                            AddSytemMessage(registerid, "续投成功", MContext);
                            #endregion
                        }
                    }
                }
                #endregion

                #region 特殊复投返现活动奖励--回款金额复投
                hutw = GeneralInvestActBonus(registerid, targetPlatform, investAmt - bonusAmt, bid_records_id, 7, life_of_loan);
                if (hutw.Count > 0)
                {
                    foreach (hx_UserAct item in hutw)
                    {
                        if (item.RewTypeID > 1) //现金转账时做过处理,这里无需再处理
                        {
                            #region MyRegion  奖励流水
                            string awardDescription = string.Format("回款复投成功获得{0}{1}", item.Amt.ToString(), GetBunusDescription(item.RewTypeID));
                            AddBonusAccoutWater(item.UserAct, registerid, decimal.Parse(item.Amt.ToString()), awardDescription);
                            #endregion MyRegion  奖励流水

                            #region MyRegion  系统消息
                            string MContext = string.Format("回款复投{0}金额为{1},获得{2}{3}如有问题可咨询创利投的客服!", borrowing_title, investAmt, item.Amt.ToString(), GetBunusDescription(item.RewTypeID));
                            AddSytemMessage(registerid, "回款复投成功", MContext);
                            #endregion
                        }
                    }
                }
                #endregion
            }


            #region 所有用户
            //所有用户
            List <hx_UserAct> hutwc = GeneralInvestActBonus(registerid, targetPlatform, investAmt - bonusAmt, bid_records_id, 5, life_of_loan);

            if (hutwc.Count > 0)
            {
                foreach (hx_UserAct item in hutwc)
                {
                    if (item.RewTypeID > 1) //现金转账时做过处理,这里无需再处理
                    {
                        #region MyRegion  奖励流水
                        string awardDescription = string.Format("投资成功获得{0}{1}", item.Amt.ToString(), GetBunusDescription(item.RewTypeID));
                        AddBonusAccoutWater(item.UserAct, registerid, decimal.Parse(item.Amt.ToString()), awardDescription);
                        #endregion MyRegion  奖励流水

                        #region MyRegion  系统消息
                        string MContext = string.Format("投资{0}金额为{1},获得{2}{3}如有问题可咨询创利投的客服!", borrowing_title, investAmt, item.Amt.ToString(), GetBunusDescription(item.RewTypeID));
                        AddSytemMessage(registerid, "投资成功", MContext);
                        #endregion
                    }
                }
            }
            #endregion

            #region 投标最大的用户  暂时注释false 有bug,投标结束后才能判断哪个位最大,而不是每次都判断????
            DataTable dmax = B_usercenter.Topinvestor(int.Parse(targetid));
            if (dmax.Rows.Count > 0 && false)
            {
                decimal amtc = decimal.Parse(dmax.Rows[0]["InvCount_Amt"].ToString());
                if (borrowing_balance == amtc)//???判断什么 一人满标?
                {
                    List <hx_UserAct> invmax = GeneralInvestActBonus(int.Parse(dmax.Rows[0]["investor_registerid"].ToString()), targetPlatform, decimal.Parse(dmax.Rows[0]["maxamt"].ToString()), bid_records_id, 4, life_of_loan);
                    if (invmax.Count > 0)
                    {
                        foreach (hx_UserAct item in invmax)
                        {
                            if (item.RewTypeID > 1) //现金转账时做过处理,这里无需再处理
                            {
                                #region MyRegion  奖励流水
                                string awardDescription = string.Format("投标最大的用户获得{0}{1}", item.Amt.ToString(), GetBunusDescription(item.RewTypeID));
                                AddBonusAccoutWater(item.UserAct, registerid, decimal.Parse(item.Amt.ToString()), awardDescription);
                                #endregion MyRegion  奖励流水

                                #region MyRegion  系统消息
                                string MContext = string.Format("投标最大的用户,投资{0}金额为{1},获得{2}{3}如有问题可咨询创利投的客服!", borrowing_title, investAmt, item.Amt.ToString(), GetBunusDescription(item.RewTypeID));
                                AddSytemMessage(registerid, "投标最大的用户奖励", MContext);
                                #endregion
                            }
                        }
                    }
                }
            }
            #endregion

            #region 每标首投用户
            if (B_usercenter.TopNum(targetid) == 1)
            {
                List <hx_UserAct> invFirst = GeneralInvestActBonus(registerid, targetPlatform, investAmt - bonusAmt, bid_records_id, 3, life_of_loan);
                if (invFirst.Count > 0)
                {
                    foreach (hx_UserAct item in invFirst)
                    {
                        if (item.RewTypeID > 1) //现金转账时做过处理,这里无需再处理
                        {
                            #region MyRegion  奖励流水
                            string awardDescription = string.Format("每标首投用户获得{0}{1}", item.Amt.ToString(), GetBunusDescription(item.RewTypeID));
                            AddBonusAccoutWater(item.UserAct, registerid, decimal.Parse(item.Amt.ToString()), awardDescription);
                            #endregion MyRegion  奖励流水

                            #region MyRegion  系统消息
                            string MContext = string.Format("每标首投用户,投资{0}金额为{1},获得{2}{3}如有问题可咨询创利投的客服!", borrowing_title, investAmt, item.Amt.ToString(), GetBunusDescription(item.RewTypeID));
                            AddSytemMessage(registerid, "每标首投用户奖励", MContext);
                            #endregion
                        }
                    }
                }
            }
            #endregion

            #endregion
        }