Esempio n. 1
0
        /// <summary>新用户注册活动奖励</summary>
        /// <param name="Registerid">注册用户id</param>
        /// <param name="ActUser">ActUser=0;面向用户 首次投资用户=1,非首投用户=2 ,每标首投用户=3,每标最大投资用户=4,所有投资用户=5,续投用户=6</param>
        /// <returns></returns>
        public List <hx_UserAct> RegisterActBonus(int Registerid, string targetPlatform, int ActUser = 0)
        {
            //ActTypeId=1  活动类型id 1新人活动/2短期活动/3常规活动/4邀请活动/5系统赠送
            int ActTypeId         = 1;
            List <hx_UserAct> t   = new List <hx_UserAct>();
            hx_ActivityTable  hat = GetActTableInfo(ActTypeId, targetPlatform, ActUser, 1);

            if (hat != null)
            {
                if (hat.RewTypeID == 1) //现金奖励,后台界面暂不支持
                {
                    GeneralActCash(Registerid, hat);
                }
                else if (hat.RewTypeID == 2) //代金券奖励
                {
                    t = GeneralActCoupon(Registerid, ActTypeId, hat);
                }
                else if (hat.RewTypeID == 3) //加息券奖励
                {
                    GeneralActInterestRatesPlus(Registerid, ActTypeId, hat);
                }
                //ef.hx_ActivityTable.Where(a => a.ActID == hat.ActID).Update(a => new hx_ActivityTable { ActState = 2 });
            }
            return(t);
        }
Esempio n. 2
0
        /// <summary>
        ///  常规活动 投资 ---用户投资活动 获得相应奖励</summary>
        /// <param name="Registerid">注册用户id</param>
        /// <param name="InvestAmt">投资金额:实际投资金额 已经扣除奖励金额</param>
        /// <param name="bid_records_id">投标记录id</param>
        /// <param name="ActUser">ActUser=0;面向用户 首次投资用户=1,非首投用户=2 ,每标首投用户=3,每标最大投资用户=4,所有投资用户=5,续投用户=6 特殊复投用户=7   </param>
        /// <returns></returns>
        private List <hx_UserAct> GeneralInvestActBonus(int Registerid, string targetPlatform, decimal InvestAmt, int bid_records_id, int ActUser, int lifeLoan = 0)
        {
            ///ActTypeId=3  活动类型id 1新人活动/2短期活动/3常规活动/4邀请活动/5系统赠送
            int ActTypeId         = 3;
            List <hx_UserAct> t   = new List <hx_UserAct>();
            hx_ActivityTable  hat = GetActTableInfo(ActTypeId, targetPlatform, ActUser, 1);

            //判断是否过期
            if (hat != null && hat.ActStarttime <= DateTime.Now && DateTime.Now <= hat.ActEndtime)
            {
                if (hat.RewTypeID == 1) //现金奖励
                {
                    GeneralActCash(Registerid, InvestAmt, hat, bid_records_id, lifeLoan);
                }
                else if (hat.RewTypeID == 2) //红包奖励
                {
                    t = GeneralActCoupon(Registerid, InvestAmt, hat);
                }
                else if (hat.RewTypeID == 3) //加息券奖励
                {
                    GeneralActInterestRatesPlus(Registerid, InvestAmt, hat);
                }
            }
            return(t);
        }
Esempio n. 3
0
        /// <summary>
        /// 根据ActID编号获取活动对象
        /// </summary>
        /// <param name="ActID"></param>
        /// <returns></returns>
        public hx_ActivityTable GetActivityModel(int ActID)
        {
            hx_ActivityTable res = (from item in ef.hx_ActivityTable
                                    where item.ActID == ActID
                                    select item).FirstOrDefault();

            return(res);
        }
Esempio n. 4
0
        public List <hx_UserAct> LoginActBonus(int registerID, string targetPlatform, int actUser, DateTime endTime)
        {
            //ActTypeId=1  活动类型id 1新人活动/2短期活动/3常规活动/4邀请活动/5系统赠送
            int ActTypeId        = 2;
            hx_ActivityTable hat = GetActTableInfo(ActTypeId, targetPlatform, actUser);

            if (hat != null && hat.RewTypeID == 2) //代金券奖励
            {
                return(GeneralActCoupon(registerID, ActTypeId, hat, endTime));
            }
            return(new List <hx_UserAct>());
        }
Esempio n. 5
0
        /// <summary>获取符合条件在有效时间内的一个活动对象</summary>
        /// <param name="ActTypeId">活动类型id 1新人活动/2短期活动/3常规活动/4邀请活动/5系统赠送 </param>
        /// <param name="ActUser">面向用户 首次投资用户=1,非首投用户=2 ,每标首投用户=3,每标最大投资用户=4,所有投资用户=5,续投用户=6 , 特殊复投用户=7</param>
        /// <param name="ActState">活动状态  0默认(未上线)  1进行中(上线)  2结束(下线) 3停止</param>
        /// <param name="RewTypeID">RewTypeID 默认0不限制  奖励类型id 1现金/2抵扣券/3加息券</param>
        /// <returns>hx_ActivityTable 符合条件的一个活动对象</returns>
        protected hx_ActivityTable GetActTableInfo(int ActTypeId, string targetPlatform, int ActUser = 0, int ActState = 1, int RewTypeID = 0)
        {
            hx_ActivityTable hat = null; //new hx_ActivityTable();
            string           key = "Act" + ActTypeId.ToString() + ActUser.ToString() + ActState.ToString() + RewTypeID.ToString();
            StringBuilder    sql = new StringBuilder();

            if (HttpRuntime.Cache[key] == null)
            {
                sql.AppendFormat("select top 1 * from hx_ActivityTable where ActTypeId = {0} and ActState = {1} and ActTypeId != {2} and ActStarttime < '{3}' and ActEndtime > '{3}'", ActTypeId, ActState, 5, DateTime.Now);
                //var query = ef.hx_ActivityTable.Where(p => p.ActTypeId == ActTypeId && p.ActState == ActState && p.ActTypeId != 5 && p.ActStarttime < DateTime.Now && p.ActEndtime > DateTime.Now);
                //if (ActUser != 0)
                //{
                //    query = query.Where(p => p.ActUser == ActUser);
                //}
                if (ActUser != 0)
                {
                    sql.AppendFormat(" and ActUser = {0} ", ActUser);
                }
                //if (RewTypeID != 0)
                //{
                //    query = query.Where(p => p.RewTypeID == RewTypeID);
                //}
                if (RewTypeID != 0)
                {
                    sql.AppendFormat(" and RewTypeID = {0} ", RewTypeID);
                }
                if (!string.IsNullOrWhiteSpace(targetPlatform) && targetPlatform != EnumCommon.E_hx_ActivityTable.E_ActTargetPlatform.all)
                {
                    string tp = targetPlatform.Replace("0", "_");
                    sql.AppendFormat(" and (ActTargetPlatform is null or ActTargetPlatform like '{0}') ", tp);
                    //query = query.AsQueryable().Where(p => p.ActTargetPlatform == null || SqlMethods.Like(p.ActTargetPlatform, targetPlatform.Replace("0", "_")));
                    //query = query.Where(" ActTargetPlatform like @atp ", new ObjectParameter("atp", tp));
                }
                sql.Append(" order by ActID desc ");
                DataTable dt = DBUtility.DbHelperSQL.Query(sql.ToString()).Tables[0];
                if (dt != null && dt.Rows.Count > 0)
                {
                    hat = ConvertDataTable <hx_ActivityTable> .ConvertToList(dt)[0];
                }
                //hat = query.OrderByDescending(p => p.ActID).FirstOrDefault();

                if (hat != null)
                {//放入缓存
                    HttpRuntime.Cache.Add(key, hat, null, DateTime.Now.AddMinutes(30), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.High, null);
                }
            }
            else
            {
                hat = (hx_ActivityTable)HttpRuntime.Cache[key];
            }
            return(hat);
        }
