Categories

Quản lý nhóm khách hàng

GET /customer-cats

Lấy danh sách nhóm khách hàng. Quyền: customer.category.view_list

Fields

Field Type Description Required
name NO
is_default NO
action NO

Request

Headers

Header Value
Accept
application/vnd.customers.v1+json
application/hal+json
application/json
Authorization HTTP Basic, HTTP Digest, or OAuth2 Bearer token (check API provider for details)

Response

Status Codes

  • 406: Not Acceptable
  • 415: Unsupported Media Type
  • 200: OK
  • 401: Unauthorized
  • 403: Forbidden

Headers

Header Value
Content-Type
application/vnd.customers.v1+json
application/hal+json
application/json
Allow Comma-separated list of all HTTP methods allowed

Body

{
    "_embedded": {
        "categories": [
            {
                "id",
                "name",
                "is_default"
            },
            ...
        ]
    }
}

POST /customer-cats

Tạo nhóm khách hàng mới. Quyền: customer.category.create

Fields

Field Type Description Required
name NO
is_default NO
action NO

Request

Headers

Header Value
Accept
application/vnd.customers.v1+json
application/hal+json
application/json
Content-Type
application/vnd.customers.v1+json
application/json
Authorization HTTP Basic, HTTP Digest, or OAuth2 Bearer token (check API provider for details)

Body

{
   "name" //Tên nhóm. Required
}

Response

Status Codes

  • 406: Not Acceptable
  • 415: Unsupported Media Type
  • 201: Created
  • 400: Client Error
  • 422: Unprocessable Entity
  • 401: Unauthorized
  • 403: Forbidden

Headers

Header Value
Content-Type
application/vnd.customers.v1+json
application/hal+json
application/json
Allow Comma-separated list of all HTTP methods allowed

Body

//SUCCESS
{"result":"SUCCESS"}

//ERROR
- ERROR: Lỗi lưu trữ

PUT /customer-cats[/:cat_id]

Chỉnh sửa thông tin nhóm khách hàng. - Sửa tên nhóm. Quyền: customer.category.edit_name - Sửa trạng thái mặc định. Quyền: customer.category.edit_is_default

Fields

Field Type Description Required
name NO
is_default NO
action NO

Request

Headers

Header Value
Accept
application/vnd.customers.v1+json
application/hal+json
application/json
Content-Type
application/vnd.customers.v1+json
application/json
Authorization HTTP Basic, HTTP Digest, or OAuth2 Bearer token (check API provider for details)

Body

{
   "action": "editName | editIsDefault",
   "name", //Với action editName. Required
   "is_default": "Y|N" //Với action editIsDefault. Required
}

Response

Status Codes

  • 406: Not Acceptable
  • 415: Unsupported Media Type
  • 200: OK
  • 404: Not Found
  • 400: Client Error
  • 422: Unprocessable Entity
  • 401: Unauthorized
  • 403: Forbidden

Headers

Header Value
Content-Type
application/vnd.customers.v1+json
application/hal+json
application/json
Allow Comma-separated list of all HTTP methods allowed

Body

//SUCCESS
{"result":"SUCCESS"}

//ERROR
- NOT_FOUND_CATEGORY: Không tìm thấy nhóm KH.
- CANNOT_UNSET_DEFAULT_CATEGORY: Không thể bỏ trạng thái mặc định.
- ERROR: Lỗi khác.

DELETE /customer-cats[/:cat_id]

Xóa nhóm khách hàng. Quyền: customer.category.delete

Fields

Field Type Description Required
name NO
is_default NO
action NO

Request

Headers

Header Value
Accept
application/vnd.customers.v1+json
application/hal+json
application/json
Authorization HTTP Basic, HTTP Digest, or OAuth2 Bearer token (check API provider for details)

Response

Status Codes

  • 406: Not Acceptable
  • 415: Unsupported Media Type
  • 204: No Content
  • 404: Not Found
  • 401: Unauthorized
  • 403: Forbidden

Headers

Header Value
Content-Type
application/vnd.customers.v1+json
application/hal+json
application/json
Allow Comma-separated list of all HTTP methods allowed

Customers

Quản lý tài khoản khách hàng

GET /customers

  1. Lấy danh sách khách hàng:

- Để lấy theo mã vạch, truyền param: card=[param]; - Để lọc theo mã KH, tên KH, SDT, truyền các param: taxid=[taxid]&name=[name]&phone=[phone] - Truyền param visible=Y để lọc KH visible - Order: loyal_score, curdebt, curdate 2. Lấy lich sử điểm tích lũy khách hàng: truyền param view_score_history=Y&customer_id=[customer_id]

Fields

