/// <summary> /// 活动加息券 /// </summary> /// 常规活动 加息券奖励 未记录系统信息及奖励流水 //与红包方法一致GeneralActCoupon /// </summary> /// <param name="registerid">用户id</param> /// <param name="investAmt">投资金额</param> /// <param name="hat">活动对象</param> /// <returns>list 用户活动奖励记录集合</returns> /// <returns></returns> ActTypeId=3 private List <hx_UserAct> GeneralActInterestRatesPlus(int registerid, decimal investAmt, hx_ActivityTable hat) { List <hx_UserAct> t = new List <hx_UserAct>(); if (hat != null) { hx_UserAct hua = new hx_UserAct(); Mcoupon mcp = new Mcoupon(); JavaScriptSerializer js = new JavaScriptSerializer(); mcp = js.Deserialize <Mcoupon>(hat.ActRule); //获取用户活动表对象 t = OPMcoupon(mcp, hat, registerid, investAmt); } return(t); }
/// <summary> /// 活动加息券 /// </summary> /// <param name="registerid"></param> /// <param name="investAmt"></param> /// <param name="ActTypeId">活动类型</param> /// <param name="ActUser"></param> /// <returns></returns> private List <hx_UserAct> InviteActInterestRatesPlus(int registerid, string targetPlatform, decimal investAmt, int ActTypeId = 3, int ActUser = 0) { List <hx_UserAct> t = new List <hx_UserAct>(); hx_ActivityTable hat = GetActTableInfo(ActTypeId, targetPlatform, ActUser, 1); if (hat != null) { hx_UserAct hua = new hx_UserAct(); Mcoupon mcp = new Mcoupon(); JavaScriptSerializer js = new JavaScriptSerializer(); mcp = js.Deserialize <Mcoupon>(hat.ActRule); //获取用户活动表对象 t = OPMcoupon(mcp, hat, registerid, investAmt); } return(t); }
/// <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 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> /// <param name="activity"></param> /// <param name="registerID"></param> private void DrawBonus(hx_ActivityTable activity, int registerID) { chuangtouEntities ef = new chuangtouEntities(); B_bonus_account bb = new B_bonus_account(); M_bonus_account mb = new M_bonus_account(); M_bonus_account_water mbaw = new M_bonus_account_water(); B_bonus_account_water bbaw = new B_bonus_account_water(); DateTime dte = DateTime.Now;//当前时间截点 //hx_ActivityTable act = ef.hx_ActivityTable.Where(c => c.ActID == activity.ActID).FirstOrDefault();//添加奖励类型 if (activity.ActEndtime >= dte && activity.ActStarttime <= dte) { Mcoupon mcp = new Mcoupon(); JavaScriptSerializer js = new JavaScriptSerializer(); mcp = js.Deserialize <Mcoupon>(activity.ActRule); hx_UserAct hua = new hx_UserAct(); hua.ActTypeId = activity.ActTypeId; hua.registerid = registerID; hua.RewTypeID = activity.RewTypeID; hua.ActID = activity.ActID; hua.Amt = mcp.cash; hua.Uselower = mcp.Msplitarr == null || mcp.Msplitarr.Count <= 0 ? 0 : mcp.Msplitarr[0].startAmt; hua.Usehight = mcp.Msplitarr == null || mcp.Msplitarr.Count <= 0 ? 0 : mcp.Msplitarr[0].endAmt; hua.AmtEndtime = activity.ActEndtime; hua.AmtUses = mcp.Uses; //没指定情况下默认为单独使用 hua.UseState = 0; //现金未转账 hua.AmtProid = 0; //未使用默认为0 hua.ISSmsOne = 0; hua.IsSmsThree = 0; hua.isSmsFifteen = 0; hua.IsSmsSeven = 0; hua.isSmsSixteen = 0; hua.Createtime = DateTime.Now; ef.hx_UserAct.Add(hua); int i = ef.SaveChanges(); mb.activity_schedule_id = activity.ActID; mb.membertable_registerid = registerID; mb.activity_schedule_name = activity.ActName; mb.amount_of_reward = decimal.Parse(hua.Amt.ToString()); mb.use_lower_limit = Convert.ToDecimal(hua.Uselower); mb.reward = 0; mb.start_date = Convert.ToDateTime(hua.Createtime); mb.end_date = Convert.ToDateTime(hua.AmtEndtime); mb.entry_time = dte; int bbid = bb.Add(mb); if (bbid > 0) //奖励记录成功后插入明细记录 { mbaw.bonus_account_id = bbid; mbaw.membertable_registerid = registerID; mbaw.income = decimal.Parse(hua.Amt.ToString()); mbaw.expenditure = 0.00M; mbaw.time_of_occurrence = DateTime.Now; mbaw.award_description = activity.ActName; mbaw.water_type = 0; bbaw.Add(mbaw); } } }
/// <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> /// <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 }
/// <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="registerid">用户id</param> /// <param name="investAmt">投资金额</param> /// <param name="hat">活动对象</param> /// <param name="bid_records_id">投标记录id</param> /// <returns>bool 是否发放成功</returns> private bool GeneralActCash(int Registerid, decimal InvestAmt, hx_ActivityTable hat, int bid_records_id, int lifeLoan = 0) { bool t = false; //hx_ActivityTable hat = GetActTableInfo(ActTypeId, ActUser, 1); if (hat != null) { B_member_table oy = new B_member_table(); //M_member_table investor = new M_member_table(); hx_member_table investor = new hx_member_table(); investor = ef.hx_member_table.Where(c => c.registerid == Registerid).FirstOrDefault(); //oy.GetModel(Registerid);//被推荐人 也就是投资人 DateTime dte = DateTime.Now; string codesql = "SELECT invcode,Invpeopleid,invpersonid,invtime from hx_td_Userinvitation where invpersonid=" + Registerid + " ";//查询本人是否已经被邀请注册过 DataTable dtcode = DbHelperSQL.GET_DataTable_List(codesql); //if (dtcode.Rows.Count > 0 || (investor != null && !string.IsNullOrWhiteSpace(investor.channel_invitedcode))) //{ int uuid = dtcode.Rows.Count > 0 ? int.Parse(dtcode.Rows[0]["Invpeopleid"].ToString()) : 0; //邀请用户id //用户等级为渠道 不参与活动 if (investor != null && investor.useridentity == 4) { return(t); } int investCount = B_usercenter.GetInvestCountByUserid(Registerid); //老渠道机制判断 (推荐人等级为4渠道用户,投资次数大于等于1次 时可参与活动 if (uuid != 0) { M_member_table py = new M_member_table(); py = oy.GetModel(uuid);//推荐人 if ((py != null && py.useridentity == 4) && investCount == 1) { return(t); } } //新渠道机制判断 using (ChannelAct channelAct = new ChannelAct()) { //按照渠道类型和投资次数判断是否参与此次活动 if (!channelAct.IsParticipateActivity(investor.channel_invitedcode, investCount)) { return(t); } } //if (((py != null && py.useridentity == 4) || !string.IsNullOrWhiteSpace(investor.channel_invitedcode)) && B_usercenter.GetInvestCountByUserid(Registerid) == 1) //{ // return t; //} //if (py.useridentity != 4)//渠道用户不执行 2016-11-8日添加 //{ string ActRule = hat.ActRule; List <MAmtList> mlist = new List <MAmtList>(); JavaScriptSerializer js = new JavaScriptSerializer(); MActCash mc = new MActCash(); mc = js.Deserialize <MActCash>(ActRule); //mlist = js.Deserialize<List<MAmtList>>(ActRule); //获取该活动对应的已经发放奖励的人次 int TopNum = B_usercenter.GetTopNum(hat.ActID); //获取该活动对应的已经发放奖励的总金额 decimal totalAmt = B_usercenter.GetTopAmtCount(hat.ActID); if (hat.ActUser == 7)//特殊回款复投奖励类型,根据规则修订奖励基数--投资金额 { InvestAmt = GetSepcialActAmt(Registerid, bid_records_id, InvestAmt, hat); } //根据投资金额计算对应现金奖励金额 decimal actamt = GetActAmt(mc, InvestAmt, TopNum, lifeLoan); //检查分发奖励是否超过人数顶限或者总金额上限,上限为0表示不限制,如果超过直接跳过 if ((mc.TopAmt > totalAmt || mc.TopAmt == 0) && (mc.TopNum > TopNum || mc.TopNum == 0)) { //t = true; if (actamt > 0)//大于 0里写入对应的奖励数据 { hx_UserAct hua = new hx_UserAct(); hua.ActTypeId = hat.ActTypeId; hua.registerid = Registerid; hua.RewTypeID = hat.RewTypeID; hua.ActID = hat.ActID; hua.Amt = actamt; hua.Uselower = 0.00M; hua.Usehight = 0.00M; hua.AmtEndtime = DateTime.Parse(hat.ActEndtime.ToString()).AddMonths(1); hua.AmtUses = 1; //没指定情况下默认为单独使用 hua.UseState = 5; //现金未转账 hua.UseTime = DateTime.Now; hua.AmtProid = bid_records_id; //未使用默认为0,对于现金奖励该字段存放获得该奖励的投资记录id hua.ISSmsOne = 0; hua.IsSmsThree = 0; hua.isSmsFifteen = 0; hua.IsSmsSeven = 0; hua.isSmsSixteen = 0; hua.OrderID = decimal.Parse(Utils.Createcode()); hua.Createtime = DateTime.Now; hua.Title = mc.ActName; hua.UseLifeLoan = ""; ef.hx_UserAct.Add(hua); int i = ef.SaveChanges(); if (i > 0) { //录入成功,后进行转账操作 1.获取用户对象 M_member_table p = new M_member_table(); B_member_table o = new B_member_table(); p = o.GetModel(Registerid); if (p != null) { //2.调用商户向用户转账接口 Transfer tf = new Transfer(); ReTransfer retf = tf.ToUserTransfer(p.UsrCustId, actamt, hua.OrderID.ToString(), hua.ActID.ToString(), "/Thirdparty/ToUserTransfer"); if (retf != null && retf.RespCode == "000") { //3.事务处理操作账户及插入流水 #region 验签缓存处理 string cachename = retf.OrdId + "ToUserTransfer" + retf.InCustId; if (Utils.GeTThirdCache(cachename) == 0) { Utils.SetThirdCache(cachename); B_usercenter BUC = new B_usercenter(); int ic = BUC.UpateActToUserTransfer(retf, bid_records_id); //用户余额更新 if (ic > 0) { string sql = "SELECT registerid,username,mobile from hx_member_table where UsrCustId='" + retf.InCustId + "'"; DataTable dt = DbHelperSQL.GET_DataTable_List(sql); if (dt.Rows.Count > 0) { #region 资金流水 B_usercenter ors = new B_usercenter(); decimal di = ors.GetUsridAvailable_balance(int.Parse(dt.Rows[0]["registerid"].ToString())); // di = di + decimal.Parse(hua.Amt.ToString()); StringBuilder strSql = new StringBuilder(); strSql.Append("insert into hx_Capital_account_water("); strSql.Append("membertable_registerid,income,expenditure,time_of_occurrence,account_balance,types_Finance,createtime,keyid,remarks)"); strSql.Append(" values ("); strSql.Append("" + int.Parse(dt.Rows[0]["registerid"].ToString()) + "," + decimal.Parse(hua.Amt.ToString()) + ",0,'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'," + di + "," + (int)Enum.Parse(typeof(EnumTypesFinance), EnumTypesFinance.现金奖励.ToString()) + ",'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',0,'" + "现金奖励" + "')"); DbHelperSQL.RunSql(strSql.ToString()); strSql.Clear(); #endregion #region MyRegion 记录奖励流水表 string awardDescription = string.Format("{0},已汇入个人账户{1}{2}", hat.ActName, retf.TransAmt, GetBunusDescription(hat.RewTypeID)); AddBonusAccoutWater(int.Parse(hua.UserAct.ToString()), Registerid, decimal.Parse(retf.TransAmt), awardDescription); #endregion #region MyRegion 发送系统消息 string MContext = string.Format("尊敬的用户:您好!恭喜您成功参与{0},获得{1}{2}如有问题可咨询创利投的客服!", hat.ActName, retf.TransAmt, GetBunusDescription(hat.RewTypeID)); AddSytemMessage(Registerid, hat.ActName, MContext); #endregion string msg = string.Format("尊敬的客户您好,您已成功投资创利投金服,获得返利{0}元,请登录官网查看。客服热线:010-53732056。", actamt.ToString("0.00")); SendSMS.Send_SMS(dt.Rows[0]["mobile"].ToString(), msg); } } t = true; } #endregion } } } } //} } //} } return(t); }
/// <summary> /// 按照投资金额进行红包或加息券奖励发放(常规投资 红包或加息券) 未记录系统信息及奖励流水 /// 返回用户活动表hx_UserAct 对象 /// </summary> /// <param name="mcp">规则对象</param> /// <param name="hua">活动项目表</param> /// <param name="Registerid">用户id</param> /// <param name="investAmt">投资金额</param> protected List <hx_UserAct> OPMcoupon(Mcoupon mcp, hx_ActivityTable hat, int Registerid, decimal investAmt) { List <hx_UserAct> t = new List <hx_UserAct>(); List <Msplitarr> msp = new List <Msplitarr>(); List <MAmtList> mat = new List <MAmtList>(); JavaScriptSerializer js = new JavaScriptSerializer(); if (mcp.rule == 1) //统一赠送 { #region 统一赠送 t.Clear(); string msplitarrc = ""; //经过比对拆分不拆分代码逻辑一样,所以合并处理 //if (mcp.ISsplit == 1) try { msplitarrc = mcp.Msplitarr.SerializeJSON(); msp = js.Deserialize <List <Msplitarr> >(msplitarrc); } catch { msp = null; } foreach (var item in msp) { hx_UserAct hua = new hx_UserAct(); hua.ActTypeId = hat.ActTypeId; hua.registerid = Registerid; hua.RewTypeID = hat.RewTypeID; hua.ActID = hat.ActID; hua.Amt = item.cashAmt; hua.Uselower = item.startAmt; hua.Usehight = item.endAmt; if (item.validity > 0) //有效天数大于0 { hua.AmtEndtime = DateTime.Now.Date.AddDays(item.validity + 1).AddSeconds(-1); } else { hua.AmtEndtime = item.endTime; } hua.AmtUses = mcp.Uses; //没指定情况下默认为单独使用 hua.UseState = 0; //现金未转账 hua.AmtProid = 0; //未使用默认为0 hua.ISSmsOne = 0; hua.IsSmsThree = 0; hua.isSmsFifteen = 0; hua.IsSmsSeven = 0; hua.isSmsSixteen = 0; hua.Createtime = DateTime.Now; hua.Title = hat.ActName; hua.UseLifeLoan = string.IsNullOrWhiteSpace(item.UseLifeLoan) ? "" : item.UseLifeLoan; ef.hx_UserAct.Add(hua); int i = ef.SaveChanges(); t.Add(hua); } #endregion } else if (mcp.rule == 2)//按投资赠送,需要判断投资金额区间,不支持拆分 只赠送一张代金券或加息券,使用限制按照金额在拆分中匹配 { #region 投资赠送 hx_UserAct hua = new hx_UserAct(); t.Clear(); string msplitarrc = ""; hua.ActTypeId = hat.ActTypeId; hua.registerid = Registerid; hua.RewTypeID = hat.RewTypeID; hua.ActID = hat.ActID; try { msplitarrc = mcp.Msplitarr.SerializeJSON(); msp = js.Deserialize <List <Msplitarr> >(msplitarrc); } catch { msp = null; } hua.Amt = GetCouponAmtByInvestAmt(mcp, investAmt); hua.Uselower = GetCouponUseConByAmt(msp, decimal.Parse(hua.Amt.ToString()), 0); hua.Usehight = GetCouponUseConByAmt(msp, decimal.Parse(hua.Amt.ToString()), 1); hua.AmtEndtime = GetCouponEndTimeByAmt(msp, decimal.Parse(hua.Amt.ToString())); hua.AmtUses = mcp.Uses; //没指定情况下默认为单独使用 hua.UseState = 0; //现金未转账 hua.AmtProid = 0; //未使用默认为0 hua.ISSmsOne = 0; hua.IsSmsThree = 0; hua.isSmsFifteen = 0; hua.IsSmsSeven = 0; hua.isSmsSixteen = 0; hua.Createtime = DateTime.Now; hua.Title = hat.ActName; hua.UseLifeLoan = msp == null ? "" : msp[0].UseLifeLoan; if (hua.Uselower >= 0 || hua.Usehight >= 0 || hua.Amt <= 0) { ef.hx_UserAct.Add(hua); int i = ef.SaveChanges(); if (i > 0) { t.Add(hua); } } #endregion } else if (mcp.rule == 3) //随机赠送,需要判断投资金额区间,不支持拆分 只赠送一张代金券或加息券,使用限制按照金额在拆分中匹配 { #region 随机赠送 t.Clear(); foreach (var item in mcp.MAmtList) { if (item.startAmt <= investAmt && (item.endAmt == 0 || item.endAmt >= investAmt)) { for (int i = 0; i < item.num; i++) { hx_UserAct hua = new hx_UserAct(); string msplitarrc = ""; hua.ActTypeId = hat.ActTypeId; hua.registerid = Registerid; hua.RewTypeID = hat.RewTypeID; hua.ActID = hat.ActID; try { msplitarrc = mcp.Msplitarr.SerializeJSON(); msp = js.Deserialize <List <Msplitarr> >(msplitarrc); } catch { msp = null; } hua.Amt = Utils.GetActRandom(item.Amtstr); hua.Uselower = GetCouponUseConByAmt(msp, decimal.Parse(hua.Amt.ToString()), 0); hua.Usehight = GetCouponUseConByAmt(msp, decimal.Parse(hua.Amt.ToString()), 1); hua.AmtEndtime = GetCouponEndTimeByAmt(msp, decimal.Parse(hua.Amt.ToString())); hua.AmtUses = mcp.Uses; //没指定情况下默认为单独使用 hua.UseState = 0; //现金未转账 hua.AmtProid = 0; //未使用默认为0 hua.ISSmsOne = 0; hua.IsSmsThree = 0; hua.isSmsFifteen = 0; hua.IsSmsSeven = 0; hua.isSmsSixteen = 0; hua.Createtime = DateTime.Now; hua.Title = hat.ActName; hua.UseLifeLoan = msp == null ? "" : msp[0].UseLifeLoan; if (hua.Uselower >= 0 || hua.Usehight >= 0 || hua.Amt <= 0) { ef.hx_UserAct.Add(hua); int c1 = ef.SaveChanges(); if (c1 > 0) { t.Add(hua); } } } break; } } #endregion } return(t); }