feat: Implement User Package Status and User Order Management features
- Added GetUserPackageStatus functionality with mapping and service implementation. - Introduced UserOrder service methods for updating order status, applying discounts, and calculating order PV. - Created Protobuf definitions for public messages and user orders, including necessary request and response messages. - Implemented mapping profiles for package and user order related queries and commands. - Developed query handlers and validators for new commands and queries in the application layer. - Established PublicMessage service for handling public messages with appropriate gRPC endpoints.
This commit is contained in:
@@ -42,6 +42,13 @@ service PackageContract
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
// Package Purchase System (Admin endpoints)
|
||||
rpc GetUserPackageStatus(GetUserPackageStatusRequest) returns (GetUserPackageStatusResponse){
|
||||
option (google.api.http) = {
|
||||
get: "/GetUserPackageStatus"
|
||||
};
|
||||
};
|
||||
}
|
||||
message CreateNewPackageRequest
|
||||
{
|
||||
@@ -113,6 +120,25 @@ message GetAllPackageByFilterResponseModel
|
||||
int64 price = 5;
|
||||
}
|
||||
|
||||
// Package Purchase Messages
|
||||
message GetUserPackageStatusRequest
|
||||
{
|
||||
int64 user_id = 1;
|
||||
}
|
||||
|
||||
message GetUserPackageStatusResponse
|
||||
{
|
||||
int64 user_id = 1;
|
||||
string package_purchase_method = 2;
|
||||
bool has_purchased_package = 3;
|
||||
bool is_club_member_active = 4;
|
||||
int64 wallet_balance = 5;
|
||||
int64 discount_balance = 6;
|
||||
bool can_activate_club_membership = 7;
|
||||
google.protobuf.StringValue last_order_number = 8;
|
||||
google.protobuf.Timestamp last_purchase_date = 9;
|
||||
}
|
||||
|
||||
message PaginationState
|
||||
{
|
||||
int32 page_number = 1;
|
||||
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>disable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Google.Protobuf" Version="3.28.3" />
|
||||
<PackageReference Include="Grpc.Net.Client" Version="2.68.0" />
|
||||
<PackageReference Include="Grpc.Tools" Version="2.68.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Protobuf Include="Protos\public_messages.proto" GrpcServices="Client" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,182 @@
|
||||
syntax = "proto3";
|
||||
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "google/protobuf/wrappers.proto";
|
||||
|
||||
option csharp_namespace = "BackOffice.BFF.PublicMessage.Protobuf";
|
||||
|
||||
package publicmessages;
|
||||
|
||||
service PublicMessageContract
|
||||
{
|
||||
rpc CreatePublicMessage(CreatePublicMessageRequest) returns (CreatePublicMessageResponse);
|
||||
rpc UpdatePublicMessage(UpdatePublicMessageRequest) returns (UpdatePublicMessageRequest);
|
||||
rpc DeletePublicMessage(DeletePublicMessageRequest) returns (DeletePublicMessageRequest);
|
||||
rpc PublishMessage(PublishMessageRequest) returns (PublishMessageResponse);
|
||||
rpc ArchiveMessage(ArchiveMessageRequest) returns (ArchiveMessageResponse);
|
||||
rpc GetAllMessages(GetAllMessagesRequest) returns (GetAllMessagesResponse);
|
||||
rpc GetActiveMessages(GetActiveMessagesRequest) returns (GetActiveMessagesResponse);
|
||||
rpc GetPublicMessage(GetPublicMessageRequest) returns (GetPublicMessageResponse);
|
||||
}
|
||||
|
||||
// Create Public Message
|
||||
message CreatePublicMessageRequest
|
||||
{
|
||||
string title = 1;
|
||||
string content = 2;
|
||||
int32 message_type = 3;
|
||||
int32 priority = 4;
|
||||
google.protobuf.Timestamp starts_at = 5;
|
||||
google.protobuf.Timestamp expires_at = 6;
|
||||
bool is_dismissible = 7;
|
||||
string target_audience = 8;
|
||||
repeated string tags = 9;
|
||||
}
|
||||
|
||||
message CreatePublicMessageResponse
|
||||
{
|
||||
bool success = 1;
|
||||
string message = 2;
|
||||
int64 message_id = 3;
|
||||
}
|
||||
|
||||
// Update Public Message
|
||||
message UpdatePublicMessageRequest
|
||||
{
|
||||
int64 message_id = 1;
|
||||
string title = 2;
|
||||
string content = 3;
|
||||
int32 message_type = 4;
|
||||
int32 priority = 5;
|
||||
google.protobuf.Timestamp starts_at = 6;
|
||||
google.protobuf.Timestamp expires_at = 7;
|
||||
bool is_dismissible = 8;
|
||||
string target_audience = 9;
|
||||
repeated string tags = 10;
|
||||
}
|
||||
|
||||
// Delete Public Message
|
||||
message DeletePublicMessageRequest
|
||||
{
|
||||
int64 message_id = 1;
|
||||
}
|
||||
|
||||
// Publish Message
|
||||
message PublishMessageRequest
|
||||
{
|
||||
int64 message_id = 1;
|
||||
}
|
||||
|
||||
message PublishMessageResponse
|
||||
{
|
||||
bool success = 1;
|
||||
string message = 2;
|
||||
google.protobuf.Timestamp published_at = 3;
|
||||
}
|
||||
|
||||
// Archive Message
|
||||
message ArchiveMessageRequest
|
||||
{
|
||||
int64 message_id = 1;
|
||||
}
|
||||
|
||||
message ArchiveMessageResponse
|
||||
{
|
||||
bool success = 1;
|
||||
string message = 2;
|
||||
google.protobuf.Timestamp archived_at = 3;
|
||||
}
|
||||
|
||||
// Get All Messages (Admin view)
|
||||
message GetAllMessagesRequest
|
||||
{
|
||||
google.protobuf.Int32Value status = 1;
|
||||
google.protobuf.Int32Value message_type = 2;
|
||||
int32 page_number = 3;
|
||||
int32 page_size = 4;
|
||||
}
|
||||
|
||||
message GetAllMessagesResponse
|
||||
{
|
||||
repeated AdminPublicMessageDto messages = 1;
|
||||
int32 total_count = 2;
|
||||
int32 page_number = 3;
|
||||
int32 page_size = 4;
|
||||
}
|
||||
|
||||
message AdminPublicMessageDto
|
||||
{
|
||||
int64 message_id = 1;
|
||||
string title = 2;
|
||||
string content = 3;
|
||||
int32 message_type = 4;
|
||||
string message_type_name = 5;
|
||||
int32 priority = 6;
|
||||
string priority_name = 7;
|
||||
int32 status = 8;
|
||||
string status_name = 9;
|
||||
google.protobuf.Timestamp starts_at = 10;
|
||||
google.protobuf.Timestamp expires_at = 11;
|
||||
google.protobuf.Timestamp published_at = 12;
|
||||
google.protobuf.Timestamp archived_at = 13;
|
||||
bool is_dismissible = 14;
|
||||
string target_audience = 15;
|
||||
repeated string tags = 16;
|
||||
google.protobuf.Timestamp created = 17;
|
||||
google.protobuf.Timestamp last_modified = 18;
|
||||
}
|
||||
|
||||
// Get Active Messages (Frontend view)
|
||||
message GetActiveMessagesRequest
|
||||
{
|
||||
google.protobuf.Int32Value message_type = 1;
|
||||
string target_audience = 2;
|
||||
}
|
||||
|
||||
message GetActiveMessagesResponse
|
||||
{
|
||||
repeated PublicMessageDto messages = 1;
|
||||
}
|
||||
|
||||
message PublicMessageDto
|
||||
{
|
||||
int64 message_id = 1;
|
||||
string title = 2;
|
||||
string content = 3;
|
||||
int32 message_type = 4;
|
||||
string message_type_name = 5;
|
||||
int32 priority = 6;
|
||||
string priority_name = 7;
|
||||
google.protobuf.Timestamp starts_at = 8;
|
||||
google.protobuf.Timestamp expires_at = 9;
|
||||
bool is_dismissible = 10;
|
||||
repeated string tags = 11;
|
||||
}
|
||||
|
||||
// Get Single Public Message
|
||||
message GetPublicMessageRequest
|
||||
{
|
||||
int64 message_id = 1;
|
||||
}
|
||||
|
||||
message GetPublicMessageResponse
|
||||
{
|
||||
int64 message_id = 1;
|
||||
string title = 2;
|
||||
string content = 3;
|
||||
int32 message_type = 4;
|
||||
string message_type_name = 5;
|
||||
int32 priority = 6;
|
||||
string priority_name = 7;
|
||||
int32 status = 8;
|
||||
string status_name = 9;
|
||||
google.protobuf.Timestamp starts_at = 10;
|
||||
google.protobuf.Timestamp expires_at = 11;
|
||||
google.protobuf.Timestamp published_at = 12;
|
||||
google.protobuf.Timestamp archived_at = 13;
|
||||
bool is_dismissible = 14;
|
||||
string target_audience = 15;
|
||||
repeated string tags = 16;
|
||||
google.protobuf.Timestamp created = 17;
|
||||
google.protobuf.Timestamp last_modified = 18;
|
||||
}
|
||||
@@ -62,6 +62,30 @@ service UserOrderContract
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
// Order Management
|
||||
rpc UpdateOrderStatus(UpdateOrderStatusRequest) returns (UpdateOrderStatusResponse){
|
||||
option (google.api.http) = {
|
||||
post: "/UpdateOrderStatus"
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
rpc GetOrdersByDateRange(GetOrdersByDateRangeRequest) returns (GetOrdersByDateRangeResponse){
|
||||
option (google.api.http) = {
|
||||
get: "/GetOrdersByDateRange"
|
||||
};
|
||||
};
|
||||
rpc ApplyDiscountToOrder(ApplyDiscountToOrderRequest) returns (ApplyDiscountToOrderResponse){
|
||||
option (google.api.http) = {
|
||||
post: "/ApplyDiscountToOrder"
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
rpc CalculateOrderPV(CalculateOrderPVRequest) returns (CalculateOrderPVResponse){
|
||||
option (google.api.http) = {
|
||||
get: "/CalculateOrderPV"
|
||||
};
|
||||
};
|
||||
}
|
||||
message CreateNewUserOrderRequest
|
||||
{
|
||||
@@ -229,6 +253,88 @@ message MetaData
|
||||
|
||||
bool has_next = 6;
|
||||
}
|
||||
|
||||
// Order Management Messages
|
||||
message UpdateOrderStatusRequest
|
||||
{
|
||||
int64 order_id = 1;
|
||||
int32 new_status = 2;
|
||||
}
|
||||
|
||||
message UpdateOrderStatusResponse
|
||||
{
|
||||
bool success = 1;
|
||||
string message = 2;
|
||||
int32 old_status = 3;
|
||||
int32 new_status = 4;
|
||||
}
|
||||
|
||||
message GetOrdersByDateRangeRequest
|
||||
{
|
||||
google.protobuf.Timestamp start_date = 1;
|
||||
google.protobuf.Timestamp end_date = 2;
|
||||
google.protobuf.Int32Value status = 3;
|
||||
google.protobuf.Int64Value user_id = 4;
|
||||
int32 page_number = 5;
|
||||
int32 page_size = 6;
|
||||
}
|
||||
|
||||
message GetOrdersByDateRangeResponse
|
||||
{
|
||||
MetaData meta_data = 1;
|
||||
repeated OrderSummaryDto orders = 2;
|
||||
}
|
||||
|
||||
message OrderSummaryDto
|
||||
{
|
||||
int64 order_id = 1;
|
||||
string order_number = 2;
|
||||
int64 user_id = 3;
|
||||
string user_full_name = 4;
|
||||
int64 total_amount = 5;
|
||||
int32 status = 6;
|
||||
string status_name = 7;
|
||||
int32 items_count = 8;
|
||||
google.protobuf.Timestamp created_at = 9;
|
||||
}
|
||||
|
||||
message ApplyDiscountToOrderRequest
|
||||
{
|
||||
int64 order_id = 1;
|
||||
int64 discount_amount = 2;
|
||||
string reason = 3;
|
||||
}
|
||||
|
||||
message ApplyDiscountToOrderResponse
|
||||
{
|
||||
bool success = 1;
|
||||
string message = 2;
|
||||
int64 original_amount = 3;
|
||||
int64 discount_amount = 4;
|
||||
int64 final_amount = 5;
|
||||
}
|
||||
|
||||
message CalculateOrderPVRequest
|
||||
{
|
||||
int64 order_id = 1;
|
||||
}
|
||||
|
||||
message CalculateOrderPVResponse
|
||||
{
|
||||
int64 order_id = 1;
|
||||
int64 total_pv = 2;
|
||||
repeated ProductPVDto products = 3;
|
||||
}
|
||||
|
||||
message ProductPVDto
|
||||
{
|
||||
int64 product_id = 1;
|
||||
string product_title = 2;
|
||||
int32 quantity = 3;
|
||||
int64 unit_pv = 4;
|
||||
int64 total_pv = 5;
|
||||
}
|
||||
|
||||
message DecimalValue
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user