Field Type Description Required
action NO
name NO
taxid NO
searchkey NO
card NO
category NO
loyal_category NO
visible NO
transaction_type NO
ticketid NO
score

Giá trị âm: số điểm cần thanh toán. Giá trị dương: Số điểm tích lũy thêm.

NO
score_content NO
maxdebt NO
phone NO
region

Tỉnh/Thành Phố

NO
city

Quận\Huyện

NO
address

Địa chỉ

NO
notes NO

Request

Headers

Header Value
Accept
application/vnd.customers.v1+json
application/hal+json
application/json
Authorization HTTP Basic, HTTP Digest, or OAuth2 Bearer token (check API provider for details)

Response

Status Codes

  • 406: Not Acceptable
  • 415: Unsupported Media Type
  • 200: OK
  • 401: Unauthorized
  • 403: Forbidden

Headers

Header Value
Content-Type
application/vnd.customers.v1+json
application/hal+json
application/json
Allow Comma-separated list of all HTTP methods allowed

Body

1. Danh sách customer
{
   "_embedded": {
       "customers": [
           {
               "id", //Id KH
               "taxid", // Mã KH
               "name", // Tên KH
               "category_name", // Tên nhóm KH
               "loyal_cat_name", // Tên nhóm KHTT
               "loyal_score", // điểm KHTT
               "curdebt", // Nợ hiện tại
               "curdate", // Ngày nợ
               "address", //Địa chỉ
               "city", // Huyện
               "region", // Tỉnh
               "visible": "Y|N"
           },
           ...
       ]
   }
}
2. Lich sử điểm:
"_embedded": {
        "customers": [
            {
                "id",
                "admin_name", //Người thực hiện
                "score_transaction", //Điểm giao dịch
                "content", //Nội dung
                "date", //Thời gian
            },
            ...
        ]
}

POST /customers

Tạo tài khoản khách hàng

Fields

Field Type Description Required
action NO
name NO
taxid NO
searchkey NO
card NO
category NO
loyal_category NO
visible NO
transaction_type NO
ticketid NO
score

Giá trị âm: số điểm cần thanh toán. Giá trị dương: Số điểm tích lũy thêm.

NO
score_content NO
maxdebt NO
phone NO
region

Tỉnh/Thành Phố

NO
city

Quận\Huyện

NO
address

Địa chỉ

NO
notes NO

Request

Headers

Header Value
Accept
application/vnd.customers.v1+json
application/hal+json
application/json
Content-Type
application/vnd.customers.v1+json
application/json

Body

{

   "name", //required
   "phone", //required
   "region", //Tỉnh/Thành Phố
   "city", //Quận/Huyện
   "address": //Địa chỉ
}

Response

Status Codes

  • 406: Not Acceptable
  • 415: Unsupported Media Type
  • 201: Created
  • 400: Client Error
  • 422: Unprocessable Entity

Headers

Header Value
Content-Type
application/vnd.customers.v1+json
application/hal+json
application/json
Allow Comma-separated list of all HTTP methods allowed

Body

//result SUCCESS
{
    "result": "SUCCESS",
    "customer": {
        "id",
        "searchkey",
        "taxid",
        "name",
        "taxcategory",
        "taxcustloyalcategory",
        "address",
        "city",
        "region",
        "phone"
    }
}

//Các lỗi xảy ra:
- EXIST_PHONE: SDT đã tồn tại
- ERROR: Lỗi khác

GET /customers[/:customer_id]

Lấy thông tin chi tiết của khách hàng

Fields

Field Type Description Required
action NO
name NO
taxid NO
searchkey NO
card NO
category NO
loyal_category NO
visible NO
transaction_type NO
ticketid NO
score

Giá trị âm: số điểm cần thanh toán. Giá trị dương: Số điểm tích lũy thêm.

NO
score_content NO
maxdebt NO
phone NO
region

Tỉnh/Thành Phố

NO
city

Quận\Huyện

NO
address

Địa chỉ

NO
notes NO

Request

Headers

Header Value
Accept
application/vnd.customers.v1+json
application/hal+json
application/json
Authorization HTTP Basic, HTTP Digest, or OAuth2 Bearer token (check API provider for details)

Response

Status Codes

  • 406: Not Acceptable
  • 415: Unsupported Media Type
  • 200: OK
  • 404: Not Found
  • 401: Unauthorized
  • 403: Forbidden

Headers

Header Value
Content-Type
application/vnd.customers.v1+json
application/hal+json
application/json
Allow Comma-separated list of all HTTP methods allowed

Body

{
    "result": "SUCCESS",
    "customer": {
        "id",
        "searchkey", // Từ khóa
        "taxid", // Mã số thuế
        "name",
        "card", // Mã thẻ
        "category_id", // Id nhóm KH
        "category_name", // Tên nhóm KH
        "loyal_cat_id", // Id nhóm KHTT
        "loyal_cat_name", // Tên nhóm KHTT
        "loyal_score", // Điểm KHTT
        "maxdebt", // Nợ tối đa
        "curdebt", // Nợ hiện tại
        "curdate", // Ngày GD nợ gần nhất
        "address", // Địa chỉ
        "city", // Quận/Huyện
        "region", // Tỉnh/Thành Phố
        "visible": "Y|N", // HIển thị
        "phone" // SDT,
        "notes"
    }
}
Lỗi có thể xảy ra: NOT_FOUND_CUSTOMER

PUT /customers[/:customer_id]

Chỉnh sửa các thông tin khách hàng:

Fields

Field Type Description Required
action NO
name NO
taxid NO
searchkey NO
card NO
category NO
loyal_category NO
visible NO
transaction_type NO
ticketid NO
score

Giá trị âm: số điểm cần thanh toán. Giá trị dương: Số điểm tích lũy thêm.

NO
score_content NO
maxdebt NO
phone NO
region

Tỉnh/Thành Phố

NO
city

Quận\Huyện

NO
address

Địa chỉ

NO
notes NO

Request

Headers

Header Value
Accept
application/vnd.customers.v1+json
application/hal+json
application/json
Content-Type
application/vnd.customers.v1+json
application/json
Authorization HTTP Basic, HTTP Digest, or OAuth2 Bearer token (check API provider for details)

Body

{
   "action": "editName | editCode | editCategory | editLoyalCategory | editVisible | editScore | editMaxDebt | editPhone | editAddress | editNotes",
   "name", // Với action editName
   "taxid", // Với action editCode
   "searchkey", // Với action editCode
   "card", // Với action editCode. Not required
   "category", //Với action editCategory. Not required
   "loyal_category", //Với action editLoyalCategory. Not required
   "visible": "Y|N", // Với action editVisible
   "transaction_type": "accumulate | exchange", //Với action eidtScore
    "ticketid", //id hóa đơn. Với action eidtScore
   "score", // Với action eidtScore. 
   "score_content", // Với action eidtScore
   "maxdebt", // Với action editMaxDebt
   "phone", // Với action editPhone
   "region", // Với action editAddress. Not required
   "city", // Với action editAddress. Not required
   "address" // Với action editAddress. Not required
   "notes" // Với action editNotes. Not required
}

Response

Status Codes

  • 406: Not Acceptable
  • 415: Unsupported Media Type
  • 200: OK
  • 404: Not Found
  • 400: Client Error
  • 422: Unprocessable Entity
  • 401: Unauthorized
  • 403: Forbidden

Headers

Header Value
Content-Type
application/vnd.customers.v1+json
application/hal+json
application/json
Allow Comma-separated list of all HTTP methods allowed

Body

//SUCCESS
{"result":"SUCCESS"}

//ERROR
- NOT_FOUND_CUSTOMER: Không tìm thấy customer
- ERROR: Lỗi khác
- NOT_ENOUGH_SCORE: ĐTL hiện tại không đủ thanh toán. //action editScore
- NOT_FOUND_TICKET: Không tìm thấy ticket. //action editScore
- EXIST_PHONE: SDT đã tồn tại ở tài khoản KH khác. //action editPhone

DELETE /customers[/:customer_id]

Xóa tài khoản khách hàng. Quyền: customer.delete

Fields

Field Type Description Required
action NO
name NO
taxid NO
searchkey NO
card NO
category NO
loyal_category NO
visible NO
transaction_type NO
ticketid NO
score

Giá trị âm: số điểm cần thanh toán. Giá trị dương: Số điểm tích lũy thêm.

NO
score_content NO
maxdebt NO
phone NO
region

Tỉnh/Thành Phố

NO
city

Quận\Huyện

NO
address

Địa chỉ

NO
notes NO

Request

Headers

Header Value
Accept
application/vnd.customers.v1+json
application/hal+json
application/json
Authorization HTTP Basic, HTTP Digest, or OAuth2 Bearer token (check API provider for details)

Response

Status Codes

  • 406: Not Acceptable
  • 415: Unsupported Media Type
  • 204: No Content
  • 404: Not Found
  • 401: Unauthorized
  • 403: Forbidden

Headers

Header Value
Content-Type
application/vnd.customers.v1+json
application/hal+json
application/json
Allow Comma-separated list of all HTTP methods allowed

LoyalCategories

GET /customer-loyal-cats[/:cat_id]

Lấy danh sách nhóm KHTT

