Ejemplo n.º 1
0
        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);
        }