feat : change OTP verify code , change digikala service , change get order invoice
parent
00ca32d32f
commit
f19c76066c
|
@ -21,7 +21,7 @@
|
||||||
"WebSiteUrl": "https://vesmeh.com",
|
"WebSiteUrl": "https://vesmeh.com",
|
||||||
"AdminPanelBaseUrl": "https://admin.vesmeh.com",
|
"AdminPanelBaseUrl": "https://admin.vesmeh.com",
|
||||||
"StorageBaseUrl": "https://storage.vesmeh.com",
|
"StorageBaseUrl": "https://storage.vesmeh.com",
|
||||||
"KaveNegarApiKey": "3735494B4143727A794346457461576A2B4B6668414973424E333561505A694B",
|
"KaveNegarApiKey": "65334B6A70303233432B7A6530795A51683134524945742F74397161785568512B794966623245744C2F773D",
|
||||||
"UserSetting": {
|
"UserSetting": {
|
||||||
"Username": "09214802813",
|
"Username": "09214802813",
|
||||||
"Email": "avvampier@gmail.com",
|
"Email": "avvampier@gmail.com",
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
using Netina.Core.Abstracts;
|
namespace Netina.Api.Controller;
|
||||||
using Netina.Domain.Models.Claims;
|
|
||||||
|
|
||||||
namespace Netina.Api.Controller;
|
|
||||||
|
|
||||||
public class ScraperController : ICarterModule
|
public class ScraperController : ICarterModule
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<InvariantGlobalization>true</InvariantGlobalization>
|
<InvariantGlobalization>true</InvariantGlobalization>
|
||||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||||
<AssemblyVersion>0.22.25.44</AssemblyVersion>
|
<AssemblyVersion>0.22.25.45</AssemblyVersion>
|
||||||
<FileVersion>0.22.25.44</FileVersion>
|
<FileVersion>0.22.25.45</FileVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -6,7 +6,7 @@ builder.Host.UseSerilog();
|
||||||
LoggerConfig.ConfigureSerilog();
|
LoggerConfig.ConfigureSerilog();
|
||||||
string env = builder.Environment.IsDevelopment() == true ? "Development" : "Production";
|
string env = builder.Environment.IsDevelopment() == true ? "Development" : "Production";
|
||||||
builder.Host.UseContentRoot(Directory.GetCurrentDirectory());
|
builder.Host.UseContentRoot(Directory.GetCurrentDirectory());
|
||||||
string projectName = "Vesmeh";
|
string projectName = "Hamyan";
|
||||||
if (builder.Environment.IsDevelopment())
|
if (builder.Environment.IsDevelopment())
|
||||||
builder.Configuration.AddJsonFile($"AppSettings/appsettings.json").AddJsonFile($"AppSettings/appsettings.{env}{projectName}.json");
|
builder.Configuration.AddJsonFile($"AppSettings/appsettings.json").AddJsonFile($"AppSettings/appsettings.{env}{projectName}.json");
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ builder.Services.AddMarten(configuration,builder.Environment);
|
||||||
builder.Services.AddCarter();
|
builder.Services.AddCarter();
|
||||||
|
|
||||||
|
|
||||||
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("Ngo9BigBOggjHTQxAR8/V1NAaF1cXmhKYVtpR2Nbe05yflRGalxSVBYiSV9jS3pTdUViWHtfcHRWQGlcUQ==");
|
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("MjM3OEAzMTM5MmUzMTJlMzBVeS82aFZBTTBzSG56NU1iekJscW9VN0s1UGJMcHBMRlFYMGduOUgxaUFvPQ==");
|
||||||
|
|
||||||
|
|
||||||
builder.Host.ConfigureContainer<ContainerBuilder>(builder =>
|
builder.Host.ConfigureContainer<ContainerBuilder>(builder =>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<!--<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
@ -12,9 +12,9 @@
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
||||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.4.1" />
|
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.4.1" />
|
||||||
</ItemGroup>-->
|
</ItemGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<!--<PropertyGroup>
|
||||||
<TargetFramework>net5.0</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
<LangVersion>10</LangVersion>
|
<LangVersion>10</LangVersion>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
@ -25,7 +25,7 @@
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
||||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.3.1" />
|
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.3.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>-->
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Using Include="MD.PersianDateTime.Standard" />
|
<Using Include="MD.PersianDateTime.Standard" />
|
||||||
|
|
|
@ -1,9 +1,4 @@
|
||||||
using Netina.Common.Extensions;
|
using Netina.Domain.Dtos.LargDtos;
|
||||||
using Netina.Domain.CommandQueries.Commands;
|
|
||||||
using Netina.Domain.CommandQueries.Queries;
|
|
||||||
using Netina.Domain.Dtos.LargDtos;
|
|
||||||
using Netina.Domain.Enums;
|
|
||||||
using Netina.Repository.Repositories.Base.Contracts;
|
|
||||||
using Syncfusion.Drawing;
|
using Syncfusion.Drawing;
|
||||||
using Syncfusion.Pdf;
|
using Syncfusion.Pdf;
|
||||||
using Syncfusion.Pdf.Graphics;
|
using Syncfusion.Pdf.Graphics;
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
|
||||||
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.3" />
|
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.3" />
|
||||||
<PackageReference Include="Quartz" Version="3.8.1" />
|
<PackageReference Include="Quartz" Version="3.8.1" />
|
||||||
<PackageReference Include="Syncfusion.Pdf.Net.Core" Version="25.1.35" />
|
<PackageReference Include="Syncfusion.Pdf.Net.Core" Version="24.1.41" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
using Netina.Common.Models.Mapper;
|
using Netina.Domain.Entities.Accounting;
|
||||||
using Netina.Domain.Entities.Accounting;
|
|
||||||
using Netina.Domain.Enums;
|
|
||||||
|
|
||||||
namespace Netina.Domain.Dtos.SmallDtos;
|
namespace Netina.Domain.Dtos.SmallDtos;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<!--<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
@ -14,9 +14,9 @@
|
||||||
<PackageReference Include="MediatR" Version="12.2.0" />
|
<PackageReference Include="MediatR" Version="12.2.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="8.0.3" />
|
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="8.0.3" />
|
||||||
<PackageReference Include="PropertyChanged.Fody" Version="4.1.0" />
|
<PackageReference Include="PropertyChanged.Fody" Version="4.1.0" />
|
||||||
</ItemGroup>-->
|
</ItemGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<!--<PropertyGroup>
|
||||||
<TargetFramework>net5.0</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
<LangVersion>10</LangVersion>
|
<LangVersion>10</LangVersion>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="5.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="5.0.0" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0" />
|
||||||
<PackageReference Include="PropertyChanged.Fody" Version="4.1.0" />
|
<PackageReference Include="PropertyChanged.Fody" Version="4.1.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>-->
|
||||||
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -7,6 +7,6 @@ public interface IDigikalaRestApi
|
||||||
[Get("/v1/search/")]
|
[Get("/v1/search/")]
|
||||||
Task<GetDigikalProductsResponseDto> SearchProductAsync([Query] string q);
|
Task<GetDigikalProductsResponseDto> SearchProductAsync([Query] string q);
|
||||||
|
|
||||||
[Get("/v1/product/{productId}/")]
|
[Get("/v2/product/{productId}/")]
|
||||||
Task<GetDigikalProductResponseDto> GetProductAsync(string productId);
|
Task<GetDigikalProductResponseDto> GetProductAsync(string productId);
|
||||||
}
|
}
|
|
@ -1,16 +1,10 @@
|
||||||
using MediatR;
|
using MediatR;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.IdentityModel.Tokens;
|
|
||||||
using Netina.Common.Models.Api;
|
|
||||||
using Netina.Common.Models.Exception;
|
|
||||||
using Netina.Core.Abstracts;
|
|
||||||
using Netina.Domain.CommandQueries.Commands;
|
using Netina.Domain.CommandQueries.Commands;
|
||||||
using Netina.Domain.Dtos.ScraperDtos.Response;
|
using Netina.Domain.Dtos.ScraperDtos.Response;
|
||||||
using Netina.Domain.Dtos.SmallDtos;
|
using Netina.Domain.Dtos.SmallDtos;
|
||||||
using Netina.Domain.Entities.Brands;
|
using Netina.Domain.Entities.Brands;
|
||||||
using Netina.Domain.Entities.ProductCategories;
|
using Netina.Domain.Entities.ProductCategories;
|
||||||
using Netina.Domain.Entities.Products;
|
|
||||||
using Netina.Infrastructure.RestServices;
|
|
||||||
using Netina.Repository.Repositories.Base.Contracts;
|
using Netina.Repository.Repositories.Base.Contracts;
|
||||||
|
|
||||||
namespace Netina.Infrastructure.Services.Scrapers;
|
namespace Netina.Infrastructure.Services.Scrapers;
|
||||||
|
@ -22,7 +16,7 @@ public class DigikalaScraper : IDigikalaScraper
|
||||||
private readonly IMediator _mediator;
|
private readonly IMediator _mediator;
|
||||||
private readonly IUploadFileService _uploadFileService;
|
private readonly IUploadFileService _uploadFileService;
|
||||||
|
|
||||||
public DigikalaScraper(IRestApiWrapper apiWrapper, IRepositoryWrapper repositoryWrapper,IMediator mediator, IUploadFileService uploadFileService)
|
public DigikalaScraper(IRestApiWrapper apiWrapper, IRepositoryWrapper repositoryWrapper, IMediator mediator, IUploadFileService uploadFileService)
|
||||||
{
|
{
|
||||||
_apiWrapper = apiWrapper;
|
_apiWrapper = apiWrapper;
|
||||||
_repositoryWrapper = repositoryWrapper;
|
_repositoryWrapper = repositoryWrapper;
|
||||||
|
@ -46,12 +40,9 @@ public class DigikalaScraper : IDigikalaScraper
|
||||||
public async Task<bool> AddProductToShopAsync(string productId, string productName, CancellationToken cancellationToken = default)
|
public async Task<bool> AddProductToShopAsync(string productId, string productName, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
var response = await _apiWrapper.DigikalaRestApi.GetProductAsync(productId);
|
var response = await _apiWrapper.DigikalaRestApi.GetProductAsync(productId);
|
||||||
var digiProduct = response.data; var dbProduct = await _repositoryWrapper.SetRepository<Product>()
|
var digiProduct = response.data;
|
||||||
.TableNoTracking
|
|
||||||
.FirstOrDefaultAsync(p => p.PersianName.ToLower().Trim().Contains(productName.ToLower().Trim()), cancellationToken);
|
|
||||||
var newSummery = digiProduct.seo.description.Replace("فروشگاه اینترنتی دیجی\u200cکالا", "فروشگاه اینترنتی وسمه");
|
var newSummery = digiProduct.seo.description.Replace("فروشگاه اینترنتی دیجی\u200cکالا", "فروشگاه اینترنتی وسمه");
|
||||||
if (dbProduct != null && !dbProduct.Summery.IsNullOrEmpty())
|
|
||||||
newSummery = dbProduct.Summery;
|
|
||||||
var specifications = new List<SpecificationSDto>();
|
var specifications = new List<SpecificationSDto>();
|
||||||
foreach (var specification in digiProduct.product.specifications)
|
foreach (var specification in digiProduct.product.specifications)
|
||||||
{
|
{
|
||||||
|
@ -81,38 +72,35 @@ public class DigikalaScraper : IDigikalaScraper
|
||||||
IsPrimary = true,
|
IsPrimary = true,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (dbProduct != null)
|
|
||||||
{
|
|
||||||
|
|
||||||
var request = new UpdateProductCommand(dbProduct.Id, digiProduct.product.title_fa, digiProduct.product.title_en,
|
|
||||||
newSummery,
|
|
||||||
dbProduct.ExpertCheck, dbProduct.Tags, dbProduct.Warranty, dbProduct.BeDisplayed, dbProduct.Cost,
|
|
||||||
dbProduct.PackingCost, dbProduct.Stock, dbProduct.HasExpressDelivery
|
|
||||||
, dbProduct.MaxOrderCount, false, dbProduct.BrandId, dbProduct.CategoryId, new DiscountSDto(), specifications, files);
|
|
||||||
await _mediator.Send(request, cancellationToken);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var nonBrand = await _repositoryWrapper.SetRepository<Brand>()
|
var nonBrand = await _repositoryWrapper.SetRepository<Brand>()
|
||||||
.TableNoTracking
|
.TableNoTracking
|
||||||
.FirstOrDefaultAsync(b => b.PersianName == "بدون برند", cancellationToken);
|
.FirstOrDefaultAsync(b => b.PersianName == "بدون برند", cancellationToken);
|
||||||
if (nonBrand == null)
|
if (nonBrand == null)
|
||||||
throw new AppException("NoneBrand is not exist");
|
{
|
||||||
|
nonBrand = Brand.Create("بدون برند" , "NoBrand","محصولات بدون برند",false,string.Empty);
|
||||||
|
_repositoryWrapper.SetRepository<Brand>()
|
||||||
|
.Add(nonBrand);
|
||||||
|
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
var nonCat = await _repositoryWrapper.SetRepository<ProductCategory>()
|
var nonCat = await _repositoryWrapper.SetRepository<ProductCategory>()
|
||||||
.TableNoTracking
|
.TableNoTracking
|
||||||
.FirstOrDefaultAsync(b => b.Name == "دسته بندی نشده", cancellationToken);
|
.FirstOrDefaultAsync(b => b.Name == "دسته بندی نشده", cancellationToken);
|
||||||
if (nonCat == null)
|
if (nonCat == null)
|
||||||
throw new AppException("NoneCategory is not exist");
|
{
|
||||||
|
nonCat = ProductCategory.Create("دسته بندی نشده", "محصولات بدون دسته بندی", false);
|
||||||
|
_repositoryWrapper.SetRepository<ProductCategory>()
|
||||||
|
.Add(nonCat);
|
||||||
|
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var request = new CreateProductCommand(productName, digiProduct.product.title_en,
|
var request = new CreateProductCommand(digiProduct.product.title_fa, digiProduct.product.title_en,
|
||||||
digiProduct.seo.description,
|
newSummery,
|
||||||
string.Empty, string.Empty, string.Empty,true, 0,
|
string.Empty, string.Empty, string.Empty, true, 0,
|
||||||
0, 0, false
|
0, 0, false
|
||||||
, 5, false, nonBrand.Id, nonCat.Id, new DiscountSDto(), specifications, files);
|
, 5, false, nonBrand.Id, nonCat.Id, new DiscountSDto(), specifications, files);
|
||||||
await _mediator.Send(request, cancellationToken);
|
await _mediator.Send(request, cancellationToken);
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class SmsService : ISmsService
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var rest = await _restApiWrapper.KaveNegarRestApi.SendLookUp(_siteSettings.KaveNegarApiKey, phoneNumber,
|
var rest = await _restApiWrapper.KaveNegarRestApi.SendLookUp(_siteSettings.KaveNegarApiKey, phoneNumber,
|
||||||
verifyCode, null, null, null, "login-brizco");
|
verifyCode, null, null, null, "login-netina");
|
||||||
|
|
||||||
if (rest.Return.status != 200 && _environment.IsProduction())
|
if (rest.Return.status != 200 && _environment.IsProduction())
|
||||||
throw new BaseApiException(ApiResultStatusCode.SendSmsError, rest.Return.message);
|
throw new BaseApiException(ApiResultStatusCode.SendSmsError, rest.Return.message);
|
||||||
|
|
|
@ -93,7 +93,7 @@ foreach (var wordPressPostDto in posts.Where(p => p.post_type == "post"))
|
||||||
SeedBlogRequestDto blog;
|
SeedBlogRequestDto blog;
|
||||||
Guid categoryId = default;
|
Guid categoryId = default;
|
||||||
string postTags = string.Empty;
|
string postTags = string.Empty;
|
||||||
var postTermRelations = termRelationships.Where(p => p.object_id == wordPressPostDto.ID);
|
var postTermRelations = termRelationships.Where(p => p.object_id == wordPressPostDto.ID).ToList();
|
||||||
foreach (var postTermRelation in postTermRelations)
|
foreach (var postTermRelation in postTermRelations)
|
||||||
{
|
{
|
||||||
var taxanomy = termTaxonomies.FirstOrDefault(f => f.term_taxonomy_id == postTermRelation.term_taxonomy_id);
|
var taxanomy = termTaxonomies.FirstOrDefault(f => f.term_taxonomy_id == postTermRelation.term_taxonomy_id);
|
||||||
|
@ -151,7 +151,7 @@ foreach (var wordPressPostDto in posts.Where(p => p.post_type == "post"))
|
||||||
|
|
||||||
blogs.Add(blog);
|
blogs.Add(blog);
|
||||||
|
|
||||||
await RestWrapper.Instance.SeedRestApi.SeedBlogsAsync(new List<SeedBlogRequestDto>{blog}, "kKAYskyG8xPxKnJrHkuYxub4Ao2bnz7AOmNtwDT0RaqzaG7ZvbvaP29tCrC8wJ823RczJFXOIQT2bDOec4F38A==");
|
await RestWrapper.Instance.SeedRestApi.SeedBlogsAsync(new List<SeedBlogRequestDto> { blog }, "kKAYskyG8xPxKnJrHkuYxub4Ao2bnz7AOmNtwDT0RaqzaG7ZvbvaP29tCrC8wJ823RczJFXOIQT2bDOec4F38A==");
|
||||||
|
|
||||||
Console.WriteLine($"{thumbCounter++ } / {blogs.Count} Blog Added Success !");
|
Console.WriteLine($"{thumbCounter++ } / {blogs.Count} Blog Added Success !");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue