Commit a763dfeea0629a6ca6397ec7a41e5e79205d7469
1 parent
102e390547
Exists in
master
amount
Showing 1 changed file with 4 additions and 4 deletions Inline Diff
lib/partner.js
1 | "use strict"; | ||
2 | |||
3 | const moment = require('moment'); | 1 | const moment = require('moment'); |
4 | 2 | ||
5 | const config = require('komodo-sdk/config'); | 3 | const config = require('komodo-sdk/config'); |
6 | const logger = require('komodo-sdk/logger'); | 4 | const logger = require('komodo-sdk/logger'); |
7 | const matrix = require('komodo-sdk/matrix'); | 5 | const matrix = require('komodo-sdk/matrix'); |
8 | const pull = require('komodo-sdk/gateway/pull'); | 6 | const pull = require('komodo-sdk/gateway/pull'); |
9 | 7 | ||
10 | function buy(task) { | 8 | function buy(task) { |
11 | logger.verbose('Got task from CORE', {task: task}); | 9 | logger.verbose('Got task from CORE', {task: task}); |
10 | const [remoteProduct, amount] = task.remote_product.split(/ *, */); | ||
12 | 11 | ||
13 | setTimeout( | 12 | setTimeout( |
14 | function() { | 13 | () => { |
15 | if (task.destination % 2) { | 14 | if (task.destination % 2) { |
16 | pull.report({ | 15 | pull.report({ |
17 | trx_id: task.trx_id, | 16 | trx_id: task.trx_id, |
18 | rc: '14', | 17 | rc: '14', |
19 | message: `GAGAL karena nomor tujuan ${task.destination} adalah nomor ganjil`, | 18 | message: `GAGAL karena nomor tujuan ${task.destination} adalah nomor ganjil`, |
20 | balance: config.supplier_ending_balance | 19 | balance: config.supplier_ending_balance |
21 | }); | 20 | }); |
22 | } | 21 | } |
23 | else { | 22 | else { |
24 | pull.report({ | 23 | pull.report({ |
25 | trx_id: task.trx_id, | 24 | trx_id: task.trx_id, |
26 | rc: '00', | 25 | rc: '00', |
27 | sn: moment().format('YYYYMMDDHHmmssSSS'), | 26 | sn: moment().format('YYYYMMDDHHmmssSSS'), |
27 | amount: amount, | ||
28 | remote_product: remoteProduct, | ||
28 | message: `BERHASIL karena nomor tujuan ${task.destination} adalah nomor genap`, | 29 | message: `BERHASIL karena nomor tujuan ${task.destination} adalah nomor genap`, |
29 | amount: config.supplier_price ? config.supplier_price[task.product] : null, | ||
30 | balance: config.supplier_ending_balance | 30 | balance: config.supplier_ending_balance |
31 | }); | 31 | }); |
32 | } | 32 | } |
33 | 33 | ||
34 | }, | 34 | }, |
35 | (config.max_result_timeout_ms || 2000) * Math.random() | 35 | (config.max_result_timeout_ms || 2000) * Math.random() |
36 | ) | 36 | ) |
37 | } | 37 | } |