Esempio n. 6
0
        /// <summary>
        /// 活动加息券
        /// </summary>
        /// <param name="registerid"></param>
        /// <param name="investAmt"></param>
        /// <param name="ActTypeId">活动类型</param>
        /// <param name="ActUser"></param>
        /// <returns></returns>
        private List <hx_UserAct> InviteActInterestRatesPlus(int registerid, string targetPlatform, decimal investAmt, int ActTypeId = 3, int ActUser = 0)
        {
            List <hx_UserAct> t   = new List <hx_UserAct>();
            hx_ActivityTable  hat = GetActTableInfo(ActTypeId, targetPlatform, ActUser, 1);

            if (hat != null)
            {
                hx_UserAct           hua = new hx_UserAct();
                Mcoupon              mcp = new Mcoupon();
                JavaScriptSerializer js  = new JavaScriptSerializer();
                mcp = js.Deserialize <Mcoupon>(hat.ActRule);
                //获取用户活动表对象
                t = OPMcoupon(mcp, hat, registerid, investAmt);
            }
            return(t);
        }
Esempio n. 7
0
        /// <summary>获取符合条件在有效时间内的一个活动对象</summary>
        /// <param name="ActTypeId">活动类型id 1新人活动/2短期活动/3常规活动/4邀请活动/5系统赠送 </param>
        /// <param name="ActUser">面向用户 首次投资用户=1,非首投用户=2 ,每标首投用户=3,每标最大投资用户=4,所有投资用户=5,续投用户=6 , 特殊复投用户=7</param>
        /// <param name="ActState">活动状态 -1不限制 0默认(未上线)  1进行中(上线)  2结束(下线) 3停止</param>
        /// <param name="RewTypeID">RewTypeID 默认0不限制  奖励类型id 1现金/2抵扣券/3加息券</param>
        /// <param name="isDescending">是否按照id降序排列</param>
        /// <returns>hx_ActivityTable 符合条件的一个活动对象</returns>
        protected hx_ActivityTable GetActTableInfoWithoutTimeLimit(int ActTypeId, int ActUser = 0, int ActState = 1, int RewTypeID = 0, bool isDescending = true)
        {
            hx_ActivityTable hat = new hx_ActivityTable();
            string           key = "ActWithoutTimeLimit" + ActTypeId.ToString() + ActUser.ToString() + ActState.ToString() + RewTypeID.ToString();

            if (HttpRuntime.Cache[key] == null)
            {
                var query = ef.hx_ActivityTable.Where(p => p.ActTypeId == ActTypeId);
                if (ActState != -1)
                {
                    query = query.Where(p => p.ActState == ActState);
                }
                if (ActUser != 0)
                {
                    query = query.Where(p => p.ActUser == ActUser);
                }
                if (RewTypeID != 0)
                {
                    query = query.Where(p => p.RewTypeID == RewTypeID);
                }
                if (isDescending)
                {
                    hat = query.OrderByDescending(p => p.ActID).FirstOrDefault();
                }
                else
                {
                    hat = query.OrderBy(p => p.ActID).FirstOrDefault();
                }
                if (hat != null)
                {//放入缓存
                    HttpRuntime.Cache.Add(key, hat, null, DateTime.Now.AddMinutes(30), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.High, null);
                }
            }
            else
            {
                hat = (hx_ActivityTable)HttpRuntime.Cache[key];
            }
            return(hat);
        }
Esempio n. 8
0
        /// <summary>
        /// 好友邀请 活动奖励
        /// </summary>
        /// <param name="Registerid">邀请人ID</param>
        /// <param name="InvitedRegisterid">被邀请人ID</param>
        /// <param name="InvestAmt">投次金额</param>
        /// <param name="RewTypeID">奖励类型????</param>
        /// <param name="ActTypeId">活动类型</param>
        /// <param name="require"></param>
        /// <param name="totalAmt">奖励金额</param>
        /// <param name="ActUser">面向用户</param>
        /// <param name="LifeOfLoan">借款期限</param>
        /// <returns></returns>
        private List <hx_UserAct> InviteActBonus(int Registerid, string targetPlatform, int InvitedRegisterid, decimal InvestAmt, int RewTypeID, int ActTypeId = 1, int require = 1, decimal totalAmt = 0M, int ActUser = 0, int LifeOfLoan = 0, string YaoQingType = "")
        {
            List <hx_UserAct> t   = new List <hx_UserAct>();
            hx_ActivityTable  hat = new hx_ActivityTable();

            hat = GetActTableInfo(ActTypeId, targetPlatform, ActUser, 1, RewTypeID);
            if (hat != null && hat.ActID > 0)
            {
                if (hat.RewTypeID == 1) //现金奖励
                {
                    t = InviteActCash(Registerid, targetPlatform, InvitedRegisterid, InvestAmt, int.Parse(hat.ActTypeId.ToString()), RewTypeID, require, totalAmt, ActUser, LifeOfLoan, YaoQingType);
                }
                else if (hat.RewTypeID == 2) //抵扣券奖励
                {
                    t = InviteActCoupon(Registerid, targetPlatform, InvestAmt, int.Parse(hat.ActTypeId.ToString()), ActUser);
                }
                else if (hat.RewTypeID == 3) //加息券奖励
                {
                    t = InviteActInterestRatesPlus(Registerid, targetPlatform, InvestAmt, int.Parse(hat.ActTypeId.ToString()), ActUser);
                }
            }
            return(t);
        }
