- Add GetUserPackageStatusQueryValidator for user package status validation.
- Create ArchiveMessageCommand and ArchiveMessageCommandHandler for archiving public messages.
- Implement ArchiveMessageCommandValidator to validate message ID.
- Introduce PublishMessageCommand and PublishMessageCommandHandler for publishing messages.
- Add PublishMessageCommandValidator for validating publish message requests.
- Implement GetPublicMessageQuery and GetPublicMessageQueryHandler for retrieving public messages.
- Create GetPublicMessageQueryValidator for validating public message requests.
- Add ApplyDiscountToOrderCommand and ApplyDiscountToOrderCommandHandler for applying discounts to orders.
- Implement ApplyDiscountToOrderCommandValidator for validating discount application requests.
- Create UpdateOrderStatusCommand and UpdateOrderStatusCommandHandler for changing order statuses.
- Implement UpdateOrderStatusCommandValidator for validating order status updates.
- Add CalculateOrderPVQuery and CalculateOrderPVQueryHandler for calculating order PV.
- Implement CalculateOrderPVQueryValidator for validating PV calculation requests.
- Create GetOrdersByDateRangeQuery and GetOrdersByDateRangeQueryHandler for retrieving orders by date range.
- Implement GetOrdersByDateRangeQueryValidator for validating date range queries.
- Add PublicMessage entity to represent public messages in the system.
- Implement PublicMessageService for handling public message operations via gRPC.
- Implemented Create, Delete, Get, and Update validators for Product Galleries.
- Added Create, Delete, Get, and Update validators for Product Tags.
- Created service classes for handling Discount Categories, Discount Orders, Discount Products, Discount Shopping Cart, Product Categories, Product Galleries, and Product Tags.
- Each service class integrates with CQRS for command and query handling.
- Established mapping profiles for Product Galleries.
Added Phase 5 (CommissionCQ) complete documentation:
- 5 Commands with detailed logic explanations
- 4 Queries with filters and features
- Recursive Binary Tree algorithm documentation
- State machine and withdrawal system
- Type conversion fixes documented
- Overall project statistics updated
Total lines: ~9,670 | Total files: 137+ | Total commits: 11
Added 5 Commands and 4 Queries for commission calculation and payout system:
Commands:
- CalculateWeeklyBalances: Recursive binary tree traversal for leg balances
- CalculateWeeklyCommissionPool: Calculate ValuePerBalance from total pool
- ProcessUserPayouts: Distribute commission to users, create payout records
- RequestWithdrawal: User requests cash/diamond withdrawal
- ProcessWithdrawal: Admin approves/rejects withdrawal
Queries:
- GetWeeklyCommissionPool: Retrieve pool details
- GetUserCommissionPayouts: List payouts with filters (status, week, user)
- GetCommissionPayoutHistory: Complete audit trail
- GetUserWeeklyBalances: Show leg balances and contributions
Total: 35 files, ~1,100 lines of code
Binary tree algorithm, state machine, withdrawal system implemented
- Implemented 3 Commands with handlers and validators:
* JoinNetworkCommand: Add user to binary network tree
- Validates parent exists and is in network
- Validates leg position is empty
- Records history with NetworkMembershipAction.Join
* MoveInNetworkCommand: Move user to different position
- Validates new parent and leg availability
- Prevents circular dependencies (IsDescendant check)
- Records old/new parent and leg in history
* RemoveFromNetworkCommand: Remove user from network
- Validates no children exist (must move/remove first)
- Soft delete (sets NetworkParentId to null)
- Idempotent design
- Implemented 3 Queries with handlers, validators, and DTOs:
* GetNetworkTreeQuery: Binary tree visualization
- Recursive tree building with MaxDepth limit (1-10)
- Returns nested structure with Left/Right children
* GetUserNetworkPositionQuery: User position details
- Parent info, leg position, children counts
- Left/Right child counts for balance view
* GetNetworkMembershipHistoryQuery: Complete audit trail
- Filter by UserId, pagination support
- Shows Join/Move/Remove actions with full details
- All operations include complete history tracking
- Binary tree validation (parent-child relationships)
- Circular dependency prevention in MoveInNetwork
- 21 new files, ~850 lines of code
- Build successful with 0 errors