Esempio n. 1
0
        /// <summary>
        /// 5月任性赚,“三重好礼”送不停   活动时间 2015年5月4日—2015年5月31日
        /// </summary>
        ///

        public void MayPan(decimal TrAMT, int month, int Reg)
        {
            if (month == 3 || month == 6)  //只有3个月和6个月才生成奖励记录
            {
                M_Activity_schedule ma = new M_Activity_schedule();
                B_Activity_schedule ba = new B_Activity_schedule();

                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 nowdate = DateTime.Now;

                DateTime startdate = new DateTime(2015, 06, 26, 00, 00, 00);
                DateTime enddate   = new DateTime(2015, 07, 31, 23, 59, 59);

                if (startdate < nowdate && nowdate < enddate) //在有效范围之内则执行活动计划
                {
                    ma = ba.GetModel(8);                      //获取奖励对象

                    // ma = ba.GetModel(10);  //获取奖励对象
                    //
                    decimal rewardamt = GetAmt(TrAMT, month);
                    mb.activity_schedule_id   = ma.activity_schedule_id;
                    mb.membertable_registerid = Reg;
                    mb.activity_schedule_name = ma.activity_schedule_name;
                    mb.amount_of_reward       = rewardamt;
                    mb.use_lower_limit        = ma.use_lower_limit;
                    mb.reward     = ma.reward;
                    mb.start_date = nowdate;
                    mb.end_date   = ma.end_date;
                    mb.entry_time = nowdate;
                    int bbid = bb.Add(mb);
                    if (bbid > 0) //奖励记录成功后插入明细记录
                    {
                        mbaw.bonus_account_id       = bbid;
                        mbaw.membertable_registerid = Reg;
                        mbaw.income             = rewardamt;
                        mbaw.expenditure        = 0.00M;
                        mbaw.time_of_occurrence = mb.entry_time;
                        // mbaw.
                        mbaw.award_description = "7月“投资拿现金大奖”  活动时间 2015年7月1日—2015年7月31日 投资" + TrAMT.ToString() + "周期" + month.ToString() + "月 奖励" + rewardamt.ToString();
                        mbaw.water_type        = 0;
                        bbaw.Add(mbaw);
                    }
                }
            }
        }
Esempio n. 2
0
        //
        //
        /// <summary>
        /// 生成奖励流水(抵扣券、现金),加息券不记录
        /// </summary>
        /// <param name="UserActid">用户奖励id</param>
        /// <param name="registerid">用户id</param>
        /// <param name="bonusAmt">奖励金额</param>
        /// <param name="awardDescription">奖励描述</param>
        /// <param name="waterType">waterType 默认为0,当为邀请奖励时,存放被邀请人的id</param>
        /// <returns></returns>
        protected bool AddBonusAccoutWater(int UserActid, int registerid, decimal bonusAmt, string awardDescription, int waterType = 0)
        {
            B_bonus_account_water bbaw = new B_bonus_account_water();
            M_bonus_account_water mbaw = new M_bonus_account_water();

            mbaw.bonus_account_id       = UserActid;
            mbaw.membertable_registerid = registerid;
            mbaw.income             = bonusAmt;
            mbaw.expenditure        = 0.00M;
            mbaw.time_of_occurrence = DateTime.Now;
            mbaw.award_description  = awardDescription;
            mbaw.water_type         = waterType;
            bbaw.Add(mbaw);
            return(true);
        }
Esempio 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);
        }
