Add delivery tracking fields to UserOrder entity
This commit is contained in:
@@ -71,7 +71,9 @@ public class
|
|||||||
PaymentDate = DateTime.Now,
|
PaymentDate = DateTime.Now,
|
||||||
UserId = request.UserId,
|
UserId = request.UserId,
|
||||||
UserAddressId = user.UserAddresss.First(f => f.IsDefault).Id,
|
UserAddressId = user.UserAddresss.First(f => f.IsDefault).Id,
|
||||||
TransactionId = newTransaction.Id
|
TransactionId = newTransaction.Id,
|
||||||
|
// سفارش فروشگاهی فیزیکی است، پس در ابتدا در انتظار ارسال است
|
||||||
|
DeliveryStatus = DeliveryStatus.Pending
|
||||||
};
|
};
|
||||||
await _context.UserOrders.AddAsync(newOrder, cancellationToken);
|
await _context.UserOrders.AddAsync(newOrder, cancellationToken);
|
||||||
await _context.SaveChangesAsync(cancellationToken);
|
await _context.SaveChangesAsync(cancellationToken);
|
||||||
|
|||||||
@@ -21,5 +21,10 @@ public record UpdateUserOrderCommand : IRequest<Unit>
|
|||||||
public long UserAddressId { get; init; }
|
public long UserAddressId { get; init; }
|
||||||
//
|
//
|
||||||
public PaymentMethod? PaymentMethod { get; init; }
|
public PaymentMethod? PaymentMethod { get; init; }
|
||||||
|
// وضعیت ارسال سفارش
|
||||||
|
public DeliveryStatus? DeliveryStatus { get; init; }
|
||||||
|
// کد رهگیری مرسوله
|
||||||
|
public string? TrackingCode { get; init; }
|
||||||
|
// توضیحات ارسال
|
||||||
|
public string? DeliveryDescription { get; init; }
|
||||||
}
|
}
|
||||||
@@ -30,4 +30,6 @@ public record GetAllUserOrderByFilterQuery : IRequest<GetAllUserOrderByFilterRes
|
|||||||
public long? UserAddressId { get; set; }
|
public long? UserAddressId { get; set; }
|
||||||
//
|
//
|
||||||
public PaymentMethod? PaymentMethod { get; set; }
|
public PaymentMethod? PaymentMethod { get; set; }
|
||||||
|
// وضعیت ارسال
|
||||||
|
public DeliveryStatus? DeliveryStatus { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ public class GetAllUserOrderByFilterQueryHandler : IRequestHandler<GetAllUserOrd
|
|||||||
.Where(x => request.Filter.PaymentDate == null || x.PaymentDate == request.Filter.PaymentDate)
|
.Where(x => request.Filter.PaymentDate == null || x.PaymentDate == request.Filter.PaymentDate)
|
||||||
.Where(x => request.Filter.UserId == null || x.UserId == request.Filter.UserId)
|
.Where(x => request.Filter.UserId == null || x.UserId == request.Filter.UserId)
|
||||||
.Where(x => request.Filter.UserAddressId == null || x.UserAddressId == request.Filter.UserAddressId)
|
.Where(x => request.Filter.UserAddressId == null || x.UserAddressId == request.Filter.UserAddressId)
|
||||||
;
|
.Where(x => request.Filter.PaymentMethod == null || x.PaymentMethod == request.Filter.PaymentMethod)
|
||||||
|
.Where(x => request.Filter.DeliveryStatus == null || x.DeliveryStatus == request.Filter.DeliveryStatus);
|
||||||
}
|
}
|
||||||
return new GetAllUserOrderByFilterResponseDto
|
return new GetAllUserOrderByFilterResponseDto
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,6 +32,12 @@ public class GetAllUserOrderByFilterResponseDto
|
|||||||
public string? UserAddressText { get; set; }
|
public string? UserAddressText { get; set; }
|
||||||
//
|
//
|
||||||
public List<GetAllUserOrderByFilterResponseModelFactorDetail>? FactorDetails { get; set; }
|
public List<GetAllUserOrderByFilterResponseModelFactorDetail>? FactorDetails { get; set; }
|
||||||
|
// وضعیت ارسال سفارش
|
||||||
|
public DeliveryStatus DeliveryStatus { get; set; }
|
||||||
|
// کد رهگیری مرسوله
|
||||||
|
public string? TrackingCode { get; set; }
|
||||||
|
// توضیحات ارسال
|
||||||
|
public string? DeliveryDescription { get; set; }
|
||||||
}
|
}
|
||||||
public class GetAllUserOrderByFilterResponseModelFactorDetail
|
public class GetAllUserOrderByFilterResponseModelFactorDetail
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,6 +25,12 @@ public class GetUserOrderResponseDto
|
|||||||
public string? UserAddressText { get; set; }
|
public string? UserAddressText { get; set; }
|
||||||
//
|
//
|
||||||
public List<GetUserOrderResponseFactorDetail>? FactorDetails { get; set; }
|
public List<GetUserOrderResponseFactorDetail>? FactorDetails { get; set; }
|
||||||
|
// وضعیت ارسال سفارش
|
||||||
|
public DeliveryStatus DeliveryStatus { get; set; }
|
||||||
|
// کد رهگیری مرسوله
|
||||||
|
public string? TrackingCode { get; set; }
|
||||||
|
// توضیحات ارسال
|
||||||
|
public string? DeliveryDescription { get; set; }
|
||||||
|
|
||||||
}public class GetUserOrderResponseFactorDetail
|
}public class GetUserOrderResponseFactorDetail
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
using CMSMicroservice.Domain.Enums;
|
using CMSMicroservice.Domain.Enums;
|
||||||
|
|
||||||
|
using CMSMicroservice.Domain.Enums;
|
||||||
|
|
||||||
namespace CMSMicroservice.Domain.Entities;
|
namespace CMSMicroservice.Domain.Entities;
|
||||||
//سفارش کاربر
|
//سفارش کاربر
|
||||||
public class UserOrder : BaseAuditableEntity
|
public class UserOrder : BaseAuditableEntity
|
||||||
@@ -27,6 +29,12 @@ public class UserOrder : BaseAuditableEntity
|
|||||||
//UserAddress Navigation Property
|
//UserAddress Navigation Property
|
||||||
public virtual UserAddress UserAddress { get; set; }
|
public virtual UserAddress UserAddress { get; set; }
|
||||||
public PaymentMethod? PaymentMethod { get; set; }
|
public PaymentMethod? PaymentMethod { get; set; }
|
||||||
|
// وضعیت ارسال سفارش
|
||||||
|
public DeliveryStatus DeliveryStatus { get; set; }
|
||||||
|
// کد رهگیری مرسوله (در صورت وجود)
|
||||||
|
public string? TrackingCode { get; set; }
|
||||||
|
// توضیحات وضعیت ارسال / نکات پستی
|
||||||
|
public string? DeliveryDescription { get; set; }
|
||||||
//FactorDetails Collection Navigation Reference
|
//FactorDetails Collection Navigation Reference
|
||||||
public virtual ICollection<FactorDetails> FactorDetailss { get; set; }
|
public virtual ICollection<FactorDetails> FactorDetailss { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
17
src/CMSMicroservice.Domain/Enums/DeliveryStatus.cs
Normal file
17
src/CMSMicroservice.Domain/Enums/DeliveryStatus.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
namespace CMSMicroservice.Domain.Enums;
|
||||||
|
|
||||||
|
// وضعیت ارسال سفارش
|
||||||
|
public enum DeliveryStatus
|
||||||
|
{
|
||||||
|
// نامشخص / بدون ارسال (مثلا سفارش پکیج)
|
||||||
|
None = 0,
|
||||||
|
// ثبت شده و در انتظار آمادهسازی/ارسال
|
||||||
|
Pending = 1,
|
||||||
|
// تحویل شرکت پست/حملونقل شده
|
||||||
|
InTransit = 2,
|
||||||
|
// توسط مشتری دریافت شده
|
||||||
|
Delivered = 3,
|
||||||
|
// مرجوع شده
|
||||||
|
Returned = 4,
|
||||||
|
}
|
||||||
|
|
||||||
1336
src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251127030633_u12.Designer.cs
generated
Normal file
1336
src/CMSMicroservice.Infrastructure/Persistence/Migrations/20251127030633_u12.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,55 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace CMSMicroservice.Infrastructure.Persistence.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class u12 : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "DeliveryDescription",
|
||||||
|
schema: "CMS",
|
||||||
|
table: "UserOrders",
|
||||||
|
type: "nvarchar(max)",
|
||||||
|
nullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "DeliveryStatus",
|
||||||
|
schema: "CMS",
|
||||||
|
table: "UserOrders",
|
||||||
|
type: "int",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0);
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "TrackingCode",
|
||||||
|
schema: "CMS",
|
||||||
|
table: "UserOrders",
|
||||||
|
type: "nvarchar(max)",
|
||||||
|
nullable: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "DeliveryDescription",
|
||||||
|
schema: "CMS",
|
||||||
|
table: "UserOrders");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "DeliveryStatus",
|
||||||
|
schema: "CMS",
|
||||||
|
table: "UserOrders");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "TrackingCode",
|
||||||
|
schema: "CMS",
|
||||||
|
table: "UserOrders");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -851,6 +851,12 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
|
|||||||
b.Property<string>("CreatedBy")
|
b.Property<string>("CreatedBy")
|
||||||
.HasColumnType("nvarchar(max)");
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("DeliveryDescription")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<int>("DeliveryStatus")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<bool>("IsDeleted")
|
b.Property<bool>("IsDeleted")
|
||||||
.HasColumnType("bit");
|
.HasColumnType("bit");
|
||||||
|
|
||||||
@@ -872,6 +878,9 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
|
|||||||
b.Property<int>("PaymentStatus")
|
b.Property<int>("PaymentStatus")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("TrackingCode")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
b.Property<long?>("TransactionId")
|
b.Property<long?>("TransactionId")
|
||||||
.HasColumnType("bigint");
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<TargetFramework>net9.0</TargetFramework>
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<Version>0.0.128</Version>
|
<Version>0.0.131</Version>
|
||||||
<DebugType>None</DebugType>
|
<DebugType>None</DebugType>
|
||||||
<DebugSymbols>False</DebugSymbols>
|
<DebugSymbols>False</DebugSymbols>
|
||||||
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
|
||||||
|
|||||||
@@ -37,6 +37,20 @@ enum PaymentStatus
|
|||||||
Reject = 1;
|
Reject = 1;
|
||||||
Pending = 2;
|
Pending = 2;
|
||||||
}
|
}
|
||||||
|
// وضعیت ارسال سفارش
|
||||||
|
enum DeliveryStatus
|
||||||
|
{
|
||||||
|
// نامشخص / نیاز به ارسال ندارد (مثلا سفارش پکیج)
|
||||||
|
DeliveryStatus_None = 0;
|
||||||
|
// ثبت شده و در انتظار آمادهسازی/ارسال
|
||||||
|
DeliveryStatus_Pending = 1;
|
||||||
|
// تحویل پست/حملونقل شده است
|
||||||
|
DeliveryStatus_InTransit = 2;
|
||||||
|
// توسط مشتری دریافت شده است
|
||||||
|
DeliveryStatus_Delivered = 3;
|
||||||
|
// مرجوع شده
|
||||||
|
DeliveryStatus_Returned = 4;
|
||||||
|
}
|
||||||
enum TransactionType
|
enum TransactionType
|
||||||
{
|
{
|
||||||
Buy = 0;
|
Buy = 0;
|
||||||
|
|||||||
@@ -88,6 +88,13 @@ message UpdateUserOrderRequest
|
|||||||
{
|
{
|
||||||
messages.PaymentMethod payment_method = 9;
|
messages.PaymentMethod payment_method = 9;
|
||||||
}
|
}
|
||||||
|
// وضعیت ارسال و اطلاعات پستی
|
||||||
|
oneof DeliveryStatus_item
|
||||||
|
{
|
||||||
|
messages.DeliveryStatus delivery_status = 10;
|
||||||
|
}
|
||||||
|
google.protobuf.StringValue tracking_code = 11;
|
||||||
|
google.protobuf.StringValue delivery_description = 12;
|
||||||
}
|
}
|
||||||
message DeleteUserOrderRequest
|
message DeleteUserOrderRequest
|
||||||
{
|
{
|
||||||
@@ -116,6 +123,13 @@ message GetUserOrderResponse
|
|||||||
}
|
}
|
||||||
google.protobuf.StringValue user_address_text = 10;
|
google.protobuf.StringValue user_address_text = 10;
|
||||||
repeated GetUserOrderResponseFactorDetail factor_details = 11;
|
repeated GetUserOrderResponseFactorDetail factor_details = 11;
|
||||||
|
// وضعیت ارسال و اطلاعات پستی
|
||||||
|
oneof DeliveryStatus_item
|
||||||
|
{
|
||||||
|
messages.DeliveryStatus delivery_status = 12;
|
||||||
|
}
|
||||||
|
google.protobuf.StringValue tracking_code = 13;
|
||||||
|
google.protobuf.StringValue delivery_description = 14;
|
||||||
}
|
}
|
||||||
message GetUserOrderResponseFactorDetail
|
message GetUserOrderResponseFactorDetail
|
||||||
{
|
{
|
||||||
@@ -149,6 +163,11 @@ message GetAllUserOrderByFilterFilter
|
|||||||
{
|
{
|
||||||
messages.PaymentMethod payment_method = 9;
|
messages.PaymentMethod payment_method = 9;
|
||||||
}
|
}
|
||||||
|
// فیلتر وضعیت ارسال
|
||||||
|
oneof DeliveryStatus_item
|
||||||
|
{
|
||||||
|
messages.DeliveryStatus delivery_status = 10;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
message GetAllUserOrderByFilterResponse
|
message GetAllUserOrderByFilterResponse
|
||||||
{
|
{
|
||||||
@@ -174,6 +193,13 @@ message GetAllUserOrderByFilterResponseModel
|
|||||||
}
|
}
|
||||||
google.protobuf.StringValue user_address_text = 10;
|
google.protobuf.StringValue user_address_text = 10;
|
||||||
repeated GetAllUserOrderByFilterResponseModelFactorDetail factor_details = 11;
|
repeated GetAllUserOrderByFilterResponseModelFactorDetail factor_details = 11;
|
||||||
|
// وضعیت ارسال و اطلاعات پستی
|
||||||
|
oneof DeliveryStatus_item
|
||||||
|
{
|
||||||
|
messages.DeliveryStatus delivery_status = 12;
|
||||||
|
}
|
||||||
|
google.protobuf.StringValue tracking_code = 13;
|
||||||
|
google.protobuf.StringValue delivery_description = 14;
|
||||||
}
|
}
|
||||||
message GetAllUserOrderByFilterResponseModelFactorDetail
|
message GetAllUserOrderByFilterResponseModelFactorDetail
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user