Ejemplo n.º 1
0
        /// <summary>
        /// 查询所有门店信息
        /// </summary>
        /// <param name="account"></param>
        public MerchantInformationES SelectMerchantInformation(Guid accountId, int countryId)
        {
            var account = new MerchantAccountDAC().GetById(accountId);

            if (account == null)
            {
                throw new CommonException(ReasonCode.FiiiPosReasonCode.ACCOUNT_NOT_EXISTS, "商家账户未注册或不存在");
            }
            var information = new MerchantInformationDAC().GetByMerchantAccountId(account.Id);
            var country     = new CountryDAC().GetById(countryId);

            if (information == null)
            {
                throw new CommonException(ReasonCode.MERCHANT_NONE, "商家没有门店");
                //return new MerchantInformationES()
                //{
                //    Countrys = new Countrys()
                //    {
                //        Name_CN = country.Name_CN,
                //        Name = country.Name
                //    }
                //};
            }

            var figures   = new MerchantOwnersFigureDAC().GetOwnersFiguresById(information.Id);
            var category  = new MerchantCategoryDAC().GetByMerchantInformationId(information.Id);
            var recommend = new MerchantRecommendDAC().GetRecommendsById(information.Id);

            return(new MerchantInformationES()
            {
                MerchantName = information.MerchantName,
                Categorys = category.Select(item => item.Category).ToList(),
                Week = information.Week,
                StartTime = information.StartTime,
                EndTime = information.EndTime,
                Tags = information.Tags,
                Phone = information.Phone,
                Introduce = information.Introduce,
                Address = information.Address,
                Lng = information.Lng,
                Lat = information.Lat,
                VerifyStatus = information.VerifyStatus,
                OwnersFigures = figures.Select(item => item.FileId).ToList(),
                Recommends = recommend.Select(item => new Recommend()
                {
                    Content = item.RecommendContent, Picture = item.RecommendPicture
                }).ToList(),
                Countrys = new Countrys()
                {
                    Name_CN = country.Name_CN,
                    Name = country.Name
                },
                IsPublic = information.IsPublic
            });
        }