Beispiel #1
0
        /// <summary>
        /// 门店首页获取诊疗项目列表
        /// </summary>
        /// <param name="pageSize"></param>
        /// <param name="pageNo"></param>
        /// <param name="shopCategoryId">诊所一级分类</param>
        /// <param name="shopId">诊所ID</param>
        /// <param name="shopBranchId">门店ID</param>
        /// <returns></returns>
        public object GetProductList(int pageSize, int pageNo, string shopCategoryId, string shopId, string shopBranchId)
        {
            ShopBranchProductQuery query = new ShopBranchProductQuery();

            query.PageSize = pageSize;
            query.PageNo   = pageNo;
            //query.ShopCategoryId = TypeHelper.ObjectToInt(shopCategoryId, 0);
            query.ShopId                  = TypeHelper.ObjectToInt(shopId, 0);
            query.shopBranchId            = TypeHelper.ObjectToInt(shopBranchId, 0);
            query.ShopBranchProductStatus = ShopBranchSkuStatus.Normal;

            if (query.ShopId <= 0)
            {
                return(Json(new { Success = false, Message = "无法定位到诊所!" }));
            }

            //if (query.ShopCategoryId <= 0)
            //    return Json(new { Success = false, Message = "无法定位到诊所分类!" });
            if (TypeHelper.ObjectToInt(shopCategoryId, 0) > 0)
            {
                query.ShopCategoryId = TypeHelper.ObjectToInt(shopCategoryId);
            }

            if (query.shopBranchId <= 0)
            {
                return(Json(new { Success = false, Message = "无法定位到门店!" }));
            }

            var pageModel = ShopBranchApplication.GetShopBranchProducts(query);

            if (pageModel.Models != null && pageModel.Models.Count > 0)
            {
                #region 处理诊疗项目 官方自营店会员折扣价,各活动价等。
                var flashSalePriceList      = LimitTimeApplication.GetPriceByProducrIds(pageModel.Models.Select(p => p.Id).ToList());
                var fightGroupSalePriceList = FightGroupApplication.GetActiveByProductIds(pageModel.Models.Select(p => p.Id).ToArray());
                if (CurrentUser != null)
                {
                    var shopInfo = ShopApplication.GetShop(query.ShopId.Value);
                    if (shopInfo != null && shopInfo.IsSelf)//当前诊所是否是官方自营店
                    {
                        decimal discount = 1M;
                        discount = CurrentUser.MemberDiscount;
                        foreach (var item in pageModel.Models)
                        {
                            item.MinSalePrice = Math.Round(item.MinSalePrice * discount, 2);
                        }
                    }
                }
                foreach (var item in pageModel.Models)
                {
                    var flashSale      = flashSalePriceList.Any(p => p.ProductId == item.Id);
                    var fightGroupSale = fightGroupSalePriceList.Any(p => p.ProductId == item.Id);

                    if (flashSale && !fightGroupSale)
                    {
                        item.MinSalePrice = TypeHelper.ObjectToDecimal(flashSalePriceList.FirstOrDefault(p => p.ProductId == item.Id).MinPrice.ToString("f2"));
                    }
                    else if (!flashSale && fightGroupSale)
                    {
                        item.MinSalePrice = TypeHelper.ObjectToDecimal(fightGroupSalePriceList.FirstOrDefault(p => p.ProductId == item.Id).MiniGroupPrice.ToString("f2"));
                    }
                }
                #endregion
            }

            var productlist = pageModel.Models.ToList().Select(item =>
            {
                return(new
                {
                    Id = item.Id,
                    ProductName = item.ProductName,
                    MeasureUnit = item.MeasureUnit,
                    MinSalePrice = item.MinSalePrice.ToString("f2"),
                    SaleCounts = item.SaleCounts,                                                                                             //销量统计没有考虑预约单支付完成。
                    RelativePath = Core.HimallIO.GetRomoteProductSizeImage(item.RelativePath, 1, (int)Himall.CommonModel.ImageSize.Size_350), //150-350
                });
            });
            var result = new
            {
                Success     = true,
                ProductList = productlist,
                total       = pageModel.Total
            };

            return(Json(result));
        }
