public static bool IsCashOnDelivery(long regionId)
        {
            var city     = RegionApplication.GetRegion(regionId, CommonModel.Region.RegionLevel.City);
            var county   = RegionApplication.GetRegion(regionId, CommonModel.Region.RegionLevel.County);
            var cityId   = city == null ? 0 : city.Id;
            var countyId = county == null ? 0 : county.Id;

            return(_iPaymentConfigService.IsCashOnDelivery(cityId, countyId));
        }
Exemple #2
0
        /// <summary>
        /// 订单区域分析图
        /// </summary>
        /// <param name="dimension"></param>
        /// <param name="year"></param>
        /// <param name="month"></param>
        /// <returns></returns>
        public static MapChartDataModel  GetAreaOrderChart(Model.OrderDimension dimension, int year, int month)
        {
            var model = _StatisticsService.GetAreaOrderChart(dimension, year, month);

            foreach (var d in model.Series.Data)
            {
                d.name = RegionApplication.GetRegion(long.Parse(d.name)).ShortName;
            }
            return(model);
        }
        /// <summary>
        /// 获取会员默认收货地址
        /// </summary>
        /// <param name="userId">会员编号</param>
        /// <returns></returns>
        public static ShippingAddressInfo GetDefaultUserShippingAddressByUserId(long userId)
        {
            var addr = _iShippingAddressService.GetDefaultUserShippingAddressByUserId(userId);

            if (addr != null)
            {
                var region = RegionApplication.GetRegion(addr.RegionId);
                if (region == null)
                {//收货地址被删除后,设置默认地址
                    addr.RegionId       = RegionApplication.GetDefaultRegionId();
                    addr.RegionFullName = RegionApplication.GetFullName(addr.RegionId);
                }
            }
            return(addr);
        }
Exemple #4
0
        /// <summary>
        /// 根据模板ID获取运费模板信息
        /// </summary>
        /// <param name="templateId"></param>
        /// <returns></returns>
        public static FreightTemplate GetFreightTemplate(long templateId, long shopId)
        {
            var model = _iFreightTemplateService.GetFreightTemplate(templateId);

            if (model.ShopID != shopId)
            {
                throw new HimallException("此运费模板不存在");
            }
            var areas   = _iFreightTemplateService.GetFreightAreaContent(templateId);
            var details = _iFreightTemplateService.GetFreightAreaDetail(templateId);

            model.Himall_FreightAreaContent = areas;
            foreach (var m in model.Himall_FreightAreaContent)
            {
                var t = details.Where(a => a.FreightAreaId == m.Id).ToList();
                m.FreightAreaDetailInfo = t;
            }
            var freightTemplate = AutoMapper.Mapper.Map <FreightTemplate>(model);
            var area            = freightTemplate.FreightArea.Where(a => a.IsDefault == 0).ToList();

            foreach (var f in area)
            {
                foreach (var a in f.FreightAreaDetail)
                {
                    a.ProvinceName = RegionApplication.GetRegion(a.ProvinceId).Name;
                    if (a.CityId.HasValue && a.CityId.Value != 0)
                    {
                        a.CityName = RegionApplication.GetRegion(a.CityId.Value).Name;
                    }
                    if (a.CountyId.HasValue && a.CountyId.Value != 0)
                    {
                        a.CountyName = RegionApplication.GetRegion(a.CountyId.Value).Name;
                    }
                    if (!string.IsNullOrEmpty(a.TownIds))
                    {
                        var regionNames = RegionApplication.GetAllRegions().Where(x => a.TownIds.Split(',').ToList().Contains(x.Id.ToString())).Select(t => t.Name).ToList();
                        a.TownNames = string.Join(",", regionNames);
                    }
                }
            }
            return(freightTemplate);
        }
