Example #1
0
        public JsonResult ApplyList(int page, int rows, string keyWords)
        {
            var data   = _iBrandService.GetShopBrandApplys(null, 0, page, rows, keyWords.Trim());
            var brands = data.Models;
            var shops  = ShopApplication.GetShops(brands.Select(p => p.ShopId).ToList());
            var list   = brands.Select(item => new BrandApplyModel()
            {
                Id           = item.Id,
                BrandId      = item.BrandId,
                ShopId       = item.ShopId,
                BrandName    = item.BrandName,
                BrandLogo    = item.Logo,
                BrandDesc    = item.Description == null ? "" : item.Description,
                BrandAuthPic = item.AuthCertificate,
                Remark       = item.Remark,
                BrandMode    = item.ApplyMode,
                AuditStatus  = item.AuditStatus,
                ApplyTime    = item.ApplyTime.ToString("yyyy-MM-dd"),
                ShopName     = shops.FirstOrDefault(p => p.Id == item.ShopId)?.ShopName ?? string.Empty
            });
            var result = new DataGridModel <BrandApplyModel>()
            {
                rows = list, total = data.Total
            };

            return(Json(result));
        }
Example #2
0
        public object GetMobileHomeProducts(long shopId, PlatformType platformType, int page, int rows, string keyWords, string shopName, long?categoryId = null)
        {
            var homeProducts = MobileHomeProductApplication.GetMobileHomePageProducts(shopId, platformType, page, rows, keyWords, shopName, categoryId);
            var products     = ProductManagerApplication.GetProducts(homeProducts.Models.Select(p => p.ProductId));
            var shops        = ShopApplication.GetShops(products.Select(p => p.ShopId));
            var brands       = BrandApplication.GetBrandsByIds(products.Select(p => p.BrandId));

            var model = homeProducts.Models.Select(item =>
            {
                var product = products.FirstOrDefault(p => p.Id == item.ProductId);
                var shop    = shops.FirstOrDefault(p => p.Id == product.ShopId);
                var brand   = brands.FirstOrDefault(p => p.Id == product.BrandId);
                return(new
                {
                    name = product.ProductName,
                    image = product.GetImage(ImageSize.Size_50),
                    price = product.MinSalePrice.ToString("F2"),
                    brand = brand?.Name ?? string.Empty,
                    sequence = item.Sequence,
                    categoryName = CategoryApplication.GetCategory(product.CategoryId).Name,
                    id = item.Id,
                    productId = item.ProductId,
                    shopName = shop?.ShopName ?? string.Empty
                });
            });

            return(new { rows = model, total = homeProducts.Total });
        }
Example #3
0
        public JsonResult List(OrderQuery query, int page, int rows)
        {
            query.PageNo              = page;
            query.PageSize            = rows;
            query.Operator            = Operator.Admin;
            query.PaymentTypeGateways = PaymentApplication.GetPaymentIdByDesc(query.PaymentTypeGateway);
            var fullOrders = OrderApplication.GetFullOrders(query);
            var models     = fullOrders.Models.ToList();

            var shops       = ShopApplication.GetShops(fullOrders.Models.Select(p => p.ShopId).ToList());
            var shopBranchs = ShopBranchApplication.GetShopBranchs(models.Where(p => p.DeliveryType == CommonModel.DeliveryType.SelfTake && p.ShopBranchId != 0).Select(p => p.ShopBranchId).ToList());

            IEnumerable <OrderModel> orderModels = models.Select(item =>
            {
                var shop = shops.FirstOrDefault(sp => sp.Id == item.ShopId);

                return(new OrderModel()
                {
                    OrderId = item.Id,
                    OrderStatus = item.OrderStatus.ToDescription(),
                    OrderState = (int)item.OrderStatus,
                    OrderDate = item.OrderDate.ToString("yyyy-MM-dd HH:mm:ss"),
                    ShopId = item.ShopId,
                    ShopName = item.ShopBranchId > 0 ? item.ShopBranchName : item.ShopName,
                    ShopBranchName = item.DeliveryType == CommonModel.DeliveryType.SelfTake && item.ShopBranchId > 0 && shopBranchs.FirstOrDefault(sb => sb.Id == item.ShopBranchId) != null ? shopBranchs.FirstOrDefault(sb => sb.Id == item.ShopBranchId).ShopBranchName : "",
                    UserId = item.UserId,
                    UserName = item.UserName,
                    TotalPrice = item.OrderTotalAmount,
                    PaymentTypeName = item.PaymentTypeName,
                    PlatForm = (int)item.Platform,
                    IconSrc = GetIconSrc(item.Platform),
                    PlatformText = item.Platform.ToDescription(),
                    PaymentTypeGateway = item.PaymentTypeGateway,
                    PayDate = item.PayDate,
                    PaymentTypeStr = item.PaymentTypeDesc,
                    PaymentType = item.PaymentType,
                    OrderType = item.OrderType,
                    GatewayOrderId = item.GatewayOrderId,
                    Payee = shop.ContactsName,
                    CellPhone = item.CellPhone,
                    RegionFullName = item.RegionFullName,
                    Address = item.Address,
                    SellerRemark = item.SellerRemark,
                    UserRemark = item.UserRemark,
                    OrderItems = item.OrderItems,
                    SellerRemarkFlag = item.SellerRemarkFlag,
                    IsVirtual = item.OrderType == OrderInfo.OrderTypes.Virtual
                });
            });

            DataGridModel <OrderModel> dataGrid = new DataGridModel <OrderModel>()
            {
                rows  = orderModels,
                total = fullOrders.Total
            };

            return(Json(dataGrid));
        }
