OVIRO LogoOVIRO
OMSĐơn hàng

Tạo đơn hàng

Tạo đơn hàng mới từ nội bộ hệ thống

Tạo đơn hàng an toàn với flow checkout của API /v1/customercarts

Nếu muốn tạo đơn hàng một cách an toàn, tự động áp dụng cơ chế khuyến mãi cho chi tiết, cho giỏ hàng...thì nên gọi api checkout của customercarts (/v1/customercarts/checkout). Đây là API được sử dụng bởi màn hình POS để tạo đơn hàng.

Tạo đơn hàng mới

Để gọi API này, bạn phải tính toán trước toàn bộ thông tin đơn hàng. Bao gồm: chi tiết đơn hàng, kết quả tính toán của khuyến mãi, giá bán...API này hiện được gọi nội bộ từ flow checkout của customercarts.

Endpoint

POST /v1/orders

Request Payload

JSON Object Payload:

{
  "company_id": 10311,
  "customer_id": 101,
  "id": 0,
  "source": 1,
  "source_name": "",
  "external_id": "",
  "uuid": "3b733736-2278-42d1-8c2f-31d5cef7cd81",
  "store_id": 32,
  "pickup_store_id": 0,
  "billing_full_name": "Hoàng Văn Hải",
  "billing_phone": "0909876543",
  "billing_email": "",
  "billing_address": "15 Trần Phú",
  "billing_region_id": 88831,
  "billing_sub_region_id": 88810507,
  "billing_sub_sub_region_id": 88811332,
  "shipping_type": 3,
  "shipping_address_id": 0,
  "shipping_full_name": "Hoàng Văn Hải",
  "shipping_phone": "0909876543",
  "shipping_email": "",
  "shipping_address": "15 Trần Phú",
  "shipping_region_id": 88831,
  "shipping_sub_region_id": 88810507,
  "shipping_sub_sub_region_id": 88811332,
  "shipping_address_line_2": "",
  "shipping_instruction": "",
  "shipping_legacy_province_name": "",
  "shipping_legacy_district_name": "",
  "shipping_legacy_ward_name": "",
  "shipping_carrier_id": 23,
  "warehouse_id": 33,
  "payment_method": 11,
  "payment_status": 1,
  "note": "",
  "coupon_code": "",
  "tax_name": "",
  "tax_is_company": 0,
  "tax_code": "",
  "tax_address": "",
  "tax_email": "",
  "price_sell": 1963600,
  "price_shipping": 20000,
  "price_discount_order": 98180,
  "price_discount_shipping": 12000,
  "price_discount_coupon": 0,
  "price_discount": 110180,
  "price_final": 1873420,
  "status": 0,
  "ip_address": "14.169.18.81",
  "date_created": 0,
  "date_modified": 0,
  "details": [
    {
      "row_identifier": "486_948_1000_0",
      "product_id": 486,
      "product_variant_id": 948,
      "uom_id": 1000,
      "uom_name": "Cái",
      "uom_factor": 1,
      "uom_quantity": 3,
      "uom_unit_price": 479200,
      "uom_unit_price_original": 599000,
      "selected_options": null,
      "type": 1,
      "sku": "2397540229784",
      "item_type": 1,
      "item_name": "PUMA - Áo khoác nam thể thao cổ trụ phối zip Fit Woven Half Zip Training 522129",
      "item_serial_number": "",
      "item_weight": 400,
      "customize_required": 0,
      "customize_description": "",
      "file_id_list": [],
      "bundle_identifier": "",
      "bundle_promotion_id": 0,
      "bundle_promotion_product_id": 0,
      "bundle_promotion_multiplier": 0,
      "bundle_index": 0,
      "bundle_allocation_rule": "",
      "bundle_discount_allocated": 0,
      "bundle_promotion_name": "",
      "bundle_promotion_type": 0
    }
  ],
  "promotionengine": {
    "order_promotion_decision": {
      "applied": [],
      "rejected": [],
      "eligible": []
    },
    "shipping_promotion_decision": {
      "applied": [],
      "rejected": [],
      "eligible": []
    },
    "coupon_promotion_decision": {
      "applied": [],
      "rejected": [],
      "eligible": []
    }
  },
  "creator_id": 1,
  "price_policy_id": 1,
  "tag": "",
  "file_id_list": [],
  "weight": 2700,
  "quantity": 7
}

Response Schema

HTTP 201 - JSON Object

Xem Order Object Schema

Error Codes

HTTPCodeMô tả
422error_not_permissionKhông có quyền tạo đơn hàng tại cửa hàng này
422error_order_with_uuid_existedUUID đã tồn tại trong hệ thống
422error_shipping_type_requiredLoại vận chuyển không hợp lệ
422error_pickup_store_requiredCửa hàng nhận hàng bắt buộc cho loại pickup
422error_pickup_store_not_existCửa hàng nhận hàng không tồn tại
422error_shift_not_existCa làm việc không tồn tại
422error_warehouse_invalidKho hàng không hợp lệ
422error_order_detail_not_foundKhông có chi tiết sản phẩm trong đơn hàng
422error_setting_fetch_errorLỗi lấy cấu hình công ty
422error_customer_id_not_foundKhách hàng không tồn tại
422error_promotion_object_invalidKhuyến mãi không hợp lệ
422error_promotion_type_coupon_invalidLoại khuyến mãi coupon không hợp lệ
422error_parse_apply_promotion_for_order_on_serverLỗi xử lý khuyến mãi trên server
422error_check_apply_promotion_for_order_on_serverLỗi kiểm tra áp dụng khuyến mãi
422error_shipping_full_name_requiredTên người nhận bắt buộc cho giao hàng
422error_shipping_phone_requiredSố điện thoại người nhận bắt buộc cho giao hàng
422error_shipping_address_requiredĐịa chỉ giao hàng bắt buộc
422error_shipping_region_requiredVùng giao hàng bắt buộc
422error_shipping_region_id_not_existVùng giao hàng không tồn tại
422error_shipping_sub_region_id_not_existQuận/huyện giao hàng không tồn tại
422error_shipping_sub_sub_region_id_not_existPhường/xã giao hàng không tồn tại
422error_billing_region_id_not_existVùng thanh toán không tồn tại
422error_billing_sub_region_id_not_existQuận/huyện thanh toán không tồn tại
422error_billing_sub_sub_region_id_not_existPhường/xã thanh toán không tồn tại
422error_add_order_details_failedKhông thể thêm chi tiết sản phẩm
500error_system_errorLỗi hệ thống trong quá trình lưu đơn
409ERR_DUPLICATE_ORDERMã đơn bị trùng

On this page