fix: change coupons to promo codes
This commit is contained in:
parent
840afa866d
commit
59cb33570b
8 changed files with 87 additions and 88 deletions
|
|
@ -25,7 +25,7 @@ const E = require('./error')
|
|||
const customers = require('./customers')
|
||||
const logs = require('./logs')
|
||||
const compliance = require('./compliance')
|
||||
const couponManager = require('./coupons')
|
||||
const promoCodes = require('./promo-codes')
|
||||
const BN = require('./bn')
|
||||
const commissionMath = require('./commission-math')
|
||||
|
||||
|
|
@ -216,15 +216,15 @@ function verifyTx (req, res, next) {
|
|||
.catch(next)
|
||||
}
|
||||
|
||||
function verifyCoupon (req, res, next) {
|
||||
couponManager.getCoupon(req.body.codeInput)
|
||||
.then(coupon => {
|
||||
if (!coupon) return next()
|
||||
function verifyPromoCode (req, res, next) {
|
||||
promoCodes.getPromoCode(req.body.codeInput)
|
||||
.then(promoCode => {
|
||||
if (!promoCode) return next()
|
||||
|
||||
const transaction = req.body.tx
|
||||
const commissions = configManager.getCommissions(transaction.cryptoCode, req.deviceId, req.settings.config)
|
||||
const tickerRate = BN(transaction.rawTickerPrice)
|
||||
const discount = commissionMath.getDiscountRate(coupon.discount, commissions[transaction.direction])
|
||||
const discount = commissionMath.getDiscountRate(promoCode.discount, commissions[transaction.direction])
|
||||
const rates = {
|
||||
[transaction.cryptoCode]: {
|
||||
[transaction.direction]: (transaction.direction === 'cashIn')
|
||||
|
|
@ -234,7 +234,7 @@ function verifyCoupon (req, res, next) {
|
|||
}
|
||||
|
||||
respond(req, res, {
|
||||
coupon: coupon,
|
||||
promoCode: promoCode,
|
||||
newRates: rates
|
||||
})
|
||||
})
|
||||
|
|
@ -479,7 +479,7 @@ const configRequiredRoutes = [
|
|||
'/phone_code',
|
||||
'/customer',
|
||||
'/tx',
|
||||
'/verify_coupon'
|
||||
'/verify_promo_code'
|
||||
]
|
||||
|
||||
const app = express()
|
||||
|
|
@ -506,7 +506,7 @@ app.post('/state', stateChange)
|
|||
|
||||
app.post('/verify_user', verifyUser)
|
||||
app.post('/verify_transaction', verifyTx)
|
||||
app.post('/verify_coupon', verifyCoupon)
|
||||
app.post('/verify_promo_code', verifyPromoCode)
|
||||
|
||||
app.post('/phone_code', getCustomerWithPhoneCode)
|
||||
app.patch('/customer/:id', updateCustomer)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue