Example #1
0
        /// <summary>
        /// 获取用户优惠券列表
        /// </summary>
        /// <returns></returns>
        public JsonResult <Result <dynamic> > GetLoadCoupon()
        {
            CheckUserLogin();
            var userCouponList = CouponApplication.GetUserCouponList(CurrentUser.Id);
            var shopBonus      = GetBonusList();

            if (userCouponList != null || shopBonus != null)
            {
                //优惠券
                var couponlist = new Object();
                if (userCouponList != null)
                {
                    couponlist = userCouponList.ToArray().Select(a => new
                    {
                        UserId          = a.UserId,
                        ShopId          = a.ShopId,
                        CouponId        = a.CouponId,
                        Price           = a.Price,
                        PerMax          = a.PerMax,
                        OrderAmount     = a.OrderAmount,
                        ShowOrderAmount = a.OrderAmount,
                        Num             = a.Num,
                        StartTime       = a.StartTime.ToString(),
                        EndTime         = a.EndTime.ToString(),
                        CreateTime      = a.CreateTime.ToString(),
                        CouponName      = a.CouponName,
                        UseStatus       = a.UseStatus,
                        UseTime         = a.UseTime.HasValue ? a.UseTime.ToString() : null,
                        VShop           = GetVShop(a.ShopId),
                        ShopName        = a.ShopName,
                        Remark          = a.Remark,
                        UseArea         = a.UseArea
                    });
                }
                else
                {
                    couponlist = null;
                }
                //代金红包
                var userBonus = new List <dynamic>();
                if (shopBonus != null)
                {
                    userBonus = shopBonus.Select(item =>
                    {
                        var bonusService    = ServiceProvider.Instance <IShopBonusService> .Create;
                        var grant           = bonusService.GetGrant(item.BonusGrantId);
                        var bonus           = bonusService.GetShopBonus(grant.ShopBonusId);
                        var shop            = ShopApplication.GetShop(bonus.ShopId);
                        var vShop           = VshopApplication.GetVShopByShopId(shop.Id);
                        var Price           = item.Price;
                        var showOrderAmount = bonus.UsrStatePrice > 0 ? bonus.UsrStatePrice : item.Price;
                        if (bonus.UseState != Entities.ShopBonusInfo.UseStateType.FilledSend)
                        {
                            showOrderAmount = item.Price;
                        }
                        var Logo     = string.Empty;
                        long VShopId = 0;
                        if (vShop != null)
                        {
                            Logo    = Core.HimallIO.GetRomoteImagePath(vShop.StrLogo);
                            VShopId = vShop.Id;
                        }

                        var State = (int)item.State;
                        if (item.State != ShopBonusReceiveInfo.ReceiveState.Use && bonus.DateEnd < DateTime.Now)
                        {
                            State = (int)ShopBonusReceiveInfo.ReceiveState.Expired;
                        }
                        var BonusDateEnd    = bonus.BonusDateEnd.ToString("yyyy-MM-dd");
                        dynamic obj         = new System.Dynamic.ExpandoObject();
                        obj.Price           = Price;
                        obj.ShowOrderAmount = showOrderAmount;
                        obj.Logo            = Logo;
                        obj.VShopId         = VShopId;
                        obj.State           = State;
                        obj.BonusDateEnd    = BonusDateEnd;
                        obj.ShopName        = shop.ShopName;
                        obj.DateEnd         = bonus.DateEnd;
                        return(obj);
                    }).ToList();
                }
                else
                {
                    shopBonus = null;
                }
                //优惠券
                int NoUseCouponCount = 0;
                int UseCouponCount   = 0;
                if (userCouponList != null)
                {
                    NoUseCouponCount = userCouponList.Count(item => (item.EndTime > DateTime.Now && item.UseStatus == CouponRecordInfo.CounponStatuses.Unuse));
                    UseCouponCount   = userCouponList.Count() - NoUseCouponCount;
                }
                //红包
                int NoUseBonusCount = 0;
                int UseBonusCount   = 0;
                if (shopBonus != null)
                {
                    var nusv = ShopBonusReceiveInfo.ReceiveState.NotUse.GetHashCode();
                    NoUseBonusCount = userBonus.Count(r => r.State == nusv && r.DateEnd > DateTime.Now);
                    UseBonusCount   = userBonus.Count() - NoUseBonusCount;
                }

                int UseCount    = UseCouponCount + UseBonusCount;
                int NotUseCount = NoUseCouponCount + NoUseBonusCount;

                var result = new
                {
                    success    = true,
                    NoUseCount = NotUseCount,
                    UserCount  = UseCount,
                    Coupon     = couponlist,
                    Bonus      = userBonus
                };
                return(JsonResult <dynamic>(result));
            }
            else
            {
                throw new Himall.Core.HimallException("没有领取记录!");
            }
        }
Example #2
0
        public JsonResult GetCartProducts()
        {
            long    userId   = 0;
            decimal discount = 1M;

            if (CurrentUser != null)
            {
                userId   = CurrentUser.Id;
                discount = CurrentUser.MemberDiscount;
            }

            var cart           = cartHelper.GetCart(userId);
            var productService = _iProductService;
            var shopService    = _iShopService;
            var typeservice    = _iTypeService;


            var products = cart.Items.Select(item =>
            {
                var product = productService.GetProduct(item.ProductId);

                ProductTypeInfo typeInfo = typeservice.GetType(product.TypeId);
                string colorAlias        = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias;
                string sizeAlias         = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias;
                string versionAlias      = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias;

                var shop = ShopApplication.GetShop(product.ShopId);
                if (null != shop)
                {
                    SKUInfo sku = productService.GetSku(item.SkuId);
                    if (sku != null)
                    {
                        var price = sku.SalePrice * discount;//
                        return(new
                        {
                            cartItemId = item.Id,
                            skuId = item.SkuId,
                            id = product.Id,
                            imgUrl = Himall.Core.HimallIO.GetProductSizeImage(product.RelativePath, 1, (int)ImageSize.Size_50),
                            name = product.ProductName,
                            productstatus = product.SaleStatus,
                            productauditstatus = product.AuditStatus,
                            price = shop.IsSelf ? price : sku.SalePrice,//sku.SalePrice,
                            Color = sku.Color,
                            Size = sku.Size,
                            Version = sku.Version,
                            count = item.Quantity,
                            shopId = shop.Id,
                            shopName = shop.ShopName,
                            productcode = !(sku.Version + sku.Color + sku.Size).Equals("") ? sku.Sku : product.ProductCode,
                            ColorAlias = colorAlias,
                            SizeAlias = sizeAlias,
                            VersionAlias = versionAlias,
                            AddTime = item.AddTime
                        });
                    }
                }
                return(null);
            }).Where(p => p != null).OrderBy(s => s.shopId).ThenByDescending(o => o.AddTime);

            var cartModel = new
            {
                products   = products,
                amount     = products.Where(item => item.productstatus == ProductInfo.ProductSaleStatus.OnSale && item.productauditstatus != ProductInfo.ProductAuditStatus.InfractionSaleOff && item.productauditstatus != ProductInfo.ProductAuditStatus.WaitForAuditing).Sum(item => item.price * item.count),
                totalCount = products.Where(item => item.productstatus == ProductInfo.ProductSaleStatus.OnSale && item.productauditstatus != ProductInfo.ProductAuditStatus.InfractionSaleOff && item.productauditstatus != ProductInfo.ProductAuditStatus.WaitForAuditing).Sum(item => item.count)
            };

            return(Json(cartModel));
        }
Example #3
0
        public object GetVShop(long id, bool sv = false)
        {
            var vshopService = ServiceProvider.Instance <IVShopService> .Create;
            var vshop        = vshopService.GetVShop(id);

            if (vshop == null)
            {
                return new Result {
                           success = false, msg = "未开通微店", code = -4
                }
            }
            ;
            if (vshop.State == Entities.VShopInfo.VShopStates.Close)
            {
                return new Result {
                           success = false, msg = "商家暂未开通微店", code = -5
                }
            }
            ;
            if (!vshop.IsOpen)
            {
                return new Result {
                           success = false, msg = "此微店已关闭", code = -3
                }
            }
            ;
            var s = ShopApplication.GetShop(vshop.ShopId);

            if (null != s && s.ShopStatus == Entities.ShopInfo.ShopAuditStatus.HasExpired)
            {
                return new Result {
                           success = false, msg = "此店铺已过期", code = -1
                }
            }
            ;
            //throw new MallApiException("此店铺已过期");
            if (null != s && s.ShopStatus == Entities.ShopInfo.ShopAuditStatus.Freeze)
            {
                return new Result {
                           success = false, msg = "此店铺已冻结", code = -2
                }
            }
            ;

            //throw new MallApiException("此店铺已冻结");

            //轮播图配置只有商家微店首页配置页面可配置,现在移动端都读的这个数据
            var slideImgs = ServiceProvider.Instance <ISlideAdsService> .Create.GetSlidAds(vshop.ShopId, Entities.SlideAdInfo.SlideAdType.VShopHome).ToList();

            //首页商品现在只有商家配置微信首页,APP读的也是这个数据所以平台类型选的的微信端
            var homeProducts = ServiceProvider.Instance <IMobileHomeProductsService> .Create.GetMobileHomeProducts(vshop.ShopId, PlatformType.WeiXin, 1, 8);

            #region 价格更新
            //会员折扣
            decimal discount   = 1M;
            long    SelfShopId = 0;
            if (CurrentUser != null)
            {
                discount = CurrentUser.MemberDiscount;

                var shopInfo = ShopApplication.GetSelfShop();
                SelfShopId = shopInfo.Id;
            }

            var limit = LimitTimeApplication.GetLimitProducts();
            var fight = FightGroupApplication.GetFightGroupPrice();

            var products    = new List <ProductItem>();
            var productData = ProductManagerApplication.GetProducts(homeProducts.Models.Select(p => p.ProductId));
            foreach (var item in homeProducts.Models)
            {
                var product = productData.FirstOrDefault(p => p.Id == item.ProductId);
                var pitem   = new ProductItem();
                pitem.Id          = item.ProductId;
                pitem.ImageUrl    = Core.MallIO.GetRomoteProductSizeImage(product.RelativePath, 1, (int)Mall.CommonModel.ImageSize.Size_350);
                pitem.Name        = product.ProductName;
                pitem.MarketPrice = product.MarketPrice;
                pitem.SalePrice   = product.MinSalePrice;
                if (item.ShopId == SelfShopId)
                {
                    pitem.SalePrice = product.MinSalePrice * discount;
                }
                var isLimit = limit.Where(r => r.ProductId == item.ProductId).FirstOrDefault();
                var isFight = fight.Where(r => r.ProductId == item.ProductId).FirstOrDefault();
                if (isLimit != null)
                {
                    pitem.SalePrice = isLimit.MinPrice;
                }
                if (isFight != null)
                {
                    pitem.SalePrice = isFight.ActivePrice;
                }
                products.Add(pitem);
            }
            #endregion
            var banner = ServiceProvider.Instance <INavigationService> .Create.GetSellerNavigations(vshop.ShopId, Core.PlatformType.WeiXin).ToList();

            var couponInfo = GetCouponList(vshop.ShopId);

            var SlideAds = slideImgs.ToArray().Select(item => new HomeSlideAdsModel()
            {
                ImageUrl = Core.MallIO.GetRomoteImagePath(item.ImageUrl), Url = item.Url
            });

            var Banner   = banner;
            var Products = products;

            bool favoriteShop = false;
            if (CurrentUser != null)
            {
                favoriteShop = ServiceProvider.Instance <IShopService> .Create.IsFavoriteShop(CurrentUser.Id, vshop.ShopId);
            }
            string followUrl = "";
            //快速关注
            var vshopSetting = ServiceProvider.Instance <IVShopService> .Create.GetVShopSetting(vshop.ShopId);

            if (vshopSetting != null)
            {
                followUrl = vshopSetting.FollowUrl;
            }
            var model = new
            {
                Id = vshop.Id,
                //Logo = "http://" + Url.Request.RequestUri.Host + vshop.Logo,
                Logo      = Core.MallIO.GetRomoteImagePath(vshop.StrLogo),
                Name      = vshop.Name,
                ShopId    = vshop.ShopId,
                Favorite  = favoriteShop,
                State     = vshop.State,
                FollowUrl = followUrl
            };

            // 客服
            var customerServices = CustomerServiceApplication.GetMobileCustomerServiceAndMQ(vshop.ShopId);

            //统计访问量
            if (!sv)
            {
                vshopService.LogVisit(id);
                //统计店铺访问人数
                StatisticApplication.StatisticShopVisitUserCount(vshop.ShopId);
            }
            dynamic result = SuccessResult();
            result.VShop            = model;
            result.SlideImgs        = SlideAds;
            result.Products         = products;
            result.Banner           = banner;
            result.Coupon           = couponInfo;
            result.CustomerServices = customerServices;
            return(result);
        }
