/// <summary> /// 查询自提点 /// </summary> /// <param name="search">查询类</param> /// <returns>结果</returns> public SelfTakeStationResultDTO GetSelfTakeStationExt(SelfTakeStationSearchDTO search) { SelfTakeStationResultDTO result = new SelfTakeStationResultDTO(); if (search == null || search.pageIndex < 1 || search.pageSize < 1 || search.appId == Guid.Empty) { return(result); } var query = from s in AppSelfTakeStation.ObjectSet() where !s.IsDel && s.AppId == search.appId select s; if (!string.IsNullOrEmpty(search.searchContent)) { query = query.Where(n => n.Name.Contains(search.searchContent) || n.Phone.Contains(search.searchContent) || n.Address.Contains(search.searchContent)); } query = query.Distinct(); result.Count = query.Count(); query = query.OrderByDescending(n => n.SubTime).Skip((search.pageIndex - 1) * search.pageSize).Take(search.pageSize); var tmpResult = query.ToList(); if (tmpResult.Count == 0) { result.Count = 0; return(result); } try { foreach (var item in tmpResult) { SelfTakeStationSearchResultDTO data = new SelfTakeStationSearchResultDTO { Id = item.Id, Name = item.Name, Province = ProvinceCityHelper.GetAreaNameByCode(item.Province), City = ProvinceCityHelper.GetAreaNameByCode(item.City), District = ProvinceCityHelper.GetAreaNameByCode(item.District), Address = item.Address, SubTime = item.SubTime, Phone = item.Phone == null ? "" : item.Phone, ModifiedOn = item.ModifiedOn }; result.SelfTakeStationList.Add(data); } return(result); } catch (Exception ex) { LogHelper.Error(string.Format("查询自提点SV服务异常。search:{0}", JsonHelper.JsonSerializer(search)), ex); return(result); } }
/// <summary> /// 得到自提地址 /// </summary> /// <param name="entity"></param> /// <returns></returns> public static string GetSelfTakAddress(SelfTakeStation entity) { if (entity != null) { //if (ProvinceCityHelper.GetDirectlyCityList().Select(c => c.AreaCode).ToList().Contains(entity.Province)) //{ // return string.Format("{0} {1}", ProvinceCityHelper.GetAreaNameByCode(entity.Province), entity.Address); //} return(string.Format("{0} {1} {2}", ProvinceCityHelper.GetAreaNameByCode(entity.Province), ProvinceCityHelper.GetAreaNameByCode(entity.City), entity.Address)); } return(string.Empty); }
/// <summary> /// 根据省编码获取城市列表 /// </summary> /// <param name="provinceCode"></param> /// <returns></returns> public List <Area> GetCityByProvinceCode(string provinceCode) { return(ProvinceCityHelper.GetProvinceCities(provinceCode)); //var result = new List<CityDTO>(); //if (string.IsNullOrEmpty(provinceCode)) // return result; //try //{ // Jinher.AMP.CBC.IBP.Facade.CityFacade facade = new CityFacade(); // facade.ContextDTO = AuthorizeHelper.CoinInitAuthorizeInfo(); // result = facade.GetCityByProvinceCode(provinceCode); //} //catch (Exception ex) //{ // LogHelper.Error("调用CBCBP.GetCityByProvinceCode异常", ex); //} //return result ?? new List<CityDTO>(); }
/// <summary> /// 获取省列表 /// </summary> /// <param name="countryCode"></param> /// <returns></returns> public List <Area> GeProvinceByCountryCode(string countryCode = "1001") { var result = new List <Area>(); result = ProvinceCityHelper.GetAllProvince(); //try //{ // Jinher.AMP.CBC.IBP.Facade.ProvinceFacade facade = new ProvinceFacade(); // facade.ContextDTO = AuthorizeHelper.CoinInitAuthorizeInfo(); // result = facade.GeProvinceByCountryCode(countryCode); //} //catch (Exception ex) //{ // LogHelper.Error("调用CBCBP.GeProvinceByCountryCode异常", ex); //} return(result ?? new List <Area>()); }
/// <summary> /// 获取商品列表(平台获取平台商品、店铺获取店铺商品) /// </summary> /// <param name="search"></param> /// <returns></returns> public Jinher.AMP.BTP.Deploy.CustomDTO.ComdtyListResultCDTO GetCommodityListV2Ext(CommodityListSearchDTO search) { Jinher.AMP.BTP.Deploy.CustomDTO.ComdtyListResultCDTO comdtyListResultCDTO = new Jinher.AMP.BTP.Deploy.CustomDTO.ComdtyListResultCDTO(); try { if (search == null || search.PageSize <= 0 || search.PageIndex <= 0) { comdtyListResultCDTO.isSuccess = false; comdtyListResultCDTO.Code = 1; comdtyListResultCDTO.Message = "参数不能为空"; comdtyListResultCDTO.realCount = 0; comdtyListResultCDTO.comdtyList = null; comdtyListResultCDTO.appInfoList = null; return(comdtyListResultCDTO); } if (!search.AppId.HasValue || search.AppId == Guid.Empty) { comdtyListResultCDTO.isSuccess = false; comdtyListResultCDTO.Code = 1; comdtyListResultCDTO.Message = "参数不能为空"; comdtyListResultCDTO.realCount = 0; comdtyListResultCDTO.comdtyList = null; comdtyListResultCDTO.appInfoList = null; return(comdtyListResultCDTO); } DateTime now = DateTime.Now; var appId = search.AppId.Value; IQueryable <Commodity> ocommodityList; //用于存储临加入真实价格后的Commodity信息 IQueryable <TempCommodity> tempOcommodityList; //根据是否平台区分 bool isPavilion = Jinher.AMP.BTP.TPS.ZPHSV.Instance.IsAppPavilion(search.AppId.Value); if (isPavilion) { tempOcommodityList = (from cs in CommodityCategory.ObjectSet() join cate in Category.ObjectSet() on cs.CategoryId equals cate.Id join c in Commodity.ObjectSet() on cs.CommodityId equals c.Id join pro in ( from query in TodayPromotion.ObjectSet() where (query.PromotionType != 3 && (query.StartTime <= now || query.PresellStartTime <= now) && query.EndTime > now) select query ) on c.Id equals pro.CommodityId into todayPros from promotion in todayPros.DefaultIfEmpty() where cs.AppId == appId && c.IsDel == false && c.State == 0 && c.CommodityType == 0 && !cate.IsDel orderby c.Salesvolume descending, c.SubTime descending select new TempCommodity { Com = c, newPrice = (promotion.Id == null) ? c.Price : (promotion.DiscountPrice > 0 ? promotion.DiscountPrice : c.Price * promotion.Intensity / 10) }); } else { tempOcommodityList = (from c in Commodity.ObjectSet() join pro in ( from query in TodayPromotion.ObjectSet() where (query.PromotionType != 3 && (query.StartTime <= now || query.PresellStartTime <= now) && query.EndTime > now) select query ) on c.Id equals pro.CommodityId into todayPros from promotion in todayPros.DefaultIfEmpty() where c.AppId == appId && c.IsDel == false && c.State == 0 && c.CommodityType == 0 select new TempCommodity { Com = c, newPrice = (promotion.Id == null) ? c.Price : (promotion.DiscountPrice > 0 ? promotion.DiscountPrice : c.Price * promotion.Intensity / 10) }); } if (search.MinPrice.HasValue && search.MinPrice != 0) { tempOcommodityList = tempOcommodityList.Where(c => c.newPrice >= search.MinPrice); } if (search.MaxPrice.HasValue && search.MaxPrice != 0) { tempOcommodityList = tempOcommodityList.Where(c => c.newPrice <= search.MaxPrice); } ocommodityList = tempOcommodityList.Select(c => c.Com).Distinct(); if (search.IsHasStock) { ocommodityList = ocommodityList.Where(c => c.Stock > 0); } if (!ProvinceCityHelper.IsTheWholeCountry(search.areaCode)) { var province = ProvinceCityHelper.GetProvinceByAreaCode(search.areaCode); var city = ProvinceCityHelper.GetCityByAreaCode(search.areaCode); if (province != null && city != null) { if (province.AreaCode == city.AreaCode) { ocommodityList = ocommodityList.Where(c => c.SaleAreas == null || c.SaleAreas == "" || c.SaleAreas == ProvinceCityHelper.CountryCode || c.SaleAreas.Contains(province.AreaCode)); } else { ocommodityList = ocommodityList.Where(c => c.SaleAreas == null || c.SaleAreas == "" || c.SaleAreas == ProvinceCityHelper.CountryCode || c.SaleAreas.Contains(province.AreaCode) || c.SaleAreas.Contains(city.AreaCode)); } } } var commoditiesQuery = from c in ocommodityList select c; List <Commodity> commodities = null; List <Jinher.AMP.BTP.Deploy.CustomDTO.CommodityListCDTO> commodityList = null; comdtyListResultCDTO.realCount = commoditiesQuery.Count(); if (isPavilion) { commodities = (from c in commoditiesQuery orderby c.Salesvolume descending, c.SubTime descending select c).Skip((search.PageIndex - 1) * search.PageSize).Take(search.PageSize).ToList(); } else { commodities = (from c in commoditiesQuery orderby c.SortValue select c).Skip((search.PageIndex - 1) * search.PageSize).Take(search.PageSize).ToList(); } //commodities = commoditiesQuery.Skip((search.PageIndex - 1) * search.PageSize).Take(search.PageSize).ToList(); if (!commodities.Any()) { return(comdtyListResultCDTO); } commodityList = commodities.Select(c => new Jinher.AMP.BTP.Deploy.CustomDTO.CommodityListCDTO { Id = c.Id, Pic = c.PicturesPath, Price = c.Price, State = c.State, Stock = c.Stock, Name = c.Name, MarketPrice = c.MarketPrice, AppId = c.AppId, IsEnableSelfTake = c.IsEnableSelfTake, ComAttribute = c.ComAttribute, ComAttrType = (c.ComAttribute == "[]" || c.ComAttribute == null) ? 1 : 3 }).ToList(); var appList = commodities.Select(c => c.AppId).Distinct().ToList(); #region 众筹 if (CustomConfig.CrowdfundingFlag) { var crowdFundingApps = Crowdfunding.ObjectSet().Where(c => c.StartTime < now && c.State == 0 && appList.Contains(c.AppId)).Select(c => c.AppId).ToList(); if (crowdFundingApps.Any()) { for (int i = 0; i < commodityList.Count; i++) { if (crowdFundingApps.Any(c => c == commodityList[i].AppId)) { commodityList[i].IsActiveCrowdfunding = true; } } } } #endregion var commodityIds = commodityList.Select(c => c.Id).Distinct().ToList(); var comStockList = CommodityStock.ObjectSet() .Where(c => commodityIds.Contains(c.CommodityId)) .Select( c => new Deploy.CommodityStockDTO { Id = c.Id, CommodityId = c.CommodityId, Price = c.Price, MarketPrice = c.MarketPrice }) .ToList(); var todayPromotions = TodayPromotion.GetCurrentPromotionsWithPresell(commodityIds); foreach (var commodity in commodityList) { commodity.IsMultAttribute = Commodity.CheckComMultAttribute(commodity.ComAttribute); List <Deploy.CommodityStockDTO> comStocks = comStockList.Where(c => c.CommodityId == commodity.Id).ToList(); var todayPromotion = todayPromotions.FirstOrDefault(c => c.CommodityId == commodity.Id && c.PromotionType != 3); if (todayPromotion != null) { commodity.LimitBuyEach = todayPromotion.LimitBuyEach ?? -1; commodity.LimitBuyTotal = todayPromotion.LimitBuyTotal ?? -1; commodity.SurplusLimitBuyTotal = todayPromotion.SurplusLimitBuyTotal ?? 0; commodity.PromotionType = todayPromotion.PromotionType; if (todayPromotion.DiscountPrice > -1) { commodity.DiscountPrice = Convert.ToDecimal(todayPromotion.DiscountPrice); commodity.Intensity = 10; } else { commodity.DiscountPrice = -1; commodity.Intensity = todayPromotion.Intensity; } } else { commodity.DiscountPrice = -1; commodity.Intensity = 10; commodity.LimitBuyEach = -1; commodity.LimitBuyTotal = -1; commodity.SurplusLimitBuyTotal = -1; commodity.PromotionType = 9999; } buildShowPrice(commodity, comStocks, todayPromotion); } try { var apps = APPSV.GetAppListByIds(appList); if (apps != null && apps.Any()) { comdtyListResultCDTO.appInfoList = new List <ComdtyAppInfoCDTO>(); foreach (var appInfo in apps) { comdtyListResultCDTO.appInfoList.Add(new ComdtyAppInfoCDTO { appId = appInfo.AppId, appName = appInfo.AppName, icon = appInfo.AppIcon }); } foreach (var commodityListCdto in commodityList) { var appInfo = apps.FirstOrDefault(c => c.AppId == commodityListCdto.AppId); if (appInfo != null) { commodityListCdto.AppName = appInfo.AppName; } } } } catch (Exception ex) { LogHelper.Error(string.Format("AppSetSV.GetCommodityListExt,获取app名称错误。appId:{0}", appId), ex); } comdtyListResultCDTO.comdtyList = commodityList; } catch (Exception ex) { LogHelper.Error(string.Format("商品列表查询错误,CommoditySV.GetCommodityListV2Ext。search:{0}", JsonHelper.JsonSerializer(search)), ex); comdtyListResultCDTO.isSuccess = false; comdtyListResultCDTO.Code = -1; comdtyListResultCDTO.Message = "Error"; comdtyListResultCDTO.realCount = 0; comdtyListResultCDTO.comdtyList = null; comdtyListResultCDTO.appInfoList = null; return(comdtyListResultCDTO); } comdtyListResultCDTO.isSuccess = true; comdtyListResultCDTO.Code = 0; comdtyListResultCDTO.Message = "Success"; return(comdtyListResultCDTO); }
/// <summary> /// 下订单页获取自提点信息 /// </summary> /// <param name="search">查询类</param> /// <returns>结果</returns> public Jinher.AMP.BTP.Deploy.CustomDTO.AppSelfTakeStationDefaultInfoDTO GetAppSelfTakeStationDefaultExt(Jinher.AMP.BTP.Deploy.CustomDTO.AppSelfTakeStationSearchDTO search) { var result = new AppSelfTakeStationDefaultInfoDTO(); if (search == null) { return(null); } if (search.SearchType == 1) { if (search.Id == Guid.Empty) { return(null); } var station = AppSelfTakeStation.ObjectSet() .Where(t => t.Id == search.Id && !t.IsDel) .FirstOrDefault(); if (station == null) { return(null); } result.StationId = station.Id; result.StationName = station.Name; result.DelayDay = station.DelayDay; result.MaxBookDay = station.MaxBookDay; result.StationPhone = station.Phone; if (!string.IsNullOrWhiteSpace(station.Province)) { result.StationAddressDetails = ProvinceCityHelper.GetAreaNameByCode(station.Province) + ProvinceCityHelper.GetAreaNameByCode(station.City) + ProvinceCityHelper.GetAreaNameByCode(station.District) + station.Address; } var officeTime = AppStsOfficeTime.ObjectSet().Where(t => t.SelfTakeStationId == station.Id).ToList(); if (officeTime.Any()) { result.StationTimeList = new List <AppStationOfficeTime>(); foreach (var appStsOfficeTime in officeTime) { var officeTimeModel = new AppStationOfficeTime(); officeTimeModel.StartTime = appStsOfficeTime.StartTime; officeTimeModel.EndTime = appStsOfficeTime.EndTime; officeTimeModel.WeekDays = appStsOfficeTime.WeekDays; result.StationTimeList.Add(officeTimeModel); } } } else if (search.SearchType == 2) { if (search.EsAppId == Guid.Empty) { return(null); } var _userId = this.ContextDTO.LoginUserID; var pickUpOrder = AppOrderPickUp.ObjectSet() .Where(t => t.AppId == search.EsAppId && t.UserId == _userId).OrderByDescending(t => t.SubTime) .FirstOrDefault(); if (pickUpOrder == null) { return(null); } var station = AppSelfTakeStation.ObjectSet() .Where(t => t.Id == pickUpOrder.SelfTakeStationId && t.AppId == pickUpOrder.AppId && !t.IsDel) .FirstOrDefault(); if (station == null) { return(null); } result.StationId = station.Id; result.StationName = station.Name; result.DelayDay = station.DelayDay; result.MaxBookDay = station.MaxBookDay; result.StationPhone = station.Phone; result.PickUpName = pickUpOrder.Name; result.PickUpPhone = pickUpOrder.Phone; if (!string.IsNullOrWhiteSpace(station.Province)) { result.StationAddressDetails = ProvinceCityHelper.GetAreaNameByCode(station.Province) + ProvinceCityHelper.GetAreaNameByCode(station.City) + ProvinceCityHelper.GetAreaNameByCode(station.District) + station.Address; } var officeTime = AppStsOfficeTime.ObjectSet().Where(t => t.SelfTakeStationId == station.Id).ToList(); if (officeTime.Any()) { result.StationTimeList = new List <AppStationOfficeTime>(); foreach (var appStsOfficeTime in officeTime) { var officeTimeModel = new AppStationOfficeTime(); officeTimeModel.StartTime = appStsOfficeTime.StartTime; officeTimeModel.EndTime = appStsOfficeTime.EndTime; officeTimeModel.WeekDays = appStsOfficeTime.WeekDays; result.StationTimeList.Add(officeTimeModel); } } } else { return(null); } result.StationTimeShowList = AppSelfTakeSV.DealScrollTime(result.StationTimeList, result.DelayDay, result.MaxBookDay); return(result); }
/// <summary> /// 获取多个省份的名称 /// </summary> /// <param name="codes">省份代码列表</param> /// <returns></returns> public IList <string> GetProvincesNameByCode(IList <string> codes) { var provinces = ProvinceCityHelper.GetAllProvince(); return(provinces.Where(predicate => codes.Contains(predicate.Code)).Select(selector => selector.Name).ToList()); }