|
@@ -5,8 +5,6 @@ |
|
@@ -5,8 +5,6 @@ |
5
|
*/
|
5
|
*/
|
6
|
'use strict';
|
6
|
'use strict';
|
7
|
|
7
|
|
8
|
-const api = global.yoho.API;
|
|
|
9
|
-
|
|
|
10
|
const _ = require('lodash');
|
8
|
const _ = require('lodash');
|
11
|
const Promise = require('bluebird');
|
9
|
const Promise = require('bluebird');
|
12
|
|
10
|
|
|
@@ -20,106 +18,116 @@ const complaintType = { |
|
@@ -20,106 +18,116 @@ const complaintType = { |
20
|
2: '物流相关'
|
18
|
2: '物流相关'
|
21
|
};
|
19
|
};
|
22
|
|
20
|
|
23
|
-/**
|
|
|
24
|
- * 获取投诉列表
|
|
|
25
|
- * @function getComplaintsList
|
|
|
26
|
- * @param { Number } uid 用户uid
|
|
|
27
|
- * @param { Number } page 页码
|
|
|
28
|
- * @param { Number } limit 每页数目
|
|
|
29
|
- * @return { Object } 投诉列表数据
|
|
|
30
|
- */
|
|
|
31
|
-const getComplaintsList = (uid, page, limit) => {
|
|
|
32
|
- page = page || 1;
|
|
|
33
|
- limit = limit || 10;
|
|
|
34
|
-
|
|
|
35
|
- const process = function*() {
|
|
|
36
|
- let resData = {};
|
|
|
37
|
- let result = yield api.get('', {
|
|
|
38
|
- method: 'web.complaints.getList',
|
|
|
39
|
- uid: uid,
|
|
|
40
|
- page: page,
|
|
|
41
|
- limit: limit
|
|
|
42
|
- }, {code: 200});
|
|
|
43
|
-
|
|
|
44
|
- if (!_.isEmpty(result.data)) {
|
|
|
45
|
- let list = [];
|
|
|
46
|
-
|
|
|
47
|
- _.forEach(_.get(result, 'data.complaintList', []), value => {
|
|
|
48
|
- list.push({
|
|
|
49
|
- id: value.id,
|
|
|
50
|
- title: value.title,
|
|
|
51
|
- target: value.customer,
|
|
|
52
|
- type: complaintType[value.complaintsType],
|
|
|
53
|
- order: value.orderCode,
|
|
|
54
|
- time: value.createTime,
|
|
|
55
|
- question: value.content,
|
|
|
56
|
- reply: value.reply,
|
|
|
57
|
- replyTime: value.replyTime,
|
|
|
58
|
- revoke: value.status === -1
|
|
|
59
|
- });
|
|
|
60
|
- });
|
|
|
61
|
|
21
|
|
62
|
- if (_.isEmpty(list)) {
|
|
|
63
|
- resData.complaints = {empty: '您尚未投诉任何内容'};
|
|
|
64
|
- } else {
|
|
|
65
|
- resData.complaints = list;
|
|
|
66
|
- }
|
22
|
+module.exports = class extends global.yoho.BaseModel {
|
|
|
23
|
+ constructor(ctx) {
|
|
|
24
|
+ super(ctx);
|
|
|
25
|
+ }
|
|
|
26
|
+
|
|
|
27
|
+ /**
|
|
|
28
|
+ * 获取投诉列表
|
|
|
29
|
+ * @function getComplaintsList
|
|
|
30
|
+ * @param { Number } uid 用户uid
|
|
|
31
|
+ * @param { Number } page 页码
|
|
|
32
|
+ * @param { Number } limit 每页数目
|
|
|
33
|
+ * @return { Object } 投诉列表数据
|
|
|
34
|
+ */
|
|
|
35
|
+ getComplaintsList(uid, page, limit) {
|
|
|
36
|
+ page = page || 1;
|
|
|
37
|
+ limit = limit || 10;
|
|
|
38
|
+
|
|
|
39
|
+ const process = function*() {
|
|
|
40
|
+ let resData = {};
|
|
|
41
|
+ let result = yield this.get({
|
|
|
42
|
+ data: {
|
|
|
43
|
+ method: 'web.complaints.getList',
|
|
|
44
|
+ uid: uid,
|
|
|
45
|
+ page: page,
|
|
|
46
|
+ limit: limit
|
|
|
47
|
+ },
|
|
|
48
|
+ param: {
|
|
|
49
|
+ cache: 200
|
|
|
50
|
+ }
|
|
|
51
|
+ });
|
67
|
|
52
|
|
68
|
- resData.pager = Object.assign({
|
|
|
69
|
- count: _.get(result, 'data.total', 0),
|
|
|
70
|
- curPage: page,
|
|
|
71
|
- totalPages: _.get(result, 'data.page_total', 0)
|
|
|
72
|
- }, setPager(_.get(result, 'data.page_total', 0), {
|
|
|
73
|
- page: page
|
|
|
74
|
- }));
|
53
|
+ if (!_.isEmpty(result.data)) {
|
|
|
54
|
+ let list = [];
|
|
|
55
|
+
|
|
|
56
|
+ _.forEach(_.get(result, 'data.complaintList', []), value => {
|
|
|
57
|
+ list.push({
|
|
|
58
|
+ id: value.id,
|
|
|
59
|
+ title: value.title,
|
|
|
60
|
+ target: value.customer,
|
|
|
61
|
+ type: complaintType[value.complaintsType],
|
|
|
62
|
+ order: value.orderCode,
|
|
|
63
|
+ time: value.createTime,
|
|
|
64
|
+ question: value.content,
|
|
|
65
|
+ reply: value.reply,
|
|
|
66
|
+ replyTime: value.replyTime,
|
|
|
67
|
+ revoke: value.status === -1
|
|
|
68
|
+ });
|
|
|
69
|
+ });
|
75
|
|
70
|
|
76
|
- if (!_.get(resData, 'pager.pages[1]')) {
|
|
|
77
|
- _.unset(resData, 'pager.pages');
|
71
|
+ if (_.isEmpty(list)) {
|
|
|
72
|
+ resData.complaints = {empty: '您尚未投诉任何内容'};
|
|
|
73
|
+ } else {
|
|
|
74
|
+ resData.complaints = list;
|
|
|
75
|
+ }
|
|
|
76
|
+
|
|
|
77
|
+ resData.pager = Object.assign({
|
|
|
78
|
+ count: _.get(result, 'data.total', 0),
|
|
|
79
|
+ curPage: page,
|
|
|
80
|
+ totalPages: _.get(result, 'data.page_total', 0)
|
|
|
81
|
+ }, setPager(_.get(result, 'data.page_total', 0), {
|
|
|
82
|
+ page: page
|
|
|
83
|
+ }));
|
|
|
84
|
+
|
|
|
85
|
+ if (!_.get(resData, 'pager.pages[1]')) {
|
|
|
86
|
+ _.unset(resData, 'pager.pages');
|
|
|
87
|
+ }
|
78
|
}
|
88
|
}
|
79
|
- }
|
|
|
80
|
-
|
|
|
81
|
- return resData;
|
|
|
82
|
- };
|
|
|
83
|
-
|
|
|
84
|
- return co(process)();
|
|
|
85
|
-};
|
|
|
86
|
|
89
|
|
87
|
-/**
|
|
|
88
|
- * 添加投诉
|
|
|
89
|
- * @function addComplaints
|
|
|
90
|
- * @param { Number } uid 用户uid
|
|
|
91
|
- * @param { Object } params 投诉内容信息
|
|
|
92
|
- * @return { Object } 添加投诉结果
|
|
|
93
|
- */
|
|
|
94
|
-const addComplaints = (uid, params) => {
|
|
|
95
|
- return api.post('', {
|
|
|
96
|
- method: 'web.complaints.add',
|
|
|
97
|
- uid: uid,
|
|
|
98
|
- title: _.trim(params.title),
|
|
|
99
|
- customer: _.trim(params.customer),
|
|
|
100
|
- complaintsType: _.trim(params.complaintsType),
|
|
|
101
|
- orderCode: _.trim(params.orderCode),
|
|
|
102
|
- content: _.trim(params.content)
|
|
|
103
|
- });
|
|
|
104
|
-};
|
|
|
105
|
-
|
|
|
106
|
-/**
|
|
|
107
|
- * 撤销投诉
|
|
|
108
|
- * @function addComplaints
|
|
|
109
|
- * @param { Number } uid 用户uid
|
|
|
110
|
- * @param { Number } id 投诉id
|
|
|
111
|
- * @return { Object } 撤销投诉结果
|
|
|
112
|
- */
|
|
|
113
|
-const cancelComplaints = (uid, id) => {
|
|
|
114
|
- return api.post('', {
|
|
|
115
|
- method: 'web.complaints.cancel',
|
|
|
116
|
- uid: uid,
|
|
|
117
|
- id: id
|
|
|
118
|
- });
|
|
|
119
|
-};
|
|
|
120
|
-
|
|
|
121
|
-module.exports = {
|
|
|
122
|
- getComplaintsList,
|
|
|
123
|
- addComplaints,
|
|
|
124
|
- cancelComplaints
|
90
|
+ return resData;
|
|
|
91
|
+ };
|
|
|
92
|
+
|
|
|
93
|
+ return co(process)();
|
|
|
94
|
+ }
|
|
|
95
|
+
|
|
|
96
|
+ /**
|
|
|
97
|
+ * 添加投诉
|
|
|
98
|
+ * @function addComplaints
|
|
|
99
|
+ * @param { Number } uid 用户uid
|
|
|
100
|
+ * @param { Object } params 投诉内容信息
|
|
|
101
|
+ * @return { Object } 添加投诉结果
|
|
|
102
|
+ */
|
|
|
103
|
+ addComplaints(uid, params) {
|
|
|
104
|
+ return this.post({
|
|
|
105
|
+ data: {
|
|
|
106
|
+ method: 'web.complaints.add',
|
|
|
107
|
+ uid: uid,
|
|
|
108
|
+ title: _.trim(params.title),
|
|
|
109
|
+ customer: _.trim(params.customer),
|
|
|
110
|
+ complaintsType: _.trim(params.complaintsType),
|
|
|
111
|
+ orderCode: _.trim(params.orderCode),
|
|
|
112
|
+ content: _.trim(params.content)
|
|
|
113
|
+ }
|
|
|
114
|
+ });
|
|
|
115
|
+ }
|
|
|
116
|
+
|
|
|
117
|
+ /**
|
|
|
118
|
+ * 撤销投诉
|
|
|
119
|
+ * @function addComplaints
|
|
|
120
|
+ * @param { Number } uid 用户uid
|
|
|
121
|
+ * @param { Number } id 投诉id
|
|
|
122
|
+ * @return { Object } 撤销投诉结果
|
|
|
123
|
+ */
|
|
|
124
|
+ cancelComplaints(uid, id) {
|
|
|
125
|
+ return this.post({
|
|
|
126
|
+ data: {
|
|
|
127
|
+ method: 'web.complaints.cancel',
|
|
|
128
|
+ uid: uid,
|
|
|
129
|
+ id: id
|
|
|
130
|
+ }
|
|
|
131
|
+ });
|
|
|
132
|
+ }
|
125
|
}; |
133
|
}; |