Ejemplo n.º 1
0
        /// <summary>
        /// 判断用户是否为渠道用户
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="channelType">渠道类型</param>
        /// <returns></returns>
        public static bool CheckIsChannel(int userID, ref string channelType)
        {
            //chuangtouEntities ef = new chuangtouEntities();
            bool           t = true;
            B_member_table b_member_table = new B_member_table();
            M_member_table investor       = new M_member_table();

            investor = b_member_table.GetModel(userID);
            if (investor == null)
            {
                return(false);
            }
            string codesql = "SELECT invcode,Invpeopleid,invpersonid,invtime from  hx_td_Userinvitation where  invpersonid=" + investor.registerid + " ";//查询本人是否已经被邀请注册过

            DataTable dtcode = DbHelperSQL.GET_DataTable_List(codesql);
            //if (dtcode.Rows.Count > 0 || (investor != null && !string.IsNullOrWhiteSpace(investor.channel_invitedcode)))
            //{
            int uuid = dtcode.Rows.Count > 0 ? int.Parse(dtcode.Rows[0]["Invpeopleid"].ToString()) : 0; //邀请用户id

            //用户等级为渠道 不参与活动
            if (investor != null && investor.useridentity == 4)
            {
                return(t);
            }
            int investCount = B_usercenter.GetInvestCountByUserid(investor.registerid);

            //老渠道机制判断 (推荐人等级为4渠道用户,投资次数大于等于1次 时可参与活动
            if (uuid != 0)
            {
                M_member_table py = new M_member_table();
                B_member_table oy = new B_member_table();
                py = oy.GetModel(uuid);//推荐人
                if ((py != null && py.useridentity == 4))
                {
                    return(t);
                }
            }

            if (string.IsNullOrWhiteSpace(investor.channel_invitedcode))
            {
                return(false);
            }
            string     cacheName     = "hx_Channel_" + investor.channel_invitedcode;
            hx_Channel channelEnitty = (hx_Channel)Utils.GetThirdCacheObject(cacheName);

            if (channelEnitty == null)
            {
                channelEnitty = ef.hx_Channel.AsNoTracking().Where(p => p.Invitedcode == investor.channel_invitedcode).FirstOrDefault();
            }
            if (channelEnitty != null)
            {
                channelType = channelEnitty.type;
                Utils.SetThirdCacheName(cacheName, channelEnitty, 5);
            }
            return(channelEnitty != null);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 判断当前用户是否可以参加活动
        /// </summary>
        /// <param name="userID">用户ID</param>
        /// <returns></returns>
        public static bool CheckChannel(int userID)
        {
            bool           t = false;
            B_member_table b_member_table = new B_member_table();
            M_member_table investor       = new M_member_table();

            investor = b_member_table.GetModel(userID);
            if (investor == null)
            {
                return(false);
            }
            string codesql = "SELECT invcode,Invpeopleid,invpersonid,invtime from  hx_td_Userinvitation where  invpersonid=" + investor.registerid + " ";//查询本人是否已经被邀请注册过

            DataTable dtcode = DbHelperSQL.GET_DataTable_List(codesql);
            //if (dtcode.Rows.Count > 0 || (investor != null && !string.IsNullOrWhiteSpace(investor.channel_invitedcode)))
            //{
            int uuid = dtcode.Rows.Count > 0 ? int.Parse(dtcode.Rows[0]["Invpeopleid"].ToString()) : 0; //邀请用户id

            //用户等级为渠道 不参与活动
            if (investor != null && investor.useridentity == 4)
            {
                return(t);
            }
            int investCount = B_usercenter.GetInvestCountByUserid(investor.registerid);

            //老渠道机制判断 (推荐人等级为4渠道用户,投资次数大于等于1次 时可参与活动
            if (uuid != 0)
            {
                M_member_table py = new M_member_table();
                B_member_table oy = new B_member_table();
                py = oy.GetModel(uuid);//推荐人
                if ((py != null && py.useridentity == 4) && investCount <= 1)
                {
                    return(t);
                }
            }

            //新渠道机制判断
            using (ChannelAct channelAct = new ChannelAct())
            {
                //按照渠道类型和投资次数判断是否参与此次活动
                if (!string.IsNullOrWhiteSpace(investor.channel_invitedcode) && !channelAct.IsParticipateActivity(investor.channel_invitedcode, investCount))
                {
                    return(t);
                }
            }
            return(true);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 无效投资标的处理
        /// </summary>
        /// <param name="investor_registerid">投资用户id</param>
        /// <param name="bid_records_id">投资记录id</param>
        /// <param name="OrdId">投资订单号</param>
        /// <param name="OrdDate">投资订单日期</param>
        /// <param name="UsrCustId">客户号</param>
        /// <param name="FreezeOrdId">冻结订单号</param>
        /// <param name="TransAmt">交易金额</param>
        /// <param name="FreezeTrxId">冻结唯一标识</param>
        /// <param name="MerPriv">优惠券字符串</param>
        /// <param name="QueryTransType">查询类型   LOANS:放款交易查询 REPAYMENT:还款交易查询 TENDER:投标交易查询 CASH:取现交易查询     FREEZE:冻结解冻交易查询     </param>
        public void setRecords_Lost(string investor_registerid, string bid_records_id, string OrdId, string OrdDate, string UsrCustId, string FreezeOrdId, string TransAmt, string FreezeTrxId, string MerPriv, string QueryTransType = "TENDER")
        {
            TransStat ts = new TransStat();
            bool      d  = ts.checktrans(OrdId, OrdDate, QueryTransType);

            if (d == false)
            {
                string sql = "update hx_UserAct set UseState=0,AmtProid=0 where UseState=3 and AmtProid=" + bid_records_id + "and registerid=" + investor_registerid;
                DbHelperSQL.RunSql(sql);
                sql = "delete hx_Bid_records where OrdId ='" + OrdId + "' and ordstate=0 and bid_records_id=" + bid_records_id;
                DbHelperSQL.RunSql(sql);
            }
            else
            {//TODO 此处有bug,自动查询的更新冻结表时缺少 FreezeTrxId 值,放款时没有该值会报错。 考虑注释该逻辑,等待汇付异步回调????
                B_usercenter BUC = new B_usercenter();
                //取得投标记录使用的优惠券
                string AmtProid = BUC.GetBid_AmtProid(int.Parse(bid_records_id));
                int    de       = BUC.ReInvest_success(UsrCustId, FreezeOrdId, TransAmt, FreezeTrxId, OrdId, AmtProid);
                if (de > 0)
                {
                    string    sql = "select targetid,bid_records_id, borrowing_title,investor_registerid ,username,mobile,invitationcode,investment_amount,life_of_loan,unit_day,borrowing_balance,bonusAmt  from  V_hx_Bid_records_borrowing_target where OrdId='" + OrdId + "'";
                    DataTable dt  = DbHelperSQL.GET_DataTable_List(sql);
                    if (dt.Rows.Count > 0)
                    {
                        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();

                        #region 待提取为公共方法
                        #region MyRegion  系统消息
                        DateTime            dti = DateTime.Now;
                        M_td_System_message pm  = new M_td_System_message();
                        pm.MReg     = registerid;
                        pm.Mstate   = 0;
                        pm.MTitle   = "投资成功";
                        pm.MContext = "尊敬的用户" + dt.Rows[0]["username"].ToString() + ":您好!恭喜您成功投资了项目【" + dt.Rows[0]["borrowing_title"].ToString() + "】,投资金额是:" + investAmt + "。如有问题可咨询创利投的客服!谢谢!";
                        pm.PubTime  = dti;
                        pm.Mtype    = 1;
                        B_usercenter.AddMessage(pm);
                        #endregion

                        #region MyRegion                                        //短信通知
                        string        contxt = Utils.GetMSMEmailContext(15, 1); // 获取注册成功邮件内容
                        StringBuilder sbsms  = new StringBuilder(contxt);
                        sbsms = sbsms.Replace("#USERANEM#", dt.Rows[0]["username"].ToString());
                        sbsms = sbsms.Replace("#PID#", targetid);
                        sbsms = sbsms.Replace("#MONEY#", investAmt.ToString());
                        string          mobile  = dt.Rows[0]["mobile"].ToString();
                        M_td_SMS_record psms    = new M_td_SMS_record();
                        B_td_SMS_record osms    = new B_td_SMS_record();
                        int             smstype = (int)Enum.Parse(typeof(EnumSMSType), EnumSMSType.投资成功.ToString());
                        psms.phone_number = mobile;
                        psms.sendtime     = DateTime.Now;
                        psms.senduserid   = registerid;
                        psms.smstype      = smstype;
                        psms.smscontext   = sbsms.ToString();
                        psms.orderid      = SendSMS.Send_SMS(mobile, sbsms.ToString());
                        psms.vcode        = "";
                        osms.Add(psms);
                        #endregion

                        #region 远程调用生成合同??? 稍后替换为本地方法调用  微信端可远程调用
                        string postString = "action=MUserPDF&data=" + targetid.ToString() + "&uc=" + registerid.ToString() + "&OrdId=" + OrdId;
                        string sr         = Utils.PostWebRequest(Utils.GetRemote_url("pdf/index"), postString, Encoding.UTF8);
                        #endregion

                        #region  道合作 第一投标调用接口???
                        B_member_table bmt = new B_member_table();
                        M_member_table mmt = new M_member_table();
                        mmt = bmt.GetModel(registerid);
                        if (mmt.Tid != null && mmt.Channelsource == 1)
                        {
                            if (B_usercenter.GetInvestCountByUserid(mmt.registerid) == 1)
                            {
                                string ret3 = Utils.GetCoopAPI(mmt.Tid, investAmt.ToString("0.00"), 2);
                                LogInfo.WriteLog("前台渠道合作第一次返回结果:" + ret3 + "  用户id:" + mmt.registerid + " 订单id " + OrdId);
                            }
                        }
                        #endregion
                        #endregion 待提取为公共方法

                        //发放奖励
                        ActFacade act = new ActFacade();
                        act.SendBonusAfterInvest(dt, EnumCommon.E_hx_ActivityTable.E_ActTargetPlatform.web);
                    }
                }
            }
        }
Ejemplo n.º 4
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
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 投资成功,汇付后台主动通知
        /// </summary>
        /// <returns></returns>
        public ActionResult BG_investment_success()
        {
            int                id  = 0;
            string             srt = "";
            ReInitiativeTender p   = new ReInitiativeTender();

            id = DNTRequest.GetInt("id", 0);
            string log = "";

            log          += "主动通知后台有响应成功!接收到的项目id=" + id;
            p.CmdId       = DNTRequest.GetString("CmdId");
            p.RespCode    = DNTRequest.GetString("RespCode");
            p.RespDesc    = HttpUtility.UrlDecode(DNTRequest.GetString("RespDesc"));
            p.MerCustId   = DNTRequest.GetString("MerCustId");
            p.OrdId       = DNTRequest.GetString("OrdId");
            p.OrdDate     = DNTRequest.GetString("OrdDate");
            p.TransAmt    = DNTRequest.GetString("TransAmt");
            p.UsrCustId   = DNTRequest.GetString("UsrCustId");
            p.TrxId       = DNTRequest.GetString("TrxId");
            p.IsFreeze    = DNTRequest.GetString("IsFreeze");
            p.FreezeOrdId = DNTRequest.GetString("FreezeOrdId");
            p.FreezeTrxId = DNTRequest.GetString("FreezeTrxId");
            p.RetUrl      = HttpUtility.UrlDecode(DNTRequest.GetString("RetUrl"));
            p.BgRetUrl    = HttpUtility.UrlDecode(DNTRequest.GetString("BgRetUrl"));
            string merp = DNTRequest.GetString("MerPriv");

            if (merp.Length > 0)
            {
                p.MerPriv = HttpUtility.UrlDecode(merp);
            }
            else
            {
                p.MerPriv = merp;
            }

            p.RespExt  = HttpUtility.UrlDecode(DNTRequest.GetString("RespExt"));
            p.ChkValue = DNTRequest.GetString("ChkValue");
            StringBuilder chkVal = new StringBuilder();

            chkVal.Append(p.CmdId);
            chkVal.Append(p.RespCode);
            chkVal.Append(p.MerCustId);
            chkVal.Append(p.OrdId);
            chkVal.Append(p.OrdDate);
            chkVal.Append(p.TransAmt);
            chkVal.Append(p.UsrCustId);
            chkVal.Append(p.TrxId);
            chkVal.Append(p.IsFreeze);
            chkVal.Append(p.FreezeOrdId);
            chkVal.Append(p.FreezeTrxId);
            chkVal.Append(p.RetUrl);
            chkVal.Append(p.BgRetUrl);
            chkVal.Append(p.MerPriv);
            chkVal.Append(p.RespExt);
            string chkv = chkVal.ToString();

            //私钥文件的位置(这里是放在了站点的根目录下)
            string merKeyFile = AppDomain.CurrentDomain.BaseDirectory + Utils.GetPgPubk();
            int    ret        = DllInterop.VeriSignMsg(merKeyFile, chkv, chkv.Length, p.ChkValue);

            log += "<br>投标后台主动投标返回报文:" + FastJSON.toJOSN(p);
            string sql = "";

            int invcount = 0; //记录用户是否是首次投资

            #region 验签
            if (ret == 0)
            {
                if (p.RespCode == "000" || p.RespCode == "322" || p.RespCode == "534" || p.RespCode == "360" || p.RespCode == "099")
                {
                    string cachename = p.OrdId + "InvestWeb" + p.UsrCustId;

                    if (Utils.GeTThirdCache(cachename) == 0)
                    {
                        Utils.SetThirdCache(cachename);
                        if (p.FreezeTrxId != "")
                        {
                            sql = "select ordstate  from hx_Bid_records  where ordstate =0 and  OrdId='" + p.OrdId + "'";
                            DataTable dts = DbHelperSQL.GET_DataTable_List(sql);

                            if (dts.Rows.Count > 0)
                            {
                                //同步处理用户金额
                                B_usercenter BUC = new B_usercenter();
                                int          d   = BUC.ReInvest_success(p.UsrCustId, p.FreezeOrdId, p.TransAmt, p.FreezeTrxId, p.OrdId, p.MerPriv);
                                log += "<br>后台投标:id" + id.ToString() + "返回唯一冻结标识:" + p.FreezeTrxId + "事务执行结果:" + d.ToString();
                                if (d > 0)
                                {
                                    sql = "select targetid,bid_records_id, borrowing_title,investor_registerid ,username,mobile,invitationcode,investment_amount,life_of_loan,unit_day,borrowing_balance,bonusAmt from  V_hx_Bid_records_borrowing_target where OrdId='" + p.OrdId + "'";
                                    DataTable dt = DbHelperSQL.GET_DataTable_List(sql);
                                    if (dt.Rows.Count > 0)
                                    {
                                        decimal investAmt  = decimal.Parse(dt.Rows[0]["investment_amount"].ToString());
                                        string  OrdId      = p.OrdId;
                                        int     registerid = int.Parse(dt.Rows[0]["investor_registerid"].ToString());
                                        ViewBag.userid = registerid;
                                        string targetid = dt.Rows[0]["targetid"].ToString();

                                        #region 待提取为公共方法
                                        #region MyRegion  系统消息
                                        DateTime            dti = DateTime.Now;
                                        M_td_System_message pm  = new M_td_System_message();
                                        pm.MReg     = registerid;
                                        pm.Mstate   = 0;
                                        pm.MTitle   = "投资成功";
                                        pm.MContext = "尊敬的用户" + dt.Rows[0]["username"].ToString() + ":您好!恭喜您成功投资了项目【" + dt.Rows[0]["borrowing_title"].ToString() + "】,投资金额是:" + investAmt + "。如有问题可咨询创利投的客服!谢谢!";
                                        pm.PubTime  = dti;
                                        pm.Mtype    = 1;
                                        B_usercenter.AddMessage(pm);
                                        #endregion

                                        #region MyRegion                                        //短信通知
                                        string        contxt = Utils.GetMSMEmailContext(15, 1); // 获取注册成功邮件内容
                                        StringBuilder sbsms  = new StringBuilder(contxt);
                                        sbsms = sbsms.Replace("#USERANEM#", dt.Rows[0]["username"].ToString());
                                        sbsms = sbsms.Replace("#PID#", targetid);
                                        sbsms = sbsms.Replace("#MONEY#", investAmt.ToString());
                                        string          mobile  = dt.Rows[0]["mobile"].ToString();
                                        M_td_SMS_record psms    = new M_td_SMS_record();
                                        B_td_SMS_record osms    = new B_td_SMS_record();
                                        int             smstype = (int)Enum.Parse(typeof(EnumSMSType), EnumSMSType.投资成功.ToString());
                                        psms.phone_number = mobile;
                                        psms.sendtime     = DateTime.Now;
                                        psms.senduserid   = registerid;
                                        psms.smstype      = smstype;
                                        psms.smscontext   = sbsms.ToString();
                                        psms.orderid      = SendSMS.Send_SMS(mobile, sbsms.ToString());
                                        psms.vcode        = "";
                                        osms.Add(psms);
                                        #endregion

                                        #region 远程调用生成合同??? 稍后替换为本地方法调用  微信端可远程调用
                                        string postString = "action=MUserPDF&data=" + targetid.ToString() + "&uc=" + registerid.ToString() + "&OrdId=" + OrdId;
                                        string sr         = Utils.PostWebRequest(Utils.GetRemote_url("pdf/index"), postString, Encoding.UTF8);
                                        #endregion

                                        #region  道合作 第一投标调用接口???
                                        B_member_table bmt = new B_member_table();
                                        M_member_table mmt = new M_member_table();
                                        mmt = bmt.GetModel(registerid);
                                        if (mmt.Tid != null && mmt.Channelsource == 1)
                                        {
                                            if (B_usercenter.GetInvestCountByUserid(mmt.registerid) == 1)
                                            {
                                                string ret3 = Utils.GetCoopAPI(mmt.Tid, investAmt.ToString("0.00"), 2);
                                                log += "<br>前台渠道合作第一次返回结果:" + ret3 + "  用户id:" + mmt.registerid + " 订单id " + OrdId;
                                            }
                                        }
                                        #endregion
                                        #endregion 待提取为公共方法

                                        //发放奖励
                                        ActFacade act = new ActFacade();
                                        act.SendBonusAfterInvest(dt, EnumCommon.E_hx_ActivityTable.E_ActTargetPlatform.web);

                                        #region  线 投资六月专享标一元抢Iphone 2016年9月11日 9点 至2016年9月30日
                                        if (false)
                                        {
                                            DateTime nowdate   = DateTime.Now;
                                            DateTime startdate = new DateTime(2016, 09, 11, 9, 00, 00);
                                            DateTime enddate   = new DateTime(2016, 09, 30, 23, 59, 59);

                                            if (nowdate > startdate && nowdate < enddate)
                                            {
                                                log += "<br>PC端【一元抢Iphone】";
                                                log += "<br>标的期限:" + dt.Rows[0]["life_of_loan"].ToString();
                                                if (dt.Rows[0]["unit_day"].ToString() == "1" && dt.Rows[0]["life_of_loan"].ToString() == "6")//是否六月标
                                                {
                                                    log += "<br>用户注册时间:" + mmt.Registration_time.ToString();
                                                    if (mmt.Registration_time > new DateTime(2016, 09, 11, 0, 0, 0))
                                                    {
                                                        B_GrabIphone gi = new B_GrabIphone();

                                                        bool isCount = gi.Exists(mmt.registerid);//查询是否存在该用户
                                                        log += "<br> 用户ID:" + mmt.registerid + ";查询是否存在该用户:" + isCount;
                                                        if (isCount != true)
                                                        {
                                                            M_GrabIphone model = new M_GrabIphone();
                                                            model.RegrsterID       = mmt.registerid;
                                                            model.Color            = "";
                                                            model.Addtime          = nowdate;
                                                            model.LuckDrawState    = 0;
                                                            model.WinningState     = 0;
                                                            model.WinningTime      = nowdate;
                                                            model.TargetID         = int.Parse(dt.Rows[0]["targetid"].ToString());
                                                            model.BidRecordsID     = int.Parse(dt.Rows[0]["bid_records_id"].ToString());
                                                            model.InvestmentAmount = dt.Rows[0]["investment_amount"].ToString();
                                                            gi.Add(model);                                                                                                 //增加一条数据
                                                            int ljcount = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["GrabIphone"].ToString()); //获取启动抽奖人数
                                                            List <M_GrabIphone> giList = gi.GetModelList(ljcount, "LuckDrawState=0", "ID");                                //获取当前阶段投资人数
                                                            if (giList != null)
                                                            {
                                                                log += "<br>当前阶段投资人数:" + giList.Count;

                                                                if (giList.Count >= ljcount)
                                                                {
                                                                    bool bo = gi.UpdateLuckDrawState();//批量更新抽奖状态
                                                                    log += "<br> 批量更新抽奖状态:" + bo;
                                                                    if (bo == true)
                                                                    {
                                                                        int          count      = giList.Count;
                                                                        int          index      = new Random().Next(count);
                                                                        M_GrabIphone randowitem = giList[index];

                                                                        if (randowitem != null)
                                                                        {
                                                                            log += "<br> 获奖用户ID:" + randowitem.RegrsterID;
                                                                            bool co = gi.Update("", 1, DateTime.Now, randowitem.RegrsterID);//更新中奖用户状态
                                                                            log += "<br> 更新中奖用户状态:" + co;
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        #endregion
                                    }
                                }
                            }
                            srt = "RECV_ORD_ID_" + p.OrdId;
                        }
                    }/*缓存检查结束位置*/
                }
            }
            LogInfo.WriteLog(log);
            #endregion
            return(Content(srt));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 常规活动 现金奖励 发放(奖励流水 资金流水 系统消息)
        /// </summary>
        /// <param name="registerid">用户id</param>
        /// <param name="investAmt">投资金额</param>
        /// <param name="hat">活动对象</param>
        /// <param name="bid_records_id">投标记录id</param>
        /// <returns>bool 是否发放成功</returns>
        private bool GeneralActCash(int Registerid, decimal InvestAmt, hx_ActivityTable hat, int bid_records_id, int lifeLoan = 0)
        {
            bool t = false;

            //hx_ActivityTable hat = GetActTableInfo(ActTypeId, ActUser, 1);
            if (hat != null)
            {
                B_member_table oy = new B_member_table();
                //M_member_table investor = new M_member_table();
                hx_member_table investor = new hx_member_table();
                investor = ef.hx_member_table.Where(c => c.registerid == Registerid).FirstOrDefault(); //oy.GetModel(Registerid);//被推荐人  也就是投资人

                DateTime dte     = DateTime.Now;
                string   codesql = "SELECT invcode,Invpeopleid,invpersonid,invtime from  hx_td_Userinvitation where  invpersonid=" + Registerid + " ";//查询本人是否已经被邀请注册过

                DataTable dtcode = DbHelperSQL.GET_DataTable_List(codesql);
                //if (dtcode.Rows.Count > 0 || (investor != null && !string.IsNullOrWhiteSpace(investor.channel_invitedcode)))
                //{
                int uuid = dtcode.Rows.Count > 0 ? int.Parse(dtcode.Rows[0]["Invpeopleid"].ToString()) : 0; //邀请用户id

                //用户等级为渠道 不参与活动
                if (investor != null && investor.useridentity == 4)
                {
                    return(t);
                }
                int investCount = B_usercenter.GetInvestCountByUserid(Registerid);
                //老渠道机制判断 (推荐人等级为4渠道用户,投资次数大于等于1次 时可参与活动
                if (uuid != 0)
                {
                    M_member_table py = new M_member_table();
                    py = oy.GetModel(uuid);//推荐人
                    if ((py != null && py.useridentity == 4) && investCount == 1)
                    {
                        return(t);
                    }
                }
                //新渠道机制判断
                using (ChannelAct channelAct = new ChannelAct())
                {
                    //按照渠道类型和投资次数判断是否参与此次活动
                    if (!channelAct.IsParticipateActivity(investor.channel_invitedcode, investCount))
                    {
                        return(t);
                    }
                }

                //if (((py != null && py.useridentity == 4) || !string.IsNullOrWhiteSpace(investor.channel_invitedcode)) && B_usercenter.GetInvestCountByUserid(Registerid) == 1)
                //{
                //    return t;
                //}
                //if (py.useridentity != 4)//渠道用户不执行 2016-11-8日添加
                //{

                string               ActRule = hat.ActRule;
                List <MAmtList>      mlist   = new List <MAmtList>();
                JavaScriptSerializer js      = new JavaScriptSerializer();
                MActCash             mc      = new MActCash();
                mc = js.Deserialize <MActCash>(ActRule);
                //mlist = js.Deserialize<List<MAmtList>>(ActRule);
                //获取该活动对应的已经发放奖励的人次
                int TopNum = B_usercenter.GetTopNum(hat.ActID);
                //获取该活动对应的已经发放奖励的总金额
                decimal totalAmt = B_usercenter.GetTopAmtCount(hat.ActID);
                if (hat.ActUser == 7)//特殊回款复投奖励类型,根据规则修订奖励基数--投资金额
                {
                    InvestAmt = GetSepcialActAmt(Registerid, bid_records_id, InvestAmt, hat);
                }
                //根据投资金额计算对应现金奖励金额
                decimal actamt = GetActAmt(mc, InvestAmt, TopNum, lifeLoan);
                //检查分发奖励是否超过人数顶限或者总金额上限,上限为0表示不限制,如果超过直接跳过
                if ((mc.TopAmt > totalAmt || mc.TopAmt == 0) && (mc.TopNum > TopNum || mc.TopNum == 0))
                {
                    //t = true;
                    if (actamt > 0)//大于 0里写入对应的奖励数据
                    {
                        hx_UserAct hua = new hx_UserAct();
                        hua.ActTypeId    = hat.ActTypeId;
                        hua.registerid   = Registerid;
                        hua.RewTypeID    = hat.RewTypeID;
                        hua.ActID        = hat.ActID;
                        hua.Amt          = actamt;
                        hua.Uselower     = 0.00M;
                        hua.Usehight     = 0.00M;
                        hua.AmtEndtime   = DateTime.Parse(hat.ActEndtime.ToString()).AddMonths(1);
                        hua.AmtUses      = 1;              //没指定情况下默认为单独使用
                        hua.UseState     = 5;              //现金未转账
                        hua.UseTime      = DateTime.Now;
                        hua.AmtProid     = bid_records_id; //未使用默认为0,对于现金奖励该字段存放获得该奖励的投资记录id
                        hua.ISSmsOne     = 0;
                        hua.IsSmsThree   = 0;
                        hua.isSmsFifteen = 0;
                        hua.IsSmsSeven   = 0;
                        hua.isSmsSixteen = 0;
                        hua.OrderID      = decimal.Parse(Utils.Createcode());
                        hua.Createtime   = DateTime.Now;
                        hua.Title        = mc.ActName;
                        hua.UseLifeLoan  = "";
                        ef.hx_UserAct.Add(hua);
                        int i = ef.SaveChanges();
                        if (i > 0)
                        {
                            //录入成功,后进行转账操作 1.获取用户对象
                            M_member_table p = new M_member_table();
                            B_member_table o = new B_member_table();
                            p = o.GetModel(Registerid);
                            if (p != null)
                            {
                                //2.调用商户向用户转账接口
                                Transfer   tf   = new Transfer();
                                ReTransfer retf = tf.ToUserTransfer(p.UsrCustId, actamt, hua.OrderID.ToString(), hua.ActID.ToString(), "/Thirdparty/ToUserTransfer");
                                if (retf != null && retf.RespCode == "000")
                                {
                                    //3.事务处理操作账户及插入流水
                                    #region 验签缓存处理
                                    string cachename = retf.OrdId + "ToUserTransfer" + retf.InCustId;
                                    if (Utils.GeTThirdCache(cachename) == 0)
                                    {
                                        Utils.SetThirdCache(cachename);
                                        B_usercenter BUC = new B_usercenter();
                                        int          ic  = BUC.UpateActToUserTransfer(retf, bid_records_id); //用户余额更新
                                        if (ic > 0)
                                        {
                                            string    sql = "SELECT registerid,username,mobile  from hx_member_table where UsrCustId='" + retf.InCustId + "'";
                                            DataTable dt  = DbHelperSQL.GET_DataTable_List(sql);
                                            if (dt.Rows.Count > 0)
                                            {
                                                #region 资金流水
                                                B_usercenter ors = new B_usercenter();
                                                decimal      di  = ors.GetUsridAvailable_balance(int.Parse(dt.Rows[0]["registerid"].ToString()));
                                                // di = di + decimal.Parse(hua.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("" + int.Parse(dt.Rows[0]["registerid"].ToString()) + "," + decimal.Parse(hua.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,'" + "现金奖励" + "')");
                                                DbHelperSQL.RunSql(strSql.ToString());
                                                strSql.Clear();
                                                #endregion

                                                #region MyRegion  记录奖励流水表
                                                string awardDescription = string.Format("{0},已汇入个人账户{1}{2}", hat.ActName, retf.TransAmt, GetBunusDescription(hat.RewTypeID));
                                                AddBonusAccoutWater(int.Parse(hua.UserAct.ToString()), Registerid, decimal.Parse(retf.TransAmt), awardDescription);
                                                #endregion

                                                #region MyRegion  发送系统消息
                                                string MContext = string.Format("尊敬的用户:您好!恭喜您成功参与{0},获得{1}{2}如有问题可咨询创利投的客服!", hat.ActName, retf.TransAmt, GetBunusDescription(hat.RewTypeID));
                                                AddSytemMessage(Registerid, hat.ActName, MContext);


                                                #endregion
                                                string msg = string.Format("尊敬的客户您好,您已成功投资创利投金服,获得返利{0}元,请登录官网查看。客服热线:010-53732056。", actamt.ToString("0.00"));
                                                SendSMS.Send_SMS(dt.Rows[0]["mobile"].ToString(), msg);
                                            }
                                        }
                                        t = true;
                                    }
                                    #endregion
                                }
                            }
                        }
                    }
                    //}
                }
                //}
            }
            return(t);
        }
Ejemplo n.º 7
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
        }