コード例 #1
0
        public ProductSku(
            Guid id,
            [NotNull] string serializedAttributeOptionIds,
            [CanBeNull] string name,
            [NotNull] string currency,
            decimal?originalPrice,
            decimal price,
            int orderMinQuantity,
            int orderMaxQuantity,
            TimeSpan?paymentExpireIn,
            [CanBeNull] string mediaResources,
            Guid?productDetailId) : base(id)
        {
            Check.NotNullOrWhiteSpace(currency, nameof(currency));
            var nodaCurrency = NodaMoney.Currency.FromCode(currency);

            SerializedAttributeOptionIds =
                Check.NotNullOrWhiteSpace(serializedAttributeOptionIds, nameof(serializedAttributeOptionIds));
            Name             = name?.Trim();
            Currency         = nodaCurrency.Code;
            OriginalPrice    = originalPrice.HasValue ? new Money(originalPrice.Value, nodaCurrency).Amount : null;
            Price            = new Money(price, nodaCurrency).Amount;
            OrderMinQuantity = orderMinQuantity;
            OrderMaxQuantity = orderMaxQuantity;
            PaymentExpireIn  = paymentExpireIn;
            MediaResources   = mediaResources;
            ProductDetailId  = productDetailId;

            ExtraProperties = new ExtraPropertyDictionary();
            this.SetDefaultsForExtraProperties();
        }
コード例 #2
0
ファイル: ProductSku.cs プロジェクト: kuiyouli/EShop
        public ProductSku(
            Guid id,
            [NotNull] string serializedAttributeOptionIds,
            [CanBeNull] string name,
            [NotNull] string currency,
            decimal?originalPrice,
            decimal price,
            int orderMinQuantity,
            int orderMaxQuantity,
            [CanBeNull] string mediaResources,
            Guid?productDetailId) : base(id)
        {
            SerializedAttributeOptionIds = serializedAttributeOptionIds;
            Name             = name?.Trim();
            Currency         = currency;
            OriginalPrice    = originalPrice;
            Price            = price;
            OrderMinQuantity = orderMinQuantity;
            OrderMaxQuantity = orderMaxQuantity;
            MediaResources   = mediaResources;
            ProductDetailId  = productDetailId;

            ExtraProperties = new ExtraPropertyDictionary();
            this.SetDefaultsForExtraProperties();
        }
コード例 #3
0
ファイル: RefundItem.cs プロジェクト: yinchang0626/EShop
        protected RefundItem()
        {
            RefundItemOrderLines = new List <RefundItemOrderLine>();

            ExtraProperties = new ExtraPropertyDictionary();
            this.SetDefaultsForExtraProperties();
        }
コード例 #4
0
        public override async Task OnStartWithdrawalAsync(Account account, string withdrawalMethod, decimal amount,
                                                          ExtraPropertyDictionary inputExtraProperties)
        {
            var request = new WithdrawalRequest(_guidGenerator.Create(), _currentTenant.Id, account.Id, account.UserId, amount);

            await _withdrawalRequestRepository.InsertAsync(request, true);
        }
コード例 #5
0
ファイル: EntityChange.cs プロジェクト: zjc-china/abp
        public EntityChange(
            IGuidGenerator guidGenerator,
            Guid auditLogId,
            EntityChangeInfo entityChangeInfo,
            Guid?tenantId = null)
        {
            Id                 = guidGenerator.Create();
            AuditLogId         = auditLogId;
            TenantId           = tenantId;
            ChangeTime         = entityChangeInfo.ChangeTime;
            ChangeType         = entityChangeInfo.ChangeType;
            EntityId           = entityChangeInfo.EntityId.Truncate(EntityChangeConsts.MaxEntityTypeFullNameLength);
            EntityTypeFullName = entityChangeInfo.EntityTypeFullName.TruncateFromBeginning(EntityChangeConsts.MaxEntityTypeFullNameLength);

            PropertyChanges = entityChangeInfo
                              .PropertyChanges?
                              .Select(p => new EntityPropertyChange(guidGenerator, Id, p, tenantId))
                              .ToList()
                              ?? new List <EntityPropertyChange>();

            ExtraProperties = new ExtraPropertyDictionary();
            if (entityChangeInfo.ExtraProperties != null)
            {
                foreach (var pair in entityChangeInfo.ExtraProperties)
                {
                    ExtraProperties.Add(pair.Key, pair.Value);
                }
            }
        }
