Giao diện
Chiến dịch
Trang sinh tự động
Phần nghiệp vụ viết tay; API, dữ liệu, quyền, đường dẫn và file nguồn do bộ sinh điền từ source tại ad83b0aea.
Làm gì
Hai loại chiến dịch: Mua chung và Mua định kỳ. Chiến dịch mở trong một khoảng thời gian, có số lượng tối thiểu và các mốc giảm giá; khi đóng thì chốt bậc giá thực tế rồi tính lại tiền cho mọi đơn.
Quy mô
| Domain API | campaign, campaign-import, campaign-public |
| Query / Mutation | 28 / 10 |
| Nguồn dữ liệu | campaign |
| Bảng | 23 |
| Luật phân quyền | 0 |
| Đường dẫn Web Admin | 4 |
Thao tác (mutation)
| Mutation | Domain | Mô tả |
|---|---|---|
adoptRecurringBasket | campaign | G2S S3 (BR-MD-05 / BR-MD-11, DR-01, DEC-OWN28-G2S-BASKET-ADOPT-REPLACE): after sign-in, the device basket replaces the caller's DRAFT of the campaign (package, window, lines and per-cycle quantities) or starts one; idempotent by requestId. Requires order.create (U-02, OWN). |
clearSearchHistory | campaign-public | Deletes the caller's search history. Signed-in APP_USER buyer only. |
createCampaign | campaign | Tạo chiến dịch (B052.R09): validated, DRAFT -> PENDING_PUBLISH (UPCOMING if publishAt <= now). deal.manage. |
deleteCampaign | campaign | Xóa (B198.R02): hard delete of a DRAFT / PENDING_PUBLISH / UPCOMING without orders. Requires deal.manage. |
discardRecurringBasket | campaign | Discards the caller's DRAFT basket. Requires order.create (U-02, OWN). |
recordSearchKeyword | campaign-public | Puts the keyword first (duplicates ignoring case and spaces removed), keeps 5; returns the new history. Signed-in APP_USER buyer only. |
saveCampaignDraft | campaign | Lưu nháp (B052.R07): create or edit a Group Buy DRAFT, stored as typed (B006.R16). Requires deal.manage. |
saveRecurringBasketDraft | campaign | Creates or replaces the caller's DRAFT basket: package (optional since G2S), window, lines and every per-cycle quantity in one write. Requires order.create (U-02, OWN). |
saveRecurringCampaignDraft | campaign | Lưu nháp of a Mua định kỳ DRAFT (create or edit): basket, tiers, windows, packages and schedule in one version. Requires deal.manage. |
updateCampaign | campaign | Lưu thay đổi (B149.R03) in PENDING_PUBLISH / UPCOMING: validated, state kept. Requires deal.manage. |
Phép đọc (query)
| Query | Domain | Mô tả |
|---|---|---|
campaign | campaign | Campaign configuration and history (figures: campaignOverview, U19-P2-08). Requires deal.read. |
campaignCloneSource | campaign | Nhân bản: the form prefill from a campaign in any state (B006.R13). Requires deal.manage. |
campaignCreators | campaign | Bộ lọc Người tạo: accounts that may create a campaign (B036.R06). Requires deal.read. |
campaignImportCheck | campaign-import | Kiểm tra file (BR-IM-05): classifies the file against current, writes nothing (DEC-CV3-07). Requires deal.manage. |
campaignImportPreflight | campaign-import | Số dòng sản phẩm of the chosen file (DEC-CV3-23): the caller's own READY upload, else not_found. Requires deal.manage. |
campaignImportTemplate | campaign-import | Tải file mẫu Mua chung / Mua định kỳ (.xlsx). Requires deal.manage. |
campaignOverlap | campaign | Field check when leaving Thời gian mở/đóng (B006.R18; touching is not overlapping). Requires deal.manage. |
campaignOverview | campaign | Tổng quan of a Mua chung (B171.R04-R09) or a Mua định kỳ (B256.R02-R10, field recurring). Requires deal.read. |
campaignPickerBrands | campaign | Thương hiệu list of the picker (CV3-P4-16, DEC-CV3-32): live brands whose |
campaignPickerCategories | campaign | Ngành hàng list of the picker (CV3-P4-16, DEC-CV3-32): every live |
campaignProductPicker | campaign | Active (On sale) single and combo products for a campaign. search under 3 |
campaignProgress | campaign-public | Server progress/estimate of a published Group Buy (UA-06/07). Requires deal.read_public. |
campaigns | campaign | Admin list (B011/B031), newest first, filters AND-ed; search = Mã or Tên, ignored under 3 characters; |
campaignSettings | campaign | System parameters of the campaign form. Requires deal.read. |
campaignSpinWheelOptions | campaign | Áp dụng vòng quay may mắn of the campaign form (CV3-P4-22, DEC-CV3-37, |
dealTermsSets | campaign | Terms sets by status (default ACTIVE), by name then version. Requires deal.read. |
myRecurringBasket | campaign | The caller's own DRAFT basket of a Mua định kỳ campaign, or null. G2S: when the campaign close discarded the draft, the next read returns it once with closedNotice true (status DISCARDED), then null. Requires order.read (U-01, OWN). |
mySearchHistory | campaign-public | The caller's last 5 search keywords, newest first. Signed-in APP_USER buyer only. |
publicCampaign | campaign-public | One published Group Buy (UA-07); unpublished = not_found. Requires deal.read_public. |
publicCampaignHome | campaign-public | App home, Mua chung: one Đang mở + one Sắp mở (null when none). Requires deal.read_public. |
publicCampaigns | campaign-public | Published Group Buy campaigns (UA-04..06): only Đang mở (OPEN) and Sắp mở |
publicCategories | campaign-public | Level-1 categories with at least one Deal shown on the App (Đang mở or Sắp mở). With campaignId (G2S S8, BR-KPD-02): level-1 categories with at least one product in that campaign (Mua định kỳ basket chips; [] when the campaign is not shown on the App). Requires deal.read_public. |
publicHomeStats | campaign-public | App home community figures (system_settings home.* / banner.*). Requires deal.read_public. |
publicRecurringCampaign | campaign-public | One published Recurring basket; unpublished, unknown or Group Buy = not_found. Requires deal.read_public. |
publicRecurringCampaigns | campaign-public | Published Recurring baskets (GAP-192): only OPEN and UPCOMING are listed |
publicRecurringHome | campaign-public | App home, Mua định kỳ: one Đang mở + one Sắp mở (null when none). Requires deal.read_public; User App only. |
publicSearch | campaign-public | Products matching the keyword (product name, brand, campaign / basket |
publicSearchFacets | campaign-public | Counts for the U-16 filter (same result set as publicSearch). Requires deal.read_public. |
Dữ liệu
- Domain
campaign— 23 bảng, 3 nhóm con: campaign (10) · recurring (8) · bảng đơn lẻ (5) (5)
Bảng được tham chiếu nhiều nhất trong module:
| Bảng | Cột | Được trỏ tới | RLS |
|---|---|---|---|
campaigns | 34 | 23 | ✓ |
campaign_policy_versions | 22 | 13 | ✓ |
campaign_outcomes | 17 | 6 | ✓ |
campaign_products | 20 | 6 | ✓ |
recurring_baskets | 19 | 4 | ✓ |
recurring_cycles | 14 | 4 | ✓ |
campaign_delivery_windows | 9 | 3 | ✓ |
campaign_term_packages | 11 | 3 | ✓ |
deal_terms_sets | 9 | 2 | ✓ |
delivery_milestones | 15 | 2 | ✓ |
Giao diện Web Admin
| Đường dẫn | Hằng số |
|---|---|
/campaigns | CAMPAIGNS |
/campaigns/:id | CAMPAIGN_DETAIL |
/campaigns/:id/edit | CAMPAIGN_EDIT |
/campaigns/new | CAMPAIGN_NEW |
File nguồn
Backend:
code/apps/api/supabase/functions/graphql/domains/campaign/code/apps/api/supabase/functions/graphql/domains/campaign-import/code/apps/api/supabase/functions/graphql/domains/campaign-public/
Dữ liệu: bảng thuộc domain campaign — xem Cơ sở dữ liệu.
Tài nguyên quyền không có luật nào
Bản đồ module khai các tài nguyên campaign nhưng ma trận quyền không có luật nào cho chúng. Hoặc tên tài nguyên trong bản đồ sai, hoặc quyền chưa được định nghĩa.