Request

Headers

Header Value
Accept
application/vnd.customers.v1+json
application/hal+json
application/json
Authorization HTTP Basic, HTTP Digest, or OAuth2 Bearer token (check API provider for details)

Response

Status Codes

  • 406: Not Acceptable
  • 415: Unsupported Media Type
  • 200: OK
  • 401: Unauthorized
  • 403: Forbidden

Headers

Header Value
Content-Type
application/vnd.customers.v1+json
application/hal+json
application/json
Allow Comma-separated list of all HTTP methods allowed

Body

{
    "_embedded": {
        "categories": [
            {
                "id",
                "name",
            },
            ...
        ]
    }
}

WarrantyInfo

Quản lý thông tin bảo hành sản phẩm.

GET /warranty-info

  1. Lấy danh sách thông tin bảo hành. Quyền: customer.warranty_info.view_list Các tham số (query params) để lọc và sắp xếp:

- search_product: Tìm theo tên, mã, model, serial sản phẩm. - search_customer: Tìm theo tên, mã khách hàng. - search_ticket: Tìm theo ID hóa đơn. - is_active: "Y" hoặc "N" để lọc theo trạng thái còn bảo hành. - order: Sắp xếp theo các cột: "product_name", "cust_name", "ticketid", "active_date", "expired_date", "person_name", "created_at". - dir: "asc" hoặc "desc". 2. Lấy lịch sử thay đổi của một thông tin bảo hành. Truyền các tham số: view_history=Ywarranty_id=[UUID của thông tin bảo hành].

Fields

Field Type Description Required
ticketid NO
cust_id NO
cust_phone NO
product_id NO
image NO
model NO
serial_num NO
private_code NO
time_warranty NO
active_date NO
expired_date NO
note NO
action NO
status NO

Request

Headers

Header Value
Accept
application/vnd.customers.v1+json
application/hal+json
application/json
Authorization HTTP Basic, HTTP Digest, or OAuth2 Bearer token (check API provider for details)

Response

Status Codes

  • 406: Not Acceptable
  • 415: Unsupported Media Type
  • 200: OK
  • 401: Unauthorized
  • 403: Forbidden

Headers

Header Value
Content-Type
application/vnd.customers.v1+json
application/hal+json
application/json
Allow Comma-separated list of all HTTP methods allowed

Body

1. Danh sách thông tin bảo hành:
{
    "_embedded": {
        "warranty_info": [
            {
                "id", // uuid
                "product_id",
                "product_name",
                "model",
                "serial_num",
                "private_code",
                "image", // URL ảnh
                "cust_id",
                "cust_name",
                "cust_phone",
                "ticketid",
                "time_warranty",
                "active_date",
                "expired_date",
                "status": "Y|N",
                "note",
                "person_id",
                "person_name",
                "created_at"
            },
            ...
        ]
    }
}

2. Lịch sử thay đổi:
{
    "_embedded": {
        "warranty_info": [
            {
                "id", // uuid của lịch sử
                "person_name", // Tên người thực hiện
                "date", // Thời gian
                "log" // Nội dung thay đổi
            }
        ]
    }
}

POST /warranty-info

Tạo một thông tin bảo hành mới. Quyền: customer.warranty_info.create

Fields

Field Type Description Required
ticketid NO
cust_id NO
cust_phone NO
product_id NO
image NO
model NO
serial_num NO
private_code NO
time_warranty NO
active_date NO
expired_date NO
note NO
action NO
status NO

Request

Headers

Header Value
Accept
application/vnd.customers.v1+json
application/hal+json
application/json
Content-Type
application/vnd.customers.v1+json
application/json
Authorization HTTP Basic, HTTP Digest, or OAuth2 Bearer token (check API provider for details)

Body

{
    "ticketid": "string", // ID hóa đơn. Required.
    "cust_id": "string", // ID khách hàng. Required.
    "cust_phone": "string", // SĐT khách hàng. Required.
    "product_id": "string", // ID sản phẩm. Required.
    "image": "string", // Ảnh sản phẩm (base64). Optional.
    "model": "string", // Model sản phẩm. Optional.
    "serial_num": "string", // Số serial. Optional.
    "private_code": "string", // Mã an ninh. Optional.
    "time_warranty": "int", // Thời gian bảo hành (tháng). Optional.
    "active_date": "Y-m-d", // Ngày kích hoạt. Optional.
    "expired_date": "Y-m-d", // Ngày hết hạn. Optional.
    "note": "string" // Ghi chú. Optional.
}

Response

Status Codes

  • 406: Not Acceptable
  • 415: Unsupported Media Type
  • 201: Created
  • 400: Client Error
  • 422: Unprocessable Entity
  • 401: Unauthorized
  • 403: Forbidden

