Báo cáo & quảng cáo

Thống kê

4 endpoint · https://pos.pages.fm/api/v1

Xem Markdown

Thống kê đơn hàng

GET/shops/{SHOP_ID}/analytics/sale

Lấy thống kê đơn hàng

Tham số đường dẫn

SHOP_IDintegerbắt buộc

Mã shop

Ví dụ: 4

Tham số truy vấn

sincestring · date-time

Thời gian bắt đầu thống kê

Ví dụ: "2024-01-01T00:00:00Z"
untilstring · date-time

Thời gian kết thúc thống kê

Ví dụ: "2024-12-31T23:59:59Z"
split_by[]array<string>

Thống kê theo một hoặc nhiều chiều, mỗi giá trị là khoá <Table>.<field>.

  • Time.hour / Time.day / Time.month / Time.year — theo giờ / ngày / tháng / năm
  • Order.source / Order.order_sources — theo nguồn đơn / tài khoản
  • Order.status — theo trạng thái đơn
  • Order.warehouse_id — theo kho
  • Order.post_id — theo bài viết Facebook
  • Order.partner_id — theo đối tác vận chuyển
  • Order.marketplace_id — theo sàn TMĐT
  • Order.country_code / Order.province_id / Order.district_id / Order.commune_id / Order.region_filter — theo địa lý giao hàng
  • Order.tag — theo tag đơn hàng
  • Order.is_wholesale / Order.is_livestream — đơn buôn / đơn livestream
  • Order.livestream_manager_ids — theo người quản lý livestream
  • Order.total_price — theo khoảng tổng tiền đơn
  • Order.ads_or_normal / Order.ad_account_id / Order.ad_id — phân nhóm quảng cáo
  • User.id / User.sale_group / User.department_id — theo nhân viên / nhóm bán / phòng ban
  • Customer.id / Customer.level_id / Customer.new — theo khách hàng / hạng / khách mới
  • Variation.id / Variation.product_id — theo mẫu mã / sản phẩm
  • Variation.category / Variation.supplier / Variation.brand_id / Variation.tag — theo danh mục / NCC / thương hiệu / tag SP
  • Variation.price_range / Variation.quantity_range — theo khoảng giá / khoảng SL
  • Variation.upsale / Variation.quantity — cờ upsell / SL bán
  • UTM.p_utm_source / UTM.p_utm_campaign / UTM.p_utm_medium / UTM.p_utm_term / UTM.p_utm_content — theo UTM
  • Promotion.default / Promotion.advance / Promotion.combo — theo khuyến mại / combo
  • Ads.ad_id / Ads.ad_set_id / Ads.ad_campaign_id — theo ad / ad set / chiến dịch
Giá trị"Time.hour""Time.day""Time.month""Time.year""Order.source""Order.order_sources""Order.status""Order.warehouse_id""Order.post_id""Order.partner_id""Order.marketplace_id""Order.country_code""Order.province_id""Order.district_id""Order.commune_id""Order.region_filter""Order.tag""Order.is_wholesale""Order.is_livestream""Order.livestream_manager_ids""Order.total_price""Order.ads_or_normal""Order.ad_account_id""Order.ad_id""User.id""User.sale_group""User.department_id""Customer.id""Customer.level_id""Customer.new""Variation.id""Variation.product_id""Variation.category""Variation.supplier""Variation.brand_id""Variation.tag""Variation.price_range""Variation.quantity_range""Variation.upsale""Variation.quantity""UTM.p_utm_source""UTM.p_utm_campaign""UTM.p_utm_medium""UTM.p_utm_term""UTM.p_utm_content""Promotion.default""Promotion.advance""Promotion.combo""Ads.ad_id""Ads.ad_set_id""Ads.ad_campaign_id"
filterobject

