/// <summary> /// 修改商家所有信息 /// </summary> /// <param name="id"></param> /// <param name="information"></param> public void Update(Guid id, MerchantInformation information) { const string sql = @"UPDATE MerchantInformations SET MerchantName = @MerchantName, Week = @Week, Tags = @Tags, Introduce = @Introduce, Address = @Address, Lng = @Lng, Lat = @Lat, Phone = @Phone, VerifyStatus = @VerifyStatus WHERE Id=@Id"; using (var conn = WriteConnection()) { conn.Execute(sql, new { information.MerchantName, information.Week, information.Tags, information.Introduce, information.Address, information.Lng, information.Lat, Id = id, information.Phone, information.VerifyStatus }); } }
public MerchantInformation Get() { Guid userId = Security.GetUserId(); Log.Verbose("Getting user information for merchant user Id: {0}", userId); try { MerchantInformation merchantInformation = null; IEnumerable <MerchantSubscriptionInfo> merchantSubscriptions = this.usersDal.GetMerchantSubscriptionsByUserId(userId); var subscription = merchantSubscriptions.FirstOrDefault(merchantSubscription => merchantSubscription.SubscriptionType == SubscriptionType.TransactionReport); if (subscription != null) { merchantInformation = new MerchantInformation() { IsActive = subscription.IsActive, Preferences = subscription.IsActive ? new LoMo.UserServices.DataContract.MerchantPreferences { EmailReportInterval = subscription.EmailReportInterval.ToString() } : null, SubscriptionType = subscription.SubscriptionType.ToString() }; } Log.Verbose("Get user preferences request completed succefully for merchant user Id: {0}", userId); return(merchantInformation); } catch (Exception e) { Log.Error(e, "Couldn't get preferences for merchant user Id: {0}", userId); throw new HttpResponseException(HttpStatusCode.InternalServerError); } }
public async Task TestAddressEnquiry() { VPAEnquiryResponse response = new VPAEnquiryResponse(); VPATranslateResponse vtr = new VPATranslateResponse(); VPAInformation vInfo = new VPAInformation(); PersonalInformation pInfo = new PersonalInformation(); AccountInformation aInfo = new AccountInformation(); MerchantInformation mInfo = new MerchantInformation(); List <AssociatedVpas> aVpas = new List <AssociatedVpas>(); VPAEnquiryRequest req = new VPAEnquiryRequest() { channelCode = 8, instructedInstitutionCode = "123", instructingInstitutionCode = "402", requestId = "i88hgtbh", targetVPA = "musaarca", updatedOn = DateTime.Now }; VPAEnquiryResponse respose = new VPAEnquiryResponse(); VPAEnquiryController controller = new VPAEnquiryController(getCacheSettings(), getAppSettings(), response, vtr, vInfo, pInfo, aInfo, mInfo, aVpas, req); respose = await controller.AddressEnquiry(req); Assert.NotNull(respose.httpStatusCode); Assert.Equal((int)HttpStatusCode.OK, respose.httpStatusCode); }
public async Task TestAccountEnquiry() { VPAEnquiryResponse response = new VPAEnquiryResponse(); VPATranslateResponse vtr = new VPATranslateResponse(); VPAInformation vInfo = new VPAInformation(); PersonalInformation pInfo = new PersonalInformation(); AccountInformation aInfo = new AccountInformation(); MerchantInformation mInfo = new MerchantInformation(); List <AssociatedVpas> aVpas = new List <AssociatedVpas>(); VPAEnquiryRequest req = new VPAEnquiryRequest(); AccountEnquiryRequest arequest = new AccountEnquiryRequest() { channelCode = 5, instructedInstitutionCode = "202", instructingInstitutionCode = "11", requestId = "jh3r4y75hui", targetAccountNumber = "2024878029" }; AccountInformation ainf = new AccountInformation(); VPAEnquiryController controller = new VPAEnquiryController(getCacheSettings(), getAppSettings(), response, vtr, vInfo, pInfo, aInfo, mInfo, aVpas, req); ainf = await controller.testAccountEnquiry(arequest); Assert.NotNull(ainf.accountNumber); Assert.Equal(arequest.targetAccountNumber, ainf.accountNumber); }
public async Task TestVPAEnquiry() { VPAEnquiryResponse response = new VPAEnquiryResponse(); VPATranslateResponse vtr = new VPATranslateResponse(); VPAInformation vInfo = new VPAInformation(); PersonalInformation pInfo = new PersonalInformation(); AccountInformation aInfo = new AccountInformation(); MerchantInformation mInfo = new MerchantInformation(); List <AssociatedVpas> aVpas = new List <AssociatedVpas>(); VPAEnquiryRequest req = new VPAEnquiryRequest(); VPAEnquiryRequest vrequest = new VPAEnquiryRequest() { channelCode = 7, instructedInstitutionCode = "044", instructingInstitutionCode = "230", requestId = "hdfufsh3652", targetVPA = "fuzzytoocool", updatedOn = DateTime.Now }; VPATranslateResponse vpaTranslateResponse = new VPATranslateResponse(); VPAEnquiryController controller = new VPAEnquiryController(getCacheSettings(), getAppSettings(), response, vtr, vInfo, pInfo, aInfo, mInfo, aVpas, req); vpaTranslateResponse = await controller.testvpaEnquiry(vrequest); //Assert.Equal(v, vpaTranslateResponse); Assert.NotNull(vpaTranslateResponse.vpaId); Assert.Equal(vrequest.targetVPA, vpaTranslateResponse.vpaId); }
/// <summary> /// 新增门店信息 /// </summary> /// <param name="information"></param> /// <param name="ownersFigures"></param> /// <param name="merchantRecommends"></param> /// <param name="merchantCategories"></param> /// <param name="phone"></param> public void InsertMerchantInformation(MerchantInformation information, List <MerchantOwnersFigure> ownersFigures, List <MerchantRecommend> merchantRecommends, List <MerchantCategory> merchantCategories) { if (new MerchantAccountDAC().GetById(information.MerchantAccountId) == null) { throw new CommonException(ReasonCode.FiiiPosReasonCode.ACCOUNT_NOT_EXISTS, "商家账户未注册或不存在"); } if (new MerchantInformationDAC().GetByMerchantAccountId(information.MerchantAccountId) != null) { throw new CommonException(ReasonCode.MERCAHNT_BINDING, "该商家已绑定门店"); } Task.WhenAll(Task.Run(() => Parallel.ForEach(merchantRecommends, item => { var tumnailId = new MasterImageAgent().UploadWithCompress(item.RecommendPicture); item.ThumbnailId = tumnailId == Guid.Empty ? item.RecommendPicture : tumnailId; })), Task.Run(() => Parallel.ForEach(ownersFigures, item => { var tumnailId = new MasterImageAgent().UploadWithCompress(item.FileId); item.ThumbnailId = tumnailId == Guid.Empty ? item.FileId : tumnailId; }))).Wait(); using (var scope = new TransactionScope()) { new MerchantInformationDAC().Insert(information); ownersFigures.ForEach(item => new MerchantOwnersFigureDAC().Insert(item)); merchantRecommends.ForEach(item => new MerchantRecommendDAC().Insert(item)); merchantCategories.ForEach(item => new MerchantCategoryDAC().Insert(item)); //new MerchantAccountDAC().UpdateCellphone(information.MerchantAccountId, phone); //new MerchantAccountDAC().UpdateMerchantName(information.MerchantAccountId, information.MerchantName); scope.Complete(); } }
private GetMerchantDetailOM GetFiiiPosMerchantDetail(MerchantInformation merchantDetail) { var weekArray = Enum.GetValues(typeof(Week)); var weekList = new List <int>(); foreach (var item in weekArray) { if (merchantDetail.Week.HasFlag((Enum)item)) { weekList.Add((int)Math.Log((int)item, 2) + 1); } } var currencyList = new MerchantWalletDAC().SupportReceiptList(merchantDetail.MerchantAccountId); var cryptoDict = new CryptocurrencyDAC().GetAll().ToDictionary(item => item.Code); var imageList = new MerchantOwnersFigureDAC().GetOwnersFiguresById(merchantDetail.Id); var recommendList = new MerchantRecommendDAC().GetRecommendsById(merchantDetail.Id); var result = new GetMerchantDetailOM() { AccountType = (int)Entities.Enums.AccountType.Merchant, IsAllowExpense = merchantDetail.IsAllowExpense, AvailableCryptoCodeList = currencyList.Select(item => item.CryptoCode).ToList(), AvailableCryptoIconList = currencyList.Select(item => { if (cryptoDict.ContainsKey(item.CryptoCode)) { return(cryptoDict[item.CryptoCode].IconURL.ToString()); } return(string.Empty); }).Where(item => !string.IsNullOrEmpty(item)).ToList(), Address = merchantDetail.Address, EndDate = merchantDetail.EndTime, StartDate = merchantDetail.StartTime, BussinessHour = merchantDetail.WeekTxt, ImageUrls = imageList.Select(item => item.FileId).ToList(), Location = new Location() { Longitude = merchantDetail.Lng, Latitude = merchantDetail.Lat }, Introduce = merchantDetail.Introduce, RecommendGoods = recommendList.Select(item => new Goods() { Content = item.RecommendContent, Image = new ImageWithCompressImage() { Compress = item.ThumbnailId, Origin = item.RecommendPicture } }).ToList(), Tags = merchantDetail.Tags.Split(','), Title = merchantDetail.MerchantName, Phone = merchantDetail.Phone, PhoneCode = merchantDetail.PhoneCode, Weeks = weekList }; return(result); }
public async Task InsertAsync(MerchantInformation information) { const string sql = @"INSERT INTO [dbo].[MerchantInformations]([Id],[MerchantName],[Week],[Tags],[Introduce],[CountryId],[StateId],[CityId],[PhoneCode],[Address],[Lng],[Lat],[Status],[VerifyStatus],[MerchantAccountId],[Phone],[Remark],[VerifyDate],[IsPublic],[FileId],[ThumbnailId],[AccountType],[Markup],[FeeRate],[IsAllowExpense],[StartTime],[EndTime],[WeekTxt],[ApplicantName],[CreateTime],[LastModifyBy],[LastModifyTime],[FromType],[UseFiiiDeduct]) VALUES (@Id,@MerchantName,@Week,@Tags,@Introduce,@CountryId,@StateId,@CityId,@PhoneCode,@Address,@Lng,@Lat,@Status,@VerifyStatus,@MerchantAccountId,@Phone,@Remark,@VerifyDate,@IsPublic,@FileId,@ThumbnailId,@AccountType,@Markup,@FeeRate,@IsAllowExpense,@StartTime,@EndTime,@WeekTxt,@ApplicantName,@CreateTime,@LastModifyBy,@LastModifyTime,@FromType,@UseFiiiDeduct)"; using (var con = await WriteConnectionAsync()) { await con.ExecuteAsync(sql, information); } }
private PrePayOM GetMerchantPrePayOM(Guid userAccountId, MerchantInformation merchantInfo) { var merchantAccount = new MerchantAccountDAC().GetById(merchantInfo.MerchantAccountId); var userWallets = new UserWalletDAC().GetUserWallets(userAccountId); var merchantWallets = new MerchantWalletDAC().GetByAccountId(merchantAccount.Id); var coins = new CryptocurrencyDAC().GetAllActived(); var priceList = new PriceInfoDAC().GetPrice(merchantAccount.FiatCurrency); bool showWhiteLable = false; if (merchantAccount.POSId.HasValue) { var pos = new POSDAC().GetById(merchantAccount.POSId.Value); if (pos.IsWhiteLabel) { showWhiteLable = true; } } if (!showWhiteLable) { var whilteLabelCryptoCode = new POSDAC().GetWhiteLabelCryptoCode(); coins.RemoveAll(t => t.Code == whilteLabelCryptoCode); } return(new PrePayOM { FiatCurrency = merchantAccount.FiatCurrency, MarkupRate = merchantAccount.Markup.ToString(CultureInfo.InvariantCulture), WaletList = coins.Select(a => { var userWallet = userWallets.FirstOrDefault(b => b.CryptoId == a.Id); decimal rate = 0; rate = priceList.Where(t => t.CryptoID == a.Id).Select(t => t.Price).FirstOrDefault(); return GetItem(userWallet, a, merchantWallets, rate); }).OrderByDescending(a => a.MerchantSupported).ThenBy(a => a.PayRank).Select(a => new WalletItem { Code = a.Code, NewStatus = a.NewStatus, ExchangeRate = a.ExchangeRate, FrozenBalance = a.FrozenBalance, IconUrl = a.IconUrl, Id = a.Id, MerchantSupported = a.MerchantSupported, Name = a.Name, UseableBalance = a.UseableBalance, FiatBalance = a.FiatBalance, DecimalPlace = a.DecimalPlace, CryptoEnable = a.CryptoEnable }).ToList() }); }
//public VPAEnquiryController(IVPAEnquiryRequetRepository requestRepository, IVPAEnquiryRequestPostgreRepo requestPostgreRepo // , IDistributedCache distributedCache, IOptions<AppSettings> settings) //{ // _requestRepository = requestRepository; // _requestPostgreRepo = requestPostgreRepo; // _distributedCache = distributedCache; // _settings = settings; //} public VPAEnquiryController(IDistributedCache distributedCache, IOptions <AppSettings> settings, VPAEnquiryResponse response, VPATranslateResponse vpaTranslateResponse , VPAInformation vInfo, PersonalInformation pInfo, AccountInformation aInfo, MerchantInformation mInfo, List <AssociatedVpas> aVpas, VPAEnquiryRequest req) { _distributedCache = distributedCache; _settings = settings; _req = req; _response = response; _vpaTranslateResponse = vpaTranslateResponse; _aVpas = aVpas; _vInfo = vInfo; _pInfo = pInfo; _aInfo = aInfo; _mInfo = mInfo; }
private GetMerchantDetailOM GetFiiiPayMerchantDetail(MerchantInformation merchantDetail) { var weekArray = Enum.GetValues(typeof(Week)); var weekList = new List <int>(); foreach (var item in weekArray) { if (merchantDetail.Week.HasFlag((Enum)item)) { weekList.Add((int)Math.Log((int)item, 2) + 1); } } var supportCurrencyList = new MerchantSupportCryptoDAC().GetList(merchantDetail.Id); var supportCryptoIdList = supportCurrencyList.Select(t => t.CryptoId).ToList(); var cryptoList = new CryptocurrencyDAC().GetAll(); var imageList = new MerchantOwnersFigureDAC().GetOwnersFiguresById(merchantDetail.Id); var recommendList = new MerchantRecommendDAC().GetRecommendsById(merchantDetail.Id); var result = new GetMerchantDetailOM() { AccountType = (int)AccountType.User, IsAllowExpense = merchantDetail.IsAllowExpense, AvailableCryptoCodeList = supportCurrencyList.Select(item => item.CryptoCode).ToList(), AvailableCryptoIconList = cryptoList.Where(c => supportCryptoIdList.Contains(c.Id)).Select(t => t.IconURL.ToString()).ToList(), Address = merchantDetail.Address, BussinessHour = merchantDetail.WeekTxt, ImageUrls = imageList.Select(item => item.FileId).ToList(), Location = new Location() { Longitude = merchantDetail.Lng, Latitude = merchantDetail.Lat }, Introduce = merchantDetail.Introduce, RecommendGoods = recommendList.Select(item => new Goods() { Content = item.RecommendContent, Image = new ImageWithCompressImage() { Compress = item.ThumbnailId, Origin = item.RecommendPicture } }).ToList(), Tags = merchantDetail.Tags.Split(','), Title = merchantDetail.MerchantName, Phone = merchantDetail.Phone, PhoneCode = merchantDetail.PhoneCode }; return(result); }
/// <summary> /// 修改商家信息不需要审核 /// </summary> /// <param name="id"></param> /// <param name="information"></param> public void UpdatePartialInformation(Guid id, MerchantInformation information) { const string sql = @"UPDATE MerchantInformations SET Week = @Week, Address = @Address, Lng = @Lng, Lat = @Lat, Phone = @Phone WHERE Id=@Id"; using (var conn = WriteConnection()) { conn.Execute(sql, new { information.Week, information.Address, information.Lng, information.Lat, information.Phone, information.Id }); } }
public string testLogtranslate(string vpaid) { BsonValue bs = new BsonValue(); try { // Open database (or create if not exits) using (var db = new LiteDatabase(@"MyData.db")) { // Get requests collection var translates = db.GetCollection <VPATranslateResponse>("translates"); Limit l = new Limit(); l.amount = 200; l.hasLimit = true; AssociatedVpas av = new AssociatedVpas(); av.vpaId = "merchant2@bank3"; av.limit = l; ContactInformation c = new ContactInformation(); c.email = "*****@*****.**"; c.phone = "08012345678"; List <AssociatedVpas> avs = new List <AssociatedVpas>(); avs.Add(av); IndividualInformation i = new IndividualInformation(); i.bvn = "12345678900987654123"; i.firstName = "Emeka"; i.lastName = "Olu"; i.middleName = "Musa"; MerchantInformation m = new MerchantInformation(); m.companyName = "Jumia"; m.rcNumber = "RC1234"; m.tin = ""; VPATranslateResponse v = new VPATranslateResponse(); v.accountCurrency = "NGN"; v.accountName = "Emeka Olu"; v.accountNumber = "0123456789"; v.associatedVpas = avs; v.contactInformation = c; v.error = ""; v.errorDescription = ""; v.hasAssociatedVpas = true; v.httpStatusCode = 200; v.individualInformation = i; v.merchantInformation = m; v.pspId = "bank1"; v.vpaId = vpaid; v.vpaType = "Individual"; // Insert new customer document (Id will be auto-incremented) bs = translates.Insert(v); } } catch (Exception ex) { } return(bs.ToString()); }
public async Task <VPATranslateResponse> testvpaEnquiry(VPAEnquiryRequest vrequest) { VPATranslateResponse vpaTranslateResponse = new VPATranslateResponse(); Limit l = new Limit(); l.amount = 200; l.hasLimit = true; AssociatedVpas av = new AssociatedVpas(); av.vpaId = "merchant2@bank3"; av.limit = l; ContactInformation c = new ContactInformation(); c.email = "*****@*****.**"; c.phone = "08012345678"; List <AssociatedVpas> avs = new List <AssociatedVpas>(); avs.Add(av); IndividualInformation i = new IndividualInformation(); i.bvn = "12345678900987654123"; i.firstName = vrequest.instructedInstitutionCode; i.lastName = "Olu"; i.middleName = "Musa"; MerchantInformation m = new MerchantInformation(); m.companyName = "Jumia"; m.rcNumber = "RC1234"; m.tin = ""; VPATranslateResponse v = new VPATranslateResponse(); v.accountCurrency = "NGN"; v.accountName = "Emeka Olu"; v.accountNumber = "0123456789"; v.associatedVpas = avs; v.contactInformation = c; v.error = ""; v.errorDescription = ""; v.hasAssociatedVpas = true; v.httpStatusCode = 200; v.individualInformation = i; v.merchantInformation = m; v.pspId = "bank1"; v.vpaId = vrequest.targetVPA; v.vpaType = "Individual"; string json = JsonHelper.toJson(v); try { var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json"); string result = await content.ReadAsStringAsync(); //vpaTranslateResponse = (VPATranslateResponse)JsonConvert.DeserializeObject(content); vpaTranslateResponse = JsonHelper.fromJson <VPATranslateResponse>(result); } catch (Exception ec) { testLogException(new VPAEnquiryException() { action = "Error deserializing translate response: " + json, exception = ec.ToString(), requestId = "Test", logTime = DateTime.Now }); } return(vpaTranslateResponse); }
public async Task <bool> FiiipayMerchantCreateAsync(UserAccount account, FiiiPayMerchantInfoCreateIM model) { var uaDAC = new UserAccountDAC(); if (account.L1VerifyStatus != VerifyStatus.Certified) { throw new CommonException(ReasonCode.NOT_VERIFY_LV1, Resources.EMNeedLV1Verfied); } var inviteAccount = uaDAC.GetByInvitationCode(model.InviteCode); bool needInviteRecord = true; if (!string.IsNullOrEmpty(model.InviteCode)) { if (inviteAccount == null) { throw new CommonException(ReasonCode.INVITORCODE_NOT_EXISTS, MessageResources.InvalidInvitation); } if (inviteAccount.InvitationCode == account.InvitationCode) { throw new CommonException(ReasonCode.INVALID_INVITECODE, MessageResources.InviteCodeCanotInputSelf); } var existInviteRecord = await new InviteRecordDAC().GetDetailByAccountIdAsync(account.Id, InviteType.FiiipayMerchant); if (existInviteRecord != null) { needInviteRecord = false; } } else { needInviteRecord = false; } var merchantCountry = new CountryDAC().GetById(model.CountryId); if (merchantCountry == null) { throw new CommonException(ReasonCode.RECORD_NOT_EXIST, MessageResources.InvalidParameters); } if (!merchantCountry.IsSupportStore) { throw new CommonException(ReasonCode.RECORD_NOT_EXIST, MessageResources.InvalidParameters); } Regions stateRegion; Regions cityRegion; if (model.StateId.HasValue) { stateRegion = await new RegionDAC().GetByIdAsync(model.StateId.Value); if (stateRegion == null) { throw new CommonException(ReasonCode.RECORD_NOT_EXIST, MessageResources.InvalidParameters); } if (stateRegion.CountryId != model.CountryId) { throw new CommonException(ReasonCode.RECORD_NOT_EXIST, MessageResources.InvalidParameters); } if (model.CityId.HasValue) { cityRegion = await new RegionDAC().GetByIdAsync(model.CityId.Value); if (cityRegion == null) { throw new CommonException(ReasonCode.RECORD_NOT_EXIST, MessageResources.InvalidParameters); } if (cityRegion.CountryId != model.CountryId || cityRegion.ParentId != stateRegion.Id) { throw new CommonException(ReasonCode.RECORD_NOT_EXIST, MessageResources.InvalidParameters); } } } #region entities Guid merchantInfoId = Guid.NewGuid(); DateTime dtNow = DateTime.UtcNow; MerchantInformation merchantInfo = new MerchantInformation { Id = merchantInfoId, CreateTime = dtNow, FromType = InputFromType.UserInput, MerchantName = model.MerchantName, WeekTxt = model.WeekTxt, Tags = model.TagList == null ? "" : string.Join(",", model.TagList), Introduce = model.Introduce, CountryId = merchantCountry.Id, StateId = model.StateId, CityId = model.CityId, PhoneCode = account.PhoneCode, Address = model.Address, Lng = model.Lng, Lat = model.Lat, Status = Status.Stop, VerifyStatus = VerifyStatus.UnderApproval, MerchantAccountId = account.Id, Phone = model.Phone, IsPublic = Status.Stop, FileId = model.StorefrontImg[0], ThumbnailId = model.StorefrontImg[1], AccountType = AccountType.User, Markup = 0, FeeRate = 0, IsAllowExpense = false, Week = Week.Monday, ApplicantName = model.ApplicantName, UseFiiiDeduct = model.UseFiiiDeduction }; InviteRecord inviteRecord = new InviteRecord { AccountId = account.Id, InviterCode = model.InviteCode, Type = InviteType.FiiipayMerchant, InviterAccountId = inviteAccount?.Id ?? Guid.Empty, Timestamp = dtNow }; FiiipayMerchantVerifyRecord record = new FiiipayMerchantVerifyRecord { CreateTime = dtNow, MerchantInfoId = merchantInfoId, BusinessLicenseImage = model.BusinessLicenseImage, LicenseNo = model.LicenseNo, VerifyStatus = VerifyStatus.UnderApproval }; List <MerchantCategory> categorys = model.MerchantCategorys.Select(t => new MerchantCategory { MerchantInformationId = merchantInfoId, Category = t }).ToList(); List <MerchantOwnersFigure> figuresList = new List <MerchantOwnersFigure>(); if (model.FigureImgList != null) { for (int i = 0; i < model.FigureImgList.Length; i++) { figuresList.Add(new MerchantOwnersFigure { MerchantInformationId = merchantInfoId, FileId = model.FigureImgList[i][0], Sort = i, ThumbnailId = model.FigureImgList[i][1] }); } } var coinList = await new CryptocurrencyDAC().GetAllAsync(); List <MerchantSupportCrypto> supportCryptoList = model.SupportCoins.Select(t => { var c = coinList.Find(m => m.Id == t); if (c != null) { return(new MerchantSupportCrypto { MerchantInfoId = merchantInfoId, CryptoId = t, CryptoCode = c.Code }); } return(null); }).Where(x => x != null).ToList(); #endregion var mInfoDAC = new MerchantInformationDAC(); var fmVerfiyRecordDAC = new FiiipayMerchantVerifyRecordDAC(); var mCategoryDAC = new MerchantCategoryDAC(); var mFigureDAC = new MerchantOwnersFigureDAC(); var mSupportCryptoDAC = new MerchantSupportCryptoDAC(); var inviteDAC = new InviteRecordDAC(); using (var scope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(0, 0, 1, 30))) { mInfoDAC.Insert(merchantInfo); fmVerfiyRecordDAC.Insert(record); if (needInviteRecord) { inviteDAC.Insert(inviteRecord); } if (categorys != null && categorys.Count > 0) { foreach (var item in categorys) { mCategoryDAC.Insert(item); } } if (figuresList != null && figuresList.Count > 0) { foreach (var item in figuresList) { mFigureDAC.Insert(item); } } if (supportCryptoList != null && supportCryptoList.Count > 0) { foreach (var item in supportCryptoList) { mSupportCryptoDAC.Insert(item); } } scope.Complete(); } return(true); }
public ServiceResult <int> MerchantInfomationSubmit(MerchantInfomationsModel model) { var _logger = LogManager.GetLogger(typeof(MerchantInfomationController)); _logger.Info(Json(model)); var result = new ServiceResult <int>(); if (!ModelState.IsValid) { result.Code = ReasonCode.MISSING_REQUIRED_FIELDS; foreach (string error in ModelState.Values.SelectMany(v => v.Errors.Select(b => b.ErrorMessage))) { result.Message += error + Environment.NewLine; } return(result); } var accountId = this.WorkContext.MerchantId; //商家ID var countryId = this.WorkContext.CountryId; //国家ID int tempWeek = 0; model.Week.ForEach(item => tempWeek += (int)Math.Pow(2, item - 1)); //门店管理信息 var information = new MerchantInformation { Id = Guid.NewGuid(), MerchantName = model.MerchantName, Week = (Week)tempWeek, StartTime = model.StartTime, EndTime = model.EndTime, Tags = string.Join(",", model.Tags), Introduce = model.Introduce, Address = model.Address, Lng = model.Lng, Lat = model.Lat, Phone = model.Phone, Status = Status.Enabled, VerifyStatus = VerifyStatus.UnderApproval, MerchantAccountId = accountId, IsPublic = Status.Enabled }; //商家主图 var ownersFigures = model.OwnersFigures.Select(item => new MerchantOwnersFigure() { FileId = item, MerchantInformationId = information.Id, Sort = model.OwnersFigures.IndexOf(item)//图片排序顺序 }).ToList(); //商家推荐图 var recommends = model.Recommends.Select(item => new MerchantRecommend() { Id = Guid.NewGuid(), MerchantInformationId = information.Id, RecommendContent = item.Content, RecommendPicture = item.Picture, Sort = model.Recommends.IndexOf(item),//图片排序顺序 }).ToList(); //商家类别 var categorys = model.Categorys.Select(item => new MerchantCategory() { MerchantInformationId = information.Id, Category = item, }).ToList(); new MerchantInformationComponent().InsertMerchantInformation(information, ownersFigures, recommends, categorys); result.Data = countryId; return(result); }
/// <summary> /// 更新所有门店信息 /// </summary> /// <param name="information"></param> /// <param name="ownersFigures"></param> /// <param name="merchantRecommends"></param> /// <param name="merchantCategories"></param> /// <param name="phone"></param> public void UpdateMerchantInformation(MerchantInformation information, List <MerchantOwnersFigure> ownersFigures, List <MerchantRecommend> merchantRecommends, List <MerchantCategory> merchantCategories, string phone) { if (new MerchantAccountDAC().GetById(information.MerchantAccountId) == null) { throw new CommonException(ReasonCode.FiiiPosReasonCode.ACCOUNT_NOT_EXISTS, "商家账户未注册或不存在"); } //var Categories = merchantCategories; var owners = new MerchantOwnersFigureDAC().GetOwnersFiguresById(information.Id); //查询商家主图id var recommends = new MerchantRecommendDAC().GetRecommendsById(information.Id); //查询商家推荐图id var merchantInfo = new MerchantInformationDAC().GetByMerchantAccountId(information.MerchantAccountId); //判断 商家名称,经营内容,商家介绍,门店相册是否一样 var isSame = merchantInfo.MerchantName == information.MerchantName && merchantInfo.Tags == information.Tags && merchantInfo.Introduce == information.Introduce; isSame &= owners.Select(item => item.FileId).All(item => ownersFigures.ToDictionary(_ => _.FileId).ContainsKey(item)) && owners.Count == ownersFigures.Count; isSame &= recommends.Select(item => item.RecommendPicture).All(item => merchantRecommends.ToDictionary(_ => _.RecommendPicture).ContainsKey(item)) && recommends.Count == merchantRecommends.Count && recommends.Select(item => item.RecommendContent).All(item => merchantRecommends.ToDictionary(_ => _.RecommendContent).ContainsKey(item)); if (merchantInfo.VerifyStatus == FiiiPay.Entities.Enums.VerifyStatus.Disapproval) { Task.WhenAll(Task.Run(() => { Parallel.ForEach(owners, item => { try { if (!ownersFigures.Any(_ => _.FileId == item.FileId)) { Task.WhenAll(Task.Run(() => { new MasterImageAgent().Delete(item.FileId.ToString()); }), Task.Run(() => { new MasterImageAgent().Delete(item.ThumbnailId.ToString()); })); } } catch { } }); }), Task.Run(() => { Parallel.ForEach(recommends, item => { if (!merchantRecommends.Any(_ => _.RecommendPicture == item.RecommendPicture)) { Task.WhenAll(Task.Run(() => { new MasterImageAgent().Delete(item.RecommendPicture.ToString()); }), Task.Run(() => { new MasterImageAgent().Delete(item.ThumbnailId.ToString()); })); } }); }), Task.Run(() => { Parallel.ForEach(ownersFigures, item => { if (!owners.Any(_ => _.FileId == item.FileId)) { var tumnailId = new MasterImageAgent().UploadWithCompress(item.FileId); item.ThumbnailId = tumnailId == Guid.Empty ? item.FileId : tumnailId; } else { item.ThumbnailId = owners.FirstOrDefault(_ => _.FileId == item.FileId)?.ThumbnailId ?? item.FileId; } }); }), Task.Run(() => { Parallel.ForEach(merchantRecommends, item => { if (!recommends.Any(_ => _.RecommendPicture == item.RecommendPicture)) { var tumnailId = new MasterImageAgent().UploadWithCompress(item.RecommendPicture); item.ThumbnailId = tumnailId == Guid.Empty ? item.RecommendPicture : tumnailId; } else { item.ThumbnailId = recommends.FirstOrDefault(_ => _.RecommendPicture == item.RecommendPicture)?.ThumbnailId ?? item.RecommendPicture; } }); })).Wait(); using (var scope = new TransactionScope()) { new MerchantInformationDAC().Update(information.Id, information); new MerchantCategoryDAC().Delete(information.Id); merchantCategories.ForEach(item => new MerchantCategoryDAC().Insert(item)); new MerchantOwnersFigureDAC().Delete(information.Id); ownersFigures.ForEach(item => new MerchantOwnersFigureDAC().Insert(item)); new MerchantRecommendDAC().Delete(information.Id); merchantRecommends.ForEach(item => new MerchantRecommendDAC().Insert(item)); scope.Complete(); } } else if (merchantInfo.VerifyStatus == FiiiPay.Entities.Enums.VerifyStatus.Certified) { if (isSame) { using (var scope = new TransactionScope()) { new MerchantInformationDAC().UpdatePartialInformation(information.Id, information); new MerchantCategoryDAC().Delete(information.Id); merchantCategories.ForEach(item => new MerchantCategoryDAC().Insert(item)); scope.Complete(); } } else { Task.WhenAll(Task.Run(() => { Parallel.ForEach(owners, item => { try { if (!ownersFigures.Any(_ => _.FileId == item.FileId)) { Task.WhenAll(Task.Run(() => { new MasterImageAgent().Delete(item.FileId.ToString()); }), Task.Run(() => { new MasterImageAgent().Delete(item.ThumbnailId.ToString()); })); } } catch { } }); }), Task.Run(() => { Parallel.ForEach(recommends, item => { if (!merchantRecommends.Any(_ => _.RecommendPicture == item.RecommendPicture)) { Task.WhenAll(Task.Run(() => { new MasterImageAgent().Delete(item.RecommendPicture.ToString()); }), Task.Run(() => { new MasterImageAgent().Delete(item.ThumbnailId.ToString()); })); } }); }), Task.Run(() => { Parallel.ForEach(ownersFigures, item => { if (!owners.Any(_ => _.FileId == item.FileId)) { var tumnailId = new MasterImageAgent().UploadWithCompress(item.FileId); item.ThumbnailId = tumnailId == Guid.Empty ? item.FileId : tumnailId; } else { item.ThumbnailId = owners.FirstOrDefault(_ => _.FileId == item.FileId)?.ThumbnailId ?? item.FileId; } }); }), Task.Run(() => { Parallel.ForEach(merchantRecommends, item => { if (!recommends.Any(_ => _.RecommendPicture == item.RecommendPicture)) { var tumnailId = new MasterImageAgent().UploadWithCompress(item.RecommendPicture); item.ThumbnailId = tumnailId == Guid.Empty ? item.RecommendPicture : tumnailId; } else { item.ThumbnailId = recommends.FirstOrDefault(_ => _.RecommendPicture == item.RecommendPicture)?.ThumbnailId ?? item.RecommendPicture; } }); })).Wait(); using (var scope = new TransactionScope()) { new MerchantInformationDAC().Update(information.Id, information); new MerchantCategoryDAC().Delete(information.Id); merchantCategories.ForEach(item => new MerchantCategoryDAC().Insert(item)); new MerchantOwnersFigureDAC().Delete(information.Id); ownersFigures.ForEach(item => new MerchantOwnersFigureDAC().Insert(item)); new MerchantRecommendDAC().Delete(information.Id); merchantRecommends.ForEach(item => new MerchantRecommendDAC().Insert(item)); scope.Complete(); } } } }
public async Task <VPAEnquiryResponse> AddressEnquiry([FromBody] VPAEnquiryRequest request) { //VPAEnquiryResponse response = new VPAEnquiryResponse(); //VPATranslateResponse vpaTranslateResponse = new VPATranslateResponse(); //VPAInformation vInfo = new VPAInformation(); //PersonalInformation pInfo = new PersonalInformation(); //AccountInformation aInfo = new AccountInformation(); //MerchantInformation mInfo = new MerchantInformation(); //List<AssociatedVpas> aVpas = new List<AssociatedVpas>(); //log request on mongo try { //VPAEnquiryRequest req = new VPAEnquiryRequest() //{ // channelCode = request.channelCode, // instructedInstitutionCode = request.instructedInstitutionCode, // instructingInstitutionCode = request.instructingInstitutionCode, // requestId = request.requestId, // targetVPA = request.targetVPA, // updatedOn = DateTime.Now //}; _req.channelCode = request.channelCode; _req.instructedInstitutionCode = request.instructedInstitutionCode; _req.instructingInstitutionCode = request.instructingInstitutionCode; _req.requestId = request.requestId; _req.targetVPA = request.targetVPA; _req.updatedOn = DateTime.Now; VPAEnquiryRequestValidator validator = new VPAEnquiryRequestValidator(); ValidationResult results = validator.Validate(_req); bool validationSucceeded = results.IsValid; IList <ValidationFailure> failures = results.Errors; if (!validationSucceeded) { string desc = string.Empty; foreach (var f in failures) { desc = desc + f.ErrorMessage; } _response.httpStatusCode = (int)HttpStatusCode.BadRequest; _response.error = "Bad Request"; _response.errorDescription = desc; return(_response); } //if (!_settings.Value.isTest) if (_settings.Value.isTest) { string bs = testLogRequest(_req); } else { await _requestRepository.AddVPAEnquiryRequest(_req); } } catch (Exception ex) { await logException(new VPAEnquiryException() { action = "Error Logging Incoming Request: " + request.targetVPA, exception = ex.ToString(), requestId = request.requestId, logTime = DateTime.Now }); } //check cache for details try { _response = await vpaEnquiry(request.targetVPA); if (_response != null && _response.httpStatusCode != 0) { return(_response); } } catch (Exception ex) { await logException(new VPAEnquiryException() { action = "Error Fetching Request From Cache: " + request.targetVPA, exception = ex.ToString(), requestId = request.requestId, logTime = DateTime.Now }); } //assume OK _response.httpStatusCode = (int)HttpStatusCode.OK; ///vpa translate call try { if (_settings.Value.isTest) { //testLogtranslate(request.targetVPA); _vpaTranslateResponse = await testvpaEnquiry(request); } else { _vpaTranslateResponse = await vpaEnquiry(request); } bool OK = _vpaTranslateResponse.httpStatusCode == (int)HttpStatusCode.OK || _vpaTranslateResponse.httpStatusCode == (int)HttpStatusCode.Created || _vpaTranslateResponse.httpStatusCode == (int)HttpStatusCode.Accepted; if (_vpaTranslateResponse == null || !OK) { _response.httpStatusCode = _vpaTranslateResponse.httpStatusCode; _response.error = _vpaTranslateResponse.error; _response.errorDescription = _vpaTranslateResponse.errorDescription; return(_response); } _aVpas = new List <AssociatedVpas>(); foreach (var avpa in _vpaTranslateResponse.associatedVpas) { AssociatedVpas aVpa = new AssociatedVpas() { limit = avpa.limit, vpaId = avpa.vpaId }; _aVpas.Add(aVpa); } _vInfo = new VPAInformation() { associatedVpas = _aVpas, hasAssociatedVPA = _vpaTranslateResponse.hasAssociatedVpas, virtualPaymentAddress = _vpaTranslateResponse.vpaId }; _response.vpaInformation = _vInfo; _pInfo = new PersonalInformation() { email = _vpaTranslateResponse.contactInformation.email, mobilePhoneNumber = _vpaTranslateResponse.contactInformation.phone }; _response.personalInformation = _pInfo; _mInfo = new MerchantInformation() { companyName = _vpaTranslateResponse.merchantInformation.companyName, rcNumber = _vpaTranslateResponse.merchantInformation.rcNumber, tin = _vpaTranslateResponse.merchantInformation.tin }; _response.merchantInformation = _mInfo; } catch (Exception ex) { await logException(new VPAEnquiryException() { action = "Error Translating VPA: " + request.targetVPA, exception = ex.ToString(), requestId = request.requestId, logTime = DateTime.Now }); } //account enquiry call try { if (_vpaTranslateResponse != null && !string.IsNullOrEmpty(_vpaTranslateResponse.accountNumber)) { AccountEnquiryRequest arequest = new AccountEnquiryRequest() { channelCode = request.channelCode, instructedInstitutionCode = request.instructedInstitutionCode, instructingInstitutionCode = request.instructingInstitutionCode, requestId = request.requestId, targetAccountNumber = _vpaTranslateResponse.accountNumber }; if (_settings.Value.isTest) { _aInfo = await testAccountEnquiry(arequest); } else { _aInfo = await accountEnquiry(arequest); } bool OK = _aInfo.http_status_code == (int)HttpStatusCode.OK || _aInfo.http_status_code == (int)HttpStatusCode.Created || _aInfo.http_status_code == (int)HttpStatusCode.Accepted; if (_aInfo == null || !OK) { _response.httpStatusCode = _aInfo.http_status_code; _response.error = _aInfo.error; _response.errorDescription = _aInfo.error_description; return(_response); } _pInfo = new PersonalInformation() { email = _aInfo.personalinformation.email, mobilePhoneNumber = _aInfo.personalinformation.mobilePhoneNumber }; //AccountInformation ai = new AccountInformation() //{ // accountCategory = aInfo.accountCategory, // accountCurrency = aInfo.accountCurrency, // accountEntityName = aInfo.accountEntityName, // accountFirstName = aInfo.accountFirstName, // accountLastName = aInfo.accountLastName, // accountMiddleName = aInfo.accountMiddleName, // accountNumber = aInfo.accountNumber, // accountStatus = aInfo.accountStatus, // accountType = aInfo.accountType, // authorizationCredentialsAllowed = aInfo.authorizationCredentialsAllowed, // authorizationCredentialsLength = aInfo.authorizationCredentialsLength, // authorizationCredentialsType = aInfo.authorizationCredentialsType, // personalinformation = pInfo, // verificationNumber = aInfo.verificationNumber, // verificationNumberType = aInfo.verificationNumberType //}; _response.personalInformation = _pInfo; _response.accountInformation = _aInfo; } } catch (Exception ex) { await logException(new VPAEnquiryException() { action = "Error on Account Enquiry: " + request.targetVPA, exception = ex.ToString(), requestId = request.requestId, logTime = DateTime.Now }); } //add to cache try { string cacheKey = _vpaTranslateResponse.vpaId; string cacheValue = JsonHelper.toJson(_response); await _distributedCache.SetStringAsync(cacheKey, cacheValue); } catch (Exception ex) { await logException(new VPAEnquiryException() { action = "Error Writing Response to Cache: " + request.targetVPA, exception = ex.ToString(), requestId = request.requestId, logTime = DateTime.Now }); } return(_response); }
public void MerchantInfomationsSubmit(MerchantInformation information, MerchantOwnersFigure ownersfigure, MerchantRecommend recommend, MerchantCategory category) { }