Ejemplo n.º 1
0
        /// <summary>
        /// 新用户注册活动
        /// </summary>
        /// <param name="registerid">用户id</param>
        /// <param name="ActUser">面向用户 0不限  1首次投资用户 2非首投用户 3每标首投用户 4每标最大投资用户 5所有投资用户</param>
        protected internal void SendBonusAfterRegister(int registerid, string targetPlatform, int ActUser = 0)
        {
            /// <param name="ActTypeId">活动类型id  1新人活动/2短期活动/3常规活动/4邀请活动/5系统赠送 </param>

            bool            t        = true;
            B_member_table  oy       = new B_member_table();
            hx_member_table investor = new hx_member_table();

            investor = ef.hx_member_table.Where(c => c.registerid == registerid).FirstOrDefault();                                                  //oy.GetModel(Registerid);//被推荐人  也就是投资人
            string    codesql = "SELECT invcode,Invpeopleid,invpersonid,invtime from  hx_td_Userinvitation where  invpersonid=" + registerid + " "; //查询本人是否已经被邀请注册过
            DataTable dtcode  = DbHelperSQL.GET_DataTable_List(codesql);
            int       uuid    = dtcode.Rows.Count > 0 ? int.Parse(dtcode.Rows[0]["Invpeopleid"].ToString()) : 0;                                    //邀请用户id

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

            if (t == true)
            {
                //新人注册奖励
                List <hx_UserAct> hut = RegisterActBonus(registerid, targetPlatform, ActUser);

                BonusRecordOperate(registerid, hut, "新人注册");
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// app登录发放奖励
        /// </summary>
        /// <param name="registerID"></param>
        /// <param name="targetPlatform"></param>
        public void SendBonusAfterLogin(int registerID, string targetPlatform = "0000")
        {
            try
            {
                //hx_member_table user = ef.hx_member_table.Where(c => c.registerid == registerID).FirstOrDefault();
                //if (user == null)
                //return;
                //var act = ef.hx_ActivityTable.Where(d => d.ActName == "下载app送1260").First();
                var isChannel1 = (from item in ef.hx_member_table
                                  join uInvited in
                                  (from htu in ef.hx_td_Userinvitation
                                   join peo in ef.hx_member_table
                                   on htu.Invpeopleid equals peo.registerid
                                   select new { useridentity = peo.useridentity, invpersonid = htu.invpersonid })
                                  on item.registerid equals uInvited.invpersonid into lu
                                  from luLeft in lu.DefaultIfEmpty()
                                  join invest in (from hbr in ef.hx_Bid_records
                                                  group hbr by hbr.investor_registerid into g
                                                  select new { investor_registerid = g.Key, investCount = g.Count() })
                                  on item.registerid equals invest.investor_registerid into investL
                                  from investLeft in investL.DefaultIfEmpty()
                                  where item.registerid == registerID
                                  select new
                {
                    channel_invitedcode = item.channel_invitedcode,
                    useridentity = luLeft == null ? -1 : luLeft.useridentity, //邀请人用户等级
                    uidentity = item.useridentity,                            //被邀请人用户等级
                    investCount = investLeft == null ? 0 : investLeft.investCount
                });
                var isChannel = isChannel1.ToList();

                //var aa = isChannel1.Where(c => c.uidentity != 4);
                //var bb = isChannel1.Where(c => (c.useridentity != 4 || c.investCount >= 1));
                //var cc = isChannel1.Where(c => new ChannelAct().IsParticipateActivity(c.channel_invitedcode, c.investCount) == true);
                ////增加逻辑,如果用户为渠道用户,并且历史投资次数大于等于一次,则允许参与1260红包活动
                //if (isChannel.Where(c => c.investCount >= 1 || (string.IsNullOrWhiteSpace(c.channel_invitedcode) && c.useridentity != 4 && c.uidentity != 4)).Count() <= 0)
                //    return;
                //用户等级为渠道 不参与活动
                if (isChannel.Where(c => c.uidentity != 4).Count() <= 0)
                {
                    return;
                }
                //老渠道机制判断 (推荐人等级为4渠道用户,投资次数大于等于1次 时可参与活动
                if (isChannel.Where(c => (c.useridentity != 4 || c.investCount >= 1)).Count() <= 0)
                {
                    return;
                }
                //新渠道机制判断
                using (ChannelAct channelAct = new ChannelAct())
                {
                    //按照渠道类型和投资次数判断是否参与此次活动
                    //IsParticipateActivity方法中是已投资后奖励发放为主,为兼容该类登录红包,投资次数默认+1后计算
                    if (isChannel.Where(c => channelAct.IsParticipateActivity(c.channel_invitedcode, c.investCount + 1) == true).Count() <= 0)
                    {
                        return;
                    }
                }
                int sended = (from item in ef.hx_UserAct
                              //join user in ef.hx_member_table
                              //on item.registerid equals user.registerid
                              join act in ef.hx_ActivityTable
                              on item.ActID equals act.ActID
                              where item.registerid == registerID && (act.ActName == "下载app登录送1260" || act.ActName == "下载app登录送100")
                              select item.ActID).Count();
                if (sended == 0)
                {
                    new ActRegister().SendBonusAfterLogin(registerID, targetPlatform, 1);
                }

                //所有用户登录送1580元抵扣券(活动时间:2017.01.09-01.24)
                int sended2 = (from item in ef.hx_UserAct
                               //join user in ef.hx_member_table
                               //on item.registerid equals user.registerid
                               join act in ef.hx_ActivityTable
                               on item.ActID equals act.ActID
                               where item.registerid == registerID && act.ActName == "登录送1580元抵扣券"
                               select item.ActID).Count();
                if (sended2 == 0)
                {
                    new ActRegister().SendBonusAfterLogin(registerID, "1111", 5);//ActUser面向用户 首次投资用户=1,非首投用户=2 ,每标首投用户=3,每标最大投资用户=4,所有投资用户=5,续投用户=6 , 特殊复投用户=7
                }
            }
            catch (Exception ex)
            {
                LogInfo.WriteLog("app登录奖励发放异常:" + ex.Message + ";StackTrace:" + ex.StackTrace);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 登录送抵扣券(1.9-1.24)
        /// </summary>
        /// <param name="registerID">用户ID</param>
        public void LoginSendDKQ(int registerID)
        {
            var isChannel1 = (from item in ef.hx_member_table
                              join uInvited in
                              (from htu in ef.hx_td_Userinvitation
                               join peo in ef.hx_member_table
                               on htu.Invpeopleid equals peo.registerid
                               select new { useridentity = peo.useridentity, invpersonid = htu.invpersonid })
                              on item.registerid equals uInvited.invpersonid into lu
                              from luLeft in lu.DefaultIfEmpty()
                              join invest in (from hbr in ef.hx_Bid_records
                                              group hbr by hbr.investor_registerid into g
                                              select new { investor_registerid = g.Key, investCount = g.Count() })
                              on item.registerid equals invest.investor_registerid into investL
                              from investLeft in investL.DefaultIfEmpty()
                              where item.registerid == registerID
                              select new
            {
                channel_invitedcode = item.channel_invitedcode,
                useridentity = luLeft == null ? -1 : luLeft.useridentity, //邀请人用户等级
                uidentity = item.useridentity,                            //被邀请人用户等级
                investCount = investLeft == null ? 0 : investLeft.investCount
            });
            var isChannel = isChannel1.ToList();

            //var aa = isChannel1.Where(c => c.uidentity != 4);
            //var bb = isChannel1.Where(c => (c.useridentity != 4 || c.investCount >= 1));
            //var cc = isChannel1.Where(c => new ChannelAct().IsParticipateActivity(c.channel_invitedcode, c.investCount) == true);
            ////增加逻辑,如果用户为渠道用户,并且历史投资次数大于等于一次,则允许参与1260红包活动
            //if (isChannel.Where(c => c.investCount >= 1 || (string.IsNullOrWhiteSpace(c.channel_invitedcode) && c.useridentity != 4 && c.uidentity != 4)).Count() <= 0)
            //    return;
            //用户等级为渠道 不参与活动
            if (isChannel.Where(c => c.uidentity != 4).Count() <= 0)
            {
                return;
            }
            //老渠道机制判断 (推荐人等级为4渠道用户,投资次数大于等于1次 时可参与活动
            if (isChannel.Where(c => (c.useridentity != 4 || c.investCount >= 1)).Count() <= 0)
            {
                return;
            }
            //新渠道机制判断
            using (ChannelAct channelAct = new ChannelAct())
            {
                //按照渠道类型和投资次数判断是否参与此次活动
                //IsParticipateActivity方法中是已投资后奖励发放为主,为兼容该类登录红包,投资次数默认+1后计算
                if (isChannel.Where(c => channelAct.IsParticipateActivity(c.channel_invitedcode, c.investCount + 1) == true).Count() <= 0)
                {
                    return;
                }
            }
            int sended = (from item in ef.hx_UserAct
                          //join user in ef.hx_member_table
                          //on item.registerid equals user.registerid
                          join act in ef.hx_ActivityTable
                          on item.ActID equals act.ActID
                          where item.registerid == registerID && act.ActName == "登录送1580元抵扣券"
                          select item.ActID).Count();

            if (sended > 0)
            {
                return;
            }
            new ActRegister().SendBonusAfterLogin(registerID, "1111", 5);//ActUser面向用户 首次投资用户=1,非首投用户=2 ,每标首投用户=3,每标最大投资用户=4,所有投资用户=5,续投用户=6 , 特殊复投用户=7
        }
Ejemplo n.º 4
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);
        }