Headers

Header Value
Content-Type
application/vnd.customers.v1+json
application/hal+json
application/json
Allow Comma-separated list of all HTTP methods allowed

Body

//SUCCESS
{"result":"SUCCESS"}

//ERROR
- 403 Forbidden: Không có quyền.
- 422 Unprocessable Entity: Thiếu các trường bắt buộc.
- TICKET_PRODUCT_NOT_FOUND: Không tìm thấy sản phẩm trong hóa đơn.
- SERIAL_NUMBER_EXISTS: Số serial đã tồn tại.
- CUSTOMER_NOT_FOUND: Không tìm thấy khách hàng.
- ERROR_UPLOAD_IMAGE: Lỗi tải ảnh lên.
- ERROR: Lỗi hệ thống khác.

PUT /warranty-info[/:warranty_id]

Cập nhật thông tin bảo hành theo action. - editProduct: Sửa thông tin sản phẩm. Quyền: customer.warranty_info.edit_product. - editCustomer: Sửa thông tin khách hàng. Quyền: customer.warranty_info.edit_customer. - editStatus: Sửa trạng thái bảo hành. Quyền: customer.warranty_info.edit_status. - editNote: Sửa ghi chú. Quyền: customer.warranty_info.edit_note.

Fields

Field Type Description Required
ticketid NO
cust_id NO
cust_phone NO
product_id NO
image NO
model NO
serial_num NO
private_code NO
time_warranty NO
active_date NO
expired_date NO
note NO
action NO
status NO

Request

Headers

Header Value
Accept
application/vnd.customers.v1+json
application/hal+json
application/json
Content-Type
application/vnd.customers.v1+json
application/json
Authorization HTTP Basic, HTTP Digest, or OAuth2 Bearer token (check API provider for details)

Body

{
    "action": "editProduct | editCustomer | editStatus | editNote",
    // Các trường dữ liệu tương ứng với từng action:
    // - action="editProduct": ticketid (req), product_id (req), model, serial_num, private_code, image.
    // - action="editCustomer": cust_id (req), cust_phone (req).
    // - action="editStatus": status (req), time_warranty, active_date, expired_date.
    // - action="editNote": note.
}

Response

Status Codes

  • 406: Not Acceptable
  • 415: Unsupported Media Type
  • 200: OK
  • 404: Not Found
  • 400: Client Error
  • 422: Unprocessable Entity
  • 401: Unauthorized
  • 403: Forbidden

Headers

Header Value
Content-Type
application/vnd.customers.v1+json
application/hal+json
application/json
Allow Comma-separated list of all HTTP methods allowed

Body

//SUCCESS
{"result":"SUCCESS"}

//ERROR
- 403 Forbidden: Không có quyền.
- 422 Unprocessable Entity: Thiếu các trường bắt buộc cho action.
- WARRANTY_INFO_NOT_FOUND: Không tìm thấy thông tin bảo hành.
- TICKET_PRODUCT_NOT_FOUND: Không tìm thấy sản phẩm trong hóa đơn (với action=editProduct).
- SERIAL_NUMBER_EXISTS: Số serial đã tồn tại (với action=editProduct).
- CUSTOMER_NOT_FOUND: Không tìm thấy khách hàng (với action=editCustomer).
- ERROR_DELETE_IMAGE, ERROR_UPLOAD_IMAGE, ERROR_UPDATE_IMAGE: Lỗi xử lý ảnh.
- ERROR: Lỗi hệ thống khác.

DELETE /warranty-info[/:warranty_id]

Xóa một thông tin bảo hành. Quyền: customer.warranty_info.delete

Fields

Field Type Description Required
ticketid NO
cust_id NO
cust_phone NO
product_id NO
image NO
model NO
serial_num NO
private_code NO
time_warranty NO
active_date NO
expired_date NO
note NO
action NO
status NO

Request

Headers

Header Value
Accept
application/vnd.customers.v1+json
application/hal+json
application/json
Authorization HTTP Basic, HTTP Digest, or OAuth2 Bearer token (check API provider for details)

Response

Status Codes

  • 406: Not Acceptable
  • 415: Unsupported Media Type
  • 204: No Content
  • 404: Not Found
  • 401: Unauthorized
  • 403: Forbidden

Headers

Header Value
Content-Type
application/vnd.customers.v1+json
application/hal+json
application/json
Allow Comma-separated list of all HTTP methods allowed

WarrantyStatus

Quản lý phiếu bảo hành.

GET /warranty-status

  1. Lấy danh sách phiếu bảo hành. Quyền: customer.warranty_status.view_list

