public ActionResult Verify(Guid id) { MerchantInformations merchantInfo = FiiiPayDB.MerchantInformationDb.GetById(id); var country = FoundationDB.CountryDb.GetById(merchantInfo.CountryId); var fiiipayAccount = FiiiPayDB.UserAccountDb.GetById(merchantInfo.MerchantAccountId); ViewBag.CountryName = country.Code.ToUpper() == "CN" ? country.Name_CN : country.Name; ViewBag.FiiiPayAccountName = fiiipayAccount.PhoneCode + " " + fiiipayAccount.Cellphone; ViewBag.StoreTypeList = FiiiPayDB.StoreTypeDb.GetList(); ViewBag.MerchantStoreTypeList = FiiiPayDB.MerchantCategoryDb.GetList(t => t.MerchantInformationId == merchantInfo.Id); ViewBag.MerchantSupportCryptoList = FiiiPayDB.MerchantSupportCryptoDb.GetList(t => t.MerchantInfoId == merchantInfo.Id); FiiipayMerchantProfiles profile = null; if (merchantInfo.VerifyStatus != Entities.Enums.VerifyStatus.Certified) { var recorde = FiiiPayDB.FiiipayMerchantVerifyRecordDb.GetList(t => t.MerchantInfoId == merchantInfo.Id).OrderByDescending(t => t.CreateTime).FirstOrDefault(); if (recorde != null) { profile = new FiiipayMerchantProfiles { MerchantInfoId = merchantInfo.Id, LicenseNo = recorde.LicenseNo, BusinessLicenseImage = recorde.BusinessLicenseImage } } ; } else { profile = FiiiPayDB.FiiipayMerchantProfileDb.GetSingle(t => t.MerchantInfoId == merchantInfo.Id); } ViewBag.FiiipayMerchantProfile = profile; ViewBag.OwnersFigure = FiiiPayDB.MerchantOwnersFigureDb.GetList(t => t.MerchantInformationId == merchantInfo.Id); ViewBag.InviteCode = FiiiPayDB.InviteRecordDb.GetSingle(t => t.AccountId == fiiipayAccount.Id && t.Type == InviteType.FiiipayMerchant)?.InviterCode; return(View(merchantInfo)); }
public SaveResult SaveAdd(string boUsername, MerchantEditInfoModel model, string inviteCode) { var fiiipayAccount = FiiiPayDB.UserAccountDb.GetSingle(t => t.CountryId == model.CountryId && t.Cellphone == model.FiiiPayAccount); if (fiiipayAccount == null) { return(new SaveResult(false, "FiiiPay用户不存在")); } if (fiiipayAccount.Status != (byte)Entities.Enums.AccountStatus.Active) { return(new SaveResult(false, "FiiiPay用户异常")); } if (fiiipayAccount.L1VerifyStatus != Entities.Enums.VerifyStatus.Certified) { return(new SaveResult(false, "该账号未通过KYC LV1认证")); } UserAccounts inviteAccount = null; bool needInsertInviteRecord = false; if (!string.IsNullOrEmpty(inviteCode)) { inviteAccount = FiiiPayDB.UserAccountDb.GetSingle(t => t.InvitationCode == inviteCode); if (inviteAccount == null) { return(new SaveResult(false, "无效的邀请码")); } if (inviteAccount.InvitationCode == fiiipayAccount.InvitationCode) { return(new SaveResult(false, "不能填写商家自己的邀请码")); } needInsertInviteRecord = true; } var existRecord = FiiiPayDB.DB.Queryable <InviteRecords>().First(t => t.AccountId == fiiipayAccount.Id && t.Type == InviteType.FiiipayMerchant); if (existRecord == null) { needInsertInviteRecord = needInsertInviteRecord && true; } else { if (existRecord.InviterCode != inviteCode) { return(new SaveResult(false, "已经设置了其他账号为邀请人")); } needInsertInviteRecord = false; } var country = FoundationDB.CountryDb.GetSingle(t => t.Code == model.CountryCode); if (country == null) { return(new SaveResult(false, "无效的国家")); } #region entities Guid merchantInfoId = Guid.NewGuid(); DateTime dtNow = DateTime.UtcNow; MerchantInformations merchantInfo = new MerchantInformations { Id = merchantInfoId, CreateTime = dtNow, FromType = InputFromType.BOInput, MerchantName = model.MerchantName, WeekTxt = model.WeekTxt, Tags = model.TagList == null ? "" : string.Join(",", model.TagList), Introduce = model.Introduce, CountryId = country.Id, PhoneCode = country.PhoneCode, Address = model.Address, Lng = model.Lng, Lat = model.Lat, Status = Status.Enabled, VerifyStatus = Entities.Enums.VerifyStatus.Certified, MerchantAccountId = fiiipayAccount.Id, Phone = model.Phone, IsPublic = Status.Enabled, FileId = model.FileId, ThumbnailId = model.FileId,//new BlobBLL().UploadWithCompress(model.FileId), AccountType = Entities.Enums.AccountType.User, Markup = 0, FeeRate = 0, IsAllowExpense = true, Week = Week.Monday, ApplicantName = model.ApplicantName }; InviteRecords inviteRecord = new InviteRecords { AccountId = fiiipayAccount.Id, InviterCode = inviteCode, Type = InviteType.FiiipayMerchant, InviterAccountId = inviteAccount?.Id ?? Guid.Empty, Timestamp = dtNow }; FiiipayMerchantProfiles profile = new FiiipayMerchantProfiles { MerchantInfoId = merchantInfoId, BusinessLicenseImage = model.BusinessLicenseImage, LicenseNo = model.LicenseNo }; FiiipayMerchantVerifyRecords record = new FiiipayMerchantVerifyRecords { CreateTime = dtNow, MerchantInfoId = merchantInfoId, BusinessLicenseImage = model.BusinessLicenseImage, LicenseNo = model.LicenseNo, VerifyStatus = Entities.Enums.VerifyStatus.Certified, VerifyTime = dtNow, Auditor = boUsername }; List <MerchantCategorys> categorys = model.MerchantCategorys.Select(t => new MerchantCategorys { MerchantInformationId = merchantInfoId, Category = t }).ToList(); List <MerchantOwnersFigures> figuresList = new List <MerchantOwnersFigures>(); if (model.FigureImgIdList != null) { var blobBLL = new BlobBLL(); for (int i = 0; i < model.FigureImgIdList.Length; i++) { figuresList.Add(new MerchantOwnersFigures { MerchantInformationId = merchantInfoId, FileId = model.FigureImgIdList[i], Sort = i, ThumbnailId = model.FigureImgIdList[i]//blobBLL.UploadWithCompress(model.FigureImgIdList[i]) }); } } var coinList = FoundationDB.CryptocurrencyDb.GetList(); List <MerchantSupportCryptos> supportCryptoList = model.SupportCoins.Select(t => new MerchantSupportCryptos { MerchantInfoId = merchantInfoId, CryptoId = t, CryptoCode = coinList == null ? "" : coinList.Find(c => c.Id == t).Code }).ToList(); #endregion var sr = FiiiPayDB.DB.Ado.UseTran(() => { FiiiPayDB.MerchantInformationDb.Insert(merchantInfo); FiiiPayDB.FiiipayMerchantProfileDb.Insert(profile); FiiiPayDB.FiiipayMerchantVerifyRecordDb.Insert(record); if (needInsertInviteRecord) { FiiiPayDB.InviteRecordDb.Insert(inviteRecord); } if (categorys.Count > 0) { FiiiPayDB.MerchantCategoryDb.InsertRange(categorys); } if (figuresList.Count > 0) { FiiiPayDB.MerchantOwnersFigureDb.InsertRange(figuresList); } if (supportCryptoList != null && supportCryptoList.Count > 0) { FiiiPayDB.MerchantSupportCryptoDb.InsertRange(supportCryptoList); } }); return(new SaveResult(sr.IsSuccess, sr.ErrorMessage)); }