Example #4
0
        public JsonResult List(long?shopGradeId, int?shopStatus, int page, int rows, string shopName, string shopAccount, string type = "")
        {
            var queryModel = new ShopQuery()
            {
                Status      = (Himall.Model.ShopInfo.ShopAuditStatus?)shopStatus,
                PageSize    = rows,
                PageNo      = page,
                ShopAccount = shopAccount,
                ShopName    = shopName,
                ShopGradeId = shopGradeId
            };

            if (type == "Auditing")
            {
                if (shopStatus == null)
                {
                    queryModel.Status = Himall.Model.ShopInfo.ShopAuditStatus.WaitAudit;
                    queryModel.MoreStatus.Add(Himall.Model.ShopInfo.ShopAuditStatus.WaitConfirm);
                }
            }

            var shops        = ShopApplication.GetShops(queryModel);
            var shopGrades   = ShopApplication.GetShopGrades();
            var shopAccounts = ShopApplication.GetShopAccounts(shops.Models.Select(p => p.Id));

            var models = shops.Models.Select(item =>
            {
                var shopGrade        = shopGrades.FirstOrDefault(p => p.Id == item.GradeId);
                var shopAccountModel = shopAccounts.FirstOrDefault(p => p.ShopId == item.Id);

                return(new ShopModel()
                {
                    Id = item.Id,
                    Account = item.ShopAccount,
                    EndDate = type == "Auditing" ? "--" : item.EndDate.HasValue ? item.EndDate.Value.ToString("yyyy-MM-dd") : "",
                    Name = item.ShopName,
                    ShopGrade = shopGrade != null ? shopGrade.Name : "",
                    Status = item.EndDate < DateTime.Now ? "已过期" : item.ShowShopAuditStatus.ToDescription(),
                    IsSelf = item.IsSelf,
                    BusinessType = item.BusinessType == null ? Himall.CommonModel.ShopBusinessType.Enterprise : item.BusinessType.Value,
                    Balance = shopAccountModel != null ? shopAccountModel.Balance : 0
                });
            });

            var dataGrid = new DataGridModel <ShopModel>()
            {
                rows = models, total = shops.Total
            };

            return(Json(dataGrid));
        }
