Пример #1
0
        /// <summary>
        /// 更新门店信息、管理员密码
        /// </summary>
        /// <param name="shopBranch"></param>
        public static void UpdateShopBranch(ShopBranch shopBranch)
        {
            if (isRepeatBranchName(shopBranch.ShopId, shopBranch.Id, shopBranch.ShopBranchName))
            {
                throw new MallException("门店名称不能重复!");
            }

            //AutoMapper.Mapper.CreateMap<ShopBranch, ShopBranchInfo>();
            //var shopBranchInfo = AutoMapper.Mapper.Map<ShopBranch, ShopBranchInfo>(shopBranch);

            var shopBranchInfo = shopBranch.Map <ShopBranchInfo>();


            shopBranchInfo.AddressPath = RegionApplication.GetRegionPath(shopBranchInfo.AddressId);
            //默认在结尾增加分隔符
            shopBranchInfo.AddressPath = shopBranchInfo.AddressPath + CommonConst.ADDRESS_PATH_SPLIT;
            Service.UpdateShopBranch(shopBranchInfo);

            if (!string.IsNullOrEmpty(shopBranch.PasswordOne))
            {
                if (shopBranch.PasswordOne != shopBranch.PasswordTwo)
                {
                    throw new MessageException("两次密码输入不一致");
                }
                //设置门店管理密码
                SetShopBranchManagerPassword(shopBranchInfo.Id, shopBranch.PasswordOne);
            }
        }
Пример #2
0
        /// <summary>
        /// 组合新地址
        /// </summary>
        /// <param name="addressPath"></param>
        /// <param name="address"></param>
        /// <param name="level"></param>
        /// <returns></returns>
        public static string RenderAddress(string addressPath, string address, int level)
        {
            if (!string.IsNullOrWhiteSpace(addressPath))
            {
                string   fullName = RegionApplication.GetRegionName(addressPath);
                string[] arr      = fullName.Split(',');//省,市,区,街道
                if (arr.Length > 0)
                {
                    for (int i = 0; i < arr.Length; i++)
                    {
                        if (!string.IsNullOrWhiteSpace(arr[i]))
                        {
                            address = address.Replace(arr[i], "");//去掉原详细地址中的省市区街道。(为兼容旧门店数据)
                        }
                    }
                }

                if (level <= arr.Length)
                {
                    for (int i = 0; i < level; i++)
                    {
                        if (!string.IsNullOrWhiteSpace(arr[i]))
                        {
                            fullName = fullName.Replace(arr[i], "");
                        }
                    }
                    address = fullName + address;
                }
            }
            if (!string.IsNullOrWhiteSpace(address))
            {
                address = address.Replace(",", " ");
            }
            return(address);
        }
Пример #3
0
        /// <summary>
        /// 分页查询门店
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public static QueryPageModel <ShopBranch> GetShopBranchs(ShopBranchQuery query)
        {
            var data        = Service.GetShopBranchs(query);
            var branchs     = data.Models;
            var tags        = Service.GetShopBranchInTagByBranchs(branchs.Select(p => p.Id).ToList());
            var shops       = GetService <IShopService>().GetShops(branchs.Select(p => p.ShopId).ToList());
            var shopBranchs = new QueryPageModel <ShopBranch>
            {
                Models = branchs.Select(e => new ShopBranch
                {
                    AddressDetail   = e.AddressDetail,
                    AddressFullName = RegionApplication.GetFullName(e.AddressId, CommonConst.ADDRESS_PATH_SPLIT) + CommonConst.ADDRESS_PATH_SPLIT + e.AddressDetail,
                    AddressId       = e.AddressId,
                    ContactPhone    = e.ContactPhone,
                    ContactUser     = e.ContactUser,
                    Id                   = e.Id,
                    ShopBranchName       = e.ShopBranchName,
                    ShopId               = e.ShopId,
                    Status               = e.Status,
                    ShopBranchInTagNames = string.Join(",", tags.Where(p => p.ShopBranchId == e.Id).Select(p => p.Title)),
                    ShopName             = shops.FirstOrDefault(p => p.Id == e.ShopId)?.ShopName ?? string.Empty
                }).ToList(),
                Total = data.Total
            };

            return(shopBranchs);
        }
Пример #4
0
        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));
        }
Пример #5
0
        public static string GetShopBranchsFullAddress(string addressPath)
        {
            var str = string.Empty;

            if (!string.IsNullOrEmpty(addressPath))
            {
                str = RegionApplication.GetRegionName(addressPath);
            }
            return(str.Replace(",", ""));
        }