Các tham số lọc: - product_name: Tên sản phẩm. - product_reference: Mã sản phẩm. - customer_name: Tên khách hàng. - customer_phone: SĐT khách hàng. - cust_received_date: Ngày nhận từ KH. - cust_return_date: Ngày trả KH. - receiver: Người xử lý. - location: ID kho. - supplier_name: Tên NCC. - supplier_send_date: Ngày gửi NCC. - supplier_return_date: Ngày nhận từ NCC. - warranty_type: Loại bảo hành. - status: Trạng thái (pending, send, receive, success). - start_date, end_date: Lọc theo ngày tạo. - order: Sắp xếp (product_name, customer_name, cust_received_date, cust_return_date, supplier_name, supplier_send_date, supplier_return_date, location_name). - dir: asc/desc.

  1. Lấy lịch sử phiếu bảo hành.

- view_history=Y - warranty_id=[UUID]

Fields

Field Type Description Required
products NO
receiver NO
location NO
warranty_type NO
customer_name NO
customer_phone NO
customer_address NO
action NO
product_name NO
product_qty NO
product_status NO
product_img NO
supplier_name NO
note NO
cust_received_date NO
supplier_send_date NO
status NO
repair_cost NO
warranty_expenses NO
progress_note_text NO
progress_note_img NO
other_cost NO

Request

Headers

Header Value
Accept
application/vnd.customers.v1+json
application/hal+json
application/json
Authorization HTTP Basic, HTTP Digest, or OAuth2 Bearer token (check API provider for details)

Response

Status Codes

  • 406: Not Acceptable
  • 415: Unsupported Media Type
  • 200: OK
  • 401: Unauthorized
  • 403: Forbidden

Headers

Header Value
Content-Type
application/vnd.customers.v1+json
application/hal+json
application/json
Allow Comma-separated list of all HTTP methods allowed

Body

1. Danh sách phiếu bảo hành:
{
    "_embedded": {
        "warranty_status": [
            {
                "id", // uuid
                "reference",
                "product_name",
                "product_status",
                "product_qty",
                "product_img", // Array URL
                "customer_name",
                "customer_phone",
                "customer_address",
                "person_name", // Người tạo
                "receiver", // Người xử lý
                "location_id", // ID kho
                "location_name", // Tên kho
                "cust_received_date", // Ngày nhận từ khách hàng
                "cust_return_date", // Ngày trả khách hàng
                "repair_cost", // Chi phí sửa chữa
                "other_cost", // Số hóa đơn thu tiền
                "supplier_name", // Tên NCC
                "supplier_send_date", // Ngày gửi NCC
                "supplier_return_date", // Ngày nhận từ NCC
                "warranty_expenses", // Chi phí bảo hành
                "warranty_type", // Loại bảo hành
                "note", // Ghi chú
                "failure_reason", // Nội dung đánh dấu phiếu
                "status", // Trạng thái
                "created_at" // Ngày tạo
            },
            ...
        ]
    }
}

2. Lịch sử:
{
    "_embedded": {
        "warranty_status": [
            {
                "id",
                "person_name",
                "date",
                "log"
            }
        ]
    }
}

POST /warranty-status

Tạo phiếu bảo hành mới. Quyền: customer.warranty_status.create

Fields

Field Type Description Required
products NO
receiver NO
location NO
warranty_type NO
customer_name NO
customer_phone NO
customer_address NO
action NO
product_name NO
product_qty NO
product_status NO
product_img NO
supplier_name NO
note NO
cust_received_date NO
supplier_send_date NO
status NO
repair_cost NO
warranty_expenses NO
progress_note_text NO
progress_note_img NO
other_cost NO

Request

Headers

Header Value
Accept
application/vnd.customers.v1+json
application/hal+json
application/json
Content-Type
application/vnd.customers.v1+json
application/json
Authorization HTTP Basic, HTTP Digest, or OAuth2 Bearer token (check API provider for details)

Body

{
    "products": [ // Required. Danh sách sản phẩm bảo hành (JSON string)
        {
            "product_name": "string", // Required. Tên sản phẩm
            "product_qty": "int", // Required. Số lượng sản phẩm
            "product_status": "string", // Required. Tình trạng sản phẩm
            "product_img": "string", // Optional. JSON string chứa mảng base64 ảnh
            "supplier_name": "string", // Optional. Tên NCC
            "note": "string" // Optional. Ghi chú
        }
    ],
    "receiver": "string", // Required. Người xử lý
    "location": "string", // Required. ID kho hàng
    "warranty_type": "string", // Optional. Loại bảo hành: `customer` || `company`
    "customer_name": "string", // Optional. Tên khách hàng
    "customer_phone": "string", // Optional. SĐT khách hàng
    "customer_address": "string" // Optional. Địa chỉ khách hàng
}