Example #5
0
        public ActionResult PaymentToOrders(string ids)
        {
            //红包数据
            var    bonusGrantIds = new Dictionary <long, Entities.ShopBonusInfo>();
            string url           = CurrentUrlHelper.CurrentUrlNoPort() + "/m-weixin/shopbonus/index/";

            if (!string.IsNullOrEmpty(ids))
            {
                string[]    strIds  = ids.Split(',');
                List <long> longIds = new List <long>();
                foreach (string id in strIds)
                {
                    longIds.Add(long.Parse(id));
                }
                var result = PaymentHelper.GenerateBonus(longIds, Request.Url.Host.ToString());
                foreach (var item in result)
                {
                    bonusGrantIds.Add(item.Key, item.Value);
                }
            }

            ViewBag.Path          = url;
            ViewBag.BonusGrantIds = bonusGrantIds;
            ViewBag.Shops         = ShopApplication.GetShops(bonusGrantIds.Select(p => p.Value.ShopId));
            ViewBag.BaseAddress   = CurrentUrlHelper.CurrentUrlNoPort();

            var statistic = StatisticApplication.GetMemberOrderStatistic(CurrentUser.Id);

            ViewBag.WaitingForComments = statistic.WaitingForComments;
            ViewBag.AllOrders          = statistic.OrderCount;
            ViewBag.WaitingForRecieve  = statistic.WaitingForRecieve + OrderApplication.GetWaitConsumptionOrderNumByUserId(CurrentUser.Id);
            ViewBag.WaitingForPay      = statistic.WaitingForPay;
            ViewBag.WaitingForDelivery = statistic.WaitingForDelivery;

            var order = OrderApplication.GetUserOrders(CurrentUser.Id, 1).FirstOrDefault();

            if (order != null && order.OrderType == OrderInfo.OrderTypes.FightGroup)
            {
                var gpord = FightGroupApplication.GetOrder(order.Id);
                if (gpord != null)
                {
                    return(Redirect(string.Format("/m-{0}/FightGroup/GroupOrderOk?orderid={1}", PlatformType.ToString(), order.Id)));
                }
            }
            return(View("~/Areas/Mobile/Templates/Default/Views/Member/Orders.cshtml"));
        }
        public JsonResult GetlimitTimeProducts(LimitTimeQuery query)
        {
            query.ShopId = this.CurrentShop.Id;//只取当前商家的限时购商品
            // var result =  EngineContext.Current.Resolve<ILimitTimeBuyService>().GetFlashSaleInfos(query);

            var result = EngineContext.Current.Resolve <ILimitTimeBuyService>().GetFlashSaleInfos(query);

            var products = ProductManagerApplication.GetProducts(result.Models.Select(p => p.ProductId));
            var shops    = ShopApplication.GetShops(result.Models.Select(p => p.ShopId));
            var market   = result.Models.Select(item =>
            {
                var product = products.FirstOrDefault(p => p.Id == item.ProductId);
                var shop    = shops.FirstOrDefault(p => p.Id == item.ShopId);
                var m       = new FlashSaleModel
                {
                    Id          = item.Id,
                    Title       = item.Title,
                    BeginDate   = item.BeginDate.ToString("yyyy-MM-dd"),
                    EndDate     = item.EndDate.ToString("yyyy-MM-dd"),
                    ShopName    = shop.ShopName,
                    ProductName = product.ProductName,
                    ProductId   = item.ProductId,
                    StatusStr   = item.Status.ToDescription()
                };
                if (item.Status != FlashSaleInfo.FlashSaleStatus.WaitForAuditing && item.Status != FlashSaleInfo.FlashSaleStatus.AuditFailed && item.BeginDate > DateTime.Now && item.EndDate < DateTime.Now)
                {
                    m.StatusStr = "进行中";
                }
                else if (item.Status != FlashSaleInfo.FlashSaleStatus.WaitForAuditing && item.Status != FlashSaleInfo.FlashSaleStatus.AuditFailed && item.BeginDate > DateTime.Now)
                {
                    m.StatusStr = "未开始";
                }
                m.SaleCount   = item.SaleCount;
                m.MinPrice    = item.MinPrice;
                m.MarketPrice = product.MarketPrice;
                m.ProductImg  = MallIO.GetProductSizeImage(product.ImagePath, 1, (int)ImageSize.Size_350);
                return(m);
            });
            var dataGrid = new DataGridModel <FlashSaleModel>()
            {
                rows = market, total = result.Total
            };

            return(Json(dataGrid));
        }