Example #4
0
        /// <summary>
        /// 页面加载时处理
        /// </summary>
        /// <param name="filterContext"></param>
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);

            ViewBag.Logo = SiteSettings.MemberLogo;
            string controllerName = filterContext.RouteData.Values["controller"].ToString().ToLower();
            string actionName     = filterContext.RouteData.Values["action"].ToString().ToLower();
            string areaName       = filterContext.RouteData.DataTokens["area"].ToString().ToLower();

            if (CurrentSellerManager == null && actionName.IndexOf("step") != 0 && filterContext.RequestContext.HttpContext.Request.HttpMethod.ToUpper() != "POST")
            {
                if (actionName != ("EditProfile0").ToLower())
                {
                    var result = RedirectToAction("EditProfile0", "ShopProfile", new { area = "SellerAdmin" });
                    filterContext.Result = result;
                    return;
                }
            }
            else if (CurrentSellerManager != null)
            {
                var shop  = ShopApplication.GetShop(CurrentSellerManager.ShopId);
                int stage = (int)shop.Stage;
                if (shop.Stage == Entities.ShopInfo.ShopStage.Finish && shop.ShopStatus == Entities.ShopInfo.ShopAuditStatus.Open)
                {
                    var result = RedirectToAction("index", "home", new { area = "SellerAdmin" });
                    filterContext.Result = result;
                    return;
                }
                if ((shop.Stage != Entities.ShopInfo.ShopStage.Finish || shop.ShopStatus == Entities.ShopInfo.ShopAuditStatus.WaitConfirm) && filterContext.RequestContext.HttpContext.Request.HttpMethod.ToUpper() != "POST" && (shop.Stage != Entities.ShopInfo.ShopStage.Finish || string.IsNullOrEmpty(Request.QueryString["source"])))
                {
                    //TODO:FG 权限验证处BaseSellerController 含有相同逻辑
                    if (actionName.IndexOf("step") != 0)
                    {
                        bool isJump = true;
                        if (shop.ShopStatus == Entities.ShopInfo.ShopAuditStatus.Refuse || shop.ShopStatus == Entities.ShopInfo.ShopAuditStatus.Unusable)
                        {
                            string _tmp    = actionName.ToLower().Replace("EditProfile".ToLower(), "");
                            int    _tmpnum = 0;
                            if (int.TryParse(_tmp, out _tmpnum))
                            {
                                if (_tmpnum >= 0 && _tmpnum <= 3)
                                {
                                    //允许在填写公司资料时返回上一步查看信息
                                    isJump = false;
                                }
                            }
                        }
                        if (isJump)
                        {
                            //如果当前action是已经是对应的值则不要跳转,否则将进入死循环
                            if (actionName != ("EditProfile" + stage).ToLower())
                            {
                                var result = RedirectToAction("EditProfile" + stage, "ShopProfile", new { area = "SellerAdmin" });
                                filterContext.Result = result;
                                return;
                            }
                        }
                    }
                }
            }
        }
Example #5
0
        public object GetActiveDetail(long id, long grouId = 0, bool isFirst = true, string ids = "")
        {
            var userList = new List <FightGroupOrderInfo>();
            var data     = FightGroupApplication.GetActive(id, true, true);
            FightGroupActiveModel result = data;

            //先初始化拼团商品主图
            result.InitProductImages();
            var imgpath = data.ProductImgPath;

            if (result != null)
            {
                result.IsEnd = true;
                if (data.EndTime.Date >= DateTime.Now.Date)
                {
                    result.IsEnd = false;
                }
                //商品图片地址修正
                result.ProductDefaultImage = MallIO.GetRomoteProductSizeImage(imgpath, 1, (int)ImageSize.Size_350);
                result.ProductImgPath      = MallIO.GetRomoteProductSizeImage(imgpath, 1);
            }
            if (result.ProductImages != null)
            {//将主图相对路径处理为绝对路径
                result.ProductImages = result.ProductImages.Select(e => MallIO.GetRomoteImagePath(e)).ToList();
            }

            if (!string.IsNullOrWhiteSpace(result.IconUrl))
            {
                result.IconUrl = Mall.Core.MallIO.GetRomoteImagePath(result.IconUrl);
            }
            bool IsUserEnter = false;
            long currentUser = 0;

            if (CurrentUser != null)
            {
                currentUser = CurrentUser.Id;
            }
            if (grouId > 0)//获取已参团的用户
            {
                userList = ServiceProvider.Instance <IFightGroupService> .Create.GetActiveUsers(id, grouId);

                foreach (var item in userList)
                {
                    item.Photo        = !string.IsNullOrWhiteSpace(item.Photo) ? Core.MallIO.GetRomoteImagePath(item.Photo) : "";
                    item.HeadUserIcon = !string.IsNullOrWhiteSpace(item.HeadUserIcon) ? Core.MallIO.GetRomoteImagePath(item.HeadUserIcon) : "";
                    if (currentUser.Equals(item.OrderUserId))
                    {
                        IsUserEnter = true;
                    }
                }
            }
            #region 商品规格
            var product = ProductManagerApplication.GetProduct((long)result.ProductId);

            ProductShowSkuInfoModel model = new ProductShowSkuInfoModel();
            model.MinSalePrice     = data.MiniSalePrice;
            model.ProductImagePath = string.IsNullOrWhiteSpace(imgpath) ? "" : MallIO.GetRomoteProductSizeImage(imgpath, 1, (int)Mall.CommonModel.ImageSize.Size_350);

            List <SKUDataModel> skudata = data.ActiveItems.Where(d => d.ActiveStock > 0).Select(d => new SKUDataModel
            {
                SkuId     = d.SkuId,
                Color     = d.Color,
                Size      = d.Size,
                Version   = d.Version,
                Stock     = (int)d.ActiveStock,
                CostPrice = d.ProductCostPrice,
                SalePrice = d.ProductPrice,
                Price     = d.ActivePrice,
            }).ToList();

            Entities.TypeInfo typeInfo = ServiceProvider.Instance <ITypeService> .Create.GetType(product.TypeId);

            string colorAlias   = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias;
            string sizeAlias    = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias;
            string versionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias;
            if (product != null)
            {
                colorAlias   = !string.IsNullOrWhiteSpace(product.ColorAlias) ? product.ColorAlias : colorAlias;
                sizeAlias    = !string.IsNullOrWhiteSpace(product.SizeAlias) ? product.SizeAlias : sizeAlias;
                versionAlias = !string.IsNullOrWhiteSpace(product.VersionAlias) ? product.VersionAlias : versionAlias;
            }
            model.ColorAlias   = colorAlias;
            model.SizeAlias    = sizeAlias;
            model.VersionAlias = versionAlias;

            if (result.ActiveItems != null && result.ActiveItems.Count() > 0)
            {
                long colorId = 0, sizeId = 0, versionId = 0;
                var  skus = ProductManagerApplication.GetSKUs((long)result.ProductId);
                foreach (var sku in result.ActiveItems)
                {
                    var specs = sku.SkuId.Split('_');
                    if (specs.Count() > 0 && !string.IsNullOrEmpty(sku.Color))
                    {
                        if (long.TryParse(specs[1], out colorId))
                        {
                        }
                        if (colorId != 0)
                        {
                            if (!model.Color.Any(v => v.Value.Equals(sku.Color)))
                            {
                                var c = result.ActiveItems.Where(s => s.Color.Equals(sku.Color)).Sum(s => s.ActiveStock);
                                model.Color.Add(new ProductSKU
                                {
                                    //Name = "选择颜色",
                                    Name         = "选择" + colorAlias,
                                    EnabledClass = c != 0 ? " " : "disabled",
                                    //SelectedClass = !model.Color.Any(c1 => c1.SelectedClass.Equals("selected")) && c != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = colorId,
                                    Value         = sku.Color,
                                    Img           = string.IsNullOrWhiteSpace(sku.ShowPic) ? "" : Core.MallIO.GetRomoteImagePath(sku.ShowPic)
                                });
                            }
                        }
                    }
                    if (specs.Count() > 1 && !string.IsNullOrEmpty(sku.Size))
                    {
                        if (long.TryParse(specs[2], out sizeId))
                        {
                        }
                        if (sizeId != 0)
                        {
                            if (!model.Size.Any(v => v.Value.Equals(sku.Size)))
                            {
                                var ss = result.ActiveItems.Where(s => s.Size.Equals(sku.Size)).Sum(s1 => s1.ActiveStock);
                                model.Size.Add(new ProductSKU
                                {
                                    //Name = "选择尺码",
                                    Name          = "选择" + sizeAlias,
                                    EnabledClass  = ss != 0 ? "enabled" : "disabled",
                                    SelectedClass = "",
                                    SkuId         = sizeId,
                                    Value         = sku.Size
                                });
                            }
                        }
                    }

                    if (specs.Count() > 2 && !string.IsNullOrEmpty(sku.Version))
                    {
                        if (long.TryParse(specs[3], out versionId))
                        {
                        }
                        if (versionId != 0)
                        {
                            if (!model.Version.Any(v => v.Value.Equals(sku.Version)))
                            {
                                var v = result.ActiveItems.Where(s => s.Version.Equals(sku.Version)).Sum(s => s.ActiveStock);
                                model.Version.Add(new ProductSKU
                                {
                                    //Name = "选择规格",
                                    Name          = "选择" + versionAlias,
                                    EnabledClass  = v != 0 ? "enabled" : "disabled",
                                    SelectedClass = "",
                                    SkuId         = versionId,
                                    Value         = sku.Version
                                });
                            }
                        }
                    }
                }
            }
            #endregion

            var cashDepositModel = CashDepositsApplication.GetCashDepositsObligation((long)result.ProductId);//提供服务(消费者保障、七天无理由、及时发货)

            var GroupsData = new List <FightGroupsListModel>();
            List <FightGroupBuildStatus> stlist = new List <FightGroupBuildStatus>();
            stlist.Add(FightGroupBuildStatus.Ongoing);
            GroupsData = FightGroupApplication.GetGroups(id, stlist, null, null, 1, 10).Models.ToList();
            foreach (var item in GroupsData)
            {
                TimeSpan mid = item.AddGroupTime.AddHours((double)item.LimitedHour) - DateTime.Now;
                item.Seconds         = (int)mid.TotalSeconds;
                item.EndHourOrMinute = item.ShowHourOrMinute(item.GetEndHour);
                item.HeadUserIcon    = !string.IsNullOrWhiteSpace(item.HeadUserIcon) ? Core.MallIO.GetRomoteImagePath(item.HeadUserIcon) : "";
            }

            #region 商品评论
            ProductCommentShowModel modelSay = new ProductCommentShowModel();
            modelSay.ProductId = (long)result.ProductId;
            var productSay = ProductManagerApplication.GetProduct((long)result.ProductId);
            modelSay.CommentList       = new List <ProductDetailCommentModel>();
            modelSay.IsShowColumnTitle = true;
            modelSay.IsShowCommentList = true;

            if (productSay == null)
            {
                //跳转到404页面
                throw new Core.MallException("商品不存在");
            }
            var comments = CommentApplication.GetCommentsByProduct(product.Id);
            modelSay.CommentCount = comments.Count;
            if (comments.Count > 0)
            {
                var comment   = comments.OrderByDescending(a => a.ReviewDate).FirstOrDefault();
                var orderItem = OrderApplication.GetOrderItem(comment.SubOrderId);
                var order     = OrderApplication.GetOrder(orderItem.OrderId);
                modelSay.CommentList = comments.OrderByDescending(a => a.ReviewDate)
                                       .Take(1)
                                       .Select(c => {
                    var images = CommentApplication.GetProductCommentImagesByCommentIds(new List <long> {
                        c.Id
                    });
                    return(new ProductDetailCommentModel
                    {
                        Sku = ServiceProvider.Instance <IProductService> .Create.GetSkuString(orderItem.SkuId),
                        UserName = c.UserName,
                        ReviewContent = c.ReviewContent,
                        AppendContent = c.AppendContent,
                        AppendDate = c.AppendDate,
                        ReplyAppendContent = c.ReplyAppendContent,
                        ReplyAppendDate = c.ReplyAppendDate,
                        FinshDate = order.FinishDate,
                        Images = images.Where(a => a.CommentType == 0).Select(a => a.CommentImage).ToList(),
                        AppendImages = images.Where(a => a.CommentType == 1).Select(a => a.CommentImage).ToList(),
                        ReviewDate = c.ReviewDate,
                        ReplyContent = string.IsNullOrWhiteSpace(c.ReplyContent) ? "暂无回复" : c.ReplyContent,
                        ReplyDate = c.ReplyDate,
                        ReviewMark = c.ReviewMark,
                        BuyDate = order.OrderDate
                    });
                }).ToList();
                foreach (var citem in modelSay.CommentList)
                {
                    if (citem.Images.Count > 0)
                    {
                        for (var _imgn = 0; _imgn < citem.Images.Count; _imgn++)
                        {
                            citem.Images[_imgn] = Mall.Core.MallIO.GetRomoteImagePath(citem.Images[_imgn]);
                        }
                    }
                    if (citem.AppendImages.Count > 0)
                    {
                        for (var _imgn = 0; _imgn < citem.AppendImages.Count; _imgn++)
                        {
                            citem.AppendImages[_imgn] = Mall.Core.MallIO.GetRomoteImagePath(citem.AppendImages[_imgn]);
                        }
                    }
                }
            }
            #endregion

            #region 店铺信息
            VShopShowShopScoreModel modelShopScore = new VShopShowShopScoreModel();
            modelShopScore.ShopId = result.ShopId;
            var shop = ServiceProvider.Instance <IShopService> .Create.GetShop(result.ShopId);

            if (shop == null)
            {
                throw new MallException("错误的店铺信息");
            }

            modelShopScore.ShopName = shop.ShopName;

            #region 获取店铺的评价统计
            var shopStatisticOrderComments = ServiceProvider.Instance <IShopService> .Create.GetShopStatisticOrderComments(result.ShopId);

            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;

            modelShopScore.SellerServiceAttitude     = defaultValue;
            modelShopScore.SellerServiceAttitudePeer = defaultValue;
            modelShopScore.SellerServiceAttitudeMax  = defaultValue;
            modelShopScore.SellerServiceAttitudeMin  = defaultValue;

            //宝贝与描述
            if (productAndDescription != null && productAndDescriptionPeer != null && !shop.IsSelf)
            {
                modelShopScore.ProductAndDescription     = productAndDescription.CommentValue;
                modelShopScore.ProductAndDescriptionPeer = productAndDescriptionPeer.CommentValue;
                modelShopScore.ProductAndDescriptionMin  = productAndDescriptionMin.CommentValue;
                modelShopScore.ProductAndDescriptionMax  = productAndDescriptionMax.CommentValue;
            }
            else
            {
                modelShopScore.ProductAndDescription     = defaultValue;
                modelShopScore.ProductAndDescriptionPeer = defaultValue;
                modelShopScore.ProductAndDescriptionMin  = defaultValue;
                modelShopScore.ProductAndDescriptionMax  = defaultValue;
            }

            //卖家服务态度
            if (sellerServiceAttitude != null && sellerServiceAttitudePeer != null && !shop.IsSelf)
            {
                modelShopScore.SellerServiceAttitude     = sellerServiceAttitude.CommentValue;
                modelShopScore.SellerServiceAttitudePeer = sellerServiceAttitudePeer.CommentValue;
                modelShopScore.SellerServiceAttitudeMax  = sellerServiceAttitudeMax.CommentValue;
                modelShopScore.SellerServiceAttitudeMin  = sellerServiceAttitudeMin.CommentValue;
            }
            else
            {
                modelShopScore.SellerServiceAttitude     = defaultValue;
                modelShopScore.SellerServiceAttitudePeer = defaultValue;
                modelShopScore.SellerServiceAttitudeMax  = defaultValue;
                modelShopScore.SellerServiceAttitudeMin  = defaultValue;
            }
            //卖家发货速度
            if (sellerDeliverySpeedPeer != null && sellerDeliverySpeed != null && !shop.IsSelf)
            {
                modelShopScore.SellerDeliverySpeed     = sellerDeliverySpeed.CommentValue;
                modelShopScore.SellerDeliverySpeedPeer = sellerDeliverySpeedPeer.CommentValue;
                modelShopScore.SellerDeliverySpeedMax  = sellerDeliverySpeedMax != null ? sellerDeliverySpeedMax.CommentValue : 0;
                modelShopScore.sellerDeliverySpeedMin  = sellerDeliverySpeedMin != null ? sellerDeliverySpeedMin.CommentValue : 0;
            }
            else
            {
                modelShopScore.SellerDeliverySpeed     = defaultValue;
                modelShopScore.SellerDeliverySpeedPeer = defaultValue;
                modelShopScore.SellerDeliverySpeedMax  = defaultValue;
                modelShopScore.sellerDeliverySpeedMin  = defaultValue;
            }
            #endregion

            modelShopScore.ProductNum = ServiceProvider.Instance <IProductService> .Create.GetShopOnsaleProducts(result.ShopId);

            modelShopScore.IsFavoriteShop    = false;
            modelShopScore.FavoriteShopCount = ServiceProvider.Instance <IShopService> .Create.GetShopFavoritesCount(result.ShopId);

            if (CurrentUser != null)
            {
                modelShopScore.IsFavoriteShop = ServiceProvider.Instance <IShopService> .Create.GetFavoriteShopInfos(CurrentUser.Id).Any(d => d.ShopId == result.ShopId);
            }

            long vShopId;
            var  vshopinfo = ServiceProvider.Instance <IVShopService> .Create.GetVShopByShopId(shop.Id);

            if (vshopinfo == null)
            {
                vShopId = -1;
            }
            else
            {
                vShopId = vshopinfo.Id;
            }
            modelShopScore.VShopId  = vShopId;
            modelShopScore.VShopLog = ServiceProvider.Instance <IVShopService> .Create.GetVShopLog(vShopId);

            if (!string.IsNullOrWhiteSpace(modelShopScore.VShopLog))
            {
                modelShopScore.VShopLog = Mall.Core.MallIO.GetRomoteImagePath(modelShopScore.VShopLog);
            }

            // 客服
            var customerServices = CustomerServiceApplication.GetMobileCustomerServiceAndMQ(shop.Id);
            #endregion
            #region 根据运费模板获取发货地址
            var    freightTemplateService = ServiceApplication.Create <IFreightTemplateService>();
            var    template       = freightTemplateService.GetFreightTemplate(product.FreightTemplateId);
            string productAddress = string.Empty;
            if (template != null)
            {
                var fullName = ServiceApplication.Create <IRegionService>().GetFullName(template.SourceAddress);
                if (fullName != null)
                {
                    var ass = fullName.Split(' ');
                    if (ass.Length >= 2)
                    {
                        productAddress = ass[0] + " " + ass[1];
                    }
                    else
                    {
                        productAddress = ass[0];
                    }
                }
            }

            var ProductAddress  = productAddress;
            var FreightTemplate = template;
            #endregion

            #region 获取店铺优惠信息
            VShopShowPromotionModel modelVshop = new VShopShowPromotionModel();
            modelVshop.ShopId = result.ShopId;
            var shopInfo = ServiceProvider.Instance <IShopService> .Create.GetShop(result.ShopId);

            if (shopInfo == null)
            {
                throw new MallException("错误的店铺编号");
            }

            modelVshop.FreeFreight = shop.FreeFreight;


            var bonus = ServiceApplication.Create <IShopBonusService>().GetByShopId(result.ShopId);
            if (bonus != null)
            {
                modelVshop.BonusCount             = bonus.Count;
                modelVshop.BonusGrantPrice        = bonus.GrantPrice;
                modelVshop.BonusRandomAmountStart = bonus.RandomAmountStart;
                modelVshop.BonusRandomAmountEnd   = bonus.RandomAmountEnd;
            }
            FullDiscountActive fullDiscount = null;
            //var fullDiscount = FullDiscountApplication.GetOngoingActiveByProductId(id, shop.Id);
            #endregion
            //商品描述

            var description = ProductManagerApplication.GetProductDescription(result.ProductId);
            if (description == null)
            {
                throw new MallException("错误的商品编号");
            }

            string DescriptionPrefix = "", DescriptiondSuffix = "";
            var    iprodestempser = ServiceApplication.Create <IProductDescriptionTemplateService>();
            if (description.DescriptionPrefixId != 0)
            {
                var desc = iprodestempser.GetTemplate(description.DescriptionPrefixId, product.ShopId);
                DescriptionPrefix = desc == null ? "" : desc.MobileContent;
            }

            if (description.DescriptiondSuffixId != 0)
            {
                var desc = iprodestempser.GetTemplate(description.DescriptiondSuffixId, product.ShopId);
                DescriptiondSuffix = desc == null ? "" : desc.MobileContent;
            }
            var productDescription = DescriptionPrefix + description.ShowMobileDescription + DescriptiondSuffix;
            //统计商品浏览量、店铺浏览人数
            StatisticApplication.StatisticVisitCount(product.Id, product.ShopId);

            //  AutoMapper.Mapper.CreateMap<FightGroupActiveModel, FightGroupActiveResult>();
            var     fightGroupData = result.Map <FightGroupActiveResult>();
            decimal discount       = 1M;
            if (CurrentUser != null)
            {
                discount = CurrentUser.MemberDiscount;
            }
            var shopItem = ShopApplication.GetShop(result.ShopId);
            fightGroupData.MiniSalePrice = shopItem.IsSelf ? fightGroupData.MiniSalePrice * discount : fightGroupData.MiniSalePrice;

            string loadShowPrice = string.Empty;//app拼团详细页加载时显示的区间价
            loadShowPrice = fightGroupData.MiniSalePrice.ToString("f2");

            if (fightGroupData != null && fightGroupData.ActiveItems.Count() > 0)
            {
                decimal min = fightGroupData.ActiveItems.Min(s => s.ActivePrice);
                decimal max = fightGroupData.ActiveItems.Max(s => s.ActivePrice);
                loadShowPrice = (min < max) ? (min.ToString("f2") + " - " + max.ToString("f2")) : min.ToString("f2");
            }

            var _result = new
            {
                success        = true,
                FightGroupData = fightGroupData,
                ShowSkuInfo    = new
                {
                    ColorAlias       = model.ColorAlias,
                    SizeAlias        = model.SizeAlias,
                    VersionAlias     = model.VersionAlias,
                    MinSalePrice     = model.MinSalePrice,
                    ProductImagePath = model.ProductImagePath,
                    Color            = model.Color.OrderByDescending(p => p.SkuId),
                    Size             = model.Size.OrderByDescending(p => p.SkuId),
                    Version          = model.Version.OrderByDescending(p => p.SkuId)
                },
                ShowPromotion       = modelVshop,
                fullDiscount        = fullDiscount,
                ShowNewCanJoinGroup = GroupsData,
                ProductCommentShow  = modelSay,
                ProductDescription  = productDescription.Replace("src=\"/Storage/", "src=\"" + Core.MallIO.GetRomoteImagePath("/Storage") + "/"),
                ShopScore           = modelShopScore,
                CashDepositsServer  = cashDepositModel,
                ProductAddress      = ProductAddress,
                //Free = FreightTemplate.IsFree == FreightTemplateType.Free ? "免运费" : "",
                userList              = userList,
                IsUserEnter           = IsUserEnter,
                SkuData               = skudata,
                CustomerServices      = customerServices,
                IsOpenLadder          = product.IsOpenLadder,
                VideoPath             = string.IsNullOrWhiteSpace(product.VideoPath) ? string.Empty : Mall.Core.MallIO.GetRomoteImagePath(product.VideoPath),
                LoadShowPrice         = loadShowPrice,                                                                                                           //商品时区间价
                ProductSaleCountOnOff = (SiteSettingApplication.SiteSettings.ProductSaleCountOnOff == 1),                                                        //是否显示销量
                SaleCounts            = data.ActiveItems.Sum(d => d.BuyCount),                                                                                   //销量
                FreightStr            = FreightTemplateApplication.GetFreightStr(product.Id, FreightTemplate, CurrentUser, product),                             //运费多少或免运费
                SendTime              = (FreightTemplate != null && !string.IsNullOrEmpty(FreightTemplate.SendTime) ? (FreightTemplate.SendTime + "h内发货") : ""), //运费模板发货时间
            };
            return(Json(_result));
        }