コード例 #6
0
        public virtual async Task StartPaymentAsync(Payment payment, ExtraPropertyDictionary configurations = null)
        {
            var provider = GetProvider(payment);

            // Todo: payment discount

            await provider.OnPaymentStartedAsync(payment, configurations);
        }
コード例 #7
0
ファイル: AuditLogInfo.cs プロジェクト: xyfy/abp
 public AuditLogInfo()
 {
     Actions         = new List <AuditLogActionInfo>();
     Exceptions      = new List <Exception>();
     ExtraProperties = new ExtraPropertyDictionary();
     EntityChanges   = new List <EntityChangeInfo>();
     Comments        = new List <string>();
 }
コード例 #8
0
        protected virtual Task <ExtraPropertyDictionary> GetPayeeConfigurationsAsync(Payment payment)
        {
            // Todo: use payee configurations provider.
            // Todo: get store side payee configurations.

            var payeeConfigurations = new ExtraPropertyDictionary();

            return(Task.FromResult(payeeConfigurations));
        }
コード例 #9
0
        public override async Task OnPaymentStartedAsync(Payment payment, ExtraPropertyDictionary configurations)
        {
            if (payment.ActualPaymentAmount <= decimal.Zero)
            {
                throw new PaymentAmountInvalidException(payment.ActualPaymentAmount, PaymentMethod);
            }

            if (!Guid.TryParse(configurations.GetOrDefault("AccountId") as string, out var accountId))
            {
                throw new ArgumentNullException("AccountId");
            }

            var account = await _accountRepository.GetAsync(accountId);

            if (account.UserId != _currentUser.GetId())
            {
                throw new UserIsNotAccountOwnerException(_currentUser.GetId(), accountId);
            }

            payment.SetProperty("AccountId", accountId);

            var accountGroupConfiguration = _accountGroupConfigurationProvider.Get(account.AccountGroupName);

            if (!accountGroupConfiguration.AllowedUsingToTopUpOtherAccounts &&
                payment.PaymentItems.Any(x => x.ItemType == PrepaymentConsts.TopUpPaymentItemType))
            {
                throw new AccountTopingUpOtherAccountsIsNotAllowedException(account.AccountGroupName);
            }

            if (payment.PaymentItems.Any(x =>
                                         x.ItemType == PrepaymentConsts.TopUpPaymentItemType && x.ItemKey == accountId.ToString()))
            {
                throw new SelfTopUpException();
            }

            if (payment.Currency != accountGroupConfiguration.Currency)
            {
                throw new CurrencyNotSupportedException(payment.Currency);
            }

            var accountChangedBalance = -1 * payment.ActualPaymentAmount;

            var transaction = new Transaction(_guidGenerator.Create(), _currentTenant.Id, account.Id, account.UserId,
                                              payment.Id, TransactionType.Credit, PrepaymentConsts.PaymentActionName, payment.PaymentMethod,
                                              payment.ExternalTradingCode, accountGroupConfiguration.Currency, accountChangedBalance,
                                              account.Balance);

            await _transactionRepository.InsertAsync(transaction, true);

            account.ChangeBalance(accountChangedBalance);

            await _accountRepository.UpdateAsync(account, true);

            await _paymentManager.CompletePaymentAsync(payment);

            await _paymentRepository.UpdateAsync(payment, true);
        }
コード例 #10
0
    public ExtensibleObject(bool setDefaultsForExtraProperties)
    {
        ExtraProperties = new ExtraPropertyDictionary();

        if (setDefaultsForExtraProperties)
        {
            this.SetDefaultsForExtraProperties(ProxyHelper.UnProxy(this).GetType());
        }
    }
