fix orderSubName issue , add version 0.22.25.44

release
Amir Hossein Khademi 2024-04-18 19:19:54 +03:30
parent 83cd317203
commit 00ca32d32f
21 changed files with 3589 additions and 159 deletions

View File

@ -1 +1 @@
0.22.25.43
0.22.25.44

View File

@ -47,8 +47,8 @@
},
"JwtSettings": {
"SecretKey": "YAEMAMZAMAN_KHODET_NEGAHDAR_IN_KEY_BASH_nw+8E0EABj0Wg8c4mHg/bDBf5qGMhmBPb6u16DVe9/MzYva1e+/J1zImyIoQX2Lmra2kvzsIjGiwP7r3Znd_YA_JADE_NASABE_v+Ro/CDixScDv6EkpZnkBv9MFdPnSmFXNGMH9gA1BzQUoC1iSX9Aq+pMIw/cMKXI9WA==_YA_HUSEIN_SEYED_SHOHADA_BE_OMID_KHODET",
"Issuer": "NetinaShop",
"Audience": "NetinaShop",
"Issuer": "Vesmeh",
"Audience": "Vesmeh",
"ExpireAddDay": "15"
}
},

View File

@ -1,4 +1,5 @@
using Netina.Core.Abstracts;
using Microsoft.Extensions.Options;
using Netina.Core.Abstracts;
using Netina.Domain.CommandQueries.Queries;
using Netina.Domain.Models.Claims;
using TypedResults = Microsoft.AspNetCore.Http.TypedResults;
@ -36,16 +37,17 @@ public class PaymentController : ICarterModule
=> TypedResults.Ok(await mediator.Send(new GetShippingQuery(id), cancellationToken));
// POST:Create Entity
public async Task<IResult> VerifyPaymentAsync([FromQuery] string Authority, [FromQuery] string Status, IPaymentService paymentService, ILogger<PaymentController> logger, CancellationToken cancellationToken)
public async Task<IResult> VerifyPaymentAsync([FromQuery] string Authority, [FromQuery] string Status, IPaymentService paymentService, IOptionsSnapshot<SiteSettings> optionsSnapshot, ILogger<PaymentController> logger, CancellationToken cancellationToken)
{
var siteUrl = optionsSnapshot.Value.WebSiteUrl;
if (Status == "OK")
{
var result = await paymentService.VerifyPaymentAsync(authority: Authority, cancellationToken);
return TypedResults.Redirect($"https://vesmeh.com/purchase-callback?refid={result.Item1}&paymentStatus=true&factorNumber={result.Item2}", true);
return TypedResults.Redirect($"{siteUrl}/purchase-callback?refid={result.Item1}&paymentStatus=true&factorNumber={result.Item2}", true);
}
else
{
return TypedResults.Redirect($"https://vesmeh.com/purchase-callback?refid=0&paymentStatus=false&factorNumber=0", true);
return TypedResults.Redirect($"{siteUrl}/purchase-callback?refid=0&paymentStatus=false&factorNumber=0", true);
}
}

View File

@ -11,8 +11,25 @@ public class SearchController : ICarterModule
group.MapGet("", SearchAsync)
.WithDisplayName("Search Async")
.HasApiVersion(1.0);
group.MapGet("zarehbin", ZarehbinAsync)
.WithDisplayName("Search Async")
.HasApiVersion(1.0);
}
private async Task<IResult> SearchAsync([FromQuery] string name, [FromServices] ISearchService searchService, CancellationToken cancellationToken)
=> TypedResults.Ok(await searchService.SearchAsync(name, cancellationToken));
private async Task<IResult> ZarehbinAsync([FromQuery] string? product_id, [FromQuery] int? page, [FromServices] ISearchService searchService, CancellationToken cancellationToken)
{
if (product_id == null)
{
if (page == null)
return TypedResults.Ok(await searchService.ZarehbinAsync(0, cancellationToken));
else
return TypedResults.Ok(await searchService.ZarehbinAsync(page.Value, cancellationToken));
}
else
return TypedResults.Ok(await searchService.ZarehbinAsync(Guid.Parse(product_id), cancellationToken));
}
}