Пример #6
0
        /// <summary>
        /// 根据城名称获取对应的区域模型
        /// </summary>
        /// <param name="name"></param>
        /// <param name="level"></param>
        /// <returns></returns>
        public static Region GetRegionByName(string name, Region.RegionLevel level)
        {
            var cityInfo = _iRegionService.GetRegionByName(name, level);

            if (cityInfo == null && level == Region.RegionLevel.City && !string.IsNullOrEmpty(name) && name.Substring(name.Length - 1) == "市")
            {
                name     = name.Substring(0, name.Length - 1) + "地区";//可能因为定位是市,而后台存的是地区,则再转换再取下,例如定位吐鲁番是“吐鲁番市”,而后台存的是“吐鲁番地区”
                cityInfo = RegionApplication.GetRegionByName(name, level);
            }
            return(cityInfo);
        }
Пример #7
0
        /// <summary>
        /// 根据分店id获取分店信息
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        public static List <ShopBranch> GetShopBranchs(List <long> ids)
        {
            var shopBranchs = Service.GetShopBranchs(ids).Map <List <ShopBranch> >();

            //补充地址详细信息,地址库采用了缓存,循环取
            foreach (var b in shopBranchs)
            {
                b.AddressFullName = RegionApplication.GetFullName(b.AddressId);
                b.RegionIdPath    = RegionApplication.GetRegionPath(b.AddressId);
            }
            return(shopBranchs);
        }
        /// <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);
        }
Пример #9
0
        /// <summary>
        /// 新增门店
        /// </summary>
        public static void AddShopBranch(ShopBranch shopBranch, out long shopBranchId)
        {
            if (isRepeatBranchName(shopBranch.ShopId, shopBranch.Id, shopBranch.ShopBranchName))
            {
                throw new MallException("此门店名称已存在,请设置其他名称!");
            }
            var branchManangerInfo = Service.GetShopBranchManagersByName(shopBranch.UserName);

            if (branchManangerInfo != null)
            {
                throw new MallException("此门店管理员账号已存在,请设置其他名称!");
            }
            if (ManagerApplication.CheckUserNameExist(shopBranch.UserName))
            {
                throw new MallException("此门店管理员账号已存在,请设置其他名称!");
            }
            // AutoMapper.Mapper.CreateMap<ShopBranch, Entities.ShopBranchInfo>();
            //  var shopBranchInfo = AutoMapper.Mapper.Map<ShopBranch, Entities.ShopBranchInfo>(shopBranch);

            var shopBranchInfo = shopBranch.Map <Entities.ShopBranchInfo>();

            shopBranchInfo.AddressPath = RegionApplication.GetRegionPath(shopBranchInfo.AddressId);
            //默认在结尾增加分隔符
            shopBranchInfo.AddressPath = shopBranchInfo.AddressPath + CommonConst.ADDRESS_PATH_SPLIT;
            Service.AddShopBranch(shopBranchInfo);
            shopBranchId = shopBranchInfo.Id;
            var salt = GetSalt();
            var shopBranchManagerInfo = new Entities.ShopBranchManagerInfo
            {
                CreateDate   = DateTime.Now,
                UserName     = shopBranch.UserName,
                ShopBranchId = shopBranchInfo.Id,
                PasswordSalt = salt,
                Password     = GetPasswrodEncode(shopBranch.PasswordOne, salt)
            };

            Service.AddShopBranchManagers(shopBranchManagerInfo);
            shopBranch.Id = shopBranchInfo.Id;
        }
Пример #10
0
        public static FreightTemplate GetFreightAreaDetail(long templateId, long shopId)
        {
            var model = Service.GetFreightTemplate(templateId);

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

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


            // freightTemplate.FreightArea = AutoMapper.Mapper.Map<List<FreightArea>>(model.FreightAreaContentInfo);
            freightTemplate.FreightArea = model.FreightAreaContentInfo.Map <List <FreightArea> >();


            foreach (var m in freightTemplate.FreightArea)
            {
                //       m.FreightAreaDetail = AutoMapper.Mapper.Map<List<FreightAreaDetail>>(model.FreightAreaContentInfo.Where(a => a.Id == m.Id).FirstOrDefault().FreightAreaDetailInfo);

                m.FreightAreaDetail = model.FreightAreaContentInfo.Where(a => a.Id == m.Id).FirstOrDefault().FreightAreaDetailInfo.Map <List <FreightAreaDetail> >();
            }
            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);
        }
