# Cart - 3 - Doanh nghiệp

# Get Cart By User Id

Sử dụng API này để lấy thông tin giỏ hàng của user thông qua id của user

# Endpoint

# Parameters

Name Type Description Required
Required parameters Number :userId:

# Response

Trả về thông tin giỏ hàng của user đó

{
    "status": true,
    "message": "success",
    "data": {
        "id": 28,
        "userId": 1,
        "totalQty": 10,
        "deleted": false,
        "createdAt": "2021-07-10T11:53:54.000Z",
        "updatedAt": "2021-07-15T03:09:38.000Z",
        "items": [
            {
                "id": 63,
                "productId": 101,
                "cartId": 28,
                "quantity": 5,
                "deleted": false,
                "createdAt": "2021-07-10T11:53:54.000Z",
                "updatedAt": "2021-07-16T05:13:25.000Z",
                "product": {
                    "id": 101,
                    "name": "Intelligent Wooden Chips",
                    "slug": "intelligent-wooden-chips",
                    "eic": null,
                    "mpn": "Durango",
                    "uom": null,
                    "companyId": 0,
                    "supplierId": 1,
                    "description": "Carbonite web goalkeeper gloves are ergonomically designed to give easy fit",
                    "specification": null,
                    "categoryId": 9,
                    "images": "http://placeimg.com/640/480",
                    "tags": null,
                    "price": 7642840,
                    "supplierPrice": null,
                    "promotionCode": null,
                    "warrantyZone": null,
                    "shipMethodId": 0,
                    "specialRequest": null,
                    "rate": 0,
                    "brand": null,
                    "deleted": 1,
                    "createdBy": 10,
                    "updatedBy": 3,
                    "createdAt": "2021-06-17T08:04:19.000Z",
                    "updatedAt": "2021-07-16T08:15:41.801Z"
                }
            },
            {
                "id": 64,
                "productId": 102,
                "cartId": 28,
                "quantity": 5,
                "deleted": false,
                "createdAt": "2021-07-10T12:06:23.000Z",
                "updatedAt": "2021-07-16T05:13:37.000Z",
                "product": {
                    "id": 102,
                    "name": "Unbranded Rubber Chair",
                    "slug": "unbranded-rubber-chair",
                    "eic": null,
                    "mpn": "Camry",
                    "uom": null,
                    "companyId": 0,
                    "supplierId": 1,
                    "description": "The automobile layout consists of a front-engine design, with transaxle-type transmissions mounted at the rear of the engine and four wheel drive",
                    "specification": null,
                    "categoryId": 8,
                    "images": "http://placeimg.com/640/480",
                    "tags": null,
                    "price": 4852090,
                    "supplierPrice": null,
                    "promotionCode": null,
                    "warrantyZone": null,
                    "shipMethodId": 0,
                    "specialRequest": null,
                    "rate": 0,
                    "brand": null,
                    "deleted": 1,
                    "createdBy": 6,
                    "updatedBy": 3,
                    "createdAt": "2021-06-17T08:04:19.000Z",
                    "updatedAt": "2021-07-16T08:15:56.137Z"
                }
            }
        ]
    }
}
curl -X POST http://localhost:3000/cart/ei/getByUserId \
  -H 'Content-Type: application/json' \
  --data '{
      "userId": 1,
  }'

# Remove items from cart

Sử dụng API này để xóa một item ra khỏi giỏ hàng (có thể chỉnh số lượng xóa bằng tham sô quantity)

# Endpoint

# Parameters

Name Type Description Required
Required parameters Number :userId:
Required parameters Number :productId:
Required parameters Number :quantity:

# Response

Trả về giỏ hàng sau khi xóa

