public ActionResult Save(int Id, string LoginPwd) { TradersUser tradersUser = new TradersUser(); if (Id == 0) { tradersUser.TUserId = CommonService.GUID.ToUpper(); tradersUser.AccountType = 2; tradersUser.State = 1; tradersUser.SysCreateUID = CurrentUser.UID; tradersUser.CreateDT = DateTime.Now; TryUpdateModel <TradersUser>(tradersUser); tradersUser.LoginPwd = Security.MD5_Encrypt(tradersUser.LoginPwd); } else { tradersUser = tradersUserService.GetEntityById(Id); if (LoginPwd.IsNullOrEmpty()) { string[] s = new string[] { "CID", "TStoreInfoId", "FullName", "LoginName", "Phone", "Memo" }; TryUpdateModel <TradersUser>(tradersUser, s); } else { TryUpdateModel <TradersUser>(tradersUser); tradersUser.LoginPwd = Security.MD5_Encrypt(tradersUser.LoginPwd); } } var op = tradersUserService.Save(tradersUser, Id, Request.Params); return(new OpActionResult(op)); }
public ActionResult Save(int?id) { var obj = new TradersUser { }; if (id.HasValue) { obj = tradersUserService.GetEntityById(id.Value); obj.LoginPwd = ""; } return(View(obj.IsNullThrow())); }
/// <summary> /// 更新商家管理员登录账号(没有SaveChanges) /// </summary> /// <param name="cids"></param> /// <param name="type">0是支付许可,1是商家结算账户,2是商家支付通道</param> /// <returns></returns> public OpResult UpAdmin(IEnumerable <int?> cids, int type) { foreach (var v in cids) { var isLicense = isExistByWhere(o => o.CID == v && o.State == (short)TraderPayLicenseState.Audited); var isBank = bankAccountService.isExistByWhere(o => o.CID == v && o.State == (int)TraderBalanceAccountState.Enabled); var isPay = tradersPaySecretKeyService.isExistByWhere(o => o.CID == v && o.State == (int)TraderPayCchannelState.Enabled); bool isUp = false; //支付许可 if (type == 0) { if (isBank && isPay) { isUp = true; } } //商家结算账户 if (type == 1) { if (isLicense && isPay) { isUp = true; } } //商家支付通道 if (type == 2) { if (isLicense && isBank) { isUp = true; } } if (isUp) { TradersUser tradersUser = tradersUserService.GetEntityByWhere(o => o.CID == v && o.AccountType == 1); if (tradersUser != null) { tradersUser.State = 2; tradersUser.IsHide = 0; tradersUserService.InsertUpdate(tradersUser, tradersUser.Id, false); } } } return(OpResult.Success()); }
/// <summary> /// 保存 /// </summary> /// <param name="payLicense"></param> /// <param name="id"></param> /// <param name="nvl"></param> /// <param name="fileCollection"></param> /// <returns></returns> public OpResult Save(PayLicense payLicense, int id, DateTime dt, System.Collections.Specialized.NameValueCollection nvl, HttpFileCollectionBase fileCollection) { //验证 var op = Verification(nvl, fileCollection, id, payLicense); if (!op.Successed) { return(op); } else { try { using (EFDbContext context = new EFDbContext()) { using (TransactionScope transaction = new TransactionScope()) { //资质或证件 HttpPostedFileBase file1 = fileCollection[0]; //企业证件 HttpPostedFileBase file2 = fileCollection[1]; //身份证正面 HttpPostedFileBase file3 = fileCollection[2]; //身份证反面 HttpPostedFileBase file4 = fileCollection[3]; string fileName1 = UploadFile(file1, payLicense, 1); string fileName2 = UploadFile(file2, payLicense, 2); string fileName3 = UploadFile(file3, payLicense, 3); string fileName4 = UploadFile(file4, payLicense, 4); if (fileName1 != "error") { payLicense.ECertificateUrl1 = fileName1; } if (fileName2 != "error") { payLicense.ECertificateUrl2 = fileName2; } if (fileName3 != "error") { payLicense.IDCardUrl1 = fileName3; } if (fileName4 != "error") { payLicense.IDCardUrl2 = fileName4; } //经营信息、商户信息 PayLicense pLicense = InsertUpdate(payLicense, id); //商户号(结算账户) string CID3 = (nvl["CID3"] ?? "").Trim(); //财务联系人 string bankLinkMan = (nvl["bankLinkMan"] ?? "").Trim(); //账户类型 string AccountType = (nvl["AccountType"] ?? "").Trim(); //开户名称 string AccountName = (nvl["AccountName"] ?? "").Trim(); //联系人电话 string bankPhone = (nvl["bankPhone"] ?? "").Trim(); //开户银行城市 string BankCityTitle = (nvl["BankCityTitle"] ?? "").Trim(); //开户银行 string BankName = (nvl["BankName"] ?? "").Trim(); //开户支行 string BranchName = (nvl["BranchName"] ?? "").Trim(); //银行账号 string AccountNumber = (nvl["AccountNumber"] ?? "").Trim(); BankAccount bankAccount = new BankAccount(); if (id > 0) { bankAccount = bankAccountService.GetEntityByWhere(o => o.LicenseId == pLicense.LicenseId); } else { bankAccount.BAccountId = CommonService.GUID.ToUpper(); bankAccount.LicenseId = pLicense.LicenseId; bankAccount.State = 1; bankAccount.CreateUID = CurrentUser.UID; bankAccount.CreateDT = dt; } bankAccount.ModifyUID = CurrentUser.UID; bankAccount.ModifyDT = dt; bankAccount.CID = CID3 == "" ? 0 : Convert.ToInt32(CID3); bankAccount.LinkMan = bankLinkMan == "" ? null : bankLinkMan; bankAccount.AccountType = AccountType == "" ? Convert.ToInt16(0) : Convert.ToInt16(AccountType); bankAccount.AccountName = AccountName == "" ? null : AccountName; bankAccount.Phone = bankPhone == "" ? null : bankPhone; bankAccount.BankCityId = getCityID(BankCityTitle); bankAccount.BankName = BankName == "" ? null : BankName; bankAccount.BranchName = BranchName == "" ? null : BranchName; bankAccount.AccountNumber = AccountNumber == "" ? null : AccountNumber; if (id > 0) { if (bankAccount.State == (int)TraderBalanceAccountState.Reject) { bankAccount.State = (int)TraderBalanceAccountState.NotAuditing; } } //结算账户 bankAccountService.InsertUpdate(bankAccount, bankAccount.Id); int CID4 = CID3 == "" ? 0 : Convert.ToInt32(CID3); TradersUser tradersUser = new TradersUser(); if (id > 0) { tradersUser = tradersUserService.GetEntityByWhere(o => o.CID == CID4 && o.AccountType == 1); } if (id == 0 || tradersUser == null) { tradersUser = new TradersUser(); tradersUser.TUserId = CommonService.GUID.ToUpper(); tradersUser.SysCreateUID = CurrentUser.UID; tradersUser.CreateDT = dt; } tradersUser.CID = CID3 == "" ? 0 : Convert.ToInt32(CID3); tradersUser.LoginName = payLicense.LoginName; tradersUser.FullName = payLicense.AdminName; tradersUser.AccountType = 1; if (id == 0) { tradersUser.State = 1; tradersUser.IsHide = 1; } //商家登录账号 tradersUserService.InsertUpdate(tradersUser, tradersUser.Id); ApproveLog approveLog = new ApproveLog(); approveLog.ModuleNum = Convert.ToInt16(ApproveLogNum.支付许可); approveLog.ItemId = pLicense.LicenseId; approveLog.CreateTime = dt; approveLog.OperatorUID = CurrentUser.UID; if (id == 0) { approveLog.OperationType = Convert.ToInt16(ApproveLogType.提交申请); approveLog.Description = "已提交支付许可材料信息申请"; } else { approveLog.OperationType = Convert.ToInt16(ApproveLogType.重新提交); approveLog.Description = "重新提交了支付许可材料信息申请"; } //审核日志 approveLogService.InsertUpdate(approveLog, 0); //提交事务 transaction.Complete(); return(OpResult.Success()); } } } catch (Exception e) { LogEngine.WriteError(e); return(OpResult.Fail(e.InnerException.InnerException.Message)); } } }
/// <summary> /// 验证 /// </summary> /// <param name="nvl"></param> /// <param name="fileCollection"></param> /// <param name="id"></param> /// <returns></returns> public OpResult Verification(System.Collections.Specialized.NameValueCollection nvl, HttpFileCollectionBase fileCollection, int id, PayLicense payLicense) { //商户号 var CID = (nvl["CID"] ?? "").Trim(); //服务商号 var AgentsId = (nvl["AgentsId"] ?? "").Trim(); //营业期限开始日期 var OperatingStartDate = (nvl["OperatingStartDate"] ?? "").Trim(); //营业期限结束日期 var OperatingEndDate = (nvl["OperatingEndDate"] ?? "").Trim(); //开户银行城市 var BankCityTitle = (nvl["BankCityTitle"] ?? "").Trim(); //支付后台登录账号 var LoginName = (nvl["LoginName"] ?? "").Trim(); //资质或证件 HttpPostedFileBase file1 = fileCollection[0]; //企业证件 HttpPostedFileBase file2 = fileCollection[1]; //身份证正面 HttpPostedFileBase file3 = fileCollection[2]; //身份证反面 HttpPostedFileBase file4 = fileCollection[3]; var list = tradersService.getUserList().Where(o => o.UserId == payLicense.DesigneeId); if (!list.Any()) { return(OpResult.Fail("指派人不正确")); } if (CID != "") { if (!Tool.IsNumber(CID)) { return(OpResult.Fail("商户号不存在")); } else { int cid = Convert.ToInt32(CID); var q = CompanyAuthorizeRepository.GetQuery(o => o.Status == 1 && o.CID == cid); if (!q.Any()) { return(OpResult.Fail("商户号未申请软件许可或不是正常的软件许可")); } if (!tradersService.isExistByWhere(o => o.Status == 1 && o.CID == cid)) { return(OpResult.Fail("商户号在客户档案不存在或不是已审")); } } } int intCID = 0; if (CID != "") { intCID = Convert.ToInt32(CID); } bool isExist = false; if (id == 0) { isExist = isExistByWhere(o => o.CID == intCID); } else { isExist = isExistByWhere(o => o.CID == intCID && o.Id != id); } if (isExist) { return(OpResult.Fail("该商户号已经申请过支付许可,无法重复申请")); } if (AgentsId != "") { if (!Tool.IsNumber(AgentsId)) { return(OpResult.Fail("服务商号不存在")); } else { int agentsId = Convert.ToInt32(AgentsId); //未修改 if (!agentsInfoService.isExistByWhere(o => o.AgentsId == agentsId)) { return(OpResult.Fail("服务商号不存在")); } } } if (OperatingStartDate != "" && OperatingEndDate != "") { DateTime startDateTime = Convert.ToDateTime(OperatingStartDate); startDateTime = startDateTime.AddMonths(4); DateTime endDateTime = Convert.ToDateTime(OperatingEndDate); if (DateTime.Compare(startDateTime, endDateTime) >= 0) { return(OpResult.Fail("营业期限结束日期必须大于开始日期4个月")); } } if (BankCityTitle != "") { if (!isExistCity(BankCityTitle)) { return(OpResult.Fail("开户银行城市不存在")); } } if (LoginName != "") { if (id > 0) { PayLicense pLicense = pRepository.GetEntityByWhere(id); if (pLicense != null) { int cid = Convert.ToInt32(CID); TradersUser tradersUser = tradersUserService.GetEntityByWhere(o => o.CID == pLicense.CID && o.AccountType == 1); if (tradersUser != null && cid == pLicense.CID) { if (tradersUserService.isExistByWhere(o => o.LoginName == LoginName && o.Id != tradersUser.Id)) { return(OpResult.Fail("支付后台登录账号不可用,请使用其它账号")); } } else { if (tradersUserService.isExistByWhere(o => o.LoginName == LoginName)) { return(OpResult.Fail("支付后台登录账号不可用,请使用其它账号")); } } } } else { if (tradersUserService.isExistByWhere(o => o.LoginName == LoginName)) { return(OpResult.Fail("支付后台登录账号不可用,请使用其它账号")); } } } string format = "*.jpg,*.jpeg,*.gif,*.png,*.bmp"; string f1 = Tool.ValidateFile(file1, 1000, format); if (f1 != "success") { return(OpResult.Fail("资质或证件" + f1)); } string f2 = Tool.ValidateFile(file2, 1000, format); if (f2 != "success") { return(OpResult.Fail("企业证件" + f2)); } string f3 = Tool.ValidateFile(file3, 1000, format); if (f3 != "success") { return(OpResult.Fail("身份证正面" + f3)); } string f4 = Tool.ValidateFile(file4, 1000, format); if (f4 != "success") { return(OpResult.Fail("身份证反面" + f4)); } return(OpResult.Success()); }