partner.js
1.27 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
const moment = require('moment');
const config = require('komodo-sdk/config');
const logger = require('komodo-sdk/logger');
const matrix = require('komodo-sdk/matrix');
const pull = require('komodo-sdk/gateway/pull');
function buy(task) {
logger.verbose('Got task from CORE', {task: task});
const [remoteProduct, amount] = task.remote_product.split(/ *, */);
setTimeout(
() => {
if (task.destination % 2) {
pull.report({
trx_id: task.trx_id,
rc: '14',
message: `GAGAL karena nomor tujuan ${task.destination} adalah nomor ganjil`,
balance: config.supplier_ending_balance
});
}
else {
pull.report({
trx_id: task.trx_id,
rc: '00',
sn: moment().format('YYYYMMDDHHmmssSSS'),
amount: amount,
remote_product: remoteProduct,
message: `BERHASIL karena nomor tujuan ${task.destination} adalah nomor genap`,
balance: config.supplier_ending_balance
});
}
},
(config.max_result_timeout_ms || 2000) * Math.random()
)
}
exports.buy = buy;