Example #6
0
        public ActionResult Index(int pageSize = 10, int pageNo = 1)
        {
            var model = _iShopService.GetUserConcernShops(CurrentUser.Id, pageNo, pageSize);
            var list  = new List <ShopConcernModel>();

            foreach (var m in model.Models)
            {
                var shop = ShopApplication.GetShop(m.ShopId);
                if (shop == null)
                {
                    continue;
                }

                ShopConcernModel concern = new ShopConcernModel();
                concern.FavoriteShopInfo.Id           = m.Id;
                concern.FavoriteShopInfo.Logo         = shop.Logo;
                concern.FavoriteShopInfo.ConcernTime  = m.Date;
                concern.FavoriteShopInfo.ShopId       = m.ShopId;
                concern.FavoriteShopInfo.ShopName     = shop.ShopName;
                concern.FavoriteShopInfo.ConcernCount = FavoriteApplication.GetFavoriteShopCountByShop(m.ShopId);
                concern.FavoriteShopInfo.ShopStatus   = shop.ShopStatus;
                #region 热门销售
                var sale = _iProductService.GetHotSaleProduct(m.ShopId, 10);
                if (sale != null)
                {
                    foreach (var item in sale)
                    {
                        concern.HotSaleProducts.Add(new HotProductInfo
                        {
                            ImgPath   = item.ImagePath,
                            Name      = item.ProductName,
                            Price     = item.MinSalePrice,
                            Id        = item.Id,
                            SaleCount = (int)(item.SaleCounts + item.VirtualSaleCounts)
                        });
                    }
                }
                #endregion

                #region 最新上架
                var newsale = _iProductService.GetNewSaleProduct(m.ShopId, 10);
                if (newsale != null && newsale.Count > 0)
                {
                    foreach (var item in newsale)
                    {
                        concern.NewSaleProducts.Add(new HotProductInfo
                        {
                            ImgPath   = item.ImagePath,
                            Name      = item.ProductName,
                            Price     = item.MinSalePrice,
                            Id        = item.Id,
                            SaleCount = (int)item.ConcernedCount
                        });
                    }
                }
                list.Add(concern);
                #endregion
            }
            PagingInfo info = new PagingInfo
            {
                CurrentPage  = pageNo,
                ItemsPerPage = pageSize,
                TotalItems   = model.Total
            };
            ViewBag.pageInfo = info;
            ViewBag.Keyword  = string.IsNullOrWhiteSpace(SiteSettings.SearchKeyword) ? SiteSettings.Keyword : SiteSettings.SearchKeyword;
            ViewBag.Keywords = SiteSettings.HotKeyWords;
            return(View(list));
        }
Example #7
0
        public JsonResult EditProfiles1(ShopProfileSteps1 shopProfileStep1)
        {
            //公司信息
            Himall.DTO.Shop shopInfo = ShopApplication.GetShop(CurrentSellerManager.ShopId);
            shopInfo.Id                   = CurrentSellerManager.ShopId;
            shopInfo.CompanyName          = shopProfileStep1.CompanyName;
            shopInfo.CompanyAddress       = shopProfileStep1.Address;
            shopInfo.CompanyRegionId      = shopProfileStep1.CityRegionId;
            shopInfo.CompanyRegionAddress = shopProfileStep1.Address;
            shopInfo.Stage                = Entities.ShopInfo.ShopStage.CompanyInfo;
            shopInfo.BusinessLicenseCert  = Request.Form["BusinessLicenseCert"];
            shopInfo.ProductCert          = Request.Form["ProductCert"];
            shopInfo.OtherCert            = Request.Form["OtherCert"];
            shopInfo.IDCard               = shopProfileStep1.IDCard;
            shopInfo.IDCardUrl            = shopProfileStep1.IDCardUrl;
            shopInfo.IDCardUrl2           = shopProfileStep1.IDCardUrl2;

            ShopApplication.UpdateShop(shopInfo);

            long uid = ShopApplication.GetShopManagers(CurrentSellerManager.ShopId);
            //管理员信息
            var mTheme = ShopApplication.GetSettled();
            var model  = MemberApplication.GetMemberAccountSafety(uid);

            if (!mTheme.SelfVerificationType.Equals(Himall.CommonModel.VerificationType.VerifyEmail) && shopProfileStep1.MemberPhone.Equals(""))
            {
                return(Json(new { success = false, msg = "必须认证手机!" }));
            }
            if (!mTheme.SelfVerificationType.Equals(Himall.CommonModel.VerificationType.VerifyPhone) && shopProfileStep1.MemberEmail.Equals(""))
            {
                return(Json(new { success = false, msg = "必须认证邮箱!" }));
            }

            //修改真实姓名
            var member = MemberApplication.GetMembers(uid);

            member.RealName = shopProfileStep1.RealName;
            MemberApplication.UpdateMember(member);

            //手机认证
            if (shopProfileStep1.MemberPhone != null && !shopProfileStep1.MemberPhone.Equals(model.Phone))
            {
                string pluginId = "Himall.Plugin.Message.SMS";
                int    result   = MemberApplication.CheckMemberCode(pluginId, shopProfileStep1.PhoneCode, shopProfileStep1.MemberPhone, uid);
                string strMsg   = "";
                switch (result)
                {
                case 0: strMsg = "手机验证码错误!"; break;

                case -1: strMsg = "此手机号已绑定!"; break;
                }
                if (!strMsg.Equals(""))
                {
                    return(Json(new { success = false, msg = strMsg }));
                }
            }

            //邮箱认证
            if (shopProfileStep1.MemberEmail != null && !shopProfileStep1.MemberEmail.ToString().Equals(model.Email))
            {
                string pluginId = "Himall.Plugin.Message.Email";
                int    result   = MemberApplication.CheckMemberCode(pluginId, shopProfileStep1.EmailCode, shopProfileStep1.MemberEmail, uid);
                string strMsg   = "";
                switch (result)
                {
                case 0: strMsg = "邮箱验证码错误!"; break;

                case -1: strMsg = "此邮箱已绑定!"; break;
                }
                if (!strMsg.Equals(""))
                {
                    return(Json(new { success = false, msg = strMsg }));
                }
            }


            ShopApplication.SetShopStage(Entities.ShopInfo.ShopStage.FinancialInfo, CurrentSellerManager.ShopId);//设置成功,则才是进入财务信息
            return(Json(new { success = true, msg = "成功!" }));
        }
Example #8
0
        /// <summary>
        /// 拼团活动详情
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Detail(long id)
        {
            FightGroupActiveModel data = FightGroupApplication.GetActive(id, false);

            if (data == null)
            {
                throw new MallException("错误的活动信息");
            }
            data.InitProductImages();
            // AutoMapper.Mapper.CreateMap<FightGroupActiveModel, FightGroupActiveDetailModel>();

            FightGroupActiveDetailModel model = data.Map <FightGroupActiveDetailModel>();
            decimal discount = 1M;

            if (CurrentUser != null)
            {
                discount = CurrentUser.MemberDiscount;
            }
            ViewBag.Discount = discount;
            var shopInfo = ShopApplication.GetShop(model.ShopId);

            ViewBag.IsSelf = shopInfo.IsSelf;

            //AutoMapper.Mapper.CreateMap<FightGroupActiveModel, FightGroupActiveResult>();
            //var fightGroupData = AutoMapper.Mapper.Map<FightGroupActiveResult>(model);

            model.ShareUrl   = string.Format("{0}/m-{1}/FightGroup/Detail/{2}", CurrentUrlHelper.CurrentUrlNoPort(), "WeiXin", data.Id);
            model.ShareTitle = data.ActiveStatus == FightGroupActiveStatus.WillStart ? "限时限量火拼 即将开始" : "限时限量火拼 正在进行";
            model.ShareImage = data.ProductDefaultImage;
            if (!string.IsNullOrWhiteSpace(model.ShareImage))
            {
                if (model.ShareImage.Substring(0, 4) != "http")
                {
                    model.ShareImage = MallIO.GetRomoteImagePath(model.ShareImage);
                }
            }

            model.ShareDesc = data.ProductName;
            if (!string.IsNullOrWhiteSpace(data.ProductShortDescription))
            {
                model.ShareDesc += ",(" + data.ProductShortDescription + ")";
            }
            if (model.ProductId > 0)
            {
                //统计商品浏览量、店铺浏览人数
                StatisticApplication.StatisticVisitCount(model.ProductId, model.ShopId);
            }

            var customerServices = CustomerServiceApplication.GetMobileCustomerServiceAndMQ(model.ShopId);

            ViewBag.CustomerServices = customerServices;
            var bonus = ServiceApplication.Create <IShopBonusService>().GetByShopId(model.ShopId);

            if (bonus != null)
            {
                model.BonusCount             = bonus.Count;
                model.BonusGrantPrice        = bonus.GrantPrice;
                model.BonusRandomAmountStart = bonus.RandomAmountStart;
                model.BonusRandomAmountEnd   = bonus.RandomAmountEnd;
            }
            var fullDiscount = FullDiscountApplication.GetOngoingActiveByProductId(id, model.ShopId);

            model.FullDiscount = fullDiscount;

            model.IsSaleCountOnOff = SiteSettingApplication.SiteSettings.ProductSaleCountOnOff == 1;                                //是否显示销量
            model.SaleVolume       = data.ActiveItems.Sum(d => d.BuyCount);                                                         //销量
            model.FreightTemplate  = FreightTemplateApplication.GetFreightTemplate(model.FreightTemplateId);                        //运费模板
            model.FreightStr       = FreightTemplateApplication.GetFreightStr(model.ProductId, model.FreightTemplate, CurrentUser); //运费或免运费

            return(View(model));
        }
Example #9
0
        public object GetUpdateToCart(string openId, string SkuID, int Quantity, int GiftID = 0)
        {
            //验证用户
            CheckUserLogin();
            var  cartHelper  = new CartHelper();
            long userId      = CurrentUser != null ? CurrentUser.Id : 0;
            var  skus        = cartHelper.GetCart(userId);
            var  oldQuantity = GetCartProductQuantity(skus, skuId: SkuID);

            oldQuantity = oldQuantity + Quantity;

            long productId = 0;
            var  skuItem   = skus.Items.FirstOrDefault(i => i.SkuId == SkuID);

            if (null == skuItem)
            {
                var sku = ProductManagerApplication.GetSKU(SkuID);
                if (null == sku)
                {
                    return(Json(ErrorResult <dynamic>("错误的参数:SkuId")));
                }
                productId = sku.ProductId;
            }
            else
            {
                productId = skuItem.ProductId;
            }
            var ladderPrice = 0m;
            var product     = ProductManagerApplication.GetProduct(productId);

            if (product != null)
            {
                if (product.MaxBuyCount > 0 && oldQuantity > product.MaxBuyCount && !product.IsOpenLadder)
                {
                    cartHelper.UpdateCartItem(SkuID, product.MaxBuyCount, userId);
                    return(Json(ErrorResult <dynamic>(string.Format("每个ID限购{0}件", product.MaxBuyCount), new { stock = product.MaxBuyCount })));
                }
            }


            SKUInfo skuinfo = OrderApplication.GetSkuByID(SkuID);

            if (skuinfo.Stock < oldQuantity)
            {
                cartHelper.UpdateCartItem(SkuID, Convert.ToInt32(skuinfo.Stock), userId);
                return(Json(ErrorResult <dynamic>("库存不足", new { stock = skuinfo.Stock })));
            }

            cartHelper.UpdateCartItem(SkuID, oldQuantity, userId);
            //调用查询购物车数据

            #region 阶梯价--张宇枫
            var isOpenLadder = product.IsOpenLadder;
            if (isOpenLadder)
            {
                var shop = ShopApplication.GetShop(product.ShopId);
                var groupCartByProduct = cartHelper.GetCart(userId).Items.Where(item => item.ShopBranchId == 0).GroupBy(i => i.ProductId).ToList();
                //var groupCartByProduct = skus.Items.Where(item => item.ShopBranchId == 0).Select(c =>
                //{
                //    var cItem = new Mall.Entities.ShoppingCartItem();
                //    var skuInfo = ServiceProvider.Instance<IProductService>.Create.GetSku(c.SkuId);
                //    if (skuInfo != null)
                //        cItem = c;
                //    return cItem;
                //}).GroupBy(i => i.ProductId).ToList();

                var quantity =
                    groupCartByProduct.Where(i => i.Key == productId)
                    .ToList()
                    .Sum(cartitem => cartitem.Sum(i => i.Quantity));
                ladderPrice = ProductManagerApplication.GetProductLadderPrice(productId, quantity);
                if (shop.IsSelf)
                {
                    ladderPrice = CurrentUser.MemberDiscount * ladderPrice;
                }
            }
            #endregion
            return(Json(new { Price = ladderPrice.ToString("F2"), ProductId = productId, IsOpenLadder = isOpenLadder ? 1 : 0 }));
        }
Example #10
0
        public object GetCart(long shopBranchId)
        {
            //CheckUserLogin();
            long userId = 0;
            //会员折扣
            decimal discount = 1.0M;//默认折扣为1(没有折扣)

            if (CurrentUser != null)
            {
                userId   = CurrentUser.Id;
                discount = CurrentUser.MemberDiscount;
            }
            var cart       = GetCart(userId, shopBranchId);
            var shopBranch = ShopBranchApplication.GetShopBranchById(shopBranchId);

            if (shopBranch == null)
            {
                throw new MallException("门店库存不足");
            }
            var     stores    = cart.Items.Where(d => d.ShopBranchId > 0).OrderByDescending(d => d.AddTime).Select(d => d.ShopBranchId).GroupBy(d => d);
            decimal prodPrice = 0.0M;//优惠价格
            //var rets = new List<CartStoreModel>();
            var _store = new CartStoreModel();

            _store.ShopBranchId   = shopBranch.Id;
            _store.ShopId         = shopBranch.ShopId;
            _store.ShopBranchName = shopBranch.ShopBranchName;
            _store.Status         = shopBranch.Status.GetHashCode();
            _store.DeliveFee      = shopBranch.DeliveFee;
            _store.DeliveTotalFee = shopBranch.DeliveTotalFee;
            _store.FreeMailFee    = shopBranch.FreeMailFee;
            var product = cart.Items.Where(d => d.ShopBranchId == shopBranch.Id).OrderBy(s => s.Status).ThenByDescending(o => o.AddTime).ToList();

            _store.Products = new List <CartStoreProduct>();
            foreach (var pitem in product)
            {
                var pro           = ProductManagerApplication.GetProduct(pitem.ProductId);
                var shopbranchsku = ShopBranchApplication.GetSkusByIds(_store.ShopBranchId, new List <string> {
                    pitem.SkuId
                }).FirstOrDefault();
                var     shop       = ShopApplication.GetShop(pro.ShopId);
                var     vshop      = VshopApplication.GetVShopByShopId(pro.ShopId);
                DTO.SKU sku        = ProductManagerApplication.GetSKU(pitem.SkuId);
                string  skuDetails = "";
                if (null != shop && sku != null)
                {
                    prodPrice = sku.SalePrice;
                    if (shop.IsSelf)
                    {
                        //官方自营店才计算会员折扣
                        prodPrice = sku.SalePrice * discount;
                    }
                    prodPrice = decimal.Round(prodPrice, 2, MidpointRounding.AwayFromZero);

                    var typeInfo = TypeApplication.GetProductType(pro.TypeId);
                    skuDetails = "";
                    if (!string.IsNullOrWhiteSpace(sku.Size))
                    {
                        if (!string.IsNullOrWhiteSpace(skuDetails))
                        {
                            skuDetails += "、";
                        }
                        skuDetails += sku.Size;
                    }
                    if (!string.IsNullOrWhiteSpace(sku.Color))
                    {
                        if (!string.IsNullOrWhiteSpace(skuDetails))
                        {
                            skuDetails += "、";
                        }
                        skuDetails += sku.Color;
                    }
                    if (!string.IsNullOrWhiteSpace(sku.Version))
                    {
                        if (!string.IsNullOrWhiteSpace(skuDetails))
                        {
                            skuDetails += "、";
                        }
                        skuDetails += sku.Version;
                    }
                    string colorAlias   = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias;
                    string sizeAlias    = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias;
                    string versionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias;
                    if (pro != null)
                    {
                        colorAlias   = !string.IsNullOrWhiteSpace(pro.ColorAlias) ? pro.ColorAlias : colorAlias;
                        sizeAlias    = !string.IsNullOrWhiteSpace(pro.SizeAlias) ? pro.SizeAlias : sizeAlias;
                        versionAlias = !string.IsNullOrWhiteSpace(pro.VersionAlias) ? pro.VersionAlias : versionAlias;
                    }
                    var _product = new CartStoreProduct
                    {
                        ShopBranchId = shopBranchId,
                        CartItemId   = pitem.Id,
                        SkuId        = pitem.SkuId,
                        Id           = pro.Id,
                        ProductName  = pro.ProductName,
                        Price        = prodPrice,
                        Count        = pitem.Quantity,
                        Stock        = shopbranchsku == null ? 0 : shopbranchsku.Stock,
                        //阶梯价商品在门店购物车自动下架
                        Status       = ProductManagerApplication.GetProductShowStatus(pro, sku, 1, shopBranch, shopbranchsku),//0:正常;1:冻结;2:库存不足
                        SkuDetails   = skuDetails,
                        ColorAlias   = colorAlias,
                        SizeAlias    = sizeAlias,
                        VersionAlias = versionAlias,
                        Size         = sku.Size,
                        Color        = sku.Color,
                        Version      = sku.Version,
                        AddTime      = pitem.AddTime,
                        DefaultImage = MallIO.GetRomoteProductSizeImage(pro.ImagePath, 1, 500)
                    };
                    _store.Products.Add(_product);
                }
            }
            _store.Amount     = (_store.Products != null && _store.Products.Count > 0) ? _store.Products.Where(x => x.Status == 0).Sum(s => s.Price * s.Count) : 0;
            _store.TotalCount = (_store.Products != null && _store.Products.Count > 0) ? _store.Products.Where(x => x.Status == 0).Sum(s => s.Count) : 0;
            if (_store.Products.Count > 0)
            {//有商品数据,才返回门店信息
                _store.Products = _store.Products.OrderBy(p => p.Status).ThenByDescending(p => p.AddTime).ToList();
                //rets.Add(_store);
            }
            return(Json(_store));
        }