Esempio n. 9
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);
        }
Esempio n. 10
0
        /// <summary>
        /// 发放奖励
        /// </summary>
        /// <param name="activity"></param>
        /// <param name="registerID"></param>
        private void DrawBonus(hx_ActivityTable activity, int registerID)
        {
            chuangtouEntities ef = new chuangtouEntities();

            B_bonus_account bb = new B_bonus_account();
            M_bonus_account mb = new M_bonus_account();

            M_bonus_account_water mbaw = new M_bonus_account_water();
            B_bonus_account_water bbaw = new B_bonus_account_water();

            DateTime dte = DateTime.Now;//当前时间截点

            //hx_ActivityTable act = ef.hx_ActivityTable.Where(c => c.ActID == activity.ActID).FirstOrDefault();//添加奖励类型
            if (activity.ActEndtime >= dte && activity.ActStarttime <= dte)
            {
                Mcoupon mcp             = new Mcoupon();
                JavaScriptSerializer js = new JavaScriptSerializer();
                mcp = js.Deserialize <Mcoupon>(activity.ActRule);
                hx_UserAct hua = new hx_UserAct();
                hua.ActTypeId    = activity.ActTypeId;
                hua.registerid   = registerID;
                hua.RewTypeID    = activity.RewTypeID;
                hua.ActID        = activity.ActID;
                hua.Amt          = mcp.cash;
                hua.Uselower     = mcp.Msplitarr == null || mcp.Msplitarr.Count <= 0 ? 0 : mcp.Msplitarr[0].startAmt;
                hua.Usehight     = mcp.Msplitarr == null || mcp.Msplitarr.Count <= 0 ? 0 : mcp.Msplitarr[0].endAmt;
                hua.AmtEndtime   = activity.ActEndtime;
                hua.AmtUses      = 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;

                ef.hx_UserAct.Add(hua);
                int i = ef.SaveChanges();

                mb.activity_schedule_id   = activity.ActID;
                mb.membertable_registerid = registerID;
                mb.activity_schedule_name = activity.ActName;
                mb.amount_of_reward       = decimal.Parse(hua.Amt.ToString());

                mb.use_lower_limit = Convert.ToDecimal(hua.Uselower);
                mb.reward          = 0;
                mb.start_date      = Convert.ToDateTime(hua.Createtime);
                mb.end_date        = Convert.ToDateTime(hua.AmtEndtime);
                mb.entry_time      = dte;
                int bbid = bb.Add(mb);
                if (bbid > 0) //奖励记录成功后插入明细记录
                {
                    mbaw.bonus_account_id       = bbid;
                    mbaw.membertable_registerid = registerID;
                    mbaw.income             = decimal.Parse(hua.Amt.ToString());
                    mbaw.expenditure        = 0.00M;
                    mbaw.time_of_occurrence = DateTime.Now;
                    mbaw.award_description  = activity.ActName;
                    mbaw.water_type         = 0;

                    bbaw.Add(mbaw);
                }
            }
        }
Esempio n. 11
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);
        }
Esempio n. 12
0
        /// <summary>
        /// 常规活动 加息券奖励 未记录系统信息及奖励流水 //与红包方法一致GeneralActCoupon
        /// </summary>
        /// <param name="registerid">用户id</param>
        /// <param name="investAmt">投资金额</param>
        /// <param name="hat">活动对象</param>
        /// <returns>list 用户活动奖励记录集合</returns>
        /// <returns></returns>
        private List <hx_UserAct> GeneralActInterestRatesPlus(int registerid, decimal investAmt, hx_ActivityTable hat)
        {
            List <hx_UserAct> t = new List <hx_UserAct>();

            //hx_ActivityTable hat = GetActTableInfo(ActTypeId, ActUser, 1);
            if (hat != null)
            {
                Mcoupon mcp             = new Mcoupon();
                JavaScriptSerializer js = new JavaScriptSerializer();
                mcp = js.Deserialize <Mcoupon>(hat.ActRule);
                //发放加息券奖励
                t = OPMcoupon(mcp, hat, registerid, investAmt);
            }
            return(t);
        }
