im-api.js
3.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
'use strict';
const _ = require('lodash');
const config = global.yoho.config;
const ImService = new global.yoho.ApiBase(config.domains.imCs, {
name: 'im',
cache: global.yoho.cache,
useCache: false
});
/**
* 新建留言信息
* path: {host}/leavemessage/saveLeavemessage
*
* @param {int} encryptedUid 加密用户id
* @param {int} conversationId 会话id
* @param {str} content 留言内容
*/
exports.saveMessage = (encryptedUid, conversationId, content) => {
let params = {
conversationId,
content,
encryptedUid
};
return ImService.post('/api/leavemessage/saveLeavemessage', params);
};
/**
* 查询用户聊天记录
* @param {string} encryptedUid 加密用户uid
* @param [int] pageSize 每次加载的聊天记录
* @param [int] startTime
* @param [int] endTime
*/
exports.fetchImHistory = (encryptedUid, endTime, pageSize, startTime) => {
let params = {
encryptedUid
};
_.forEach({startTime, endTime}, (val, key) => {
val && (params[key] = val);
});
return ImService.post('/api/conversationMessage/pageList', params)
.then(result => {
return result;
}, () => {
return {
code: 500,
data: {
records: [], totalCount: 0
}
};
});
};
/**
* 获取用户订单, 默认最近10笔
* @param {string} encryptedUid 用户加密uid
* @param {init} createTimeBegin 开始时间
*/
exports.fetchOrderList = (encryptedUid, createTimeBegin) => {
let params = {
encryptedUid,
imgSize: '90x120',
};
_.forEach({createTimeBegin}, (key, val) => {
val && (params[key] = val);
});
return ImService.post('/api/order/queryLastTenOrder', params);
};
/**
*
新建评价信息
### url
```
{host}/evalute/saveEvalute
```
### 请求参数说明
| 名称 | 类型 | 是否必须 | 描述 |
| -------------- | ------ | ---- | --------------- |
| conversationId | long | Y | 会话id |
| uid | int | Y | 用户ID |
|encryptedUid | String |Y |加密的用户标识 |
| promoter | int | Y | 评价发起者 1 用户 2 客服 |
| stars | int | Y | 评分星级 |
| reasonIds | string | N | 固定原因Id用冒号隔开 |
| reasonMsgs | string | N | 固定原因用分号隔开 |
| reasonMsg | string | N | 其他原因 |
*/
exports.saveEvalute = (params) => {
return ImService.post('/api/evalute/saveEvalute', params);
};
/**
* 获取全球购的订单
*/
exports.queryGlobalOrder = encryptedUid => {
let params = {
encryptedUid
};
return ImService.post('/api/order/queryGlobalOrder', params);
};
/**
* 获取评价原因
* @param cvId 会话ID
*/
exports.queryReasons = cvId => {
let params = {
conversationId: cvId
};
return ImService.post('/api/evalute/queryReasonByConversationId', params);
};