Beispiel #2
0
        public JsonResult ProductList(int pageSize, int pageNo, string shopCategoryId, string shopId, string shopBranchId)
        {
            bool isOpenStore = SiteSettingApplication.GetSiteSettings() != null && SiteSettingApplication.GetSiteSettings().IsOpenStore;

            if (!isOpenStore)
            {
                throw new Core.HimallException("门店未授权!");
            }
            ShopBranchProductQuery query = new ShopBranchProductQuery();

            query.PageSize                = pageSize;
            query.PageNo                  = pageNo;
            query.ShopId                  = TypeHelper.ObjectToInt(shopId, 0);
            query.shopBranchId            = TypeHelper.ObjectToInt(shopBranchId, 0);
            query.ShopBranchProductStatus = ShopBranchSkuStatus.Normal;

            if (query.ShopId <= 0)
            {
                return(Json(new { Success = false, Message = "无法定位到商家!" }, JsonRequestBehavior.AllowGet));
            }

            if (TypeHelper.ObjectToInt(shopCategoryId, 0) > 0)
            {
                query.ShopCategoryId = TypeHelper.ObjectToInt(shopCategoryId);
            }

            if (query.shopBranchId <= 0)
            {
                return(Json(new { Success = false, Message = "无法定位到门店!" }, JsonRequestBehavior.AllowGet));
            }

            var pageModel = ShopBranchApplication.GetShopBranchProducts(query);

            if (pageModel.Models != null && pageModel.Models.Count > 0)
            {
                #region 处理商品 官方自营店会员折扣价,各活动价等。
                var flashSalePriceList      = _iLimitTimeBuyService.GetPriceByProducrIds(pageModel.Models.Select(p => p.Id).ToList());
                var fightGroupSalePriceList = FightGroupApplication.GetActiveByProductIds(pageModel.Models.Select(p => p.Id).ToArray());

                if (CurrentUser != null)
                {
                    var shopInfo = ShopApplication.GetShop(query.ShopId.Value);
                    if (shopInfo != null && shopInfo.IsSelf)//当前商家是否是官方自营店
                    {
                        decimal discount = 1M;
                        discount = CurrentUser.MemberDiscount;
                        foreach (var item in pageModel.Models)
                        {
                            item.MinSalePrice = Math.Round(item.MinSalePrice * discount, 2);
                        }
                    }
                }

                foreach (var item in pageModel.Models)
                {
                    var flashSale      = flashSalePriceList.Any(p => p.ProductId == item.Id);
                    var fightGroupSale = fightGroupSalePriceList.Any(p => p.ProductId == item.Id);

                    if (flashSale && !fightGroupSale)
                    {
                        item.MinSalePrice = TypeHelper.ObjectToDecimal(flashSalePriceList.FirstOrDefault(p => p.ProductId == item.Id).MinPrice.ToString("f2"));
                    }
                    else if (!flashSale && fightGroupSale)
                    {
                        item.MinSalePrice = TypeHelper.ObjectToDecimal(fightGroupSalePriceList.FirstOrDefault(p => p.ProductId == item.Id).MiniGroupPrice.ToString("f2"));
                    }
                }
                #endregion
            }
            var product = pageModel.Models.ToList().Select(item =>
            {
                return(new
                {
                    Id = item.Id,
                    ProductName = item.ProductName,
                    MeasureUnit = item.MeasureUnit,
                    MinSalePrice = item.MinSalePrice.ToString("f2"),
                    SaleCounts = item.SaleCounts,//销量统计没有考虑订单支付完成。
                    RelativePath = Core.HimallIO.GetRomoteProductSizeImage(item.RelativePath, 1, (int)Himall.CommonModel.ImageSize.Size_350),
                });
            });
            return(Json(new { Success = true, Models = product, Total = pageModel.Total }, JsonRequestBehavior.AllowGet));
        }