// // GET: /UserBlackList/ public ActionResult Index(UserBlackList UserBlackList, EFPagingInfo <UserBlackList> p, DateTime?STime, DateTime?ETime, int IsFirst = 0) { //if (STime.IsNullOrEmpty()) //{ // STime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")); //} //if (ETime.IsNullOrEmpty()) //{ // ETime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")); //} //ViewBag.ETime = ETime; //ViewBag.STime = STime; ViewBag.UserBlackList = UserBlackList; if (IsFirst == 0) { PageOfItems <UserBlackList> UserBlackListList1 = new PageOfItems <UserBlackList>(new List <UserBlackList>(), 0, 10, 0, new Hashtable()); ViewBag.UserBlackListList = UserBlackListList1; return(View()); } if (!UserBlackList.CardNumber.IsNullOrEmpty()) { p.SqlWhere.Add(f => f.CardNumber == UserBlackList.CardNumber); } if (UserBlackList.State != 0) { p.SqlWhere.Add(f => f.State == UserBlackList.State); } // ETime = ETime.Value.AddDays(1); // p.SqlWhere.Add(f => f.AddTime >= STime && f.AddTime <= ETime); p.OrderByList.Add("Id", "DESC"); IPageOfItems <UserBlackList> UserBlackListList = Entity.Selects <UserBlackList>(p); ViewBag.UserBlackListList = UserBlackListList; return(View()); }
public ActionResult Create(UpsertBlacklistUserViewModel model) { try { if (ModelState.IsValid) { UserBlackList newBlacklistUser = new UserBlackList(); newBlacklistUser.clanUserId = model.ClanUserId; newBlacklistUser.clanId = (int)ClanManager.GetClanId(User.Identity.GetUserId()); newBlacklistUser.note = model.Notes; BlacklistManager.Insert(newBlacklistUser); ClanUser blUser = ClanUserManager.SelectByClanUserId(model.ClanUserId); blUser.clanId = null; ClanUserManager.Update(blUser); } } catch { return(View(new UpsertBlacklistUserViewModel())); } return(RedirectToAction("EditMode", "Members")); }
public void Delete(UserBlackList blackList) { if (blackList != null) { db.UserBlackLists.Remove(blackList); } }
/// <summary> /// 加入黑名单 /// </summary> public static bool AddBlackList(SqlConnection connection, UserBlackList model) { using (connection) { if (model != null && !string.IsNullOrEmpty(model.UserId)) { string strSql = @" IF((SELECT COUNT(UserId) FROM Marketing..tbl_FaXianBlackList WITH(NOLOCK) WHERE UserId = @UserId) <= 0) BEGIN INSERT INTO Marketing..tbl_FaXianBlackList(UserId,RelatedContent,BanType,Operator,CreateTime) VALUES(@UserId,@RelatedContent,@BanType,@Operator,@CreateTime) END"; var sqlParamsInfo = new SqlParameter[] { new SqlParameter("@UserId", model.UserId), new SqlParameter("@RelatedContent", model.RelatedContent), new SqlParameter("@BanType", model.BanType), new SqlParameter("@Operator", model.Operator), new SqlParameter("@CreateTime", model.CreateTime) }; int res = SqlHelper.ExecuteNonQuery(connection, CommandType.Text, strSql, sqlParamsInfo); return(res > 0); } return(false); } }
/// <summary> /// Inserts a new UserBlackList record /// </summary> public static void Insert(UserBlackList bUser) { using (var dbContext = new HouseOfClansEntities()) { bUser.addedOn = DateTime.Now; dbContext.UserBlackLists.Add(bUser); dbContext.SaveChanges(); } }
public void Delete(UserBlackList UserBlackList, string InfoList, int?IsDel) { if (string.IsNullOrEmpty(InfoList)) { InfoList = UserBlackList.Id.ToString(); } int Ret = Entity.MoveToDeleteEntity <UserBlackList>(InfoList, IsDel, AdminUser.UserName); Entity.SaveChanges(); Response.Write(Ret); }
public static UserBlackListDTO ToUserBlackListDTO(this UserBlackList userBlackList) { return(new UserBlackListDTO() { GuestId = userBlackList.GuestId, GuestName = userBlackList.Guest.FirstName + " " + userBlackList.Guest.LastName, HotelId = userBlackList.HotelId, HotelName = userBlackList.Hotel.Name, Reason = userBlackList.Reason }); }
//加入黑名单 public static bool AddBlackList(UserBlackList model) { try { return(UserBlackListDAL.AddBlackList(ProcessConnection.OpenMarketing, model)); } catch (Exception ex) { throw ex; } }
/// <summary> /// Gets a UserBlacklist based on the blacklist id /// </summary> /// <param name="userBlacklistId">UserBlacklist Id</param> public static UserBlackList SelectByBlacklistId(int blacklistId) { UserBlackList blacklist = new UserBlackList(); using (var dbContext = new HouseOfClansEntities()) { blacklist = dbContext.UserBlackLists.Where(p => p.id == blacklistId).FirstOrDefault(); } return(blacklist); }
/// <summary> /// Updates a UserBlackList /// </summary> public static void Update(UserBlackList updatedBUser) { UserBlackList bUser = BlacklistManager.SelectByBlacklistId(updatedBUser.id); using (var dbContext = new HouseOfClansEntities()) { //TODO: Add updatedOn for the UserBlackList entity in the database //updatedBUser.updatedOn = DateTime.Now; dbContext.UserBlackLists.Attach(bUser); dbContext.Entry(bUser).CurrentValues.SetValues(updatedBUser); dbContext.SaveChanges(); } }
/// <summary> /// Deletes a UserBlackList /// </summary> public static bool Delete(int blacklistId) { bool isDeleted = false; UserBlackList deleteBlacklist = BlacklistManager.SelectByBlacklistId(blacklistId); using (var dbContext = new HouseOfClansEntities()) { dbContext.UserBlackLists.Attach(deleteBlacklist); dbContext.UserBlackLists.Remove(deleteBlacklist); isDeleted = dbContext.SaveChanges() > 0; } return(isDeleted); }
public void EditSave(UserBlackList UserBlackList) { UserBlackList.CardNumber = UserBlackList.CardNumber.Replace(" ", ""); if (UserBlackList.State == 1)//手机 { UserBlackList BasicBlackTemp = Entity.UserBlackList.FirstOrDefault(o => o.CardNumber == UserBlackList.CardNumber && o.State == 1); if (BasicBlackTemp != null) { Response.Write("该手机号已存在"); return; } } if (UserBlackList.State == 2)//身份证 { UserBlackList BasicBlackTemp = Entity.UserBlackList.FirstOrDefault(o => o.CardNumber == UserBlackList.CardNumber && o.State == 2); if (BasicBlackTemp != null) { Response.Write("该身份证已存在"); return; } } if (UserBlackList.State == 3)//银行卡 { UserBlackList BasicBlackTemp = Entity.UserBlackList.FirstOrDefault(o => o.CardNumber == UserBlackList.CardNumber && o.State == 3); if (BasicBlackTemp != null) { Response.Write("该银行卡已存在"); return; } } UserBlackList.AId = AdminUser.Id; UserBlackList.AddTime = DateTime.Now; Entity.UserBlackList.AddObject(UserBlackList); Entity.SaveChanges(); BaseRedirect(); }
public ActionResult AddCard(string etnum, string Card = "", string Mobile = "", string code = "") { string tnum = LokFuEncode.LokFuAPIDecode(etnum, DllName); FastOrder FastOrder = Entity.FastOrder.FirstOrDefault(n => n.TNum == tnum); if (FastOrder == null) { ViewBag.ErrorMsg = "订单有误!"; return(View("Error")); } Users Users = Entity.Users.FirstOrDefault(n => n.Id == FastOrder.UId); if (Users == null) { ViewBag.ErrorMsg = "商户信息有误!"; return(View("Error")); } ViewBag.FastOrder = FastOrder; ViewBag.Users = Users; ViewBag.etnum = etnum; if (!Card.IsNullOrEmpty() && !Mobile.IsNullOrEmpty() && !code.IsNullOrEmpty()) { if (Card.Length > 20) { ViewBag.ErrorMsg = "卡号长度超限!"; return(View("Error")); } if (Mobile.Length > 20) { ViewBag.ErrorMsg = "手机号码长度超限!"; return(View("Error")); } if (code.ToUpper() != Session.GetCheckCode()) { ViewBag.ErrorMsg = "验证码错误!"; return(View("Error")); } Session.ClearCheckCode(); //绑卡前验证是否有鉴权权限 UsersPayCard UsersPayCard = Entity.UsersPayCard.FirstOrDefault(n => n.Card == Card && n.Mobile == Mobile && n.UId == FastOrder.UId); if (UsersPayCard == null)//不存在则绑卡 { UserBlackList UserBlackList = Entity.UserBlackList.FirstOrDefault(UBL => UBL.CardNumber == Card && UBL.State == 3); if (UserBlackList != null) { ViewBag.ErrorMsg = "暂不支持该银行卡绑卡"; return(View("Error")); } string HaoFu_Auth_MerId = ConfigurationManager.AppSettings["HaoFu_Auth_MerId"].ToString(); string HaoFu_Auth_MerKey = ConfigurationManager.AppSettings["HaoFu_Auth_MerKey"].ToString(); string HaoFu_Auth_Url = ConfigurationManager.AppSettings["HaoFu_Auth_Url"].ToString(); string data = "{\"action\":\"authuser\",\"merid\":\"" + HaoFu_Auth_MerId + "\",\"orderid\":\"" + FastOrder.TNum + "\",\"bankaccount\":\"" + Card + "\",\"accountname\":\"" + Users.TrueName + "\",\"identitycode\":\"" + Users.CardId + "\",\"mobile\":\"" + Mobile + "\"}"; string DataBase64 = LokFuEncode.Base64Encode(data, "utf-8"); string Sign = (DataBase64 + HaoFu_Auth_MerKey).GetMD5(); DataBase64 = HttpUtility.UrlEncode(DataBase64, Encoding.UTF8); string postdata = "req=" + DataBase64 + "&sign=" + Sign; string CONTENT = Utils.PostRequest(HaoFu_Auth_Url, postdata, "utf-8"); JObject JS = new JObject(); try { JS = (JObject)JsonConvert.DeserializeObject(CONTENT); } catch (Exception) { ViewBag.ErrorMsg = "请求银联鉴权失败!【00】"; return(View("Error")); } string resp = JS["resp"].ToString(); CONTENT = LokFuEncode.Base64Decode(resp, "utf-8"); try { JS = (JObject)JsonConvert.DeserializeObject(CONTENT); } catch (Exception) { ViewBag.ErrorMsg = "请求银联鉴权失败!【01】"; return(View("Error")); } string ret_code = JS["respcode"].ToString(); if (ret_code == "0000") { string BankNumLeft = Card.Substring(0, 6); //获取卡Bin BasicCardBin BasicCardBin = Entity.BasicCardBin.FirstOrDefault(n => n.BIN == BankNumLeft); string bankName = "银联卡"; byte CardType = 0; if (BasicCardBin != null) { bankName = BasicCardBin.BankName; CardType = (byte)BasicCardBin.CardType; } else { } UsersPayCard = new UsersPayCard(); UsersPayCard.UId = FastOrder.UId; UsersPayCard.Type = CardType; UsersPayCard.Bank = bankName; UsersPayCard.Name = Users.TrueName; UsersPayCard.Card = Card; UsersPayCard.Mobile = Mobile; UsersPayCard.State = 1; UsersPayCard.AddTime = DateTime.Now; Entity.UsersPayCard.AddObject(UsersPayCard); Entity.SaveChanges(); Response.Redirect("GoPay.html?BankId=" + UsersPayCard.Id + "&etnum=" + HttpUtility.UrlEncode(etnum)); } else { string ret_msg = JS["respmsg"].ToString(); ViewBag.ErrorMsg = "银行卡认证失败!"; return(View("Error")); } } else { if (UsersPayCard.State == 0) { UsersPayCard.State = 1; Entity.SaveChanges(); } Response.Redirect("GoPay.html?BankId=" + UsersPayCard.Id + "&etnum=" + HttpUtility.UrlEncode(etnum)); } } return(View()); }
public void Post() { string Data = DataObj.GetData(); if (Data.IsNullOrEmpty()) { DataObj.OutError("1000"); return; } JObject json = new JObject(); try { json = (JObject)JsonConvert.DeserializeObject(Data); } catch (Exception Ex) { Log.Write("[CreditCardAdd]:", "【Data】" + Data, Ex); } if (json == null) { DataObj.OutError("1000"); return; } UserCard UserCard = new UserCard(); UserCard = JsonToObject.ConvertJsonToModel(UserCard, json); UserTrack UserTrack = new UserTrack(); UserTrack = JsonToObject.ConvertJsonToModel(UserTrack, json); if (UserTrack.X.IsNullOrEmpty() || UserTrack.Y.IsNullOrEmpty()) { DataObj.OutError("1000"); return; } string Token = UserCard.Token; if (!UserCard.Card.IsNullOrEmpty() && !UserCard.ValidYear.IsNullOrEmpty() && !UserCard.ValidMonth.IsNullOrEmpty() && !UserCard.CVV.IsNullOrEmpty() && !UserCard.Mobile.IsNullOrEmpty() && !UserCard.BillDay.IsNullOrEmpty() && !UserCard.BillDay.IsNullOrEmpty() && !UserCard.ValidateCode.IsNullOrEmpty()) { if (UserCard.ValidYear.Length == 4) { UserCard.ValidYear = UserCard.ValidYear.Substring(UserCard.ValidYear.Length - 2, 2); } } else { DataObj.OutError("1000"); return; } if (UserCard.Card.Length < 6) { DataObj.OutError("1000"); return; } #region 基础验证 //获取用户信息 Users baseUsers = Entity.Users.FirstOrDefault(n => n.Token == Token); if (baseUsers == null)//用户令牌不存在 { DataObj.OutError("2004"); return; } if (baseUsers.State != 1)//用户被锁定 { DataObj.OutError("2003"); return; } if (baseUsers.CardStae != 2)//未实名认证 { DataObj.OutError("2006"); return; } UserBlackList UserBlackList = Entity.UserBlackList.FirstOrDefault(UBL => UBL.CardNumber == UserCard.Card && UBL.State == 3); if (UserBlackList != null) { //提示暂不支持该卡绑定 DataObj.OutError("2017"); return; } UserCard UserCard_ = Entity.UserCard.FirstOrDefault(n => n.UId == baseUsers.Id && n.Card == UserCard.Card && n.Type == 2 && n.State == 1);//信用卡已绑定 if (UserCard_ != null) { DataObj.OutError("2015"); return; } UserCard.Card = UserCard.Card.Replace(" ", ""); string cardbin = UserCard.Card.Substring(0, 6); var BasicCardBin = this.Entity.BasicCardBin.Where(o => o.BIN == cardbin).FirstOrDefault(); if (BasicCardBin == null) { byte UsedCardType = this.GetCardType(UserCard.Card); if (UsedCardType == 0) { DataObj.OutError("7005");//查询次数用完了 return; } else if (UsedCardType != 2) { DataObj.Msg = "请使用信用卡绑定"; DataObj.OutError("1000"); return; } } else { if (BasicCardBin.CardType != 2) { DataObj.Msg = "请使用信用卡绑定"; DataObj.OutError("1000"); return; } } BasicBank BasicBank = Entity.BasicBank.FirstOrDefault(n => n.Name == UserCard.Bank); if (BasicBank == null) { DataObj.OutError("1000"); return; } else { if (BasicBank.BIN.IsNullOrEmpty()) { DataObj.Msg = "卡BIN未设置"; DataObj.OutError("1000"); return; } } #endregion UserCard.Type = 2; UserCard.BId = BasicBank.Id; UserCard.Bin = BasicBank.BIN; UserCard.UId = baseUsers.Id; UserCard.Name = baseUsers.TrueName; //======================================= UserTrack.ENo = DataObj.ENo; UserTrack.OPType = "添加信用卡"; UserTrack.GPSAddress = UserTrack.GPSAddress; UserTrack.GPSX = UserTrack.X; UserTrack.GPSY = UserTrack.Y; baseUsers.SeavGPSLog(UserTrack, Entity); //======================================= string RetString = ""; //三方接口返回数据 string bindId = string.Empty; //绑卡需记录字符串 bool IsSuccess = false; //绑卡状态 JobPayWay JobPayWay = Entity.JobPayWay.Where(n => n.State == 1 && n.GroupType == "Pay").OrderBy(n => n.Sort).FirstOrDefault(); //目前只支持一条 if (JobPayWay == null) { DataObj.Msg = "暂无可用通道"; DataObj.OutError("1000"); return; } #region 第三方鉴权 string[] JobPayWayArr = JobPayWay.QueryArray.Split(','); if (JobPayWay.DllName == "HLBPay" && JobPayWayArr.Length == 2) { #region 合利宝 string MerId = JobPayWayArr[0]; string MerKey = JobPayWayArr[1]; string postUrl = "http://pay.trx.helipay.com/trx/quickPayApi/interface.action"; string orderId = Guid.NewGuid().ToString("N"); Dictionary <string, string> map = new Dictionary <string, string>(); map.Add("P1_bizType", "QuickPayBindCard"); map.Add("P2_customerNumber", MerId); map.Add("P3_userId", "HF_" + baseUsers.Id.ToString()); //用户ID唯一 map.Add("P4_orderId", orderId); map.Add("P5_timestamp", DateTime.Now.ToString("yyyyMMddHHmmss")); map.Add("P6_payerName", baseUsers.TrueName); map.Add("P7_idCardType", "IDCARD"); //IDCARD:身份证 map.Add("P8_idCardNo", baseUsers.CardId); //身份证 map.Add("P9_cardNo", UserCard.Card); //银行卡 map.Add("P10_year", UserCard.ValidYear); //当银行卡是信用卡时必输 信用卡有效期年 map.Add("P11_month", UserCard.ValidMonth); //当银行卡是信用卡时必输 信用卡有效期月 map.Add("P12_cvv2", UserCard.CVV); //当银行卡是信用卡时必输 信用卡有效期月 map.Add("P13_phone", UserCard.Mobile); map.Add("P14_validateCode", UserCard.ValidateCode); //选填 鉴权绑卡短信接口下发给用户的短信 //签名串,把参数值拼接 string data = Utils.CreateLinkString(map, false); //MD5签名KEY string sign = ("&" + data + "&" + MerKey).GetMD5(); map.Add("sign", sign); if (map["P6_payerName"] != null) //编码 { map.Remove("P6_payerName"); map.Add("P6_payerName", HttpUtility.UrlEncode(baseUsers.TrueName)); } string send_data = Utils.CreateLinkString(map); RetString = Utils.PostRequest(postUrl, send_data, "utf-8"); //================================================ //这里记录日志 JobLog JobLog = new JobLog(); JobLog.PayWay = JobPayWay.Id; JobLog.ReqNo = orderId; JobLog.TNum = baseUsers.Mobile; JobLog.Trade = ""; JobLog.Amount = 0; JobLog.Way = "CardAdd"; JobLog.AddTime = DateTime.Now; JobLog.Data = RetString; JobLog.State = 1; Entity.JobLog.AddObject(JobLog); Entity.SaveChanges(); //================================================ JObject obj = new JObject(); try { obj = (JObject)JsonConvert.DeserializeObject(RetString); } catch (Exception) { Utils.WriteLog("[CreditCardAdd]:" + RetString, "HLBPayError"); DataObj.OutError("1000"); return; } string rt2_retCode = obj["rt2_retCode"].ToString(); string rt3_retMsg = obj["rt3_retMsg"].ToString(); if (rt2_retCode == "0000") { string rt7_bindStatus = obj["rt7_bindStatus"].ToString(); //绑卡状态结果 /成功/失败 if (rt7_bindStatus == "SUCCESS") { IsSuccess = true; bindId = obj["rt10_bindId"].ToString(); } else { DataObj.Msg = rt3_retMsg; DataObj.OutError("1010"); return; } } else { DataObj.Msg = rt3_retMsg; DataObj.OutError("1010"); return; } #endregion } else if (JobPayWay.DllName == "HFJSPay" && JobPayWayArr.Length == 3) { #region 结算系统 string Code = JobPayWayArr[0]; string CodeKey = JobPayWayArr[1]; string PayWayCode = JobPayWayArr[2]; JobUserPay JobUserPay = Entity.JobUserPay.FirstOrDefault(n => n.UId == baseUsers.Id && n.PayWay == JobPayWay.Id); fastcardauthModel fastcardauthModel = new fastcardauthModel() { bankcard = UserCard.Card, mcode = UserCard.ValidateCode, merid = JobUserPay.MerId, paywaycode = PayWayCode }; ErrorCode errorCode = HFJSTools.fastcardauth(fastcardauthModel, JobUserPay.MerKey); if (errorCode.respcode == "00") { IsSuccess = true; } else { DataObj.Msg = errorCode.respmsg; DataObj.OutError("1010"); return; } #endregion } #endregion if (IsSuccess) { //系统要限制每条通道每张卡只能存在一个授权,所以这里要处理 UserCardOpen UserCardOpen = Entity.UserCardOpen.FirstOrDefault(n => n.CardNum == UserCard.Card && n.UId == baseUsers.Id && n.PayWay == JobPayWay.Id); if (UserCardOpen == null) { UserCardOpen = new UserCardOpen() { UId = baseUsers.Id, CardNum = UserCard.Card, Mobile = UserCard.Mobile, PayWay = JobPayWay.Id, State = 1, STime = new DateTime(1990, 1, 1), ETime = new DateTime(2099, 1, 1), Token = bindId, RqData = RetString }; Entity.UserCardOpen.AddObject(UserCardOpen); } else { UserCardOpen.Mobile = UserCard.Mobile; UserCardOpen.State = 1; UserCardOpen.Token = bindId; UserCardOpen.RqData = RetString; } UserCard.Pic = string.Empty; UserCard.ScanNo = string.Empty; UserCard.State = 1; UserCard.Deposit = string.Empty; Entity.UserCard.AddObject(UserCard); Entity.SaveChanges(); } DataObj.OutError("0000"); }
public void Post() { string Data = DataObj.GetData(); if (Data.IsNullOrEmpty()) { DataObj.OutError("1000"); return; } JObject json = new JObject(); try { json = (JObject)JsonConvert.DeserializeObject(Data); } catch (Exception Ex) { Log.Write("[OrderCash]:", "【Data】" + Data, Ex); } if (json == null) { DataObj.OutError("1000"); return; } //System.Threading.Thread.Sleep(60000 * 60 * 24); OrderCash OrderCash = new OrderCash(); OrderCash = JsonToObject.ConvertJsonToModel(OrderCash, json); UserTrack UserTrack = new UserTrack(); UserTrack = JsonToObject.ConvertJsonToModel(UserTrack, json); if (OrderCash.TrunType.IsNullOrEmpty()) { OrderCash.TrunType = 0; } if (OrderCash.TrunType != 0) { OrderCash.TrunType = 1; } string Tag = "Cash"; if (OrderCash.TrunType == 0) { Tag = "CashT0"; } if (OrderCash.TrunType == 1) { Tag = "CashT1"; } SysControl SysControl = Entity.SysControl.FirstOrDefault(n => n.Tag == Tag); SysControl syscontrol = SysControl.ChkState(); if (syscontrol.State != 1) { DataObj.OutError("1005"); return; } if (OrderCash.PayPwd.IsNullOrEmpty()) { DataObj.OutError("1000"); return; } if (OrderCash.PayPwd.Length < 6)//6位及以上 { DataObj.OutError("1000"); return; } //获取用户信息 Users baseUsers = Entity.Users.FirstOrDefault(n => n.Token == OrderCash.Token); if (baseUsers == null)//用户令牌不存在 { DataObj.OutError("2004"); return; } if (baseUsers.State != 1)//用户被锁定 { DataObj.OutError("2003"); return; } if (baseUsers.CardStae != 2)//未实名认证 { DataObj.OutError("2006"); return; } if (baseUsers.MiBao != 1)//未设置支付密码 { DataObj.OutError("2008"); return; } if (baseUsers.PayLock == 1)//密码错误太多次锁定 { DataObj.OutError("2050"); return; } if (baseUsers.StopPayState == 2)//禁止支付 { DataObj.OutError("6060"); return; } //获取系统配置 SysSet SysSet = Entity.SysSet.FirstOrDefault(); //这里是执行指纹解锁 bool IfCheckOk = true; if (OrderCash.PayPwd.Substring(0, 3) == "HF_") { string PassWord = OrderCash.PayPwd; PassWord = PassWord.Replace("HF_", ""); string Token = baseUsers.Token; Token = Token + "GoodPay"; string Md5Token = Token.GetMD5().ToUpper(); string Pass = Md5Token.Substring(0, 4) + Md5Token.Substring(Md5Token.Length - 4, 4); if (Pass != PassWord) { IfCheckOk = false; } } else if (baseUsers.PayPwd != OrderCash.PayPwd.GetPayMD5()) { //原支付密码错误 IfCheckOk = false; } if (!IfCheckOk) { //付密码错误 baseUsers.PayErr++; if (baseUsers.PayErr >= SysSet.PayLock) { baseUsers.PayLock = 1; } Entity.SaveChanges(); Users Out = new Users(); Out.PayErr = SysSet.PayLock - baseUsers.PayErr; Out.Cols = "PayErr"; DataObj.Data = Out.OutJson(); //DataObj.Code = "2010"; DataObj.Code = "2002"; if (Out.PayErr == 0) { DataObj.Msg = "用户支付密码不正确,请明日再试或取回支付密码"; } else { DataObj.Msg = "用户支付密码不正确,您还可以尝试" + Out.PayErr + "次"; } DataObj.OutString(); return; } baseUsers.PayErr = 0; Entity.SaveChanges(); //开始处理参数 if (OrderCash.Amoney.IsNullOrEmpty()) { DataObj.OutError("1000"); return; } OrderCash.Amoney = OrderCash.Amoney.FormatMoney(); //提现金额大于余额 if (OrderCash.Amoney > baseUsers.Amount) { DataObj.OutError("6001"); return; } //冻结金额小于0不能提现 if (baseUsers.Frozen < 0) { DataObj.OutError("6001"); return; } if (OrderCash.X.IsNullOrEmpty() || OrderCash.Y.IsNullOrEmpty()) { DataObj.OutError("1000"); return; } if (OrderCash.Owner.IsNullOrEmpty() || OrderCash.Bank.IsNullOrEmpty() || OrderCash.CardNum.IsNullOrEmpty() || OrderCash.Deposit.IsNullOrEmpty() || OrderCash.Mobile.IsNullOrEmpty()) { DataObj.OutError("1000"); return; } UserBlackList UserBlackList = Entity.UserBlackList.FirstOrDefault(UBL => UBL.CardNumber == OrderCash.CardNum && UBL.State == 3); if (UserBlackList != null) { //提示暂不支持该卡提现 DataObj.OutError("2017"); return; } //获取分支机构信息 SysAgent SysAgent = new SysAgent(); if (!baseUsers.Agent.IsNullOrEmpty()) { SysAgent = Entity.SysAgent.FirstOrNew(n => n.Id == baseUsers.Agent); } if (SysAgent.Id.IsNullOrEmpty()) { SysAgent.Cash0Times = 0; SysAgent.Cash1Times = 0; } decimal Peier = 0; if (OrderCash.TrunType == 0) { if (baseUsers.HasT0 != 1) { //T0黑名单 DataObj.OutError("6020"); return; } //验证是否满足T0 int Day = (DateTime.Now - baseUsers.AddTime).Days; int OrderCount = Entity.Orders.Count(n => (n.TType == 2 || n.TType == 5) && n.PayState == 2 && n.UId == baseUsers.Id); decimal?OrderMoney = Entity.Orders.Where(n => (n.TType == 2 || n.TType == 5) && n.PayState == 2 && n.UId == baseUsers.Id).Sum(n => (decimal?)n.Amoney); if (OrderMoney.IsNullOrEmpty()) { OrderMoney = 0; } if (Day >= SysSet.CashDay && OrderCount >= SysSet.CashNum && OrderMoney >= SysSet.CashMoney) { } else { DataObj.OutError("6020"); return; } //验证是否在快速提现时段内 TaskTimeSet TaskTimeSet = Entity.TaskTimeSet.FirstOrDefault(n => n.STime <= DateTime.Now && n.ETime >= DateTime.Now && n.TId == 1); if (TaskTimeSet == null) { DataObj.OutError("6018"); return; } Peier = TaskTimeSet.AllMoney - TaskTimeSet.UsedMoney; } OrderCash.UId = baseUsers.Id; if (OrderCash.TrunType == 0)//加急提现 { if (baseUsers.T0Times < SysAgent.Cash0Times) { //用户提现服务费 OrderCash.UserRate = 0; //加急费用 OrderCash.Cash = 0; //提现服务费 OrderCash.ECash = 0; } else { //用户提现服务费=提现金额*加急费率+提现服务费 OrderCash.UserRate = (double)(OrderCash.Amoney * baseUsers.Cash0 + baseUsers.ECash0); //提现服务费进位 OrderCash.UserRate = OrderCash.UserRate.Ceiling(); //加急费用 OrderCash.Cash = baseUsers.Cash0; //提现服务费 OrderCash.ECash = baseUsers.ECash0; } //系统提现费成本 OrderCash.CashRate = OrderCash.Amoney * SysSet.SysCash0 + SysSet.SysECash0; //系统手续费进位 OrderCash.CashRate = OrderCash.CashRate.Ceiling(); //这里是利润计算========== //代理商分润 double GetAgent = OrderCash.UserRate - (double)(OrderCash.Amoney * SysSet.AgentCash0 + SysSet.AgentECash0); if (GetAgent < 0) { GetAgent = 0; } //利润=收取用户手续费-系统支出手续费 double GetAll = OrderCash.UserRate - (double)OrderCash.CashRate - GetAgent; //利润舍位 GetAll = GetAll.Floor(); //总利润 OrderCash.AIdCashGet = (double)GetAll; //分支机构佣金设置为0,待分润计算后再写入 OrderCash.AgentCashGet = GetAgent; } else { if (baseUsers.T1Times < SysAgent.Cash1Times) { //用户提现服务费 OrderCash.UserRate = 0; //加急费用 OrderCash.Cash = 0; //提现服务费 OrderCash.ECash = 0; } else { //用户提现服务费=提现金额*加急费率+提现服务费 OrderCash.UserRate = (double)(OrderCash.Amoney * baseUsers.Cash1 + baseUsers.ECash1); //提现服务费进位 OrderCash.UserRate = OrderCash.UserRate.Ceiling(); //加急费用 OrderCash.Cash = baseUsers.Cash1; //提现服务费 OrderCash.ECash = baseUsers.ECash1; } //系统提现费成本 OrderCash.CashRate = OrderCash.Amoney * SysSet.SysCash1 + SysSet.SysECash1; //系统手续费进位 OrderCash.CashRate = OrderCash.CashRate.Ceiling(); //这里是利润计算========== //代理商分润 double GetAgent = OrderCash.UserRate - (double)(OrderCash.Amoney * SysSet.AgentCash1 + SysSet.AgentECash1); if (GetAgent < 0) { GetAgent = 0; } //利润=收取用户手续费-系统支出手续费 double GetAll = OrderCash.UserRate - (double)OrderCash.CashRate - GetAgent; //利润舍位 GetAll = GetAll.Floor(); //总利润 OrderCash.AIdCashGet = (double)GetAll; //分支机构佣金 OrderCash.AgentCashGet = GetAgent; } decimal Money = OrderCash.Amoney - (decimal)OrderCash.UserRate; if (Money < 0) { DataObj.OutError("1006"); return; } if (OrderCash.TrunType == 0)//T0时才验证 { //付款金额 //验证是否配额充足 if (Peier < Money) { DataObj.OutError("6019"); return; } } OrderCash.Agent = SysAgent.Id;//分支机构Id OrderCash.AId = baseUsers.AId; OrderCash.FId = 0; OrderCash.OrderState = 1; OrderCash.PayState = 1; OrderCash.AgentState = 0; OrderCash.FState = 0; OrderCash.AddTime = DateTime.Now; //写入前,判断交易金额限制 if (OrderCash.Amoney < syscontrol.SNum || OrderCash.Amoney > syscontrol.ENum) { DataObj.OutError("1006"); return; } //写入订单总表 Orders Orders = new Orders(); Orders.UId = OrderCash.UId; Orders.TName = baseUsers.TrueName; Orders.PayType = 0; Orders.PayName = "提现"; Orders.RUId = 0; Orders.RName = string.Empty; Orders.TType = 2; Orders.TState = 1; Orders.Amoney = OrderCash.Amoney; Orders.Poundage = (decimal)OrderCash.UserRate; Orders.AddTime = DateTime.Now; Orders.PayState = 1;//提现为余额支付的一种特殊形式。 Orders.PayWay = 4; Orders.PayTime = DateTime.Now; Orders.Agent = OrderCash.Agent; Orders.AgentState = 0; Orders.AId = OrderCash.AId; Orders.FId = 0; Orders.UserCardId = baseUsers.CardId; string OrderAddress = OrderCash.OrderAddress; if (OrderAddress.IsNullOrEmpty()) { OrderAddress = Utils.GetAddressByGPS(OrderCash.X, OrderCash.Y); } Orders.OrderAddress = OrderAddress; Orders.X = OrderCash.X; Orders.Y = OrderCash.Y; Orders.TrunType = OrderCash.TrunType; Entity.Orders.AddObject(Orders); Entity.SaveChanges(); Entity.Refresh(RefreshMode.StoreWins, Orders); OrderCash.OId = Orders.TNum; Entity.OrderCash.AddObject(OrderCash); Entity.SaveChanges(); //帐户变动记录 int USERSID = baseUsers.Id; string TNUM = OrderCash.OId; decimal PAYMONEY = Orders.Amoney; string SP_Ret = Entity.SP_UsersMoney(USERSID, TNUM, PAYMONEY, 3, ""); if (SP_Ret != "3") { Utils.WriteLog(string.Format("U{0},O{1},T{2}:{3}【{4}】", USERSID, TNUM, 3, PAYMONEY, SP_Ret), "SP_UsersMoney"); Orders.TState = 0; Orders.PayState = 0; OrderCash.OrderState = 0; OrderCash.PayState = 0; Entity.SaveChanges(); DataObj.OutError("8888"); return; } if (OrderCash.TrunType == 0)//T0时减少配额 { DateTime Today = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")); TaskTimeSet TaskTimeSet = Entity.TaskTimeSet.FirstOrDefault(n => n.ODate == Today); if (TaskTimeSet != null) { TaskTimeSet.UsedMoney += Money; Entity.SaveChanges(); } baseUsers.T0Times = baseUsers.T0Times + 1; } else { baseUsers.T1Times = baseUsers.T1Times + 1; } if (SysSet.CashChecked == 1) { bool IsAuto = true; if (SysSet.EveryDayMaxCash > 0)//超出规定额度,变成人工审核。规定是0刚不执行 { DateTime Today = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")); var todaymoney = this.Entity.OrderCash.Where(o => (o.OrderState == 2 || o.OrderState == 1) && o.AddTime > Today && (o.PayState == 1 || o.PayState == 2) && o.UId == baseUsers.Id).Sum(o => (decimal?)o.Amoney) ?? 0m; if (todaymoney > SysSet.EveryDayMaxCash)//当天累加提现 > 规定额度 { IsAuto = false; } } if (IsAuto) { //帐户变动记录 string SP_Ret2 = Entity.SP_UsersMoney(USERSID, TNUM, PAYMONEY, 4, ""); if (SP_Ret2 != "3") { Utils.WriteLog(string.Format("U{0},O{1},T{2}:{3}【{4}】", USERSID, TNUM, 4, PAYMONEY, SP_Ret2), "SP_UsersMoney"); DataObj.OutError("8888"); return; } else { //自动审核 Orders.TState = 2; OrderCash.OrderState = 2; OrderCash.AuditTime = DateTime.Now; Entity.SaveChanges(); } if (SysSet.CashPayWay == 1) //开启自动结算时执行 { if (OrderCash.TrunType == 0) //T0时自动出款 { if (OrderCash.Amoney <= SysSet.QCash0) { Utils.WriteLog("[S]" + Orders.TNum, "CashAuto"); OrderCash.PayCash(Orders, Entity);//去付款 Utils.WriteLog("[E]" + Orders.TNum, "CashAuto"); } else { Utils.WriteLog("结算金额超出自动出款金额" + OrderCash.OId + ":提现金额[" + OrderCash.Amoney + "]自动出款金额[" + SysSet.QCash0 + "]", "OrderCash"); } } //else //{ // Utils.WriteLog("T0时自动出款没开启" + OrderCash.OId, "OrderCash"); //} } else { Utils.WriteLog("自动结算没开启" + OrderCash.OId, "OrderCash"); } } else { Utils.WriteLog("单卡超过限定金额" + OrderCash.OId, "OrderCash"); } } else { Utils.WriteLog("自动审核没开启" + OrderCash.OId, "OrderCash"); } Entity.Refresh(RefreshMode.StoreWins, Orders); //======================================= UserTrack.ENo = DataObj.ENo; UserTrack.OPType = Orders.PayName; UserTrack.UserName = Orders.TNum; UserTrack.GPSAddress = Orders.OrderAddress; UserTrack.GPSX = Orders.X; UserTrack.GPSY = Orders.Y; Orders.SeavGPSLog(UserTrack, Entity); //======================================= Orders.SendMsg(Entity);//发送消息类 if (Orders.PayState == 3 && Orders.Remark == "本银行卡今日提交超过限额!") { DataObj.OutError("1016"); return; } //超过单日单卡(10W)到账限额 DataObj.Data = Orders.OutJson(); DataObj.Code = "0000"; DataObj.OutString(); }
public void Post() { string Data = DataObj.GetData(); if (Data.IsNullOrEmpty()) { DataObj.OutError("1000"); return; } JObject json = new JObject(); try { json = (JObject)JsonConvert.DeserializeObject(Data); } catch (Exception Ex) { Log.Write("[UserCardAdd]:", "【Data】" + Data, Ex); } if (json == null) { DataObj.OutError("1000"); return; } UserCard UserCard = new UserCard(); UserCard = JsonToObject.ConvertJsonToModel(UserCard, json); #region 校验 if (UserCard.PayPwd.IsNullOrEmpty()) { DataObj.OutError("1000"); return; } if (UserCard.PayPwd.Length < 6)//6位及以上 { DataObj.OutError("1000"); return; } var Bank = this.Entity.BasicBank.Where(o => o.Name == UserCard.Bank).FirstOrDefault(); if (Bank == null) { DataObj.OutError("1103"); return; } var BasicBankInfo = this.Entity.BasicBankInfo.Where(o => o.BId == Bank.Id && o.BIN == UserCard.Bin).FirstOrDefault(); if (BasicBankInfo == null) { DataObj.OutError("1102"); return; } //获取用户信息 string Token = UserCard.Token; Users baseUsers = Entity.Users.FirstOrDefault(n => n.Token == Token); if (baseUsers == null)//用户令牌不存在 { DataObj.OutError("2004"); return; } if (baseUsers.State != 1)//用户被锁定 { DataObj.OutError("2003"); return; } if (baseUsers.CardStae != 2)//未实名认证 { DataObj.OutError("2006"); return; } if (baseUsers.MiBao != 1)//未设置支付密码 { DataObj.OutError("2008"); return; } UserBlackList UserBlackList = Entity.UserBlackList.FirstOrDefault(UBL => UBL.CardNumber == UserCard.Card && UBL.State == 3); if (UserBlackList != null) { //提示暂不支持该卡绑定 DataObj.OutError("2016"); return; } UserCard UserCard_ = Entity.UserCard.FirstOrDefault(n => n.UId == baseUsers.Id && n.Card == UserCard.Card && n.State == 1);//已绑定本张银行卡 if (UserCard_ != null) { DataObj.OutError("2015"); return; } if (baseUsers.PayLock == 1)//密码错误太多次锁定 { DataObj.OutError("2050"); return; } #region 验证是否是借记卡 by anjing 2018-01-03 if (GetCardType(UserCard.Card) != 1) { DataObj.OutError("2016"); return; } #endregion #region 密码验证 //这里是执行指纹解锁 bool IfCheckOk = true; if (UserCard.PayPwd.Substring(0, 3) == "HF_") { string PassWord = UserCard.PayPwd; PassWord = PassWord.Replace("HF_", ""); string token = baseUsers.Token; token = token + "GoodPay"; string Md5Token = token.GetMD5().ToUpper(); string Pass = Md5Token.Substring(0, 4) + Md5Token.Substring(Md5Token.Length - 4, 4); if (Pass != PassWord) { IfCheckOk = false; } } else if (baseUsers.PayPwd != UserCard.PayPwd.GetPayMD5()) { //原支付密码错误 IfCheckOk = false; } if (!IfCheckOk) { //付密码错误 SysSet SysSet = Entity.SysSet.FirstOrNew(); //系统统一修改标识SAME002 baseUsers.PayErr++; if (baseUsers.PayErr >= SysSet.PayLock) { baseUsers.PayLock = 1; } Entity.SaveChanges(); Users Out = new Users(); Out.PayErr = SysSet.PayLock - baseUsers.PayErr; Out.Cols = "PayErr"; DataObj.Data = Out.OutJson(); DataObj.Code = "2002"; if (Out.PayErr == 0) { DataObj.Msg = "用户支付密码不正确,请明日再试或取回支付密码"; } else { DataObj.Msg = "用户支付密码不正确,您还可以尝试" + Out.PayErr + "次"; } DataObj.OutString(); return; } baseUsers.PayErr = 0; #endregion BasicBank BasicBank = Entity.BasicBank.FirstOrDefault(n => n.Name == UserCard.Bank); if (BasicBank == null) { DataObj.OutError("1000"); return; } #endregion Users cacheUsers = CacheBuilder.EntityCache.Get(baseUsers.Id.ToString() + "CardPicTemp") as Users; if (cacheUsers != null) { UserCard.Pic = cacheUsers.CardPic; UserCard.ScanNo = cacheUsers.CardNum ?? string.Empty; } else { UserCard.Pic = string.Empty; UserCard.ScanNo = string.Empty; } UserCard.UId = baseUsers.Id; UserCard.BId = BasicBank.Id; UserCard.Mobile = UserCard.Mobile.IsNullOrEmpty() ? string.Empty : UserCard.Mobile; UserCard.State = 1; UserCard.AddTime = DateTime.Now; Entity.UserCard.AddObject(UserCard); Entity.SaveChanges(); //if (HasCache) //{ // string CashName = "UserCard_" + UserCard.Type + "_" + Token; // CacheBuilder.EntityCache.Remove(CashName, null); //} DataObj.Data = UserCard.OutJson(); DataObj.Code = "0000"; DataObj.OutString(); }
public void Update(UserBlackList item) { db.Entry(item).State = EntityState.Modified; }
public void Create(UserBlackList item) { db.UserBlackLists.Add(item); }