Esempio n. 13
0
        /// <summary>
        /// 发放奖励
        /// </summary>
        /// <param name="activity"></param>
        /// <param name="registerID"></param>
        public static void DrawBonus(hx_ActivityTable activity, int registerID, int effectiveDays)
        {
            //chuangtouEntities ef = new chuangtouEntities();
            M_bonus_account_water mbaw = new M_bonus_account_water();
            B_bonus_account_water bbaw = new B_bonus_account_water();

            DateTime dte = DateTime.Now;//当前时间截点

            //if (activity.ActEndtime >= dte && activity.ActStarttime <= dte)   //发布的时候要释放
            if (true)
            {
                Mcoupon mcp             = new Mcoupon();
                JavaScriptSerializer js = new JavaScriptSerializer();
                mcp = js.Deserialize <Mcoupon>(activity.ActRule);
                hx_UserAct hua = new hx_UserAct();
                hua.ActTypeId  = activity.ActTypeId;
                hua.registerid = registerID;
                hua.RewTypeID  = activity.RewTypeID;
                if (activity.RewTypeID == 3)
                {
                    hua.UseLifeLoan = "3-0";
                }
                hua.ActID        = activity.ActID;
                hua.Amt          = mcp.cash;
                hua.Uselower     = mcp.Msplitarr == null || mcp.Msplitarr.Count <= 0 ? 0 : mcp.Msplitarr[0].startAmt;
                hua.Usehight     = mcp.Msplitarr == null || mcp.Msplitarr.Count <= 0 ? 0 : mcp.Msplitarr[0].endAmt;
                hua.AmtEndtime   = Convert.ToDateTime(dte.AddDays(effectiveDays).ToShortDateString() + " 23:59:59"); //有效期为10天
                hua.AmtUses      = 1;                                                                                //没指定情况下默认为单独使用
                hua.UseState     = activity.RewTypeID == 1 ? 5 : 0;
                hua.AmtProid     = 0;                                                                                //未使用默认为0
                hua.ISSmsOne     = 0;
                hua.IsSmsThree   = 0;
                hua.isSmsFifteen = 0;
                hua.IsSmsSeven   = 0;
                hua.isSmsSixteen = 0;
                hua.Title        = activity.ActName;
                hua.Createtime   = dte;
                hua.OrderID      = decimal.Parse(Utils.Createcode());//根据日期生成单号
                ef.hx_UserAct.Add(hua);
                ef.SaveChanges();


                if (activity.RewTypeID == 1)  //当奖品为现金时
                {
                    Transfer       tf = new Transfer();
                    M_member_table p  = new M_member_table();
                    B_member_table o  = new B_member_table();
                    p = o.GetModel(registerID);
                    ReTransfer retf = tf.ToUserTransfer(p.UsrCustId, mcp.cash, 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();
                                BUC.UpateActToUserTransfer(retf, 0);

                                //增加账户资金流水
                                hx_Capital_account_water Caw = new hx_Capital_account_water();

                                Caw.membertable_registerid = registerID;
                                Caw.income             = mcp.cash;
                                Caw.expenditure        = 0;
                                Caw.time_of_occurrence = dte;
                                Caw.account_balance    = p.available_balance + mcp.cash;
                                Caw.types_Finance      = 43;
                                Caw.createtime         = dte;
                                Caw.keyid   = 0;
                                Caw.remarks = "现金奖励";
                                ef.hx_Capital_account_water.Add(Caw);
                                ef.SaveChanges();
                            }
                            #endregion
                        }
                    }
                }
            }
        }
Esempio n. 14
0
        /// <summary>
        /// 邀请好友 现金奖励
        /// </summary>
        /// <param name="Registerid">邀请人用户id</param>
        /// <param name="InvestAmt">投资金额</param>
        /// <param name="ActTypeId">活动类型(1新人注册,3常规活动,4邀请奖励)</param>
        /// <param name="RewTypeID">奖励类型(1现金,2抵扣券,3加息券)</param>
        /// <param name="totalAmt">奖励金额</param>
        /// <param name="ActUser">面向用户对象</param>
        /// <returns></returns>
        private List <hx_UserAct> InviteActCashNew(int Registerid, string targetPlatform, decimal InvestAmt, int ActTypeId, int RewTypeID, decimal totalAmt = 0M, int ActUser = 0)
        {   //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 邀请好友现金奖励
                decimal actamt = 0M;

                if (InvestAmt >= 2000) //
                {
                    actamt = totalAmt; //奖励邀请人
                }
                #region 奖励
                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.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        = "邀请好友首投满2000送10元现金";
                    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);
        }
Esempio n. 15
0
        /// <summary>
        /// 根据活动规则计算特殊回款复投奖励现金金额
        /// </summary>
        /// <param name="Registerid">投资人id</param>
        /// <param name="bid_records_id">投标记录id</param>
        /// <param name="InvestAmt">本次投标金额</param>
        /// <param name="hx_ActivityTable"> hx_ActivityTable.ActUser面向用户 首次投资用户=1,非首投用户=2 ,每标首投用户=3,每标最大投资用户=4,所有投资用户=5,续投用户=6 , 特殊复投用户=7</param>
        ///
        public decimal GetSepcialActAmt(int Registerid, int bid_records_id, decimal InvestAmt, hx_ActivityTable hat = null)
        {
            //获取活动一次开始时间 ;
            DateTime         startTime = new DateTime(2016, 10, 31, 13, 35, 0);
            hx_ActivityTable shat      = null;

            if (hat != null)
            {
                shat = GetActTableInfoWithoutTimeLimit((int)hat.ActTypeId, (int)hat.ActUser, -1, (int)hat.RewTypeID, true);
            }
            else
            {
                shat = GetActTableInfoWithoutTimeLimit(4, 7, -1, 1, true);
            }
            if (shat != null)
            {
                startTime = (DateTime)shat.ActStarttime;
            }

            decimal CurrentInvestAmt = 0.00M;
            //计算本次计入返现基数的投资金额
            //查找最近30天回款记录(income_statement)
            List <hx_income_statement> incomeList = GetIncomeStatementList(Registerid, 30);

            if (incomeList != null && incomeList.Count > 0)
            {
                List <Behavor> behavorList = new List <Behavor>();
                DateTime?      firstRecentPrincipalRepayTime = null;
                foreach (hx_income_statement income in incomeList)
                {
                    Behavor behavor = new Behavor();
                    behavor.type   = BehavorType.HK;
                    behavor.time   = income.repayment_period;
                    behavor.amount = decimal.Parse(income.Principal.ToString());
                    if (behavor.amount > 0.00M && behavor.time != null && (firstRecentPrincipalRepayTime == null || firstRecentPrincipalRepayTime > (DateTime)behavor.time))
                    {
                        firstRecentPrincipalRepayTime = (DateTime)behavor.time;
                    }
                    behavor.amountExt = decimal.Parse(income.interestpayment.ToString());
                    behavorList.Add(behavor);
                }
                if (firstRecentPrincipalRepayTime == null)
                {//最近30天没有本金回款
                    return(0.00M);
                }
                DateTime time = (DateTime)firstRecentPrincipalRepayTime;
                //查找最近30天第一笔本金回款之后充值记录(recharge)
                List <hx_Recharge_history> rechargeList = GetRechargeList(Registerid, time);
                foreach (hx_Recharge_history recharge in rechargeList)
                {
                    Behavor behavor = new Behavor();
                    behavor.type   = BehavorType.CZ;
                    behavor.time   = recharge.recharge_time;
                    behavor.amount = decimal.Parse(recharge.recharge_amount.ToString());
                    behavorList.Add(behavor);
                }
                //查找最近30天第一笔回款之后提现记录(cash)
                List <hx_td_UserCash> cashList = GetCashList(Registerid, time);
                foreach (hx_td_UserCash cash in cashList)
                {
                    Behavor behavor = new Behavor();
                    behavor.type   = BehavorType.TX;
                    behavor.time   = cash.OperTime;
                    behavor.amount = decimal.Parse(cash.TransAmt.ToString());
                    behavorList.Add(behavor);
                }
                //查找最近30天第一笔回款之后投资记录(含红包金额)(bid_records orderstate=1)
                List <hx_Bid_records> investList = GetInvestList(Registerid, time);
                foreach (hx_Bid_records invest in investList)
                {
                    if (invest.bid_records_id == bid_records_id)
                    //不包括本次投标记录
                    {
                        continue;
                    }
                    Behavor behavor = new Behavor();
                    behavor.type      = BehavorType.TZ;
                    behavor.time      = invest.invest_time;
                    behavor.amount    = decimal.Parse(invest.investment_amount.ToString());
                    behavor.amountExt = decimal.Parse(invest.BonusAmt.ToString());
                    behavorList.Add(behavor);
                }
                //查找最近30天第一笔回款之后返现记录(useract,rewardtype=1,createtime)
                List <hx_UserAct> cashRewardList = GetCashRewardList(Registerid, time);
                foreach (hx_UserAct cashReward in cashRewardList)
                {
                    Behavor behavor = new Behavor();
                    behavor.type   = BehavorType.FX;
                    behavor.time   = cashReward.Createtime;
                    behavor.amount = decimal.Parse(cashReward.Amt.ToString());
                    behavorList.Add(behavor);
                }

                //TODO list 按照时间排序,最近三十天内的第一笔回款之后的操作行为保留,其他排除
                behavorList.OrderBy(p => p.time);

                CurrentInvestAmt = CacuBonusBaseAmount(behavorList, InvestAmt, startTime);
                //return GetActAmt(mc, CurrentInvestAmt, TopNum, lifeLoan);
            }
            return(CurrentInvestAmt);
        }
