add order new prices , ver 0.5.7.15
parent
4100e2f8fa
commit
83393e7146
|
@ -1,7 +1,8 @@
|
|||
{
|
||||
"ConnectionStrings": {
|
||||
"PostgresServer": "User ID=postgres;Password=root;Host=localhost;Port=5432;Database=iGarsonDB;",
|
||||
"Postgres": "Host=pg-0;Username=vesmmehAgent;Password=g05CTjK358Vx3Eoc9satsWyVwo+15UmsA2dnCrZRUYh1pLTe;Database=NetinaShopDB;Application Name=NetinaShopApi"
|
||||
"Postgres": "Host=pg-0;Username=vesmmehAgent;Password=g05CTjK358Vx3Eoc9satsWyVwo+15UmsA2dnCrZRUYh1pLTe;Database=NetinaShopDB;Application Name=NetinaShopApi",
|
||||
"MartenDB": "Host=pg-0;Username=vesmmehAgent;Password=g05CTjK358Vx3Eoc9satsWyVwo+15UmsA2dnCrZRUYh1pLTe;Database=NetinaShopMartenDB;"
|
||||
},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
|
@ -16,7 +17,7 @@
|
|||
"TaxesFee": 9
|
||||
},
|
||||
"SiteSettings": {
|
||||
"BaseUrl": "https://apinetinashop.visabartar.com",
|
||||
"BaseUrl": "https://api.vesmeh.com",
|
||||
"KaveNegarApiKey": "3735494B4143727A794346457461576A2B4B6668414973424E333561505A694B",
|
||||
"UserSetting": {
|
||||
"Username": "09214802813",
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
"ConnectionStrings": {
|
||||
"PostgresServer": "User ID=postgres;Password=root;Host=localhost;Port=5432;Database=iGarsonDB;",
|
||||
"Postgres": "Host=pg-0,pg-1;Username=igarsonAgent;Password=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=NetinaShopDB;Load Balance Hosts=true;Target Session Attributes=primary;Application Name=iGLS",
|
||||
"Marten": "Host=pg-0,pg-1;Username=igarsonAgent;Password=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=NetinaShopSettingsDB;",
|
||||
"SettingDB": "Host=pg-0,pg-1;Username=igarsonAgent;Password=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=NetinaShopSettingDB;Load Balance Hosts=true;Target Session Attributes=primary;Application Name=iGLS"
|
||||
"MartenDB": "Host=pg-0,pg-1;Username=igarsonAgent;Password=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=NetinaShopMartenDB;"
|
||||
},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
|
|
|
@ -51,8 +51,14 @@ public class OrderBagController : ICarterModule
|
|||
=> TypedResults.Ok(await mediator.Send(new SubmitDiscountCommand(orderId, discountCode), cancellationToken));
|
||||
|
||||
public async Task<IResult> AddShippingToOrderBagAsync(Guid orderId, [FromBody] SubmitOrderDeliveryCommand request, IMediator mediator, CancellationToken cancellationToken)
|
||||
=> TypedResults.Ok( await mediator.Send(new SubmitOrderDeliveryCommand(request.AddressId, orderId, request.ShippingId), cancellationToken));
|
||||
=> TypedResults.Ok(await mediator.Send(new SubmitOrderDeliveryCommand(request.AddressId, orderId, request.ShippingId), cancellationToken));
|
||||
|
||||
public async Task<IResult> SubmitOrderPaymentAsync(Guid orderId, [FromQuery] OrderPaymentMethod paymentMethod, IMediator mediator, CancellationToken cancellationToken)
|
||||
=> TypedResults.Ok( await mediator.Send(new SubmitOrderPaymentCommand(orderId, paymentMethod), cancellationToken));
|
||||
{
|
||||
var result = await mediator.Send(new SubmitOrderPaymentCommand(orderId, paymentMethod), cancellationToken);
|
||||
if (result.NeedToPayOnline)
|
||||
return TypedResults.Redirect(result.PaymentUrl,true);
|
||||
else
|
||||
return TypedResults.Ok(result);
|
||||
}
|
||||
}
|
|
@ -6,8 +6,8 @@
|
|||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<InvariantGlobalization>true</InvariantGlobalization>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
<AssemblyVersion>0.5.4.13</AssemblyVersion>
|
||||
<FileVersion>0.5.4.13</FileVersion>
|
||||
<AssemblyVersion>0.5.7.15</AssemblyVersion>
|
||||
<FileVersion>0.5.7.15</FileVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -66,7 +66,7 @@ public static class ServiceExtensions
|
|||
serviceCollection.AddMarten(options =>
|
||||
{
|
||||
// Establish the connection string to your Marten database
|
||||
options.Connection(configuration.GetConnectionString("Marten")!);
|
||||
options.Connection(configuration.GetConnectionString("MartenDB")!);
|
||||
|
||||
// If we're running in development mode, let Marten just take care
|
||||
// of all necessary schema building and patching behind the scenes
|
||||
|
|
|
@ -21,15 +21,12 @@ public class CalculateOrderDiscountCommandHandler : IRequestHandler<CalculateOrd
|
|||
throw new AppException("تخفیف وجود منقضی شده است یا وجود ندارد", ApiResultStatusCode.NotFound);
|
||||
|
||||
double discountPrice = 0;
|
||||
|
||||
double totalPrice = 0;
|
||||
if (discount.Type == DiscountType.All)
|
||||
{
|
||||
if (!discount.IsExpired())
|
||||
{
|
||||
var totalPrice = request.Order.OrderProducts.Sum(op => op.ProductCost);
|
||||
discountPrice = discount.AmountType == DiscountAmountType.Amount
|
||||
? totalPrice - discount.DiscountAmount
|
||||
: totalPrice - ((totalPrice / 100) * discount.DiscountAmount);
|
||||
totalPrice = request.Order.OrderProducts.Sum(op => op.ProductCost);
|
||||
}
|
||||
}
|
||||
else if (discount.Type == DiscountType.Category)
|
||||
|
@ -39,10 +36,8 @@ public class CalculateOrderDiscountCommandHandler : IRequestHandler<CalculateOrd
|
|||
.FirstOrDefaultAsync(d => d.Code == request.DiscountCode, cancellationToken);
|
||||
if ( categoryDiscount!=null && !categoryDiscount.IsExpired())
|
||||
{
|
||||
var totalPrice = request.Order.OrderProducts.Where(op => op.ProductCategoryId == categoryDiscount.CategoryId).Sum(op => op.ProductCost);
|
||||
discountPrice = discount.AmountType == DiscountAmountType.Amount
|
||||
? totalPrice - discount.DiscountAmount
|
||||
: totalPrice - ((totalPrice / 100) * discount.DiscountAmount);
|
||||
totalPrice = request.Order.OrderProducts.Where(op => op.ProductCategoryId == categoryDiscount.CategoryId).Sum(op => op.ProductCost);
|
||||
|
||||
}
|
||||
}
|
||||
else if (discount.Type == DiscountType.Product)
|
||||
|
@ -53,10 +48,8 @@ public class CalculateOrderDiscountCommandHandler : IRequestHandler<CalculateOrd
|
|||
|
||||
if (productDiscount != null && !productDiscount.IsExpired())
|
||||
{
|
||||
var totalPrice = request.Order.OrderProducts.Where(op => op.ProductId == productDiscount!.ProductId).Sum(op => op.ProductCost);
|
||||
discountPrice = discount.AmountType == DiscountAmountType.Amount
|
||||
? totalPrice - discount.DiscountAmount
|
||||
: totalPrice - ((totalPrice / 100) * discount.DiscountAmount);
|
||||
totalPrice = request.Order.OrderProducts.Where(op => op.ProductId == productDiscount!.ProductId).Sum(op => op.ProductCost);
|
||||
|
||||
}
|
||||
}
|
||||
else if (discount.Type == DiscountType.Subscriber)
|
||||
|
@ -64,6 +57,9 @@ public class CalculateOrderDiscountCommandHandler : IRequestHandler<CalculateOrd
|
|||
throw new NotImplementedException("Subscribe discount not implemented");
|
||||
}
|
||||
|
||||
discountPrice = discount.AmountType == DiscountAmountType.Amount
|
||||
? discount.DiscountAmount
|
||||
: ((totalPrice / 100) * discount.DiscountPercent);
|
||||
return discountPrice;
|
||||
}
|
||||
}
|
|
@ -20,21 +20,23 @@ public class CalculateOrderCommandHandler : IRequestHandler<CalculateOrderComman
|
|||
throw new AppException("Order is not in bag status and cant be calculate", ApiResultStatusCode.BadRequest);
|
||||
var totalProductPrice = order.OrderProducts.Sum(op => op.ProductFee * op.Count);
|
||||
var totalPackingPrice = order.OrderProducts.Sum(op => op.PackingCost);
|
||||
|
||||
//var servicePrice = _shopSettings.ServiceIsPercent
|
||||
// ? (totalProductPrice / 100) * _shopSettings.ServiceFee
|
||||
// : _shopSettings.ServiceFee;
|
||||
|
||||
var servicePrice = 0;
|
||||
var deliveryPrice = order.OrderDelivery?.DeliveryCost ?? 0;
|
||||
double discountPrice = order.OrderProducts.Sum(op=>(op.ProductFee - op.ProductFeeWithDiscount) * op.Count);
|
||||
double productDiscountPrice = order.OrderProducts.Sum(op=>(op.ProductFee - op.ProductFeeWithDiscount) * op.Count);
|
||||
double discountCodePrice = 0;
|
||||
if (!order.DiscountCode.IsNullOrEmpty())
|
||||
{
|
||||
discountPrice += await _mediator.Send(new CalculateOrderDiscountCommand(order.DiscountCode, order),cancellationToken);
|
||||
}
|
||||
discountCodePrice += await _mediator.Send(new CalculateOrderDiscountCommand(order.DiscountCode, order),cancellationToken);
|
||||
|
||||
//var taxesPrice = (((totalProductPrice - discountPrice) + totalPackingPrice + servicePrice) / 100) * _shopSettings.TaxesFee;
|
||||
|
||||
var taxesPrice = 0;
|
||||
|
||||
order.SetTotalPrice(totalProductPrice, totalPackingPrice, servicePrice, deliveryPrice, discountPrice, taxesPrice);
|
||||
order.SetTotalPrice(totalProductPrice, totalPackingPrice, servicePrice, deliveryPrice, productDiscountPrice, discountCodePrice, taxesPrice);
|
||||
order.OrderProducts.Clear();
|
||||
order.OrderDelivery = null;
|
||||
_repositoryWrapper.SetRepository<Order>().Update(order);
|
||||
|
|
|
@ -8,6 +8,8 @@ public class OrderLDto : BaseDto<OrderLDto,Order>
|
|||
public long ServicePrice { get; set; }
|
||||
public long PackingPrice { get; set; }
|
||||
public long TotalProductsPrice { get; set; }
|
||||
public double DiscountCodePrice { get; set; }
|
||||
public double ProductDiscountPrice { get; set; }
|
||||
public long DiscountPrice { get; set; }
|
||||
public bool IsPayed { get; set; }
|
||||
public OrderStatus OrderStatus { get; set; }
|
||||
|
|
|
@ -9,6 +9,8 @@ public class OrderSDto : BaseDto<OrderSDto, Order>
|
|||
public double PackingPrice { get; set; }
|
||||
public double TotalProductsPrice { get; set; }
|
||||
public double DiscountPrice { get; set; }
|
||||
public double DiscountCodePrice { get; set; }
|
||||
public double ProductDiscountPrice { get; set; }
|
||||
public bool IsPayed { get; set; }
|
||||
public OrderStatus OrderStatus { get; set; }
|
||||
public DateTime PayedAt { get; set; }
|
||||
|
|
|
@ -90,7 +90,8 @@ public partial class Order
|
|||
double packingPrice,
|
||||
double servicePrice,
|
||||
double deliveryPrice,
|
||||
double discountPrice,
|
||||
double productDiscountPrice,
|
||||
double discountCodePrice,
|
||||
double taxesPrice)
|
||||
{
|
||||
TotalProductsPrice = totalProductPrice;
|
||||
|
@ -98,8 +99,10 @@ public partial class Order
|
|||
ServicePrice = servicePrice;
|
||||
DeliveryPrice = deliveryPrice;
|
||||
TaxesPrice = taxesPrice;
|
||||
DiscountPrice = discountPrice;
|
||||
TotalPrice = (totalProductPrice + packingPrice + servicePrice + deliveryPrice + taxesPrice) - discountPrice;
|
||||
DiscountCodePrice = discountCodePrice;
|
||||
ProductDiscountPrice = productDiscountPrice;
|
||||
DiscountPrice = productDiscountPrice+discountCodePrice;
|
||||
TotalPrice = (totalProductPrice + packingPrice + servicePrice + deliveryPrice + taxesPrice) - DiscountPrice;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -55,6 +55,8 @@ public partial class Order : ApiEntity
|
|||
public double ServicePrice { get; internal set; }
|
||||
public double DeliveryPrice { get; internal set; }
|
||||
public double DiscountPrice { get; internal set; }
|
||||
public double DiscountCodePrice { get; internal set; }
|
||||
public double ProductDiscountPrice { get; internal set; }
|
||||
public double TaxesPrice { get; internal set; }
|
||||
public double TotalPrice { get; internal set; }
|
||||
public bool IsPayed { get; internal set; }
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
public enum OrderPaymentMethod
|
||||
{
|
||||
[Display(Name = "پرداخت درب محل")]
|
||||
PayOnDoor,
|
||||
PayOnDoor = 0,
|
||||
[Display(Name = "پرداخت انلاین")]
|
||||
OnlinePayment,
|
||||
OnlinePayment = 1,
|
||||
[Display(Name = "پرداخت کارت به کارت")]
|
||||
CardTransfer,
|
||||
CardTransfer = 2,
|
||||
[Display(Name = "نقدی")]
|
||||
Cash,
|
||||
Cash = 3,
|
||||
}
|
|
@ -25,6 +25,8 @@ namespace NetinaShop.Domain.Mappers
|
|||
ServicePrice = (double)p1.ServicePrice,
|
||||
DeliveryPrice = (double)p1.DeliveryPrice,
|
||||
DiscountPrice = (double)p1.DiscountPrice,
|
||||
DiscountCodePrice = p1.DiscountCodePrice,
|
||||
ProductDiscountPrice = p1.ProductDiscountPrice,
|
||||
TaxesPrice = (double)p1.TaxesPrice,
|
||||
TotalPrice = (double)p1.TotalPrice,
|
||||
IsPayed = p1.IsPayed,
|
||||
|
@ -66,6 +68,8 @@ namespace NetinaShop.Domain.Mappers
|
|||
result.ServicePrice = (double)p4.ServicePrice;
|
||||
result.DeliveryPrice = (double)p4.DeliveryPrice;
|
||||
result.DiscountPrice = (double)p4.DiscountPrice;
|
||||
result.DiscountCodePrice = p4.DiscountCodePrice;
|
||||
result.ProductDiscountPrice = p4.ProductDiscountPrice;
|
||||
result.TaxesPrice = (double)p4.TaxesPrice;
|
||||
result.TotalPrice = (double)p4.TotalPrice;
|
||||
result.IsPayed = p4.IsPayed;
|
||||
|
@ -91,6 +95,8 @@ namespace NetinaShop.Domain.Mappers
|
|||
ServicePrice = (double)p18.ServicePrice,
|
||||
DeliveryPrice = (double)p18.DeliveryPrice,
|
||||
DiscountPrice = (double)p18.DiscountPrice,
|
||||
DiscountCodePrice = p18.DiscountCodePrice,
|
||||
ProductDiscountPrice = p18.ProductDiscountPrice,
|
||||
TaxesPrice = (double)p18.TaxesPrice,
|
||||
TotalPrice = (double)p18.TotalPrice,
|
||||
IsPayed = p18.IsPayed,
|
||||
|
@ -168,6 +174,8 @@ namespace NetinaShop.Domain.Mappers
|
|||
ServicePrice = (long)p21.ServicePrice,
|
||||
PackingPrice = (long)p21.PackingPrice,
|
||||
TotalProductsPrice = (long)p21.TotalProductsPrice,
|
||||
DiscountCodePrice = p21.DiscountCodePrice,
|
||||
ProductDiscountPrice = p21.ProductDiscountPrice,
|
||||
DiscountPrice = (long)p21.DiscountPrice,
|
||||
IsPayed = p21.IsPayed,
|
||||
OrderStatus = p21.OrderStatus,
|
||||
|
@ -209,6 +217,8 @@ namespace NetinaShop.Domain.Mappers
|
|||
result.ServicePrice = (long)p24.ServicePrice;
|
||||
result.PackingPrice = (long)p24.PackingPrice;
|
||||
result.TotalProductsPrice = (long)p24.TotalProductsPrice;
|
||||
result.DiscountCodePrice = p24.DiscountCodePrice;
|
||||
result.ProductDiscountPrice = p24.ProductDiscountPrice;
|
||||
result.DiscountPrice = (long)p24.DiscountPrice;
|
||||
result.IsPayed = p24.IsPayed;
|
||||
result.OrderStatus = p24.OrderStatus;
|
||||
|
@ -235,6 +245,8 @@ namespace NetinaShop.Domain.Mappers
|
|||
ServicePrice = (long)p32.ServicePrice,
|
||||
PackingPrice = (long)p32.PackingPrice,
|
||||
TotalProductsPrice = (long)p32.TotalProductsPrice,
|
||||
DiscountCodePrice = p32.DiscountCodePrice,
|
||||
ProductDiscountPrice = p32.ProductDiscountPrice,
|
||||
DiscountPrice = (long)p32.DiscountPrice,
|
||||
IsPayed = p32.IsPayed,
|
||||
OrderStatus = p32.OrderStatus,
|
||||
|
@ -301,6 +313,8 @@ namespace NetinaShop.Domain.Mappers
|
|||
ServicePrice = p35.ServicePrice,
|
||||
DeliveryPrice = p35.DeliveryPrice,
|
||||
DiscountPrice = p35.DiscountPrice,
|
||||
DiscountCodePrice = p35.DiscountCodePrice,
|
||||
ProductDiscountPrice = p35.ProductDiscountPrice,
|
||||
TaxesPrice = p35.TaxesPrice,
|
||||
TotalPrice = p35.TotalPrice,
|
||||
IsPayed = p35.IsPayed,
|
||||
|
@ -334,6 +348,8 @@ namespace NetinaShop.Domain.Mappers
|
|||
result.ServicePrice = p36.ServicePrice;
|
||||
result.DeliveryPrice = p36.DeliveryPrice;
|
||||
result.DiscountPrice = p36.DiscountPrice;
|
||||
result.DiscountCodePrice = p36.DiscountCodePrice;
|
||||
result.ProductDiscountPrice = p36.ProductDiscountPrice;
|
||||
result.TaxesPrice = p36.TaxesPrice;
|
||||
result.TotalPrice = p36.TotalPrice;
|
||||
result.IsPayed = p36.IsPayed;
|
||||
|
@ -362,6 +378,8 @@ namespace NetinaShop.Domain.Mappers
|
|||
PackingPrice = p40.PackingPrice,
|
||||
TotalProductsPrice = p40.TotalProductsPrice,
|
||||
DiscountPrice = p40.DiscountPrice,
|
||||
DiscountCodePrice = p40.DiscountCodePrice,
|
||||
ProductDiscountPrice = p40.ProductDiscountPrice,
|
||||
IsPayed = p40.IsPayed,
|
||||
OrderStatus = p40.OrderStatus,
|
||||
PayedAt = p40.PayedAt,
|
||||
|
@ -392,6 +410,8 @@ namespace NetinaShop.Domain.Mappers
|
|||
result.PackingPrice = p41.PackingPrice;
|
||||
result.TotalProductsPrice = p41.TotalProductsPrice;
|
||||
result.DiscountPrice = p41.DiscountPrice;
|
||||
result.DiscountCodePrice = p41.DiscountCodePrice;
|
||||
result.ProductDiscountPrice = p41.ProductDiscountPrice;
|
||||
result.IsPayed = p41.IsPayed;
|
||||
result.OrderStatus = p41.OrderStatus;
|
||||
result.PayedAt = p41.PayedAt;
|
||||
|
@ -417,6 +437,8 @@ namespace NetinaShop.Domain.Mappers
|
|||
PackingPrice = p43.PackingPrice,
|
||||
TotalProductsPrice = p43.TotalProductsPrice,
|
||||
DiscountPrice = p43.DiscountPrice,
|
||||
DiscountCodePrice = p43.DiscountCodePrice,
|
||||
ProductDiscountPrice = p43.ProductDiscountPrice,
|
||||
IsPayed = p43.IsPayed,
|
||||
OrderStatus = p43.OrderStatus,
|
||||
PayedAt = p43.PayedAt,
|
||||
|
|
1685
NetinaShop.Repository/Migrations/20240213103856_EditOrderAddProductDiscount.Designer.cs
generated
100644
1685
NetinaShop.Repository/Migrations/20240213103856_EditOrderAddProductDiscount.Designer.cs
generated
100644
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,44 @@
|
|||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace NetinaShop.Repository.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class EditOrderAddProductDiscount : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<double>(
|
||||
name: "DiscountCodePrice",
|
||||
schema: "public",
|
||||
table: "Orders",
|
||||
type: "double precision",
|
||||
nullable: false,
|
||||
defaultValue: 0.0);
|
||||
|
||||
migrationBuilder.AddColumn<double>(
|
||||
name: "ProductDiscountPrice",
|
||||
schema: "public",
|
||||
table: "Orders",
|
||||
type: "double precision",
|
||||
nullable: false,
|
||||
defaultValue: 0.0);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "DiscountCodePrice",
|
||||
schema: "public",
|
||||
table: "Orders");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ProductDiscountPrice",
|
||||
schema: "public",
|
||||
table: "Orders");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -455,6 +455,9 @@ namespace NetinaShop.Repository.Migrations
|
|||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("DiscountCodePrice")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<Guid?>("DiscountId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
|
@ -498,6 +501,9 @@ namespace NetinaShop.Repository.Migrations
|
|||
b.Property<int>("PreparingMinute")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double>("ProductDiscountPrice")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<DateTime>("RemovedAt")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
|
|
Loading…
Reference in New Issue