Bộ lọc áp dụng cho tập đơn hàng. Object có khoá dạng <Table>.<field>, giá trị là mảng chuỗi. Thêm hậu tố _exclude để loại trừ (ví dụ Order.status_exclude, Variation.category_exclude). Thêm hậu tố _and để AND-kết hợp các filter dạng danh sách (ví dụ Variation.tags_and). Các khoá thường dùng:

  • Variation.id / Variation.product_id — theo mẫu mã / sản phẩm
  • Variation.category / Variation.supplier / Variation.brand_id / Variation.brand — theo danh mục / NCC / thương hiệu
  • Variation.tag / Variation.tags / Variation.attribute — theo tag / thuộc tính SP
  • Variation.price_range / Variation.quantity_range / Variation.quantity — theo khoảng giá / khoảng SL
  • Variation.upsale / Variation.one_time_product / Variation.is_bonus_product / Variation.product_price_of_zero / Variation.unlink_ecommerce — các cờ SP
  • Order.source / Order.source_exclude / Order.order_sources — nguồn đơn
  • Order.status — mã trạng thái đơn
  • Order.warehouse_id / Order.post_id / Order.partner_id / Order.shop_partner_id / Order.marketplace_id — vận hành
  • Order.country_code / Order.province_id / Order.district_id / Order.commune_id / Order.region_filter / Order.region_filter_phil — địa lý giao hàng
  • Order.tag / Order.is_wholesale / Order.is_livestream / Order.received_at_shop / Order.is_upsale_order — cờ đơn
  • Order.total_price / Order.revenue — theo khoảng tổng tiền / doanh thu
  • Order.ad_id / Order.ads_source / Order.ad_account_id / Order.ads_or_normal — quảng cáo
  • Order.order_currency — tiền tệ đơn
  • Order.id / Order.project — theo mã đơn / dự án
  • Order.p_utm_source / Order.p_utm_campaign / Order.p_utm_medium / Order.p_utm_term / Order.p_utm_content / Order.utm_affiliate / Order.link — UTM
  • Order.instant / Order.N24H / Order.GSGN — dịch vụ vận chuyển
  • Order.livestream_manager_id / Order.livestream_manager_ids — người quản lý livestream
  • User.id / User.sale_group / User.department_id / User.pke_mkter / User.assigning_seller_id / User.assigning_care_id / User.item_assign_seller_id — nhân viên
  • Customer.id / Customer.level_id / Customer.gender / Customer.tag / Customer.conversation_tags / Customer.new / Customer.referral_code — khách hàng
  • Promotion.default / Promotion.advance / Promotion.id / Promotion.combo — khuyến mại / combo
success_statusstring

'send_to_partner': Tính đơn chốt khi đẩy sang ĐVVC
'1': Tính đơn chốt khi cập nhật sang trạng thái đã xác nhận

Ví dụ: "send_to_partner"
success_recordstring

'inserted_at': Doanh thu cộng vào thời điểm tạo đơn
'updated_at': Doanh thu cộng vào thời điểm cập nhật trạng thái

Ví dụ: "inserted_at"
user_typestring

Tính đơn cho nhân viên ('create': Tạo đơn, 'update': Cập nhật trạng thái, 'assign': NV được phân công, 'care': NV chăm sóc, 'marketer': NV Marketing)

Ví dụ: "create"
returned_recordstring

Doanh thu sẽ trừ vào thời điểm ('inserted_at': Tạo đơn, 'updated_at': Cập nhật trạng thái, 'success_record': Chốt đơn)

Ví dụ: "inserted_at"
select_fields[]array<string>

Các số liệu cần lấy

Phản hồi

object
dataarray<object>

Dữ liệu thống kê

successboolean

Trạng thái thành công