コード例 #11
0
    public static object ToEnum(this ExtraPropertyDictionary extraPropertyDictionary, string key, Type enumType)
    {
        if (!enumType.IsEnum || extraPropertyDictionary[key].GetType() == enumType)
        {
            return(extraPropertyDictionary[key]);
        }

        extraPropertyDictionary[key] = Enum.Parse(enumType, extraPropertyDictionary[key].ToString(), ignoreCase: true);
        return(extraPropertyDictionary[key]);
    }
コード例 #12
0
ファイル: Shop.cs プロジェクト: zzzzzz7946/SoMall
 public Shop(Guid id, string name, string shortName, string logoImage, string description, Guid?tenantId)
 {
     Id              = id;
     Name            = name;
     ShortName       = shortName;
     LogoImage       = logoImage;
     Description     = description;
     TenantId        = tenantId;
     ExtraProperties = new ExtraPropertyDictionary();
 }
コード例 #13
0
ファイル: Shop.cs プロジェクト: zzzzzz7946/SoMall
 public Shop(ShopData shopData)
 {
     Id              = shopData.Id;
     Name            = shopData.Name;
     ShortName       = shopData.ShortName;
     LogoImage       = shopData.ShortName;
     CoverImage      = shopData.CoverImage;
     Description     = shopData.Description;
     TenantId        = shopData.TenantId;
     ExtraProperties = new ExtraPropertyDictionary();
 }
コード例 #14
0
ファイル: OutgoingEventRecord.cs プロジェクト: younes21/abp
    public OutgoingEventRecord(
        OutgoingEventInfo eventInfo)
        : base(eventInfo.Id)
    {
        EventName    = eventInfo.EventName;
        EventData    = eventInfo.EventData;
        CreationTime = eventInfo.CreationTime;

        ExtraProperties = new ExtraPropertyDictionary();
        this.SetDefaultsForExtraProperties();
    }
コード例 #15
0
    public static T ToEnum <T>(this ExtraPropertyDictionary extraPropertyDictionary, string key)
        where T : Enum
    {
        if (extraPropertyDictionary[key].GetType() == typeof(T))
        {
            return((T)extraPropertyDictionary[key]);
        }

        extraPropertyDictionary[key] = Enum.Parse(typeof(T), extraPropertyDictionary[key].ToString(), ignoreCase: true);
        return((T)extraPropertyDictionary[key]);
    }
コード例 #16
0
 public AuditLog(
     Guid id,
     string applicationName,
     Guid?tenantId,
     string tenantName,
     Guid?userId,
     string userName,
     DateTime executionTime,
     int executionDuration,
     string clientIpAddress,
     string clientName,
     string clientId,
     string correlationId,
     string browserInfo,
     string httpMethod,
     string url,
     int?httpStatusCode,
     Guid?impersonatorUserId,
     string impersonatorUserName,
     Guid?impersonatorTenantId,
     string impersonatorTenantName,
     ExtraPropertyDictionary extraPropertyDictionary,
     List <EntityChange> entityChanges,
     List <AuditLogAction> actions,
     string exceptions,
     string comments)
     : base(id)
 {
     ApplicationName   = applicationName.Truncate(AuditLogConsts.MaxApplicationNameLength);
     TenantId          = tenantId;
     TenantName        = tenantName.Truncate(AuditLogConsts.MaxTenantNameLength);
     UserId            = userId;
     UserName          = userName.Truncate(AuditLogConsts.MaxUserNameLength);
     ExecutionTime     = executionTime;
     ExecutionDuration = executionDuration;
     ClientIpAddress   = clientIpAddress.Truncate(AuditLogConsts.MaxClientIpAddressLength);
     ClientName        = clientName.Truncate(AuditLogConsts.MaxClientNameLength);
     ClientId          = clientId.Truncate(AuditLogConsts.MaxClientIdLength);
     CorrelationId     = correlationId.Truncate(AuditLogConsts.MaxCorrelationIdLength);
     BrowserInfo       = browserInfo.Truncate(AuditLogConsts.MaxBrowserInfoLength);
     HttpMethod        = httpMethod.Truncate(AuditLogConsts.MaxHttpMethodLength);
     Url                    = url.Truncate(AuditLogConsts.MaxUrlLength);
     HttpStatusCode         = httpStatusCode;
     ImpersonatorUserId     = impersonatorUserId;
     ImpersonatorUserName   = impersonatorUserName.Truncate(AuditLogConsts.MaxUserNameLength);
     ImpersonatorTenantId   = impersonatorTenantId;
     ImpersonatorTenantName = impersonatorTenantName.Truncate(AuditLogConsts.MaxTenantNameLength);
     ExtraProperties        = extraPropertyDictionary;
     EntityChanges          = entityChanges;
     Actions                = actions;
     Exceptions             = exceptions;
     Comments               = comments.Truncate(AuditLogConsts.MaxCommentsLength);
 }
