我正在研究使用Crystal Report和Crystal语法将数字转换为单词的任务。 我使用下面的代码在<100K的任何金额上都做得很好,但是面临金额> 100K的问题(以VN货币计算,我们甚至可以转换数十亿的奇数,而不仅仅是1万或数百万)。有人能帮我找到解决这个问题的方法吗? 预先感谢您的帮助。
app.post('/api/reservations', (req, res) => {
const resDate = new Date(req.body.reservationDate).toISOString();
const queryDate = new Date(req.body.reservationDate);
const tableDict = req.body.tableDict;
const slot = req.body.timeSlot;
const seats = req.body.seats;
const restaurant = req.body.restaurant;
const customer = req.body.customer;
const comment = req.body.comment;
function gteQueryDate(date) {
return date.toISOString();
}
function lteQueryDate(date) {
date.setDate(date.getDate() + 1);
return date.toISOString();
}
const gteDate = gteQueryDate(queryDate);
const lteDate = lteQueryDate(queryDate);
const sortedTables = [];
for (i = 0; i < tableDict[slot].length - 1; i++) {
if (tableDict[slot][i] !== null && tableDict[slot][i].seats >= seats) {
sortedTables.push([tableDict[slot][i]._id, tableDict[slot][i].seats]);
}
}
sortedTables.sort(function(a, b) {
return a[1] - b[1];
});
var createReservation = function(tableId) {
console.log("called function with id : " + tableId);
Reservation.findOne({
'restaurant': restaurant,
'timeSlot.slot': slot,
'timeSlot.table': tableId,
'reservationDate': {
'$gte': gteDate,
'$lte': lteDate
}
})
.then(reservation => {
if (!reservation) {
console.log("can create reservation with id: " + tableId);
var timeSlot = [{
'slot': slot,
'table': tableId
}];
const newReservation = new Reservation({
seats: seats,
comment: comment,
timeSlot: timeSlot,
customer: customer,
restaurant: restaurant,
reservationDate: resDate
});
newReservation.save()
.then(result => {
res.send(result);
})
.catch(err => {
console.log(err);
});
} else {
console.log("reservation with id: " + tableId + " exists already.");
}
})
.catch(err => {
console.log(err);
});
}
for (j = 0; j < sortedTables.length; j++) {
var tableId = sortedTables[j][0];
createReservation(tableId);
}
});