public APIResponse GetList(int userId, ExtendedAppType type) { List <ExtendedApp> extendedApps = new List <ExtendedApp>(); if (type == ExtendedAppType.All) { extendedApps = CurrentDb.ExtendedApp.Where(m => m.Type != Enumeration.ExtendedAppType.CarService && m.IsDisplay == true).Take(4).ToList(); } else if (type == ExtendedAppType.MainHomeCarService) { extendedApps = CurrentDb.ExtendedApp.Where(m => m.Type == Enumeration.ExtendedAppType.CarService && m.IsDisplay == true).Take(4).ToList(); } else if (type == ExtendedAppType.MainHomeRecommend) { extendedApps = CurrentDb.ExtendedApp.Where(m => m.Type != Enumeration.ExtendedAppType.CarService && m.IsDisplay == true).Take(4).ToList(); } List <ExtendedAppModel> model = new List <ExtendedAppModel>(); foreach (var m in extendedApps) { ExtendedAppModel imageModel = new ExtendedAppModel(); imageModel.Id = m.Id; imageModel.Name = m.Name; imageModel.ImgUrl = m.ImgUrl; imageModel.LinkUrl = m.LinkUrl; imageModel.AppKey = m.AppKey; imageModel.AppSecret = m.AppSecret; model.Add(imageModel); } APIResult result = new APIResult() { Result = ResultType.Success, Code = ResultCode.Success, Message = "", Data = model }; return(new APIResponse(result)); }
public APIResponse Home(int userId, int merchantId, int posMachineId, DateTime?datetime) { HomeModel model = new HomeModel(); DateTime?lastUpdateTime; if (!SysFactory.SysItemCacheUpdateTime.CanGetData(userId, datetime, out lastUpdateTime)) { return(ResponseResult(ResultType.Failure, ResultCode.Failure, "没有最新的数据")); } model.ServiceTelphone = "服务热线:400-00-00-00 (9:00~18:00)"; model.LastUpdateTime = lastUpdateTime.Value; #region 获取bannder var banner = CurrentDb.SysBanner.Where(m => m.Type == Enumeration.BannerType.MainHomeTop && m.Status == Enumeration.SysBannerStatus.Release).ToList(); List <BannerImageModel> bannerImageModel = new List <BannerImageModel>(); foreach (var m in banner) { BannerImageModel imageModel = new BannerImageModel(); imageModel.Id = m.Id; imageModel.Title = m.Title; imageModel.LinkUrl = SysFactory.Banner.GetLinkUrl(m.Id); imageModel.ImgUrl = m.ImgUrl; bannerImageModel.Add(imageModel); } model.Banner = bannerImageModel; #endregion #region 获取 投保公司,理赔公司 var carInsCompanys = (from u in CurrentDb.CarInsuranceCompany join r in CurrentDb.Company on u.InsuranceCompanyId equals r.Id where u.Status == Enumeration.CarInsuranceCompanyStatus.Normal select new { r.Id, r.Name, u.InsuranceCompanyImgUrl, u.CanClaims, u.CanInsure, u.CanApplyLossAssess, u.Priority }).Distinct().OrderByDescending(m => m.Priority); List <CarInsCompanyModel> carInsCompanyModels = new List <CarInsCompanyModel>(); foreach (var carInsCompany in carInsCompanys) { CarInsCompanyModel carInsCompanyModel = new CarInsCompanyModel(); carInsCompanyModel.Id = carInsCompany.Id; carInsCompanyModel.Name = carInsCompany.Name; carInsCompanyModel.ImgUrl = carInsCompany.InsuranceCompanyImgUrl; carInsCompanyModel.CanClaims = carInsCompany.CanClaims; carInsCompanyModel.CanInsure = carInsCompany.CanInsure; carInsCompanyModel.CanApplyLossAssess = carInsCompany.CanApplyLossAssess; carInsCompanyModels.Add(carInsCompanyModel); } model.CarInsCompany = carInsCompanyModels; #endregion #region 获取车险险种 List <CarInsKindModel> carInsKindModels = new List <CarInsKindModel>(); var carKinds = CurrentDb.CarKind.OrderByDescending(m => m.Priority).ToList(); foreach (var carKind in carKinds) { CarInsKindModel carInsKindModel = new CarInsKindModel(); carInsKindModel.Id = carKind.Id; carInsKindModel.PId = carKind.PId; carInsKindModel.Name = carKind.Name; carInsKindModel.AliasName = carKind.AliasName; carInsKindModel.Type = carKind.Type; carInsKindModel.CanWaiverDeductible = carKind.CanWaiverDeductible; carInsKindModel.IsWaiverDeductible = carKind.IsWaiverDeductible; carInsKindModel.InputType = carKind.InputType; carInsKindModel.InputUnit = carKind.InputUnit; carInsKindModel.InputValue = carKind.InputValue; if (!string.IsNullOrEmpty(carKind.InputOption)) { carInsKindModel.InputOption = Newtonsoft.Json.JsonConvert.DeserializeObject <List <string> >(carKind.InputOption); } carInsKindModel.IsHasDetails = carKind.IsHasDetails; carInsKindModel.IsCheck = carKind.IsCheck; carInsKindModels.Add(carInsKindModel); } model.CarInsKind = carInsKindModels; #endregion #region 获取车险的投保方案 List <CarInsPlanModel> carInsPlanModels = new List <CarInsPlanModel>(); var carInsurePlans = CurrentDb.CarInsurePlan.Where(m => m.IsDelete == false).ToList(); var carInsurePlanKinds = CurrentDb.CarInsurePlanKind.ToList(); foreach (var carInsurePlan in carInsurePlans) { CarInsPlanModel carInsPlanModel = new CarInsPlanModel(); carInsPlanModel.Id = carInsurePlan.Id; carInsPlanModel.Name = carInsurePlan.Name; carInsPlanModel.ImgUrl = carInsurePlan.ImgUrl; var carKindIds = carInsurePlanKinds.Where(m => m.CarInsurePlanId == carInsurePlan.Id).Select(m => m.CarKindId).ToArray(); var carInsurePlanKindParentKindIds = carKinds.Where(m => carKindIds.Contains(m.Id) && m.PId == 0).Select(m => m.Id).ToList(); List <CarInsPlanKindParentModel> carInsPlanKindParentModels = new List <CarInsPlanKindParentModel>(); foreach (var carInsurePlanKindParentKindId in carInsurePlanKindParentKindIds) { CarInsPlanKindParentModel carInsPlanKindParentModel = new CarInsPlanKindParentModel(); carInsPlanKindParentModel.Id = carInsurePlanKindParentKindId; var carInsurePlanKindChildKindIds = carKinds.Where(m => carKindIds.Contains(m.Id) && m.PId == carInsurePlanKindParentKindId).Select(m => m.Id).ToList(); carInsPlanKindParentModel.Child = carInsurePlanKindChildKindIds; carInsPlanKindParentModels.Add(carInsPlanKindParentModel); } carInsPlanModel.KindParent = carInsPlanKindParentModels; carInsPlanModels.Add(carInsPlanModel); } model.CarInsPlan = carInsPlanModels; #endregion #region 人才输送工种 List <TalentDemandWorkJobModel> talentDemandWorkJobModel = new List <TalentDemandWorkJobModel>(); foreach (Enumeration.WorkJob t in Enum.GetValues(typeof(Enumeration.WorkJob))) { int id = Convert.ToInt32(t); if (id != 0) { Enum en = (Enum)Enum.Parse(t.GetType(), id.ToString()); string name = en.GetCnName(); talentDemandWorkJobModel.Add(new TalentDemandWorkJobModel { Id = id, Name = name }); } } model.TalentDemandWorkJob = talentDemandWorkJobModel; #endregion #region 检查流量费 是否到期后,需支付的订单 if (!IsSaleman(userId)) { var orderToServiceFee = CurrentDb.OrderToServiceFee.Where(m => m.UserId == userId && m.MerchantId == merchantId && m.PosMachineId == posMachineId && m.Status == Enumeration.OrderStatus.WaitPay).FirstOrDefault(); if (orderToServiceFee != null) { model.OrderInfo = BizFactory.Merchant.GetOrderConfirmInfoByServiceFee(orderToServiceFee); } } #endregion #region 第三方服务 var extendedApps = CurrentDb.ExtendedApp.Where(m => m.IsDisplay == true).ToList(); List <ExtendedAppModel> extendedAppModel = new List <ExtendedAppModel>(); foreach (var m in extendedApps) { ExtendedAppModel appModel = new ExtendedAppModel(); appModel.Id = m.Id; appModel.Name = m.Name; appModel.ImgUrl = m.ImgUrl; appModel.LinkUrl = m.LinkUrl; appModel.AppKey = m.AppKey; appModel.AppSecret = m.AppSecret; appModel.Type = m.Type; extendedAppModel.Add(appModel); } model.ExtendedApp = extendedAppModel; #endregion #region 查询违章积分 var lllegalQueryScore = CurrentDb.LllegalQueryScore.Where(m => m.UserId == userId).FirstOrDefault(); if (lllegalQueryScore != null) { model.LllegalQueryScore = lllegalQueryScore.Score; } #endregion model.ProductKinds = ServiceFactory.Product.GetKinds(); APIResult result = new APIResult() { Result = ResultType.Success, Code = ResultCode.Success, Message = "获取成功", Data = model }; return(new APIResponse(result)); }
public APIResponse Home(int userId, int merchantId) { HomeModel model = new HomeModel(); //获取bannder var banner = CurrentDb.SysBanner.Where(m => m.Type == Enumeration.BannerType.MainHomeTop).ToList(); List <BannerImageModel> bannerImageModel = new List <BannerImageModel>(); foreach (var m in banner) { BannerImageModel imageModel = new BannerImageModel(); imageModel.Id = m.Id; imageModel.Title = m.Title; imageModel.LinkUrl = SysFactory.Banner.GetLinkUrl(m.Id); imageModel.ImgUrl = m.ImgUrl; bannerImageModel.Add(imageModel); } model.Banner = bannerImageModel; //获取车务服务 var carServiceApps = CurrentDb.ExtendedApp.Where(m => m.Type == Enumeration.ExtendedAppType.CarService && m.IsDisplay == true).Take(4).ToList(); List <ExtendedAppModel> carServiceAppsModel = new List <ExtendedAppModel>(); foreach (var m in carServiceApps) { ExtendedAppModel extendedAppModel = new ExtendedAppModel(); extendedAppModel.Id = m.Id; extendedAppModel.Name = m.Name; extendedAppModel.ImgUrl = m.ImgUrl; extendedAppModel.LinkUrl = m.LinkUrl; extendedAppModel.AppKey = m.AppKey; extendedAppModel.AppSecret = m.AppSecret; carServiceAppsModel.Add(extendedAppModel); } model.CarService = carServiceAppsModel; //获取推荐服务 var recommendApps = CurrentDb.ExtendedApp.Where(m => m.Type != Enumeration.ExtendedAppType.CarService && m.IsDisplay == true).Take(4).ToList(); List <ExtendedAppModel> recommendAppsModel = new List <ExtendedAppModel>(); foreach (var m in recommendApps) { ExtendedAppModel extendedAppModel = new ExtendedAppModel(); extendedAppModel.Id = m.Id; extendedAppModel.Name = m.Name; extendedAppModel.ImgUrl = m.ImgUrl; extendedAppModel.LinkUrl = m.LinkUrl; extendedAppModel.AppKey = m.AppKey; extendedAppModel.AppSecret = m.AppSecret; recommendAppsModel.Add(extendedAppModel); } model.RecommendService = recommendAppsModel; //获取推荐商品 var recommendProduct = (from m in CurrentDb.Product where ((int)m.Type).ToString().StartsWith("101") select new { m.Id, m.Name, m.Price, m.Type, m.CreateTime, m.MainImgUrl }).OrderByDescending(r => r.CreateTime).Skip(0).Take(6).ToList(); List <RecommendProductModel> recommendProductModel = new List <RecommendProductModel>(); foreach (var m in recommendProduct) { RecommendProductModel product = new RecommendProductModel(); product.Id = m.Id; product.Name = m.Name; product.Price = m.Price; product.Type = m.Type.GetCnName(); product.ImgUrl = m.MainImgUrl; product.LinkUrl = BizFactory.Product.GetLinkUrl(m.Type, m.Id); recommendProductModel.Add(product); } model.RecommendProduct = recommendProductModel; APIResult result = new APIResult() { Result = ResultType.Success, Code = ResultCode.Success, Message = "获取成功", Data = model }; return(new APIResponse(result)); }