fix: login by new transaction receipt id
parent
54b9658075
commit
d612b6725a
|
@ -11,6 +11,7 @@ import {
|
||||||
} from '../models/queue.model';
|
} from '../models/queue.model';
|
||||||
import { QueueOrder } from '../../domain/entities/order.entity';
|
import { QueueOrder } from '../../domain/entities/order.entity';
|
||||||
import * as moment from 'moment';
|
import * as moment from 'moment';
|
||||||
|
import { TransactionModel } from 'src/modules/transaction/transaction/data/models/transaction.model';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class TicketDataService extends BaseDataService<QueueTicket> {
|
export class TicketDataService extends BaseDataService<QueueTicket> {
|
||||||
|
@ -23,6 +24,9 @@ export class TicketDataService extends BaseDataService<QueueTicket> {
|
||||||
|
|
||||||
@InjectRepository(QueueItemModel, CONNECTION_NAME.DEFAULT)
|
@InjectRepository(QueueItemModel, CONNECTION_NAME.DEFAULT)
|
||||||
private item: Repository<QueueItemModel>,
|
private item: Repository<QueueItemModel>,
|
||||||
|
|
||||||
|
@InjectRepository(TransactionModel, CONNECTION_NAME.DEFAULT)
|
||||||
|
private transaction: Repository<TransactionModel>,
|
||||||
) {
|
) {
|
||||||
super(repo);
|
super(repo);
|
||||||
}
|
}
|
||||||
|
@ -36,13 +40,37 @@ export class TicketDataService extends BaseDataService<QueueTicket> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async loginQueue(id: string): Promise<QueueOrder> {
|
async loginQueue(id: string): Promise<QueueOrder> {
|
||||||
return this.order.findOneOrFail({
|
const order = await this.order.findOne({
|
||||||
relations: ['tickets'],
|
relations: ['tickets'],
|
||||||
where: [
|
where: [
|
||||||
{ transaction_id: id },
|
{ transaction_id: id },
|
||||||
{ code: id, transaction_id: Not(IsNull()) },
|
{ code: id, transaction_id: Not(IsNull()) },
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!order) {
|
||||||
|
const { customer_name, customer_phone } =
|
||||||
|
await this.transaction.findOneOrFail({
|
||||||
|
where: {
|
||||||
|
id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const start = moment().startOf('day').valueOf();
|
||||||
|
const end = moment().endOf('day').valueOf();
|
||||||
|
const order = this.order.findOneOrFail({
|
||||||
|
relations: ['tickets'],
|
||||||
|
where: {
|
||||||
|
customer: customer_name,
|
||||||
|
phone: customer_phone,
|
||||||
|
date: Between(start, end),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return order;
|
||||||
|
}
|
||||||
|
|
||||||
|
return order;
|
||||||
}
|
}
|
||||||
|
|
||||||
async ticketByCode(code: string): Promise<QueueTicketModel[]> {
|
async ticketByCode(code: string): Promise<QueueTicketModel[]> {
|
||||||
|
|
Loading…
Reference in New Issue