Example #11
0
        public object GetOrderDetail(long id)
        {
            CheckUserLogin();
            OrderInfo order = ServiceProvider.Instance <IOrderService> .Create.GetOrder(id, CurrentUser.Id);

            var    orderService       = ServiceProvider.Instance <IOrderService> .Create;
            var    bonusService       = ServiceProvider.Instance <IShopBonusService> .Create;
            var    orderRefundService = ServiceProvider.Instance <IRefundService> .Create;
            var    bonusmodel         = bonusService.GetGrantByUserOrder(id, CurrentUser.Id);
            bool   hasBonus           = bonusmodel != null ? true : false;
            string shareHref          = "";
            string shareTitle         = "";
            string shareDetail        = "";
            string shareImg           = "";

            if (hasBonus)
            {
                shareHref = CurrentUrlHelper.CurrentUrlNoPort() + "/m-weixin/shopbonus/index/" + bonusService.GetGrantIdByOrderId(id);
                var bonus = ShopBonusApplication.GetBonus(bonusmodel.ShopBonusId);
                shareTitle  = bonus.ShareTitle;
                shareDetail = bonus.ShareDetail;
                shareImg    = HimallIO.GetRomoteImagePath(bonus.ShareImg);
            }
            var vshop = ServiceProvider.Instance <IVShopService> .Create.GetVShopByShopId(order.ShopId);

            var customerServices = CustomerServiceApplication.GetMobileCustomerServiceAndMQ(order.ShopId);

            var shop        = ShopApplication.GetShop(order.ShopId);
            var orderItems  = OrderApplication.GetOrderItemsByOrderId(order.Id);
            var products    = ProductManagerApplication.GetProducts(orderItems.Select(p => p.ProductId));
            var refunds     = OrderApplication.GetOrderRefundsByOrder(order.Id);        //获取订单商品项数据
            var orderDetail = new
            {
                ShopId     = shop.Id,
                ShopName   = shop.ShopName,
                OrderItems = orderItems.Select(item =>
                {
                    var product  = products.FirstOrDefault(p => p.Id == item.ProductId);
                    var typeInfo = TypeApplication.GetType(product.TypeId);

                    string colorAlias   = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias;
                    string sizeAlias    = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias;
                    string versionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias;
                    if (product != null)
                    {
                        colorAlias   = !string.IsNullOrWhiteSpace(product.ColorAlias) ? product.ColorAlias : colorAlias;
                        sizeAlias    = !string.IsNullOrWhiteSpace(product.SizeAlias) ? product.SizeAlias : sizeAlias;
                        versionAlias = !string.IsNullOrWhiteSpace(product.VersionAlias) ? product.VersionAlias : versionAlias;
                    }
                    var itemrefund   = refunds.FirstOrDefault(d => d.OrderItemId == item.Id && d.RefundMode != OrderRefundInfo.OrderRefundMode.OrderRefund);
                    int?itemrefstate = (itemrefund == null ? null : (int?)itemrefund.SellerAuditStatus);
                    itemrefstate     = (itemrefstate > 4 ? (int?)itemrefund.ManagerConfirmStatus : itemrefstate);
                    var IsCanRefund  = OrderApplication.CanRefund(order, itemrefstate, itemId: item.Id);
                    return(new
                    {
                        ItemId = item.Id,
                        ProductId = item.ProductId,
                        ProductName = item.ProductName,
                        Count = item.Quantity,
                        Price = item.SalePrice,
                        ProductImage = Core.HimallIO.GetRomoteProductSizeImage(product.RelativePath, 1, (int)Himall.CommonModel.ImageSize.Size_100),
                        color = item.Color,
                        size = item.Size,
                        version = item.Version,
                        IsCanRefund = IsCanRefund,
                        ColorAlias = colorAlias,
                        SizeAlias = sizeAlias,
                        VersionAlias = versionAlias,
                        EnabledRefundAmount = item.EnabledRefundAmount,
                        OrderRefundId = (itemrefund == null ? 0 : itemrefund.Id),
                        RefundStats = itemrefstate
                    });
                })
            };
            //取拼团订单状态
            var fightGroupOrderInfo = ServiceProvider.Instance <IFightGroupService> .Create.GetFightGroupOrderStatusByOrderId(order.Id);

            var _ordrefobj = orderRefundService.GetOrderRefundByOrderId(order.Id) ?? new OrderRefundInfo {
                Id = 0
            };

            if (order.OrderStatus != OrderInfo.OrderOperateStatus.WaitDelivery && order.OrderStatus != OrderInfo.OrderOperateStatus.WaitSelfPickUp)
            {
                _ordrefobj = new OrderRefundInfo {
                    Id = 0
                };
            }
            int?ordrefstate = (_ordrefobj == null ? null : (int?)_ordrefobj.SellerAuditStatus);

            ordrefstate = (ordrefstate > 4 ? (int?)_ordrefobj.ManagerConfirmStatus : ordrefstate);

            var hasAppendComment = ServiceProvider.Instance <ICommentService> .Create.HasAppendComment(orderItems.FirstOrDefault().Id);

            var orderModel = new
            {
                Id                 = order.Id,
                OrderType          = order.OrderType,
                OrderTypeName      = order.OrderType.ToDescription(),
                Status             = order.OrderStatus.ToDescription(),
                JoinStatus         = fightGroupOrderInfo == null ? -2 : fightGroupOrderInfo.JoinStatus,
                ShipTo             = order.ShipTo,
                Phone              = order.CellPhone,
                Address            = order.RegionFullName + " " + order.Address,
                HasExpressStatus   = !string.IsNullOrWhiteSpace(order.ShipOrderNumber),
                ExpressCompanyName = order.ExpressCompanyName,
                Freight            = order.Freight,
                Tax                = order.Tax,
                IntegralDiscount   = order.IntegralDiscount,
                RealTotalAmount    = order.OrderTotalAmount,
                CapitalAmount      = order.CapitalAmount,
                RefundTotalAmount  = order.RefundTotalAmount,
                ProductTotalAmount = order.ProductTotalAmount,
                OrderPayAmount     = order.OrderPayAmount,//订单需要第三方支付的金额
                PaymentTypeName    = PaymentApplication.GetPaymentTypeDescById(order.PaymentTypeGateway) ?? order.PaymentTypeName,
                PaymentTypeDesc    = order.PaymentTypeDesc,
                OrderDate          = order.OrderDate.ToString("yyyy-MM-dd HH:mm:ss"),
                ShopName           = order.ShopName,
                VShopId            = vshop == null ? 0 : vshop.Id,
                commentCount       = OrderApplication.GetOrderCommentCount(order.Id),
                ShopId             = order.ShopId,
                orderStatus        = (int)order.OrderStatus,
                //Invoice = order.InvoiceType.ToDescription(),
                //InvoiceValue = (int)order.InvoiceType,
                //InvoiceContext = order.InvoiceContext,
                //InvoiceTitle = order.InvoiceTitle,
                //InvoiceCode = order.InvoiceCode,
                PaymentType         = order.PaymentType.ToDescription(),
                PaymentTypeValue    = (int)order.PaymentType,
                FullDiscount        = order.FullDiscount,
                DiscountAmount      = order.DiscountAmount,
                OrderRemarks        = string.IsNullOrEmpty(order.OrderRemarks) ? "" : order.OrderRemarks,
                HasBonus            = hasBonus,
                ShareHref           = shareHref,
                ShareTitle          = shareTitle,
                ShareDetail         = shareDetail,
                ShareImg            = shareImg,
                IsCanRefund         = !(orderDetail.OrderItems.Any(e => e.IsCanRefund == true)) && OrderApplication.CanRefund(order, ordrefstate, null),
                RefundStats         = ordrefstate,
                OrderRefundId       = _ordrefobj.Id > 0 ? _ordrefobj.Id : 0,
                EnabledRefundAmount = order.OrderEnabledRefundAmount,
                HasAppendComment    = hasAppendComment,
                SelfTake            = order.DeliveryType == Himall.CommonModel.DeliveryType.SelfTake ? 1 : 0,
                OrderInvoice        = OrderApplication.GetOrderInvoiceInfo(order.Id)
            };

            #region 门店配送信息
            Himall.DTO.ShopBranch storeInfo = null;
            if (order.ShopBranchId > 0)
            {
                storeInfo = ShopBranchApplication.GetShopBranchById(order.ShopBranchId);
            }
            #endregion
            #region 虚拟订单信息
            VirtualProductInfo virtualProductInfo = null;
            int            validityType = 0; string startDate = string.Empty, endDate = string.Empty;
            List <dynamic> orderVerificationCodes = null;
            List <dynamic> virtualOrderItemInfos  = null;
            bool           isCanRefundVirtual     = false;
            if (order.OrderType == OrderInfo.OrderTypes.Virtual)
            {
                var orderItemInfo = orderItems.FirstOrDefault();
                if (orderItemInfo != null)
                {
                    virtualProductInfo = ProductManagerApplication.GetVirtualProductInfoByProductId(orderItemInfo.ProductId);
                    if (virtualProductInfo != null)
                    {
                        validityType = virtualProductInfo.ValidityType ? 1 : 0;
                        if (validityType == 1)
                        {
                            startDate = virtualProductInfo.StartDate.Value.ToString("yyyy-MM-dd");
                            endDate   = virtualProductInfo.EndDate.Value.ToString("yyyy-MM-dd");
                        }
                    }
                    var codes = OrderApplication.GetOrderVerificationCodeInfosByOrderIds(new List <long>()
                    {
                        order.Id
                    });
                    orderVerificationCodes = codes.Select(p =>
                    {
                        return(new
                        {
                            VerificationCode = Regex.Replace(p.VerificationCode, @"(\d{4})", "$1 "),
                            Status = p.Status,
                            StatusText = p.Status.ToDescription(),
                            QRCode = GetQRCode(p.VerificationCode)
                        });
                    }).ToList <dynamic>();

                    var virtualItems = OrderApplication.GetVirtualOrderItemInfosByOrderId(order.Id);
                    virtualOrderItemInfos = virtualItems.Select(p =>
                    {
                        return(new
                        {
                            VirtualProductItemName = p.VirtualProductItemName,
                            Content = ReplaceImage(p.Content, p.VirtualProductItemType),
                            VirtualProductItemType = p.VirtualProductItemType
                        });
                    }).ToList <dynamic>();
                }
            }
            if (order.OrderStatus == Himall.Entities.OrderInfo.OrderOperateStatus.WaitVerification)
            {
                if (virtualProductInfo != null)
                {
                    if (virtualProductInfo.SupportRefundType == 2)
                    {
                        isCanRefundVirtual = true;
                    }
                    else if (virtualProductInfo.SupportRefundType == 1)
                    {
                        if (virtualProductInfo.EndDate.Value > DateTime.Now)
                        {
                            isCanRefundVirtual = true;
                        }
                    }
                    else if (virtualProductInfo.SupportRefundType == 3)
                    {
                        isCanRefundVirtual = false;
                    }

                    if (isCanRefundVirtual)
                    {
                        long num = orderVerificationCodes.Where(a => a.Status == OrderInfo.VerificationCodeStatus.WaitVerification).Count();
                        if (num > 0)
                        {
                            isCanRefundVirtual = true;
                        }
                        else
                        {
                            isCanRefundVirtual = false;
                        }
                    }
                }
            }
            #endregion
            #region 虚拟订单核销地址信息
            string shipperAddress = string.Empty, shipperTelPhone = string.Empty;
            if (order.OrderType == OrderInfo.OrderTypes.Virtual)
            {
                if (order.ShopBranchId > 0 && storeInfo != null)
                {
                    shipperAddress  = RegionApplication.GetFullName(storeInfo.AddressId) + " " + storeInfo.AddressDetail;
                    shipperTelPhone = storeInfo.ContactPhone;
                }
                else
                {
                    var verificationShipper = ShopShippersApplication.GetDefaultVerificationShipper(order.ShopId);
                    if (verificationShipper != null)
                    {
                        shipperAddress  = RegionApplication.GetFullName(verificationShipper.RegionId) + " " + verificationShipper.Address;
                        shipperTelPhone = verificationShipper.TelPhone;
                    }
                }
            }
            #endregion
            return(new
            {
                success = true,
                Order = orderModel,
                OrderItem = orderDetail.OrderItems,
                StoreInfo = storeInfo,
                CustomerServices = customerServices,
                ValidityType = validityType,
                StartDate = startDate,
                EndDate = endDate,
                OrderVerificationCodes = orderVerificationCodes,
                VirtualOrderItemInfos = virtualOrderItemInfos,
                IsCanRefundVirtual = isCanRefundVirtual,
                ShipperAddress = shipperAddress,
                ShipperTelPhone = shipperTelPhone
            });
        }
        public object GetUser(string userName, string password)
        {
            var siteSettings = SiteSettingApplication.SiteSettings;

            //普通登录
            if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(password))
            {
                //商家登录也放在这里,因为商家app和门店app为同一个并且没做登录区分,只能通过登录后才能知道是登录的商家还是门店管理员
                var     seller = ManagerApplication.Login(userName, password);
                dynamic result = SuccessResult();
                if (seller != null)
                {
                    if (!siteSettings.IsOpenShopApp)
                    {
                        return(ErrorResult("未授权商家APP"));
                    }

                    var shop = ShopApplication.GetShop(seller.ShopId);
                    if (shop != null && shop.ShopStatus == Entities.ShopInfo.ShopAuditStatus.HasExpired)
                    {
                        return(ErrorResult("店铺已过期"));
                    }
                    if (null != shop && shop.ShopStatus == Entities.ShopInfo.ShopAuditStatus.Freeze)
                    {
                        return(ErrorResult("店铺已冻结"));
                    }
                    if (shop != null && shop.ShopStatus != Entities.ShopInfo.ShopAuditStatus.Open)
                    {
                        return(ErrorResult("无效的账号"));
                    }
                    if (seller.RoleId != 0)
                    {
                        var model = RoleApplication.GetRoleInfo(seller.RoleId);
                        //TODO:FG 权限验证 实现逻辑待优化
                        var SellerPrivileges = RoleApplication.GetSellerPrivileges(seller.RoleId);
                        if (!SellerPermission.CheckPermissions(SellerPrivileges, "App", "App"))
                        {
                            return(ErrorResult("您没有登录商家APP的权限"));
                        }
                    }
                    result         = SuccessResult();
                    result.UserKey = UserCookieEncryptHelper.Encrypt(seller.Id, CookieKeysCollection.USERROLE_SELLERADMIN);
                    result.type    = ManagerType.ShopManager;
                    return(result);
                }
                var member = ShopBranchApplication.ShopBranchLogin(userName, password);
                if (member == null)
                {
                    return(ErrorResult("用户名或密码错误"));
                }
                var shopbranch = ShopBranchApplication.GetShopBranchById(member.ShopBranchId);
                if (shopbranch != null)
                {
                    if (shopbranch.Status == ShopBranchStatus.Freeze)
                    {
                        return(ErrorResult("门店已被冻结"));
                    }
                    if (!siteSettings.IsOpenStore)
                    {
                        return(ErrorResult("未授权门店模块"));
                    }
                }
                var membershop = ShopApplication.GetShop(shopbranch.ShopId);
                if (membershop != null && membershop.ShopStatus == Entities.ShopInfo.ShopAuditStatus.HasExpired)
                {
                    return(ErrorResult("门店所属店铺已过期"));
                }
                if (null != membershop && membershop.ShopStatus == Entities.ShopInfo.ShopAuditStatus.Freeze)
                {
                    return(ErrorResult("门店所属店铺已冻结"));
                }
                if (member != null)
                {
                    result         = SuccessResult();
                    result.UserKey = UserCookieEncryptHelper.Encrypt(member.Id, CookieKeysCollection.USERROLE_USER);
                    result.type    = ManagerType.ShopBranchManager;
                    return(result);
                }
            }
            return(ErrorResult("用户名或密码不能为空"));
        }
Example #13
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));
        }
Example #14
0
        public JsonResult UpdateCartItem(string skuId, int count)
        {
            //TODO:FG 购物车改造 购物车数量变更
            long userId     = CurrentUser != null ? CurrentUser.Id : 0;
            var  cartHelper = new CartHelper();
            var  skucart    = cartHelper.GetCart(userId).Items.FirstOrDefault(d => d.SkuId == skuId);
            bool isadd      = true;

            if (skucart != null)
            {
                if (skucart.Quantity > count)
                {
                    isadd = false;
                }
            }

            Entities.SKUInfo skuinfo = OrderApplication.GetSkuByID(skuId);
            if (skuinfo.Stock < count && isadd)
            {
                return(Json(new { success = false, msg = "库存不足", stock = skuinfo.Stock }));
            }

            var product = ProductManagerApplication.GetProduct(skuinfo.ProductId);

            if (product != null)
            {
                if (product.MaxBuyCount > 0 && count > product.MaxBuyCount && !product.IsOpenLadder)
                {
                    return(Json(new { success = false, msg = string.Format("每个ID限购{0}件", product.MaxBuyCount), stock = product.MaxBuyCount }));
                }
            }

            cartHelper.UpdateCartItem(skuId, count, userId);

            #region 购物车修改数量阶梯价变动--张宇枫
            //获取产品详情
            var price = 0m;
            if (product.IsOpenLadder)
            {
                var shop = ShopApplication.GetShop(product.ShopId);

                var groupCartByProduct = cartHelper.GetCart(userId).Items.Where(item => item.ShopBranchId == 0).Select(c =>
                {
                    var cItem   = new Mall.Entities.ShoppingCartItem();
                    var skuInfo = _iProductService.GetSku(c.SkuId);
                    if (skuInfo != null)
                    {
                        cItem = c;
                    }
                    return(cItem);
                }).GroupBy(i => i.ProductId).ToList();
                var quantity = groupCartByProduct.Where(i => i.Key == product.Id).ToList().Sum(cartitem => cartitem.Sum(i => i.Quantity));

                decimal discount = 1M;
                if (CurrentUser != null)
                {
                    discount = CurrentUser.MemberDiscount;
                }
                price = ProductManagerApplication.GetProductLadderPrice(product.Id, quantity);
                if (shop.IsSelf)
                {
                    price = price * discount;
                }
            }

            #endregion

            return(SuccessResult <dynamic>(data: new { saleprice = price.ToString("F2"), productid = product.Id, isOpenLadder = product.IsOpenLadder }));
        }
        /// <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(ErrorResult("无法定位到商家!"));
            }

            //if (query.ShopCategoryId <= 0)
            //    return ErrorResult("无法定位到商家分类!");
            if (TypeHelper.ObjectToInt(shopCategoryId, 0) > 0)
            {
                query.ShopCategoryId = TypeHelper.ObjectToInt(shopCategoryId);
            }

            if (query.ShopBranchId <= 0)
            {
                return(ErrorResult("无法定位到门店!"));
            }

            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 + Himall.Core.Helper.TypeHelper.ObjectToInt(item.VirtualSaleCounts),                         //销量统计没有考虑订单支付完成。
                    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,
                isSaleCountOnOff = SiteSettingApplication.SiteSettings.ProductSaleCountOnOff == 1
            };

            return(result);
        }
