Exemple #1
0
        /// <summary>
        /// 邀请奖历 投资成功奖励
        /// </summary>
        /// <param name="dt"></param>
        protected internal void SendBonusForInviteAfterInvest(DataTable dt, string targetPlatform)
        //(int registerid, string invcode, int invcount, decimal investAmt, string userName, string borrowing_title, decimal bonusAmt)
        {
            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()); //投资人ID
            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 = 0;
            }
            string borrowing_title = dt.Rows[0]["borrowing_title"].ToString();
            string userName        = dt.Rows[0]["username"].ToString();
            string invcode         = dt.Rows[0]["invitationcode"].ToString();
            int    targetid        = int.Parse(dt.Rows[0]["targetid"].ToString());//标的ID
            //本次投标使用的奖励金额
            decimal bonusAmt           = decimal.Parse(dt.Rows[0]["bonusAmt"].ToString());
            B_bonus_account_water bbaw = new B_bonus_account_water();
            int invcount = B_usercenter.GetInvestCountByUserid(registerid);//投资次数

            string uid = registerid.ToString();

            LogInfo.WriteLog("投资人ID:" + registerid + "; /*邀请码*/:" + invcode);
            #region MyRegion  邀请奖历 投资成功奖励   暂不启用false  待重新梳理帐号fangjianmin
            if (invcode != null && invcode != "")// && false
            {
                DateTime dte     = DateTime.Now;
                string   codesql = "SELECT invcode,Invpeopleid,invpersonid,invtime from  hx_td_Userinvitation where invcode='" + invcode + "' and invpersonid=" + uid + " ";//查询本人是否已经被邀请注册过
                LogInfo.WriteLog("投资人ID:" + registerid + ";查询本人是否已经被邀请注册过:" + codesql);
                DataTable dtcode = DbHelperSQL.GET_DataTable_List(codesql);
                if (dtcode.Rows.Count > 0)
                {
                    int            uuid = int.Parse(dtcode.Rows[0]["Invpeopleid"].ToString()); //邀请用户id
                    B_member_table oy   = new B_member_table();
                    M_member_table py   = new M_member_table();
                    //获取 邀请用户身份渠道用户不执行
                    py = oy.GetModel(uuid);
                    if (py.useridentity != 4)
                    {
                        DateTime invtime = Convert.ToDateTime(dtcode.Rows[0]["invtime"].ToString()); //邀请时间

                        DateTime nowdate   = DateTime.Now;
                        DateTime startdate = new DateTime(2017, 1, 6, 0, 00, 00);
                        DateTime enddate   = new DateTime(2017, 3, 31, 23, 59, 59);
                        if ((nowdate > startdate && nowdate < enddate) && (invtime > startdate && invtime < enddate))
                        {
                            #region 1月6日活动,奖励邀请人首投满2000返现10元
                            if (!string.IsNullOrWhiteSpace(py.UsrCustId))
                            {
                                B_borrowing_target bbt = new B_borrowing_target();
                                M_borrowing_target mbt = new M_borrowing_target();
                                mbt = bbt.GetModel(targetid);
                                if (mbt.project_type_id != 6)//排除新手标
                                {
                                    string    log     = "用户" + registerid + "活动奖励邀请人首投满2000返现10元: ";
                                    decimal   amtc    = 0;
                                    DataTable dtstAmt = B_usercenter.GetInvestCountByUseridNew(registerid);
                                    if (dtstAmt.Rows.Count > 0)
                                    {
                                        log += "<br> 投资次数" + dtstAmt.Rows.Count + "次";
                                        if (dtstAmt.Rows.Count == 1)
                                        {
                                            amtc = decimal.Parse(dtstAmt.Rows[0]["InvCount_Amt"].ToString());
                                            log += "<br>投资金额" + amtc;
                                            if (amtc >= 2000)
                                            {
                                                hx_UserAct huact = InviteActCashNew(uuid, targetPlatform, amtc, 4, 1, 10, 5)[0];

                                                if (huact != null && huact.ActID != null)
                                                {
                                                    log += "<br>奖励发放成功";
                                                    #region MyRegion  奖励流水
                                                    string awardDescription = string.Format("邀请好友首投满2000成功,获得{0}{1}", Convert.ToDouble(huact.Amt.ToString()), GetBunusDescription(huact.RewTypeID));
                                                    AddBonusAccoutWater(huact.UserAct, uuid, decimal.Parse(huact.Amt.ToString()), awardDescription, registerid); //registerid 被邀请人 uuid邀请人
                                                    #endregion MyRegion  奖励流水

                                                    #region MyRegion  系统消息
                                                    string MContext = string.Format("尊敬的用户:邀请好友{0}首投{1}金额为{2},获得{3}{4}如有问题可咨询创利投的客服!", userName, borrowing_title, investAmt, decimal.Parse(huact.Amt.ToString()), GetBunusDescription(huact.RewTypeID));
                                                    AddSytemMessage(uuid, "邀请好友首投满2000成功奖励", MContext);
                                                    #endregion

                                                    #region 现金流水信息
                                                    if (huact.RewTypeID == 1)
                                                    {
                                                        B_usercenter o  = new B_usercenter();
                                                        decimal      di = o.GetUsridAvailable_balance(uuid);
                                                        //di = di + decimal.Parse(huact.Amt.ToString());
                                                        StringBuilder strSql = new StringBuilder();
                                                        strSql.Append("insert into hx_Capital_account_water(");
                                                        strSql.Append("membertable_registerid,income,expenditure,time_of_occurrence,account_balance,types_Finance,createtime,keyid,remarks)");
                                                        strSql.Append(" values (");
                                                        strSql.Append("" + uuid + "," + decimal.Parse(huact.Amt.ToString()) + ",0,'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'," + di + "," + (int)Enum.Parse(typeof(EnumTypesFinance), EnumTypesFinance.邀请奖励.ToString()) + ",'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',0,'" + awardDescription + "')");
                                                        DbHelperSQL.RunSql(strSql.ToString());
                                                        strSql.Clear();
                                                    }
                                                    #endregion
                                                }
                                            }
                                        }
                                    }
                                    LogInfo.WriteLog(log);
                                }
                            }
                            #endregion
                            #region 受邀好友首次成功投资给予活动奖励   常规邀请
                            //获取标的期限
                            life_of_loan = int.Parse(dt.Rows[0]["life_of_loan"].ToString());
                            unit_day     = int.Parse(dt.Rows[0]["unit_day"].ToString());
                            int lol = 0;
                            if (unit_day == 1)
                            {
                                lol = life_of_loan;
                            }
                            #region 邀请好友投资成功返现(奖励邀请人)
                            if (!string.IsNullOrWhiteSpace(py.UsrCustId))
                            {
                                hx_UserAct hut = InviteActBonus(uuid, targetPlatform, int.Parse(dtcode.Rows[0]["invpersonid"].ToString()), investAmt, 1, 4, 1, 0, 5, lol, "邀请好友投资成功返现")[0];//
                                if (hut != null && hut.ActID != null)
                                {
                                    #region MyRegion  奖励流水
                                    string awardDescription = string.Format("邀请好友投资成功,获得{0}{1}", Convert.ToDouble(hut.Amt.ToString()), GetBunusDescription(hut.RewTypeID));
                                    AddBonusAccoutWater(hut.UserAct, uuid, decimal.Parse(hut.Amt.ToString()), awardDescription, registerid); //registerid 被邀请人 uuid邀请人
                                    #endregion MyRegion  奖励流水

                                    #region MyRegion  系统消息
                                    string MContext = string.Format("尊敬的用户:邀请好友{0}投资{1}金额为{2},获得{3}{4}如有问题可咨询创利投的客服!", userName, borrowing_title, investAmt, hut.Amt.ToString(), GetBunusDescription(hut.RewTypeID));
                                    AddSytemMessage(uuid, "邀请好友投资成功奖励", MContext);
                                    #endregion

                                    #region 现金流水信息
                                    if (hut.RewTypeID == 1)
                                    {
                                        B_usercenter o  = new B_usercenter();
                                        decimal      di = o.GetUsridAvailable_balance(uuid);
                                        //di = di + decimal.Parse(hut.Amt.ToString());
                                        StringBuilder strSql = new StringBuilder();
                                        strSql.Append("insert into hx_Capital_account_water(");
                                        strSql.Append("membertable_registerid,income,expenditure,time_of_occurrence,account_balance,types_Finance,createtime,keyid,remarks)");
                                        strSql.Append(" values (");
                                        strSql.Append("" + uuid + "," + decimal.Parse(hut.Amt.ToString()) + ",0,'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'," + di + "," + (int)Enum.Parse(typeof(EnumTypesFinance), EnumTypesFinance.邀请奖励.ToString()) + ",'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',0,'" + awardDescription + "')");
                                        DbHelperSQL.RunSql(strSql.ToString());
                                        strSql.Clear();
                                    }
                                    #endregion
                                }
                            }
                            #endregion
                            #region 被邀请投资成功返现(奖励被邀请人)
                            int        byquuid = int.Parse(dtcode.Rows[0]["invpersonid"].ToString());
                            hx_UserAct byhut   = InviteActBonus(byquuid, targetPlatform, 0, investAmt, 1, 4, 1, 0, 5, lol, "被邀请投资返现")[0];//
                            if (byhut != null && byhut.ActID != null)
                            {
                                #region MyRegion  奖励流水
                                string awardDescription = string.Format("被邀请投资成功,获得{0}{1}", Convert.ToDouble(byhut.Amt.ToString()), GetBunusDescription(byhut.RewTypeID));
                                AddBonusAccoutWater(byhut.UserAct, byquuid, decimal.Parse(byhut.Amt.ToString()), awardDescription, registerid); //registerid 被邀请人 uuid邀请人
                                #endregion MyRegion  奖励流水

                                #region MyRegion  系统消息
                                string MContext = string.Format("尊敬的用户:被邀请投资{0}金额为{1},获得{2}{3}如有问题可咨询创利投的客服!", borrowing_title, investAmt, byhut.Amt.ToString(), GetBunusDescription(byhut.RewTypeID));
                                AddSytemMessage(byquuid, "被邀请投资成功奖励", MContext);
                                #endregion

                                #region 现金流水信息
                                if (byhut.RewTypeID == 1)
                                {
                                    B_usercenter o  = new B_usercenter();
                                    decimal      di = o.GetUsridAvailable_balance(byquuid);
                                    //di = di + decimal.Parse(byhut.Amt.ToString());
                                    StringBuilder strSql = new StringBuilder();
                                    strSql.Append("insert into hx_Capital_account_water(");
                                    strSql.Append("membertable_registerid,income,expenditure,time_of_occurrence,account_balance,types_Finance,createtime,keyid,remarks)");
                                    strSql.Append(" values (");
                                    strSql.Append("" + byquuid + "," + decimal.Parse(byhut.Amt.ToString()) + ",0,'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'," + di + "," + (int)Enum.Parse(typeof(EnumTypesFinance), EnumTypesFinance.邀请奖励.ToString()) + ",'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',0,'" + awardDescription + "')");
                                    DbHelperSQL.RunSql(strSql.ToString());
                                    strSql.Clear();
                                }
                                #endregion
                            }
                            #endregion
                            #endregion
                        }



                        #region 这里现金返现  ??? 投资金额为-1 作了单独处理。注册?? RewTypeID-1 ???
                        //hx_UserAct ua = InviteActBonus(uuid, int.Parse(dtcode.Rows[0]["invpersonid"].ToString()), -1M, 1, 4, 1, 0, 5)[0];//???
                        #endregion
                        //}
                        //else if (invcount > 1)
                        //{
                        //    #region 受邀用户续投奖励 邀请活动正常续投
                        //    int biyaoUsrid = int.Parse(dtcode.Rows[0]["invpersonid"].ToString());
                        //    decimal totAmt = B_usercenter.GetInviUserTotalAmt(uuid, biyaoUsrid);//????这里需要取出受邀用户奖总数
                        //    // hx_UserAct hut = aci.InviteActCash(uuid, biyaoUsrid, decimal.Parse(p.TransAmt), 4, 2, 1, totAmt, 5);
                        //    hx_UserAct hut = InviteActBonus(uuid, int.Parse(dtcode.Rows[0]["invpersonid"].ToString()), investAmt - bonusAmt, 1, 4, 1, totAmt, 5)[0];//????
                        //    if (hut != null && hut.ActID != null)
                        //    {
                        //        #region MyRegion  奖励流水
                        //        string awardDescription = string.Format("邀请好友续投成功获得{0}{1}", hut.Amt.ToString(), GetBunusDescription(hut.RewTypeID));
                        //        AddBonusAccoutWater(hut.UserAct, uuid, decimal.Parse(hut.Amt.ToString()), awardDescription, registerid); //registerid 被邀请人 uuid邀请人
                        //        #endregion MyRegion  奖励流水

                        //        #region MyRegion  系统消息
                        //        string MContext = string.Format("尊敬的用户:邀请好友续投{1}金额为{2},获得{3}{4}如有问题可咨询创利投的客服!", userName, borrowing_title, investAmt, hut.Amt.ToString(), GetBunusDescription(hut.RewTypeID));
                        //        AddSytemMessage(uuid, "邀请好友续投奖励", MContext);
                        //        #endregion

                        //        #region 现金奖励 资金流水信息
                        //        if (hut.RewTypeID == 1)
                        //        {
                        //            B_usercenter o = new B_usercenter();
                        //            decimal di = o.GetUsridAvailable_balance(uuid);
                        //            // di = di + decimal.Parse(hut.Amt.ToString());
                        //            StringBuilder strSql = new StringBuilder();
                        //            strSql.Append("insert into hx_Capital_account_water(");
                        //            strSql.Append("membertable_registerid,income,expenditure,time_of_occurrence,account_balance,types_Finance,createtime,keyid,remarks)");
                        //            strSql.Append(" values (");
                        //            strSql.Append("" + uuid + "," + decimal.Parse(hut.Amt.ToString()) + ",0,'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'," + di + "," + (int)Enum.Parse(typeof(EnumTypesFinance), EnumTypesFinance.邀请奖励.ToString()) + ",'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',0,'" + awardDescription + "')");
                        //            LogInfo.WriteLog("续投奖励流水语句:" + strSql.ToString());
                        //            DbHelperSQL.RunSql(strSql.ToString());
                        //            strSql.Clear();
                        //        }
                        //        #endregion
                        //    }
                        //    #endregion
                        //}

                        /*
                         *  DbHelperSQL.RunSql(" update hx_td_Userinvitation  set InvitesStates=1  where invcode='" + invcode + "' and invpersonid=" + uid + " and  InvitesStates=2 ");
                         *  LogInfo.WriteLog(" 后台更新数据邀请状态 update hx_td_Userinvitation  set InvitesStates=1  where invcode='" + invcode + "' and invpersonid=" + uid + " and  InvitesStates=2 ");
                         */
                    }
                }
            }
            #endregion
        }