fix: queue bucket item id
parent
28c1ab36da
commit
bf5914af92
|
@ -93,6 +93,9 @@ export class ItemModel
|
||||||
@JoinColumn({ name: 'item_queue_id' })
|
@JoinColumn({ name: 'item_queue_id' })
|
||||||
item_queue: ItemQueueModel;
|
item_queue: ItemQueueModel;
|
||||||
|
|
||||||
|
@Column('varchar', { name: 'item_queue_id', nullable: true })
|
||||||
|
item_queue_id: string;
|
||||||
|
|
||||||
// relation ke tenant
|
// relation ke tenant
|
||||||
// ? karena item bisajadi merupakan item dari tenant
|
// ? karena item bisajadi merupakan item dari tenant
|
||||||
@Column('varchar', { name: 'tenant_id', nullable: true })
|
@Column('varchar', { name: 'tenant_id', nullable: true })
|
||||||
|
|
|
@ -6,12 +6,16 @@ import { Between, Repository } from 'typeorm';
|
||||||
import { BaseReadService } from 'src/core/modules/data/service/base-read.service';
|
import { BaseReadService } from 'src/core/modules/data/service/base-read.service';
|
||||||
import { QueueBucketModel } from '../models/queue-bucket.model';
|
import { QueueBucketModel } from '../models/queue-bucket.model';
|
||||||
import * as moment from 'moment';
|
import * as moment from 'moment';
|
||||||
|
import { QueueItemModel } from '../models/queue.model';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class QueueBucketReadService extends BaseReadService<QueueBucketModel> {
|
export class QueueBucketReadService extends BaseReadService<QueueBucketModel> {
|
||||||
constructor(
|
constructor(
|
||||||
@InjectRepository(QueueBucketModel, CONNECTION_NAME.DEFAULT)
|
@InjectRepository(QueueBucketModel, CONNECTION_NAME.DEFAULT)
|
||||||
private repo: Repository<QueueBucketModel>,
|
private repo: Repository<QueueBucketModel>,
|
||||||
|
|
||||||
|
@InjectRepository(QueueItemModel, CONNECTION_NAME.DEFAULT)
|
||||||
|
private item: Repository<QueueItemModel>,
|
||||||
) {
|
) {
|
||||||
super(repo);
|
super(repo);
|
||||||
}
|
}
|
||||||
|
@ -20,9 +24,16 @@ export class QueueBucketReadService extends BaseReadService<QueueBucketModel> {
|
||||||
const start = moment().startOf('day').valueOf();
|
const start = moment().startOf('day').valueOf();
|
||||||
const end = moment().endOf('day').valueOf();
|
const end = moment().endOf('day').valueOf();
|
||||||
|
|
||||||
|
const queueItem = await this.item.findOne({
|
||||||
|
relations: ['item'],
|
||||||
|
where: {
|
||||||
|
id: item_id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const queue = await this.repo.findOne({
|
const queue = await this.repo.findOne({
|
||||||
where: {
|
where: {
|
||||||
queue_item_id: item_id,
|
queue_item_id: queueItem.item.item_queue_id ?? queueItem.item.id,
|
||||||
date: Between(start, end),
|
date: Between(start, end),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -31,7 +42,7 @@ export class QueueBucketReadService extends BaseReadService<QueueBucketModel> {
|
||||||
const regularNumber = vip ? 0 : 1;
|
const regularNumber = vip ? 0 : 1;
|
||||||
const vipNumber = vip ? 1 : 0;
|
const vipNumber = vip ? 1 : 0;
|
||||||
this.repo.save({
|
this.repo.save({
|
||||||
queue_item_id: item_id,
|
queue_item_id: queueItem.item.item_queue_id ?? queueItem.item.id,
|
||||||
date: start,
|
date: start,
|
||||||
regular: regularNumber,
|
regular: regularNumber,
|
||||||
vip: vipNumber,
|
vip: vipNumber,
|
||||||
|
|
Loading…
Reference in New Issue