From 93539c7a96fce7feed37d6a73983991f2d46212d Mon Sep 17 00:00:00 2001 From: Galip Tolga Erdem Date: Sat, 8 Jan 2022 00:34:44 +0300 Subject: [PATCH] added my order ui --- .../Basket/BasketWidgetViewComponent.cs | 4 +- .../Payment/PaymentWidgetViewComponent.cs | 2 +- .../Components/Purchase/Default.cshtml | 1 + .../Toolbar/Cart/CartWidgetViewComponent.cs | 4 +- .../Pages/MyOrders.cshtml | 125 ++++++++++++++---- .../Pages/Payment.cshtml.cs | 38 ++++-- .../src/EShopOnAbp.PublicWeb/Pages/index.js | 2 - .../EShopOnAbp.PublicWeb/Pages/myOrders.css | 16 +++ .../EShopOnAbp.PublicWeb/Pages/myOrders.js | 19 +++ .../src/EShopOnAbp.PublicWeb/Pages/payment.js | 2 +- .../ServiceProviders/DiscountProvider.cs | 9 ++ .../UserAddressProvider.cs | 2 +- .../UserBasketProvider.cs | 10 +- .../components/basket/basket-widget.css | 19 ++- 14 files changed, 198 insertions(+), 55 deletions(-) create mode 100644 apps/public-web/src/EShopOnAbp.PublicWeb/Pages/myOrders.css create mode 100644 apps/public-web/src/EShopOnAbp.PublicWeb/ServiceProviders/DiscountProvider.cs rename apps/public-web/src/EShopOnAbp.PublicWeb/{Basket => ServiceProviders}/UserAddressProvider.cs (96%) rename apps/public-web/src/EShopOnAbp.PublicWeb/{Basket => ServiceProviders}/UserBasketProvider.cs (95%) diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Basket/BasketWidgetViewComponent.cs b/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Basket/BasketWidgetViewComponent.cs index 05ebab88..308e0dc6 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Basket/BasketWidgetViewComponent.cs +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Basket/BasketWidgetViewComponent.cs @@ -1,6 +1,6 @@ -using EShopOnAbp.PublicWeb.Basket; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; using System.Threading.Tasks; +using EShopOnAbp.PublicWeb.ServiceProviders; using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc.UI.Widgets; diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Payment/PaymentWidgetViewComponent.cs b/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Payment/PaymentWidgetViewComponent.cs index 92b281fa..e0335a7a 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Payment/PaymentWidgetViewComponent.cs +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Payment/PaymentWidgetViewComponent.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Threading.Tasks; using EShopOnAbp.BasketService; -using EShopOnAbp.PublicWeb.Basket; +using EShopOnAbp.PublicWeb.ServiceProviders; using Microsoft.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc.UI.Widgets; diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Purchase/Default.cshtml b/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Purchase/Default.cshtml index 1722a34c..09bf2ff9 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Purchase/Default.cshtml +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Purchase/Default.cshtml @@ -55,6 +55,7 @@
@Html.AntiForgeryToken() +
diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Toolbar/Cart/CartWidgetViewComponent.cs b/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Toolbar/Cart/CartWidgetViewComponent.cs index ce214c76..04ca8d5b 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Toolbar/Cart/CartWidgetViewComponent.cs +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Toolbar/Cart/CartWidgetViewComponent.cs @@ -1,6 +1,6 @@ -using EShopOnAbp.PublicWeb.Basket; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; using System.Threading.Tasks; +using EShopOnAbp.PublicWeb.ServiceProviders; using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc.UI.Widgets; diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/MyOrders.cshtml b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/MyOrders.cshtml index d340cf92..08f2c4fa 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/MyOrders.cshtml +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/MyOrders.cshtml @@ -1,39 +1,114 @@ @page @using EShopOnAbp.Localization @using Microsoft.Extensions.Localization +@using System.Globalization @model EShopOnAbp.PublicWeb.Pages.MyOrdersModel @inject IStringLocalizer L @section scripts { + } -

Hello