{
    "status": true,
    "message": "success",
    "data": {
        "id": 31,
        "userId": 5,
        "totalQty": 15,
        "deleted": false,
        "createdAt": "2021-07-16T04:51:47.000Z",
        "updatedAt": "2021-07-16T10:56:59.000Z",
        "items": [
            {
                "id": 74,
                "productId": 104,
                "cartId": 31,
                "quantity": 5,
                "deleted": false,
                "createdAt": "2021-07-16T04:52:49.000Z",
                "updatedAt": "2021-07-16T04:52:53.000Z",
                "product": {
                    "id": 104,
                    "name": "Practical Steel Chair",
                    "slug": "practical-steel-chair",
                    "eic": null,
                    "mpn": "2",
                    "uom": null,
                    "companyId": 0,
                    "supplierId": 1,
                    "description": "The automobile layout consists of a front-engine design, with transaxle-type transmissions mounted at the rear of the engine and four wheel drive",
                    "specification": null,
                    "categoryId": 9,
                    "images": "http://placeimg.com/640/480",
                    "tags": null,
                    "price": 2151320,
                    "supplierPrice": null,
                    "promotionCode": null,
                    "warrantyZone": null,
                    "shipMethodId": 0,
                    "specialRequest": null,
                    "rate": 0,
                    "brand": null,
                    "deleted": 1,
                    "createdBy": 5,
                    "updatedBy": 3,
                    "createdAt": "2021-06-17T08:04:19.000Z",
                    "updatedAt": "2021-07-16T08:15:42.788Z"
                }
            },
            {
                "id": 78,
                "productId": 103,
                "cartId": 31,
                "quantity": 4,
                "deleted": false,
                "createdAt": "2021-07-16T05:13:46.000Z",
                "updatedAt": "2021-07-16T05:13:49.000Z",
                "product": {
                    "id": 103,
                    "name": "Small Concrete Salad",
                    "slug": "small-concrete-salad",
                    "eic": null,
                    "mpn": "Spyder",
                    "uom": null,
                    "companyId": 0,
                    "supplierId": 1,
                    "description": "The Nagasaki Lander is the trademarked name of several series of Nagasaki sport bikes, that started with the 1984 ABC800J",
                    "specification": null,
                    "categoryId": 4,
                    "images": "http://placeimg.com/640/480",
                    "tags": null,
                    "price": 5821940,
                    "supplierPrice": null,
                    "promotionCode": null,
                    "warrantyZone": null,
                    "shipMethodId": 0,
                    "specialRequest": null,
                    "rate": 0,
                    "brand": null,
                    "deleted": 1,
                    "createdBy": 10,
                    "updatedBy": 3,
                    "createdAt": "2021-06-17T08:04:19.000Z",
                    "updatedAt": "2021-07-16T08:16:15.512Z"
                }
            },
            {
                "id": 79,
                "productId": 105,
                "cartId": 31,
                "quantity": 6,
                "deleted": false,
                "createdAt": "2021-07-16T05:13:58.000Z",
                "updatedAt": "2021-07-16T10:56:59.000Z",
                "product": {
                    "id": 105,
                    "name": "Small Cotton Table",
                    "slug": "small-cotton-table",
                    "eic": null,
                    "mpn": "Escalade",
                    "uom": null,
                    "companyId": 0,
                    "supplierId": 1,
                    "description": "The Football Is Good For Training And Recreational Purposes",
                    "specification": null,
                    "categoryId": 9,
                    "images": "http://placeimg.com/640/480",
                    "tags": null,
                    "price": 6461960,
                    "supplierPrice": null,
                    "promotionCode": null,
                    "warrantyZone": null,
                    "shipMethodId": 0,
                    "specialRequest": null,
                    "rate": 0,
                    "brand": null,
                    "deleted": 1,
                    "createdBy": 9,
                    "updatedBy": 3,
                    "createdAt": "2021-06-17T08:04:19.000Z",
                    "updatedAt": "2021-07-16T08:15:43.839Z"
                }
            }
        ]
    }
}
curl -X POST http://localhost:3000/cart/ei/deleteItem \
  -H 'Content-Type: application/json' \
  --data '{
        "userId" : 5,
        "productId": 105,
        "quantity": 1
  }'

# Remove product from cart

Sử dụng API này để xóa một sản phẩm ra khỏi giỏ hàng (xóa hết sô lượng)

# Endpoint

# Parameters

Name Type Description Required
Required parameters Number :userId:
Required parameters Number :productId:

# Response

Trả về giỏ hàng sau khi xóa