コード例 #17
0
ファイル: IncomingEventRecord.cs プロジェクト: younes21/abp
    public IncomingEventRecord(
        IncomingEventInfo eventInfo)
        : base(eventInfo.Id)
    {
        MessageId    = eventInfo.MessageId;
        EventName    = eventInfo.EventName;
        EventData    = eventInfo.EventData;
        CreationTime = eventInfo.CreationTime;

        ExtraProperties = new ExtraPropertyDictionary();
        this.SetDefaultsForExtraProperties();
    }
コード例 #18
0
 public AuditLogAction(string id, string auditLogId, AuditLogActionInfo actionInfo, string tenantId = null)
 {
     Id                = id;
     TenantId          = tenantId;
     AuditLogId        = auditLogId;
     ExecutionTime     = actionInfo.ExecutionTime;
     ExecutionDuration = actionInfo.ExecutionDuration;
     ExtraProperties   = new ExtraPropertyDictionary(actionInfo.ExtraProperties);
     ServiceName       = actionInfo.ServiceName.TruncateFromBeginning(AuditLogActionConsts.MaxServiceNameLength);
     MethodName        = actionInfo.MethodName.TruncateFromBeginning(AuditLogActionConsts.MaxMethodNameLength);
     Parameters        = actionInfo.Parameters.Length > AuditLogActionConsts.MaxParametersLength ? "" : actionInfo.Parameters;
 }
コード例 #19
0
ファイル: AuditLog.cs プロジェクト: zjc-china/abp
        public AuditLog(IGuidGenerator guidGenerator, AuditLogInfo auditInfo)
            : base(guidGenerator.Create())
        {
            ApplicationName   = auditInfo.ApplicationName.Truncate(AuditLogConsts.MaxApplicationNameLength);
            TenantId          = auditInfo.TenantId;
            TenantName        = auditInfo.TenantName.Truncate(AuditLogConsts.MaxTenantNameLength);
            UserId            = auditInfo.UserId;
            UserName          = auditInfo.UserName.Truncate(AuditLogConsts.MaxUserNameLength);
            ExecutionTime     = auditInfo.ExecutionTime;
            ExecutionDuration = auditInfo.ExecutionDuration;
            ClientIpAddress   = auditInfo.ClientIpAddress.Truncate(AuditLogConsts.MaxClientIpAddressLength);
            ClientName        = auditInfo.ClientName.Truncate(AuditLogConsts.MaxClientNameLength);
            ClientId          = auditInfo.ClientId.Truncate(AuditLogConsts.MaxClientIdLength);
            CorrelationId     = auditInfo.CorrelationId.Truncate(AuditLogConsts.MaxCorrelationIdLength);
            BrowserInfo       = auditInfo.BrowserInfo.Truncate(AuditLogConsts.MaxBrowserInfoLength);
            HttpMethod        = auditInfo.HttpMethod.Truncate(AuditLogConsts.MaxHttpMethodLength);
            Url                  = auditInfo.Url.Truncate(AuditLogConsts.MaxUrlLength);
            HttpStatusCode       = auditInfo.HttpStatusCode;
            ImpersonatorUserId   = auditInfo.ImpersonatorUserId;
            ImpersonatorTenantId = auditInfo.ImpersonatorTenantId;

            ExtraProperties = new ExtraPropertyDictionary();
            if (auditInfo.ExtraProperties != null)
            {
                foreach (var pair in auditInfo.ExtraProperties)
                {
                    ExtraProperties.Add(pair.Key, pair.Value);
                }
            }

            EntityChanges = auditInfo
                            .EntityChanges?
                            .Select(entityChangeInfo => new EntityChange(guidGenerator, Id, entityChangeInfo, tenantId: auditInfo.TenantId))
                            .ToList()
                            ?? new List <EntityChange>();

            Actions = auditInfo
                      .Actions?
                      .Select(auditLogActionInfo => new AuditLogAction(guidGenerator.Create(), Id, auditLogActionInfo, tenantId: auditInfo.TenantId))
                      .ToList()
                      ?? new List <AuditLogAction>();

            Exceptions = auditInfo
                         .Exceptions?
                         .JoinAsString(Environment.NewLine)
                         .Truncate(AuditLogConsts.MaxExceptionsLengthValue);

            Comments = auditInfo
                       .Comments?
                       .JoinAsString(Environment.NewLine)
                       .Truncate(AuditLogConsts.MaxCommentsLength);
        }
