feat: add discount source column to transaction tables
fix: move individual discounts to phone code response instead of poller
This commit is contained in:
parent
e837ee3e7a
commit
b0fa62a9f3
6 changed files with 32 additions and 12 deletions
|
|
@ -11,6 +11,7 @@ const httpError = require('../route-helpers').httpError
|
|||
const plugins = require('../plugins')
|
||||
const Tx = require('../tx')
|
||||
const respond = require('../respond')
|
||||
const loyalty = require('../loyalty')
|
||||
|
||||
function addOrUpdateCustomer (req) {
|
||||
const customerData = req.body
|
||||
|
|
@ -37,13 +38,18 @@ function addOrUpdateCustomer (req) {
|
|||
if (_.isEmpty(patch)) return customer
|
||||
return customers.update(customer.id, patch)
|
||||
})
|
||||
}).then(customer => {
|
||||
})
|
||||
.then(customer => {
|
||||
return Tx.customerHistory(customer.id, maxDaysThreshold)
|
||||
.then(result => {
|
||||
customer.txHistory = result
|
||||
return customer
|
||||
})
|
||||
})
|
||||
.then(customer => {
|
||||
return loyalty.getCustomerIndividualDiscounts(customer.id)
|
||||
.then(discount => ({ ...customer, discount }))
|
||||
})
|
||||
}
|
||||
|
||||
function getCustomerWithPhoneCode (req, res, next) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue