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); }