public string BankBind(int cid = 0, int UserId = 0, string mobile = "", string bankcard = "", string bankcode = "", int typeid = 0, string cvn2 = "", string expiresYear = "", string expiresMouth = "", string OpeningBank = "", string OpeningSerialBank = "", int BankID = 0) { Logs.WriteLog($"Action:User,Cmd:BankBind,UserId:{UserId},mobile:{mobile},bankcard:{bankcard},bankcode:{bankcode},typeid:{typeid},cvn2:{cvn2},expiresYear:{expiresYear},expiresMouth:{expiresMouth},OpeningBank:{OpeningBank},OpeningSerialBank:{OpeningSerialBank}", "d:\\Log\\ITOrm", "BankBind"); userEventDao.UserBankBind(cid, UserId, Ip.GetClientIp(), mobile, bankcard, bankcode, typeid, cvn2, expiresYear, expiresMouth, OpeningBank, OpeningSerialBank, BankID); var version = TQuery.GetString("version"); if (cid == 3 && version == "1.0.0") { string temp = expiresYear; expiresYear = expiresMouth; expiresMouth = temp; } #region 验证 if (!TypeParse.IsMobile(mobile)) { return(ApiReturnStr.getError(-100, "预留手机号格式验证失败")); } if (!(bankcard.Length > 13 && bankcard.Length < 21)) { return(ApiReturnStr.getError(-100, "银行卡参数错误")); } if (string.IsNullOrEmpty(bankcode)) { return(ApiReturnStr.getError(-100, "银行编号不能为空")); } Users user = userDao.Single(UserId); if (user == null || user.UserId <= 0) { return(ApiReturnStr.getError(-100, "用户不存在")); } if (user.IsRealState != 1) { return(ApiReturnStr.getError(-100, "用户未实名认证,无法绑卡")); } if (typeid == 1)//如果是结算卡 { if (string.IsNullOrEmpty(cvn2) || string.IsNullOrEmpty(expiresYear) || string.IsNullOrEmpty(expiresMouth)) { return(ApiReturnStr.getError(-100, "支付卡参数有误")); } if (BankID == 0) { UserBankCard ubc = userBankCardDao.Single(" UserId=@UserId and BankCard=@bankcard and TypeId=1 ", new { UserId, bankcard }); if (ubc != null && ubc.ID > 0) { return(ApiReturnStr.getError(-100, "该支付卡已经绑定过,不能重复绑定")); } } } else { UserBankCard ubc = userBankCardDao.Single(" UserId=@UserId and TypeId=0 and State=1 ", new { UserId }); if (ubc != null && ubc.ID > 0) { return(ApiReturnStr.getApiData(-100, "结算卡只能绑定一张")); } } UserBankCard model = null; if (BankID > 0) { model = userBankCardDao.Single(BankID); if (model == null) { return(ApiReturnStr.getApiData(-100, "BankID记录不存在")); } if (model.State == 1) { return(ApiReturnStr.getApiData(-100, "该银行卡已通过验证,不可修改信息")); } } else { model = new UserBankCard(); } #endregion #region 绑卡 var result = BankCardBindHelper.Bind(typeid, user.RealName, user.IdCard, bankcard, mobile, cvn2, expiresYear, expiresMouth); model.BankCard = result.bankCard; model.BankCode = bankcode; model.BankName = bankDao.QueryBankName(bankcode); model.CVN2 = cvn2; model.ExpiresYear = expiresYear; model.ExpiresMouth = expiresMouth; model.UTime = DateTime.Now; model.Mobile = mobile; model.TypeId = typeid; model.OpeningBank = OpeningBank; model.OpeningSerialBank = OpeningSerialBank; model.State = 0;// result.backState ? 1 : 0;//默认为0 model.RelationId = ",0,"; bool flag = false; if (BankID == 0) { model.UserId = UserId; model.IP = Ip.GetClientIp(); model.CTime = DateTime.Now; model.Platform = cid; int num = userBankCardDao.Insert(model); flag = num > 0; return(ApiReturnStr.getError(flag ? 0 : -100, flag ? "绑定成功" : "绑定失败")); } else { var list = bankTreatyApplyDao.GetQuery(" State=2 And UbkID=@BankID", new { BankID }); if (list != null && list.Count > 0) { foreach (var item in list) { MasgetDepository.TreatyModify(BankID, cvn2, expiresYear, expiresMouth, cid, (Logic.ChannelType)item.ChannelType); } } flag = userBankCardDao.Update(model); return(ApiReturnStr.getError(flag ? 0 : -100, flag ? "修改成功" : "修改失败")); } #endregion }