/var/www/qr4y.com/server/delivery/api/responseModels/order
Edit: /var/www/qr4y.com/server/delivery/api/responseModels/order/orderHeaderOperators.model.js (4614B)
const { isSet } = require('../../utils/validator.util')
const UserShortModel = require('../user/userShort.model')
module.exports = class OrderHeaderOperators {
constructor({
id,
number,
remoteNumber,
branchId,
companyId,
driverId,
userId,
operatorId,
status,
comment,
discount,
rate,
tax,
bag,
tips,
total,
order_cost,
delivery_cost,
prepare_time,
delivery_time,
delivery_distance,
branch,
company,
payType,
payTypeId,
deliveryServerId,
deliveryServerJson,
deliveryPayType,
deliveryPayTypeId,
deliveryType,
deliveryTypeId,
pay_status_order,
pay_status_delivery,
user,
operator,
driver,
orderAddress,
orderCancelCauseId,
orderCancelCause,
createdAt,
confirmedAt,
acceptAt,
reservAt,
readyAt,
deliveryAt,
arrivedAt,
payAt,
completeAt,
updatedAt,
no_plastic,
printed,
table,
orderWaiters,
orderItems
}) {
this.id = id || ''
this.number = number || ''
this.remoteNumber = remoteNumber || ''
this.comment = isSet(comment) ? comment : ''
this.phone =
isSet(user) && isSet(user.userPhones) ? '+' + user.userPhones[0].phone || '' : ''
this.orderCancelCauseId = orderCancelCauseId || ''
this.orderCancelCause = orderCancelCause ? orderCancelCause.name : ''
this.payTypeId = payTypeId ? payTypeId : ''
this.payTypeName = payType ? payType.name : ''
this.payTypeKey = payType ? payType.key : ''
this.deliveryServerId = deliveryServerId ? deliveryServerId : ''
this.deliveryServerJson = deliveryServerJson ? deliveryServerJson : ''
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 || 0
this.pay_status_delivery = pay_status_delivery || 0
this.status = status || ORDER_STATUS.NEW
this.discount = parseFloat(discount) || 0
this.tax = parseFloat(tax) || 0
this.bag = parseFloat(bag) || 0
this.tips = parseFloat(tips) || 0
this.total = parseFloat(total) || 0
this.order_cost = parseFloat(order_cost) || 0
this.delivery_cost = parseFloat(delivery_cost) || 0
this.delivery_distance = parseFloat(delivery_distance) || 0
this.prepare_time = prepare_time || 0
this.delivery_time = delivery_time || 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 || ''
this.branchName = isSet(branch) ? branch.name : ''
this.companyId = companyId || ''
this.companyName = isSet(company) ? company.name : ''
this.companyCurrency = isSet(company) ? company.currency : ''
this.rate = rate || 0
this.userId = userId || ''
this.userName = isSet(user) ? user.name : ''
this.userImage = isSet(user) ? user.image : ''
this.userPhone =
isSet(user)
&& isSet(user.userPhones[0])
&& isSet(user.userPhones[0].phone)
? user.userPhones[0].phone || ''
: ''
this.createdAt = isSet(createdAt) ? createdAt : ''
this.updatedAt = isSet(updatedAt) ? updatedAt : ''
this.reservAt = isSet(reservAt) ? reservAt : ''
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.operatorId = operatorId || ''
this.operatorName = operator?.name || ''
this.operatorPhone =
isSet(operator)
&& isSet(operator.userPhones[0])
&& isSet(operator.userPhones[0].phone)
? operator.userPhones[0].phone || ''
: ''
this.driverId = driverId || 0
this.driverName = driver?.user?.name || ''
this.driverPhone =
isSet(driver) && isSet(driver.user)
&& isSet(driver.user.userPhones[0])
&& isSet(driver.user.userPhones[0].phone)
? driver.user.userPhones[0].phone || ''
: ''
this.no_plastic = no_plastic || false
this.printed = printed || false
this.table = table || {}
this.orderItems = orderItems || {}
this.orderWaiters = orderWaiters
? orderWaiters.map((w) => {
return new UserShortModel(w)
})
: []
}
}