Response

Status Codes

  • 406: Not Acceptable
  • 415: Unsupported Media Type
  • 201: Created
  • 400: Client Error
  • 422: Unprocessable Entity
  • 401: Unauthorized
  • 403: Forbidden

Headers

Header Value
Content-Type
application/vnd.customers.v1+json
application/hal+json
application/json
Allow Comma-separated list of all HTTP methods allowed

Body

//SUCCESS
{"result":"SUCCESS"}

//ERROR
- 403 Forbidden: Không có quyền.
- 422 Unprocessable Entity: Thiếu trường bắt buộc (products, product_name, product_qty, product_status).
- ERROR_UPLOAD_IMAGE: Lỗi upload ảnh.
- ERROR: Lỗi hệ thống.

PUT /warranty-status[/:warranty_id]

Cập nhật thông tin phiếu bảo hành theo action.

  1. editProduct: Sửa thông tin sản phẩm. Quyền: customer.warranty_status.edit_product.
    • Params: product_name (req), product_qty (req), product_status, product_img (JSON string base64), supplier_name, note.
  2. editCustomer: Sửa thông tin khách hàng. Quyền: customer.warranty_status.edit_customer.
    • Params: customer_name (req), customer_phone, customer_address.
  3. editReceiveDate: Sửa ngày nhận. Quyền: customer.warranty_status.edit_receive_date.
    • Params: cust_received_date (req).
  4. editSupplier: Sửa NCC. Quyền: customer.warranty_status.edit_supplier.
    • Params: supplier_name (req).
  5. editSendDate: Sửa ngày gửi NCC. Quyền: customer.warranty_status.edit_send_date.
    • Params: supplier_send_date (req).
  6. editStatus: Chuyển trạng thái. Quyền: customer.warranty_status.edit_status.
    • Params: status (req: pending, send, receive, success).
  7. editCost: Sửa chi phí. Quyền: customer.warranty_status.edit_cost.
    • Params: repair_cost, warranty_expenses.
  8. addProgressNote: Thêm ghi chú tiến độ. Quyền: customer.warranty_status.add_progress_note.
    • Params: progress_note_text, progress_note_img.
  9. forwardWarranty: Chuyển tiếp bảo hành. Quyền: customer.warranty_status.forward_warranty.
    • Params: receiver (req), location (req).
  10. sendToSupplier: Gửi đi NCC. Quyền: customer.warranty_status.send_to_supplier.
    • Params: supplier_name (req).
  11. receivedFromSupplier: Nhận từ NCC. Quyền: customer.warranty_status.received_from_supplier.
    • Params: location (req), warranty_expenses, repair_cost.
  12. completeWarranty: Hoàn tất bảo hành. Quyền: customer.warranty_status.complete_warranty.
    • Params: other_cost.
  13. editOtherCost: Sửa số hóa đơn. Quyền: customer.warranty_status.edit_other_cost.
    • Params: other_cost.

Fields

Field Type Description Required
products NO
receiver NO
location NO
warranty_type NO
customer_name NO
customer_phone NO
customer_address NO
action NO
product_name NO
product_qty NO
product_status NO
product_img NO
supplier_name NO
note NO
cust_received_date NO
supplier_send_date NO
status NO
repair_cost NO
warranty_expenses NO
progress_note_text NO
progress_note_img NO
other_cost NO

Request

Headers

Header Value
Accept
application/vnd.customers.v1+json
application/hal+json
application/json
Content-Type
application/vnd.customers.v1+json
application/json
Authorization HTTP Basic, HTTP Digest, or OAuth2 Bearer token (check API provider for details)

Body

// 1. editProduct - Sửa thông tin sản phẩm
{
    "action": "editProduct",
    "product_name": "string", // Required. Tên sản phẩm
    "product_qty": "int", // Required. Số lượng
    "product_status": "string", // Optional. Tình trạng sản phẩm
    "product_img": "string", // Optional. JSON string chứa mảng base64 images
    "supplier_name": "string", // Optional. Tên nhà cung cấp
    "note": "string" // Optional. Ghi chú
}

// 2. editCustomer - Sửa thông tin khách hàng
{
    "action": "editCustomer",
    "customer_name": "string", // Required. Tên khách hàng
    "customer_phone": "string", // Optional. SĐT khách hàng
    "customer_address": "string" // Optional. Địa chỉ khách hàng
}

// 3. editReceiveDate - Sửa ngày nhận từ khách hàng
{
    "action": "editReceiveDate",
    "cust_received_date": "Y-m-d H:i:s" // Required. Ngày nhận
}

