Ejemplo n.º 1
0
        /// <summary>
        /// 获取门店信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public JsonResult <Result <dynamic> > GetStoreInfo(long id, string fromLatLng = "")
        {
            CheckOpenStore();
            var shopBranch = ShopBranchApplication.GetShopBranchById(id);

            if (shopBranch == null)
            {
                throw new HimallApiException(ApiErrorCode.Parameter_Error, "id");
            }
            var shop = ShopApplication.GetShop(shopBranch.ShopId);

            if (null != shop && shop.ShopStatus == Entities.ShopInfo.ShopAuditStatus.HasExpired)
            {
                return(Json(ErrorResult <dynamic>("此店铺已过期")));
            }
            if (null != shop && shop.ShopStatus == Entities.ShopInfo.ShopAuditStatus.Freeze)
            {
                return(Json(ErrorResult <dynamic>("此店铺已冻结")));
            }
            if (!string.IsNullOrWhiteSpace(fromLatLng))
            {
                shopBranch.Distance = ShopBranchApplication.GetLatLngDistances(fromLatLng, string.Format("{0},{1}", shopBranch.Latitude, shopBranch.Longitude));
            }
            shopBranch.AddressDetail = ShopBranchApplication.RenderAddress(shopBranch.AddressPath, shopBranch.AddressDetail, 2);
            shopBranch.ShopImages    = HimallIO.GetRomoteImagePath(shopBranch.ShopImages);
            Mapper.CreateMap <ShopBranch, HomeGetShopBranchInfoModel>();
            var store          = Mapper.Map <ShopBranch, HomeGetShopBranchInfoModel>(shopBranch);
            var homepageBranch = ProcessBranchHomePageData(new List <ShopBranch>()
            {
                shopBranch
            }, true).FirstOrDefault();

            //过滤不能领取的优惠券
            homepageBranch.ShopAllActives.ShopCoupons = homepageBranch.ShopAllActives.ShopCoupons.ToList();
            //统计门店访问人数
            StatisticApplication.StatisticShopBranchVisitUserCount(shopBranch.ShopId, shopBranch.Id);
            return(JsonResult <dynamic>(new
            {
                Store = store,
                homepageBranch.ShopAllActives,
                CommentScore = ShopBranchApplication.GetServiceMark(store.Id).ComprehensiveMark,   //评分
            }));
        }