/// <summary> /// 计算多个省份的名称 /// </summary> /// <param name="details"></param> /// <returns></returns> private string ComputeProvincesName(string provinceCodes) { if (string.IsNullOrEmpty(provinceCodes)) { return(string.Empty); } CBCBPFacade facade = new CBCBPFacade(); return(string.Join("、", facade.GetProvincesNameByCode(provinceCodes))); }
/// <summary> /// 获取一条运费模板记录 /// </summary> /// <param name="freightTemplateId"></param> /// <returns></returns> public FreightDTO GetOneFreightExt(Guid freightTemplateId) { try { FreightDTO freight = null; FreightTemplate ftDTO = FreightTemplate.ObjectSet().Where(s => s.Id == freightTemplateId).FirstOrDefault(); if (ftDTO == null) { return(freight); } freight = new FreightDTO(); freight.Id = ftDTO.Id; freight.AppId = ftDTO.AppId; freight.Name = ftDTO.Name; freight.IsFreeExp = ftDTO.IsFreeExp; freight.FreightMethod = ftDTO.FreightMethod; freight.FreightTo = ftDTO.FreightTo; freight.FirstCount = ftDTO.FirstCount; freight.FirstCountPrice = ftDTO.FirstCountPrice; freight.NextCount = ftDTO.NextCount; freight.NextCountPrice = ftDTO.NextCountPrice; freight.PricingMethod = ftDTO.PricingMethod; freight.ExpressType = ftDTO.ExpressType; //运费详情。 freight.FreightDetailList = GetFreightTemplateDetailListByTemId(freightTemplateId); //部分包邮 var pfQuery = from fpf in FreightPartialFree.ObjectSet() where fpf.FreightTemplateId == ftDTO.Id select fpf; if (pfQuery.Any()) { var pfList = pfQuery.ToList().ConvertAll(ConvertFreightPartialFree2ExtDTO); try { var provList = CBCBP.Instance.GeProvinceByCountryCode(); if (provList != null && provList.Any()) { foreach (var pf in pfList) { var provNamesQ = from p in provList where ("," + pf.DestinationCodes + ",").Contains("," + p.Code + ",") select p.Name; pf.FreightTo = string.Join(",", provNamesQ); } } } catch (Exception ex) { LogHelper.Error("GetOneFreightExt中调用Jinher.AMP.CBC.IBP.Facade.GeProvinceByCountryCode异常", ex); } freight.PartialFreeList = pfList; } #region 价格区间运费 var details = FreightRangeDetails.ObjectSet().Where(predicate => predicate.TemplateId == freightTemplateId); TPS.CBCBPFacade facade = new CBCBPFacade(); if (details.Any()) { foreach (var group in details.GroupBy(selector => new { selector.ProvinceCodes, selector.IsSpecific })) { var sort = group.OrderBy(selector => selector.Min); if (!group.Key.IsSpecific) { foreach (var detail in sort) { freight.DefaultRangeFreightDetails.Add(new Deploy.CustomDTO.FreightRangeDefaultDetailsDTO { Min = detail.Min, Max = detail.Max, Cost = detail.Cost }); } continue; } freight.SpecificRangeFreightDetails.Add(new FreightRangeSpecificDetailsDTO { ProvinceNames = facade.GetProvincesNameByCode(group.Key.ProvinceCodes), ProvinceCodes = group.Key.ProvinceCodes, Details = sort.Select(selector => new Jinher.AMP.BTP.Deploy.CustomDTO.FreightRangeDefaultDetailsDTO { Min = selector.Min, Max = selector.Max, Cost = selector.Cost }).ToList() }); } } #endregion return(freight); } catch (Exception ex) { LogHelper.Error(string.Format("获取一条运费记录服务异常。freightTemplateId:{0}", freightTemplateId), ex); return(null); } }