Example #7
0
        public JsonResult List(ShopQuery query, string type = "")
        {
            if (type == "Auditing")
            {
                query.Status = ShopInfo.ShopAuditStatus.WaitAudit;
                query.MoreStatus.Add(ShopInfo.ShopAuditStatus.WaitConfirm);
            }
            var shops        = ShopApplication.GetShops(query);
            var shopGrades   = ShopApplication.GetShopGrades();
            var shopAccounts = ShopApplication.GetShopAccounts(shops.Models.Select(p => p.Id).ToList());
            var models       = shops.Models.Select(item =>
            {
                var shopGrade        = shopGrades.FirstOrDefault(p => p.Id == item.GradeId);
                var shopAccountModel = shopAccounts.FirstOrDefault(p => p.ShopId == item.Id);
                var shopbranchs      = ShopBranchApplication.GetShopBranchByShopId(item.Id);
                return(new ShopModel()
                {
                    Id = item.Id,
                    Account = item.ShopAccount,
                    EndDate = type == "Auditing" ? "--" : item.EndDate.HasValue ? item.EndDate.Value.ToString("yyyy-MM-dd") : "",
                    Name = item.ShopName,
                    ShopGrade = shopGrade != null ? shopGrade.Name : "",
                    Status = (item.EndDate < DateTime.Now && item.ShowShopAuditStatus == ShopInfo.ShopAuditStatus.Open) ? "已过期" : item.ShowShopAuditStatus.ToDescription(),
                    IsSelf = item.IsSelf,
                    BusinessType = item.BusinessType == null ? CommonModel.ShopBusinessType.Enterprise : item.BusinessType.Value,
                    Balance = shopAccountModel != null ? shopAccountModel.Balance : 0,
                    ShopBranchCount = shopbranchs.Count()
                });
            });

            var dataGrid = new DataGridModel <ShopModel>()
            {
                rows = models, total = shops.Total
            };

            return(Json(dataGrid));
        }
