Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public bool SendCash(int actID, int Registerid)
        {
            bool t = false;
            chuangtouEntities ef  = new chuangtouEntities();
            hx_ActivityTable  hat = new ActFacade().GetActivityModel(actID); //GetActTableInfo(ActTypeId, ActUser, 1);

            if (hat != null)
            {
                //判是否过期
                if (hat.ActStarttime <= DateTime.Now && DateTime.Now <= hat.ActEndtime)
                {
                    string               ActRule = hat.ActRule;
                    List <MAmtList>      mlist   = new List <MAmtList>();
                    JavaScriptSerializer js      = new JavaScriptSerializer();
                    //MActCash mc = new MActCash();
                    Mcoupon mcp = new Mcoupon();
                    mcp = js.Deserialize <Mcoupon>(ActRule);
                    //mlist = js.Deserialize<List<MAmtList>>(ActRule);

                    //检查分发奖励是否超过顶限,如果超过直接跳过
                    //int TopNum = B_usercenter.GetTopNum(hat.ActID);
                    //项目已经发放的金额
                    //decimal totalAmt = B_usercenter.GetTopAmtCount(hat.ActID);
                    //第一次投资获取对应奖励
                    decimal actamt = mcp.cash;//GetActAmt(mc, InvestAmt, TopNum);

                    //if (mc.TopAmt > totalAmt && mc.TopNum > TopNum)
                    //{

                    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     = 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;
                        hua.Title        = hat.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)
                                {
                                    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 流水信息
                                                    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 奖励流水
                                                    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(hua.ActID.ToString());
                                                    mbaw.membertable_registerid = int.Parse(dt.Rows[0]["registerid"].ToString());
                                                    mbaw.income             = decimal.Parse(retf.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() + ":您好!恭喜您成功" + hat.ActName + ",现金奖励 " + retf.TransAmt + "元。如有问题可咨询创利投的客服!";
                                                    pm.PubTime  = dti;
                                                    B_usercenter.AddMessage(pm);
                                                    #endregion
                                                }
                                            }

                                            t = true;
                                        }
                                        #endregion
                                    }
                                }
                            }
                        }
                    }
                    //}
                }
            }


            return(t);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 常规活动 现金奖励 发放(奖励流水 资金流水 系统消息)
        /// </summary>
        /// <param name="registerid">用户id</param>
        /// <param name="investAmt">投资金额</param>
        /// <param name="hat">活动对象</param>
        /// <param name="bid_records_id">投标记录id</param>
        /// <returns>bool 是否发放成功</returns>
        private bool GeneralActCash(int Registerid, decimal InvestAmt, hx_ActivityTable hat, int bid_records_id, int lifeLoan = 0)
        {
            bool t = false;

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

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

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

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

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

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

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

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


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

            LogInfo.WriteLog("后台平台向用户活动转账后---1台验签:" + ret.ToString());

            LogInfo.WriteLog("后台平台向用户活动转账后---1台主动投标返回报文:" + FastJSON.toJOSN(p));


            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();
                             *
                             *
                             *  //int  biyaouserid= DbHelperSQL.Execint("");
                             *
                             *
                             *
                             #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
                }
                else
                {
                }
            }

            return(Content(str));
        }