Esempio n. 16
0
        /// <summary>
        /// 活动企业向用户转账
        /// </summary>
        /// <returns></returns>
        public ActionResult ToUserTransfer()
        {
            //  Thread.Sleep(6000);
            string     str = "";
            ReTransfer p   = new ReTransfer();

            p.CmdId     = DNTRequest.GetString("CmdId");
            p.RespCode  = DNTRequest.GetString("RespCode");
            p.RespDesc  = HttpUtility.UrlDecode(DNTRequest.GetString("RespDesc"));
            p.OrdId     = DNTRequest.GetString("OrdId");
            p.OutCustId = DNTRequest.GetString("OutCustId");
            p.OutAcctId = DNTRequest.GetString("OutAcctId");
            p.TransAmt  = DNTRequest.GetString("TransAmt");
            p.InCustId  = DNTRequest.GetString("InCustId");
            p.InAcctId  = DNTRequest.GetString("InAcctId");
            p.RetUrl    = HttpUtility.UrlDecode(DNTRequest.GetString("RetUrl"));
            p.BgRetUrl  = HttpUtility.UrlDecode(DNTRequest.GetString("BgRetUrl"));
            p.MerPriv   = DNTRequest.GetString("MerPriv");
            p.ChkValue  = DNTRequest.GetString("ChkValue");
            StringBuilder builder = new StringBuilder();

            builder.Append(p.CmdId);
            builder.Append(p.RespCode);
            builder.Append(p.OrdId);
            builder.Append(p.OutCustId);
            builder.Append(p.OutAcctId);
            builder.Append(p.TransAmt);
            builder.Append(p.InCustId);
            builder.Append(p.InAcctId);
            builder.Append(HttpUtility.UrlDecode(p.RetUrl));
            builder.Append(HttpUtility.UrlDecode(p.BgRetUrl));
            builder.Append(p.MerPriv);
            string chkv = builder.ToString();
            //私钥文件的位置(这里是放在了站点的根目录下)
            string merKeyFile = AppDomain.CurrentDomain.BaseDirectory + Utils.GetPgPubk();

            int ret = DllInterop.VeriSignMsg(merKeyFile, chkv, chkv.Length, p.ChkValue);

            string log = "后台平台向用户活动转账后";

            log += "<br>1台验签:" + ret.ToString();

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

            LogInfo.WriteLog(log);
            if (ret == 0)
            {
                if (p.RespCode == "000")
                {
                    #region 验签缓存处理
                    string cachename = p.OrdId + "ToUserTransfer" + p.InCustId;

                    if (Utils.GeTThirdCache(cachename) == 0)
                    {
                        Utils.SetThirdCache(cachename);
                        B_usercenter BUC = new B_usercenter();


                        int bid_records_id = DbHelperSQL.Execint(" select  amtproid from hx_UserAct where  OrderID='" + p.OrdId + "' and UseState=5");

                        int ic = BUC.UpateActToUserTransfer(p, bid_records_id);
                        if (ic > 0)
                        {
                            string    sql = "SELECT registerid,username,mobile  from hx_member_table where UsrCustId='" + p.InCustId + "'";
                            DataTable dt  = DbHelperSQL.GET_DataTable_List(sql);
                            if (dt.Rows.Count > 0)
                            {
                                int ActID            = int.Parse(p.MerPriv);
                                hx_ActivityTable hat = ef.hx_ActivityTable.Where(c => c.ActID == ActID).FirstOrDefault();



                                #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(p.TransAmt.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 奖励流水
                                M_bonus_account_water mbaw = new M_bonus_account_water();
                                B_bonus_account_water bbaw = new B_bonus_account_water();
                                DateTime dte = DateTime.Now;
                                mbaw.bonus_account_id       = int.Parse(hat.ActID.ToString());
                                mbaw.membertable_registerid = int.Parse(dt.Rows[0]["registerid"].ToString());
                                mbaw.income             = decimal.Parse(p.TransAmt);
                                mbaw.expenditure        = 0.00M;
                                mbaw.time_of_occurrence = DateTime.Now;

                                mbaw.award_description = hat.ActName + "奖励已汇入个人账户";
                                mbaw.water_type        = 0;
                                bbaw.Add(mbaw);

                                #endregion


                                #region MyRegion  系统消息
                                DateTime            dti = DateTime.Now;
                                M_td_System_message pm  = new M_td_System_message();
                                pm.MReg     = int.Parse(dt.Rows[0]["registerid"].ToString());
                                pm.Mstate   = 0;
                                pm.MTitle   = hat.ActName;
                                pm.MContext = "尊敬的用户" + dt.Rows[0]["username"].ToString() + ":您好!恭喜您成功投资了项目,现金奖励 " + p.TransAmt + "元。如有问题可咨询创利投的客服!";
                                pm.PubTime  = dti;
                                pm.Mtype    = 2;
                                B_usercenter.AddMessage(pm);
                                #endregion
                            }
                        }
                    }
                    #endregion

                    str = "RECV_ORD_ID_" + p.OrdId.ToString();
                }
                else
                {
                }
            }

            return(Content(str));
        }