View File

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

View File

@ -6,7 +6,7 @@ builder.Host.UseSerilog();
LoggerConfig.ConfigureSerilog();
string env = builder.Environment.IsDevelopment() == true ? "Development" : "Production";
builder.Host.UseContentRoot(Directory.GetCurrentDirectory());
string projectName = "Hamyan";
string projectName = "Vesmeh";
if (builder.Environment.IsDevelopment())
builder.Configuration.AddJsonFile($"AppSettings/appsettings.json").AddJsonFile($"AppSettings/appsettings.{env}{projectName}.json");

View File

@ -1,9 +1,10 @@
using Netina.Common.Models;
using Netina.Domain.Dtos.ResponseDtos;
using Netina.Domain.Dtos.ResponseDtos.Zarehbin;
namespace Netina.Core.CoreServices.Abstracts;
public interface ISearchService : IScopedDependency
{
public Task<SearchResponseDto> SearchAsync(string name,CancellationToken cancellationToken = default);
public Task<ZarehbinPagedResponseDto> ZarehbinAsync(int page,CancellationToken cancellationToken = default);
public Task<ZarehbinProductResponseDto> ZarehbinAsync(Guid productId,CancellationToken cancellationToken = default);
}

View File

@ -1,8 +1,5 @@
using Netina.Core.CoreServices.Abstracts;
using Netina.Domain.Dtos.ResponseDtos;
using Netina.Domain.Dtos.ResponseDtos.Zarehbin;
using Netina.Domain.Entities.ProductCategories;
using Netina.Domain.Entities.Products;
using Netina.Repository.Repositories.Base.Contracts;
namespace Netina.Core.CoreServices;
@ -34,4 +31,14 @@ public class SearchService : ISearchService
Categories = categories.Select(c => c.Adapt<SearchedProductCategoryResponseDto>()).ToList()
};
}
public Task<ZarehbinPagedResponseDto> ZarehbinAsync(int page, CancellationToken cancellationToken = default)
{
throw new NotImplementedException();
}
public Task<ZarehbinProductResponseDto> ZarehbinAsync(Guid productId, CancellationToken cancellationToken = default)
{
throw new NotImplementedException();
}
}

View File

@ -104,11 +104,11 @@ public class GetOrderInvoiceCommandHandler : IRequestHandler<GetOrderInvoiceComm
orderAtText.StringFormat = format;
result = orderAtText.Draw(currentPage, new PointF(clientSize.Width - 100, result.Bounds.Y + 30));
var nameText = new PdfTextElement($"{order.UserFullName}", _mediumFont);
var nameText = new PdfTextElement($"{order.CustomerFullName}", _mediumFont);
nameText.StringFormat = format;
result = nameText.Draw(currentPage, new PointF(clientSize.Width - 100, result.Bounds.Bottom));
var phoneText = new PdfTextElement($"{order.UserPhoneNumber}", _mediumFont);
var phoneText = new PdfTextElement($"{order.CustomerPhoneNumber}", _mediumFont);
phoneText.StringFormat = new PdfStringFormat(PdfTextAlignment.Left);
result = phoneText.Draw(currentPage, new PointF(0, result.Bounds.Y));

View File

