Add delivery tracking fields to UserOrder entity

This commit is contained in:
masoodafar-web
2025-11-27 06:39:47 +03:30
parent 23ac9f77a1
commit 32b7cb3238
14 changed files with 1493 additions and 6 deletions

View File

@@ -71,7 +71,9 @@ public class
PaymentDate = DateTime.Now,
UserId = request.UserId,
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.SaveChangesAsync(cancellationToken);
@@ -92,4 +94,4 @@ public class
};
return finalResult;
}
}
}

View File

@@ -21,5 +21,10 @@ public record UpdateUserOrderCommand : IRequest<Unit>
public long UserAddressId { get; init; }
//
public PaymentMethod? PaymentMethod { get; init; }
}
// وضعیت ارسال سفارش
public DeliveryStatus? DeliveryStatus { get; init; }
// کد رهگیری مرسوله
public string? TrackingCode { get; init; }
// توضیحات ارسال
public string? DeliveryDescription { get; init; }
}

View File

@@ -30,4 +30,6 @@ public record GetAllUserOrderByFilterQuery : IRequest<GetAllUserOrderByFilterRes
public long? UserAddressId { get; set; }
//
public PaymentMethod? PaymentMethod { get; set; }
// وضعیت ارسال
public DeliveryStatus? DeliveryStatus { get; set; }
}

View File

@@ -28,7 +28,8 @@ public class GetAllUserOrderByFilterQueryHandler : IRequestHandler<GetAllUserOrd
.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.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
{

View File

@@ -32,6 +32,12 @@ public class GetAllUserOrderByFilterResponseDto
public string? UserAddressText { 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
{

View File

@@ -25,6 +25,12 @@ public class GetUserOrderResponseDto
public string? UserAddressText { 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
{

View File

@@ -1,5 +1,7 @@
using CMSMicroservice.Domain.Enums;
using CMSMicroservice.Domain.Enums;
namespace CMSMicroservice.Domain.Entities;
//سفارش کاربر
public class UserOrder : BaseAuditableEntity
@@ -27,6 +29,12 @@ public class UserOrder : BaseAuditableEntity
//UserAddress Navigation Property
public virtual UserAddress UserAddress { 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
public virtual ICollection<FactorDetails> FactorDetailss { get; set; }
}

View File

@@ -0,0 +1,17 @@
namespace CMSMicroservice.Domain.Enums;
// وضعیت ارسال سفارش
public enum DeliveryStatus
{
// نامشخص / بدون ارسال (مثلا سفارش پکیج)
None = 0,
// ثبت شده و در انتظار آماده‌سازی/ارسال
Pending = 1,
// تحویل شرکت پست/حمل‌ونقل شده
InTransit = 2,
// توسط مشتری دریافت شده
Delivered = 3,
// مرجوع شده
Returned = 4,
}

File diff suppressed because it is too large Load Diff

View File

@@ -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");
}
}
}

View File

@@ -851,6 +851,12 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
b.Property<string>("CreatedBy")
.HasColumnType("nvarchar(max)");
b.Property<string>("DeliveryDescription")
.HasColumnType("nvarchar(max)");
b.Property<int>("DeliveryStatus")
.HasColumnType("int");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
@@ -872,6 +878,9 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
b.Property<int>("PaymentStatus")
.HasColumnType("int");
b.Property<string>("TrackingCode")
.HasColumnType("nvarchar(max)");
b.Property<long?>("TransactionId")
.HasColumnType("bigint");

View File

@@ -3,7 +3,7 @@
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>0.0.128</Version>
<Version>0.0.131</Version>
<DebugType>None</DebugType>
<DebugSymbols>False</DebugSymbols>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>

View File

@@ -37,6 +37,20 @@ enum PaymentStatus
Reject = 1;
Pending = 2;
}
// وضعیت ارسال سفارش
enum DeliveryStatus
{
// نامشخص / نیاز به ارسال ندارد (مثلا سفارش پکیج)
DeliveryStatus_None = 0;
// ثبت شده و در انتظار آماده‌سازی/ارسال
DeliveryStatus_Pending = 1;
// تحویل پست/حمل‌ونقل شده است
DeliveryStatus_InTransit = 2;
// توسط مشتری دریافت شده است
DeliveryStatus_Delivered = 3;
// مرجوع شده
DeliveryStatus_Returned = 4;
}
enum TransactionType
{
Buy = 0;

View File

@@ -88,6 +88,13 @@ message UpdateUserOrderRequest
{
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
{
@@ -116,6 +123,13 @@ message GetUserOrderResponse
}
google.protobuf.StringValue user_address_text = 10;
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
{
@@ -149,6 +163,11 @@ message GetAllUserOrderByFilterFilter
{
messages.PaymentMethod payment_method = 9;
}
// فیلتر وضعیت ارسال
oneof DeliveryStatus_item
{
messages.DeliveryStatus delivery_status = 10;
}
}
message GetAllUserOrderByFilterResponse
{
@@ -174,6 +193,13 @@ message GetAllUserOrderByFilterResponseModel
}
google.protobuf.StringValue user_address_text = 10;
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
{