Example #8
0
        //APP首页配置共用于安卓和IOS,这里的平台类型写的为IOS,安卓调用首页接口数据时平台类型也选IOS
        public APPHome Get(int pageNo, int pageSize)
        {
            var slideImageSettings = ServiceProvider.Instance <ISlideAdsService> .Create.GetSlidAds(0, Entities.SlideAdInfo.SlideAdType.IOSShopHome);

            var images = ServiceProvider.Instance <ISlideAdsService> .Create.GetImageAds(0, Himall.CommonModel.ImageAdsType.APPSpecial).ToList();

            var     mhproser      = ServiceProvider.Instance <IMobileHomeProductsService> .Create;
            var     data          = mhproser.GetMobileHomeProducts(0, PlatformType.IOS, pageNo, pageSize);
            var     totalProducts = data.Total;
            var     homeProducts  = data.Models;
            decimal discount      = 1M;

            if (CurrentUser != null)
            {
                discount = CurrentUser.MemberDiscount;
            }
            var products = new List <HomeProduct>();

            var limitService = ServiceProvider.Instance <ILimitTimeBuyService> .Create;
            var fight        = FightGroupApplication.GetFightGroupPrice();
            var allProducts  = ProductManagerApplication.GetProducts(homeProducts.Select(p => p.ProductId));
            var allShops     = ShopApplication.GetShops(allProducts.Select(p => p.ShopId));

            foreach (var item in homeProducts)
            {
                var     limitBuy     = limitService.GetLimitTimeMarketItemByProductId(item.ProductId);
                var     product      = allProducts.FirstOrDefault(p => p.Id == item.ProductId);
                var     shop         = allShops.FirstOrDefault(p => p.Id == product.ShopId);
                decimal minSalePrice = shop.IsSelf ? product.MinSalePrice * discount : product.MinSalePrice;
                if (limitBuy != null)
                {
                    minSalePrice = limitBuy.MinPrice; //限时购不打折
                }
                var  isFight  = fight.Where(r => r.ProductId == item.ProductId).FirstOrDefault();
                long activeId = 0;
                if (isFight != null)
                {
                    minSalePrice = isFight.ActivePrice;
                    activeId     = isFight.ActiveId;
                }
                products.Add(new HomeProduct()
                {
                    Id           = item.ProductId.ToString(),
                    ImageUrl     = HimallIO.GetRomoteProductSizeImage(product.RelativePath, 1, (int)CommonModel.ImageSize.Size_220),
                    Name         = product.ProductName,
                    MarketPrice  = product.MarketPrice.ToString(),
                    SalePrice    = minSalePrice.ToString("f2"),
                    Discount     = product.MarketPrice <= 0 ? "0" : (minSalePrice / product.MarketPrice).ToString("0.0"),
                    Url          = Core.HimallIO.GetRomoteImagePath("/m-ios/product/detail/" + item.ProductId),
                    FightGroupId = activeId
                });
            }

            var iconSettings = ServiceProvider.Instance <ISlideAdsService> .Create.GetSlidAds(0, Entities.SlideAdInfo.SlideAdType.APPIcon);

            var icon = iconSettings.ToArray().Select(item => new HomeSlides {
                Desc = item.Description, ImageUrl = Core.HimallIO.GetRomoteImagePath(item.ImageUrl), Url = item.Url
            });

            var services = CustomerServiceApplication.GetPlatformCustomerService(true, true);
            //var meiqia = CustomerServiceApplication.GetPlatformCustomerService(true, false).FirstOrDefault(p => p.Tool == Entities.CustomerServiceInfo.ServiceTool.MeiQia);
            //if (meiqia != null)
            //    services.Insert(0, meiqia);

            APPHome appHome = new APPHome();

            appHome.success = true;
            //2017年9月1号 商城首页接口修改(把原广告图片的去掉,只保留商品)
            appHome.TotalProduct = totalProducts;
            appHome.Icon         = icon;
            //appHome.Slide = slides;//轮播图数组
            //appHome.Topic = homeImage;//专题数组
            appHome.Product          = products;
            appHome.CustomerServices = services;
            return(appHome);
        }
        /// <summary>
        /// 页面缓存时间
        /// </summary>


        // GET: Web/ProductPartial
        //[OutputCache(Duration = ConstValues.PAGE_CACHE_DURATION)]
        public ActionResult Header()
        {
            ViewBag.Now = DateTime.Now;
            bool isLogin = CurrentUser != null;
            var  model   = new ProductPartialHeaderModel();

            model.PlatformCustomerServices = CustomerServiceApplication.GetPlatformCustomerService(true, false);
            model.isLogin = isLogin ? "true" : "false";
            //用户积分
            model.MemberIntegral = isLogin ? MemberIntegralApplication.GetAvailableIntegral(CurrentUser.Id) : 0;

            //关注商品
            var user        = CurrentUser?.Id ?? 0;
            var baseCoupons = new List <DisplayCoupon>();
            //优惠卷
            var usercoupons = _iCouponService.GetAllUserCoupon(user);//优惠卷
            var coupons     = CouponApplication.GetCouponInfo(usercoupons.Select(p => p.CouponId));
            var shops       = ShopApplication.GetShops(coupons.Select(p => p.ShopId));
            var shopBonus   = ShopBonusApplication.GetShopBounsByUser(user);//红包

            baseCoupons.AddRange(usercoupons.Select(item =>
            {
                var coupon = coupons.FirstOrDefault(p => p.Id == item.CouponId);
                var shop   = shops.FirstOrDefault(p => p.Id == coupon.ShopId);
                return(new DisplayCoupon
                {
                    Type = CommonModel.CouponType.Coupon,
                    Limit = coupon.OrderAmount,
                    Price = item.Price,
                    ShopId = shop.Id,
                    ShopName = shop.ShopName,
                    EndTime = coupon.EndTime,
                });
            }));

            baseCoupons.AddRange(shopBonus.Select(p => new DisplayCoupon
            {
                Type     = CommonModel.CouponType.ShopBonus,
                EndTime  = p.Bonus.DateEnd,
                Limit    = p.Bonus.UsrStatePrice,
                Price    = p.Receive.Price,
                ShopId   = p.Shop.Id,
                ShopName = p.Shop.ShopName,
                UseState = p.Bonus.UseState
            }));
            model.BaseCoupon = baseCoupons;
            //广告
            var imageAds = _iSlideAdsService.GetImageAds(0).Where(p => p.TypeId == Himall.CommonModel.ImageAdsType.HeadRightAds).ToList();

            if (imageAds.Count > 0)
            {
                ViewBag.HeadAds = imageAds;
            }
            else
            {
                ViewBag.HeadAds = _iSlideAdsService.GetImageAds(0).Take(1).ToList();
            }
            //浏览的商品
            //var browsingPro = isLogin ? BrowseHistrory.GetBrowsingProducts(10, CurrentUser == null ? 0 : CurrentUser.Id) : new List<ProductBrowsedHistoryModel>();
            //model.BrowsingProducts = browsingPro;

            InitHeaderData();

            string html = System.IO.File.ReadAllText(this.Server.MapPath(_templateHeadHtmlFileFullName));//读取模板头部html静态文件内容

            ViewBag.Html = html;
            return(PartialView("~/Areas/Web/Views/Shared/Header.cshtml", model));
        }
        public ActionResult ShopHeader(long id)
        {
            InitHeaderData();
            #region 获取店铺的评价统计
            var shopStatisticOrderComments = ServiceApplication.Create <IShopService>().GetShopStatisticOrderComments(id);

            var productAndDescription = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescription).FirstOrDefault();
            var sellerServiceAttitude = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitude).FirstOrDefault();
            var sellerDeliverySpeed   = shopStatisticOrderComments.Where(c => c.CommentKey ==
                                                                         Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeed).FirstOrDefault();

            var productAndDescriptionPeer = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescriptionPeer).FirstOrDefault();
            var sellerServiceAttitudePeer = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitudePeer).FirstOrDefault();
            var sellerDeliverySpeedPeer   = shopStatisticOrderComments.Where(c => c.CommentKey ==
                                                                             Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeedPeer).FirstOrDefault();

            var productAndDescriptionMax = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescriptionMax).FirstOrDefault();
            var productAndDescriptionMin = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.ProductAndDescriptionMin).FirstOrDefault();

            var sellerServiceAttitudeMax = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitudeMax).FirstOrDefault();
            var sellerServiceAttitudeMin = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerServiceAttitudeMin).FirstOrDefault();

            var sellerDeliverySpeedMax = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeedMax).FirstOrDefault();
            var sellerDeliverySpeedMin = shopStatisticOrderComments.Where(c => c.CommentKey == Entities.StatisticOrderCommentInfo.EnumCommentKey.SellerDeliverySpeedMin).FirstOrDefault();

            decimal defaultValue = 5;
            //宝贝与描述
            if (productAndDescription != null && productAndDescriptionPeer != null)
            {
                ViewBag.ProductAndDescription     = productAndDescription.CommentValue;
                ViewBag.ProductAndDescriptionPeer = productAndDescriptionPeer.CommentValue;
                ViewBag.ProductAndDescriptionMin  = productAndDescriptionMin.CommentValue;
                ViewBag.ProductAndDescriptionMax  = productAndDescriptionMax.CommentValue;
            }
            else
            {
                ViewBag.ProductAndDescription     = defaultValue;
                ViewBag.ProductAndDescriptionPeer = defaultValue;
                ViewBag.ProductAndDescriptionMin  = defaultValue;
                ViewBag.ProductAndDescriptionMax  = defaultValue;
            }
            //卖家服务态度
            if (sellerServiceAttitude != null && sellerServiceAttitudePeer != null)
            {
                ViewBag.SellerServiceAttitude     = sellerServiceAttitude.CommentValue;
                ViewBag.SellerServiceAttitudePeer = sellerServiceAttitudePeer.CommentValue;
                ViewBag.SellerServiceAttitudeMax  = sellerServiceAttitudeMax.CommentValue;
                ViewBag.SellerServiceAttitudeMin  = sellerServiceAttitudeMin.CommentValue;
            }
            else
            {
                ViewBag.SellerServiceAttitude     = defaultValue;
                ViewBag.SellerServiceAttitudePeer = defaultValue;
                ViewBag.SellerServiceAttitudeMax  = defaultValue;
                ViewBag.SellerServiceAttitudeMin  = defaultValue;
            }
            //卖家发货速度
            if (sellerDeliverySpeedPeer != null && sellerDeliverySpeed != null)
            {
                ViewBag.SellerDeliverySpeed     = sellerDeliverySpeed.CommentValue;
                ViewBag.SellerDeliverySpeedPeer = sellerDeliverySpeedPeer.CommentValue;
                ViewBag.SellerDeliverySpeedMax  = sellerDeliverySpeedMax.CommentValue;
                ViewBag.sellerDeliverySpeedMin  = sellerDeliverySpeedMin.CommentValue;
            }
            else
            {
                ViewBag.SellerDeliverySpeed     = defaultValue;
                ViewBag.SellerDeliverySpeedPeer = defaultValue;
                ViewBag.SellerDeliverySpeedMax  = defaultValue;
                ViewBag.sellerDeliverySpeedMin  = defaultValue;
            }
            #endregion

            #region 微店二维码
            var    vshop    = ServiceApplication.Create <IVShopService>().GetVShopByShopId(id);
            string vshopUrl = "";
            var    curUrl   = CurrentUrlHelper.CurrentUrlNoPort();
            if (vshop != null)
            {
                vshopUrl        = curUrl + "/m-" + PlatformType.WeiXin.ToString() + "/vshop/detail/" + vshop.Id;
                ViewBag.VShopQR = CreateQR(vshop.StrLogo, vshopUrl);
            }
            else
            {
                vshopUrl        = curUrl + "/m-" + PlatformType.WeiXin.ToString();
                ViewBag.VShopQR = CreateQR(null, vshopUrl);
            }
            #endregion

            ViewBag.ShopName = ServiceApplication.Create <IShopService>().GetShop(id).ShopName;

            var  user    = CurrentUser?.Id ?? 0;
            bool isLogin = CurrentUser != null;
            var  model   = new ProductPartialHeaderModel();
            model.ShopId  = id;
            model.isLogin = isLogin ? "true" : "false";
            //用户积分
            model.MemberIntegral = isLogin ? MemberIntegralApplication.GetAvailableIntegral(CurrentUser.Id) : 0;


            var baseCoupons = new List <DisplayCoupon>();
            //优惠卷
            var usercoupons = _iCouponService.GetAllUserCoupon(user);//优惠卷
            var coupons     = CouponApplication.GetCouponInfo(usercoupons.Select(p => p.CouponId));
            var shops       = ShopApplication.GetShops(coupons.Select(p => p.ShopId));
            var shopBonus   = ShopBonusApplication.GetShopBounsByUser(user);//红包
            baseCoupons.AddRange(usercoupons.Select(item =>
            {
                var coupon = coupons.FirstOrDefault(p => p.Id == item.CouponId);
                var shop   = shops.FirstOrDefault(p => p.Id == coupon.ShopId);
                return(new DisplayCoupon
                {
                    Type = CommonModel.CouponType.Coupon,
                    Limit = coupon.OrderAmount,
                    Price = item.Price,
                    ShopId = shop.Id,
                    ShopName = shop.ShopName,
                    EndTime = coupon.EndTime,
                });
            }));

            baseCoupons.AddRange(shopBonus.Select(p => new DisplayCoupon
            {
                Type     = CommonModel.CouponType.ShopBonus,
                EndTime  = p.Bonus.DateEnd,
                Limit    = p.Bonus.UsrStatePrice,
                Price    = p.Receive.Price,
                ShopId   = p.Shop.Id,
                ShopName = p.Shop.ShopName,
                UseState = p.Bonus.UseState
            }));

            model.BaseCoupon = baseCoupons;

            //浏览的商品
            //var browsingPro = isLogin ? BrowseHistrory.GetBrowsingProducts(10, CurrentUser == null ? 0 : CurrentUser.Id) : new List<ProductBrowsedHistoryModel>();
            //model.BrowsingProducts = browsingPro;
            InitHeaderData();
            setTheme();//主题设置
            ViewBag.Keyword  = string.IsNullOrWhiteSpace(SiteSettings.SearchKeyword) ? SiteSettings.Keyword : SiteSettings.SearchKeyword;
            ViewBag.Keywords = SiteSettings.HotKeyWords;
            return(PartialView("~/Areas/Web/Views/Shared/ShopHeader.cshtml", model));
        }