@ -1,9 +1,4 @@
using Netina.Common.Models.Mapper;
using Netina.Domain.Dtos.SmallDtos;
using Netina.Domain.Entities.Orders;
using Netina.Domain.Enums;
namespace Netina.Domain.Dtos.LargDtos;
namespace Netina.Domain.Dtos.LargDtos;
public class OrderLDto : BaseDto<OrderLDto,Order>
{
public string FactorCode { get; set; } = string.Empty;
@ -24,8 +19,8 @@ public class OrderLDto : BaseDto<OrderLDto,Order>
public string DiscountCode { get; set; } = string.Empty;
public long TotalPriceWithoutDiscount => TotalPrice + DiscountPrice;
public string UserFullName { get; set; } = string.Empty;
public string UserPhoneNumber { get; set; } = string.Empty;
public string CustomerFullName { get; set; } = string.Empty;
public string CustomerPhoneNumber { get; set; } = string.Empty;
public List<OrderProductSDto> OrderProducts { get; set; } = new();

View File

@ -0,0 +1,26 @@
namespace Netina.Domain.Dtos.ResponseDtos.Zarehbin;
public class ZarehbinPagedResponseDto
{
public int count { get; set; }
public int total_pages_count { get; set; }
public List<ZarehbinProductResponseDto> products { get; set; } = new();
}
public class ZarehbinProductResponseDto
{
public string title { get; set; } = string.Empty;
public string subtitle { get; set; } = string.Empty;
public string id { get; set; } = string.Empty;
public string current_price { get; set; } = string.Empty;
public string old_price { get; set; } = string.Empty;
public string availability { get; set; } = string.Empty;
public List<string> categories { get; set; } = new();
public string image_link { get; set; } = string.Empty;
public List<string> image_links { get; set; } = new();
public string page_url { get; set; } = string.Empty;
public string short_desc { get; set; } = string.Empty;
public List<Tuple<string, string>> spec { get; set; } = new();
public string registry { get; set; } = string.Empty;
public string guarantee { get; set; } = string.Empty;
}

View File

@ -34,10 +34,10 @@ public partial class Discount
public bool IsExpired()
=> !Immortal && ExpireDate.Date < DateTime.Today.Date;
public void SetCorporate(Guid userId)
public void SetCorporate(Guid marketerId)
{
IsForSaleCooperation = true;
CorporateUserId = userId;
MarketerId = marketerId;
}
}

View File

@ -82,8 +82,8 @@ public partial class Discount : ApiEntity
public bool IsForFirstPurchase { get; internal set; }
public Guid? CorporateUserId { get; internal set; }
public ApplicationUser? CorporateUser { get; internal set; }
public Guid? MarketerId { get; internal set; }
public Marketer? Marketer { get; internal set; }
public List<Order> Orders { get; internal set; } = new();
}

View File

