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
Error Codes
| HTTP | Code | Mô tả |
|---|---|---|
| 422 | error_not_permission | Không có quyền tạo đơn hàng tại cửa hàng này |
| 422 | error_order_with_uuid_existed | UUID đã tồn tại trong hệ thống |
| 422 | error_shipping_type_required | Loại vận chuyển không hợp lệ |
| 422 | error_pickup_store_required | Cửa hàng nhận hàng bắt buộc cho loại pickup |
| 422 | error_pickup_store_not_exist | Cửa hàng nhận hàng không tồn tại |
| 422 | error_shift_not_exist | Ca làm việc không tồn tại |
| 422 | error_warehouse_invalid | Kho hàng không hợp lệ |
| 422 | error_order_detail_not_found | Không có chi tiết sản phẩm trong đơn hàng |
| 422 | error_setting_fetch_error | Lỗi lấy cấu hình công ty |
| 422 | error_customer_id_not_found | Khách hàng không tồn tại |
| 422 | error_promotion_object_invalid | Khuyến mãi không hợp lệ |
| 422 | error_promotion_type_coupon_invalid | Loại khuyến mãi coupon không hợp lệ |
| 422 | error_parse_apply_promotion_for_order_on_server | Lỗi xử lý khuyến mãi trên server |
| 422 | error_check_apply_promotion_for_order_on_server | Lỗi kiểm tra áp dụng khuyến mãi |
| 422 | error_shipping_full_name_required | Tên người nhận bắt buộc cho giao hàng |
| 422 | error_shipping_phone_required | Số điện thoại người nhận bắt buộc cho giao hàng |
| 422 | error_shipping_address_required | Địa chỉ giao hàng bắt buộc |
| 422 | error_shipping_region_required | Vùng giao hàng bắt buộc |
| 422 | error_shipping_region_id_not_exist | Vùng giao hàng không tồn tại |
| 422 | error_shipping_sub_region_id_not_exist | Quận/huyện giao hàng không tồn tại |
| 422 | error_shipping_sub_sub_region_id_not_exist | Phường/xã giao hàng không tồn tại |
| 422 | error_billing_region_id_not_exist | Vùng thanh toán không tồn tại |
| 422 | error_billing_sub_region_id_not_exist | Quận/huyện thanh toán không tồn tại |
| 422 | error_billing_sub_sub_region_id_not_exist | Phường/xã thanh toán không tồn tại |
| 422 | error_add_order_details_failed | Không thể thêm chi tiết sản phẩm |
| 500 | error_system_error | Lỗi hệ thống trong quá trình lưu đơn |
| 409 | ERR_DUPLICATE_ORDER | Mã đơn bị trùng |