Example #11
0
        public JsonResult Browse(long?categoryId, int?auditStatus, string ids, int page, string keyWords, string shopName,
                                 int?saleStatus, bool?isShopCategory, int rows = 10, bool isLimitTimeBuy = false, bool showSku = false, long[] exceptProductIds = null)
        {
            var query = new ProductQuery()
            {
                PageSize         = rows,
                PageNo           = page,
                KeyWords         = keyWords,
                ShopName         = shopName,
                CategoryId       = isShopCategory.GetValueOrDefault() ? null : categoryId,
                ShopCategoryId   = isShopCategory.GetValueOrDefault() ? categoryId : null,
                Ids              = string.IsNullOrWhiteSpace(ids) ? null : ids.Split(',').Select(item => long.Parse(item)),
                ShopId           = CurrentSellerManager.ShopId,
                IsLimitTimeBuy   = isLimitTimeBuy,
                ExceptIds        = exceptProductIds,
                IsFilterStock    = false,
                HasLadderProduct = false,
                AuditStatus      = new[] { ProductInfo.ProductAuditStatus.Audited },
                SaleStatus       = ProductInfo.ProductSaleStatus.OnSale
            };

            var data   = ProductManagerApplication.GetProducts(query);
            var shops  = ShopApplication.GetShops(data.Models.Select(p => p.ShopId));
            var brands = BrandApplication.GetBrands(data.Models.Select(p => p.BrandId));
            var skus   = ProductManagerApplication.GetSKUByProducts(data.Models.Select(p => p.Id));

            var products = data.Models.Select(item =>
            {
                var brand    = brands.FirstOrDefault(p => p.Id == item.BrandId);
                var shop     = shops.FirstOrDefault(p => p.Id == item.ShopId);
                var cate     = CategoryApplication.GetCategory(item.CategoryId);
                var sku      = skus.Where(p => p.ProductId == item.Id);
                var limitAdd = LimitTimeApplication.IsAdd(item.Id);
                return(new
                {
                    name = item.ProductName,
                    brandName = brand?.Name ?? string.Empty,
                    categoryName = brand == null ? "" : cate.Name,
                    id = item.Id,
                    imgUrl = item.GetImage(ImageSize.Size_50),
                    price = item.MinSalePrice,
                    skus = !showSku ? null : sku.Select(a => new SKUModel()
                    {
                        Id = a.Id,
                        SalePrice = a.SalePrice,
                        Size = a.Size,
                        Stock = a.Stock,
                        Version = a.Version,
                        Color = a.Color,
                        Sku = a.Sku,
                        AutoId = a.AutoId,
                        ProductId = a.ProductId
                    }),
                    shopName = shop.ShopName,
                    isOpenLadder = item.IsOpenLadder,
                    isLimit = limitAdd
                });
            });

            var dataGrid = new
            {
                rows  = products,
                total = data.Total
            };

            return(Json(dataGrid));
        }