Example #16
0
        public JsonResult PendingSettlementList(StatisticsPendingSettlementQuery query)
        {
            var result = BillingApplication.StatisticsPendingSettlementOrders(query);

            if (result.Models != null)
            {
                foreach (var item in result.Models)
                {
                    item.ShopName = ShopApplication.GetShop(item.ShopId) == null ? item.ShopName : ShopApplication.GetShop(item.ShopId).ShopName;
                }
            }
            return(Json(new { rows = result.Models, result.Total }, true));
        }
Example #17
0
        public JsonResult EditProfile1(ShopProfileStep1 shopProfileStep1)
        {
            if (ShopApplication.ExistCompanyName(shopProfileStep1.CompanyName, CurrentSellerManager.ShopId))
            {
                return(Json(new { success = false, msg = "该公司名已存在!" }));
            }
            if (ShopApplication.ExistBusinessLicenceNumber(shopProfileStep1.BusinessLicenceNumber, CurrentSellerManager.ShopId))
            {
                return(Json(new { success = false, msg = "该营业执照号已存在!" }));
            }

            //公司信息
            Himall.DTO.Shop shopInfo = ShopApplication.GetShop(CurrentSellerManager.ShopId);
            shopInfo.Id                         = CurrentSellerManager.ShopId;
            shopInfo.CompanyName                = shopProfileStep1.CompanyName;
            shopInfo.CompanyAddress             = shopProfileStep1.Address;
            shopInfo.CompanyRegionId            = shopProfileStep1.CityRegionId;
            shopInfo.CompanyRegionAddress       = shopProfileStep1.Address;
            shopInfo.CompanyPhone               = shopProfileStep1.Phone;
            shopInfo.CompanyEmployeeCount       = (CompanyEmployeeCount)shopProfileStep1.EmployeeCount;
            shopInfo.CompanyRegisteredCapital   = shopProfileStep1.RegisterMoney;
            shopInfo.ContactsName               = shopProfileStep1.ContactName;
            shopInfo.ContactsPhone              = shopProfileStep1.ContactPhone;
            shopInfo.ContactsEmail              = shopProfileStep1.Email;
            shopInfo.BusinessLicenceNumber      = shopProfileStep1.BusinessLicenceNumber;
            shopInfo.BusinessLicenceRegionId    = shopProfileStep1.BusinessLicenceArea;
            shopInfo.BusinessLicenceStart       = shopProfileStep1.BusinessLicenceValidStart;
            shopInfo.BusinessLicenceEnd         = shopProfileStep1.BusinessLicenceValidEnd;
            shopInfo.BusinessSphere             = shopProfileStep1.BusinessSphere;
            shopInfo.BusinessLicenceNumberPhoto = shopProfileStep1.BusinessLicenceNumberPhoto;
            shopInfo.OrganizationCode           = shopProfileStep1.OrganizationCode;
            shopInfo.OrganizationCodePhoto      = shopProfileStep1.OrganizationCodePhoto;
            shopInfo.GeneralTaxpayerPhot        = shopProfileStep1.GeneralTaxpayerPhoto;
            shopInfo.Stage                      = ShopInfo.ShopStage.FinancialInfo;
            shopInfo.BusinessLicenseCert        = Request.Form["BusinessLicenseCert"];
            shopInfo.ProductCert                = Request.Form["ProductCert"];
            shopInfo.OtherCert                  = Request.Form["OtherCert"];
            shopInfo.legalPerson                = shopProfileStep1.legalPerson;
            shopInfo.CompanyFoundingDate        = shopProfileStep1.CompanyFoundingDate;
            ShopApplication.UpdateShop(shopInfo);

            //管理员信息
            long uid   = ShopApplication.GetShopManagers(CurrentSellerManager.ShopId);
            var  model = MemberApplication.GetMemberAccountSafety(uid);

            if (shopProfileStep1.MemberPhone.Equals(""))
            {
                return(Json(new { success = false, msg = "必须认证手机!" }));
            }

            //修改真实姓名
            var member = MemberApplication.GetMembers(uid);

            member.RealName = shopProfileStep1.RealName;
            MemberApplication.UpdateMember(member);

            //手机认证
            if (!shopProfileStep1.MemberPhone.Equals(model.Phone))
            {
                string pluginId = "Himall.Plugin.Message.SMS";
                int    result   = MemberApplication.CheckMemberCode(pluginId, shopProfileStep1.PhoneCode, shopProfileStep1.MemberPhone, uid);
                string strMsg   = "";
                switch (result)
                {
                case 0: strMsg = "手机验证码错误!"; break;

                case -1: strMsg = "此手机号已绑定!"; break;
                }
                if (!strMsg.Equals(""))
                {
                    return(Json(new { success = false, msg = strMsg }));
                }
            }
            return(Json(new { success = true, msg = "成功!" }));
        }