@ -1,6 +1,4 @@
using Netina.Common.Models.Entity;
namespace Netina.Domain.Entities.Users;
namespace Netina.Domain.Entities.Users;
[AdaptTwoWays("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Map | MapType.MapToTarget)]
[AdaptTo("[name]SDto", IgnoreAttributes = new[] { typeof(AdaptIgnoreAttribute) }, MapType = MapType.Projection)]
@ -9,6 +7,10 @@ public class Marketer : ApiEntity
{
public string FatherName { get; set; } = string.Empty;
public string Shaba { get; set; } = string.Empty;
public DateTime LastSettlement { get; set; }
public Guid UserId { get; set; }
public ApplicationUser? User { get; set; }
public Discount? Discount { get; set; }
}

View File

@ -178,6 +178,8 @@ namespace Netina.Domain.Mappers
OrderAt = p19.OrderAt,
PreparingMinute = p19.PreparingMinute,
DiscountCode = p19.DiscountCode,
CustomerFullName = p19.Customer != null && p19.Customer.User != null ? p19.Customer.User.FirstName + " " + p19.Customer.User.LastName : string.Empty,
CustomerPhoneNumber = p19.Customer != null && p19.Customer.User != null ? p19.Customer.User.PhoneNumber : string.Empty,
OrderProducts = funcMain8(p19.OrderProducts),
Payments = funcMain9(p19.Payments),
OrderDelivery = p19.OrderDelivery == null ? null : new OrderDeliverySDto()
@ -228,6 +230,8 @@ namespace Netina.Domain.Mappers
result.OrderAt = p22.OrderAt;
result.PreparingMinute = p22.PreparingMinute;
result.DiscountCode = p22.DiscountCode;
result.CustomerFullName = p22.Customer != null && p22.Customer.User != null ? p22.Customer.User.FirstName + " " + p22.Customer.User.LastName : string.Empty;
result.CustomerPhoneNumber = p22.Customer != null && p22.Customer.User != null ? p22.Customer.User.PhoneNumber : string.Empty;
result.OrderProducts = funcMain10(p22.OrderProducts, result.OrderProducts);
result.Payments = funcMain11(p22.Payments, result.Payments);
result.OrderDelivery = funcMain12(p22.OrderDelivery, result.OrderDelivery);
@ -254,6 +258,8 @@ namespace Netina.Domain.Mappers
OrderAt = p30.OrderAt,
PreparingMinute = p30.PreparingMinute,
DiscountCode = p30.DiscountCode,
CustomerFullName = p30.Customer != null && p30.Customer.User != null ? p30.Customer.User.FirstName + " " + p30.Customer.User.LastName : string.Empty,
CustomerPhoneNumber = p30.Customer != null && p30.Customer.User != null ? p30.Customer.User.PhoneNumber : string.Empty,
OrderProducts = p30.OrderProducts.Select<OrderProduct, OrderProductSDto>(p31 => new OrderProductSDto()
{
Count = p31.Count,

View File

@ -0,0 +1,7 @@
namespace Netina.Domain.MartenEntities.Settings;
public class MarketerSetting
{
public int ProfitPercent { get; set; }
public string ContractTerms { get; set; } = string.Empty;
}

View File

@ -1,13 +1,4 @@
using Microsoft.EntityFrameworkCore;
using Netina.Common.Extensions;
using Netina.Common.Models.Api;
using Netina.Common.Models.Exception;
using Netina.Domain.CommandQueries.Commands;
using Netina.Domain.Entities.Discounts;
using Netina.Domain.Entities.Users;
using Netina.Domain.Enums;
using Netina.Repository.Abstracts;
using Netina.Repository.Repositories.Base.Contracts;
namespace Netina.Repository.Handlers.Discounts;
@ -33,20 +24,27 @@ public class CreateSaleCooperationDiscountHandler : IRequestHandler<CreateSaleCo
if (!Guid.TryParse(_currentUserService.UserId, out userId))
throw new AppException("User id is wrong");
}
var user = await _userManager.FindByIdAsync(request.CorporateUserId.ToString());
var user = await _userManager.FindByIdAsync(userId.ToString());
if (user == null)
throw new AppException("User not found", ApiResultStatusCode.NotFound);
var marketer = await _repositoryWrapper.SetRepository<Marketer>()
.TableNoTracking
.FirstOrDefaultAsync(m => m.UserId == user.Id, cancellationToken);
if (marketer == null)
throw new AppException("Marketer not found", ApiResultStatusCode.NotFound);
var foundedDiscount = await _repositoryWrapper.SetRepository<Discount>()
.TableNoTracking
.FirstOrDefaultAsync(d => d.IsForSaleCooperation && d.CorporateUserId == userId, cancellationToken);
.FirstOrDefaultAsync(d => d.IsForSaleCooperation && d.MarketerId == marketer.Id, cancellationToken);
if (foundedDiscount == null)
{
var code = StringExtensions.GetId();
foundedDiscount = Discount.Create(code,$"کد مخصوص همکاری در فروش برای کاربر - {user.FirstName} {user.LastName}", 10, 0, true,
DiscountAmountType.Percent, DiscountType.All, 0, true, DateTime.Today, DateTime.Today.AddYears(10), 0,
false, 0, false, true, 0, false, false,false);
foundedDiscount.SetCorporate(userId);
foundedDiscount.SetCorporate(marketer.Id);
_repositoryWrapper.SetRepository<Discount>().Add(foundedDiscount);
await _repositoryWrapper.SaveChangesAsync(cancellationToken);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -40,9 +40,9 @@ public class ApplicationContext : IdentityDbContext<ApplicationUser, Application
protected void RenameIdentityTables(ModelBuilder builder)
{
builder.HasDefaultSchema("public");
builder.Entity<ApplicationUser>().ToTable("Users");
builder.Entity<ApplicationRole>().ToTable("Roles");
builder.Entity<IdentityRoleClaim<Guid>>().ToTable("RoleClaims");
builder.Entity<IdentityUserRole<Guid>>().ToTable("UserRoles");
builder.Entity<IdentityUserClaim<Guid>>().ToTable("Claims");