コード例 #20
0
        public ChangeAccountBalanceEto(
            Guid?tenantId,
            Guid accountId,
            decimal changedBalance,
            string actionName = PrepaymentConsts.ChangeBalanceActionName)
        {
            TenantId       = tenantId;
            AccountId      = accountId;
            ChangedBalance = changedBalance;
            ActionName     = actionName;

            ExtraProperties = new ExtraPropertyDictionary();
        }
コード例 #21
0
        public ProductAttributeOption(
            Guid id,
            [NotNull] string displayName,
            [CanBeNull] string description,
            int displayOrder = 0) : base(id)
        {
            DisplayName  = displayName;
            Description  = description;
            DisplayOrder = displayOrder;

            ExtraProperties = new ExtraPropertyDictionary();
            this.SetDefaultsForExtraProperties();
        }
コード例 #22
0
ファイル: OutgoingEventInfo.cs プロジェクト: younes21/abp
 public OutgoingEventInfo(
     Guid id,
     string eventName,
     byte[] eventData,
     DateTime creationTime)
 {
     Id              = id;
     EventName       = Check.NotNullOrWhiteSpace(eventName, nameof(eventName), MaxEventNameLength);
     EventData       = eventData;
     CreationTime    = creationTime;
     ExtraProperties = new ExtraPropertyDictionary();
     this.SetDefaultsForExtraProperties();
 }
コード例 #23
0
 public AbpMenu(Guid id, string name, string displayName, string url, string icon, int order, string permissionName, Guid?parentId = null, bool isDisabled = false, Guid?tenantId = null)
 {
     Id              = id;
     ParentId        = parentId;
     MenuName        = name;
     PermissionName  = permissionName;
     DisplayName     = displayName;
     Url             = url;
     Icon            = icon;
     Order           = order;
     IsDisabled      = isDisabled;
     TenantId        = tenantId;
     ExtraProperties = new ExtraPropertyDictionary();
 }
コード例 #24
0
ファイル: RefundItem.cs プロジェクト: EasyAbp/PaymentService
        public RefundItem(
            Guid id,
            Guid paymentItemId,
            decimal refundAmount,
            [CanBeNull] string customerRemark,
            [CanBeNull] string staffRemark) : base(id)
        {
            PaymentItemId  = paymentItemId;
            RefundAmount   = refundAmount;
            CustomerRemark = customerRemark;
            StaffRemark    = staffRemark;

            ExtraProperties = new ExtraPropertyDictionary();
            this.SetDefaultsForExtraProperties();
        }
コード例 #25
0
        public CreatePaymentEto(
            Guid?tenantId,
            Guid userId,
            string paymentMethod,
            string currency,
            List <CreatePaymentItemEto> paymentItems)
        {
            TenantId      = tenantId;
            UserId        = userId;
            PaymentMethod = paymentMethod;
            Currency      = currency;
            PaymentItems  = paymentItems;

            ExtraProperties = new ExtraPropertyDictionary();
        }