Esempio n. 17
0
        /// <summary>
        /// 活动加息券
        /// </summary>
        /// 常规活动 加息券奖励 未记录系统信息及奖励流水 //与红包方法一致GeneralActCoupon
        /// </summary>
        /// <param name="registerid">用户id</param>
        /// <param name="investAmt">投资金额</param>
        /// <param name="hat">活动对象</param>
        /// <returns>list 用户活动奖励记录集合</returns>
        /// <returns></returns> ActTypeId=3
        private List <hx_UserAct> GeneralActInterestRatesPlus(int registerid, decimal investAmt, hx_ActivityTable hat)
        {
            List <hx_UserAct> t = new List <hx_UserAct>();

            if (hat != null)
            {
                hx_UserAct           hua = new hx_UserAct();
                Mcoupon              mcp = new Mcoupon();
                JavaScriptSerializer js  = new JavaScriptSerializer();
                mcp = js.Deserialize <Mcoupon>(hat.ActRule);
                //获取用户活动表对象
                t = OPMcoupon(mcp, hat, registerid, investAmt);
            }
            return(t);
        }
Esempio n. 18
0
        /// <summary>
        /// 邀请注册奖励活动
        /// </summary>
        /// <param name="registerid">注册用户id</param>
        /// <param name="ActUser">面向用户 0不限  1首次投资用户 2非首投用户 3每标首投用户 4每标最大投资用户 5所有投资用户</param>
        protected internal void SendBonusForInviteAfterRegister(int registerid, string targetPlatform, int ActUser = 0)
        {
            #region MyRegion   //邀请奖励处理逻辑,暂无邀请奖励
            bool flag = true;
            if (flag)
            {
                if (registerid < 0)
                {
                    return;
                }
                DateTime dte     = DateTime.Now;
                string   codesql = "SELECT invcode,Invpeopleid,invpersonid,invtime from  hx_td_Userinvitation where invpersonid=" + registerid.ToString();//查询本人是否已经被邀请注册过 invcode='" + invcode + "' and
                LogInfo.WriteLog("codesql2:" + codesql);
                DataTable dtcode = DbHelperSQL.GET_DataTable_List(codesql);
                //邀请奖励处理逻辑
                if (dtcode.Rows.Count > 0)
                {
                    B_member_table oy = new B_member_table();
                    M_member_table py = new M_member_table();
                    //获取邀请用户id
                    int invpeopleid = int.Parse(dtcode.Rows[0]["Invpeopleid"].ToString());
                    py = oy.GetModel(invpeopleid);
                    if (py.useridentity != 4 && py.iD_number != "")//渠道用户不执行
                    {
                        DateTime nowdate   = DateTime.Now;
                        DateTime startdate = new DateTime(2017, 1, 6, 0, 00, 00);
                        DateTime enddate   = new DateTime(2017, 3, 31, 23, 59, 59);
                        DateTime invtime   = Convert.ToDateTime(dtcode.Rows[0]["invtime"].ToString()); //邀请时间

                        #region 生成奖励,记录流水

                        //??待优化到奖励内部记录
                        if ((nowdate > startdate && nowdate < enddate) && (invtime > startdate && invtime < enddate))
                        {
                            List <hx_UserAct> hut    = InviteActBonus(py.registerid, targetPlatform, registerid, -1M, 0, 4, 1, 0, 5);
                            string            strlog = "用户:" + py.registerid + ",邀请奖励返回实体:" + hut.Count;
                            if (hut.Count > 0)
                            {
                                foreach (hx_UserAct ua in hut)
                                {
                                    if (ua.Amt != null && ua.Amt > 0)
                                    {
                                        string sql = "update hx_td_Userinvitation set Invitereward=" + ua.Amt + ",UserAct= " + ua.UserAct + " where invpersonid=" + int.Parse(dtcode.Rows[0]["invpersonid"].ToString());
                                        strlog += ";更新邀请表:" + sql;
                                        DbHelperSQL.ExecuteSql(sql);

                                        #region MyRegion  记录奖励流水表
                                        string awardDescription = string.Format("邀请好友注册成功,获得{0}{1}", Convert.ToDouble(ua.Amt.ToString()), GetBunusDescription(ua.RewTypeID));
                                        AddBonusAccoutWater(ua.UserAct, py.registerid, decimal.Parse(ua.Amt.ToString()), awardDescription, registerid);
                                        #endregion
                                        strlog += ";" + awardDescription;
                                        #region MyRegion  发送系统消息
                                        string MContext = string.Format("尊敬的用户:您邀请好友注册成功,获得{0}{1}如有问题可咨询创利投的客服!", ua.Amt.ToString(), GetBunusDescription(ua.RewTypeID));
                                        AddSytemMessage(py.registerid, "邀请好友注册奖励", MContext);
                                        #endregion
                                        strlog += ";ua.RewTypeID:" + ua.RewTypeID;
                                        if (ua.RewTypeID == 1)
                                        {
                                            #region 资金流水信息
                                            B_usercenter o  = new B_usercenter();
                                            decimal      di = o.GetUsridAvailable_balance(py.registerid);
                                            //di = di + decimal.Parse(ua.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("" + py.registerid + "," + decimal.Parse(ua.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 + "')");
                                            strlog += ";邀请好友注册奖励流水语句:" + strSql.ToString();
                                            DbHelperSQL.RunSql(strSql.ToString());
                                            strSql.Clear();
                                            #endregion
                                        }
                                    }
                                }
                            }
                            LogInfo.WriteLog(strlog);
                        }
                        #endregion

                        #region 11月活动,每邀请5位好友实名注册,奖励邀请人2%加息券一张

                        if ((nowdate > startdate && nowdate < enddate) && (invtime > startdate && invtime < enddate))
                        {
                            string log = "11月活动用户" + invpeopleid + "每邀请5位好友,当前好友(" + registerid + ")实名注册奖励邀请人2%加息券一张: ";
                            //查询活动期间内邀请人累计邀请实名注册人数
                            string strSQL = string.Format("select COUNT(mt.registerid) recount from hx_td_Userinvitation ut inner join hx_member_table mt on ut.invpersonid=mt.registerid where mt.iD_number <> '' and mt.useridentity <> 4 and mt.registration_time >= '{0}' and mt.registration_time <= '{1}' and ut.Invpeopleid={2}", startdate.ToString("yyyy-MM-dd HH:mm:ss"), enddate.ToString("yyyy-MM-dd HH:mm:ss"), invpeopleid);
                            log += "查询活动期间邀请实名人数sql:" + strSQL;
                            DataTable dtcount = DbHelperSQL.GET_DataTable_List(strSQL);
                            if (dtcount.Rows.Count > 0)
                            {
                                int recount = int.Parse(dtcount.Rows[0]["recount"].ToString());
                                log += "<br>累计实名人数:" + recount;
                                if (recount > 0)
                                {
                                    if (recount % 5 == 0)
                                    {
                                        log += "<br>实名人数" + dtcount.Rows.Count + "人,执行奖励操作";
                                        List <hx_UserAct> t   = new List <hx_UserAct>();
                                        hx_ActivityTable  hat = new hx_ActivityTable();
                                        hat = GetActTableInfo(4, targetPlatform, ActUser, 1, 1); //赋值11月活动RewTypeID为1 ,主要获取活动起止时间,真正发放奖励hua.RewTypeID是3 加息券
                                        if (hat != null && hat.ActID > 0)
                                        {
                                            hx_UserAct hua = new hx_UserAct();
                                            hua.ActTypeId    = hat.ActTypeId; //活动类型id 1新人活动/2短期活动/3常规活动/4邀请活动/5系统赠送
                                            hua.registerid   = invpeopleid;   //邀请人ID
                                            hua.RewTypeID    = 3;             //奖励类型id 1现金/2抵扣券/3加息券
                                            hua.ActID        = hat.ActID;
                                            hua.Amt          = 2;             //2%加息券
                                            hua.Uselower     = 100;
                                            hua.Usehight     = 0;
                                            hua.AmtEndtime   = DateTime.Now.Date.AddDays(31).AddSeconds(-1); // DateTime.Parse(hat.ActEndtime.ToString());
                                            hua.AmtUses      = 1;                                            //使用要求 1单独使用,2组合使用
                                            hua.UseState     = 0;                                            //使用状态 0 未使用 1 已使用 2已过期 3 锁定中
                                            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        = "11月活动每邀请5位好友送2%加息券";
                                            hua.UseLifeLoan  = "3-0";
                                            ef.hx_UserAct.Add(hua);
                                            int i = ef.SaveChanges();
                                            if (i > 0)
                                            {
                                                log += "<br>2%加息券奖励发放成功";
                                                if (hua.Amt != null && hua.Amt > 0)
                                                {
                                                    #region MyRegion  发送系统消息
                                                    string MContext = string.Format("尊敬的用户:您邀请{0}好友实名注册成功,获得{1}{2}如有问题可咨询创利投的客服!", recount, hua.Amt.ToString(), GetBunusDescription(hua.RewTypeID));
                                                    AddSytemMessage(registerid, "邀请好友注册奖励", MContext);
                                                    #endregion
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            LogInfo.WriteLog(log);
                        }
                        #endregion
                        #region 11月活动,被邀请人实名注册,奖励2%加息券一张
                        if ((nowdate > startdate && nowdate < enddate) && (invtime > startdate && invtime < enddate))
                        {
                            string log = "11月活动,被邀请人(" + registerid + ")实名注册奖励2%加息券一张: ";

                            List <hx_UserAct> t   = new List <hx_UserAct>();
                            hx_ActivityTable  hat = new hx_ActivityTable();
                            hat = GetActTableInfo(4, targetPlatform, ActUser, 1, 1); //赋值11月活动RewTypeID为1 ,主要获取活动起止时间,真正发放奖励hua.RewTypeID是3 加息券
                            if (hat != null && hat.ActID > 0)
                            {
                                hx_UserAct hua = new hx_UserAct();
                                hua.ActTypeId    = hat.ActTypeId; //活动类型id 1新人活动/2短期活动/3常规活动/4邀请活动/5系统赠送
                                hua.registerid   = registerid;    //注册人ID
                                hua.RewTypeID    = 3;             //奖励类型id 1现金/2抵扣券/3加息券
                                hua.ActID        = hat.ActID;
                                hua.Amt          = 2;             //2%加息券
                                hua.Uselower     = 100;
                                hua.Usehight     = 0;
                                hua.AmtEndtime   = DateTime.Now.Date.AddDays(31).AddSeconds(-1); // DateTime.Parse(hat.ActEndtime.ToString());
                                hua.AmtUses      = 1;                                            //使用要求 1单独使用,2组合使用
                                hua.UseState     = 0;                                            //使用状态 0 未使用 1 已使用 2已过期 3 锁定中
                                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        = "11月活动实名注册送2%加息券";
                                hua.UseLifeLoan  = "3-0";
                                //待添加加息券使用标的
                                ef.hx_UserAct.Add(hua);
                                int i = ef.SaveChanges();
                                if (i > 0)
                                {
                                    log += "<br>2%加息券奖励发放成功";
                                    if (hua.Amt != null && hua.Amt > 0)
                                    {
                                        #region MyRegion  发送系统消息
                                        string MContext = string.Format("尊敬的用户:您实名注册成功,获得{0}{1}如有问题可咨询创利投的客服!", hua.Amt.ToString(), GetBunusDescription(hua.RewTypeID));
                                        AddSytemMessage(registerid, "邀请好友注册奖励", MContext);
                                        #endregion
                                    }
                                }
                            }
                            LogInfo.WriteLog(log);
                        }
                        #endregion
                    }
                }
            }
            #endregion
        }
Esempio n. 19
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);
        }
Esempio n. 20
0
        /// <summary>
        /// 按照投资金额进行红包或加息券奖励发放(常规投资 红包或加息券) 未记录系统信息及奖励流水
        /// 返回用户活动表hx_UserAct 对象
        /// </summary>
        /// <param name="mcp">规则对象</param>
        ///  <param name="hua">活动项目表</param>
        ///  <param name="Registerid">用户id</param>
        ///  <param name="investAmt">投资金额</param>
        protected List <hx_UserAct> OPMcoupon(Mcoupon mcp, hx_ActivityTable hat, int Registerid, decimal investAmt)
        {
            List <hx_UserAct>    t   = new List <hx_UserAct>();
            List <Msplitarr>     msp = new List <Msplitarr>();
            List <MAmtList>      mat = new List <MAmtList>();
            JavaScriptSerializer js  = new JavaScriptSerializer();

            if (mcp.rule == 1) //统一赠送
            {
                #region 统一赠送
                t.Clear();
                string msplitarrc = "";
                //经过比对拆分不拆分代码逻辑一样,所以合并处理
                //if (mcp.ISsplit == 1)
                try
                {
                    msplitarrc = mcp.Msplitarr.SerializeJSON();
                    msp        = js.Deserialize <List <Msplitarr> >(msplitarrc);
                }
                catch
                {
                    msp = null;
                }
                foreach (var item in msp)
                {
                    hx_UserAct hua = new hx_UserAct();
                    hua.ActTypeId  = hat.ActTypeId;
                    hua.registerid = Registerid;
                    hua.RewTypeID  = hat.RewTypeID;
                    hua.ActID      = hat.ActID;
                    hua.Amt        = item.cashAmt;
                    hua.Uselower   = item.startAmt;
                    hua.Usehight   = item.endAmt;
                    if (item.validity > 0) //有效天数大于0
                    {
                        hua.AmtEndtime = DateTime.Now.Date.AddDays(item.validity + 1).AddSeconds(-1);
                    }
                    else
                    {
                        hua.AmtEndtime = item.endTime;
                    }

                    hua.AmtUses      = 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  = string.IsNullOrWhiteSpace(item.UseLifeLoan) ? "" : item.UseLifeLoan;
                    ef.hx_UserAct.Add(hua);
                    int i = ef.SaveChanges();
                    t.Add(hua);
                }
                #endregion
            }
            else if (mcp.rule == 2)//按投资赠送,需要判断投资金额区间,不支持拆分 只赠送一张代金券或加息券,使用限制按照金额在拆分中匹配
            {
                #region  投资赠送
                hx_UserAct hua = new hx_UserAct();
                t.Clear();
                string msplitarrc = "";
                hua.ActTypeId  = hat.ActTypeId;
                hua.registerid = Registerid;
                hua.RewTypeID  = hat.RewTypeID;
                hua.ActID      = hat.ActID;
                try
                {
                    msplitarrc = mcp.Msplitarr.SerializeJSON();
                    msp        = js.Deserialize <List <Msplitarr> >(msplitarrc);
                }
                catch
                {
                    msp = null;
                }
                hua.Amt          = GetCouponAmtByInvestAmt(mcp, investAmt);
                hua.Uselower     = GetCouponUseConByAmt(msp, decimal.Parse(hua.Amt.ToString()), 0);
                hua.Usehight     = GetCouponUseConByAmt(msp, decimal.Parse(hua.Amt.ToString()), 1);
                hua.AmtEndtime   = GetCouponEndTimeByAmt(msp, decimal.Parse(hua.Amt.ToString()));
                hua.AmtUses      = 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  = msp == null ? "" : msp[0].UseLifeLoan;
                if (hua.Uselower >= 0 || hua.Usehight >= 0 || hua.Amt <= 0)
                {
                    ef.hx_UserAct.Add(hua);
                    int i = ef.SaveChanges();
                    if (i > 0)
                    {
                        t.Add(hua);
                    }
                }
                #endregion
            }

            else if (mcp.rule == 3) //随机赠送,需要判断投资金额区间,不支持拆分 只赠送一张代金券或加息券,使用限制按照金额在拆分中匹配
            {
                #region 随机赠送
                t.Clear();
                foreach (var item in mcp.MAmtList)
                {
                    if (item.startAmt <= investAmt && (item.endAmt == 0 || item.endAmt >= investAmt))
                    {
                        for (int i = 0; i < item.num; i++)
                        {
                            hx_UserAct hua        = new hx_UserAct();
                            string     msplitarrc = "";
                            hua.ActTypeId  = hat.ActTypeId;
                            hua.registerid = Registerid;
                            hua.RewTypeID  = hat.RewTypeID;
                            hua.ActID      = hat.ActID;
                            try
                            {
                                msplitarrc = mcp.Msplitarr.SerializeJSON();
                                msp        = js.Deserialize <List <Msplitarr> >(msplitarrc);
                            }
                            catch
                            {
                                msp = null;
                            }
                            hua.Amt        = Utils.GetActRandom(item.Amtstr);
                            hua.Uselower   = GetCouponUseConByAmt(msp, decimal.Parse(hua.Amt.ToString()), 0);
                            hua.Usehight   = GetCouponUseConByAmt(msp, decimal.Parse(hua.Amt.ToString()), 1);
                            hua.AmtEndtime = GetCouponEndTimeByAmt(msp, decimal.Parse(hua.Amt.ToString()));

                            hua.AmtUses      = 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  = msp == null ? "" : msp[0].UseLifeLoan;
                            if (hua.Uselower >= 0 || hua.Usehight >= 0 || hua.Amt <= 0)
                            {
                                ef.hx_UserAct.Add(hua);
                                int c1 = ef.SaveChanges();
                                if (c1 > 0)
                                {
                                    t.Add(hua);
                                }
                            }
                        }
                        break;
                    }
                }
                #endregion
            }
            return(t);
        }