/var/www/qr4y.com/server/delivery/api/responseModels/order
Edit: /var/www/qr4y.com/server/delivery/api/responseModels/order/orderHeaderClients.model.js (3758B)
const { isSet } = require('../../utils/validator.util')
const UserShortModel = require('../user/userShort.model')
module.exports = class OrderHeaderClients {
constructor({
id,
number,
remoteNumber,
branchId,
companyId,
driverId,
userId,
status,
tax,
bag,
tips,
total,
branch,
company,
payType,
payTypeId,
rate,
prepare_time,
deliveryServerJson,
delivery_time,
delivery_distance,
delivery_cost,
deliveryPayType,
deliveryPayTypeId,
deliveryType,
deliveryTypeId,
pay_status_order,
pay_status_delivery,
user,
orderCancelCauseId,
orderCancelCause,
orderAddress,
createdAt,
updatedAt,
reservAt,
person_count,
confirmedAt,
acceptAt,
readyAt,
deliveryAt,
arrivedAt,
completeAt,
payAt,
no_plastic,
table,
orderItems,
orderWaiters
}) {
this.id = id || ''
this.number = number || ''
this.remoteNumber = remoteNumber || ''
this.driverId = driverId || 0
this.phone = isSet(user) && isSet(user.userPhones) ? '+'+user.userPhones[0].phone || '' : ''
this.orderCancelCauseId = orderCancelCauseId || 0
this.orderCancelCause = orderCancelCause ? orderCancelCause.name : ''
this.prepare_time = prepare_time ? prepare_time : 0
this.deliveryServerJson = deliveryServerJson ? deliveryServerJson : ''
this.delivery_time = delivery_time ? delivery_time : 0
this.delivery_distance = delivery_distance ? delivery_distance : 0
this.delivery_cost = delivery_cost ? delivery_cost : 0
this.payTypeId = payTypeId ? payTypeId : 0
this.payTypeName = payType ? payType.name : ''
this.deliveryPayTypeId = deliveryPayTypeId ? deliveryPayTypeId : 0
this.deliveryPayTypeName = deliveryPayType ? deliveryPayType.name : ''
this.deliveryPayTypeKey = deliveryPayType ? deliveryPayType.key : ''
this.deliveryTypeId = deliveryTypeId ? deliveryTypeId : 0
this.deliveryTypeName = deliveryType ? deliveryType.name : ''
this.deliveryTypeKey = deliveryType ? deliveryType.key : ''
this.pay_status_order = pay_status_order || ORDER_PAY_STATUS.NOT_PAID
this.pay_status_delivery = pay_status_delivery || ORDER_PAY_STATUS_DELIVERY.NOT_PAID
this.status = status || ORDER_STATUS.NEW
this.tax = parseFloat(tax).toFixed(2) || 0
this.bag = parseFloat(bag).toFixed(2) || 0
this.tips = parseFloat(tips).toFixed(2) || 0
this.total = parseFloat(total).toFixed(2) || 0
this.address = isSet(orderAddress) ? orderAddress.adres : ''
this.latitude = isSet(orderAddress) ? parseFloat(orderAddress.latitude) : 0
this.longtitude = isSet(orderAddress) ? parseFloat(orderAddress.longtitude) : 0
this.branchId = branchId || 0
this.branchName = isSet(branch) ? branch.name : ''
this.companyId = companyId || 0
this.companyName = isSet(company) ? company.name : ''
this.companyImage = isSet(company)&&isSet(company.image) ? company.image : ''
this.companyCurrency = isSet(company) ? company.currency : ''
this.rate = rate || 0
this.no_plastic = no_plastic || false
this.userId = userId || 0
this.createdAt = createdAt || ''
this.updatedAt = updatedAt || ''
this.reservAt = isSet(reservAt) ? reservAt : ''
this.person_count = person_count || '1'
this.confirmedAt = isSet(confirmedAt) ? confirmedAt : ''
this.acceptAt = isSet(acceptAt) ? acceptAt : ''
this.readyAt = isSet(readyAt) ? readyAt : ''
this.deliveryAt = isSet(deliveryAt) ? deliveryAt : ''
this.arrivedAt = isSet(arrivedAt) ? arrivedAt : ''
this.completeAt = isSet(completeAt) ? completeAt : ''
this.payAt = isSet(payAt) ? payAt : ''
this.userName = isSet(user) ? user.name : ''
this.table = table || {}
this.orderItems = orderItems || {}
this.orderWaiters = orderWaiters
? orderWaiters.map((w) => {
return new UserShortModel(w)
})
: []
}
}