Example #12
0
        public JsonResult List(long?categoryId, string brandName, string productCode, int?auditStatus, string ids, int page, int rows, string keyWords, string shopName, int?saleStatus, bool?isAsc, string sort = "", sbyte?productType = null)
        {
            var query = new ProductQuery()
            {
                PageSize    = rows,
                PageNo      = page,
                BrandName   = brandName,
                KeyWords    = keyWords,
                CategoryId  = categoryId,
                Ids         = string.IsNullOrWhiteSpace(ids) ? null : ids.Split(',').Select(item => long.Parse(item)),
                ShopName    = shopName,
                ProductCode = productCode,
                IsAsc       = isAsc.HasValue ? isAsc.Value : false,
                Sort        = sort
            };

            if (productType.HasValue && productType.Value > -1)
            {
                query.ProductType = productType.Value;
            }
            if (isAsc.HasValue && string.IsNullOrEmpty(query.Sort)) //如果按序号排序不为null
            {
                query.OrderKey  = 5;                                //4商家,5平台
                query.OrderType = isAsc.Value;
            }
            if (auditStatus.HasValue)
            {
                query.AuditStatus = new ProductInfo.ProductAuditStatus[] { (ProductInfo.ProductAuditStatus)auditStatus };
                if (auditStatus == (int)ProductInfo.ProductAuditStatus.WaitForAuditing)
                {
                    query.SaleStatus = ProductInfo.ProductSaleStatus.OnSale;
                }
            }
            if (saleStatus.HasValue)
            {
                query.SaleStatus = (ProductInfo.ProductSaleStatus)saleStatus;
            }

            var products = ProductManagerApplication.GetProducts(query);

            var brands     = BrandApplication.GetBrandsByIds(products.Models.Select(p => p.BrandId).ToList());
            var categories = CategoryApplication.GetCategories();
            var shops      = ShopApplication.GetShops(products.Models.Select(p => p.ShopId).ToList());

            var list = products.Models.Select(item =>
            {
                var description = ProductManagerApplication.GetProductDescription(item.Id);
                return(new ProductModel()
                {
                    //TODO:FG 循环内查询调用提取
                    name = item.ProductName,
                    brandName = brands.FirstOrDefault(p => p.Id == item.BrandId)?.Name ?? string.Empty,
                    categoryName = categories.FirstOrDefault(p => p.Id == item.CategoryId)?.Name ?? string.Empty,
                    id = item.Id,
                    imgUrl = item.GetImage(ImageSize.Size_50),
                    price = item.MinSalePrice,
                    state = item.ShowProductState,
                    auditStatus = (int)item.AuditStatus,
                    url = "",
                    auditReason = description?.AuditReason ?? string.Empty,
                    shopName = shops.FirstOrDefault(p => p.Id == item.ShopId)?.ShopName ?? string.Empty,
                    saleStatus = (int)item.SaleStatus,
                    productCode = item.ProductCode,
                    saleCounts = item.SaleCounts,
                    AddedDate = item.AddedDate.ToString("yyyy-MM-dd HH:mm"),
                    DisplaySequence = item.DisplaySequence,
                    VirtualSaleCounts = (int)item.VirtualSaleCounts,
                    ProductType = item.ProductType
                });
            });

            return(Json(new DataGridModel <ProductModel>()
            {
                rows = list, total = products.Total
            }));
        }