[[_TOC_]]
# 1. Document hệ thống Shop Report Webservice
## DESCRIPTION
Get list notifications for app C2C/B2C and Marketplace
#### 1. Thiết kế hệ thống :
https://app.diagrams.net/#G1jaETp3C0Lk2ssxKidC6Uf6uOMRyl4LyQ
#### 2. Tài liệu :
https://docs.google.com/document/u/1/d/1PmBY1BSv-vhlbtBZdz1TK8HuNW9VJbbSCUwDYLZMacg/edit?usp=drive_web&ouid=117725526527454196904
## PRODUCTION URL
## CS_NOTIFICATION -> Project xử lý notifications
# 2. CONFIG
## 1.1 ENV VARIABLE
- ENV=development
- MONGO_CS_NOTIFICATION_SERVERS='
- MONGO_CS_NOTIFICATION_DB=
- MONGO_CS_NOTIFICATION_USER=
- MONGO_CS_NOTIFICATION_PW=
- MONGO_ADMIN_DB=admin
- MONGO_READ_PREFERENCE=secondary
## 1.2 CONNECT
- ecom
# 3. API NOTIFICATIONS
## 1. API getMobileNotifications Marketplace
> URL:
```
GET /api/mp/notifications/get
```
> Params:
|key|type|descriptions | required|
|--|--|--|--|
|shop_id|number| ID mp shop |Y|
|group_id|number| ID nhóm thông báo|N|
|created_from|string| Ngày bắt đầu|N|
|created_to|string| Ngày kết thúc|N|
|page|number| Trang|N|
|is_b2c|number| Check shop B2C|Y|
>Header:
|key|type|descriptions | required|
|--|--|--|--|
|appType|string| Loại app ('iosb2c', 'iosc2c' , 'androidb2c', 'androidb2c') |Y|
>RESPONSE
SUCCESS
```json
{
"success": true,
"data": [
{
"id": 534219290,
"type": 4,
"subject": "Thông báo lấy hàng cho Shop",
"content": "Gửi hàng bưu cục/2 ĐH/S12183378 - Big hero. Bưu cục: BC Ngô Xuân Quảng đã nhận hàng.",
"addition": {
"package_ids": [
"5e8dadfc-924c-4406-84f9-4847c0a80266",
"5e9a8653-a888-4f43-b802-4398c0a80266"
],
"c2c_app_data": {
"id": "5e8da6cc-1bb4-485e-bb34-4095c0a80266",
"code": "S12183378",
"is_b2c": true
}
},
"shop_id": "5e8da6cc-1bb4-485e-bb34-4095c0a80266",
"role": "shop",
"read": 0,
"created": "2020-04-18T04:50:41.000Z",
"deleted": 0
},
],
"count": 8
}
```
FAIL
```json
{
"success" : false,
"message" : "Không tìm thấy thông tin shop sàn. Vui lòng liên hệ để được hỗ trợ."
}
```
## 2. API getMobileNotificationsV2 Marketplace
> URL:
```
GET /api/mp/notifications/getV2
```
> Params:
|key|type|descriptions | required|
|--|--|--|--|
|shop_id|number| ID mp shop |Y|
|group_id|number| ID nhóm thông báo|N|
|created_from|string| Ngày bắt đầu|N|
|created_to|string| Ngày kết thúc|N|
|page|number| Trang|N|
|is_b2c|number| Check shop B2C|Y|
>Header:
|key|type|descriptions | required|
|--|--|--|--|
|appType|string| Loại app ('iosb2c', 'iosc2c' , 'androidb2c', 'androidb2c') |Y|
>RESPONSE
SUCCESS
```json
{
"success": true,
"data": [
{
"id": 534219290,
"type": 4,
"subject": "Thông báo lấy hàng cho Shop",
"content": "Gửi hàng bưu cục/2 ĐH/S12183378 - Big hero. Bưu cục: BC Ngô Xuân Quảng đã nhận hàng.",
"addition": {
"package_ids": [
"5e8dadfc-924c-4406-84f9-4847c0a80266",
"5e9a8653-a888-4f43-b802-4398c0a80266"
],
"c2c_app_data": {
"id": "5e8da6cc-1bb4-485e-bb34-4095c0a80266",
"code": "S12183378",
"is_b2c": true
}
},
"shop_id": "5e8da6cc-1bb4-485e-bb34-4095c0a80266",
"role": "shop",
"read": 0,
"created": "2020-04-18T04:50:41.000Z",
"deleted": 0
},
]
}
```
FAIL
```json
{
"success" : false,
"message" : "Không tìm thấy thông tin shop sàn. Vui lòng liên hệ để được hỗ trợ."
}
```
## 3. API countNotifications Marketplace
> URL:
```
POST /api/mp/notifications/count
```
> Body:
|key|type|descriptions | required|
|--|--|--|--|
|shop_id|number| ID mp shop |Y|
|shops|array| Mảng thông tin shop (shop_id, shop_type, date)|Y|
>Properties:
|key|type|descriptions | required|
|--|--|--|--|
|shop_id|string| ID shop |Y|
|shop_type|string| Loại shop (MP, B2C, C2C)|Y|
|date|string| Điều kiện ngày bắt đầu lấy thông báo|Y|
>Header:
|key|type|descriptions | required|
|--|--|--|--|
|appType|string| Loại app ('iosb2c', 'iosc2c' , 'androidb2c', 'androidb2c') |Y|
>RESPONSE
```json
{
"success": true,
"data": [
{
"shop_id": 1,
"notifications_count": 4
},
{
"shop_id": 2,
"notifications_count": 7
}
]
}
```
## 4. API getMobileNotifications B2C
> URL:
```
GET /api/b2c/notifications/get
```
> Params:
|key|type|descriptions | required|
|--|--|--|--|
|shop_id|string| ID shop |Y|
|role|string| Vai trò|Y|
|group_id|number| ID nhóm thông báo|N|
|created_from|string| Ngày bắt đầu|N|
|created_to|string| Ngày kết thúc|N|
|page|number| Trang|N|
|type|number| Loại thông báo|N|
>RESPONSE
```json
{
"success": true,
"data": [
{
"id": 534219290,
"type": 4,
"subject": "Thông báo lấy hàng cho Shop",
"content": "Gửi hàng bưu cục/2 ĐH/S12183378 - Big hero. Bưu cục: BC Ngô Xuân Quảng đã nhận hàng.",
"addition": {
"package_ids": [
"5e8dadfc-924c-4406-84f9-4847c0a80266",
"5e9a8653-a888-4f43-b802-4398c0a80266"
],
"c2c_app_data": {
"id": "5e8da6cc-1bb4-485e-bb34-4095c0a80266",
"code": "S12183378",
"is_b2c": true
}
},
"shop_id": "5e8da6cc-1bb4-485e-bb34-4095c0a80266",
"role": "shop",
"read": 0,
"created": "2020-04-18T04:50:41.000Z",
"deleted": 0
},
],
"count": 8
}
```
## 5. API getMobileNotificationsV2 B2C
> URL:
```
GET /api/b2c/notifications/getV2
```
> Params:
|key|type|descriptions | required|
|--|--|--|--|
|shop_id|string| ID shop |Y|
|role|string| Vai trò|Y|
|group_id|number| ID nhóm thông báo|N|
|created_from|string| Ngày bắt đầu|N|
|created_to|string| Ngày kết thúc|N|
|page|number| Trang|N|
|type|number| Loại thông báo|N|
>RESPONSE
```json
{
"success": true,
"data": [
{
"id": 534219290,
"type": 4,
"subject": "Thông báo lấy hàng cho Shop",
"content": "Gửi hàng bưu cục/2 ĐH/S12183378 - Big hero. Bưu cục: BC Ngô Xuân Quảng đã nhận hàng.",
"addition": {
"package_ids": [
"5e8dadfc-924c-4406-84f9-4847c0a80266",
"5e9a8653-a888-4f43-b802-4398c0a80266"
],
"c2c_app_data": {
"id": "5e8da6cc-1bb4-485e-bb34-4095c0a80266",
"code": "S12183378",
"is_b2c": true
}
},
"shop_id": "5e8da6cc-1bb4-485e-bb34-4095c0a80266",
"role": "shop",
"read": 0,
"created": "2020-04-18T04:50:41.000Z",
"deleted": 0
},
]
}
```
## 6. API countNotifications B2C
> URL:
```
POST /api/b2c/notifications/count
```
> Body:
|key|type|descriptions | required|
|--|--|--|--|
|shop_id|string| ID shop |Y|
|role|string| vai trò|Y|
|date|string| Điều kiện ngày bắt đầu lấy thông báo |Y|
|group_id|number| ID nhóm thông báo|N|
>RESPONSE
```json
{
"success": true,
"data": {
"shop_id": 1,
"notifications_count": 4
}
}
```
## 7. API getMobileNotifications C2C
> URL:
```
GET /api/c2c/notifications/get
```
> Params:
|key|type|descriptions | required|
|--|--|--|--|
|shop_id|string| ID shop |Y|
|group_id|number| ID nhóm thông báo|N|
|page|number| Trang|N|
>RESPONSE
```json
{
"success": true,
"data": [
{
"id": 534219290,
"type": 4,
"subject": "Thông báo lấy hàng cho Shop",
"content": "Gửi hàng bưu cục/2 ĐH/S12183378 - Big hero. Bưu cục: BC Ngô Xuân Quảng đã nhận hàng.",
"addition": {
"package_ids": [
"5e8dadfc-924c-4406-84f9-4847c0a80266",
"5e9a8653-a888-4f43-b802-4398c0a80266"
],
"c2c_app_data": {
"id": "5e8da6cc-1bb4-485e-bb34-4095c0a80266",
"code": "S12183378",
"is_b2c": true
}
},
"shop_id": "5e8da6cc-1bb4-485e-bb34-4095c0a80266",
"role": "shop",
"read": 0,
"created": "2020-04-18T04:50:41.000Z",
"deleted": 0
},
],
"count": 16
}
```
## 8. API getMobileNotificationsV2 C2C
> URL:
```
GET /api/c2c/notifications/getV2
```
> Params:
|key|type|descriptions | required|
|--|--|--|--|
|shop_id|string| ID shop |Y|
|group_id|number| ID nhóm thông báo|N|
|page|number| Trang|N|
>RESPONSE
```json
{
"success": true,
"data": [
{
"id": 534219290,
"type": 4,
"subject": "Thông báo lấy hàng cho Shop",
"content": "Gửi hàng bưu cục/2 ĐH/S12183378 - Big hero. Bưu cục: BC Ngô Xuân Quảng đã nhận hàng.",
"addition": {
"package_ids": [
"5e8dadfc-924c-4406-84f9-4847c0a80266",
"5e9a8653-a888-4f43-b802-4398c0a80266"
],
"c2c_app_data": {
"id": "5e8da6cc-1bb4-485e-bb34-4095c0a80266",
"code": "S12183378",
"is_b2c": true
}
},
"shop_id": "5e8da6cc-1bb4-485e-bb34-4095c0a80266",
"role": "shop",
"read": 0,
"created": "2020-04-18T04:50:41.000Z",
"deleted": 0
},
],
"count": 16
}
```
## 9. API getMobileNotificationsV3 C2C
> URL:
```
GET /api/c2c/notifications/getV3
```
> Params:
|key|type|descriptions | required|
|--|--|--|--|
|shop_id|string| ID shop |Y|
|group_id|number| ID nhóm thông báo|N|
|page|number| Trang|N|
>RESPONSE
```json
{
"success": true,
"data": [
{
"id": 534219290,
"type": 4,
"subject": "Thông báo lấy hàng cho Shop",
"content": "Gửi hàng bưu cục/2 ĐH/S12183378 - Big hero. Bưu cục: BC Ngô Xuân Quảng đã nhận hàng.",
"addition": {
"package_ids": [
"5e8dadfc-924c-4406-84f9-4847c0a80266",
"5e9a8653-a888-4f43-b802-4398c0a80266"
],
"c2c_app_data": {
"id": "5e8da6cc-1bb4-485e-bb34-4095c0a80266",
"code": "S12183378",
"is_b2c": true
}
},
"shop_id": "5e8da6cc-1bb4-485e-bb34-4095c0a80266",
"role": "shop",
"read": 0,
"created": "2020-04-18T04:50:41.000Z",
"deleted": 0
},
]
}
```
## 10. API getImportantNoti C2C
> URL:
```
GET /api/c2c/notifications/important
```
> Params:
|key|type|descriptions | required|
|--|--|--|--|
|shop_id|string| ID shop |Y|
|group_id|number| ID nhóm thông báo|N|
|page|number| Trang|N|
>RESPONSE
```json
{
"success": true,
"data": [
{
"id": 534219290,
"type": 4,
"subject": "Thông báo lấy hàng cho Shop",
"content": "Gửi hàng bưu cục/2 ĐH/S12183378 - Big hero. Bưu cục: BC Ngô Xuân Quảng đã nhận hàng.",
"addition": {
"package_ids": [
"5e8dadfc-924c-4406-84f9-4847c0a80266",
"5e9a8653-a888-4f43-b802-4398c0a80266"
],
"c2c_app_data": {
"id": "5e8da6cc-1bb4-485e-bb34-4095c0a80266",
"code": "S12183378",
"is_b2c": true
}
},
"shop_id": "5e8da6cc-1bb4-485e-bb34-4095c0a80266",
"role": "shop",
"read": 0,
"created": "2020-04-18T04:50:41.000Z",
"deleted": 0
},
]
}
```
## 11. API countNotifications C2C
> URL:
```
POST /api/c2c/notifications/count
```
> Body:
|key|type|descriptions | required|
|--|--|--|--|
|shop_id|string| ID shop |Y|
|date|string| Điều kiện ngày bắt đầu lấy thông báo |Y|
|group_id|number| ID nhóm thông báo|N|
>RESPONSE
```json
{
"success": true,
"data": {
"shop_id": 1,
"notifications_count": 4
}
}
```
## 12. API getTopics C2C
> URL:
```
GET /api/c2c/topics/get
```
> Params:
|key|type|descriptions | required|
|--|--|--|--|
|shop_id|string| ID shop |Y|
|dateFrom|string| Điều kiện ngày bắt đầu lấy thông báo |N|
>RESPONSE
```json
{
"success": true,
"data": [
{
"id": 6,
"title": "Tin Tức",
"types": [],
"count": 0,
"count_unread": 0
},
{
"id": 0,
"title": "Quan trọng",
"types": [13,14,8,9,10,11,16,17,18],
"count": 0,
"count_unread": 0
},
{
"id": 3,
"title": "Giao Hàng",
"types": [5,8,9,10,11],
"count": 0,
"count_unread": 0
},
{
"id": 2,
"title": "Lấy Hàng",
"types": [1,4,12,13,14],
"count": 18,
"count_unread": 3
},
{
"id": 1,
"title": "Yêu Cầu",
"types": [0],
"count": 27,
"count_unread": 12
},
{
"id": 7,
"title": "Thay đổi đơn hàng",
"types": [17,18,21],
"count": 0,
"count_unread": 0
},
{
"id": 5,
"title": "Đối Soát",
"types": [3],
"count": 0,
"count_unread": 0
},
{
"id": 4,
"title": "Trả Hàng",
"types": [15,16],
"count": 0,
"count_unread": 0
}
]
}
```
## 13. API insert device token EZ app:
> URL:
```
POST /api/ez/token/insert
```
> Body:
|key|type|descriptions | required|
|--|--|--|--|
|object_id|number| ID user |Y|
|device_token|string| Device token |Y|
|role|string| Vai trò (default: 'user')|N|
|app_type|string| Loại app (default: 'EZ') |N|
>RESPONSE
```json
{
"success": true,
"message": "Insert device token success !",
"data": {
"id": "5f1fe1e9a688f914c8a9cc29",
"object_id": 5,
"device_token": "12313",
"role": "user",
"app_type": "EZ",
"created": "2020-07-28T15:29:29.852Z",
"modified": "2020-07-28T15:29:29.852Z"
}
}
```
## 14. API remove device token EZ app:
> URL:
```
POST /api/ez/token/remove
```
> Body:
|key|type|descriptions | required|
|--|--|--|--|
|device_token|string| Device token |Y|
>RESPONSE
```json
{
"success": true,
"message": "Remove token success !"
}
```
## 15. API get list CS call log:
> URL:
```
GET /api/cs/call-log/list
```
> Header:
```
token: upNCQJn3ihM3VBgnUvT5irbfBi362fMS
```
> Params:
|key|type|descriptions | required|
|--|--|--|--|
|user_id|number| CS ID |Y|
|pkg_order|number| Mã đơn hàng |Y|
>RESPONSE
```json
{
"success": true,
"message": "Get list CS call logs successfully !",
"data": [
{
"id": 6814095,
"from": "0931494111",
"to": "0914280617",
"is_shop": true,
"is_confirmed": true,
"desc": "hieupt37 gọi khách hàng 091***0617 lúc 15/11 13:24:17, thời gian 20s",
"call_date": "2018-12-15T13:24:17.000Z",
"answer_duration": 20,
"ring_duration": 0
},
{
"id": 6813802,
"from": "0931494111",
"to": "0334654323",
"is_shop": true,
"is_confirmed": false,
"desc": "hieupt37 gọi shop 033***4323 lúc 15/11 13:16:51, thời gian 16s",
"call_date": "2018-12-15T13:16:51.000Z",
"answer_duration": 16,
"ring_duration": 0
}
]
}
```
## 16. API lưu log cuộc gọi vào đơn hàng:
> URL:
```
POST /api/cs/call-log/save-package
```
> Header:
```
token: upNCQJn3ihM3VBgnUvT5irbfBi362fMS
```
> Body:
|key|type|descriptions | required|
|--|--|--|--|
|pkg_order|number| Mã đơn hàng |Y|
|log_ids|array| Danh sách log ID |Y|
|user_id|number| User ID |Y|
>RESPONSE
```json
{
"success": true,
"message": "Save CS package call logs successfully !"
}
```
## 17. API lấy log cuộc gọi theo đơn hàng:
> URL:
```
POST /api/cs/call-log/get-by-package
```
> Header:
```
token: {{token_shop}}
```
> Body:
|key|type|descriptions | required|
|--|--|--|--|
|pkg_order|number| Mã đơn hàng |Y|
>RESPONSE
```json
{
"success": true,
"message": "Get package CS call logs successfully",
"data": [
{
"id": "61dcfded96916c019241a5e2",
"log_id": 6813764,
"pkg_order": 591911437,
"shop_code": "S3096572",
"desc": "hieupt37 gọi shop 033***4323 lúc 15/11 13:15:28, thời gian 24s",
"created": "2018-12-15T13:15:28.000Z",
"package_id": "61ad89a8-53a0-4814-a23e-00640ae95ea8",
"shop_id": "5c049ab0-b284-44cd-bf55-4edb0a0a0211"
},
{
"id": "61dd09bec9316503e48cdbfe",
"log_id": 6813851,
"pkg_order": 591911437,
"shop_code": "S3096572",
"desc": "hieupt37 gọi khách hàng 091***0617 lúc 15/11 13:18:07, thời gian 12s",
"created": "2018-12-15T13:18:07.000Z",
"package_id": "61ad89a8-53a0-4814-a23e-00640ae95ea8",
"shop_id": "5c049ab0-b284-44cd-bf55-4edb0a0a0211"
}
]
}
```
## 18. API cập nhật user zoiper:
> URL:
```
POST /api/cs/call-log/zoiper/user/{{action}}
```
> Header:
```
token: {{access_token}}
```
> Params:
|key|type|descriptions | required|
|--|--|--|--|
|action|number| Action (create / update / delete) |Y|
> Body:
|key|type|descriptions | required|
|--|--|--|--|
|id|number| Zoiper user ID |N|
|zoiper_id|number| Zoiper ID |N|
|username|string| Username |Y|
>RESPONSE
```json
{
"success": true,
"message": "Success",
"data": {}
}
```