Exemple #5
0
        public static FreightTemplate GetFreightAreaDetail(long templateId, long shopId)
        {
            var model = Service.GetFreightTemplate(templateId);

            if (model.ShopID != shopId)
            {
                throw new HimallException("此运费模板不存在");
            }

            var freightTemplate = AutoMapper.Mapper.Map <FreightTemplate>(model);

            freightTemplate.FreightArea = AutoMapper.Mapper.Map <List <FreightArea> >(model.FreightAreaContentInfo);
            foreach (var m in freightTemplate.FreightArea)
            {
                m.FreightAreaDetail = AutoMapper.Mapper.Map <List <FreightAreaDetail> >(model.FreightAreaContentInfo.Where(a => a.Id == m.Id).FirstOrDefault().FreightAreaDetailInfo);
            }
            freightTemplate.FreeTempContent = new List <FreeTempContent>();
            var freeGroups  = Service.GetShippingFreeGroups(model.Id);
            var freeRegions = Service.GetShippingFreeRegions(model.Id);

            freeGroups.ForEach(item =>
            {
                var info = new FreeTempContent()
                {
                    ConditionNumber = item.ConditionNumber,
                    ConditionType   = item.ConditionType
                };
                if (!string.IsNullOrWhiteSpace(info.ConditionNumber))
                {
                    var condition = info.ConditionNumber.Split('$');
                    if (condition.Length == 2)
                    {
                        info.ConditionNumber1 = condition[0];
                        info.ConditionNumber2 = condition[1];
                    }
                    else if (condition.Length == 1)
                    {
                        info.ConditionNumber1 = condition[0];
                    }
                }
                info.FreightAreaDetail = freeRegions
                                         .Where(p => p.GroupId == item.Id)
                                         .Select(a => new FreightAreaDetail()
                {
                    RegionPath = a.RegionPath
                })
                                         .ToList();

                freightTemplate.FreeTempContent.Add(info);
            });
            var area = freightTemplate.FreightArea.Where(a => a.IsDefault == 0).ToList();

            foreach (var f in area)
            {
                foreach (var a in f.FreightAreaDetail)
                {
                    a.ProvinceName = RegionApplication.GetRegion(a.ProvinceId).Name;
                    if (a.CityId.HasValue && a.CityId.Value != 0)
                    {
                        a.CityName = RegionApplication.GetRegion(a.CityId.Value).Name;
                    }
                    if (a.CountyId.HasValue && a.CountyId.Value != 0)
                    {
                        a.CountyName = RegionApplication.GetRegion(a.CountyId.Value).Name;
                    }
                    if (!string.IsNullOrEmpty(a.TownIds))
                    {
                        var regionNames = RegionApplication.GetAllRegions().Where(x => a.TownIds.Split(',').ToList().Contains(x.Id.ToString())).Select(t => t.Name).ToList();
                        a.TownNames = string.Join(",", regionNames);
                    }
                }
            }

            foreach (var item in freightTemplate.FreeTempContent)
            {
                Parallel.ForEach(item.FreightAreaDetail, a =>
                {
                    var path = a.RegionPath;
                    var arr  = path.Split(',');
                    if (arr.Length >= 3)
                    {
                        a.ProvinceId = int.Parse(arr[0]);
                        a.CityId     = int.Parse(arr[1]);
                        a.CountyId   = int.Parse(arr[2]);

                        a.ProvinceName = RegionApplication.GetRegion(a.ProvinceId).Name;
                        a.CityName     = RegionApplication.GetRegion(a.CityId.Value).Name;
                        a.CountyName   = RegionApplication.GetRegion(a.CountyId.Value).Name;
                    }
                    else if (arr.Length >= 2)
                    {
                        a.ProvinceId   = int.Parse(arr[0]);
                        a.CityId       = int.Parse(arr[1]);
                        a.ProvinceName = RegionApplication.GetRegion(a.ProvinceId).Name;
                        a.CityName     = RegionApplication.GetRegion(a.CityId.Value).Name;
                    }
                    else if (arr.Length >= 1)
                    {
                        a.ProvinceId   = int.Parse(arr[0]);
                        a.ProvinceName = RegionApplication.GetRegion(a.ProvinceId).Name;
                    }
                });
            }
            return(freightTemplate);
        }