Yêu cầu
curl "https://pos.pages.fm/api/v1/shops/{SHOP_ID}/analytics/sale?api_key=API_KEY"
Phản hồi 200
{
  "success": true,
  "data": [
    {
      "Time.day": "2020-07-22",
      "returned": null,
      "success": {
        "cod": 1710000,
        "discount": 0,
        "order_count": 3,
        "price": 1800000,
        "product_count": 18,
        "shipping_fee": 0,
        "custom_formula_d6ae-ad02-be3d-b26e-3f65-d497-33c4": 1000000
      }
    },
    {
      "Time.day": "2020-07-27",
      "returned": null,
      "success": {
        "cod": 570000,
        "discount": 0,
        "order_count": 1,
        "price": 600000,
        "avg_price": 600000,
        "product_count": 6,
        "shipping_fee": 0,
        "custom_formula_d6ae-ad02-be3d-b26e-3f65-d497-33c4": 1000000
      }
    },
    {
      "Time.day": "2020-07-28",
      "returned": null,
      "success": {
        "cod": 5130000,
        "discount": 0,
        "order_count": 9,
        "price": 5400000,
        "avg_price": 600000,
        "product_count": 54,
        "shipping_fee": 0,
        "custom_formula_d6ae-ad02-be3d-b26e-3f65-d497-33c4": 1200000
      }
    },
    {
      "Time.day": "2020-07-30",
      "returned": null,
      "success": {
        "cod": 570000,
        "discount": 0,
        "order_count": 1,
        "price": 600000,
        "avg_price": 600000,
        "product_count": 6,
        "shipping_fee": 0,
        "custom_formula_d6ae-ad02-be3d-b26e-3f65-d497-33c4": 1200000
      }
    }
  ]
}

Danh sách công thức tùy chỉnh

GET/shops/{SHOP_ID}/analytics/get_list_formula

Lấy danh sách công thức tùy chỉnh

Tham số đường dẫn

SHOP_IDintegerbắt buộc

Mã shop

Ví dụ: 4

Phản hồi

object
dataarray<object>

Danh sách công thức tùy chỉnh

successboolean

Trạng thái thành công

Yêu cầu
curl "https://pos.pages.fm/api/v1/shops/{SHOP_ID}/analytics/get_list_formula?api_key=API_KEY"
Phản hồi 200
{
  "success": true,
  "data": [
    {
      "formula": "{price} - {shipping_fee}",
      "id": "0ea7-bc72-ae51-0769-a7c9-ca34-fff6",
      "name": "tien hang - phi ship",
      "unit": "currency"
    },
    {
      "formula": "{revenue} + {transfer_money}",
      "id": "3db3-72a7-c426-066a-4eed-a63b-be49",
      "name": "doanh thu + ck$",
      "unit": "currency"
    }
  ]
}

Danh sách số liệu mặc định

GET/shops/{SHOP_ID}/analytics/get_analytic_fields

Lấy danh sách số liệu mặc định

Tham số đường dẫn

SHOP_IDintegerbắt buộc

Mã shop

Ví dụ: 4

Phản hồi

object
dataarray<object>

Danh sách số liệu mặc định

successboolean

Trạng thái thành công

Yêu cầu
curl "https://pos.pages.fm/api/v1/shops/{SHOP_ID}/analytics/get_analytic_fields?api_key=API_KEY"
Phản hồi 200
{
  "success": true,
  "data": [
    {
      "id": "price",
      "name": "Tiền hàng"
    },
    {
      "id": "avg_price",
      "name": "Giá bán trung bình"
    },
    {
      "id": "shipping_fee",
      "name": "Phí VC thu của khách",
      "description": "Tiền vận chuyển thu của khách."
    },
    {
      "id": "discount",
      "name": "Chiết khấu",
      "description": "Tổng số tiền giảm giá trên từng sản phẩm."
    },
    {
      "id": "product_count",
      "name": "SL bán thực",
      "description": "Hàng bán ra đã trừ SL hoàn/đổi trả"
    },
    {
      "id": "close_rate",
      "name": "Tỷ lệ chốt",
      "description": "Số đơn chốt / (Tổng số đơn - SL đơn xoá)."
    },
    {
      "id": "commissions",
      "name": "Hoa hồng",
      "description": "Hoa hồng cho nhân viên, có thể cài đặt trong phần cấu hình."
    }
  ]
}

Danh sách thư mục báo cáo tùy chỉnh

GET/shops/{SHOP_ID}/statistic_custom/folders

Lấy danh sách thư mục báo cáo tùy chỉnh và các báo cáo bên trong (folder_items). Mỗi thư mục gom nhóm các báo cáo tùy chỉnh được cấu hình cho cửa hàng (ví dụ doanh thu, đơn hàng, sản phẩm, tài chính, công nợ).