+@section styles{ + +} + +
+ @Model.MyOrders.Count sipariş verildi. +
-@foreach (var item in Model.MyOrders) +@foreach (var order in Model.MyOrders) { - - -
@item.OrderDate
-

@item.OrderStatus

-

@item.Buyer.Name

- - @foreach (var product in item.Items) - { - - - - - - -

@product.ProductName x @product.Units

-
-
-
- } -
-
-
+
+
+
+
+
Sipariş Tarihi
+
@order.OrderDate.ToString("dd MMMM yyyy")
+
+
+
TOPLAM
+
@order.Items.Sum(q => q.UnitPrice)
+
+
+
TESLİMAT ADRESİ
+
@order.Address.Description
+
+
+
SİPARİŞ NO @order.OrderNo.ToString("N0", new NumberFormatInfo() {NumberGroupSeparator = " "})
+
+
+
+
+ @foreach (var item in order.Items) + { + + +
+

@order.OrderStatus

+
+ + + + + +
@item.ProductName
+
Ürünü iade edebileceğiniz son tarih: @order.OrderDate.AddMonths(1).ToString("dd MMMM yyyy")
+
+ +
+
+ + Ürünleri iade et + Ürün yorumu yazın + +
+
+
+ } +
+

-} \ No newline at end of file +} + + + + + + + + + + + + + + +@* @foreach (var item in Model.MyOrders) *@ +@* { *@ +@* *@ +@* *@ +@*
@item.OrderDate
*@ +@*

@item.OrderStatus

*@ +@*

@item.Buyer.Name

*@ +@* *@ +@* @foreach (var product in item.Items) *@ +@* { *@ +@* *@ +@* *@ +@* *@ +@* *@ +@* *@ +@* *@ +@*

@product.ProductName x @product.Units

*@ +@*
*@ +@*
*@ +@*
*@ +@* } *@ +@*
*@ +@*
*@ +@*
*@ +@*
*@ +@* } *@ \ No newline at end of file diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Payment.cshtml.cs b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Payment.cshtml.cs index 54aeeb96..d4191c8c 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Payment.cshtml.cs +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Payment.cshtml.cs @@ -1,6 +1,6 @@ -using EShopOnAbp.BasketService; +using System; +using EShopOnAbp.BasketService; using EShopOnAbp.PaymentService.PaymentRequests; -using EShopOnAbp.PublicWeb.Basket; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; @@ -9,6 +9,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using EShopOnAbp.OrderingService.Orders; +using EShopOnAbp.PublicWeb.ServiceProviders; using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; using Volo.Abp.Users; @@ -46,13 +47,21 @@ public class PaymentModel : AbpPageModel Logger.LogInformation("Payment Proceeded..."); Logger.LogInformation($"AddressId: {model.SelectedAddressId}"); Logger.LogInformation($"PaymentId: {model.SelectedPaymentId}"); + Logger.LogInformation($"Total Discount: {model.TotalDiscountPercentage}"); var basket = await _userBasketProvider.GetBasketAsync(); + var productItems = ObjectMapper.Map, List>(basket.Items); + + if (model.TotalDiscountPercentage != 0) + { + ApplyDiscountPercentageToBasketItems(productItems, model.TotalDiscountPercentage); + } + var placedOrder = await _orderAppService.CreateAsync(new OrderCreateDto() { PaymentTypeId = 1, // Paypal Address = GetUserAddress(model.SelectedAddressId), - Products = ObjectMapper.Map, List>(basket.Items) + Products = productItems }); var paymentRequest = await _paymentRequestAppService.CreateAsync(new PaymentRequestCreationDto @@ -74,22 +83,31 @@ public class PaymentModel : AbpPageModel return Redirect(response.CheckoutLink); } + public class PaymentPageViewModel + { + public int SelectedAddressId { get; set; } + public int SelectedPaymentId { get; set; } + public decimal TotalDiscountPercentage { get; set; } + } + + private void ApplyDiscountPercentageToBasketItems(List productItems, decimal discount) + { + for (int i = 0; i < productItems.Count; i++) + { + productItems[i].Discount = discount; + } + } + private OrderAddressDto GetUserAddress(int selectedAddressId) { var address = _userAddressProvider.GetDemoAddresses().First(q => q.Id == selectedAddressId); return new OrderAddressDto { + Description = address.Type, City = address.City, Country = address.Country, - Description = address.Type, Street = address.Street, ZipCode = address.ZipCode }; } - - public class PaymentPageViewModel - { - public int SelectedAddressId { get; set; } - public int SelectedPaymentId { get; set; } - } } \ No newline at end of file diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/index.js b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/index.js index 04c54ef9..c9ed2841 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/index.js +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/index.js @@ -6,7 +6,6 @@ } $(function () { - $('.product-list-item').click(function () { var $this = $(this); var productId = $this.attr('data-product-id'); @@ -14,7 +13,6 @@ productId: productId, anonymousId: anonymousId, }).then(function () { - $('.abp-widget-wrapper[data-widget-name="CartWidget"]') .data('abp-widget-manager') .refresh(); diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/myOrders.css b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/myOrders.css new file mode 100644 index 00000000..4d842359 --- /dev/null +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/myOrders.css @@ -0,0 +1,16 @@ +.img-size { + width: 80%; +} +.order-item { + width:-webkit-fill-available; + background-color: #fff; + border: 1px solid #eee; + border-radius: 3px; + box-shadow: 0 0 10px rgba(0, 0, 0, .05); + transition: all .2s; + cursor: default; +} + +.order-item:hover { + box-shadow: 0 0 20px rgba(0, 0, 0, .1); +} \ No newline at end of file diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/myOrders.js b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/myOrders.js index e69de29b..b6b81532 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/myOrders.js +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/myOrders.js @@ -0,0 +1,19 @@ +(function () { + const anonymousId = abp.utils.getCookieValue("anonymous_id"); + $(function () { + $('.buy-again').click(function () { + const $this = $(this); + const productId = $this.attr('data-product-id'); + eShopOnAbp.basketService.basket.addProduct({ + productId: productId, + anonymousId: anonymousId, + }).then(function () { + $('.abp-widget-wrapper[data-widget-name="CartWidget"]') + .data('abp-widget-manager') + .refresh(); + + abp.notify.success("Added product to your basket.", "Successfully added"); + }); + }); + }); +})(); \ No newline at end of file diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/payment.js b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/payment.js index c102cea6..fd41fe8f 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/payment.js +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/payment.js @@ -12,6 +12,6 @@ paymentInput.setAttribute('name', "model.SelectedPaymentId"); paymentInput.setAttribute('value', document.querySelector(".payment-list .card.is-selected").getAttribute("data-payment-id")); paymentInput.setAttribute('type', "hidden"); - form.appendChild(paymentInput); + form.appendChild(paymentInput); }; })(); \ No newline at end of file diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/ServiceProviders/DiscountProvider.cs b/apps/public-web/src/EShopOnAbp.PublicWeb/ServiceProviders/DiscountProvider.cs new file mode 100644 index 00000000..c1d036f1 --- /dev/null +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/ServiceProviders/DiscountProvider.cs @@ -0,0 +1,9 @@ + +using Volo.Abp.DependencyInjection; + +namespace EShopOnAbp.PublicWeb.ServiceProviders; + +public class DiscountProvider : ITransientDependency +{ + // TODO: Configure or remove discount logic +} \ No newline at end of file diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Basket/UserAddressProvider.cs b/apps/public-web/src/EShopOnAbp.PublicWeb/ServiceProviders/UserAddressProvider.cs similarity index 96% rename from apps/public-web/src/EShopOnAbp.PublicWeb/Basket/UserAddressProvider.cs rename to apps/public-web/src/EShopOnAbp.PublicWeb/ServiceProviders/UserAddressProvider.cs index 40b090a5..6e343752 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Basket/UserAddressProvider.cs +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/ServiceProviders/UserAddressProvider.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using Volo.Abp.DependencyInjection; -namespace EShopOnAbp.PublicWeb.Basket; +namespace EShopOnAbp.PublicWeb.ServiceProviders; public class UserAddressProvider : ITransientDependency { diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Basket/UserBasketProvider.cs b/apps/public-web/src/EShopOnAbp.PublicWeb/ServiceProviders/UserBasketProvider.cs similarity index 95% rename from apps/public-web/src/EShopOnAbp.PublicWeb/Basket/UserBasketProvider.cs rename to apps/public-web/src/EShopOnAbp.PublicWeb/ServiceProviders/UserBasketProvider.cs index c96a21a9..fd8f5b61 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Basket/UserBasketProvider.cs +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/ServiceProviders/UserBasketProvider.cs @@ -1,13 +1,13 @@ -using EShopOnAbp.BasketService; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Logging; -using System; +using System; using System.Threading.Tasks; +using EShopOnAbp.BasketService; using EShopOnAbp.Shared.Hosting.AspNetCore; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Logging; using Volo.Abp.DependencyInjection; using Volo.Abp.Users; -namespace EShopOnAbp.PublicWeb.Basket +namespace EShopOnAbp.PublicWeb.ServiceProviders { public class UserBasketProvider : ITransientDependency { diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/components/basket/basket-widget.css b/apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/components/basket/basket-widget.css index 06d922a6..c6421e2c 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/components/basket/basket-widget.css +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/components/basket/basket-widget.css @@ -3,7 +3,7 @@ } .basket-list-item { - width:-webkit-fill-available; + width: -webkit-fill-available; background-color: #fff; border: 1px solid #eee; border-radius: 3px; @@ -87,15 +87,21 @@ line-height: 20px; vertical-align: top; } -.description-cargo{ + +.description-cargo { color: #189c38; text-align: center; font-size: 1rem; } -.description-cargo> span { - line-height: 20px; - vertical-align: top; - } + +.description-cargo > span { + line-height: 20px; + vertical-align: top; +} + +.basket-item-remove { + cursor: pointer; +} .remove-container { color: #bb2d3b; @@ -124,6 +130,7 @@ .basket-list-item:hover .hide { opacity: 1.0; } + .sticky { position: -webkit-sticky; /* for Safari */ position: sticky;