public JsonResult GetTotal() { string[] dt = B_usercenter.GetTotal(); var result = new { state = 0, aLLFinance = dt[0], income = dt[1], investment = dt[2] }; return(Json(result)); }
/// <summary> /// 判断用户是否为渠道用户 /// </summary> /// <param name="userID"></param> /// <param name="channelType">渠道类型</param> /// <returns></returns> public static bool CheckIsChannel(int userID, ref string channelType) { //chuangtouEntities ef = new chuangtouEntities(); bool t = true; B_member_table b_member_table = new B_member_table(); M_member_table investor = new M_member_table(); investor = b_member_table.GetModel(userID); if (investor == null) { return(false); } string codesql = "SELECT invcode,Invpeopleid,invpersonid,invtime from hx_td_Userinvitation where invpersonid=" + investor.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(investor.registerid); //老渠道机制判断 (推荐人等级为4渠道用户,投资次数大于等于1次 时可参与活动 if (uuid != 0) { M_member_table py = new M_member_table(); B_member_table oy = new B_member_table(); py = oy.GetModel(uuid);//推荐人 if ((py != null && py.useridentity == 4)) { return(t); } } if (string.IsNullOrWhiteSpace(investor.channel_invitedcode)) { return(false); } string cacheName = "hx_Channel_" + investor.channel_invitedcode; hx_Channel channelEnitty = (hx_Channel)Utils.GetThirdCacheObject(cacheName); if (channelEnitty == null) { channelEnitty = ef.hx_Channel.AsNoTracking().Where(p => p.Invitedcode == investor.channel_invitedcode).FirstOrDefault(); } if (channelEnitty != null) { channelType = channelEnitty.type; Utils.SetThirdCacheName(cacheName, channelEnitty, 5); } return(channelEnitty != null); }
/// <summary> ///生成站内信 系统消息(发放奖励) /// </summary> ///<param name="registerid">用户id</param> ///<param name="MTitle">消息标题</param> ///<param name="MContext">消息内容</param> ///<param name="Mtye">消息类型 0系统消息 1投资通知 2收益通知 3提现 4充值 5系统通知</param> protected bool AddSytemMessage(int registerid, string MTitle, string MContext, int Mtype = 5) { DateTime dtiff = DateTime.Now; M_td_System_message pm2 = new M_td_System_message(); pm2.MReg = registerid; pm2.Mstate = 0; pm2.MTitle = MTitle; pm2.MContext = MContext; pm2.PubTime = dtiff; pm2.Mtype = Mtype; B_usercenter.AddMessage(pm2); return(true); }
/// <summary> /// 判断当前用户是否可以参加活动 /// </summary> /// <param name="userID">用户ID</param> /// <returns></returns> public static bool CheckChannel(int userID) { bool t = false; B_member_table b_member_table = new B_member_table(); M_member_table investor = new M_member_table(); investor = b_member_table.GetModel(userID); if (investor == null) { return(false); } string codesql = "SELECT invcode,Invpeopleid,invpersonid,invtime from hx_td_Userinvitation where invpersonid=" + investor.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(investor.registerid); //老渠道机制判断 (推荐人等级为4渠道用户,投资次数大于等于1次 时可参与活动 if (uuid != 0) { M_member_table py = new M_member_table(); B_member_table oy = new B_member_table(); py = oy.GetModel(uuid);//推荐人 if ((py != null && py.useridentity == 4) && investCount <= 1) { return(t); } } //新渠道机制判断 using (ChannelAct channelAct = new ChannelAct()) { //按照渠道类型和投资次数判断是否参与此次活动 if (!string.IsNullOrWhiteSpace(investor.channel_invitedcode) && !channelAct.IsParticipateActivity(investor.channel_invitedcode, investCount)) { return(t); } } return(true); }
/// <summary> /// 获取短信验证码 /// </summary> /// <returns></returns> public ActionResult smscode() { string json = ""; string vvcode = ""; B_usercenter bu = new B_usercenter(); string mobile = Utils.CheckSQLHtml(Request["mobile"].ToString().Trim()); int userid = DNTRequest.GetInt("userid", 0); int smstype = (int)Enum.Parse(typeof(EnumSMSType), EnumSMSType.短信验证码.ToString()); int smstype1 = (int)Enum.Parse(typeof(EnumSMSType), EnumSMSType.语音短信验证码.ToString()); string sql2 = "SELECT registerid,username,mobile from hx_member_table where mobile='" + mobile + "'"; DataTable dt1 = DbHelperSQL.GET_DataTable_List(sql2); if (dt1.Rows.Count > 0) { if (Request["vcodec"] != null) { vvcode = Utils.CheckSQLHtml(Request["vcodec"].ToString().Trim()); } string ipc = Utils.GetRealIP(); if (vvcode.Length >= 4) { string strIdentify = "LoginValidateCode"; //随机字串存储键值,以便存储到Session中 if (Session[strIdentify] != null) { if (Session[strIdentify].ToString() == vvcode) { } else { json = @" {""rs"": ""n"", ""info"": ""验证码不对!""}"; return(Content(json)); } } else { json = @" {""rs"": ""n"", ""info"": ""验证码已过期!""}"; return(Content(json)); } } else if (vvcode.Length > 0 && vvcode.Length <= 3) { json = @" {""rs"": ""n"", ""info"": ""验证码位数不对!""}"; return(Content(json)); } else { // json = @" {""rs"": ""n"", ""info"": ""v""}"; // return Content(json); } if (Session["checkmobileq"] == null) { Session["checkmobileq"] = DateTime.Now.ToString(); } else { DateTime dte = DateTime.Parse(Session["checkmobileq"].ToString()); long sec = Utils.DateDiff("Second", dte, DateTime.Now); if (sec > 60) { Session["checkmobileq"] = null; } else { json = @" {""rs"": ""n"", ""info"": ""短信发送太频繁!请稍后再试""}"; return(Content(json)); } } if (bu.checkipsess(Utils.GetRealIP(), smstype, smstype1) == false) { json = @" {""rs"": ""n"", ""info"": ""短信发送太频繁!发送异常""}"; return(Content(json)); } if (bu.checkipnum(Utils.GetRealIP(), smstype, smstype1) >= 8) { json = @" {""rs"": ""n"", ""info"": ""短信发送太频繁!请与客服联系""}"; return(Content(json)); } else { /* * hx_td_SMS_record记录短信,验证码类型应是1 * */ string contxt = Utils.GetMSMEmailContext(1, 0); // 获取注册成功邮件内容 M_td_SMS_record p = new M_td_SMS_record(); B_td_SMS_record o = new B_td_SMS_record(); string sql = "select sms_record_id,smscontext,phone_number,hits from hx_td_SMS_record where ( smstype=" + smstype + " or smstype=" + smstype1 + " ) and phone_number='" + mobile + "' and DATEDIFF(MINUTE,sendtime,getDate())<3 order by sms_record_id desc"; DataTable dt = DbHelperSQL.GET_DataTable_List(sql); if (dt.Rows.Count > 0) { if (int.Parse(dt.Rows[0]["hits"].ToString()) < 3) { //以前存在,直接发送验证码 decimal dd = SendSMS.Send_SMS(dt.Rows[0]["phone_number"].ToString(), dt.Rows[0]["smscontext"].ToString()); if (dd != 0) { json = @" {""rs"": ""n"", ""info"": ""短信发送异常,请与客报联系""}"; return(Content(json)); } //if (dd > 0) // { sql = "update hx_td_SMS_record set orderid=" + dd.ToString() + ",hits=hits+1 where sms_record_id=" + dt.Rows[0]["sms_record_id"].ToString(); DbHelperSQL.RunSql(sql); //} } else { json = @" {""rs"": ""n"", ""info"": ""短信发送异常,请与客报联系""}"; return(Content(json)); } } else { //不存在生成新的验证码 string vcode = Utils.RndNum(6); string smscontxt = Utils.GetMSMEmailContext(16, 1); // 获取注册成功邮件内容 StringBuilder sbsms = new StringBuilder(smscontxt); sbsms = sbsms.Replace("#CODE#", vcode); decimal dd = SendSMS.Send_SMS(mobile, sbsms.ToString()); if (dd != 0) { json = @" {""rs"": ""n"", ""info"": ""短信发送异常,请与客报联系""}"; return(Content(json)); } p.phone_number = mobile; p.sendtime = DateTime.Now; p.senduserid = userid; p.smstype = smstype; p.smscontext = sbsms.ToString(); p.orderid = dd; p.vcode = vcode; p.ip = Utils.GetRealIP(); o.Add(p); } json = @" {""rs"": ""y"", ""info"": ""短信发送成功! ""}"; return(Content(json)); } } return(Content(json)); }
/// <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.)); } } } }
/// <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 } } } } }
/// <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)); }
public ActionResult PostGENERALAmt() { //显示于页面给汇付 string str = string.Empty; //日志变量 string log = string.Empty; //响应通知加签的状态码 int ret = -1; //业务的sql语句变量 string sql = string.Empty; ReCash m = ChinapnrFacade.CashCallBack(out ret); if (m != null) { //提现成功后,得多事务处理账户金额,流水及冻结金额等 if (m.RespCode == "000") { string cachename = m.OrdId + "Cash" + m.UsrCustId; if (Utils.GeTThirdCache(cachename) == 0) { Utils.SetThirdCache(cachename); B_usercenter BUC = new B_usercenter(); M_ReqExt mre = JsonConvert.DeserializeObject <M_ReqExt>(m.RespExt.Replace("[", "").Replace("]", "")); int CashOp = BUC.CashTran(m.OpenAcctId, m.OpenBankId, m.OrdId, m.RealTransAmt, m.UsrCustId, m.FeeAmt, mre.FeeObjFlag, mre.CashChl); if (CashOp > 0) { sql = "select registerid,username,mobile,UsrCustId,available_balance from hx_member_table where UsrCustId='" + m.UsrCustId + "'"; LogInfo.WriteLog("审请取现成功短信sql:" + sql); DataTable dt = DbHelperSQL.GET_DataTable_List(sql); if (dt.Rows.Count > 0) { //短信通知 //尊敬的#USERANEM#,您已成功提现#MONEY#元,账户余额#MONEY1#.请注意查收!【创利投】 string contxt = Utils.GetMSMEmailContext(12, 1); // 获取注册成功邮件内容 StringBuilder sbsms = new StringBuilder(contxt); sbsms = sbsms.Replace("#USERANEM#", dt.Rows[0]["username"].ToString()); sbsms = sbsms.Replace("#MONEY#", m.TransAmt); decimal amt = decimal.Parse(dt.Rows[0]["available_balance"].ToString()) - decimal.Parse(m.TransAmt); sbsms = sbsms.Replace("#MONEY1#", amt.ToString()); 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); 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 = sbsms.ToString(); pm.PubTime = dti; pm.Mtype = 3; B_usercenter.AddMessage(pm); } string cashChl = Enum.GetName(typeof(EnumCommon.E_hx_td_UserCash.EnumCashChl), (int)EnumCommon.E_hx_td_UserCash.EnumCashChl.IMMEDIATE); if (mre.CashChl == cashChl && decimal.Parse(m.TransAmt) <= 200000M) { string retUrl = Utils.GetRe_url("admin/UserCash/RePostCashProcessing"); string bgRetUrl = Utils.GetRe_url("admin/Thirdparty/BgCashProcessing"); BusinessLogicHelper.AutoCheckCash(m.UsrCustId, retUrl, bgRetUrl); } } } } } return(View(m)); }
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); }
/// <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); }
public ActionResult BgCashProcessing() { // Response.BufferOutput = true; // System.Threading.Thread.Sleep(1000); string str = ""; ReCashAudit m = new ReCashAudit(); m.CmdId = DNTRequest.GetString("CmdId"); m.RespCode = DNTRequest.GetString("RespCode"); m.RespDesc = HttpUtility.UrlDecode(DNTRequest.GetString("RespDesc")); m.MerCustId = DNTRequest.GetString("MerCustId"); m.OrdId = DNTRequest.GetString("OrdId"); m.UsrCustId = DNTRequest.GetString("UsrCustId"); m.TransAmt = DNTRequest.GetString("TransAmt"); m.OpenAcctId = DNTRequest.GetString("OpenAcctId"); m.OpenBankId = DNTRequest.GetString("OpenBankId"); m.AuditFlag = DNTRequest.GetString("AuditFlag"); m.FeeAmt = DNTRequest.GetString("FeeAmt"); m.FeeCustId = DNTRequest.GetString("FeeCustId"); m.FeeAcctId = DNTRequest.GetString("FeeAcctId"); m.RetUrl = HttpUtility.UrlDecode(DNTRequest.GetString("RetUrl")); m.BgRetUrl = HttpUtility.UrlDecode(DNTRequest.GetString("BgRetUrl")); m.MerPriv = HttpUtility.UrlDecode(DNTRequest.GetString("MerPriv")); m.ChkValue = DNTRequest.GetString("ChkValue"); LogInfo.WriteLog("后台取现审核返回参数:" + FastJSON.toJOSN(m)); StringBuilder chkVal = new StringBuilder(); chkVal.Append(m.CmdId); chkVal.Append(m.RespCode); chkVal.Append(m.MerCustId); chkVal.Append(m.OrdId); chkVal.Append(m.UsrCustId); chkVal.Append(m.TransAmt); chkVal.Append(m.OpenAcctId); chkVal.Append(m.OpenBankId); chkVal.Append(m.AuditFlag); chkVal.Append(m.RetUrl); chkVal.Append(m.BgRetUrl); chkVal.Append(m.MerPriv); string msg = chkVal.ToString(); //私钥文件的位置(这里是放在了站点的根目录下) string merKeyFile = AppDomain.CurrentDomain.BaseDirectory + Utils.GetPgPubk(); //需要指定提交字符串的长度 int len = Encoding.UTF8.GetBytes(msg).Length; StringBuilder sbChkValue = new StringBuilder(256); int ret = DllInterop.VeriSignMsg(merKeyFile, msg, msg.Length, m.ChkValue); LogInfo.WriteLog("后台验签返回参数:" + ret.ToString()); #region 核验签结果 if (ret == 0) { if (m.RespCode == "000" || m.RespCode == "999" || m.RespCode == "406") { System.Threading.Thread.Sleep(500); string cachename = m.OrdId + "Cash" + m.UsrCustId + m.TransAmt.ToString(); if (Utils.GeTThirdCache(cachename) == 0) { Utils.SetThirdCache(cachename); //提现成功后,得多事务处理账户金额,流水等 B_usercenter BUC = new B_usercenter(); M_Capital_account_water aw = new M_Capital_account_water(); if (BUC.Su_CashProcessing(m, aw) > 0) { str = "RECV_ORD_ID_" + m.OrdId; LogInfo.WriteLog("后台取款审核成功" + str); } else { LogInfo.WriteLog("后台取款审核事误操作失败"); } } str = "RECV_ORD_ID_" + m.OrdId; } else { LogInfo.WriteLog("后台提现失败"); } } else { LogInfo.WriteLog("后台验签失败"); } #endregion return(Content(str)); }
public ActionResult BgLoans() { string outstr = ""; ReLoans m = new ReLoans(); m.CmdId = DNTRequest.GetString("CmdId"); m.RespCode = DNTRequest.GetString("RespCode"); m.RespDesc = DNTRequest.GetString("RespDesc"); m.MerCustId = DNTRequest.GetString("MerCustId"); m.OrdId = DNTRequest.GetString("OrdId"); m.OrdDate = DNTRequest.GetString("OrdDate"); m.OutCustId = DNTRequest.GetString("OutCustId"); m.OutAcctId = DNTRequest.GetString("OutAcctId"); m.TransAmt = DNTRequest.GetString("TransAmt"); m.Fee = DNTRequest.GetString("Fee"); m.InCustId = DNTRequest.GetString("InCustId"); m.InAcctId = DNTRequest.GetString("InAcctId"); m.SubOrdId = DNTRequest.GetString("SubOrdId"); m.SubOrdDate = DNTRequest.GetString("SubOrdDate"); m.FeeObjFlag = DNTRequest.GetString("FeeObjFlag"); m.IsDefault = DNTRequest.GetString("IsDefault"); m.IsUnFreeze = DNTRequest.GetString("IsUnFreeze"); m.UnFreezeOrdId = DNTRequest.GetString("UnFreezeOrdId"); m.FreezeTrxId = DNTRequest.GetString("FreezeTrxId"); m.BgRetUrl = DNTRequest.GetString("BgRetUrl"); m.MerPriv = DNTRequest.GetString("MerPriv"); m.RespExt = DNTRequest.GetString("RespExt"); m.ChkValue = DNTRequest.GetString("ChkValue"); StringBuilder chkVal = new StringBuilder(); chkVal.Append(m.CmdId); chkVal.Append(m.RespCode); chkVal.Append(m.MerCustId); chkVal.Append(m.OrdId); chkVal.Append(m.OrdDate); chkVal.Append(m.OutCustId); chkVal.Append(m.OutAcctId); chkVal.Append(m.TransAmt); chkVal.Append(m.Fee); chkVal.Append(m.InCustId); chkVal.Append(m.InAcctId); chkVal.Append(m.SubOrdId); chkVal.Append(m.SubOrdDate); chkVal.Append(m.FeeObjFlag); chkVal.Append(m.IsDefault); chkVal.Append(m.IsUnFreeze); chkVal.Append(m.UnFreezeOrdId); chkVal.Append(m.FreezeTrxId); chkVal.Append(m.BgRetUrl); chkVal.Append(m.MerPriv); chkVal.Append(m.RespExt); string msg = chkVal.ToString(); //私钥文件的位置(这里是放在了站点的根目录下) string merKeyFile = AppDomain.CurrentDomain.BaseDirectory + Utils.GetPgPubk(); //需要指定提交字符串的长度 int len = Encoding.UTF8.GetBytes(msg).Length; StringBuilder sbChkValue = new StringBuilder(256); int ret = DllInterop.VeriSignMsg(merKeyFile, msg, msg.Length, m.ChkValue); LogInfo.WriteLog("验签:" + ret.ToString()); if (ret == 0) { if (m.RespCode == "000") { // M_borrowing_target m = new M_borrowing_target(); B_borrowing_target o = new B_borrowing_target(); B_member_table o1 = new B_member_table(); M_member_table p1 = new M_member_table(); M_member_table p2 = new M_member_table(); B_usercenter BUC = new B_usercenter(); string cachename = m.OrdId + "Loans" + m.FreezeTrxId; if (Utils.GeTThirdCache(cachename) == 0) { Utils.SetThirdCache(cachename); M_Capital_account_water baw = new M_Capital_account_water(); //借款人流水对象 //标的id,借款人id,投资人id,投资记录bid,抵扣券金额 string strings = m.MerPriv; string[] sArray = strings.Split('_'); if (sArray.Count() == 5) { p1 = o1.GetModel(int.Parse(sArray[1])); //借款人用户对象 LogInfo.WriteLog("sArray[1].ToString():" + sArray[1].ToString()); baw.membertable_registerid = p1.registerid; baw.income = decimal.Parse(m.TransAmt); baw.expenditure = 0.00M; baw.time_of_occurrence = DateTime.Now; // decimal ff = p1.available_balance + decimal.Parse(retloan.TransAmt); baw.account_balance = p1.available_balance; //面要得么帐户余额 LogInfo.WriteLog("借款人余额:" + p1.available_balance); baw.types_Finance = (int)Enum.Parse(typeof(EnumTypesFinance), EnumTypesFinance.借款转入.ToString()); baw.createtime = DateTime.Now; baw.keyid = 0; baw.remarks = m.OrdId + "," + m.OrdDate; M_Capital_account_water iaw = new M_Capital_account_water(); //投资人流水对象 p2 = o1.GetModel(int.Parse(sArray[2].ToString())); //投款人用户对象 iaw.membertable_registerid = p2.registerid; iaw.income = 0.00M; iaw.expenditure = decimal.Parse(m.TransAmt); iaw.time_of_occurrence = DateTime.Now; // decimal df=p1.available_balance - decimal.Parse(retloan.TransAmt); iaw.account_balance = p2.available_balance; //面要得么帐户余额 LogInfo.WriteLog("投资人余额:" + p2.ToString()); iaw.types_Finance = (int)Enum.Parse(typeof(EnumTypesFinance), EnumTypesFinance.项目投资.ToString()); iaw.createtime = DateTime.Now; iaw.keyid = 0; iaw.remarks = m.OrdId + "," + m.OrdDate; LogInfo.WriteLog("放款bid_records_id:" + sArray[3].ToString()); if (BUC.Loan_Successfully(m, baw, iaw, sArray[3].ToString(), decimal.Parse(sArray[4].ToString())) > 0) { //成功 outstr = "RECV_ORD_ID_" + m.OrdId; LogInfo.WriteLog("后台主动通知操作成功:" + outstr); return(Content(outstr)); // Response.Redirect("/usercenter/index.html"); } } } } } return(Content("")); }
/// <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 }
/// <summary> /// 汇付回调逻辑 /// </summary> /// <param name="m"></param> public static void RePostCashHelper(ReCashAudit m) { string str = ""; StringBuilder chkVal = new StringBuilder(); chkVal.Append(m.CmdId); chkVal.Append(m.RespCode); chkVal.Append(m.MerCustId); chkVal.Append(m.OrdId); chkVal.Append(m.UsrCustId); chkVal.Append(m.TransAmt); chkVal.Append(m.OpenAcctId); chkVal.Append(m.OpenBankId); chkVal.Append(m.AuditFlag); chkVal.Append(m.RetUrl); chkVal.Append(m.BgRetUrl); chkVal.Append(m.MerPriv); string msg = chkVal.ToString(); //私钥文件的位置(这里是放在了站点的根目录下) string merKeyFile = AppDomain.CurrentDomain.BaseDirectory + Utils.GetPgPubk(); //需要指定提交字符串的长度 int len = Encoding.UTF8.GetBytes(msg).Length; StringBuilder sbChkValue = new StringBuilder(256); int ret = DllInterop.VeriSignMsg(merKeyFile, msg, msg.Length, m.ChkValue); LogInfo.WriteLog("前台取现复核验签返回参数:" + ret.ToString()); #region 核验签成功 if (ret == 0) { //在406取现失败后,再次复核申请时会变成415 if (m.RespCode == "000" || m.RespCode == "999" || m.RespCode == "406") { string cachename = m.OrdId + "Cash" + m.UsrCustId + m.TransAmt.ToString(); if (Utils.GeTThirdCache(cachename) == 0) { Utils.SetThirdCache(cachename); //提现成功后,得多事务处理账户金额,流水等 B_usercenter BUC = new B_usercenter(); M_Capital_account_water aw = new M_Capital_account_water(); if (BUC.Su_CashProcessing(m, aw) > 0) { str = "RECV_ORD_ID_" + m.OrdId; LogInfo.WriteLog("后台取款审核成功" + str); } else { LogInfo.WriteLog("后台取款审核事误操作失败"); } } } else { LogInfo.WriteLog("后台提现失败"); } } else { LogInfo.WriteLog("后台验签失败"); } #endregion }
/// <summary> /// 无效投资标的处理 /// </summary> /// <param name="investor_registerid">投资用户id</param> /// <param name="bid_records_id">投资记录id</param> /// <param name="OrdId">投资订单号</param> /// <param name="OrdDate">投资订单日期</param> /// <param name="UsrCustId">客户号</param> /// <param name="FreezeOrdId">冻结订单号</param> /// <param name="TransAmt">交易金额</param> /// <param name="FreezeTrxId">冻结唯一标识</param> /// <param name="MerPriv">优惠券字符串</param> /// <param name="QueryTransType">查询类型 LOANS:放款交易查询 REPAYMENT:还款交易查询 TENDER:投标交易查询 CASH:取现交易查询 FREEZE:冻结解冻交易查询 </param> public void setRecords_Lost(string investor_registerid, string bid_records_id, string OrdId, string OrdDate, string UsrCustId, string FreezeOrdId, string TransAmt, string FreezeTrxId, string MerPriv, string QueryTransType = "TENDER") { TransStat ts = new TransStat(); bool d = ts.checktrans(OrdId, OrdDate, QueryTransType); if (d == false) { string sql = "update hx_UserAct set UseState=0,AmtProid=0 where UseState=3 and AmtProid=" + bid_records_id + "and registerid=" + investor_registerid; DbHelperSQL.RunSql(sql); sql = "delete hx_Bid_records where OrdId ='" + OrdId + "' and ordstate=0 and bid_records_id=" + bid_records_id; DbHelperSQL.RunSql(sql); } else {//TODO 此处有bug,自动查询的更新冻结表时缺少 FreezeTrxId 值,放款时没有该值会报错。 考虑注释该逻辑,等待汇付异步回调???? B_usercenter BUC = new B_usercenter(); //取得投标记录使用的优惠券 string AmtProid = BUC.GetBid_AmtProid(int.Parse(bid_records_id)); int de = BUC.ReInvest_success(UsrCustId, FreezeOrdId, TransAmt, FreezeTrxId, OrdId, AmtProid); if (de > 0) { string sql = "select targetid,bid_records_id, borrowing_title,investor_registerid ,username,mobile,invitationcode,investment_amount,life_of_loan,unit_day,borrowing_balance,bonusAmt from V_hx_Bid_records_borrowing_target where OrdId='" + OrdId + "'"; DataTable dt = DbHelperSQL.GET_DataTable_List(sql); if (dt.Rows.Count > 0) { 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(); #region 待提取为公共方法 #region MyRegion 系统消息 DateTime dti = DateTime.Now; M_td_System_message pm = new M_td_System_message(); pm.MReg = registerid; pm.Mstate = 0; pm.MTitle = "投资成功"; pm.MContext = "尊敬的用户" + dt.Rows[0]["username"].ToString() + ":您好!恭喜您成功投资了项目【" + dt.Rows[0]["borrowing_title"].ToString() + "】,投资金额是:" + investAmt + "。如有问题可咨询创利投的客服!谢谢!"; pm.PubTime = dti; pm.Mtype = 1; B_usercenter.AddMessage(pm); #endregion #region MyRegion //短信通知 string contxt = Utils.GetMSMEmailContext(15, 1); // 获取注册成功邮件内容 StringBuilder sbsms = new StringBuilder(contxt); sbsms = sbsms.Replace("#USERANEM#", dt.Rows[0]["username"].ToString()); sbsms = sbsms.Replace("#PID#", targetid); sbsms = sbsms.Replace("#MONEY#", investAmt.ToString()); 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 = registerid; psms.smstype = smstype; psms.smscontext = sbsms.ToString(); psms.orderid = SendSMS.Send_SMS(mobile, sbsms.ToString()); psms.vcode = ""; osms.Add(psms); #endregion #region 远程调用生成合同??? 稍后替换为本地方法调用 微信端可远程调用 string postString = "action=MUserPDF&data=" + targetid.ToString() + "&uc=" + registerid.ToString() + "&OrdId=" + OrdId; string sr = Utils.PostWebRequest(Utils.GetRemote_url("pdf/index"), postString, Encoding.UTF8); #endregion #region 道合作 第一投标调用接口??? B_member_table bmt = new B_member_table(); M_member_table mmt = new M_member_table(); mmt = bmt.GetModel(registerid); if (mmt.Tid != null && mmt.Channelsource == 1) { if (B_usercenter.GetInvestCountByUserid(mmt.registerid) == 1) { string ret3 = Utils.GetCoopAPI(mmt.Tid, investAmt.ToString("0.00"), 2); LogInfo.WriteLog("前台渠道合作第一次返回结果:" + ret3 + " 用户id:" + mmt.registerid + " 订单id " + OrdId); } } #endregion #endregion 待提取为公共方法 //发放奖励 ActFacade act = new ActFacade(); act.SendBonusAfterInvest(dt, EnumCommon.E_hx_ActivityTable.E_ActTargetPlatform.web); } } } }
/// <summary> /// 充值汇付后台主动通知 /// </summary> /// <returns></returns> public ActionResult ReQPNetSave() { string str1 = ""; lock (this) { Settings.Instance.SetSYSDateTimeFormat(); ReQPNetSave m = new ReQPNetSave(); m.CmdId = DNTRequest.GetString("CmdId"); m.RespCode = DNTRequest.GetString("RespCode"); m.RespDesc = HttpUtility.UrlDecode(DNTRequest.GetString("RespDesc")); m.MerCustId = DNTRequest.GetString("MerCustId"); m.UsrCustId = DNTRequest.GetString("UsrCustId"); m.OrdId = DNTRequest.GetString("OrdId"); m.OrdDate = DNTRequest.GetString("OrdDate"); m.TransAmt = DNTRequest.GetString("TransAmt"); m.TrxId = DNTRequest.GetString("TrxId"); m.GateBusiId = DNTRequest.GetString("GateBusiId"); m.GateBankId = DNTRequest.GetString("GateBankId"); m.FeeAmt = DNTRequest.GetString("FeeAmt"); m.FeeCustId = DNTRequest.GetString("FeeCustId"); m.FeeAcctId = DNTRequest.GetString("FeeAcctId"); m.RetUrl = HttpUtility.UrlDecode(DNTRequest.GetString("RetUrl")); m.BgRetUrl = HttpUtility.UrlDecode(DNTRequest.GetString("BgRetUrl")); m.CardId = DNTRequest.GetString("CardId"); m.MerPriv = HttpUtility.UrlDecode(DNTRequest.GetString("MerPriv")); // m.MerPriv = DESEncrypt.Decrypt(DNTRequest.GetString("MerPriv"), ConfigurationManager.AppSettings["webp"].ToString()); m.ChkValue = DNTRequest.GetString("ChkValue"); StringBuilder chkVal = new StringBuilder(); chkVal.Append(m.CmdId); chkVal.Append(m.RespCode); chkVal.Append(m.MerCustId); chkVal.Append(m.UsrCustId); chkVal.Append(m.OrdId); chkVal.Append(m.OrdDate); chkVal.Append(m.TransAmt); chkVal.Append(m.TrxId); chkVal.Append(m.RetUrl); chkVal.Append(m.BgRetUrl); chkVal.Append(m.MerPriv); string msg = chkVal.ToString(); //私钥文件的位置(这里是放在了站点的根目录下) string merKeyFile = AppDomain.CurrentDomain.BaseDirectory + Settings.Instance.PgPubk; //需要指定提交字符串的长度 int len = Encoding.UTF8.GetBytes(msg).Length; StringBuilder sbChkValue = new StringBuilder(256); int ret = DllInterop.VeriSignMsg(merKeyFile, msg, msg.Length, m.ChkValue); // Response.Write("验签:" + ret.ToString()); LoggerHelper.Info("快充接口后台验签:ret=" + ret.ToString() + " RespCode:" + m.RespCode + m.RespDesc); LoggerHelper.Info("快充接口后台充值返回报文:" + JsonHelper.Entity2Json(m)); StringBuilder str = new StringBuilder(); string sql = ""; if (ret == 0) { if (m.RespCode == "000") { string MerPrivTemp = EncryptHelper.Decrypt(m.MerPriv, Settings.Instance.WebPass); string[] arr = Settings.Instance.SplitString(MerPrivTemp, "_"); //第一位是用户id 二是 记录id int userid = int.Parse(arr[0]); int reid = int.Parse(arr[1]); string cachename = m.OrdId + userid.ToString() + reid.ToString(); if (Settings.Instance.GeTThirdCache(cachename) == 0) { Settings.Instance.SetThirdCache(cachename); sql = "select recharge_condition from hx_Recharge_history where recharge_condition=0 and recharge_history_id=" + reid + " and order_No='" + m.OrdId + "'"; DataTable dtr = DbHelper.Query(sql).Tables[0]; if (dtr.Rows.Count > 0) { LoggerHelper.Info("快充接口后台充值数据没有写入情况下操作>>>>>>>>>>>>>>>>>>>>>>>"); M_Recharge_history rh = new M_Recharge_history(); M_Capital_account_water aw = new M_Capital_account_water(); B_member_table o = new B_member_table(); M_member_table p = new M_member_table(); p = o.GetModel(userid); rh.membertable_registerid = userid; rh.recharge_amount = decimal.Parse(m.TransAmt); rh.recharge_time = DateTime.Now; rh.account_amount = decimal.Parse(m.TransAmt); rh.order_No = m.OrdId; rh.recharge_condition = 1; //1表示充值成功 rh.recharge_bank = m.GateBankId; // 得接口返回; rh.recharge_history_id = reid; //本值提交里存的充值id aw.membertable_registerid = userid; aw.income = decimal.Parse(m.TransAmt); aw.expenditure = 0.00M; aw.time_of_occurrence = rh.recharge_time; aw.account_balance = p.available_balance + aw.income; //要得么帐户余额 aw.types_Finance = (int)Enum.Parse(typeof(EnumTypesFinance), EnumTypesFinance.充值.ToString()); aw.createtime = DateTime.Now; aw.keyid = 0; aw.remarks = m.OrdId; B_usercenter BUC = new B_usercenter(); int bucrec = BUC.rechargeTran(rh, aw); LoggerHelper.Info("后台充值事务操作返回码小于=0 操作失败:" + bucrec.ToString()); if (m.GateBusiId == "QP") { sql = "select UsrBindCardID from hx_UsrBindCardC where UsrCustId='" + m.UsrCustId + "' and OpenAcctId='" + m.CardId + "'"; DataTable dt = DbHelper.Query(sql).Tables[0]; if (dt.Rows.Count > 0) { } else { sql = "INSERT INTO hx_UsrBindCardC (UsrCustId,OpenAcctId,OpenBankId,defCard) VALUES ('" + m.UsrCustId + "','" + m.CardId + "','" + m.GateBankId + "',1)"; DbHelper.Query(sql); sql = "update hx_member_table set isbankcard=1 where registerid=" + userid.ToString(); DbHelper.Query(sql); } } } } str1 = "RECV_ORD_ID_" + m.TrxId; } } } return(Content(str1)); }
/// <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); }
/// <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); }
/// <summary> /// 邀请注册奖励活动 /// </summary> /// <param name="registerid">注册用户id</param> /// <param name="ActUser">面向用户 0不限 1首次投资用户 2非首投用户 3每标首投用户 4每标最大投资用户 5所有投资用户</param> protected internal void SendBonusForInviteAfterRegister(int registerid, string targetPlatform, int ActUser = 0) { #region MyRegion //邀请奖励处理逻辑,暂无邀请奖励 bool flag = true; if (flag) { if (registerid < 0) { return; } DateTime dte = DateTime.Now; string codesql = "SELECT invcode,Invpeopleid,invpersonid,invtime from hx_td_Userinvitation where invpersonid=" + registerid.ToString();//查询本人是否已经被邀请注册过 invcode='" + invcode + "' and LogInfo.WriteLog("codesql2:" + codesql); DataTable dtcode = DbHelperSQL.GET_DataTable_List(codesql); //邀请奖励处理逻辑 if (dtcode.Rows.Count > 0) { B_member_table oy = new B_member_table(); M_member_table py = new M_member_table(); //获取邀请用户id int invpeopleid = int.Parse(dtcode.Rows[0]["Invpeopleid"].ToString()); py = oy.GetModel(invpeopleid); if (py.useridentity != 4 && py.iD_number != "")//渠道用户不执行 { DateTime nowdate = DateTime.Now; DateTime startdate = new DateTime(2017, 1, 6, 0, 00, 00); DateTime enddate = new DateTime(2017, 3, 31, 23, 59, 59); DateTime invtime = Convert.ToDateTime(dtcode.Rows[0]["invtime"].ToString()); //邀请时间 #region 生成奖励,记录流水 //??待优化到奖励内部记录 if ((nowdate > startdate && nowdate < enddate) && (invtime > startdate && invtime < enddate)) { List <hx_UserAct> hut = InviteActBonus(py.registerid, targetPlatform, registerid, -1M, 0, 4, 1, 0, 5); string strlog = "用户:" + py.registerid + ",邀请奖励返回实体:" + hut.Count; if (hut.Count > 0) { foreach (hx_UserAct ua in hut) { if (ua.Amt != null && ua.Amt > 0) { string sql = "update hx_td_Userinvitation set Invitereward=" + ua.Amt + ",UserAct= " + ua.UserAct + " where invpersonid=" + int.Parse(dtcode.Rows[0]["invpersonid"].ToString()); strlog += ";更新邀请表:" + sql; DbHelperSQL.ExecuteSql(sql); #region MyRegion 记录奖励流水表 string awardDescription = string.Format("邀请好友注册成功,获得{0}{1}", Convert.ToDouble(ua.Amt.ToString()), GetBunusDescription(ua.RewTypeID)); AddBonusAccoutWater(ua.UserAct, py.registerid, decimal.Parse(ua.Amt.ToString()), awardDescription, registerid); #endregion strlog += ";" + awardDescription; #region MyRegion 发送系统消息 string MContext = string.Format("尊敬的用户:您邀请好友注册成功,获得{0}{1}如有问题可咨询创利投的客服!", ua.Amt.ToString(), GetBunusDescription(ua.RewTypeID)); AddSytemMessage(py.registerid, "邀请好友注册奖励", MContext); #endregion strlog += ";ua.RewTypeID:" + ua.RewTypeID; if (ua.RewTypeID == 1) { #region 资金流水信息 B_usercenter o = new B_usercenter(); decimal di = o.GetUsridAvailable_balance(py.registerid); //di = di + decimal.Parse(ua.Amt.ToString()); StringBuilder strSql = new StringBuilder(); strSql.Append("insert into hx_Capital_account_water("); strSql.Append("membertable_registerid,income,expenditure,time_of_occurrence,account_balance,types_Finance,createtime,keyid,remarks)"); strSql.Append(" values ("); strSql.Append("" + py.registerid + "," + decimal.Parse(ua.Amt.ToString()) + ",0,'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'," + di + "," + (int)Enum.Parse(typeof(EnumTypesFinance), EnumTypesFinance.邀请奖励.ToString()) + ",'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',0,'" + awardDescription + "')"); strlog += ";邀请好友注册奖励流水语句:" + strSql.ToString(); DbHelperSQL.RunSql(strSql.ToString()); strSql.Clear(); #endregion } } } } LogInfo.WriteLog(strlog); } #endregion #region 11月活动,每邀请5位好友实名注册,奖励邀请人2%加息券一张 if ((nowdate > startdate && nowdate < enddate) && (invtime > startdate && invtime < enddate)) { string log = "11月活动用户" + invpeopleid + "每邀请5位好友,当前好友(" + registerid + ")实名注册奖励邀请人2%加息券一张: "; //查询活动期间内邀请人累计邀请实名注册人数 string strSQL = string.Format("select COUNT(mt.registerid) recount from hx_td_Userinvitation ut inner join hx_member_table mt on ut.invpersonid=mt.registerid where mt.iD_number <> '' and mt.useridentity <> 4 and mt.registration_time >= '{0}' and mt.registration_time <= '{1}' and ut.Invpeopleid={2}", startdate.ToString("yyyy-MM-dd HH:mm:ss"), enddate.ToString("yyyy-MM-dd HH:mm:ss"), invpeopleid); log += "查询活动期间邀请实名人数sql:" + strSQL; DataTable dtcount = DbHelperSQL.GET_DataTable_List(strSQL); if (dtcount.Rows.Count > 0) { int recount = int.Parse(dtcount.Rows[0]["recount"].ToString()); log += "<br>累计实名人数:" + recount; if (recount > 0) { if (recount % 5 == 0) { log += "<br>实名人数" + dtcount.Rows.Count + "人,执行奖励操作"; List <hx_UserAct> t = new List <hx_UserAct>(); hx_ActivityTable hat = new hx_ActivityTable(); hat = GetActTableInfo(4, targetPlatform, ActUser, 1, 1); //赋值11月活动RewTypeID为1 ,主要获取活动起止时间,真正发放奖励hua.RewTypeID是3 加息券 if (hat != null && hat.ActID > 0) { hx_UserAct hua = new hx_UserAct(); hua.ActTypeId = hat.ActTypeId; //活动类型id 1新人活动/2短期活动/3常规活动/4邀请活动/5系统赠送 hua.registerid = invpeopleid; //邀请人ID hua.RewTypeID = 3; //奖励类型id 1现金/2抵扣券/3加息券 hua.ActID = hat.ActID; hua.Amt = 2; //2%加息券 hua.Uselower = 100; hua.Usehight = 0; hua.AmtEndtime = DateTime.Now.Date.AddDays(31).AddSeconds(-1); // DateTime.Parse(hat.ActEndtime.ToString()); hua.AmtUses = 1; //使用要求 1单独使用,2组合使用 hua.UseState = 0; //使用状态 0 未使用 1 已使用 2已过期 3 锁定中 hua.AmtProid = 0; //未使用默认为0 hua.ISSmsOne = 0; hua.IsSmsThree = 0; hua.isSmsFifteen = 0; hua.IsSmsSeven = 0; hua.isSmsSixteen = 0; hua.Createtime = DateTime.Now; hua.Title = "11月活动每邀请5位好友送2%加息券"; hua.UseLifeLoan = "3-0"; ef.hx_UserAct.Add(hua); int i = ef.SaveChanges(); if (i > 0) { log += "<br>2%加息券奖励发放成功"; if (hua.Amt != null && hua.Amt > 0) { #region MyRegion 发送系统消息 string MContext = string.Format("尊敬的用户:您邀请{0}好友实名注册成功,获得{1}{2}如有问题可咨询创利投的客服!", recount, hua.Amt.ToString(), GetBunusDescription(hua.RewTypeID)); AddSytemMessage(registerid, "邀请好友注册奖励", MContext); #endregion } } } } } } LogInfo.WriteLog(log); } #endregion #region 11月活动,被邀请人实名注册,奖励2%加息券一张 if ((nowdate > startdate && nowdate < enddate) && (invtime > startdate && invtime < enddate)) { string log = "11月活动,被邀请人(" + registerid + ")实名注册奖励2%加息券一张: "; List <hx_UserAct> t = new List <hx_UserAct>(); hx_ActivityTable hat = new hx_ActivityTable(); hat = GetActTableInfo(4, targetPlatform, ActUser, 1, 1); //赋值11月活动RewTypeID为1 ,主要获取活动起止时间,真正发放奖励hua.RewTypeID是3 加息券 if (hat != null && hat.ActID > 0) { hx_UserAct hua = new hx_UserAct(); hua.ActTypeId = hat.ActTypeId; //活动类型id 1新人活动/2短期活动/3常规活动/4邀请活动/5系统赠送 hua.registerid = registerid; //注册人ID hua.RewTypeID = 3; //奖励类型id 1现金/2抵扣券/3加息券 hua.ActID = hat.ActID; hua.Amt = 2; //2%加息券 hua.Uselower = 100; hua.Usehight = 0; hua.AmtEndtime = DateTime.Now.Date.AddDays(31).AddSeconds(-1); // DateTime.Parse(hat.ActEndtime.ToString()); hua.AmtUses = 1; //使用要求 1单独使用,2组合使用 hua.UseState = 0; //使用状态 0 未使用 1 已使用 2已过期 3 锁定中 hua.AmtProid = 0; //未使用默认为0 hua.ISSmsOne = 0; hua.IsSmsThree = 0; hua.isSmsFifteen = 0; hua.IsSmsSeven = 0; hua.isSmsSixteen = 0; hua.Createtime = DateTime.Now; hua.Title = "11月活动实名注册送2%加息券"; hua.UseLifeLoan = "3-0"; //待添加加息券使用标的 ef.hx_UserAct.Add(hua); int i = ef.SaveChanges(); if (i > 0) { log += "<br>2%加息券奖励发放成功"; if (hua.Amt != null && hua.Amt > 0) { #region MyRegion 发送系统消息 string MContext = string.Format("尊敬的用户:您实名注册成功,获得{0}{1}如有问题可咨询创利投的客服!", hua.Amt.ToString(), GetBunusDescription(hua.RewTypeID)); AddSytemMessage(registerid, "邀请好友注册奖励", MContext); #endregion } } } LogInfo.WriteLog(log); } #endregion } } } #endregion }
public ActionResult PlatformToUserMoney(string UsrCustId = "", decimal money = 0) { string keypassword = ConfigurationManager.AppSettings["RechargePassWord"].ToString(); string password = DNTRequest.GetFormString("pssword"); if (string.IsNullOrEmpty(UsrCustId)) { return(Content(StringAlert.Alert("客户号不可以为空!"), "text/html")); } if (money <= 0) { return(Content(StringAlert.Alert("转账金额错误!"), "text/html")); } if (String.IsNullOrEmpty(password)) { return(Content(StringAlert.Alert("密码不能为空!"), "text/html")); } if (keypassword != password) { return(Content(StringAlert.Alert("充值密码不正确"), "text/html")); } M_Transfer m = new M_Transfer(); m.Version = "10"; m.CmdId = "Transfer"; m.OrdId = Utils.Createcode(); m.OutCustId = Utils.GetMerCustID(); m.OutAcctId = "MDT000001"; m.TransAmt = money.ToString("0.00"); m.InCustId = Utils.CheckSQLHtml(UsrCustId); m.BgRetUrl = Utils.GetRe_url("admin/Thirdparty/BgToUserTransfer"); 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("加签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("加签字符:" + str.ToString()); m.ChkValue = sbChkValue.ToString(); LogInfo.WriteLog("提交信息:" + FastJSON.toJOSN(m)); LogInfo.WriteLog("ChkValue:" + m.ChkValue); string _resultStr = ""; 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("自动扣款转账(商户用)返回报文" + 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(retloan.RetUrl); builder.Append(retloan.BgRetUrl); builder.Append(retloan.MerPriv); var msg = builder.ToString(); LogInfo.WriteLog("返回参数:" + msg); //验签 string pgPubkFile = AppDomain.CurrentDomain.BaseDirectory + Utils.GetPgPubk(); int ret = DllInterop.VeriSignMsg(pgPubkFile, msg, msg.Length, retloan.ChkValue); LogInfo.WriteLog("验签ret:" + ret.ToString()); if (ret == 0) { if (retloan.RespCode == "000") { //_resultStr = retloan.RespCode.ToString() + " <br> " + HttpUtility.UrlDecode(retloan.RespDesc) + "<br>转账成功"; #region 流水信息 string sql = "SELECT registerid,username,mobile from hx_member_table where UsrCustId='" + retloan.InCustId + "'"; System.Data.DataTable dt = DbHelperSQL.GET_DataTable_List(sql); if (dt.Rows.Count > 0) { 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(retloan.TransAmt) + ",0,'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'," + (di + decimal.Parse(retloan.TransAmt)) + "," + (int)Enum.Parse(typeof(EnumTypesFinance), EnumTypesFinance.平台向用户划账.ToString()) + ",'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',0,'" + "平台向用户划账" + "')"); DbHelperSQL.RunSql(strSql.ToString()); strSql.Clear(); } #endregion _resultStr = "<br>转账成功"; } else { _resultStr = HttpUtility.UrlDecode(retloan.RespDesc); } } } ViewBag.str = _resultStr; return(View()); }
public ActionResult Changepass() { string json = ""; string tel1 = Utils.CheckSQLHtml(DNTRequest.GetString("t")); string rid1 = Utils.CheckSQLHtml(DNTRequest.GetString("key")); string vcode1 = Utils.CheckSQLHtml(DNTRequest.GetString("c")); string pcode1 = Utils.CheckSQLHtml(DNTRequest.GetString("p")); string rid = ""; if (rid1 != "") { rid = DESEncrypt.Decrypt(rid1, ConfigurationManager.AppSettings["webp"].ToString()); } string tel = ""; if (tel1 != "") { tel = DESEncrypt.Decrypt(tel1, ConfigurationManager.AppSettings["webp"].ToString()); } string vcode = ""; if (vcode1 != "") { vcode = DESEncrypt.Decrypt(vcode1, ConfigurationManager.AppSettings["webp"].ToString()); } string pcode = ""; if (pcode1 != "") { pcode = DESEncrypt.Decrypt(pcode1, ConfigurationManager.AppSettings["webp"].ToString()); } string pass = ""; string sql = ""; if (pcode == "gettel") { sql = "select top 1 smscontext,phone_number from hx_td_SMS_record where ( smstype=8 or smstype=7) and phone_number='" + tel + "' and vcode='" + vcode + "' and DATEDIFF(MINUTE,sendtime,getDate())<3 order by sms_record_id desc"; DataTable dtc = DbHelperSQL.GET_DataTable_List(sql); var ts = true; if (Settings.Instance.SiteDomain.IndexOf(PublicURL.NewPCUrl) >= 0) { ts = false; } if (dtc.Rows.Count > 0 || ts) { sql = "select registerid,mobile from hx_member_table where registerid=" + rid + " and mobile='" + tel + "' "; DataTable dt = DbHelperSQL.GET_DataTable_List(sql); if (dt.Rows.Count > 0) { pass = DESEncrypt.Encrypt(Utils.CheckSQLHtml(DNTRequest.GetString("userpassword")), ConfigurationManager.AppSettings["webp"].ToString()); sql = "update hx_member_table set password='******' where registerid=" + rid; if (DbHelperSQL.ExecuteSql(sql) > 0) { DateTime dti = DateTime.Now; M_td_System_message p = new M_td_System_message(); p.MReg = int.Parse(dt.Rows[0]["registerid"].ToString()); p.Mstate = 0; p.MTitle = "安全提示"; p.MContext = "您在" + dti.ToString("yyyy-MM-dd HH:mm:ss") + "使用手机进行了密码找回操作,如非本人操作请联系客服"; p.PubTime = dti; B_usercenter.AddMessage(p); 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(17, 1); // 获取注册成功邮件内容 StringBuilder sbsms = new StringBuilder(smscontxt); string mobile = tel; sbsms = sbsms.Replace("#DATATIME#", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); pm.phone_number = mobile; pm.sendtime = DateTime.Now; pm.senduserid = int.Parse(dt.Rows[0]["registerid"].ToString()); pm.smstype = smstype; pm.smscontext = sbsms.ToString(); // p.orderid = SendSMS.Send_SMS(mobile, sbsms.ToString()); pm.orderid = SendSMS.Send_Audio(mobile, smscontxt); pm.vcode = ""; om.Add(pm); json = @" {""rs"": ""y"", ""info"": ""新密码设置成功!"",""url"":""/""}"; return(Content(json)); } else { json = @" {""rs"": ""n"", ""info"": ""新密码设置失败!""}"; return(Content(json)); } } else { json = @" {""rs"": ""n"", ""info"": ""数据异常!""}"; return(Content(json)); } } else { json = @" {""rs"": ""n"", ""info"": ""验证码无效,或已经过期,请重新获取!""}"; return(Content(json)); } } return(Content(json)); }
public ActionResult BgUsrPay() { string str = ""; ReUsrAcctPay m = new ReUsrAcctPay(); m.CmdId = DNTRequest.GetString("CmdId"); m.RespCode = DNTRequest.GetString("RespCode"); m.RespDesc = HttpUtility.UrlDecode(DNTRequest.GetString("RespDesc")); m.OrdId = DNTRequest.GetString("OrdId"); m.UsrCustId = DNTRequest.GetString("UsrCustId"); m.MerCustId = DNTRequest.GetString("MerCustId"); m.TransAmt = DNTRequest.GetString("TransAmt"); m.InAcctId = DNTRequest.GetString("InAcctId"); m.InAcctType = DNTRequest.GetString("InAcctType"); m.RetUrl = HttpUtility.UrlDecode(DNTRequest.GetString("RetUrl")); m.BgRetUrl = HttpUtility.UrlDecode(DNTRequest.GetString("BgRetUrl")); m.MerPriv = DNTRequest.GetString("MerPriv"); m.ChkValue = DNTRequest.GetString("ChkValue"); StringBuilder chkVal = new StringBuilder(); chkVal.Append(m.CmdId); chkVal.Append(m.RespCode); chkVal.Append(m.OrdId); chkVal.Append(m.UsrCustId); chkVal.Append(m.MerCustId); chkVal.Append(m.TransAmt); chkVal.Append(m.InAcctId); chkVal.Append(m.InAcctType); chkVal.Append(m.RetUrl); chkVal.Append(m.BgRetUrl); chkVal.Append(m.MerPriv); string chkv = chkVal.ToString(); string logstr = "RECV_ORD_ID_" + m.OrdId; //私钥文件的位置(这里是放在了站点的根目录下) string merKeyFile = AppDomain.CurrentDomain.BaseDirectory + Utils.GetPgPubk(); int ret = DllInterop.VeriSignMsg(merKeyFile, chkv, chkv.Length, m.ChkValue); LogInfo.WriteLog("用户向平台商户号转账返回信息:" + FastJSON.toJOSN(m)); if (ret == 0) { if (m.RespCode == "000") { string cachename = m.OrdId + "BgUsrPay" + m.UsrCustId; if (Utils.GeTThirdCache(cachename) == 0) { Utils.SetThirdCache(cachename); string sql = "update hx_member_table set available_balance=available_balance-" + m.TransAmt + " where UsrCustId='" + m.UsrCustId + "'"; DbHelperSQL.RunSql(sql); #region 流水信息 sql = "SELECT registerid,username,mobile from hx_member_table where UsrCustId='" + m.UsrCustId + "'"; System.Data.DataTable dt = DbHelperSQL.GET_DataTable_List(sql); if (dt.Rows.Count > 0) { 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()) + ",0," + decimal.Parse(m.TransAmt) + ",'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'," + (di - decimal.Parse(m.TransAmt)) + "," + (int)Enum.Parse(typeof(EnumTypesFinance), EnumTypesFinance.用户向平台划账.ToString()) + ",'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',0,'" + "用户向平台划账" + "')"); DbHelperSQL.RunSql(strSql.ToString()); strSql.Clear(); } #endregion //Response.Write(logstr + "转账成功!"); LogInfo.WriteLog(logstr + "用户向平台商户号转账成功:" + sql); } } } else { LogInfo.WriteLog(m.UsrCustId + "用户向平台商户号转账后台失败:"); } return(Content(logstr)); }
/// <summary> /// 汇付主动通知页面 /// </summary> /// <returns></returns> public ActionResult CashBgCallback() { string str1 = ""; ReCash m = new ReCash(); m.CmdId = DNTRequest.GetString("CmdId"); m.RespCode = DNTRequest.GetString("RespCode"); m.RespDesc = HttpUtility.UrlDecode(DNTRequest.GetString("RespDesc")); m.MerCustId = DNTRequest.GetString("MerCustId"); m.OrdId = DNTRequest.GetString("OrdId"); m.UsrCustId = DNTRequest.GetString("UsrCustId"); m.TransAmt = DNTRequest.GetString("TransAmt"); m.OpenAcctId = DNTRequest.GetString("OpenAcctId"); m.OpenBankId = DNTRequest.GetString("OpenBankId"); m.FeeAmt = DNTRequest.GetString("FeeAmt"); m.FeeCustId = DNTRequest.GetString("FeeCustId"); m.FeeAcctId = DNTRequest.GetString("FeeAcctId"); m.ServFee = DNTRequest.GetString("ServFee"); m.ServFeeAcctId = DNTRequest.GetString("ServFeeAcctId"); m.RetUrl = HttpUtility.UrlDecode(DNTRequest.GetString("RetUrl")); m.BgRetUrl = HttpUtility.UrlDecode(DNTRequest.GetString("BgRetUrl")); m.MerPriv = DNTRequest.GetString("MerPriv"); m.RespExt = HttpUtility.UrlDecode(DNTRequest.GetString("RespExt")); m.ChkValue = DNTRequest.GetString("ChkValue"); m.RealTransAmt = DNTRequest.GetString("RealTransAmt"); LoggerHelper.Info("后台取现返回报文:" + JsonHelper.Entity2Json(m)); //验签 StringBuilder chkVal = new StringBuilder(); chkVal.Append(m.CmdId); chkVal.Append(m.RespCode); chkVal.Append(m.MerCustId); chkVal.Append(m.OrdId); chkVal.Append(m.UsrCustId); chkVal.Append(m.TransAmt); chkVal.Append(m.OpenAcctId); chkVal.Append(m.OpenBankId); chkVal.Append(m.FeeAmt); chkVal.Append(m.FeeCustId); chkVal.Append(m.FeeAcctId); chkVal.Append(m.ServFee); chkVal.Append(m.ServFeeAcctId); chkVal.Append(m.RetUrl); chkVal.Append(m.BgRetUrl); chkVal.Append(m.MerPriv); chkVal.Append(m.RespExt); string msg = chkVal.ToString(); //私钥文件的位置(这里是放在了站点的根目录下) string merKeyFile = AppDomain.CurrentDomain.BaseDirectory + Settings.Instance.PgPubk; //需要指定提交字符串的长度 int len = Encoding.UTF8.GetBytes(msg).Length; StringBuilder sbChkValue = new StringBuilder(256); int ret = DllInterop.VeriSignMsg(merKeyFile, msg, msg.Length, m.ChkValue); // LoggerHelper.Info("验签返回参数:" + ret.ToString()); StringBuilder str = new StringBuilder(); if (ret == 0) { //提现成功后,得多事务处理账户金额,流水及冻结金额等 if (m.RespCode == "000") { string cachename = m.OrdId + "Cash" + m.UsrCustId; if (Settings.Instance.GeTThirdCache(cachename) == 0) { Settings.Instance.SetThirdCache(cachename); B_usercenter BUC = new B_usercenter(); M_ReqExt mr = new M_ReqExt(); mr = FastJSON.ToObject <M_ReqExt>(m.RespExt.Replace("[", "").Replace("]", "")); int CashOp = BUC.CashTran(m.OpenAcctId, m.OpenBankId, m.OrdId, m.RealTransAmt, m.UsrCustId, m.FeeAmt, mr.FeeObjFlag, mr.CashChl); if (CashOp > 0) { string sql = "select registerid,username,mobile,UsrCustId,available_balance from hx_member_table where UsrCustId='" + m.UsrCustId + "'"; LoggerHelper.Info("后台审请取现成功短信sql:" + sql); DataTable dt = DbHelper.Query(sql).Tables[0]; if (dt.Rows.Count > 0) { //短信通知 //尊敬的#USERANEM#,您已成功提现#MONEY#元,账户余额#MONEY1#.请注意查收!【创利投】 MemberLogic _logic = new MemberLogic(); var ebt = _logic.GetSmsEmailEntity(1, 12); // 获取内容 string contxt = ebt.SEContext; StringBuilder sbsms = new StringBuilder(contxt); sbsms = sbsms.Replace("#USERANEM#", dt.Rows[0]["username"].ToString()); sbsms = sbsms.Replace("#MONEY#", m.TransAmt); decimal amt = decimal.Parse(dt.Rows[0]["available_balance"].ToString()) - decimal.Parse(m.TransAmt); sbsms = sbsms.Replace("#MONEY1#", amt.ToString()); 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(mobile, sbsms.ToString()); psms.vcode = ""; osms.Add(psms); 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 = sbsms.ToString(); pm.PubTime = dti; pm.Mtype = 3; B_usercenter.AddMessage(pm); //即时提现,提现金额小于等于20万自动审核,高于20万人工审核 string cashChl = Enum.GetName(typeof(EnumCommon.E_hx_td_UserCash.EnumCashChl), (int)EnumCommon.E_hx_td_UserCash.EnumCashChl.IMMEDIATE); if (mr.CashChl == cashChl && decimal.Parse(m.TransAmt) <= 200000) { string retUrl = Settings.Instance.ImagesDomain + "/admin/UserCash/RePostCashProcessing"; string bgRetUrl = Settings.Instance.ImagesDomain + "/admin/Thirdparty/BgCashProcessing"; BusinessLogicHelper.AutoCheckCash(m.UsrCustId, retUrl, bgRetUrl); } } } } str1 = "RECV_ORD_ID_" + m.OrdId; } } return(Content(str1)); }
public ActionResult Su_Repayment() { Utils.SetSYSDateTimeFormat(); chuangtouEntities ef = new chuangtouEntities(); string str = ""; ReRepayment Re = new ReRepayment(); Re.CmdId = DNTRequest.GetString("CmdId"); Re.RespCode = DNTRequest.GetString("RespCode"); Re.MerCustId = DNTRequest.GetString("MerCustId"); Re.ProId = DNTRequest.GetString("ProId"); Re.OrdId = DNTRequest.GetString("OrdId"); Re.OrdDate = DNTRequest.GetString("OrdDate"); Re.OutCustId = DNTRequest.GetString("OutCustId"); Re.SubOrdId = DNTRequest.GetString("SubOrdId"); Re.SubOrdDate = DNTRequest.GetString("SubOrdDate"); Re.OutAcctId = DNTRequest.GetString("OutAcctId"); Re.TransAmt = DNTRequest.GetString("TransAmt"); Re.PrincipalAmt = DNTRequest.GetString("PrincipalAmt"); Re.InterestAmt = DNTRequest.GetString("InterestAmt"); Re.Fee = DNTRequest.GetString("Fee"); Re.InCustId = DNTRequest.GetString("InCustId"); Re.InAcctId = DNTRequest.GetString("InAcctId"); Re.FeeObjFlag = DNTRequest.GetString("FeeObjFlag"); Re.DzObject = DNTRequest.GetString("DzObject"); Re.BgRetUrl = DNTRequest.GetString("BgRetUrl"); Re.MerPriv = DNTRequest.GetString("MerPriv"); Re.RespExt = DNTRequest.GetString("RespExt"); LogInfo.WriteLog("后台还款返回报文:" + FastJSON.toJOSN(Re)); string version = "20"; if (string.IsNullOrEmpty(Re.TransAmt) || Re.TransAmt == "0.00") { version = "30"; } StringBuilder builder = new StringBuilder(); builder.Append(Re.CmdId); builder.Append(Re.RespCode); builder.Append(Re.MerCustId); if (version == "30") { builder.Append(Re.ProId); } builder.Append(Re.OrdId); builder.Append(Re.OrdDate); builder.Append(Re.OutCustId); builder.Append(Re.SubOrdId); builder.Append(Re.SubOrdDate); builder.Append(Re.OutAcctId); if (version == "30") { builder.Append(Re.PrincipalAmt); builder.Append(Re.InterestAmt); } else { builder.Append(Re.TransAmt); } builder.Append(Re.Fee); builder.Append(Re.InCustId); builder.Append(Re.InAcctId); builder.Append(Re.FeeObjFlag); if (version == "30") { builder.Append(Re.DzObject); } builder.Append(HttpUtility.UrlDecode(Re.BgRetUrl)); builder.Append(Re.MerPriv); builder.Append(HttpUtility.UrlDecode(Re.RespExt)); // builder.Append(Re.ChkValue); var msg = builder.ToString(); if (version == "30") { msg = Utils.MD5(msg); } string pgPubkFile = AppDomain.CurrentDomain.BaseDirectory + Utils.GetPgPubk(); int ret = DllInterop.VeriSignMsg(pgPubkFile, msg, msg.Length, Re.ChkValue); LogInfo.WriteLog("后台验签 ret= " + ret.ToString()); if (ret == 0) { if (Re.RespCode == "000" || Re.TransAmt == "0.00") { string cachename = "Repayment" + Re.OrdId; if (Utils.GeTThirdCache(cachename) == 0) { Utils.SetThirdCache(cachename); B_member_table o = new B_member_table(); M_member_table p = new M_member_table(); M_member_table p2 = new M_member_table(); M_Capital_account_water baw = new M_Capital_account_water(); V_borrowing_Bid_records_income_statement item = new V_borrowing_Bid_records_income_statement(); int income_statement_id = int.Parse(Re.MerPriv); item = ef.V_borrowing_Bid_records_income_statement.AsNoTracking().Where(ps => ps.income_statement_id == income_statement_id).FirstOrDefault(); p = o.GetModel(int.Parse(item.borrower_registerid.ToString())); //借款人用户对象 baw.membertable_registerid = p.registerid; baw.income = 0.00M; baw.expenditure = decimal.Parse(Re.TransAmt); baw.time_of_occurrence = DateTime.Now; baw.account_balance = p.available_balance - baw.expenditure; //面要得么帐户余额 baw.types_Finance = (int)Enum.Parse(typeof(EnumTypesFinance), EnumTypesFinance.还款.ToString()); baw.createtime = DateTime.Now; baw.keyid = 0; baw.remarks = Re.OrdId + "," + Re.OrdDate; M_Capital_account_water iaw = new M_Capital_account_water(); //投资人流水对象 p2 = o.GetModel(int.Parse(item.investor_registerid.ToString())); //投资人用户对象 iaw.membertable_registerid = p2.registerid; iaw.income = decimal.Parse(Re.TransAmt); iaw.expenditure = 0.00M; iaw.time_of_occurrence = DateTime.Now; iaw.account_balance = p2.available_balance + iaw.income; //面要得么帐户余额 iaw.types_Finance = (int)Enum.Parse(typeof(EnumTypesFinance), EnumTypesFinance.借款人还款.ToString()); iaw.createtime = DateTime.Now; iaw.keyid = 0; iaw.remarks = Re.OrdId + "," + Re.OrdDate; int targetid = int.Parse(item.targetid.ToString()); //判断是否为最后一期还款,并进行相应状态处理 hx_repayment_plan plan = (from a in ef.hx_repayment_plan where a.targetid == targetid select a).OrderByDescending(a => a.current_period).Take(1).FirstOrDefault(); var lastcur = plan.current_period; //判断是否是最后一期,如果是对本金处理。得直接用最后一期还款金额减去本金,这样就解决多出本金问题 bool lastrepamt = false; if (item.current_investment_period.ToString() == lastcur.ToString()) { lastrepamt = true; } //需要更新投资记录表已还款金额 B_usercenter BUC = new B_usercenter(); decimal PrincipalInterest = decimal.Parse(item.Principal.ToString()) + decimal.Parse(item.interestpayment.ToString()); //本金加利息 decimal PInterest = decimal.Parse(item.interestpayment.ToString()); //利息 Re.MerPriv = DateTime.Parse(item.interest_payment_date.ToString()).ToString("yyyy-MM-dd"); //传入还款日期 int bucd = BUC.Repayment_Successfully(Re, baw, iaw, lastrepamt, PrincipalInterest, PInterest); if (bucd > 0) { // 尊敬#UserName#,您投资的第#PID#号标第#ORDER#期还款已到帐,本次已成功还款#MONEY#元.欢迎继续投资!【创利投】 #region 短信通知 //短信通知 string contxt = Utils.GetMSMEmailContext(11, 1); // 获取注册成功邮件内容 StringBuilder sbsms = new StringBuilder(contxt); sbsms = sbsms.Replace("#USERANEM#", item.username.ToString()); sbsms = sbsms.Replace("#PID#", item.targetid.ToString()); sbsms = sbsms.Replace("#ORDER#", item.current_investment_period.ToString()); sbsms = sbsms.Replace("#MONEY#", item.repayment_amount.ToString()); string mobile = item.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(item.investor_registerid.ToString()); psms.smstype = smstype; psms.smscontext = sbsms.ToString(); psms.orderid = SendSMS.Send_SMS(mobile, sbsms.ToString()); psms.vcode = ""; osms.Add(psms); #endregion #region 系统消息 //系统消息 DateTime dti = DateTime.Now; M_td_System_message pm = new M_td_System_message(); pm.MReg = int.Parse(item.investor_registerid.ToString()); pm.Mstate = 0; pm.MTitle = "投资回款"; // pm.MContext = "尊敬的用户" + dt.Rows[0]["username"].ToString() + ":您好!恭喜您成功投资了项目【" + dt.Rows[0]["borrowing_title"].ToString() + "】,投资金额是:" + dt.Rows[0]["investment_amount"].ToString() + "。如有问题可咨询创利投的客服!谢谢!"; pm.MContext = sbsms.ToString(); pm.PubTime = dti; pm.Mtype = 2; B_usercenter.AddMessage(pm); #endregion #region 更新标的状态为还还清 ///更新标的状态为还还清 if (item.current_investment_period.ToString() == lastcur.ToString()) { //更新标的状态为还还清 string sql = "update hx_borrowing_target set tender_state=5 where targetid=" + item.targetid.ToString() + ""; DbHelperSQL.ExecuteSql(sql); sql = "update hx_Bid_records set payment_status =1 where bid_records_id=" + item.bid_records_id.ToString(); DbHelperSQL.ExecuteSql(sql); } #endregion //Response.Write("还款验签成功!"); } else { //Response.Write("还款更新失败!" + bucd.ToString()); } } str = "RECV_ORD_ID_" + Re.OrdId; LogInfo.WriteLog(str + "后台还款成功"); } else { string cc = Utils.GetReturnCode(Int32.Parse(Re.RespCode)); if (cc.Contains("还款金额超过还款总额") || cc.Contains("重复的还款请求")) { B_member_table o = new B_member_table(); M_member_table p = new M_member_table(); M_member_table p2 = new M_member_table(); M_Capital_account_water baw = new M_Capital_account_water(); V_borrowing_Bid_records_income_statement item = new V_borrowing_Bid_records_income_statement(); int income_statement_id = int.Parse(Re.MerPriv); item = ef.V_borrowing_Bid_records_income_statement.AsNoTracking().Where(ps => ps.income_statement_id == income_statement_id).FirstOrDefault(); p = o.GetModel(int.Parse(item.borrower_registerid.ToString())); //借款人用户对象 baw.membertable_registerid = p.registerid; baw.income = 0.00M; baw.expenditure = decimal.Parse(Re.TransAmt); baw.time_of_occurrence = DateTime.Now; baw.account_balance = p.available_balance - baw.expenditure; //面要得么帐户余额 baw.types_Finance = (int)Enum.Parse(typeof(EnumTypesFinance), EnumTypesFinance.还款.ToString()); baw.createtime = DateTime.Now; baw.keyid = 0; baw.remarks = Re.OrdId + "," + Re.OrdDate; M_Capital_account_water iaw = new M_Capital_account_water(); //投资人流水对象 p2 = o.GetModel(int.Parse(item.investor_registerid.ToString())); //投资人用户对象 iaw.membertable_registerid = p2.registerid; iaw.income = decimal.Parse(Re.TransAmt); iaw.expenditure = 0.00M; iaw.time_of_occurrence = DateTime.Now; iaw.account_balance = p2.available_balance + iaw.income; //面要得么帐户余额 iaw.types_Finance = (int)Enum.Parse(typeof(EnumTypesFinance), EnumTypesFinance.借款人还款.ToString()); iaw.createtime = DateTime.Now; iaw.keyid = 0; iaw.remarks = Re.OrdId + "," + Re.OrdDate; int targetid = int.Parse(item.targetid.ToString()); //判断是否为最后一期还款,并进行相应状态处理 hx_repayment_plan plan = (from a in ef.hx_repayment_plan where a.targetid == targetid select a).OrderByDescending(a => a.current_period).Take(1).FirstOrDefault(); var lastcur = plan.current_period; //判断是否是最后一期,如果是对本金处理。得直接用最后一期还款金额减去本金,这样就解决多出本金问题 bool lastrepamt = false; if (item.current_investment_period.ToString() == lastcur.ToString()) { lastrepamt = true; } //需要更新投资记录表已还款金额 B_usercenter BUC = new B_usercenter(); decimal PrincipalInterest = decimal.Parse(item.Principal.ToString()) + decimal.Parse(item.interestpayment.ToString()); //本金加利息 decimal PInterest = decimal.Parse(item.interestpayment.ToString()); //利息 Re.MerPriv = DateTime.Parse(item.interest_payment_date.ToString()).ToString("yyyy-MM-dd"); //传入还款日期 int bucd = BUC.Repayment_Successfully(Re, baw, iaw, lastrepamt, PrincipalInterest, PInterest); if (bucd > 0) { // 尊敬#UserName#,您投资的第#PID#号标第#ORDER#期还款已到帐,本次已成功还款#MONEY#元.欢迎继续投资!【创利投】 #region 短信通知 //短信通知 string contxt = Utils.GetMSMEmailContext(11, 1); // 获取注册成功邮件内容 StringBuilder sbsms = new StringBuilder(contxt); sbsms = sbsms.Replace("#USERANEM#", item.username.ToString()); sbsms = sbsms.Replace("#PID#", item.targetid.ToString()); sbsms = sbsms.Replace("#ORDER#", item.current_investment_period.ToString()); sbsms = sbsms.Replace("#MONEY#", item.repayment_amount.ToString()); string mobile = item.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(item.investor_registerid.ToString()); psms.smstype = smstype; psms.smscontext = sbsms.ToString(); psms.orderid = SendSMS.Send_SMS(mobile, sbsms.ToString()); psms.vcode = ""; osms.Add(psms); #endregion #region 系统消息 //系统消息 DateTime dti = DateTime.Now; M_td_System_message pm = new M_td_System_message(); pm.MReg = int.Parse(item.investor_registerid.ToString()); pm.Mstate = 0; pm.MTitle = "投资回款"; // pm.MContext = "尊敬的用户" + dt.Rows[0]["username"].ToString() + ":您好!恭喜您成功投资了项目【" + dt.Rows[0]["borrowing_title"].ToString() + "】,投资金额是:" + dt.Rows[0]["investment_amount"].ToString() + "。如有问题可咨询创利投的客服!谢谢!"; pm.MContext = sbsms.ToString(); pm.PubTime = dti; pm.Mtype = 2; B_usercenter.AddMessage(pm); #endregion #region 更新标的状态为还还清 ///更新标的状态为还还清 if (item.current_investment_period.ToString() == lastcur.ToString()) { //更新标的状态为还还清 string sql = "update hx_borrowing_target set tender_state=5 where targetid=" + item.targetid.ToString() + ""; DbHelperSQL.ExecuteSql(sql); sql = "update hx_Bid_records set payment_status =1 where bid_records_id=" + item.bid_records_id.ToString(); DbHelperSQL.ExecuteSql(sql); } #endregion //Response.Write("还款验签成功!"); } else { //Response.Write("还款更新失败!" + bucd.ToString()); } } //Response.Write("出现错误! " + Utils.GetReturnCode(Int32.Parse(Re.RespCode))); /* * string cc = Utils.GetReturnCode(Int32.Parse(Re.RespCode)); * * * if (cc.Contains("还款金额超过还款总额") || cc.Contains("重复的还款请求")) * { * * B_member_table o = new B_member_table(); * M_member_table p = new M_member_table(); * M_member_table p2 = new M_member_table(); * M_Capital_account_water baw = new M_Capital_account_water(); * V_borrowing_Bid_records_income_statement item = new V_borrowing_Bid_records_income_statement(); * int income_statement_id = int.Parse(Re.MerPriv); * item = ef.V_borrowing_Bid_records_income_statement.AsNoTracking().Where(ps => ps.income_statement_id == income_statement_id).FirstOrDefault(); * p = o.GetModel(int.Parse(item.borrower_registerid.ToString())); //借款人用户对象 * * * int ic = ef.hx_income_statement.Where(c => c.bid_records_id == item.bid_records_id && c.targetid == item.targetid && c.orderid== Re.OrdId).Update(c => new hx_income_statement { payment_status = 1, repayment_period = DateTime.Now }); * * if (ic > 0) * { * int userid = int.Parse(item.borrower_registerid.ToString()); * UserInfoData ud = new UserInfoData(); * ReQueryBalanceBg retloan = ud.Querybalance(userid); * * if (retloan.RespCode == "000") * { * // sql = "update hx_member_table set available_balance=" + decimal.Parse(retloan.AvlBal) + " ,frozen_sum=" + decimal.Parse(retloan.FrzBal) + " where registerid=" + userid.ToString() + ""; * * //sql = "update hx_member_table set available_balance=" + decimal.Parse(retloan.AvlBal) + " where registerid=" + userid.ToString() + ""; * * //DbHelperSQL.RunSql(sql); * B_usercenter bu = new B_usercenter(); * bu.DataSync(retloan, userid.ToString()); * * * * * } * } */ } } return(Content(str)); }
public ActionResult CashProcessingMore(string str) { string json = ""; if (string.IsNullOrEmpty(str)) { json = @"{""ret"":0,""msg"":""参数错误""}"; } string strCount = ""; string bid = str; string[] s = bid.Split(new char[] { ',' }); string sqllist = ""; for (int i = 0; i < s.Length; i++) { sqllist = sqllist + "'" + s[i] + "',"; } if (sqllist.Contains(",")) { bid = Utils.ClearLastChar(sqllist); } int orstate = 1; sqllist = " select registerid,UserCashId,OrdId,OrdIdState,TransAmt,BankName,OpenBankId,OpenAcctId,UsrCustId,realname,Reason,Remarks,available_balance from V_UserCash_Bank "; sqllist += " where UserCashId in (" + bid + ")"; DataTable dt = DbHelperSQL.GET_DataTable_List(sqllist); int succ = 0, lost = 0; for (int i = 0; i < dt.Rows.Count; i++) { M_CashAudit mc = new M_CashAudit(); mc.Version = "10"; mc.CmdId = "CashAudit"; mc.MerCustId = Utils.GetMerCustID(); mc.OrdId = dt.Rows[i]["OrdId"].ToString(); mc.UsrCustId = dt.Rows[i]["UsrCustId"].ToString(); mc.TransAmt = dt.Rows[i]["TransAmt"].ToString(); //判定用户在审核期间内把卡号 移除或取消绑定 或 绑定 状态等于0 string bindCardSql = " SELECT * FROM hx_UsrBindCardC WHERE UsrCustId='{0}' AND OpenAcctId='{1}' "; bindCardSql = string.Format(bindCardSql, dt.Rows[i]["UsrCustId"].ToString(), dt.Rows[i]["OpenAcctId"].ToString()); DataTable bcDt = DbHelperSQL.GET_DataTable_List(bindCardSql); if (bcDt == null || bcDt.Rows.Count == 0) { orstate = 4; } if (orstate == 4) { mc.AuditFlag = "R"; } else { mc.AuditFlag = "S"; } // mc.BgRetUrl = ""; mc.BgRetUrl = Utils.GetRe_url("admin/Thirdparty/BgCashProcessing"); mc.MerPriv = "chuanglitou"; StringBuilder chkVal = new StringBuilder(); chkVal.Append(mc.Version); chkVal.Append(mc.CmdId); chkVal.Append(mc.MerCustId); chkVal.Append(mc.OrdId); chkVal.Append(mc.UsrCustId); chkVal.Append(mc.TransAmt); chkVal.Append(mc.AuditFlag); // chkVal.Append(mc.RetUrl); chkVal.Append(mc.BgRetUrl); chkVal.Append(mc.MerPriv); string chkv = chkVal.ToString(); LogInfo.WriteLog("批量取现审核chkv字符:" + chkv); //私钥文件的位置(这里是放在了站点的根目录下) string merKeyFile = AppDomain.CurrentDomain.BaseDirectory + Utils.GetMerPr(); //需要指定提交字符串的长度 int len = Encoding.UTF8.GetBytes(chkv).Length; StringBuilder sbChkValue = new StringBuilder(256); //加签 int strer = DllInterop.SignMsg(Utils.GetMerId(), merKeyFile, chkv, len, sbChkValue); mc.ChkValue = sbChkValue.ToString(); LogInfo.WriteLog("批量取现审核提交信息:" + FastJSON.toJOSN(mc)); using (var client = new WebClient()) { var values = new NameValueCollection(); values.Add("Version", mc.Version); values.Add("CmdId", mc.CmdId); values.Add("MerCustId", mc.MerCustId); values.Add("OrdId", mc.OrdId); values.Add("UsrCustId", mc.UsrCustId); values.Add("TransAmt", mc.TransAmt); values.Add("AuditFlag", mc.AuditFlag); values.Add("BgRetUrl", mc.BgRetUrl); values.Add("MerPriv", mc.MerPriv); values.Add("ChkValue", mc.ChkValue); string url = Utils.GetChinapnrUrl(); //同步发送form表单请求 byte[] result = client.UploadValues(url, "POST", values); var retStr = Encoding.UTF8.GetString(result); // Response.Write(retStr); // LogInfo.WriteLog("批量取现审同步form表单请求" + retStr); ReCashAudit ReCa = new ReCashAudit(); var Re = (ReCashAudit)FastJSON.ToObject(retStr, ReCa); LogInfo.WriteLog("批量取现审返回报文:" + FastJSON.toJOSN(Re)); StringBuilder builder = new StringBuilder(); builder.Append(Re.CmdId); builder.Append(Re.RespCode); builder.Append(Re.MerCustId); builder.Append(Re.OrdId); builder.Append(Re.UsrCustId); builder.Append(Re.TransAmt); builder.Append(Re.OpenAcctId); builder.Append(Re.OpenBankId); builder.Append(Re.AuditFlag); builder.Append(HttpUtility.UrlDecode(Re.BgRetUrl)); builder.Append(Re.MerPriv); var msg = builder.ToString(); LogInfo.WriteLog("批量取现审验签文明:" + msg); //验签 string pgPubkFile = AppDomain.CurrentDomain.BaseDirectory + Utils.GetPgPubk(); int ret = DllInterop.VeriSignMsg(pgPubkFile, msg, msg.Length, Re.ChkValue); LogInfo.WriteLog("批量取现审验签 ret= " + ret.ToString()); if (ret == 0) { //更新数据库 string sql = ""; if (orstate == 1) { sql = "update hx_td_UserCash set Remarks='' where UserCashId=" + dt.Rows[i]["UserCashId"].ToString(); DbHelperSQL.RunSql(sql); } else if (orstate == 3) { sql = "update hx_td_UserCash set Remarks='',OrdIdState=3 ,OperTime='" + DateTime.Now.ToString() + "' where UserCashId=" + dt.Rows[i]["UserCashId"].ToString(); DbHelperSQL.RunSql(sql); } else if (orstate == 4) { // sql = "update hx_td_UserCash set Remarks='" + Utils.CheckSQLHtml(model.Remarks) + "', Reason='" + Utils.CheckSQLHtml(model.Reason) + "',OrdIdState=4 ,OperTime='" + DateTime.Now.ToString() + "' where UserCashId=" + UserCashId.ToString(); // sql += ";update hx_member_table set available_balance=available_balance+" + dt.Rows[0]["TransAmt"].ToString() + ",frozen_sum=frozen_sum-" + dt.Rows[0]["TransAmt"].ToString() + " where registerid=" + dt.Rows[0]["registerid"].ToString(); // DbHelperSQL.RunSql(sql); // return Content(StringAlert.Alert("取现未通过,金额已退还!", "/admin/UserCash/CashProcessing?UserCashId=" + model.UserCashId)); } if (Re.RespCode == "000" || Re.RespCode == "999" || Re.RespCode == "406") { string cachename = Re.OrdId + "Cash" + Re.UsrCustId + Re.TransAmt.ToString(); if (Utils.GeTThirdCache(cachename) == 0) { Utils.SetThirdCache(cachename); //提现成功后,得多事务处理账户金额,流水等 B_usercenter BUC = new B_usercenter(); M_Capital_account_water aw = new M_Capital_account_water(); if (BUC.Su_CashProcessing(Re, aw) > 0) { strCount += Re.OrdId + " 取款审核成功<br /> "; LogInfo.WriteLog("后台取款审核成功:" + str); succ = succ + 1; } else { lost = lost + 1; strCount += Re.OrdId + " 取款审核失败<br /> "; LogInfo.WriteLog("后台取款审核事误操作失败"); } } } else { lost = lost + 1; strCount += Re.OrdId + " 取款审核失败 (" + Re.RespCode + ")<br /> "; LogInfo.WriteLog("后台提现失败" + Re.RespCode); } } else { // Response.Write(Re.UsrCustId + "取款审核验签失败 原因: " + Re.RespDesc + " <br>"); } } } json = @"{""ret"":1,""msg"":""<div style='margin: 9px;line-height:20px;'>批量复核操作成功 RR</div>"" }"; string sfd = succ.ToString() + "笔成功, " + lost.ToString() + "失败<br />" + strCount + " "; json = json.Replace("RR", sfd); return(Content(json, "text/json")); }
/// <summary> /// 累计为投资人赚取收益 /// </summary> /// <returns></returns> private decimal GetTmpData() { return(Convert.ToDecimal(B_usercenter.GetIncome())); }
//汇付模拟发起的请求,没有携带用户的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)); }
///// <summary> ///// 累计为投资人赚取收益 ///// </summary> ///// <returns></returns> //private string GetIncomeText() //{ // var chars = ChuanglitouP2P.BLL.B_usercenter.GetIncome().ToCharArray(); // //<p><span>1</span>,<span>2</span><span>3</span><span>4</span>,<span>5</span><span>6</span><span>7</span>,<span>8</span><span>9</span><span>4</span>.<span>0</span><span>0</span></p> // StringBuilder builder = new StringBuilder(); // builder.Append("<p>"); // foreach (char c in chars) // { // if (c == '.' || c == ',') // { // builder.Append(c.ToString()); // } // else // { // builder.Append("<span>"); // builder.Append(c.ToString()); // builder.Append("</span>"); // } // } // builder.Append("</p>"); // return builder.ToString(); //} /// <summary> /// 累计为投资人赚取收益 /// </summary> /// <returns></returns> public static decimal GetTmpData() { return(Convert.ToDecimal(B_usercenter.GetIncome())); }
/// <summary> /// 分页列表 /// </summary> /// <param name="pageIndex"></param> /// <param name="startdatetime"></param> /// <param name="enddatetime"></param> /// <param name="timeday"></param> /// <param name="pgaesize"></param> /// <returns></returns> // GET: Cash public ActionResult Index(int?pageIndex, string startdatetime, string enddatetime, int timeday = 0, int pgaesize = 5) { ViewBag.rndstr = Utils.RndNumChar(10).ToString(); int OrdIdState = DNTRequest.GetInt("OrdIdState", 0); ViewBag.OrdIdState = OrdIdState; int userid = Utils.checkloginsession(); int Counts = 0; int lostCount = 0; int succCount = 0; decimal Totals = 0.00M; decimal lostTotal = 0.00M; decimal succTotal = 0.00M; B_member_table b = new B_member_table(); M_member_table pu = new M_member_table(); pu = b.GetModel(userid); //判断用户是否开户 if (string.IsNullOrEmpty(pu.UsrCustId)) { string temstr = "/opening_account/Index/" + userid.ToString(); return(Redirect(temstr)); } new BindCardController().checkbank(pu.UsrCustId); if (userid > 0) { if (Session["retloan1"] != null) { } else { UserInfoData ud = new UserInfoData(); ReQueryBalanceBg retloan = ud.Querybalance(userid); if (retloan.RespCode == "000") { // string sql = "update hx_member_table set available_balance=" + decimal.Parse(retloan.AvlBal) + " ,frozen_sum=" + decimal.Parse(retloan.FrzBal) + " where registerid=" + userid.ToString() + ""; //string sql = "update hx_member_table set available_balance=" + decimal.Parse(retloan.AvlBal) + " where registerid=" + userid.ToString() + ""; //DbHelperSQL.RunSql(sql); B_usercenter bu = new B_usercenter(); bu.DataSync(retloan, userid.ToString()); Session["retloan1"] = "updateUserbalance"; } } } List <V_UsrBindCardBank> vubc = ef.V_UsrBindCardBank.Where(c => c.registerid == userid && c.OpenBankId != null).ToList(); //判断用户是否绑定一行卡 //if (vubc.Count <= 0) //{ // string temstr = "/BindCard/Index"; // return Redirect(temstr); //} var ListByOwner = ef.hx_td_UserCash.Where(l => l.registerid == userid && l.OpenBankId != null).GroupBy(l => l.registerid) .Select(lg => new { Owner = lg.Key, Counts = lg.Count(), lostCount = lg.Where(lo => lo.OrdIdState == 0).Count(), succCount = lg.Where(su => su.OrdIdState == 3).Count(), Totals = lg.Where(w => w.OrdIdState == 3).Sum(w => w.TransAmt), lostTotal = lg.Where(w => w.OrdIdState == 0).Sum(w => w.TransAmt), succTotal = lg.Where(w => w.OrdIdState == 3).Sum(w => w.TransAmt), }); foreach (var itc in ListByOwner) { if (itc.Counts > 0) { //Counts = itc.Counts; // Totals = (decimal)itc.Totals; int.TryParse(itc.Counts.ToString(), out Counts); decimal.TryParse(itc.Totals.ToString(), out Totals); int.TryParse(itc.lostCount.ToString(), out lostCount); int.TryParse(itc.succCount.ToString(), out succCount); decimal.TryParse(itc.lostTotal.ToString(), out lostTotal); decimal.TryParse(itc.succTotal.ToString(), out succTotal); } } Expression <Func <hx_td_UserCash, bool> > where = PredicateExtensionses.True <hx_td_UserCash>(); where = where.And(p => p.UserCashId > 0); where = where.And(p => p.registerid == userid); where = where.And(p => p.OpenBankId != null); if (ViewBag.OrdIdState == 3) { where = where.And(p => p.OrdIdState == OrdIdState); } DateTime sdatetime = new DateTime(); DateTime edatetime = new DateTime(); if (Utils.IsDate(startdatetime)) { sdatetime = DateTime.Parse(startdatetime); } if (Utils.IsDate(enddatetime)) { edatetime = DateTime.Parse(enddatetime); } if (sdatetime > DateTime.Parse("0001-01-01 00:00:00") && edatetime > DateTime.Parse("0001-01-01 00:00:00")) { where = where.And(p => ((DateTime)p.OrdIdTime).CompareTo(sdatetime) >= 0); DateTime dt2 = Convert.ToDateTime(edatetime.ToString("yyyy-MM-dd") + " 23:59:59"); where = where.And(p => ((DateTime)p.OrdIdTime).CompareTo(dt2) <= 0); } else { DateTime dt2; switch (timeday) { case 0: break; case 1: sdatetime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00"); dt2 = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 23:59:59"); where = where.And(p => ((DateTime)p.OrdIdTime).CompareTo(sdatetime) >= 0); where = where.And(p => ((DateTime)p.OrdIdTime).CompareTo(dt2) <= 0); break; case 30: sdatetime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00").AddDays(-30); dt2 = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 23:59:59"); where = where.And(p => ((DateTime)p.OrdIdTime).CompareTo(sdatetime) >= 0); where = where.And(p => ((DateTime)p.OrdIdTime).CompareTo(dt2) <= 0); where = where.And(p => ((DateTime)p.OrdIdTime).CompareTo(sdatetime) >= 0); where = where.And(p => ((DateTime)p.OrdIdTime).CompareTo(dt2) <= 0); break; case 90: sdatetime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00").AddDays(-90); dt2 = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 23:59:59"); break; default: break; } } var list = ef.hx_td_UserCash.Where(where).OrderByDescending(p => p.UserCashId).ToPagedList(pageIndex ?? 1, pgaesize); ViewBag.startdatetime = startdatetime; ViewBag.enddatetime = enddatetime; ViewBag.timeday = timeday; ViewBag.pageIndex = pageIndex; ViewBag.Counts = Counts; ViewBag.Totals = Totals; ViewBag.lostCount = lostCount; ViewBag.lostTotal = lostTotal; ViewBag.succTotal = succTotal; ViewBag.succCount = succCount; ViewBag.users = pu; vubc = BusinessLogicHelper.LeftOne(vubc); ViewBag.UsrBindCard = vubc.OrderByDescending(c => c.defCard).ToList(); ViewBag.Isquick = vubc.Where(c => c.Isquick == 1).Count() > 0; ViewBag.GENERAL = DateTime.Now.AddDays(1).ToString("MM月dd日"); ViewBag.QM = DateTime.Now.ToString("MM月dd日"); if (Request.IsAjaxRequest()) { return(PartialView("_Cashlist", list)); } return(View(list)); }