protected override void OnModelCreating(ModelBuilder builder)
        {
            base.OnModelCreating(builder);

            // Configuration of the Identity Class
            IdentityUserRoleConfig.ConfigurationIdentityUserRole(builder);
            IdentityUserClaimConfig.ConfigurationIdentityUserClaim(builder);
            IdentityRoleClaimConfig.ConfigurationIdentityRoleClaim(builder);
            IdentityUserTokenConfig.ConfigurationIdentityUserToken(builder);
            IdentityUserLoginConfig.ConfigurationIdentityUserLogin(builder);

            // Configuration of the Marmify Class
            UserConfig.ConfigurationUser(builder);
            ItemConfig.ConfigurationItem(builder);
            PaymentConditionConfig.ConfigurationPaymentCondition(builder);
            PurchaseOrderConfig.ConfigurationPurchaseOrder(builder);
            EstablishmentConfig.ConfigurationEstablishment(builder);
            ItemPurchaseConfig.ConfigurationItemPurchase(builder);
            UserFavoritesConfig.ConfigurationUserFavorites(builder);
            AddressConfig.ConfigurationAddress(builder);
            DeliveryConfig.ConfigurationDelivery(builder);
            DeliveryTypeConfig.ConfigurationDeliveryType(builder);

            ApplicationRoleConfig.ConfigurationApplicationRole(builder);
            //UserRoleConfig.ConfigurationUserRole(builder);

            // Do not change
            builder.Entity <Establishment>()
            .HasData(
                new Establishment
            {
                Id            = 1,
                CorporateName = "Administration",
                Cnpj          = "N/A",
                CompanyName   = "Administration",
                Email         = "N/A",
                Phone         = "N/A",
                Address       = "N/A",
                Number        = 0,
                Neighborhood  = "N/A",
                IsPartner     = false
            },
                new Establishment
            {
                Id            = 2,
                CorporateName = "User",
                Cnpj          = "N/A",
                CompanyName   = "User",
                Email         = "N/A",
                Phone         = "N/A",
                Address       = "N/A",
                Number        = 0,
                Neighborhood  = "N/A",
                IsPartner     = false
            });
        }
Exemplo n.º 2
0
        public DeliveryDiscount GetDiscount(int aid, int amount)
        {
            DeliveryConfig config      = DeliveryConfigBLL.SingleModel.GetStoreConfig(aid);
            bool           hasDiscount = config != null && config.Attr.DiscountEnable && config.Attr.Discount <= amount;

            return(new DeliveryDiscount
            {
                HasDiscount = hasDiscount,
                DiscountPrice = hasDiscount ? 0 : amount,
                DiscountInfo = hasDiscount ? $"购买金额满{config.Attr.Discount * 0.01}元,减免运费 " : null,
            });
        }
Exemplo n.º 3
0
        public DeliveryFeeResult GetDeliveryFee(BargainUser bargainOrder, string province, string city, DeliveryFeeSumMethond sumMethod, DeliveryConfig config = null)
        {
            if (config == null)
            {
                config = DeliveryConfigBLL.SingleModel.GetConfig(new Bargain {
                    Id = bargainOrder.BId
                });
            }
            DeliveryProduct formatProduct = new DeliveryProduct
            {
                Count      = 1,
                Name       = bargainOrder.BName,
                TemplateId = config.Attr.DeliveryTemplateId,
                Weight     = config.Attr.Weight,
                Amount     = bargainOrder.CurrentPrice,
            };

            DeliveryFeeResult result = GetDeliveryFeeCommon(new List <DeliveryProduct> {
                formatProduct
            }, province, city, sumMethod);

            if (result.InRange)
            {
                DeliveryDiscount discount = GetDiscount(bargainOrder.aid, bargainOrder.CurrentPrice);
                result.Fee     = discount.HasDiscount ? discount.DiscountPrice : result.Fee;
                result.Message = discount.HasDiscount ? discount.DiscountInfo : result.Message;
            }
            return(result);
        }