fix calculate issue

subProduct
Amir Hossein Khademi 2024-09-30 22:09:39 +03:30
parent a1f2e92863
commit cfb293c135
5 changed files with 20 additions and 7 deletions

View File

@ -1 +1 @@
1.5.17.23
1.5.17.26

View File

@ -6,8 +6,8 @@
<ImplicitUsings>enable</ImplicitUsings>
<InvariantGlobalization>true</InvariantGlobalization>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<AssemblyVersion>1.5.17.23</AssemblyVersion>
<FileVersion>1.5.17.23</FileVersion>
<AssemblyVersion>1.5.17.26</AssemblyVersion>
<FileVersion>1.5.17.26</FileVersion>
</PropertyGroup>
<ItemGroup>

View File

@ -72,7 +72,7 @@ public static class ServiceExtensions
serviceCollection.AddDbContextFactory<ApplicationContext>(options =>
{
options.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking);
options.UseNpgsql(Configuration.GetConnectionString("PostgresServer"), b => b.MigrationsAssembly("Netina.Repository"))
options.UseNpgsql(Configuration.GetConnectionString("Postgres"), b => b.MigrationsAssembly("Netina.Repository"))
.UseProjectAssembly(typeof(ApplicationUser).Assembly);
//options.EnableServiceProviderCaching(true);

View File

@ -70,7 +70,7 @@ public class CalculateProductDiscountCommandHandler(IRepositoryWrapper repositor
if (request.DiscountPercent == 0)
{
request.CostWithDiscount = 0;
request.CostWithDiscount = request.Cost;
request.HasDiscount = false;
}
@ -131,6 +131,12 @@ public class CalculateProductDiscountCommandHandler(IRepositoryWrapper repositor
request.CostWithDiscount = discountPrice;
request.DiscountPercent = request.Cost == 0 ? 0 : 100 - 100 * request.CostWithDiscount / request.Cost;
}
if (request.DiscountPercent == 0)
{
request.CostWithDiscount = request.Cost;
request.HasDiscount = false;
}
return request;
}

View File

@ -30,7 +30,7 @@ public partial class Order
}
else
{
orderProduct.SetCount(count);
orderProduct.SetCount(count,cost,costWithDiscount,packingCost);
}
}
public void RemoveFromOrderBag(Guid productId, int count)
@ -175,7 +175,14 @@ public partial class OrderProduct
public void SetCount(int count)
{
Count = count;
var productCost = ProductFeeWithDiscount * Count;
}
public void SetCount(int count,double productFee,double costWithDiscount,double packingFee)
{
Count = count;
ProductFee = productFee;
PackingFee = packingFee;
ProductFeeWithDiscount = costWithDiscount;
ProductCost = ProductFeeWithDiscount * Count;
}
}