/// <summary> /// 修改满减活动 /// </summary> /// <returns></returns> public ActionResult EditActive(long id) { FullDiscountActive data = FullDiscountApplication.GetActive(id); FullDiscountActiveModel model = new FullDiscountActiveModel(); if (data == null || data.ShopId != CurShopId) { throw new HimallException("错误的活动编号"); } model.Id = data.Id; model.ActiveName = data.ActiveName; model.StartTime = data.StartTime; model.EndTime = data.EndTime; model.IsAllProduct = data.IsAllProduct; model.RuleJSON = JsonConvert.SerializeObject(data.Rules); var proids = data.Products.Select(d => d.ProductId).ToArray(); model.ProductIds = string.Join(",", proids); var sermodel = FullDiscountApplication.GetMarketService(CurShopId); model.EndServerTime = sermodel.EndTime.Value.Date.AddDays(1).AddMinutes(-1); return(View(model)); }
public JsonResult PostActiveDelete(long id) { FullDiscountApplication.DeleteActive(id); return(Json(new Result { success = true, msg = "删除成功" })); }
public JsonResult GetProductsByIds(string productids) { if (string.IsNullOrWhiteSpace(productids)) { throw new HimallException("错误的参数"); } var selproids = productids.Split(',') .Where(d => !string.IsNullOrWhiteSpace(d)) .Select(d => long.Parse(d)) .ToList(); var noproids = FullDiscountApplication.GetNoSaleProductId(selproids); var products = FullDiscountApplication.GetProductByIds(selproids); List <ActiveProductModel> result = products.Select(item => { return(new ActiveProductModel() { Name = item.ProductName, Id = item.Id, Image = item.GetImage(ImageSize.Size_50), Price = item.MinSalePrice, ProductCode = item.ProductCode, IsException = noproids.Any(d => d == item.Id) }); }).ToList(); return(Json(result)); }
/// <summary> /// 重写验证,以过滤未购买服务或已过期情况 /// </summary> /// <param name="filterContext"></param> protected override void OnActionExecuting(ActionExecutingContext filterContext) { //路由处理 var route = filterContext.RouteData; //string controller = route.Values["controller"].ToString().ToLower(); string action = route.Values["action"].ToString().ToLower(); if (action.ToLower() != "nosetting" && action.ToLower() != "nobuytips") { bool iscanmarket = FullDiscountApplication.IsCanUseMarketService(CurShopId); if (!iscanmarket && action.ToLower() != "buymarketservice") { if (FullDiscountApplication.IsOpenMarketService()) { filterContext.Result = RedirectToAction("NoBuyTips"); return; } else { filterContext.Result = RedirectToAction("Nosetting"); return; } } } base.OnActionExecuting(filterContext); }
public JsonResult GetBoughtList(MarketBoughtQuery query) { query.MarketType = CommonModel.MarketType.FullDiscount; var data = FullDiscountApplication.GetMarketServiceBuyList(query); return(Json(data)); }
/// <summary> /// 营销功能未开放 /// </summary> /// <returns></returns> public ActionResult Nosetting() { if (FullDiscountApplication.IsOpenMarketService()) { return(View("NoBuyTips")); } return(View("Nosetting")); }
public JsonResult BuyMarketService(int month) { Result result = new Result(); FullDiscountApplication.BuyMarketService(month, CurrentSellerManager.ShopId); result.success = true; result.msg = "购买服务成功"; return(Json(result)); }
/// <summary> /// 检测不可以参加活动的诊疗项目 /// </summary> /// <param name="productIds"></param> private List <long> CheckCanNotJoinProduct(IEnumerable <long> products, long activeId) { if (products == null || products.Count() < 1) { throw new HimallException("请选择参与活动的诊疗项目"); } List <long> result = products.ToList(); var canjoin = FullDiscountApplication.FilterActiveProductId(products, activeId, CurrentShop.Id); result = result.Where(d => !canjoin.Contains(d)).ToList(); return(result); }
public JsonResult ServiceSetting(decimal Price) { Result result = new Result(); if (Price < 0) { result.success = false; result.msg = "错误的服务价格!"; return(Json(result)); } FullDiscountApplication.SetMarketServicePrice(Price); result.success = true; result.msg = "保存成功!"; return(Json(result)); }
/// <summary> /// 添加满减活动 /// </summary> /// <returns></returns> public ActionResult AddActive() { FullDiscountActiveModel model = new FullDiscountActiveModel(); model.ShopId = CurShopId; model.StartTime = DateTime.Now; model.EndTime = DateTime.Now.AddMonths(1); model.IsAllProduct = true; model.RuleJSON = ""; var sermodel = FullDiscountApplication.GetMarketService(CurShopId); model.EndServerTime = sermodel.EndTime.Value.Date.AddDays(1).AddMinutes(-1); return(View(model)); }
public JsonResult GetCanJoinProducts(string name, string code, string selectedProductId, int activeId, int page, int rows) { List <long> selproids = new List <long>(); if (!string.IsNullOrWhiteSpace(selectedProductId)) { selproids = selectedProductId.Split(',') .Where(d => !string.IsNullOrWhiteSpace(d)) .Select(d => long.Parse(d)) .ToList(); } if (name != null) { name = name.Trim(); } if (code != null) { code = code.Trim(); } var products = FullDiscountApplication.GetCanJoinProducts(CurShopId, name, code, selproids, activeId, page, rows); DataGridModel <ActiveProductModel> dataGrid = new DataGridModel <ActiveProductModel>() { rows = products.Models .Select(item => new ActiveProductModel() { Name = item.ProductName, Id = item.Id, Image = item.GetImage(ImageSize.Size_50), Price = item.MinSalePrice, ProductCode = item.ProductCode }), total = products.Total }; return(Json(dataGrid)); }
public JsonResult PostActiveList(string activeName, FullDiscountStatus?status, DateTime?startTime, DateTime?endTime, int page, int rows) { if (startTime.HasValue) { startTime = startTime.Value.Date; } if (endTime.HasValue) { endTime = endTime.Value.AddDays(1).Date; } var query = new FullDiscountActiveQuery(); query.ShopId = CurShopId; query.ActiveName = activeName; query.Status = status; query.StartTime = startTime; query.EndTime = endTime; query.PageNo = page; query.PageSize = rows; var data = FullDiscountApplication.GetActives(query); var datalist = data.Models.ToList(); return(Json(new { rows = datalist, total = data.Total })); }
/// <summary> /// 购买营销服务 /// </summary> /// <returns></returns> public ActionResult BuyMarketService() { var model = FullDiscountApplication.GetMarketService(CurShopId); return(View(model)); }
public object GetProductDetail(long id) { ProductDetailModelForMobie model = new ProductDetailModelForMobie() { Product = new ProductInfoModel(), Shop = new ShopInfoModel(), Color = new CollectionSKU(), Size = new CollectionSKU(), Version = new CollectionSKU() }; ProductInfo product = null; ShopInfo shop = null; product = ServiceProvider.Instance <IProductService> .Create.GetProduct(id); var cashDepositModel = ServiceProvider.Instance <ICashDepositsService> .Create.GetCashDepositsObligation(product.Id);//提供服务(消费者保障、七天无理由、及时发货) model.CashDepositsServer = cashDepositModel; #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]; } } } model.ProductAddress = productAddress; model.FreightTemplate = template; #endregion #region 店铺Logo long vShopId; shop = ServiceProvider.Instance <IShopService> .Create.GetShop(product.ShopId); var vshopinfo = ServiceProvider.Instance <IVShopService> .Create.GetVShopByShopId(shop.Id); if (vshopinfo == null) { vShopId = -1; } else { vShopId = vshopinfo.Id; } model.Shop.VShopId = vShopId; model.VShopLog = ServiceProvider.Instance <IVShopService> .Create.GetVShopLog(model.Shop.VShopId); #endregion model.Shop.FavoriteShopCount = ServiceProvider.Instance <IShopService> .Create.GetShopFavoritesCount(product.ShopId);//关注人数 var com = product.Himall_ProductComments.Where(item => !item.IsHidden.HasValue || item.IsHidden.Value == false); var limitBuy = ServiceProvider.Instance <ILimitTimeBuyService> .Create.GetLimitTimeMarketItemByProductId(id); #region 商品SKU 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; if (limitBuy != null) { var limitSku = ServiceProvider.Instance <ILimitTimeBuyService> .Create.Get(limitBuy.Id); var limitSkuItem = limitSku.Details.OrderBy(d => d.Price).FirstOrDefault(); if (limitSkuItem != null) { product.MinSalePrice = limitSkuItem.Price; } } if (product.SKUInfo != null && product.SKUInfo.Count() > 0) { long colorId = 0, sizeId = 0, versionId = 0; foreach (var sku in product.SKUInfo) { var specs = sku.Id.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 = product.SKUInfo.Where(s => s.Color.Equals(sku.Color)).Sum(s => s.Stock); model.Color.Add(new ProductSKU { //Name = "选择颜色", Name = "选择" + colorAlias, EnabledClass = c != 0 ? "enabled" : "disabled", //SelectedClass = !model.Color.Any(c1 => c1.SelectedClass.Equals("selected")) && c != 0 ? "selected" : "", SelectedClass = "", SkuId = colorId, Value = sku.Color, Img = Himall.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 = product.SKUInfo.Where(s => s.Size.Equals(sku.Size)).Sum(s1 => s1.Stock); model.Size.Add(new ProductSKU { //Name = "选择尺码", Name = "选择" + sizeAlias, EnabledClass = ss != 0 ? "enabled" : "disabled", //SelectedClass = !model.Size.Any(s1 => s1.SelectedClass.Equals("selected")) && ss != 0 ? "selected" : "", 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 = product.SKUInfo.Where(s => s.Version.Equals(sku.Version)).Sum(s => s.Stock); model.Version.Add(new ProductSKU { //Name = "选择版本", Name = "选择" + versionAlias, EnabledClass = v != 0 ? "enabled" : "disabled", //SelectedClass = !model.Version.Any(v1 => v1.SelectedClass.Equals("selected")) && v != 0 ? "selected" : "", SelectedClass = "", SkuId = versionId, Value = sku.Version }); } } } } } #endregion #region 店铺 shop = ServiceProvider.Instance <IShopService> .Create.GetShop(product.ShopId); var mark = ShopServiceMark.GetShopComprehensiveMark(shop.Id); model.Shop.PackMark = mark.PackMark; model.Shop.ServiceMark = mark.ServiceMark; model.Shop.ComprehensiveMark = mark.ComprehensiveMark; var comm = ServiceProvider.Instance <ICommentService> .Create.GetCommentsByProductId(id); model.Shop.Name = shop.ShopName; model.Shop.ProductMark = (comm == null || comm.Count() == 0) ? 0 : comm.Average(p => (decimal)p.ReviewMark); model.Shop.Id = product.ShopId; model.Shop.FreeFreight = shop.FreeFreight; model.Shop.ProductNum = ServiceProvider.Instance <IProductService> .Create.GetShopOnsaleProducts(product.ShopId); var shopStatisticOrderComments = ServiceProvider.Instance <IShopService> .Create.GetShopStatisticOrderComments(product.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; //宝贝与描述 if (productAndDescription != null && productAndDescriptionPeer != null) { model.Shop.ProductAndDescription = productAndDescription.CommentValue; } else { model.Shop.ProductAndDescription = defaultValue; } //卖家服务态度 if (sellerServiceAttitude != null && sellerServiceAttitudePeer != null) { model.Shop.SellerServiceAttitude = sellerServiceAttitude.CommentValue; } else { model.Shop.SellerServiceAttitude = defaultValue; } //卖家发货速度 if (sellerDeliverySpeedPeer != null && sellerDeliverySpeed != null) { model.Shop.SellerDeliverySpeed = sellerDeliverySpeed.CommentValue; } else { model.Shop.SellerDeliverySpeed = defaultValue; } if (ServiceProvider.Instance <IVShopService> .Create.GetVShopByShopId(shop.Id) == null) { model.Shop.VShopId = -1; } else { model.Shop.VShopId = ServiceProvider.Instance <IVShopService> .Create.GetVShopByShopId(shop.Id).Id; } //优惠券 var couponCount = GetCouponList(shop.Id);//取设置的优惠券 if (couponCount > 0) { model.Shop.CouponCount = couponCount; } // 客服 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 consultations = ServiceProvider.Instance <IConsultationService> .Create.GetConsultations(id); double total = product.Himall_ProductComments.Count(); double niceTotal = product.Himall_ProductComments.Count(item => item.ReviewMark >= 4); bool isFavorite = false; bool IsFavoriteShop = false; decimal discount = 1M; if (CurrentUser == null) { isFavorite = false; IsFavoriteShop = false; } else { isFavorite = ServiceProvider.Instance <IProductService> .Create.IsFavorite(product.Id, CurrentUser.Id); var favoriteShopIds = ServiceProvider.Instance <IShopService> .Create.GetFavoriteShopInfos(CurrentUser.Id).Select(item => item.ShopId).ToArray();//获取已关注店铺 IsFavoriteShop = favoriteShopIds.Contains(product.ShopId); discount = CurrentUser.MemberDiscount; } var productImage = new List <string>(); for (int i = 1; i < 6; i++) { if (Core.HimallIO.ExistFile(product.RelativePath + string.Format("/{0}.png", i))) { var path = Core.HimallIO.GetRomoteProductSizeImage(product.RelativePath, i, (int)Himall.CommonModel.ImageSize.Size_350); productImage.Add(path); } } //File.Exists(HttpContext.Current.Server.MapPath(product.ImagePath + string.Format("/{0}.png", 1))); decimal minSalePrice = shop.IsSelf ? product.MinSalePrice * discount : product.MinSalePrice; var isValidLimitBuy = "false"; if (limitBuy != null) { isValidLimitBuy = "true"; minSalePrice = limitBuy.MinPrice; //限时购不打折 } bool isFightGroupActive = false; var activeInfo = ServiceProvider.Instance <IFightGroupService> .Create.GetActiveByProId(product.Id); if (activeInfo != null && activeInfo.ActiveStatus > FightGroupActiveStatus.Ending) { isFightGroupActive = true; } model.Product = new ProductInfoModel() { ProductId = product.Id, CommentCount = com.Count(),//product.Himall_ProductComments.Count(), Consultations = consultations.Count(), ImagePath = productImage, IsFavorite = isFavorite, MarketPrice = product.MarketPrice, MinSalePrice = minSalePrice, NicePercent = model.Shop.ProductMark == 0 ? 100 : (int)((niceTotal / total) * 100), ProductName = product.ProductName, ProductSaleStatus = product.SaleStatus, AuditStatus = product.AuditStatus, ShortDescription = product.ShortDescription, ProductDescription = GetProductDescription(product.ProductDescriptionInfo), IsOnLimitBuy = limitBuy != null }; #endregion #region 佣金 var probroker = DistributionApplication.GetDistributionProductInfo(id); var IsDistribution = false; decimal Brokerage = 0; if (probroker != null) { IsDistribution = true; Brokerage = probroker.Commission; } #endregion #region 代金红包 var bonus = ServiceProvider.Instance <IShopBonusService> .Create.GetByShopId(shop.Id); int BonusCount = 0; decimal BonusGrantPrice = 0; decimal BonusRandomAmountStart = 0; decimal BonusRandomAmountEnd = 0; if (bonus != null) { BonusCount = bonus.Count; BonusGrantPrice = bonus.GrantPrice; BonusRandomAmountStart = bonus.RandomAmountStart; BonusRandomAmountEnd = bonus.RandomAmountEnd; } var fullDiscount = FullDiscountApplication.GetOngoingActiveByProductId(id, shop.Id); #endregion LogProduct(id); //统计商品浏览量、店铺浏览人数 StatisticApplication.StatisticVisitCount(product.Id, product.ShopId); var IsPromoter = false; if (CurrentUser != null && CurrentUser.Id > 0) { var prom = DistributionApplication.GetPromoterByUserId(CurrentUser.Id); if (prom != null && prom.Status == PromoterInfo.PromoterStatus.Audited) { IsPromoter = true; } } return(Json(new { Success = "true", IsOnLimitBuy = isValidLimitBuy, IsFightGroupActive = isFightGroupActive, ActiveId = isFightGroupActive ? activeInfo.Id : 0, ActiveStatus = activeInfo != null ? activeInfo.ActiveStatus.GetHashCode() : 0, MaxSaleCount = limitBuy == null ? 0 : limitBuy.LimitCountOfThePeople, Title = limitBuy == null ? string.Empty : limitBuy.Title, Second = limitBuy == null ? 0 : (limitBuy.EndDate - DateTime.Now).TotalSeconds, Product = model.Product, CashDepositsServer = model.CashDepositsServer, //提供服务(消费者保障、七天无理由、及时发货) ProductAddress = model.ProductAddress, //发货地址 Free = model.FreightTemplate.IsFree == FreightTemplateType.Free ? "免运费" : "", //是否免运费 VShopLog = Himall.Core.HimallIO.GetRomoteImagePath(model.VShopLog), Shop = model.Shop, IsFavoriteShop = IsFavoriteShop, Color = model.Color, Size = model.Size, Version = model.Version, BonusCount = BonusCount, BonusGrantPrice = BonusGrantPrice, BonusRandomAmountStart = BonusRandomAmountStart, BonusRandomAmountEnd = BonusRandomAmountEnd, fullDiscount = fullDiscount, ColorAlias = colorAlias, SizeAlias = sizeAlias, VersionAlias = versionAlias, IsDistribution = IsDistribution, Brokerage = Brokerage.ToString("f2"), IsPromoter = IsPromoter, userId = CurrentUser == null ? 0 : CurrentUser.Id, IsOpenStore = SiteSettingApplication.GetSiteSettings() != null && SiteSettingApplication.GetSiteSettings().IsOpenStore, CustomerServices = customerServices })); }
/// <summary> /// 拼团活动详情 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult Detail(long id) { FightGroupActiveModel data = FightGroupApplication.GetActive(id, false); if (data == null) { throw new HimallException("错误的活动信息"); } data.InitProductImages(); AutoMapper.Mapper.CreateMap <FightGroupActiveModel, FightGroupActiveDetailModel>(); FightGroupActiveDetailModel model = AutoMapper.Mapper.Map <FightGroupActiveDetailModel>(data); 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 = HimallIO.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)); }
public ActionResult FullDiscount() { var model = FullDiscountApplication.GetOngoingActiveByProductIds(new long[] { 709, 700, 698, 696, 800, 825 }, 1); return(Json(model, JsonRequestBehavior.AllowGet)); }
public ActionResult ServiceSetting() { decimal model = FullDiscountApplication.GetMarketServicePrice(); return(View(model)); }
public JsonResult EditActive(FullDiscountActiveModel model) { var result = new Result { success = false, msg = "未知错误", status = -1 }; if (string.IsNullOrWhiteSpace(model.ActiveName)) { model.ActiveName = model.ActiveName.Trim(); } FullDiscountActive data = FullDiscountApplication.GetActive(model.Id); if (data == null || data.ShopId != CurShopId) { throw new HimallException("错误的活动编号"); } if (model.EndTime.Date < model.StartTime.Date) { throw new HimallException("错误的结束时间"); } //数据有效性验证 model.CheckValidation(); List <FullDiscountRules> rules = JsonConvert.DeserializeObject <List <FullDiscountRules> >(model.RuleJSON); if (rules == null) { throw new HimallException("优惠规则异常"); } rules = rules.OrderBy(d => d.Quota).ToList(); CheckRules(rules); List <long> proids = new List <long>(); if (model.IsAllProduct) { proids.Add(-1); } else { if (!string.IsNullOrWhiteSpace(model.ProductIds)) { proids = model.ProductIds.Split(',').Where(d => !string.IsNullOrWhiteSpace(d)).Select(d => long.Parse(d)).ToList(); List <long> cannotjoin = CheckCanNotJoinProduct(proids, data.Id); if (cannotjoin.Count > 0) { result = new Result { success = false, msg = string.Join(",", cannotjoin.ToArray()), status = -2 }; return(Json(result)); } } } var sermodel = FullDiscountApplication.GetMarketService(CurShopId); if (model.EndTime > sermodel.EndTime.Value.Date.AddDays(1)) { throw new HimallException("活动结束时间不可超过服务时间"); } if (ModelState.IsValid) { List <FullDiscountActiveProduct> products = proids.Select(d => new FullDiscountActiveProduct { ProductId = d }).ToList(); data.Id = model.Id; data.ActiveName = model.ActiveName; data.EndTime = model.EndTime; data.ShopId = CurShopId; data.IsAllProduct = model.IsAllProduct; data.Rules = rules; data.Products = products; FullDiscountApplication.UpdateActive(data); result = new Result { success = true, msg = "操作成功", status = 1 }; } else { result = new Result { success = false, msg = "数据异常,请检查数据有效性", status = -1 }; } return(Json(result)); }
public JsonResult GetBoughtList(string shopName, int page, int rows) { var data = FullDiscountApplication.GetMarketServiceBuyList(shopName, page, rows); return(Json(new { rows = data.Models.ToList(), total = data.Total })); }
private List <HomePageShopBranch> ProcessBranchHomePageData(List <ShopBranch> list, bool isAllCoupon = false) { var service = ServiceProvider.Instance <ICouponService> .Create; var shopIds = list.Select(e => e.ShopId).Distinct(); var homepageBranchs = list.Select(e => new HomePageShopBranch { ShopBranch = e }).ToList(); foreach (var sid in shopIds) { ShopActiveList actives = new ShopActiveList(); //优惠券 var coupons = CouponApplication.GetCouponLists(sid); var settings = service.GetSettingsByCoupon(coupons.Select(p => p.Id).ToList()); var couponList = coupons.Where(d => settings.Any(c => c.CouponID == d.Id && c.PlatForm == PlatformType.Wap)); var appCouponlist = new List <CouponModel>(); foreach (var couponinfo in couponList) { var coupon = new CouponModel(); var status = 0; long userid = 0; if (CurrentUser != null) { userid = CurrentUser.Id; } //当前优惠券的可领状态 status = ShopBranchApplication.CouponIsUse(couponinfo, userid); coupon.Id = couponinfo.Id; coupon.CouponName = couponinfo.CouponName; coupon.ShopId = couponinfo.ShopId; coupon.OrderAmount = couponinfo.OrderAmount.ToString("F2"); coupon.Price = Math.Round(couponinfo.Price, 2); coupon.StartTime = couponinfo.StartTime; coupon.EndTime = couponinfo.EndTime; coupon.IsUse = status; coupon.UseArea = couponinfo.UseArea; coupon.Remark = couponinfo.Remark; appCouponlist.Add(coupon); } actives.ShopCoupons = appCouponlist.OrderBy(d => d.Price).ToList(); //满额减活动 var fullDiscount = FullDiscountApplication.GetOngoingActiveByShopId(sid); if (fullDiscount != null) { actives.ShopActives = fullDiscount.Select(e => new ActiveInfo { ActiveName = e.ActiveName, ShopId = e.ShopId }).ToList(); } //商家所有门店显示活动相同 var shopBranchs = homepageBranchs.Where(e => e.ShopBranch.ShopId == sid); foreach (var shop in shopBranchs) { shop.ShopAllActives = new ShopActiveList { ShopActives = actives.ShopActives, ShopCoupons = actives.ShopCoupons, FreeFreightAmount = shop.ShopBranch.IsFreeMail ? shop.ShopBranch.FreeMailFee : 0, IsFreeMail = shop.ShopBranch.IsFreeMail }; } } return(homepageBranchs); }