示例#1
0
        /// <summary>
        /// 获取收货地址
        /// </summary>
        /// <param name="regionId"></param>
        /// <returns></returns>
        private Entities.ShippingAddressInfo GetShippingAddress(long?regionId)
        {
            Entities.ShippingAddressInfo result = null;
            if (regionId != null)
            {
                result = _iShippingAddressService.GetUserShippingAddress((long)regionId);
            }
            else
            {
                result = _iShippingAddressService.GetDefaultUserShippingAddressByUserId(CurrentUser.Id);
            }

            return(result);
        }
        /// <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);
        }