alipay.service.js
942 Bytes
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
const alipayRepository = require('./alipay.repository');
const { logger } = global.yoho;
async function create({ uid, alipayAccount, alipayName }) {
try {
const result = await alipayRepository.insert({
uid, alipayAccount, alipayName
});
if (!result) {
return {
error: {
code: 500,
message: '服务器出错,请稍候再来提交'
}
};
}
return {
code: 200,
message: '提交成功'
};
} catch (e) {
if (e.code === 'ER_DUP_ENTRY') {
// 重复的情况
return {
error: {
code: 404,
message: '您已提交过支付宝信息,请不要重复提交!'
}
};
} else {
logger.error('mysql error =>', e);
return {
error: {
code: 500,
message: '服务器出错,请稍候再来提交'
}
};
}
}
}
module.exports = {
create
};