{
    "status": true,
    "message": "success",
    "data": {
        "id": 31,
        "userId": 5,
        "totalQty": 9,
        "deleted": false,
        "createdAt": "2021-07-16T04:51:47.000Z",
        "updatedAt": "2021-07-16T11:08:43.000Z",
        "items": [
            {
                "id": 74,
                "productId": 104,
                "cartId": 31,
                "quantity": 5,
                "deleted": false,
                "createdAt": "2021-07-16T04:52:49.000Z",
                "updatedAt": "2021-07-16T04:52:53.000Z",
                "product": {
                    "id": 104,
                    "name": "Practical Steel Chair",
                    "slug": "practical-steel-chair",
                    "eic": null,
                    "mpn": "2",
                    "uom": null,
                    "companyId": 0,
                    "supplierId": 1,
                    "description": "The automobile layout consists of a front-engine design, with transaxle-type transmissions mounted at the rear of the engine and four wheel drive",
                    "specification": null,
                    "categoryId": 9,
                    "images": "http://placeimg.com/640/480",
                    "tags": null,
                    "price": 2151320,
                    "supplierPrice": null,
                    "promotionCode": null,
                    "warrantyZone": null,
                    "shipMethodId": 0,
                    "specialRequest": null,
                    "rate": 0,
                    "brand": null,
                    "deleted": 1,
                    "createdBy": 5,
                    "updatedBy": 3,
                    "createdAt": "2021-06-17T08:04:19.000Z",
                    "updatedAt": "2021-07-16T08:15:42.788Z"
                }
            },
            {
                "id": 78,
                "productId": 103,
                "cartId": 31,
                "quantity": 4,
                "deleted": false,
                "createdAt": "2021-07-16T05:13:46.000Z",
                "updatedAt": "2021-07-16T05:13:49.000Z",
                "product": {
                    "id": 103,
                    "name": "Small Concrete Salad",
                    "slug": "small-concrete-salad",
                    "eic": null,
                    "mpn": "Spyder",
                    "uom": null,
                    "companyId": 0,
                    "supplierId": 1,
                    "description": "The Nagasaki Lander is the trademarked name of several series of Nagasaki sport bikes, that started with the 1984 ABC800J",
                    "specification": null,
                    "categoryId": 4,
                    "images": "http://placeimg.com/640/480",
                    "tags": null,
                    "price": 5821940,
                    "supplierPrice": null,
                    "promotionCode": null,
                    "warrantyZone": null,
                    "shipMethodId": 0,
                    "specialRequest": null,
                    "rate": 0,
                    "brand": null,
                    "deleted": 1,
                    "createdBy": 10,
                    "updatedBy": 3,
                    "createdAt": "2021-06-17T08:04:19.000Z",
                    "updatedAt": "2021-07-16T08:16:15.512Z"
                }
            }
        ]
    }
}
curl -X POST http://localhost:3000/cart/ei/deleteProduct \
  -H 'Content-Type: application/json' \
  --data '{
        "userId" : 5,
        "productId": 105
  }'

# Remove Cart By User Id

Sử dụng API này để xóa giỏ hàng cụ thể thông qua userId

# Endpoint

# Parameters

Name Type Description Required
Required parameters Number :userId:

# Response

{
    "status": true,
    "message": "success"
}
curl -X POST http://localhost:3000/cart/ei/delete \
  -H 'Content-Type: application/json' \
  --data '{
        "userId" : 5,
  }'

# Add To Order

Sử dụng API này để tạo đơn hàng từ giỏ hàng (khi nhắn nút thanh toán)

# Endpoint

# Parameters

Name Type Description Required
Required parameters Number :userId:
Required parameters Number :addressId:
Required parameters Array :productList:

# Response

Trả về thông tin đơn hàng kèm theo chi tiết đơn hàng

{
    "status": true,
    "message": "success",
    "data": {
        "id": 447,
        "name": "Xinat1",
        "phone": "123456789",
        "email": "xinat@gmail.com",
        "address": null,
        "city": "1",
        "district": "1",
        "town": null,
        "deliveryDate": null,
        "estimatedDeliveryDate": null,
        "totalQty": 7,
        "totalPrice": 42336880,
        "totalSalePrice": 42336880,
        "status": 1,
        "presenter": null,
        "company_id": 0,
        "voucher_id": null,
        "discountType": null,
        "wms": 0,
        "wms_checkout_id": 0,
        "wms_checkout_status": 0,
        "deleted": false,
        "createdBy": -1,
        "updatedBy": -1,
        "createdAt": "2021-07-16T11:20:50.000Z",
        "updatedAt": "2021-07-16T11:20:50.000Z",
        "orderDetails": [
            {
                "id": 2532,
                "quantity": 3,
                "price": 7642840,
                "totalPrice": 22928520,
                "supId": 1,
                "is_receive": false,
                "status": 0,
                "deliveryDate": null,
                "checkoutId": 447,
                "productName": "Intelligent Wooden Chips",
                "productImg": "http://placeimg.com/640/480",
                "productModel": "ABC",
                "productId": 101,
                "deleted": false,
                "createdBy": -1,
                "updatedBy": -1,
                "createdAt": "2021-07-16T11:20:50.000Z",
                "updatedAt": "2021-07-16T11:20:50.000Z"
            },
            {
                "id": 2533,
                "quantity": 4,
                "price": 4852090,
                "totalPrice": 19408360,
                "supId": 1,
                "is_receive": false,
                "status": 0,
                "deliveryDate": null,
                "checkoutId": 447,
                "productName": "Unbranded Rubber Chair",
                "productImg": "http://placeimg.com/640/480",
                "productModel": "ABC",
                "productId": 102,
                "deleted": false,
                "createdBy": -1,
                "updatedBy": -1,
                "createdAt": "2021-07-16T11:20:50.000Z",
                "updatedAt": "2021-07-16T11:20:50.000Z"
            }
        ]
    }
}
curl -X POST http://localhost:3000/cart/ei/addToCart \
  -H 'Content-Type: application/json' \
  --data '{
        "userId" : 5,
        "addressId": 1,
        "productList": [101, 102]
  }'