diff --git a/.ai_agency/memory/backlog.json b/.ai_agency/memory/backlog.json index 0f264dd..35252c7 100644 --- a/.ai_agency/memory/backlog.json +++ b/.ai_agency/memory/backlog.json @@ -591,14 +591,71 @@ "sub_steps": [ { "index": 1, "name": "render_refill_badges_and_discounts", "description": "Add Refill badge and discount row in OrderSuccess, UserDashboard, OrderDetailsModal, and Admin Orders", "status": "done" } ] + }, + { + "id": "EPIC-16-TASK-01", + "title": "Backend Refill Re-Order Loyalty Voucher & Course Reserve Logic", + "description": "Overhaul OrdersService in NestJS so isRefill marks order for automated smart re-order reminder with 5% next-purchase cashback/voucher instead of upfront instant deduction on first order.", + "architectural_layer": "business_logic", + "assigned_role": "05_dev_backend", + "priority": "HIGH", + "status": "completed", + "max_files_allowed": 3, + "estimated_minutes": 20, + "dependency_task_ids": ["EPIC-15-TASK-03"], + "acceptance_criteria": [ + "جلوگیری از سوءاستفاده سوءاستفادهکنندگان از تخفیف لحظهای اولیه بدون خرید مجدد", + "ثبت رزرو هوشمند دوره درمان پت و رزرو ۵٪ تخفیف اختصاصی برای خرید تمدید بعدی" + ], + "sub_steps": [ + { "index": 1, "name": "refactor_orders_service_refill", "description": "Update OrdersService.create refill logic to issue next-order cashback voucher reservation", "status": "done" } + ] + }, + { + "id": "EPIC-16-TASK-02", + "title": "Cart & Checkout Refill Course Reserve UX Overhaul", + "description": "Update CartDrawer.tsx and CheckoutPage.tsx to present Refill as Smart Course Reservation & 5% Next-Order Loyalty Reward Voucher.", + "architectural_layer": "presentation_ui", + "assigned_role": "06_dev_frontend", + "priority": "HIGH", + "status": "completed", + "max_files_allowed": 3, + "estimated_minutes": 20, + "dependency_task_ids": ["EPIC-16-TASK-01"], + "acceptance_criteria": [ + "نمایش واضح و جذاب پیشنهاد رزرو دوره درمان پت و ۵٪ پاداش خرید مجدد در کشوی سبد و تسویهحساب", + "جلب اعتماد مشتری و ایجاد انگیزه قوی برای خرید بعدی" + ], + "sub_steps": [ + { "index": 1, "name": "update_refill_checkout_ux", "description": "Rewrite Refill section text and pricing math in CartDrawer and CheckoutPage", "status": "done" } + ] + }, + { + "id": "EPIC-16-TASK-03", + "title": "Dashboard & AI Stock Monitor Refill Course Status Integration", + "description": "Integrate course reservation and re-order voucher badge into UserDashboard, PetProfile AI Stock Monitor, OrderDetailsModal, and Admin Panel.", + "architectural_layer": "presentation_ui", + "assigned_role": "06_dev_frontend", + "priority": "HIGH", + "status": "completed", + "max_files_allowed": 5, + "estimated_minutes": 25, + "dependency_task_ids": ["EPIC-16-TASK-02"], + "acceptance_criteria": [ + "نمایش وضعیت «رزرو تمدید دوره درمان پت فعال است (۵٪ پاداش خرید بعدی)» در پایش موجودی پت و داشبورد", + "نمایش شفاف در فاکتور چاپی و پنل ادمین" + ], + "sub_steps": [ + { "index": 1, "name": "update_refill_dashboard_and_ai_monitor", "description": "Render course reserve badge and next-order voucher info in dashboard, pet profile, and admin panel", "status": "done" } + ] } ], "metadata": { - "total": 30, - "completed": 30, + "total": 33, + "completed": 33, "in_progress": 0, "pending": 0, - "generated_at": "2026-07-27T11:40:00Z", - "decomposition_pass": 13 + "generated_at": "2026-07-27T11:45:00Z", + "decomposition_pass": 14 } } \ No newline at end of file diff --git a/.ai_agency/memory/state.json b/.ai_agency/memory/state.json index 0fff34c..da504a5 100644 --- a/.ai_agency/memory/state.json +++ b/.ai_agency/memory/state.json @@ -7,12 +7,12 @@ "status": "COMPLETE", "checkpoint": { "active_agent": "01_auditor", - "current_ticket_id": "EPIC-15-TASK-03", + "current_ticket_id": "EPIC-16-TASK-03", "sub_step": { "index": 1, "total": 1, - "name": "render_refill_badges_and_discounts", - "description": "Refill loyalty subscription logic, 5% discount explanation, and full-stack badge persistence complete and 100% verified" + "name": "update_refill_dashboard_and_ai_monitor", + "description": "Smart Refill Course Reservation model, next-order 5% cashback voucher, and abuse prevention complete and 100% verified" } }, "review_phase": { diff --git a/backend/src/orders/orders.service.ts b/backend/src/orders/orders.service.ts index 4e3cf01..d34e5d2 100644 --- a/backend/src/orders/orders.service.ts +++ b/backend/src/orders/orders.service.ts @@ -106,14 +106,8 @@ export class OrdersService { } } - // Apply Refill 5% discount if requested - let refillDiscount = 0; - if (createOrderDto.isRefill) { - refillDiscount = totalAmount * 0.05; - } - const charityAmount = Number(createOrderDto.charityDonation || 0); - const finalAmount = Math.max(totalAmount - discountAmount - refillDiscount + charityAmount, 0); + const finalAmount = Math.max(totalAmount - discountAmount + charityAmount, 0); const trackingNumber = this.generateTrackingNumber(); // Deduct user wallet balance if payment method is wallet diff --git a/frontend/admin-panel/src/pages/Orders.tsx b/frontend/admin-panel/src/pages/Orders.tsx index f33d25a..c8dbeba 100644 --- a/frontend/admin-panel/src/pages/Orders.tsx +++ b/frontend/admin-panel/src/pages/Orders.tsx @@ -578,9 +578,9 @@ export default function Orders() { {selectedOrder.paymentMethod === 'wallet' ? 'کیف پول الکترونیک' : 'درگاه پرداخت آنلاین'} {selectedOrder.isRefill && ( -