// 4. editSupplier - Sửa thông tin nhà cung cấp
{
    "action": "editSupplier",
    "supplier_name": "string" // Required. Tên NCC
}

// 5. editSendDate - Sửa ngày gửi NCC
{
    "action": "editSendDate",
    "supplier_send_date": "Y-m-d H:i:s" // Required. Ngày gửi
}

// 6. editStatus - Chuyển trạng thái phiếu
{
    "action": "editStatus",
    "status": "pending | send | receive | success" // Required. Trạng thái mới
}

// 7. editCost - Sửa chi phí
{
    "action": "editCost",
    "repair_cost": "float", // Optional. Chi phí sửa chữa
    "warranty_expenses": "float" // Optional. Chi phí bảo hành
}

// 8. addProgressNote - Thêm ghi chú tiến độ
{
    "action": "addProgressNote",
    "progress_note_text": "string", // Optional. Nội dung ghi chú
    "progress_note_img": "string" // Optional. Base64 image
}

// 9. forwardWarranty - Chuyển tiếp bảo hành
{
    "action": "forwardWarranty",
    "receiver": "string", // Required. Người nhận xử lý
    "location": "int" // Required. ID kho
}

// 10. sendToSupplier - Gửi sản phẩm đi NCC
{
    "action": "sendToSupplier",
    "supplier_name": "string" // Required. Tên NCC
}

// 11. receivedFromSupplier - Nhận sản phẩm từ NCC
{
    "action": "receivedFromSupplier",
    "location": "int", // Required. ID kho nhận
    "warranty_expenses": "float", // Optional. Chi phí bảo hành
    "repair_cost": "float" // Optional. Chi phí sửa chữa
}

// 12. completeWarranty - Hoàn tất bảo hành, trả khách
{
    "action": "completeWarranty",
    "other_cost": "string" // Optional. Số hóa đơn thu tiền (nếu có)
}

// 13. editOtherCost - Sửa số hóa đơn
{
    "action": "editOtherCost",
    "other_cost": "string" // Required. Số hóa đơn thu tiền
}

Response

Status Codes

  • 406: Not Acceptable
  • 415: Unsupported Media Type
  • 200: OK
  • 404: Not Found
  • 400: Client Error
  • 422: Unprocessable Entity
  • 401: Unauthorized
  • 403: Forbidden

Headers

Header Value
Content-Type
application/vnd.customers.v1+json
application/hal+json
application/json
Allow Comma-separated list of all HTTP methods allowed

Body

//SUCCESS
{"result":"SUCCESS"}

//ERROR
- 403 Forbidden
- 422 Unprocessable Entity
- WARRANTY_STATUS_NOT_FOUND: Không tìm thấy phiếu bảo hành.
- WARRANTY_ALREADY_COMPLETED: Không thể thao tác khi đã hoàn thành.
- INVALID_STATUS_TRANSITION: Chuyển trạng thái không hợp lệ.
- SEND_DATE_UPDATE_NOT_ALLOWED: Không được sửa ngày gửi khi chưa gửi.
- WARRANTY_ALREADY_SENT: Không thể thao tác khi đã gửi NCC.
- WARRANTY_NOT_SENT: Không thể thao tác khi chưa gửi NCC.
- WARRANTY_ALREADY_RECEIVED: Không thể thao tác khi đã nhận từ NCC.
- WARRANTY_NOT_RECEIVED: Không thể thao tác khi chưa nhận từ NCC.
- LOCATION_NOT_FOUND: Không tìm thấy kho.
- ERROR

DELETE /warranty-status[/:warranty_id]

Xóa phiếu bảo hành. Quyền: customer.warranty_status.delete

Fields

Field Type Description Required
products NO
receiver NO
location NO
warranty_type NO
customer_name NO
customer_phone NO
customer_address NO
action NO
product_name NO
product_qty NO
product_status NO
product_img NO
supplier_name NO
note NO
cust_received_date NO
supplier_send_date NO
status NO
repair_cost NO
warranty_expenses NO
progress_note_text NO
progress_note_img NO
other_cost NO

Request

Headers

Header Value
Accept
application/vnd.customers.v1+json
application/hal+json
application/json
Authorization HTTP Basic, HTTP Digest, or OAuth2 Bearer token (check API provider for details)

Response

Status Codes

  • 406: Not Acceptable
  • 415: Unsupported Media Type
  • 204: No Content
  • 404: Not Found
  • 401: Unauthorized
  • 403: Forbidden

Headers

Header Value
Content-Type
application/vnd.customers.v1+json
application/hal+json
application/json
Allow Comma-separated list of all HTTP methods allowed