Exemple #1
0
        protected decimal GetYaoActAMT(MActCash mc, decimal InvestAmt, int lifeLoan = 0)
        {
            decimal amt = 0.00M;

            foreach (MAmtList item in mc.MAmtList)
            {
                if ((item.startAmt <= InvestAmt || InvestAmt == -1) && (item.endAmt == 0 || item.endAmt >= InvestAmt) && (lifeLoan == 0 || item.LifeLoan == 0 || item.LifeLoan == lifeLoan))
                {
                    if (mc.require == 1)  //按百分比赠送
                    {
                        amt = (item.percent / 100) * InvestAmt;
                        if (amt > mc.TopAmt1 && mc.TopAmt1 != 0)//大于单比封顶金额
                        {
                            amt = mc.TopAmt1;
                        }
                    }
                    else if (mc.require == 2)//2 投投资赠送
                    {
                        amt = item.percent;
                    }
                    break;
                }
            }

            return(amt);
        }
Exemple #2
0
        /// <summary>
        /// 新人注册 现金奖励
        /// </summary>
        /// <returns></returns>
        private bool GeneralActCash(int Registerid, hx_ActivityTable hat)
        {
            bool t = false;

            if (hat != null)
            {
                string               ActRule = hat.ActRule;
                List <MAmtList>      mlist   = new List <MAmtList>();
                JavaScriptSerializer js      = new JavaScriptSerializer();
                MActCash             mc      = new MActCash();
                mc = js.Deserialize <MActCash>(ActRule);
                //获取对应奖励
                decimal actamt = GetActAmt(mc, 0, 0, 0);
                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.AmtProid     = 0; //未使用默认为0
                    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;
                    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)
                            {
                                if (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, 0);
                                        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 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

                                                /*短信接口*/
                                            }
                                        }
                                        t = true;
                                    }
                                    #endregion
                                }
                            }
                        }
                    }
                }
            }
            return(t);
        }
Exemple #3
0
        /// <summary>
        /// 邀请好友 现金奖励
        /// </summary>
        /// <param name="Registerid">邀请人用户id</param>
        /// <param name="biyaoUsrid">被邀请用户id</param>
        /// <param name="InvestAmt">投资金额</param>
        /// <param name="ActTypeId">活动类型</param>
        /// <param name="RewTypeID">奖励类型</param>
        /// <param name="require">活动规则条件</param>
        /// <param name="totalAmt">已获得奖励金额</param>
        /// <param name="ActUser">面向用户对象</param>
        /// <param name="LifeOfLoan">借款期限</param>
        /// <returns></returns>
        private List <hx_UserAct> InviteActCash(int Registerid, string targetPlatform, int biyaoUsrid, decimal InvestAmt, int ActTypeId, int RewTypeID, int require = 1, decimal totalAmt = 0M, int ActUser = 0, int LifeOfLoan = 0, string YaoQingType = "")
        {   //RewTypeID=1
            List <hx_UserAct> t   = new List <hx_UserAct>();
            hx_ActivityTable  hat = new hx_ActivityTable();

            hat = GetActTableInfo(ActTypeId, targetPlatform, ActUser, 1, RewTypeID);
            if (hat != null)
            {
                #region 邀请好友现金奖励
                string               ActRule = hat.ActRule;
                List <MAmtList>      mlist   = new List <MAmtList>();
                JavaScriptSerializer js      = new JavaScriptSerializer();
                MActCash             mc      = new MActCash();
                mc = js.Deserialize <MActCash>(ActRule);
                decimal actamt = 0M;
                totalAmt = B_usercenter.GetTopAmtCount(hat.ActID);
                //检查奖历邀请总佣金
                if (mc.TopAmt > totalAmt)
                {
                    if (mc.require == 1 && InvestAmt == -1M) //受邀好友注册成功发放红包---//首次成功投资
                    {
                        actamt = mc.Cash;
                        //发放红包
                        //hx_UserAct hua = new hx_UserAct();
                        //hua.RewTypeID = 2;
                        //t.Add(hua);

                        hx_UserAct hua = new hx_UserAct();
                        hua.ActTypeId    = hat.ActTypeId;
                        hua.registerid   = Registerid;
                        hua.RewTypeID    = 2;                                                             //hat.RewTypeID;
                        hua.ActID        = hat.ActID;
                        hua.Amt          = actamt;                                                        //item.cashAmt;
                        hua.Uselower     = 500;                                                           //item.startAmt;
                        hua.Usehight     = 0;                                                             //item.endAmt;
                        hua.AmtEndtime   = hua.AmtEndtime = DateTime.Now.Date.AddDays(31).AddSeconds(-1); // hat.ActEndtime;//item.endTime;
                        hua.AmtUses      = 2;                                                             //mcp.Uses; //没指定情况下默认为单独使用
                        hua.UseState     = 0;                                                             //现金未转账
                        hua.AmtProid     = 0;                                                             //未使用默认为0
                        hua.ISSmsOne     = 0;
                        hua.IsSmsThree   = 0;
                        hua.isSmsFifteen = 0;
                        hua.IsSmsSeven   = 0;
                        hua.isSmsSixteen = 0;
                        hua.Createtime   = DateTime.Now;
                        hua.Title        = hat.ActName;
                        hua.UseLifeLoan  = "0-0";//string.IsNullOrWhiteSpace(item.UseLifeLoan) ? "" : item.UseLifeLoan;
                        ef.hx_UserAct.Add(hua);
                        int i = ef.SaveChanges();
                        t.Add(hua);
                    }
                    else if (mc.require1 == 1 && InvestAmt > 0)           //续投按一定金额赠送
                    {
                        actamt = GetYaoActAMT(mc, InvestAmt, LifeOfLoan); //奖励邀请人与被邀请人返现金额(邀请人与被邀请人返现规则一直)


                        #region 奖励
                        if (actamt > 0 && actamt <= mc.TopAmt1)//大于 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.UseState     = 5; //现金未转账
                            hua.AmtEndtime   = DateTime.Parse(hat.ActEndtime.ToString());
                            hua.OrderID      = decimal.Parse(Utils.Createcode());
                            hua.AmtUses      = 1; //没指定情况下默认为单独使用
                            hua.AmtProid     = 0; //未使用默认为0
                            hua.ISSmsOne     = 0;
                            hua.IsSmsThree   = 0;
                            hua.isSmsFifteen = 0;
                            hua.IsSmsSeven   = 0;
                            hua.isSmsSixteen = 0;
                            hua.Createtime   = DateTime.Now;
                            hua.Title        = YaoQingType;// "邀请好友返现";
                            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)
                                    {
                                        if (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, 0);
                                                if (ic > 0)
                                                {
                                                    //处理 资金流水信息 奖励流水  系统消息
                                                    t.Add(hua); //????
                                                }
                                            }
                                            #endregion
                                        }
                                    }
                                }
                            }
                        }
                        #endregion
                    }
                }
                #endregion
            }
            return(t);
        }
Exemple #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);
        }