/// <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); }
/// <summary> /// 根据分店id获取分店信息 /// </summary> /// <param name="ids"></param> /// <returns></returns> public static List <ShopBranch> GetShopBranchs(IEnumerable <long> ids) { var shopBranchs = _shopBranchService.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); }
/// <summary> /// 分页查询门店 /// </summary> /// <param name="query"></param> /// <returns></returns> public static QueryPageModel <ShopBranch> GetShopBranchs(ShopBranchQuery query) { var shopBranchInfos = _shopBranchService.GetShopBranchs(query); QueryPageModel <ShopBranch> shopBranchs = new QueryPageModel <ShopBranch> { Models = shopBranchInfos.Models.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 }).ToList(), Total = shopBranchInfos.Total }; return(shopBranchs); }
/// <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); }