Tham số đường dẫn

SHOP_IDintegerbắt buộc

Mã shop

Ví dụ: 4

Phản hồi

object
successboolean

Trạng thái thành công

foldersarray<object>

Danh sách thư mục báo cáo tùy chỉnh

Yêu cầu
curl "https://pos.pages.fm/api/v1/shops/{SHOP_ID}/statistic_custom/folders?api_key=API_KEY"
Phản hồi 200
{
  "success": true,
  "folders": [
    {
      "name": "OtherReports",
      "label": "Báo cáo khác",
      "order": -1,
      "shop_id": 4,
      "creator_id": null,
      "last_editor_id": null,
      "can_remove": false,
      "is_removed": null,
      "setting": null,
      "total_price_ranges": null,
      "inserted_at": "2024-02-26T08:21:01",
      "updated_at": "2024-02-26T08:21:01",
      "folder_items": [
        {
          "id": "9d80f8b9-1c68-4026-81e6-70ed2381d360",
          "name": "pages.shop.statistic.salesStatistics",
          "label": "Doanh số",
          "description": null,
          "folder_name": "employee",
          "parent_id": null,
          "order": 0,
          "shop_id": 4,
          "creator_id": null,
          "last_editor_id": null,
          "can_remove": false,
          "is_removed": null,
          "attributes": null,
          "fields": [
            "total_order_count",
            "order_count",
            "price",
            "shipping_fee",
            "discount",
            "capital",
            "product_count"
          ],
          "filter": null,
          "children": [],
          "charts": null,
          "compare_ranges": {
            "chart": "bar-chart",
            "field": "product_count",
            "ranges": [
              {
                "range": "7"
              },
              {
                "range": "-7"
              }
            ]
          },
          "fill_color": false,
          "setting": {
            "returned_record": "success_record",
            "success_record": "inserted_at",
            "success_status": 0,
            "user_type": "assign"
          },
          "sort_by_field": null,
          "time_range": [
            "90"
          ],
          "users_can_see": null,
          "inserted_at": "2024-02-26T08:21:01",
          "updated_at": "2024-02-26T08:21:01"
        }
      ]
    },
    {
      "name": "Revenue",
      "label": "Báo cáo doanh thu",
      "order": 1,
      "shop_id": 4,
      "creator_id": null,
      "last_editor_id": null,
      "can_remove": false,
      "is_removed": null,
      "setting": null,
      "total_price_ranges": null,
      "inserted_at": "2023-09-20T03:01:25",
      "updated_at": "2023-09-20T03:01:25",
      "folder_items": [
        {
          "id": "9783d2e9-d973-4f6f-a735-f5883f4e678f",
          "name": "commons.time",
          "label": "Thời gian",
          "description": null,
          "folder_name": "Revenue",
          "parent_id": null,
          "order": 0,
          "shop_id": 4,
          "creator_id": null,
          "last_editor_id": null,
          "can_remove": false,
          "is_removed": null,
          "attributes": [
            "Variation.product_id"
          ],
          "fields": [
            "success_order_count",
            "returned_order_count",
            "price",
            "sales",
            "revenue",
            "capital",
            "profit"
          ],
          "filter": [],
          "children": [],
          "charts": [
            {
              "field": "success_order_count",
              "top": "all",
              "type": "bar-chart",
              "width": 100
            }
          ],
          "compare_ranges": {
            "chart": "bar-chart",
            "field": "profit",
            "ranges": [
              {
                "range": "7"
              },
              {
                "range": "-7"
              }
            ]
          },
          "fill_color": false,
          "setting": {
            "returned_record": "success_record",
            "success_record": "updated_at",
            "success_status": 1,
            "user_type": "update"
          },
          "sort_by_field": {
            "multi": [
              {
                "columnKey": "product_count",
                "field": "product_count",
                "order": "descend"
              }
            ]
          },
          "time_range": [
            "30"
          ],
          "users_can_see": null,
          "inserted_at": "2023-09-20T03:01:25",
          "updated_at": "2026-05-05T04:33:58"
        }
      ]
    }
  ]
}