コード例 #26
0
        public PaymentItem(
            Guid id,
            [NotNull] string itemType,
            [NotNull] string itemKey,
            decimal originalPaymentAmount
            ) : base(id)
        {
            ItemType = itemType;
            ItemKey  = itemKey;
            OriginalPaymentAmount = originalPaymentAmount;
            ActualPaymentAmount   = originalPaymentAmount;

            ExtraProperties = new ExtraPropertyDictionary();
            this.SetDefaultsForExtraProperties();
        }
コード例 #27
0
        public override async Task OnPaymentStartedAsync(Payment payment, ExtraPropertyDictionary configurations)
        {
            if (payment.ActualPaymentAmount != decimal.Zero)
            {
                throw new PaymentAmountInvalidException(payment.ActualPaymentAmount, PaymentMethod);
            }

            // payment.SetPayeeAccount("None");

            // payment.SetExternalTradingCode(payment.Id.ToString());

            await _paymentManager.CompletePaymentAsync(payment);

            await _paymentRepository.UpdateAsync(payment, true);
        }
コード例 #28
0
        public OrderLine(
            Guid id,
            Guid productId,
            Guid productSkuId,
            Guid?productDetailId,
            DateTime productModificationTime,
            DateTime?productDetailModificationTime,
            [NotNull] string productGroupName,
            [NotNull] string productGroupDisplayName,
            [CanBeNull] string productUniqueName,
            [NotNull] string productDisplayName,
            [CanBeNull] string skuName,
            [CanBeNull] string skuDescription,
            [CanBeNull] string mediaResources,
            [NotNull] string currency,
            decimal unitPrice,
            decimal totalPrice,
            decimal totalDiscount,
            decimal actualTotalPrice,
            int quantity) : base(id)
        {
            ProductId                     = productId;
            ProductSkuId                  = productSkuId;
            ProductDetailId               = productDetailId;
            ProductModificationTime       = productModificationTime;
            ProductDetailModificationTime = productDetailModificationTime;
            ProductGroupName              = productGroupName;
            ProductGroupDisplayName       = productGroupDisplayName;
            ProductUniqueName             = productUniqueName;
            ProductDisplayName            = productDisplayName;
            SkuName          = skuName;
            SkuDescription   = skuDescription;
            MediaResources   = mediaResources;
            Currency         = currency;
            UnitPrice        = unitPrice;
            TotalPrice       = totalPrice;
            TotalDiscount    = totalDiscount;
            ActualTotalPrice = actualTotalPrice;
            Quantity         = quantity;

            RefundedQuantity = 0;
            RefundAmount     = 0;

            ExtraProperties = new ExtraPropertyDictionary();
            this.SetDefaultsForExtraProperties();
        }
コード例 #29
0
        public virtual async Task ConsumeAsync(GiftCard giftCard, Guid?userId, ExtraPropertyDictionary extraProperties = null)
        {
            var template = await _giftCardTemplateRepository.GetAsync(giftCard.GiftCardTemplateId);

            giftCard.Consume(_clock, userId, extraProperties);

            await _repository.UpdateAsync(giftCard, true);

            _unitOfWorkManager.Current.OnCompleted(async() => await _distributedEventBus.PublishAsync(
                                                       new GiftCardConsumedEto
            {
                GiftCardTemplateName            = template.Name,
                GiftCardTemplateExtraProperties = template.ExtraProperties,
                GiftCardCode            = giftCard.Code,
                GiftCardExtraProperties = giftCard.ExtraProperties,
                ConsumptionUserId       = userId
            }));
        }
コード例 #30
0
        public void Consume(IClock clock, Guid?userId, ExtraPropertyDictionary extraProperties = null)
        {
            CheckUsable(clock);

            ConsumptionTime   = clock.Now;
            ConsumptionUserId = userId;

            ExtraProperties = new ExtraPropertyDictionary();

            if (extraProperties.IsNullOrEmpty())
            {
                return;
            }

            foreach (var extraProperty in extraProperties)
            {
                this.SetProperty(extraProperty.Key, extraProperty.Value);
            }
        }