Пример #11
0
        /// <summary>
        /// 取打印元素值
        /// </summary>
        /// <param name="shopId"></param>
        /// <param name="orderId"></param>
        /// <param name="printElementIndexes"></param>
        /// <returns></returns>
        public static IDictionary <int, string> GetPrintElementIndexAndOrderValue(long shopId, long orderId, IEnumerable <ExpressElementType> printElementIndexes)
        {
            var order = OrderApplication.GetOrder(orderId);

            if (order == null)
            {
                throw new NullReferenceException("订单为空");
            }

            var shopShipper = ShopShippersApplication.GetDefaultSendGoodsShipper(shopId);
            var dic         = new Dictionary <int, string>();

            string[] regionNames       = order.RegionFullName.Split(' ');
            string[] sellerRegionNames = new string[] { };

            if (shopShipper == null)
            {
                throw new NullReferenceException("商家需先设置“发/退货地址”");
            }

            string sellerRegionFullName = RegionApplication.GetFullName(shopShipper.RegionId);

            sellerRegionNames = sellerRegionFullName.Split(' ');

            string value;

            foreach (var index in printElementIndexes.ToList())
            {
                value = string.Empty;
                #region 获取对应值
                switch (index)
                {
                case  ExpressElementType.ReceiverUser:    //"收货人-姓名"
                    value = order.ShipTo;
                    break;

                case  ExpressElementType.ReceiverAddress:    //"收货人-地址"
                    value = order.Address;
                    break;

                case  ExpressElementType.ReceiverPhone:    //"收货人-电话"
                    value = order.CellPhone;
                    break;

                case  ExpressElementType.ReceiverPostCode:    //"收货人-邮编"
                    value = "";
                    break;

                case  ExpressElementType.ReceiverAddressLevel1:    //"收货人-地区1级"
                    value = regionNames[0];
                    break;

                case  ExpressElementType.ReceiverAddressLevel2:    //"收货人-地区2级"
                    value = regionNames.Length > 1 ? regionNames[1] : "";
                    break;

                case  ExpressElementType.ReceiverAddressLevel3:    //"收货人-地区3级"
                    value = regionNames.Length > 2 ? regionNames[2] : "";
                    break;

                case  ExpressElementType.ShipToUser:    //"发货人-姓名"
                    value = shopShipper.ShipperName;
                    break;

                case  ExpressElementType.ShipToAddressLevel1:    //"发货人-地区1级"
                    value = sellerRegionNames.Length > 0 ? sellerRegionNames[0] : "";
                    break;

                case  ExpressElementType.ShipToAddressLevel2:    // "发货人-地区2级"
                    value = sellerRegionNames.Length > 1 ? sellerRegionNames[1] : "";
                    break;

                case  ExpressElementType.ShipToAddressLevel3:    //"发货人-地区3级"
                    value = sellerRegionNames.Length > 2 ? sellerRegionNames[2] : "";
                    break;

                case  ExpressElementType.ShipToAddress:    //"发货人-地址"
                    value = shopShipper.Address;
                    break;

                case  ExpressElementType.ShipToPostCode:    //"发货人-邮编"
                    value = "";
                    break;

                case  ExpressElementType.ShipToPhone:    //"发货人-电话"
                    value = shopShipper.TelPhone;
                    break;

                case ExpressElementType.OrderNo:    //"订单-订单号"
                    value = order.Id.ToString();
                    break;

                case ExpressElementType.OrderAmount:    //"订单-总金额"
                    value = order.OrderTotalAmount.ToString("F2");
                    break;

                case  ExpressElementType.OrderWeight:    //"订单-物品总重量"
                    value = string.Empty;
                    break;

                case  ExpressElementType.OrderRemark:    //"订单-备注"
                    value = string.IsNullOrWhiteSpace(order.UserRemark) ? "" : order.UserRemark.ToString();
                    break;

                case ExpressElementType.OrderDetail:    //"订单-详情"
                    value = string.Empty;
                    break;

                case ExpressElementType.ShopName:    //"网店名称"
                    value = order.ShopName;
                    break;

                case ExpressElementType.RightChar:    //"对号-√"
                    value = "√";
                    break;

                default:
                    value = string.Empty;
                    break;
                }
                #endregion
                dic.Add((int)index, value);
            }
            return(dic);
        }