Example #18
0
        /// <summary>
        /// 拼团活动商品详情
        /// </summary>
        /// <param name="id">拼团活动ID</param>
        /// /// <param name="grouId">团活动ID</param>
        /// <returns></returns>
        public object GetActiveDetail(long id, long grouId = 0, bool isFirst = true, string ids = "")
        {
            var userList = new List <FightGroupOrderInfo>();
            var data     = ServiceProvider.Instance <IFightGroupService> .Create.GetActive(id, true, true);

            Mapper.CreateMap <FightGroupActiveInfo, FightGroupActiveModel>();
            //规格映射
            Mapper.CreateMap <FightGroupActiveItemInfo, FightGroupActiveItemModel>();


            FightGroupActiveModel result = Mapper.Map <FightGroupActiveInfo, FightGroupActiveModel>(data);

            if (result != null)
            {
                result.IsEnd = true;
                if (data.EndTime.Value.Date >= DateTime.Now.Date)
                {
                    result.IsEnd = false;
                }
                //商品图片地址修正
                result.ProductDefaultImage = HimallIO.GetRomoteProductSizeImage(data.ProductImgPath, 1, (int)ImageSize.Size_350);
                result.ProductImgPath      = HimallIO.GetRomoteProductSizeImage(data.ProductImgPath, 1);
            }
            //result.InitProductImages();
            if (!string.IsNullOrWhiteSpace(result.ProductDefaultImage))
            {
                //补充图片地址
                for (var n = 2; n < 6; n++)
                {
                    var _imgurl = HimallIO.GetProductSizeImage(result.ProductDefaultImage, n, (int)ImageSize.Size_350);
                    if (this.IsExist(_imgurl))
                    {
                        result.ProductImages.Add(_imgurl);
                    }
                }
            }
            if (!string.IsNullOrWhiteSpace(result.IconUrl))
            {
                result.IconUrl = Himall.Core.HimallIO.GetRomoteImagePath(result.IconUrl);
            }
            bool IsUserEnter = false;
            long currentUser = 0;

            if (CurrentUser != null)
            {
                currentUser = CurrentUser.Id;
            }
            if (grouId > 0)//获取已参团的用户
            {
                userList = ServiceProvider.Instance <IFightGroupService> .Create.GetActiveUsers(id, grouId);

                foreach (var item in userList)
                {
                    item.Photo = !string.IsNullOrWhiteSpace(item.Photo) ? Core.HimallIO.GetRomoteImagePath(item.Photo) : "";
                    if (currentUser.Equals(item.OrderUserId))
                    {
                        IsUserEnter = true;
                    }
                }
            }
            #region 商品规格
            ProductInfo product = ServiceProvider.Instance <IProductService> .Create.GetProduct((long)result.ProductId);

            //if (product == null)
            //{
            //    throw new Himall.Core.HimallException("产品编号错误");
            //}

            //if (product.IsDeleted)
            //{
            //    throw new Himall.Core.HimallException("产品编号错误");
            //}


            ProductShowSkuInfoModel model = new ProductShowSkuInfoModel();
            model.MinSalePrice     = data.MiniSalePrice;
            model.ProductImagePath = string.IsNullOrWhiteSpace(data.ProductImgPath) ? "" : HimallIO.GetRomoteProductSizeImage(data.ProductImgPath, 1, (int)Himall.CommonModel.ImageSize.Size_350);

            List <SKUDataModel> skudata = data.ActiveItems.Where(d => d.ActiveStock > 0).Select(d => new SKUDataModel
            {
                SkuId     = d.SkuId,
                Color     = d.Color,
                Size      = d.Size,
                Version   = d.Version,
                Stock     = (int)d.ActiveStock,
                CostPrice = d.ProductCostPrice,
                SalePrice = d.ProductPrice,
                Price     = d.ActivePrice,
            }).ToList();

            ProductTypeInfo typeInfo = ServiceProvider.Instance <ITypeService> .Create.GetType(product.TypeId);

            string colorAlias   = (typeInfo == null || string.IsNullOrEmpty(typeInfo.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeInfo.ColorAlias;
            string sizeAlias    = (typeInfo == null || string.IsNullOrEmpty(typeInfo.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeInfo.SizeAlias;
            string versionAlias = (typeInfo == null || string.IsNullOrEmpty(typeInfo.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeInfo.VersionAlias;
            model.ColorAlias   = colorAlias;
            model.SizeAlias    = sizeAlias;
            model.VersionAlias = versionAlias;

            if (result.ActiveItems != null && result.ActiveItems.Count() > 0)
            {
                long colorId = 0, sizeId = 0, versionId = 0;
                var  skus = ServiceProvider.Instance <IProductService> .Create.GetSKUs((long)result.ProductId);

                foreach (var sku in result.ActiveItems)
                {
                    var specs = sku.SkuId.Split('_');
                    if (specs.Count() > 0)
                    {
                        if (long.TryParse(specs[1], out colorId))
                        {
                        }
                        if (colorId != 0)
                        {
                            if (!model.Color.Any(v => v.Value.Equals(sku.Color)))
                            {
                                var c = result.ActiveItems.Where(s => s.Color.Equals(sku.Color)).Sum(s => s.ActiveStock);
                                model.Color.Add(new ProductSKU
                                {
                                    //Name = "选择颜色",
                                    Name         = "选择" + colorAlias,
                                    EnabledClass = c != 0 ? " " : "disabled",
                                    //SelectedClass = !model.Color.Any(c1 => c1.SelectedClass.Equals("selected")) && c != 0 ? "selected" : "",
                                    SelectedClass = "",
                                    SkuId         = colorId,
                                    Value         = sku.Color,
                                    Img           = string.IsNullOrWhiteSpace(sku.ShowPic) ? "" : Core.HimallIO.GetRomoteImagePath(sku.ShowPic)
                                });
                            }
                        }
                    }
                    if (specs.Count() > 1)
                    {
                        if (long.TryParse(specs[2], out sizeId))
                        {
                        }
                        if (sizeId != 0)
                        {
                            if (!model.Size.Any(v => v.Value.Equals(sku.Size)))
                            {
                                var ss = result.ActiveItems.Where(s => s.Size.Equals(sku.Size)).Sum(s1 => s1.ActiveStock);
                                model.Size.Add(new ProductSKU
                                {
                                    //Name = "选择尺码",
                                    Name          = "选择" + sizeAlias,
                                    EnabledClass  = ss != 0 ? "enabled" : "disabled",
                                    SelectedClass = "",
                                    SkuId         = sizeId,
                                    Value         = sku.Size
                                });
                            }
                        }
                    }

                    if (specs.Count() > 2)
                    {
                        if (long.TryParse(specs[3], out versionId))
                        {
                        }
                        if (versionId != 0)
                        {
                            if (!model.Version.Any(v => v.Value.Equals(sku.Version)))
                            {
                                var v = result.ActiveItems.Where(s => s.Version.Equals(sku.Version)).Sum(s => s.ActiveStock);
                                model.Version.Add(new ProductSKU
                                {
                                    //Name = "选择规格",
                                    Name          = "选择" + versionAlias,
                                    EnabledClass  = v != 0 ? "enabled" : "disabled",
                                    SelectedClass = "",
                                    SkuId         = versionId,
                                    Value         = sku.Version
                                });
                            }
                        }
                    }
                }
            }
            #endregion

            var cashDepositModel = ServiceProvider.Instance <ICashDepositsService> .Create.GetCashDepositsObligation((long)result.ProductId);//提供服务(消费者保障、七天无理由、及时发货)

            var GroupsData = new List <FightGroupsListModel>();
            List <FightGroupBuildStatus> stlist = new List <FightGroupBuildStatus>();
            stlist.Add(FightGroupBuildStatus.Ongoing);
            GroupsData = FightGroupApplication.GetGroups(id, stlist, null, null, 1, 10).Models.ToList();
            foreach (var item in GroupsData)
            {
                TimeSpan mid = item.AddGroupTime.AddHours((double)item.LimitedHour) - DateTime.Now;
                item.Seconds         = (int)mid.TotalSeconds;
                item.EndHourOrMinute = item.ShowHourOrMinute(item.GetEndHour);
            }

            #region 商品评论
            ProductCommentShowModel modelSay = new ProductCommentShowModel();
            modelSay.ProductId = (long)result.ProductId;
            var productSay = ServiceProvider.Instance <IProductService> .Create.GetProduct((long)result.ProductId);

            modelSay.CommentList       = new List <ProductDetailCommentModel>();
            modelSay.IsShowColumnTitle = true;
            modelSay.IsShowCommentList = true;

            if (productSay == null)
            {
                //跳转到404页面
                throw new Core.HimallException("商品不存在");
            }
            if (product.IsDeleted)
            {
                //跳转到404页面
                throw new Core.HimallException("商品不存在");
            }
            var com      = product.Himall_ProductComments.Where(item => !item.IsHidden.HasValue || item.IsHidden.Value == false);
            var comCount = com.Count();
            modelSay.CommentCount = comCount;
            if (comCount > 0)
            {
                modelSay.CommentList = com.OrderByDescending(a => a.ReviewDate).Take(1).Select(c => new ProductDetailCommentModel
                {
                    Sku                = ServiceProvider.Instance <IProductService> .Create.GetSkuString(c.Himall_OrderItems.SkuId),
                    UserName           = c.UserName,
                    ReviewContent      = c.ReviewContent,
                    AppendContent      = c.AppendContent,
                    AppendDate         = c.AppendDate,
                    ReplyAppendContent = c.ReplyAppendContent,
                    ReplyAppendDate    = c.ReplyAppendDate,
                    FinshDate          = c.Himall_OrderItems.OrderInfo.FinishDate,
                    Images             = c.Himall_ProductCommentsImages.Where(a => a.CommentType == 0).Select(a => a.CommentImage).ToList(),
                    AppendImages       = c.Himall_ProductCommentsImages.Where(a => a.CommentType == 1).Select(a => a.CommentImage).ToList(),
                    ReviewDate         = c.ReviewDate,
                    ReplyContent       = string.IsNullOrWhiteSpace(c.ReplyContent) ? "暂无回复" : c.ReplyContent,
                    ReplyDate          = c.ReplyDate,
                    ReviewMark         = c.ReviewMark,
                    BuyDate            = c.Himall_OrderItems.OrderInfo.OrderDate
                }).ToList();
                foreach (var citem in modelSay.CommentList)
                {
                    if (citem.Images.Count > 0)
                    {
                        for (var _imgn = 0; _imgn < citem.Images.Count; _imgn++)
                        {
                            citem.Images[_imgn] = Himall.Core.HimallIO.GetImagePath(citem.Images[_imgn]);
                        }
                    }
                    if (citem.AppendImages.Count > 0)
                    {
                        for (var _imgn = 0; _imgn < citem.AppendImages.Count; _imgn++)
                        {
                            citem.AppendImages[_imgn] = Himall.Core.HimallIO.GetImagePath(citem.AppendImages[_imgn]);
                        }
                    }
                }
            }
            #endregion

            #region 店铺信息
            VShopShowShopScoreModel modelShopScore = new VShopShowShopScoreModel();
            modelShopScore.ShopId = result.ShopId;
            var shop = ServiceProvider.Instance <IShopService> .Create.GetShop(result.ShopId);

            if (shop == null)
            {
                throw new HimallException("错误的店铺信息");
            }

            modelShopScore.ShopName = shop.ShopName;

            #region 获取店铺的评价统计
            var shopStatisticOrderComments = ServiceProvider.Instance <IShopService> .Create.GetShopStatisticOrderComments(result.ShopId);

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

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

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

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

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

            decimal defaultValue = 5;

            modelShopScore.SellerServiceAttitude     = defaultValue;
            modelShopScore.SellerServiceAttitudePeer = defaultValue;
            modelShopScore.SellerServiceAttitudeMax  = defaultValue;
            modelShopScore.SellerServiceAttitudeMin  = defaultValue;

            //宝贝与描述
            if (productAndDescription != null && productAndDescriptionPeer != null && !shop.IsSelf)
            {
                modelShopScore.ProductAndDescription     = productAndDescription.CommentValue;
                modelShopScore.ProductAndDescriptionPeer = productAndDescriptionPeer.CommentValue;
                modelShopScore.ProductAndDescriptionMin  = productAndDescriptionMin.CommentValue;
                modelShopScore.ProductAndDescriptionMax  = productAndDescriptionMax.CommentValue;
            }
            else
            {
                modelShopScore.ProductAndDescription     = defaultValue;
                modelShopScore.ProductAndDescriptionPeer = defaultValue;
                modelShopScore.ProductAndDescriptionMin  = defaultValue;
                modelShopScore.ProductAndDescriptionMax  = defaultValue;
            }

            //卖家服务态度
            if (sellerServiceAttitude != null && sellerServiceAttitudePeer != null && !shop.IsSelf)
            {
                modelShopScore.SellerServiceAttitude     = sellerServiceAttitude.CommentValue;
                modelShopScore.SellerServiceAttitudePeer = sellerServiceAttitudePeer.CommentValue;
                modelShopScore.SellerServiceAttitudeMax  = sellerServiceAttitudeMax.CommentValue;
                modelShopScore.SellerServiceAttitudeMin  = sellerServiceAttitudeMin.CommentValue;
            }
            else
            {
                modelShopScore.SellerServiceAttitude     = defaultValue;
                modelShopScore.SellerServiceAttitudePeer = defaultValue;
                modelShopScore.SellerServiceAttitudeMax  = defaultValue;
                modelShopScore.SellerServiceAttitudeMin  = defaultValue;
            }
            //卖家发货速度
            if (sellerDeliverySpeedPeer != null && sellerDeliverySpeed != null && !shop.IsSelf)
            {
                modelShopScore.SellerDeliverySpeed     = sellerDeliverySpeed.CommentValue;
                modelShopScore.SellerDeliverySpeedPeer = sellerDeliverySpeedPeer.CommentValue;
                modelShopScore.SellerDeliverySpeedMax  = sellerDeliverySpeedMax != null ? sellerDeliverySpeedMax.CommentValue : 0;
                modelShopScore.sellerDeliverySpeedMin  = sellerDeliverySpeedMin != null ? sellerDeliverySpeedMin.CommentValue : 0;
            }
            else
            {
                modelShopScore.SellerDeliverySpeed     = defaultValue;
                modelShopScore.SellerDeliverySpeedPeer = defaultValue;
                modelShopScore.SellerDeliverySpeedMax  = defaultValue;
                modelShopScore.sellerDeliverySpeedMin  = defaultValue;
            }
            #endregion

            modelShopScore.ProductNum = ServiceProvider.Instance <IProductService> .Create.GetShopOnsaleProducts(result.ShopId);

            modelShopScore.IsFavoriteShop    = false;
            modelShopScore.FavoriteShopCount = ServiceProvider.Instance <IShopService> .Create.GetShopFavoritesCount(result.ShopId);

            if (CurrentUser != null)
            {
                modelShopScore.IsFavoriteShop = ServiceProvider.Instance <IShopService> .Create.GetFavoriteShopInfos(CurrentUser.Id).Any(d => d.ShopId == result.ShopId);
            }

            long vShopId;
            var  vshopinfo = ServiceProvider.Instance <IVShopService> .Create.GetVShopByShopId(shop.Id);

            if (vshopinfo == null)
            {
                vShopId = -1;
            }
            else
            {
                vShopId = vshopinfo.Id;
            }
            modelShopScore.VShopId  = vShopId;
            modelShopScore.VShopLog = ServiceProvider.Instance <IVShopService> .Create.GetVShopLog(vShopId);

            if (!string.IsNullOrWhiteSpace(modelShopScore.VShopLog))
            {
                modelShopScore.VShopLog = Himall.Core.HimallIO.GetRomoteImagePath(modelShopScore.VShopLog);
            }

            // 客服
            var customerServices = CustomerServiceApplication.GetMobileCustomerService(shop.Id);
            var meiqia           = CustomerServiceApplication.GetPreSaleByShopId(shop.Id).FirstOrDefault(p => p.Tool == CustomerServiceInfo.ServiceTool.MeiQia);
            if (meiqia != null)
            {
                customerServices.Insert(0, meiqia);
            }
            #endregion
            #region 根据运费模板获取发货地址
            var freightTemplateService   = ServiceHelper.Create <IFreightTemplateService>();
            FreightTemplateInfo template = freightTemplateService.GetFreightTemplate(product.FreightTemplateId);
            string productAddress        = string.Empty;
            if (template != null && template.SourceAddress.HasValue)
            {
                var fullName = ServiceHelper.Create <IRegionService>().GetFullName(template.SourceAddress.Value);
                if (fullName != null)
                {
                    var ass = fullName.Split(' ');
                    if (ass.Length >= 2)
                    {
                        productAddress = ass[0] + " " + ass[1];
                    }
                    else
                    {
                        productAddress = ass[0];
                    }
                }
            }

            var ProductAddress  = productAddress;
            var FreightTemplate = template;
            #endregion

            #region 获取店铺优惠信息
            VShopShowPromotionModel modelVshop = new VShopShowPromotionModel();
            modelVshop.ShopId = result.ShopId;
            var shopInfo = ServiceProvider.Instance <IShopService> .Create.GetShop(result.ShopId);

            if (shopInfo == null)
            {
                throw new HimallException("错误的店铺编号");
            }

            modelVshop.FreeFreight = shop.FreeFreight;


            var bonus = ServiceHelper.Create <IShopBonusService>().GetByShopId(result.ShopId);
            if (bonus != null)
            {
                modelVshop.BonusCount             = bonus.Count;
                modelVshop.BonusGrantPrice        = bonus.GrantPrice;
                modelVshop.BonusRandomAmountStart = bonus.RandomAmountStart;
                modelVshop.BonusRandomAmountEnd   = bonus.RandomAmountEnd;
            }
            #endregion
            //商品描述
            var ProductDescription = ServiceHelper.Create <IProductService>().GetProductDescription((long)result.ProductId);
            if (ProductDescription == null)
            {
                throw new Himall.Core.HimallException("错误的商品编号");
            }
            //统计商品浏览量、店铺浏览人数
            StatisticApplication.StatisticVisitCount(product.Id, product.ShopId);

            AutoMapper.Mapper.CreateMap <FightGroupActiveModel, FightGroupActiveResult>();
            var     fightGroupData = AutoMapper.Mapper.Map <FightGroupActiveResult>(result);
            decimal discount       = 1M;
            if (CurrentUser != null)
            {
                discount = CurrentUser.MemberDiscount;
            }
            var shopItem = ShopApplication.GetShop(result.ShopId);
            fightGroupData.MiniSalePrice = shopItem.IsSelf ? fightGroupData.MiniSalePrice * discount : fightGroupData.MiniSalePrice;

            return(Json(new
            {
                FightGroupData = fightGroupData,
                ShowSkuInfo = model,
                ShowPromotion = modelVshop,
                ShowNewCanJoinGroup = GroupsData,
                ProductCommentShow = modelSay,
                ProductDescription = ProductDescription.ShowMobileDescription.Replace("src=\"/Storage/", "src=\"" + Core.HimallIO.GetRomoteImagePath("/Storage/")),
                ShopScore = modelShopScore,
                CashDepositsServer = cashDepositModel,
                ProductAddress = ProductAddress,
                Free = FreightTemplate.IsFree == FreightTemplateType.Free ? "免运费" : "",
                userList = userList,
                IsUserEnter = IsUserEnter,
                SkuData = skudata,
                CustomerServices = customerServices
            }));
        }