Esempio n. 4
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. 5
0
        /// <summary>
        /// 12月份元旦活动转账专用 获取活动信息  短信通知部分需要更改
        /// </summary>
        /// <param name="mc"></param>
        /// <param name="TrAMT"></param>
        /// <param name="TransAmt"></param>
        public void YuandaiToUserTransfer(M_CashAwards mc, decimal TrAMT, decimal TransAmt)
        {
            M_Transfer m = new M_Transfer();

            m.Version = "10";
            m.CmdId   = "Transfer";

            // m.OrdId = Utils.Createcode();

            m.OrdId     = mc.OrdId.ToString();
            m.OutCustId = Utils.GetMerCustID();
            m.OutAcctId = "MDT000001";
            m.TransAmt  = mc.Amounts.ToString("0.00");
            m.InCustId  = mc.UsrCustId;
            m.BgRetUrl  = Utils.GetRe_url("Thirdparty/ToUserTransfer.aspx");
            m.MerPriv   = mc.proid.ToString();


            StringBuilder chkVal = new StringBuilder();

            chkVal.Append(m.Version);
            chkVal.Append(m.CmdId);
            chkVal.Append(m.OrdId);
            chkVal.Append(m.OutCustId);
            chkVal.Append(m.OutAcctId);
            chkVal.Append(m.TransAmt);
            chkVal.Append(m.InCustId);
            chkVal.Append(m.RetUrl);
            chkVal.Append(m.BgRetUrl);
            chkVal.Append(m.MerPriv);

            string chkv = chkVal.ToString();

            LogInfo.WriteLog("12月份元旦活动平台向用户活动转账加签chkv字符:" + chkv);

            //私钥文件的位置(这里是放在了站点的根目录下)
            string merKeyFile = AppDomain.CurrentDomain.BaseDirectory + Utils.GetMerPr();
            //需要指定提交字符串的长度
            int           len        = Encoding.UTF8.GetBytes(chkv).Length;
            StringBuilder sbChkValue = new StringBuilder(256);
            //加签
            int str = DllInterop.SignMsg(Utils.GetMerId(), merKeyFile, chkv, len, sbChkValue);

            LogInfo.WriteLog("12月份元旦活动平台向用户活动转账加签字符:" + str.ToString());

            m.ChkValue = sbChkValue.ToString();

            LogInfo.WriteLog("12月份元旦活动平台向用户活动转账提交信息:" + FastJSON.toJOSN(m));
            LogInfo.WriteLog("ChkValue:" + m.ChkValue);


            using (var client = new WebClient())
            {
                var values = new NameValueCollection();
                values.Add("Version", m.Version);
                values.Add("CmdId", m.CmdId);
                values.Add("OrdId", m.OrdId);
                values.Add("OutCustId", m.OutCustId);
                values.Add("OutAcctId", m.OutAcctId);
                values.Add("TransAmt", m.TransAmt);
                values.Add("InCustId", m.InCustId);
                values.Add("InAcctId", m.InAcctId);
                values.Add("RetUrl", m.RetUrl);
                values.Add("BgRetUrl", m.BgRetUrl);
                values.Add("MerPriv", m.MerPriv);
                values.Add("ChkValue", m.ChkValue);
                string url = Utils.GetChinapnrUrl();
                //同步发送form表单请求
                byte[] result = client.UploadValues(url, "POST", values);
                var    retStr = Encoding.UTF8.GetString(result);
                // Response.Write(retStr);
                LogInfo.WriteLog("12月份元旦活动自动扣款转账(商户用)返回报文" + retStr);
                ReTransfer reg = new ReTransfer();

                var           retloan = (ReTransfer)FastJSON.ToObject(retStr, reg);
                StringBuilder builder = new StringBuilder();
                builder.Append(retloan.CmdId);
                builder.Append(retloan.RespCode);
                builder.Append(retloan.OrdId);
                builder.Append(retloan.OutCustId);
                builder.Append(retloan.OutAcctId);
                builder.Append(retloan.TransAmt);
                builder.Append(retloan.InCustId);
                builder.Append(retloan.InAcctId);
                builder.Append(HttpUtility.UrlDecode(retloan.RetUrl));
                builder.Append(HttpUtility.UrlDecode(retloan.BgRetUrl));
                builder.Append(retloan.MerPriv);
                var msg = builder.ToString();

                LogInfo.WriteLog("12月份元旦活动平台向用户活动转账返回参数:" + msg);
                //验签
                string pgPubkFile = AppDomain.CurrentDomain.BaseDirectory + Utils.GetPgPubk();
                int    ret        = DllInterop.VeriSignMsg(pgPubkFile, msg, msg.Length, retloan.ChkValue);

                LogInfo.WriteLog("12月份元旦活动平台向用户活动转账验签ret:" + ret.ToString());
                if (ret == 0)
                {
                    if (retloan.RespCode == "000")
                    {
                        /*
                         * string sql = "update hx_CashAwards  set  OrdIdstate=3  where OrdIdstate=1 and OrdId=" + retloan.OrdId + " and  proid =" + retloan.MerPriv;
                         * DbHelperSQL.RunSql(sql);
                         * LogInfo.WriteLog("平台向用户活动转账验签更新"+ sql);
                         */
                        // Response.Write(retloan.RespCode + "  <br> ");
                        B_usercenter BUC = new B_usercenter();

                        int dint = BUC.UpateAwa(retloan);
                        LogInfo.WriteLog("12月份元旦活动事务执行返回:" + dint.ToString());
                        if (dint > 0)
                        {
                            B_member_table dmt = new B_member_table();

                            string    sql = "SELECT registerid,username,mobile  from hx_member_table where UsrCustId='" + retloan.InCustId + "'";
                            DataTable dt  = DbHelperSQL.GET_DataTable_List(sql);

                            if (dt.Rows.Count > 0)
                            {
                                //活动奖历
                                M_Activity_schedule ma = new M_Activity_schedule();
                                B_Activity_schedule ba = new B_Activity_schedule();
                                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;


                                // ma = ba.GetModel(16);  //测试平台
                                ma = ba.GetModel(15);  //获取奖励对象


                                mb.activity_schedule_id   = ma.activity_schedule_id;
                                mb.membertable_registerid = int.Parse(dt.Rows[0]["registerid"].ToString());
                                mb.activity_schedule_name = ma.activity_schedule_name;
                                mb.amount_of_reward       = decimal.Parse(retloan.TransAmt);
                                mb.use_lower_limit        = ma.use_lower_limit;
                                mb.reward       = ma.reward;
                                mb.start_date   = dte;
                                mb.end_date     = dte;
                                mb.entry_time   = dte;
                                mb.reward_state = 3;
                                int bbid = bb.Add(mb);
                                if (bbid > 0) //奖励记录成功后插入明细记录
                                {
                                    mbaw.bonus_account_id       = bbid;
                                    mbaw.membertable_registerid = mb.membertable_registerid;
                                    mbaw.income             = mb.amount_of_reward;
                                    mbaw.expenditure        = 0.00M;
                                    mbaw.time_of_occurrence = mb.entry_time;
                                    // mbaw.
                                    mbaw.award_description = "已汇入个人账户";
                                    mbaw.water_type        = 0;
                                    bbaw.Add(mbaw);


                                    //短信通知

                                    #region MyRegion                                 //短信通知
                                    string contxt = Utils.GetMSMEmailContext(20, 1); // 获取注册成功邮件内容

                                    StringBuilder sbsms = new StringBuilder(contxt);

                                    sbsms = sbsms.Replace("#USERANEM#", dt.Rows[0]["username"].ToString());

                                    sbsms = sbsms.Replace("#MONEY#", TrAMT.ToString("0.00"));

                                    sbsms = sbsms.Replace("#AMTM#", TransAmt.ToString("0.00"));


                                    string mobile = dt.Rows[0]["mobile"].ToString();

                                    M_td_SMS_record psms    = new M_td_SMS_record();
                                    B_td_SMS_record osms    = new B_td_SMS_record();
                                    int             smstype = (int)Enum.Parse(typeof(EnumSMSType), EnumSMSType.活动奖励.ToString());
                                    psms.phone_number = mobile;
                                    psms.sendtime     = DateTime.Now;
                                    psms.senduserid   = int.Parse(dt.Rows[0]["registerid"].ToString());
                                    psms.smstype      = smstype;
                                    psms.smscontext   = sbsms.ToString();
                                    psms.orderid      = SendSMS.Send_SMS(mobile, sbsms.ToString());
                                    psms.vcode        = "";

                                    osms.Add(psms);
                                    #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   = "投资成功现金奖励";
                                pm.MContext = "尊敬的用户" + dt.Rows[0]["username"].ToString() + ":您好!恭喜您成功投资了项目,现金奖励 " + retloan.TransAmt + "元。如有问题可咨询创利投的客服!";
                                pm.PubTime  = dti;
                                B_usercenter.AddMessage(pm);
                                #endregion
                            }

                            LogInfo.WriteLog("12月份元旦活动 平台向用户活动转账验签更新成功,需要写入消息");
                        }
                    }
                    else
                    {
                        //Response.Write(HttpUtility.UrlDecode(retloan.));
                    }
                }
            }
        }
Esempio n. 6
0
        public string Register(string Validatecode, string userpassword1, string mobile1, string username1, bool realMobileUser = false)
        {
            Utils.SetSYSDateTimeFormat();
            string json = "";
            //注册奖励
            M_Activity_schedule ma = new M_Activity_schedule();
            B_Activity_schedule ba = new B_Activity_schedule();

            B_member_table o = new B_member_table();
            M_member_table p = new M_member_table();

            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();

            string email1   = "";
            string strvcode = realMobileUser ? "y" : ck.GetVcode(Validatecode, mobile1);
            string tid      = "";//富爸爸参数uid //Utils.GetCookie("Cooperation", "tid");//渠道来源ID
            string invcode  = Utils.GetInvCode();

            // 用户邀请用户关系存在的时候,不走 新渠道机制(channel)
            #region  道
            //渠道的cookie
            var    cc_keyValue  = Utils.GetInvCookie("channel");
            string cInvitedcode = string.Empty;
            if (string.IsNullOrEmpty(invcode) && cc_keyValue.Count != 0)
            {
                cInvitedcode = cc_keyValue["Invitedcode"];
                var channelInvitedCode = ef.hx_Channel.Where(c => c.ChannelName == "fubaba").Select(c => c.Invitedcode).FirstOrDefault();
                if (cInvitedcode.Trim() == channelInvitedCode)
                {
                    tid = cc_keyValue["uid"];
                }
            }
            #endregion
            int ch = 0;
            if (Utils.GetCookie("Cooperation", "ch") != "")
            {
                try
                {
                    ch = int.Parse(Utils.GetCookie("Cooperation", "ch"));//渠道来源
                }
                catch
                {
                    ch = 0;
                }
            }

            if (ch == 0)
            {
                if (invcode != "")
                {
                    ch = 1;
                }
            }

            if (strvcode != null)
            {
                if (strvcode == "y")
                {
                    string checkMob = ck.checkmobile(mobile1, 0);

                    if (checkMob != "y")
                    {
                        json = @" {""rs""    : ""n"", ""error""      :  ""手机号已被注册!""}";
                        return(json);
                    }

                    p.username            = username1;
                    p.password            = DESEncrypt.Encrypt(userpassword1, ConfigurationManager.AppSettings["webp"].ToString());
                    p.mobile              = mobile1;
                    p.email               = email1;
                    p.usertypes           = 0;
                    p.invitedcode         = Calculator.Getinvitedcode();
                    p.ismobile            = 1;
                    p.Channelsource       = ch;
                    p.Tid                 = tid;
                    p.channel_invitedcode = cInvitedcode;
                    LogInfo.WriteLog("用户注册内容:" + FastJSON.toJOSN(p) + "     IP:" + Utils.GetRealIP());
                    int uid = o.Add(p);
                    if (uid > 0)
                    {
                        CheckXiCai(p.mobile, cInvitedcode);
                        //if (tid != "")
                        //{
                        //    Utils.GetCoopAPI(tid, uid.ToString(), 1);
                        //}
                        string keys = DESEncrypt.Encrypt(uid.ToString(), ConfigurationManager.AppSettings["webp"].ToString());

                        string keys1 = DESEncrypt.Encrypt(username1, ConfigurationManager.AppSettings["webp"].ToString());

                        M_td_SMS_record pm        = new M_td_SMS_record();
                        B_td_SMS_record om        = new B_td_SMS_record();
                        int             smstype   = (int)Enum.Parse(typeof(EnumSMSType), EnumSMSType.注册成功.ToString());
                        string          smscontxt = Utils.GetMSMEmailContext(18, 1); // 获取注册成功邮件内容
                        StringBuilder   sbsms     = new StringBuilder(smscontxt);
                        string          mobile    = mobile1;
                        sbsms           = sbsms.Replace("#USERANEM#", p.username.ToString());
                        pm.phone_number = mobile;
                        pm.sendtime     = DateTime.Now;
                        pm.senduserid   = uid;
                        pm.smstype      = smstype;
                        pm.smscontext   = sbsms.ToString();
                        pm.orderid      = SendSMS.Send_SMS(mobile, sbsms.ToString());
                        pm.vcode        = "";
                        om.Add(pm);

                        M_login mlogin = new M_login();
                        mlogin.userid   = uid;
                        mlogin.username = p.username;
                        mlogin.codeno   = Utils.SetSessioncode();
                        int remember = 0;
                        if (Utils.LoginWriteSession(mlogin, remember) > 0)
                        {
                            string sql = "update hx_member_table set lastlogintime='" + DateTime.Now + "',lastloginIP='" + Utils.GetRealIP() + "' where registerid=" + uid.ToString();
                            LogInfo.WriteLog(sql);
                            DbHelperSQL.ExecuteSql(sql);
                        }


                        #region MyRegion   //记录邀请关系

                        LogInfo.WriteLog("注册:邀请码:" + invcode);
                        if (invcode != "")
                        {
                            string codesql = "SELECT invcode from  hx_td_Userinvitation where  invpersonid=" + uid.ToString();//查询本人是否已经被邀请注册过  invcode='" + invcode + "' and
                            LogInfo.WriteLog("codesql2:" + codesql);
                            DataTable dtcode = DbHelperSQL.GET_DataTable_List(codesql);
                            if (dtcode.Rows.Count == 0)
                            {
                                M_td_Userinvitation myao = new M_td_Userinvitation();
                                B_td_Userinvitation dyao = new B_td_Userinvitation();
                                int yaouids = Utils.GetCodeUid();
                                myao.invcode       = invcode;
                                myao.invtime       = DateTime.Now;
                                myao.invpersonid   = uid;
                                myao.Invpeopleid   = yaouids;
                                myao.InvitesStates = 0;
                                myao.Invitereward  = 0;
                                int myaoint = dyao.Add(myao);
                            }
                        }
                        #endregion MyRegion   //记录邀请关系

                        json = @" {""rs""    : ""y"", ""url""      :  ""/""}";
                        string temstr = "/opening_account/Index/" + uid.ToString();
                        json = json.Replace("/", temstr);
                        return(json);
                    }
                    else
                    {
                        json = @" {""rs""    : ""n"", ""error""      :  ""注册失败!""}";
                        return(json);
                    }
                }
                else
                {
                    json = @" {""rs""    : ""n"", ""error""      :  ""验证码不对!""}";
                    return(json);
                }
            }
            else
            {
                json = @" {""rs""    : ""n"", ""error""      :  ""验证码不存在或过期!""}";
            }
            return(json);
        }
Esempio n. 7
0
        //汇付模拟发起的请求,没有携带用户的cookie,造成邀请丢失,邀请关系逻辑迁移至注册成功
        /// <summary>
        /// 注册成功汇付返回通知
        /// </summary>
        /// <returns></returns>
        public ActionResult Succ_Registered()
        {
            int            it        = -10000;
            string         username  = "";
            string         useremail = "";
            ReUserRegister m         = new ReUserRegister();

            m.CmdId     = DNTRequest.GetString("CmdId");
            m.RespCode  = DNTRequest.GetString("RespCode");
            m.RespDesc  = DNTRequest.GetString("RespDesc");
            m.MerCustId = DNTRequest.GetString("MerCustId");
            m.UsrId     = DNTRequest.GetString("UsrId");
            m.UsrCustId = DNTRequest.GetString("UsrCustId");
            m.BgRetUrl  = DNTRequest.GetString("BgRetUrl");
            m.TrxId     = DNTRequest.GetString("TrxId");
            m.RetUrl    = DNTRequest.GetString("RetUrl");
            m.MerPriv   = DNTRequest.GetString("MerPriv");
            m.IdType    = DNTRequest.GetString("IdType");
            m.IdNo      = DNTRequest.GetString("IdNo");
            m.UsrMp     = DNTRequest.GetString("UsrMp");
            useremail   = DNTRequest.GetString("UsrEmail");
            m.UsrEmail  = useremail;
            username    = HttpUtility.UrlDecode(DNTRequest.GetString("UsrName"));
            m.UsrName   = username;
            m.ChkValue  = DNTRequest.GetString("ChkValue");
            string        log    = "注册开户返回报文:" + FastJSON.toJOSN(m);
            StringBuilder chkVal = new StringBuilder();

            chkVal.Append(m.CmdId);
            chkVal.Append(m.RespCode);
            chkVal.Append(m.MerCustId);
            chkVal.Append(m.UsrId);
            chkVal.Append(m.UsrCustId);
            chkVal.Append(m.BgRetUrl);
            chkVal.Append(m.TrxId);
            chkVal.Append(m.RetUrl);
            chkVal.Append(m.MerPriv);
            string chkv = chkVal.ToString();
            //私钥文件的位置(这里是放在了站点的根目录下)
            string merKeyFile = AppDomain.CurrentDomain.BaseDirectory + Utils.GetPgPubk();
            int    ret        = DllInterop.VeriSignMsg(merKeyFile, chkv, chkv.Length, m.ChkValue);

            log += ";ret:" + ret;
            if (ret == 0)
            {
                B_member_table ob = new B_member_table();
                M_member_table pm = new M_member_table();
                if (m.RespCode == "000")
                {
                    //为避免重复调用,增加缓存校验
                    string cachename = "UserRegister" + m.TrxId;
                    if (Utils.GeTThirdCache(cachename) == 0)
                    {
                        Utils.SetThirdCache(cachename);
                        M_bonus_account_water mbaw = new M_bonus_account_water();
                        B_bonus_account_water bbaw = new B_bonus_account_water();
                        B_usercenter          b    = new B_usercenter();
                        it   = b.Succ_Reg(m);
                        log += ";汇付开户成功后进行用户数据更新返回:" + it;
                        if (it > 0)
                        {
                            pm = ob.GetModel(Utils.GetUserSplit(m.UsrId));
                            ViewBag.registerid = pm.registerid;

                            //新人注册奖励
                            ActFacade act = new ActFacade();
                            log += ";注册ID:" + pm.registerid;
                            act.SendBonusAfterRegister(pm.registerid, EnumCommon.E_hx_ActivityTable.E_ActTargetPlatform.web);
                        }
                        else
                        {
                            /*第三方成功,本地服务器操作失败*/
                        }
                    }
                }
            }
            else
            {
                log += "验签不成功";
                /*验签不成功*/
            }
            LogInfo.WriteLog(log);
            return(View(m));
        }
Esempio n. 8
0
        public string Register(string Validatecode, string userpassword1, string mobile1, string username1, bool realMobileUser = false)
        {
            Utils.SetSYSDateTimeFormat();
            string json = "";
            //注册奖历
            M_Activity_schedule ma = new M_Activity_schedule();
            B_Activity_schedule ba = new B_Activity_schedule();

            B_member_table o = new B_member_table();
            M_member_table p = new M_member_table();

            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();
            string email1   = "";
            string strvcode = realMobileUser ? "y" : ck.GetVcode(Validatecode, mobile1);

            //string strvcode = "y";
            if ((Settings.Instance.SiteDomain.IndexOf(PublicURL.NewWXUrl) >= 0))
            {
                strvcode = ck.GetVcodeWX(Validatecode, mobile1);
            }
            string tid = Utils.GetCookie("Cooperation", "tid");
            int    ch  = 0;

            string invcode = Utils.GetInvCode();

            #region  道
            //渠道的cookie
            var    cc_keyValue  = Utils.GetInvCookie("channel");
            string cInvitedcode = string.Empty;
            if (string.IsNullOrEmpty(invcode) && cc_keyValue.Count != 0)
            {
                cInvitedcode = cc_keyValue["Invitedcode"];
            }
            #endregion

            if (Utils.GetCookie("Cooperation", "ch") != "")
            {
                try
                {
                    ch = int.Parse(Utils.GetCookie("Cooperation", "ch"));
                }
                catch
                {
                    ch = 0;
                }
            }

            if (ch == 0)
            {
                if (invcode != "")
                {
                    ch = 3;
                }
                else
                {
                    ch = 2;
                }
            }

            if (realMobileUser || strvcode != null)
            {
                if (realMobileUser || strvcode == "y")
                {
                    string checkMob = ck.checkmobile(mobile1, 0);

                    if (checkMob != "y")
                    {
                        json = @" {""rs""    : ""n"", ""error""      :  ""手机号已被注册!""}";
                        return(json);
                    }

                    p.username      = username1;
                    p.password      = DESEncrypt.Encrypt(userpassword1, ConfigurationManager.AppSettings["webp"].ToString());
                    p.mobile        = mobile1;
                    p.email         = email1;
                    p.usertypes     = 0;
                    p.invitedcode   = Calculator.Getinvitedcode();
                    p.ismobile      = 1;
                    p.Channelsource = ch;
                    p.Tid           = tid;

                    p.channel_invitedcode = cInvitedcode;
                    LogInfo.WriteLog("用户注册内容:" + FastJSON.toJOSN(p) + "     IP:" + Utils.GetRealIP());
                    int uid = o.Add(p);//注册成功返回会员ID
                    if (uid > 0)
                    {
                        //记录用户信息到活动流量发放表里  2016.10.21-31日
                        //string CookCode = Utils.GetCookie("CookCode");
                        //if (!string.IsNullOrWhiteSpace(CookCode))
                        //{
                        //    if (CookCode== "liumi")
                        //    {
                        //        AddReceiveInfo(uid);
                        //    }

                        //}

                        if (tid != "")
                        {
                            //    Utils.GetCoopAPI(tid, uid.ToString(), 1);
                        }
                        string keys = DESEncrypt.Encrypt(uid.ToString(), ConfigurationManager.AppSettings["webp"].ToString());

                        string keys1 = DESEncrypt.Encrypt(username1, ConfigurationManager.AppSettings["webp"].ToString());

                        M_td_SMS_record pm        = new M_td_SMS_record();
                        B_td_SMS_record om        = new B_td_SMS_record();
                        int             smstype   = (int)Enum.Parse(typeof(EnumSMSType), EnumSMSType.注册成功.ToString());
                        string          smscontxt = Utils.GetMSMEmailContext(18, 1); // 获取注册成功邮件内容
                        StringBuilder   sbsms     = new StringBuilder(smscontxt);
                        string          mobile    = mobile1;
                        sbsms           = sbsms.Replace("#USERANEM#", p.username.ToString());
                        pm.phone_number = mobile;
                        pm.sendtime     = DateTime.Now;
                        pm.senduserid   = uid;
                        pm.smstype      = smstype;
                        pm.smscontext   = sbsms.ToString();
                        pm.orderid      = SendSMS.Send_SMS(mobile, sbsms.ToString());
                        pm.vcode        = "";
                        om.Add(pm);

                        M_login mlogin = new M_login();
                        mlogin.userid   = uid;
                        mlogin.username = p.username;
                        mlogin.codeno   = Utils.SetSessioncode();
                        int remember = 0;


                        FormsAuthentication.SignOut();

                        Utils.AddLoginCache(p.username, mlogin);

                        string sql = "update hx_member_table set lastlogintime='" + DateTime.Now + "',lastloginIP='" + Utils.GetRealIP() + "' where registerid=" + uid.ToString();
                        DbHelperSQL.ExecuteSql(sql);

                        #region MyRegion   //记录邀请关系
                        LogInfo.WriteLog("注册:邀请码:" + invcode);
                        if (invcode != "")
                        {
                            string codesql = "SELECT invcode from  hx_td_Userinvitation where  invpersonid=" + uid.ToString();//查询本人是否已经被邀请注册过  invcode='" + invcode + "' and
                            LogInfo.WriteLog("codesql2:" + codesql);
                            DataTable dtcode = DbHelperSQL.GET_DataTable_List(codesql);
                            if (dtcode.Rows.Count == 0)
                            {
                                M_td_Userinvitation myao = new M_td_Userinvitation();
                                B_td_Userinvitation dyao = new B_td_Userinvitation();
                                int yaouids = Utils.GetCodeUid();
                                myao.invcode       = invcode;
                                myao.invtime       = DateTime.Now;
                                myao.invpersonid   = uid;
                                myao.Invpeopleid   = yaouids;
                                myao.InvitesStates = 0;
                                myao.Invitereward  = 0;
                                int myaoint = dyao.Add(myao);
                            }
                        }
                        #endregion MyRegion   //记录邀请关系

                        json = @" {""rs""    : ""y"", ""url""      :  ""/index.html"",""uid"":" + uid + "}";
                        string temstr = "/opening_account/Index/" + uid.ToString();
                        json = json.Replace("/index.html", temstr);
                        return(json);
                    }
                    else
                    {
                        json = @" {""rs""    : ""n"", ""error""      :  ""注册失败!""}";
                        return(json);
                    }
                }
                else
                {
                    json = @" {""rs""    : ""n"", ""error""      :  ""验证码不对!""}";
                    return(json);
                }
            }
            else
            {
                json = @" {""rs""    : ""n"", ""error""      :  ""验证码不存在或过期!""}";
            }
            return(json);
        }
Esempio n. 9
0
        /// <summary>
        /// 邀请奖历 投资成功奖励
        /// </summary>
        /// <param name="dt"></param>
        protected internal void SendBonusForInviteAfterInvest(DataTable dt, string targetPlatform)
        //(int registerid, string invcode, int invcount, decimal investAmt, string userName, string borrowing_title, decimal bonusAmt)
        {
            if (dt.Rows.Count <= 0)
            {
                return;
            }
            //投资金额
            decimal investAmt      = decimal.Parse(dt.Rows[0]["investment_amount"].ToString());
            int     registerid     = int.Parse(dt.Rows[0]["investor_registerid"].ToString()); //投资人ID
            int     bid_records_id = int.Parse(dt.Rows[0]["bid_records_id"].ToString());
            int     life_of_loan   = int.Parse(dt.Rows[0]["life_of_loan"].ToString());
            int     unit_day       = int.Parse(dt.Rows[0]["unit_day"].ToString());

            if (unit_day != 1)
            {
                life_of_loan = 0;
            }
            string borrowing_title = dt.Rows[0]["borrowing_title"].ToString();
            string userName        = dt.Rows[0]["username"].ToString();
            string invcode         = dt.Rows[0]["invitationcode"].ToString();
            int    targetid        = int.Parse(dt.Rows[0]["targetid"].ToString());//标的ID
            //本次投标使用的奖励金额
            decimal bonusAmt           = decimal.Parse(dt.Rows[0]["bonusAmt"].ToString());
            B_bonus_account_water bbaw = new B_bonus_account_water();
            int invcount = B_usercenter.GetInvestCountByUserid(registerid);//投资次数

            string uid = registerid.ToString();

            LogInfo.WriteLog("投资人ID:" + registerid + "; /*邀请码*/:" + invcode);
            #region MyRegion  邀请奖历 投资成功奖励   暂不启用false  待重新梳理帐号fangjianmin
            if (invcode != null && invcode != "")// && false
            {
                DateTime dte     = DateTime.Now;
                string   codesql = "SELECT invcode,Invpeopleid,invpersonid,invtime from  hx_td_Userinvitation where invcode='" + invcode + "' and invpersonid=" + uid + " ";//查询本人是否已经被邀请注册过
                LogInfo.WriteLog("投资人ID:" + registerid + ";查询本人是否已经被邀请注册过:" + codesql);
                DataTable dtcode = DbHelperSQL.GET_DataTable_List(codesql);
                if (dtcode.Rows.Count > 0)
                {
                    int            uuid = int.Parse(dtcode.Rows[0]["Invpeopleid"].ToString()); //邀请用户id
                    B_member_table oy   = new B_member_table();
                    M_member_table py   = new M_member_table();
                    //获取 邀请用户身份渠道用户不执行
                    py = oy.GetModel(uuid);
                    if (py.useridentity != 4)
                    {
                        DateTime invtime = Convert.ToDateTime(dtcode.Rows[0]["invtime"].ToString()); //邀请时间

                        DateTime nowdate   = DateTime.Now;
                        DateTime startdate = new DateTime(2017, 1, 6, 0, 00, 00);
                        DateTime enddate   = new DateTime(2017, 3, 31, 23, 59, 59);
                        if ((nowdate > startdate && nowdate < enddate) && (invtime > startdate && invtime < enddate))
                        {
                            #region 1月6日活动,奖励邀请人首投满2000返现10元
                            if (!string.IsNullOrWhiteSpace(py.UsrCustId))
                            {
                                B_borrowing_target bbt = new B_borrowing_target();
                                M_borrowing_target mbt = new M_borrowing_target();
                                mbt = bbt.GetModel(targetid);
                                if (mbt.project_type_id != 6)//排除新手标
                                {
                                    string    log     = "用户" + registerid + "活动奖励邀请人首投满2000返现10元: ";
                                    decimal   amtc    = 0;
                                    DataTable dtstAmt = B_usercenter.GetInvestCountByUseridNew(registerid);
                                    if (dtstAmt.Rows.Count > 0)
                                    {
                                        log += "<br> 投资次数" + dtstAmt.Rows.Count + "次";
                                        if (dtstAmt.Rows.Count == 1)
                                        {
                                            amtc = decimal.Parse(dtstAmt.Rows[0]["InvCount_Amt"].ToString());
                                            log += "<br>投资金额" + amtc;
                                            if (amtc >= 2000)
                                            {
                                                hx_UserAct huact = InviteActCashNew(uuid, targetPlatform, amtc, 4, 1, 10, 5)[0];

                                                if (huact != null && huact.ActID != null)
                                                {
                                                    log += "<br>奖励发放成功";
                                                    #region MyRegion  奖励流水
                                                    string awardDescription = string.Format("邀请好友首投满2000成功,获得{0}{1}", Convert.ToDouble(huact.Amt.ToString()), GetBunusDescription(huact.RewTypeID));
                                                    AddBonusAccoutWater(huact.UserAct, uuid, decimal.Parse(huact.Amt.ToString()), awardDescription, registerid); //registerid 被邀请人 uuid邀请人
                                                    #endregion MyRegion  奖励流水

                                                    #region MyRegion  系统消息
                                                    string MContext = string.Format("尊敬的用户:邀请好友{0}首投{1}金额为{2},获得{3}{4}如有问题可咨询创利投的客服!", userName, borrowing_title, investAmt, decimal.Parse(huact.Amt.ToString()), GetBunusDescription(huact.RewTypeID));
                                                    AddSytemMessage(uuid, "邀请好友首投满2000成功奖励", MContext);
                                                    #endregion

                                                    #region 现金流水信息
                                                    if (huact.RewTypeID == 1)
                                                    {
                                                        B_usercenter o  = new B_usercenter();
                                                        decimal      di = o.GetUsridAvailable_balance(uuid);
                                                        //di = di + decimal.Parse(huact.Amt.ToString());
                                                        StringBuilder strSql = new StringBuilder();
                                                        strSql.Append("insert into hx_Capital_account_water(");
                                                        strSql.Append("membertable_registerid,income,expenditure,time_of_occurrence,account_balance,types_Finance,createtime,keyid,remarks)");
                                                        strSql.Append(" values (");
                                                        strSql.Append("" + uuid + "," + decimal.Parse(huact.Amt.ToString()) + ",0,'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'," + di + "," + (int)Enum.Parse(typeof(EnumTypesFinance), EnumTypesFinance.邀请奖励.ToString()) + ",'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',0,'" + awardDescription + "')");
                                                        DbHelperSQL.RunSql(strSql.ToString());
                                                        strSql.Clear();
                                                    }
                                                    #endregion
                                                }
                                            }
                                        }
                                    }
                                    LogInfo.WriteLog(log);
                                }
                            }
                            #endregion
                            #region 受邀好友首次成功投资给予活动奖励   常规邀请
                            //获取标的期限
                            life_of_loan = int.Parse(dt.Rows[0]["life_of_loan"].ToString());
                            unit_day     = int.Parse(dt.Rows[0]["unit_day"].ToString());
                            int lol = 0;
                            if (unit_day == 1)
                            {
                                lol = life_of_loan;
                            }
                            #region 邀请好友投资成功返现(奖励邀请人)
                            if (!string.IsNullOrWhiteSpace(py.UsrCustId))
                            {
                                hx_UserAct hut = InviteActBonus(uuid, targetPlatform, int.Parse(dtcode.Rows[0]["invpersonid"].ToString()), investAmt, 1, 4, 1, 0, 5, lol, "邀请好友投资成功返现")[0];//
                                if (hut != null && hut.ActID != null)
                                {
                                    #region MyRegion  奖励流水
                                    string awardDescription = string.Format("邀请好友投资成功,获得{0}{1}", Convert.ToDouble(hut.Amt.ToString()), GetBunusDescription(hut.RewTypeID));
                                    AddBonusAccoutWater(hut.UserAct, uuid, decimal.Parse(hut.Amt.ToString()), awardDescription, registerid); //registerid 被邀请人 uuid邀请人
                                    #endregion MyRegion  奖励流水

                                    #region MyRegion  系统消息
                                    string MContext = string.Format("尊敬的用户:邀请好友{0}投资{1}金额为{2},获得{3}{4}如有问题可咨询创利投的客服!", userName, borrowing_title, investAmt, hut.Amt.ToString(), GetBunusDescription(hut.RewTypeID));
                                    AddSytemMessage(uuid, "邀请好友投资成功奖励", MContext);
                                    #endregion

                                    #region 现金流水信息
                                    if (hut.RewTypeID == 1)
                                    {
                                        B_usercenter o  = new B_usercenter();
                                        decimal      di = o.GetUsridAvailable_balance(uuid);
                                        //di = di + decimal.Parse(hut.Amt.ToString());
                                        StringBuilder strSql = new StringBuilder();
                                        strSql.Append("insert into hx_Capital_account_water(");
                                        strSql.Append("membertable_registerid,income,expenditure,time_of_occurrence,account_balance,types_Finance,createtime,keyid,remarks)");
                                        strSql.Append(" values (");
                                        strSql.Append("" + uuid + "," + decimal.Parse(hut.Amt.ToString()) + ",0,'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'," + di + "," + (int)Enum.Parse(typeof(EnumTypesFinance), EnumTypesFinance.邀请奖励.ToString()) + ",'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',0,'" + awardDescription + "')");
                                        DbHelperSQL.RunSql(strSql.ToString());
                                        strSql.Clear();
                                    }
                                    #endregion
                                }
                            }
                            #endregion
                            #region 被邀请投资成功返现(奖励被邀请人)
                            int        byquuid = int.Parse(dtcode.Rows[0]["invpersonid"].ToString());
                            hx_UserAct byhut   = InviteActBonus(byquuid, targetPlatform, 0, investAmt, 1, 4, 1, 0, 5, lol, "被邀请投资返现")[0];//
                            if (byhut != null && byhut.ActID != null)
                            {
                                #region MyRegion  奖励流水
                                string awardDescription = string.Format("被邀请投资成功,获得{0}{1}", Convert.ToDouble(byhut.Amt.ToString()), GetBunusDescription(byhut.RewTypeID));
                                AddBonusAccoutWater(byhut.UserAct, byquuid, decimal.Parse(byhut.Amt.ToString()), awardDescription, registerid); //registerid 被邀请人 uuid邀请人
                                #endregion MyRegion  奖励流水

                                #region MyRegion  系统消息
                                string MContext = string.Format("尊敬的用户:被邀请投资{0}金额为{1},获得{2}{3}如有问题可咨询创利投的客服!", borrowing_title, investAmt, byhut.Amt.ToString(), GetBunusDescription(byhut.RewTypeID));
                                AddSytemMessage(byquuid, "被邀请投资成功奖励", MContext);
                                #endregion

                                #region 现金流水信息
                                if (byhut.RewTypeID == 1)
                                {
                                    B_usercenter o  = new B_usercenter();
                                    decimal      di = o.GetUsridAvailable_balance(byquuid);
                                    //di = di + decimal.Parse(byhut.Amt.ToString());
                                    StringBuilder strSql = new StringBuilder();
                                    strSql.Append("insert into hx_Capital_account_water(");
                                    strSql.Append("membertable_registerid,income,expenditure,time_of_occurrence,account_balance,types_Finance,createtime,keyid,remarks)");
                                    strSql.Append(" values (");
                                    strSql.Append("" + byquuid + "," + decimal.Parse(byhut.Amt.ToString()) + ",0,'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'," + di + "," + (int)Enum.Parse(typeof(EnumTypesFinance), EnumTypesFinance.邀请奖励.ToString()) + ",'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',0,'" + awardDescription + "')");
                                    DbHelperSQL.RunSql(strSql.ToString());
                                    strSql.Clear();
                                }
                                #endregion
                            }
                            #endregion
                            #endregion
                        }



                        #region 这里现金返现  ??? 投资金额为-1 作了单独处理。注册?? RewTypeID-1 ???
                        //hx_UserAct ua = InviteActBonus(uuid, int.Parse(dtcode.Rows[0]["invpersonid"].ToString()), -1M, 1, 4, 1, 0, 5)[0];//???
                        #endregion
                        //}
                        //else if (invcount > 1)
                        //{
                        //    #region 受邀用户续投奖励 邀请活动正常续投
                        //    int biyaoUsrid = int.Parse(dtcode.Rows[0]["invpersonid"].ToString());
                        //    decimal totAmt = B_usercenter.GetInviUserTotalAmt(uuid, biyaoUsrid);//????这里需要取出受邀用户奖总数
                        //    // hx_UserAct hut = aci.InviteActCash(uuid, biyaoUsrid, decimal.Parse(p.TransAmt), 4, 2, 1, totAmt, 5);
                        //    hx_UserAct hut = InviteActBonus(uuid, int.Parse(dtcode.Rows[0]["invpersonid"].ToString()), investAmt - bonusAmt, 1, 4, 1, totAmt, 5)[0];//????
                        //    if (hut != null && hut.ActID != null)
                        //    {
                        //        #region MyRegion  奖励流水
                        //        string awardDescription = string.Format("邀请好友续投成功获得{0}{1}", hut.Amt.ToString(), GetBunusDescription(hut.RewTypeID));
                        //        AddBonusAccoutWater(hut.UserAct, uuid, decimal.Parse(hut.Amt.ToString()), awardDescription, registerid); //registerid 被邀请人 uuid邀请人
                        //        #endregion MyRegion  奖励流水

                        //        #region MyRegion  系统消息
                        //        string MContext = string.Format("尊敬的用户:邀请好友续投{1}金额为{2},获得{3}{4}如有问题可咨询创利投的客服!", userName, borrowing_title, investAmt, hut.Amt.ToString(), GetBunusDescription(hut.RewTypeID));
                        //        AddSytemMessage(uuid, "邀请好友续投奖励", MContext);
                        //        #endregion

                        //        #region 现金奖励 资金流水信息
                        //        if (hut.RewTypeID == 1)
                        //        {
                        //            B_usercenter o = new B_usercenter();
                        //            decimal di = o.GetUsridAvailable_balance(uuid);
                        //            // di = di + decimal.Parse(hut.Amt.ToString());
                        //            StringBuilder strSql = new StringBuilder();
                        //            strSql.Append("insert into hx_Capital_account_water(");
                        //            strSql.Append("membertable_registerid,income,expenditure,time_of_occurrence,account_balance,types_Finance,createtime,keyid,remarks)");
                        //            strSql.Append(" values (");
                        //            strSql.Append("" + uuid + "," + decimal.Parse(hut.Amt.ToString()) + ",0,'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'," + di + "," + (int)Enum.Parse(typeof(EnumTypesFinance), EnumTypesFinance.邀请奖励.ToString()) + ",'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',0,'" + awardDescription + "')");
                        //            LogInfo.WriteLog("续投奖励流水语句:" + strSql.ToString());
                        //            DbHelperSQL.RunSql(strSql.ToString());
                        //            strSql.Clear();
                        //        }
                        //        #endregion
                        //    }
                        //    #endregion
                        //}

                        /*
                         *  DbHelperSQL.RunSql(" update hx_td_Userinvitation  set InvitesStates=1  where invcode='" + invcode + "' and invpersonid=" + uid + " and  InvitesStates=2 ");
                         *  LogInfo.WriteLog(" 后台更新数据邀请状态 update hx_td_Userinvitation  set InvitesStates=1  where invcode='" + invcode + "' and invpersonid=" + uid + " and  InvitesStates=2 ");
                         */
                    }
                }
            }
            #endregion
        }
Esempio n. 10
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. 11
0
        //DataTable dt 投资记录视图 V_hx_Bid_records_borrowing_target
        /// <summary>
        /// 投资后按照常规活动进行奖励发放(常规投资、邀请奖励)
        /// </summary>
        /// <param name="dt"></param>
        protected internal void SendBonusAfterInvest(DataTable dt, string targetPlatform)
        {
            if (dt.Rows.Count <= 0)
            {
                return;
            }
            //投资金额
            decimal investAmt  = decimal.Parse(dt.Rows[0]["investment_amount"].ToString());
            int     registerid = int.Parse(dt.Rows[0]["investor_registerid"].ToString());
            string  targetid   = dt.Rows[0]["targetid"].ToString();
            //string OrdId = dt.Rows[0]["OrdId"].ToString();
            int bid_records_id = int.Parse(dt.Rows[0]["bid_records_id"].ToString());
            int life_of_loan   = int.Parse(dt.Rows[0]["life_of_loan"].ToString());
            int unit_day       = int.Parse(dt.Rows[0]["unit_day"].ToString());

            if (unit_day == 1)
            {
                life_of_loan = life_of_loan >= 6 ? 6 : (life_of_loan < 3 ? 1 : 3);
            }
            if (unit_day == 3)
            {
                life_of_loan = (life_of_loan / 30) >= 6 ? 6 : ((life_of_loan / 30) < 3 ? ((life_of_loan / 30) >= 1 ? 1 : -1) : 3);
            }
            string borrowing_title = dt.Rows[0]["borrowing_title"].ToString();
            string userName        = dt.Rows[0]["username"].ToString();
            //string mobile = dt.Rows[0]["mobile"].ToString();
            string invcode = dt.Rows[0]["invitationcode"].ToString();
            //本次投标使用的奖励金额
            decimal bonusAmt = decimal.Parse(dt.Rows[0]["bonusAmt"].ToString());
            //项目总借款金额
            decimal borrowing_balance = decimal.Parse(dt.Rows[0]["borrowing_balance"].ToString());//??

            LogInfo.WriteLog(" /*此处加入活动*/:" + targetid + ";投资人:" + registerid);
            B_bonus_account_water bbaw = new B_bonus_account_water();
            /*此处加入活动*/
            int invcount = B_usercenter.GetInvestCountByUserid(registerid);//投资次数

            //ActFacade act = new ActFacade();
            #region 活动奖励
            if (invcount == 1)
            {
                #region 首次投资活动奖励
                List <hx_UserAct> hut = GeneralInvestActBonus(registerid, targetPlatform, investAmt - bonusAmt, bid_records_id, 1, life_of_loan);
                if (hut.Count > 0)//合并到奖励中
                {
                    foreach (hx_UserAct item in hut)
                    {
                        if (item.RewTypeID > 1) //现金转账时做过处理,这里无需再处理
                        {
                            #region MyRegion  记录奖励流水表
                            string awardDescription = string.Format("首次投资成功获得{0}{1}", item.Amt.ToString(), GetBunusDescription(item.RewTypeID));
                            AddBonusAccoutWater(item.UserAct, registerid, decimal.Parse(item.Amt.ToString()), awardDescription);
                            #endregion

                            #region MyRegion  发送系统消息
                            string MContext = string.Format("首次投资{0}金额为{1},获得{2}{3}如有问题可咨询创利投的客服!", borrowing_title, investAmt, item.Amt.ToString(), GetBunusDescription(item.RewTypeID));
                            AddSytemMessage(registerid, "首次投资成功", MContext);
                            #endregion
                        }
                    }
                }
                #endregion
            }
            else if (invcount >= 2)
            {
                #region 续投活动奖励
                List <hx_UserAct> hutw = GeneralInvestActBonus(registerid, targetPlatform, investAmt - bonusAmt, bid_records_id, 6, life_of_loan);
                if (hutw.Count > 0)
                {
                    foreach (hx_UserAct item in hutw)
                    {
                        if (item.RewTypeID > 1) //现金转账时做过处理,这里无需再处理
                        {
                            #region MyRegion  奖励流水
                            string awardDescription = string.Format("续投成功获得{0}{1}", item.Amt.ToString(), GetBunusDescription(item.RewTypeID));
                            AddBonusAccoutWater(item.UserAct, registerid, decimal.Parse(item.Amt.ToString()), awardDescription);
                            #endregion MyRegion  奖励流水

                            #region MyRegion  系统消息
                            string MContext = string.Format("续投{0}金额为{1},获得{2}{3}如有问题可咨询创利投的客服!", borrowing_title, investAmt, item.Amt.ToString(), GetBunusDescription(item.RewTypeID));
                            AddSytemMessage(registerid, "续投成功", MContext);
                            #endregion
                        }
                    }
                }
                #endregion

                #region 特殊复投返现活动奖励--回款金额复投
                hutw = GeneralInvestActBonus(registerid, targetPlatform, investAmt - bonusAmt, bid_records_id, 7, life_of_loan);
                if (hutw.Count > 0)
                {
                    foreach (hx_UserAct item in hutw)
                    {
                        if (item.RewTypeID > 1) //现金转账时做过处理,这里无需再处理
                        {
                            #region MyRegion  奖励流水
                            string awardDescription = string.Format("回款复投成功获得{0}{1}", item.Amt.ToString(), GetBunusDescription(item.RewTypeID));
                            AddBonusAccoutWater(item.UserAct, registerid, decimal.Parse(item.Amt.ToString()), awardDescription);
                            #endregion MyRegion  奖励流水

                            #region MyRegion  系统消息
                            string MContext = string.Format("回款复投{0}金额为{1},获得{2}{3}如有问题可咨询创利投的客服!", borrowing_title, investAmt, item.Amt.ToString(), GetBunusDescription(item.RewTypeID));
                            AddSytemMessage(registerid, "回款复投成功", MContext);
                            #endregion
                        }
                    }
                }
                #endregion
            }


            #region 所有用户
            //所有用户
            List <hx_UserAct> hutwc = GeneralInvestActBonus(registerid, targetPlatform, investAmt - bonusAmt, bid_records_id, 5, life_of_loan);

            if (hutwc.Count > 0)
            {
                foreach (hx_UserAct item in hutwc)
                {
                    if (item.RewTypeID > 1) //现金转账时做过处理,这里无需再处理
                    {
                        #region MyRegion  奖励流水
                        string awardDescription = string.Format("投资成功获得{0}{1}", item.Amt.ToString(), GetBunusDescription(item.RewTypeID));
                        AddBonusAccoutWater(item.UserAct, registerid, decimal.Parse(item.Amt.ToString()), awardDescription);
                        #endregion MyRegion  奖励流水

                        #region MyRegion  系统消息
                        string MContext = string.Format("投资{0}金额为{1},获得{2}{3}如有问题可咨询创利投的客服!", borrowing_title, investAmt, item.Amt.ToString(), GetBunusDescription(item.RewTypeID));
                        AddSytemMessage(registerid, "投资成功", MContext);
                        #endregion
                    }
                }
            }
            #endregion

            #region 投标最大的用户  暂时注释false 有bug,投标结束后才能判断哪个位最大,而不是每次都判断????
            DataTable dmax = B_usercenter.Topinvestor(int.Parse(targetid));
            if (dmax.Rows.Count > 0 && false)
            {
                decimal amtc = decimal.Parse(dmax.Rows[0]["InvCount_Amt"].ToString());
                if (borrowing_balance == amtc)//???判断什么 一人满标?
                {
                    List <hx_UserAct> invmax = GeneralInvestActBonus(int.Parse(dmax.Rows[0]["investor_registerid"].ToString()), targetPlatform, decimal.Parse(dmax.Rows[0]["maxamt"].ToString()), bid_records_id, 4, life_of_loan);
                    if (invmax.Count > 0)
                    {
                        foreach (hx_UserAct item in invmax)
                        {
                            if (item.RewTypeID > 1) //现金转账时做过处理,这里无需再处理
                            {
                                #region MyRegion  奖励流水
                                string awardDescription = string.Format("投标最大的用户获得{0}{1}", item.Amt.ToString(), GetBunusDescription(item.RewTypeID));
                                AddBonusAccoutWater(item.UserAct, registerid, decimal.Parse(item.Amt.ToString()), awardDescription);
                                #endregion MyRegion  奖励流水

                                #region MyRegion  系统消息
                                string MContext = string.Format("投标最大的用户,投资{0}金额为{1},获得{2}{3}如有问题可咨询创利投的客服!", borrowing_title, investAmt, item.Amt.ToString(), GetBunusDescription(item.RewTypeID));
                                AddSytemMessage(registerid, "投标最大的用户奖励", MContext);
                                #endregion
                            }
                        }
                    }
                }
            }
            #endregion

            #region 每标首投用户
            if (B_usercenter.TopNum(targetid) == 1)
            {
                List <hx_UserAct> invFirst = GeneralInvestActBonus(registerid, targetPlatform, investAmt - bonusAmt, bid_records_id, 3, life_of_loan);
                if (invFirst.Count > 0)
                {
                    foreach (hx_UserAct item in invFirst)
                    {
                        if (item.RewTypeID > 1) //现金转账时做过处理,这里无需再处理
                        {
                            #region MyRegion  奖励流水
                            string awardDescription = string.Format("每标首投用户获得{0}{1}", item.Amt.ToString(), GetBunusDescription(item.RewTypeID));
                            AddBonusAccoutWater(item.UserAct, registerid, decimal.Parse(item.Amt.ToString()), awardDescription);
                            #endregion MyRegion  奖励流水

                            #region MyRegion  系统消息
                            string MContext = string.Format("每标首投用户,投资{0}金额为{1},获得{2}{3}如有问题可咨询创利投的客服!", borrowing_title, investAmt, item.Amt.ToString(), GetBunusDescription(item.RewTypeID));
                            AddSytemMessage(registerid, "每标首投用户奖励", MContext);
                            #endregion
                        }
                    }
                }
            }
            #endregion

            #endregion
        }