Feature: Lên danh sách khuyến mãi - #68
Conversation
WalkthroughA scheduled promotional bonuses system ("planned extras") was added: new config file and Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Plugin as DotMan
participant PlannedExtras
participant CardProvider_Admin as CardProvider/AdminCmd
participant Config
User->>CardProvider_Admin: request award (card/manual)
CardProvider_Admin->>Plugin: access plannedExtras
Plugin->>PlannedExtras: getCurrentExtra()
PlannedExtras-->>Plugin: active promotion or null
alt Promotion found
CardProvider_Admin->>CardProvider_Admin: apply planned promotion (amount, percent, name)
else No promotion
CardProvider_Admin->>Config: read legacy extraRate/extraUntil
CardProvider_Admin->>CardProvider_Admin: apply legacy extra if applicable
end
CardProvider_Admin-->>User: award points and send messages (include promotion info if any)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15 minutes Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
dotman-plugin/src/main/resources/khuyenmai.yml (1)
19-27: Update sample dates to avoid confusion.The sample promotions use 2024 dates which are already expired. Consider updating these to future dates or adding a comment clarifying these are historical examples to avoid confusion when administrators copy this configuration.
- from: 30/04/2024 00:00 - to: 01/05/2024 23:59 + from: 30/04/2025 00:00 + to: 01/05/2025 23:59 - from: 02/09/2024 00:00 - to: 03/09/2024 23:59 + from: 02/09/2025 00:00 + to: 03/09/2025 23:59
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
dotman-plugin/src/main/java/net/minevn/dotman/DotMan.kt(2 hunks)dotman-plugin/src/main/java/net/minevn/dotman/commands/AdminCmd.kt(1 hunks)dotman-plugin/src/main/java/net/minevn/dotman/config/PlannedExtras.kt(1 hunks)dotman-plugin/src/main/java/net/minevn/dotman/providers/CardProvider.kt(1 hunks)dotman-plugin/src/main/resources/khuyenmai.yml(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: the manual-point feature in `napthucong()` (admincmd.kt) now rejects non-positive values using `take...
Learnt from: amadeusmz
PR: minevn/dotman#62
File: dotman-plugin/src/main/java/net/minevn/dotman/commands/AdminCmd.kt:0-0
Timestamp: 2025-01-06T14:09:58.896Z
Learning: The manual-point feature in `napThuCong()` (AdminCmd.kt) now rejects non-positive values using `takeIf { it > 0 }`. This ensures a user cannot enter zero or negative points.
Applied to files:
dotman-plugin/src/main/java/net/minevn/dotman/commands/AdminCmd.ktdotman-plugin/src/main/java/net/minevn/dotman/providers/CardProvider.kt
🧬 Code Graph Analysis (1)
dotman-plugin/src/main/java/net/minevn/dotman/config/PlannedExtras.kt (1)
dotman-plugin/src/main/java/net/minevn/dotman/utils/Utils.kt (1)
info(27-27)
🔇 Additional comments (7)
dotman-plugin/src/main/java/net/minevn/dotman/DotMan.kt (1)
39-39: LGTM! Proper integration of the new PlannedExtras component.The new
plannedExtrasproperty follows the established pattern used by other components likemilestonesMasteranddiscord, with proper lateinit declaration and initialization in the reload() method.Also applies to: 84-84
dotman-plugin/src/main/java/net/minevn/dotman/commands/AdminCmd.kt (1)
236-242: LGTM! Proper prioritization of planned extras over legacy configuration.The logic correctly prioritizes planned promotions over legacy configuration with a proper fallback mechanism. The implementation maintains backward compatibility while enabling the new promotional system.
dotman-plugin/src/main/resources/khuyenmai.yml (1)
1-18: LGTM! Excellent documentation and configuration structure.The comprehensive comments clearly explain all configuration options, including the rate calculation formula and date format. The structure is intuitive and well-organized.
dotman-plugin/src/main/java/net/minevn/dotman/providers/CardProvider.kt (1)
119-128: LGTM! Well-implemented prioritization of planned extras.The refactoring correctly prioritizes planned promotions while maintaining backward compatibility. The use of
plannedExtra.calculateAmount()andplannedExtra.getPercentage()methods provides good encapsulation and consistency with the new promotional system.dotman-plugin/src/main/java/net/minevn/dotman/config/PlannedExtras.kt (3)
50-55: LGTM! Efficient logic for finding the highest rate active promotion.The
getCurrentExtra()method correctly filters active promotions and returns the one with the highest rate usingmaxByOrNull. This handles the requirement that overlapping promotions should prioritize the highest rate.
17-37: LGTM! Robust error handling and logging.The
loadComponents()method properly handles invalid entries with try-catch blocks, logs warnings for problematic promotions, and provides informative feedback about the number of loaded promotions.
74-75: Integer overflow incalculateAmountis not a concern with current ranges
After inspection, the largestbaseAmountcomes fromCardPrice.CP_1000K, which maps to 1,000,000. Even at a 100% promotion (rate = 1.0), the result is 2,000,000; and to overflow anInt(max ≈2.1 billion) you’d need an implausibly highrate(>2,147). No changes are required.

https://git.minevn.net/kitchen/plan/-/issues/60
Tổng quan
Cho phép server admin lên danh sách khuyên mãi tại file
khuyenmai.ymlNội dung file mẫu (dùng năm 2024 làm ví dụ)
Summary by CodeRabbit
New Features
Enhancements
Chores