Compare commits
1 Commits
developmen
...
pos/eiger
Author | SHA1 | Date |
---|---|---|
|
90d1548c0b |
104
.drone.yml
104
.drone.yml
|
@ -2,42 +2,44 @@ kind: pipeline
|
||||||
type: docker
|
type: docker
|
||||||
name: server
|
name: server
|
||||||
steps:
|
steps:
|
||||||
# - name: build
|
- name: build
|
||||||
# image: appleboy/drone-ssh
|
image: appleboy/drone-ssh
|
||||||
# settings:
|
|
||||||
# host:
|
|
||||||
# - 172.10.10.10
|
|
||||||
# username: eigen
|
|
||||||
# key:
|
|
||||||
# from_secret: DEVOPS_SSH_PRIVATE_OPEN
|
|
||||||
# port: 22
|
|
||||||
# script:
|
|
||||||
# - cd /home/eigen/PROJECT/POS/POS.DEV/BE
|
|
||||||
# - sh build.sh
|
|
||||||
# when:
|
|
||||||
# ref:
|
|
||||||
# - refs/tags/devel_*
|
|
||||||
# - refs/tags/*-alpha.*
|
|
||||||
- name: build-testing
|
|
||||||
image: plugins/docker
|
|
||||||
settings:
|
settings:
|
||||||
registry: registry.eigen.co.id
|
host:
|
||||||
repo: registry.eigen.co.id/eigen/${DRONE_REPO_NAME}
|
- 172.10.10.10
|
||||||
tags: ${DRONE_TAG}
|
username: eigen
|
||||||
custom_dns: 172.10.10.16
|
key:
|
||||||
|
from_secret: DEVOPS_SSH_PRIVATE_OPEN
|
||||||
|
port: 22
|
||||||
|
script:
|
||||||
|
- cd /home/eigen/PROJECT/POS/POS.DEV/BE
|
||||||
|
- sh build.sh
|
||||||
when:
|
when:
|
||||||
ref:
|
ref:
|
||||||
|
- refs/tags/devel_*
|
||||||
- refs/tags/*-alpha.*
|
- refs/tags/*-alpha.*
|
||||||
- name: build-production
|
- name: build-production
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
settings:
|
settings:
|
||||||
registry: registry.eigen.co.id
|
registry: registry.eigen.co.id
|
||||||
repo: registry.eigen.co.id/eigen/${DRONE_REPO_NAME}
|
repo: registry.eigen.co.id/eigen/${DRONE_REPO_NAME}
|
||||||
|
build_args:
|
||||||
|
- env_target=env.production
|
||||||
tags: ${DRONE_TAG}
|
tags: ${DRONE_TAG}
|
||||||
custom_dns: 172.10.10.16
|
custom_dns: 172.10.10.16
|
||||||
when:
|
when:
|
||||||
ref:
|
ref:
|
||||||
- refs/tags/*-production.*
|
- refs/tags/*-production.*
|
||||||
|
- name: build-eiger-testing
|
||||||
|
image: plugins/docker
|
||||||
|
settings:
|
||||||
|
registry: registry.eigen.co.id
|
||||||
|
repo: registry.eigen.co.id/eigen/${DRONE_REPO_NAME}
|
||||||
|
tags: ${DRONE_TAG}
|
||||||
|
custom_dns: 172.10.10.16
|
||||||
|
when:
|
||||||
|
ref:
|
||||||
|
- refs/tags/*-eiger.testing
|
||||||
- name: send-message
|
- name: send-message
|
||||||
image: plugins/webhook
|
image: plugins/webhook
|
||||||
settings:
|
settings:
|
||||||
|
@ -50,60 +52,12 @@ steps:
|
||||||
"channel_id": "s1ekqde1c3du5p35g6budnuotc",
|
"channel_id": "s1ekqde1c3du5p35g6budnuotc",
|
||||||
"message": "Build {{repo.name}} sudah selesai"
|
"message": "Build {{repo.name}} sudah selesai"
|
||||||
}
|
}
|
||||||
|
when:
|
||||||
|
ref:
|
||||||
|
- refs/tags/*-eiger.testing
|
||||||
|
- refs/tags/*-production.*
|
||||||
|
- refs/tags/*-alpha.*
|
||||||
trigger:
|
trigger:
|
||||||
event:
|
event:
|
||||||
exclude:
|
exclude:
|
||||||
- promote
|
- promote
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
type: docker
|
|
||||||
name: kustomize
|
|
||||||
|
|
||||||
clone:
|
|
||||||
disable: true
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: kustomize-testing
|
|
||||||
image: registry.k8s.io/kustomize/kustomize:v5.0.0
|
|
||||||
environment:
|
|
||||||
DEVOPS_SSH_PRIVATE:
|
|
||||||
from_secret: DEVOPS_SSH_PRIVATE
|
|
||||||
DEVOPS_SSH_PUBLIC:
|
|
||||||
from_secret: DEVOPS_SSH_PUBLIC
|
|
||||||
INFRASTRUCTURE_REPO: "k8s-kustomize-external"
|
|
||||||
DIRECTORY_NAME: "weplay-pos-testing"
|
|
||||||
commands:
|
|
||||||
- mkdir -p ~/.ssh &&
|
|
||||||
- echo $DEVOPS_SSH_PRIVATE | base64 -d > ~/.ssh/id_rsa &&
|
|
||||||
- echo $DEVOPS_SSH_PUBLIC | base64 -d > ~/.ssh/id_rsa.pub &&
|
|
||||||
- ssh-keyscan -H -p 2222 git.eigen.co.id >> ~/.ssh/known_hosts &&
|
|
||||||
- chmod 700 ~/.ssh/ &&
|
|
||||||
- chmod 600 ~/.ssh/id_rsa &&
|
|
||||||
- git clone ssh://git@git.eigen.co.id:2222/eigen/$INFRASTRUCTURE_REPO.git &&
|
|
||||||
- cd $INFRASTRUCTURE_REPO/$DIRECTORY_NAME
|
|
||||||
- kustomize edit set image registry.eigen.co.id/eigen/$DRONE_REPO_NAME=registry.eigen.co.id/eigen/$DRONE_REPO_NAME:$DRONE_TAG &&
|
|
||||||
- git add . &&
|
|
||||||
- |-
|
|
||||||
git commit -m "feat: update $DRONE_REPO_NAME testing to $DRONE_TAG" &&
|
|
||||||
- git push origin master
|
|
||||||
- name: send-message
|
|
||||||
image: harbor.eigen.co.id/docker.com/plugins/webhook
|
|
||||||
settings:
|
|
||||||
urls: https://mattermost.eigen.co.id/api/v4/posts
|
|
||||||
content_type: application/json
|
|
||||||
headers:
|
|
||||||
- Authorization=Bearer 5zubexudb38uuradfa36qy98ca
|
|
||||||
template: |
|
|
||||||
{
|
|
||||||
"channel_id": "s1ekqde1c3du5p35g6budnuotc",
|
|
||||||
"message": "ALERT: {{ repo.name }} gagal update dengan tag ${DRONE_TAG}"
|
|
||||||
}
|
|
||||||
when:
|
|
||||||
status:
|
|
||||||
- failure
|
|
||||||
trigger:
|
|
||||||
ref:
|
|
||||||
include:
|
|
||||||
- refs/tags/*-alpha.*
|
|
||||||
depends_on:
|
|
||||||
- server
|
|
|
@ -43,7 +43,4 @@ GOOGLE_CALENDAR_ID="326464ac296874c7121825f5ef2e2799baa90b51da240f0045aae22beec1
|
||||||
|
|
||||||
SUPERSET_URL=https://dashboard.weplayground.eigen.co.id
|
SUPERSET_URL=https://dashboard.weplayground.eigen.co.id
|
||||||
SUPERSET_ADMIN_USERNAME=admin
|
SUPERSET_ADMIN_USERNAME=admin
|
||||||
SUPERSET_ADMIN_PASSWORD=admin
|
SUPERSET_ADMIN_PASSWORD=admin
|
||||||
|
|
||||||
WHATSAPP_BUSINESS_ACCOUNT_NUMBER_ID=604883366037548
|
|
||||||
WHATSAPP_BUSINESS_ACCESS_TOKEN=EAAINOvRRiEEBO9yQsYDnYtjHZB7q1nZCwbBpRcxIGMDWajKZBtmWxNRKvPYkS95KQZBsZBOvSFyjiEg5CcCZBZBtaSZApxyV8fiA3cEyVwf7iVZBQP2YCTPRQZArMFeeXbO0uq5TGygmjsIz3M4YxcUHxPzKO4pKxIyxnzcoUZCqCSo1NqQSLVf3a0JyZAwgDXGL55dV
|
|
|
@ -40,7 +40,4 @@ GOOGLE_CALENDAR_ID="326464ac296874c7121825f5ef2e2799baa90b51da240f0045aae22beec1
|
||||||
|
|
||||||
SUPERSET_URL=https://dashboard.weplayground.eigen.co.id
|
SUPERSET_URL=https://dashboard.weplayground.eigen.co.id
|
||||||
SUPERSET_ADMIN_USERNAME=admin
|
SUPERSET_ADMIN_USERNAME=admin
|
||||||
SUPERSET_ADMIN_PASSWORD=admin
|
SUPERSET_ADMIN_PASSWORD=admin
|
||||||
|
|
||||||
WHATSAPP_BUSINESS_ACCOUNT_NUMBER_ID=604883366037548
|
|
||||||
WHATSAPP_BUSINESS_ACCESS_TOKEN=EAAINOvRRiEEBO9yQsYDnYtjHZB7q1nZCwbBpRcxIGMDWajKZBtmWxNRKvPYkS95KQZBsZBOvSFyjiEg5CcCZBZBtaSZApxyV8fiA3cEyVwf7iVZBQP2YCTPRQZArMFeeXbO0uq5TGygmjsIz3M4YxcUHxPzKO4pKxIyxnzcoUZCqCSo1NqQSLVf3a0JyZAwgDXGL55dV
|
|
|
@ -49,7 +49,6 @@
|
||||||
"exceljs": "^4.4.0",
|
"exceljs": "^4.4.0",
|
||||||
"fs-extra": "^11.2.0",
|
"fs-extra": "^11.2.0",
|
||||||
"googleapis": "^140.0.0",
|
"googleapis": "^140.0.0",
|
||||||
"gtts": "^0.2.1",
|
|
||||||
"handlebars": "^4.7.8",
|
"handlebars": "^4.7.8",
|
||||||
"mathjs": "^13.0.2",
|
"mathjs": "^13.0.2",
|
||||||
"midtrans-client": "^1.3.1",
|
"midtrans-client": "^1.3.1",
|
||||||
|
|
|
@ -45,10 +45,8 @@ import { GoogleCalendarModule } from './modules/configuration/google-calendar/go
|
||||||
import { TransactionModule } from './modules/transaction/transaction/transaction.module';
|
import { TransactionModule } from './modules/transaction/transaction/transaction.module';
|
||||||
import { TransactionModel } from './modules/transaction/transaction/data/models/transaction.model';
|
import { TransactionModel } from './modules/transaction/transaction/data/models/transaction.model';
|
||||||
import {
|
import {
|
||||||
TransactionBreakdownTaxModel,
|
|
||||||
TransactionItemBreakdownModel,
|
TransactionItemBreakdownModel,
|
||||||
TransactionItemModel,
|
TransactionItemModel,
|
||||||
TransactionItemTaxModel,
|
|
||||||
} from './modules/transaction/transaction/data/models/transaction-item.model';
|
} from './modules/transaction/transaction/data/models/transaction-item.model';
|
||||||
import { TransactionTaxModel } from './modules/transaction/transaction/data/models/transaction-tax.model';
|
import { TransactionTaxModel } from './modules/transaction/transaction/data/models/transaction-tax.model';
|
||||||
import { ReconciliationModule } from './modules/transaction/reconciliation/reconciliation.module';
|
import { ReconciliationModule } from './modules/transaction/reconciliation/reconciliation.module';
|
||||||
|
@ -82,17 +80,6 @@ import { GateScanModule } from './modules/gates/gate.module';
|
||||||
import { UserLoginModel } from './modules/user-related/user/data/models/user-login.model';
|
import { UserLoginModel } from './modules/user-related/user/data/models/user-login.model';
|
||||||
import { LogUserLoginModel } from './modules/configuration/log/data/models/log-user-login.model';
|
import { LogUserLoginModel } from './modules/configuration/log/data/models/log-user-login.model';
|
||||||
import { AuthService } from './core/guards/domain/services/auth.service';
|
import { AuthService } from './core/guards/domain/services/auth.service';
|
||||||
import { ReportSummaryModule } from './modules/reports/report-summary/report-summary.module';
|
|
||||||
import { QueueModule } from './modules/queue/queue.module';
|
|
||||||
import {
|
|
||||||
QueueOrderModel,
|
|
||||||
QueueTicketModel,
|
|
||||||
QueueItemModel,
|
|
||||||
QueueModel,
|
|
||||||
} from './modules/queue/data/models/queue.model';
|
|
||||||
import { ItemQueueModule } from './modules/item-related/item-queue/item-queue.module';
|
|
||||||
import { ItemQueueModel } from './modules/item-related/item-queue/data/models/item-queue.model';
|
|
||||||
import { QueueBucketModel } from './modules/queue/data/models/queue-bucket.model';
|
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
|
@ -117,7 +104,6 @@ import { QueueBucketModel } from './modules/queue/data/models/queue-bucket.model
|
||||||
ItemModel,
|
ItemModel,
|
||||||
ItemCategoryModel,
|
ItemCategoryModel,
|
||||||
ItemRateModel,
|
ItemRateModel,
|
||||||
ItemQueueModel,
|
|
||||||
LogModel,
|
LogModel,
|
||||||
LogUserLoginModel,
|
LogUserLoginModel,
|
||||||
NewsModel,
|
NewsModel,
|
||||||
|
@ -135,8 +121,6 @@ import { QueueBucketModel } from './modules/queue/data/models/queue-bucket.model
|
||||||
TransactionTaxModel,
|
TransactionTaxModel,
|
||||||
TransactionDemographyModel,
|
TransactionDemographyModel,
|
||||||
TransactionItemBreakdownModel,
|
TransactionItemBreakdownModel,
|
||||||
TransactionItemTaxModel,
|
|
||||||
TransactionBreakdownTaxModel,
|
|
||||||
UserModel,
|
UserModel,
|
||||||
UserLoginModel,
|
UserLoginModel,
|
||||||
|
|
||||||
|
@ -146,13 +130,6 @@ import { QueueBucketModel } from './modules/queue/data/models/queue-bucket.model
|
||||||
// report
|
// report
|
||||||
ReportBookmarkModel,
|
ReportBookmarkModel,
|
||||||
ExportReportHistoryModel,
|
ExportReportHistoryModel,
|
||||||
|
|
||||||
// Queue
|
|
||||||
QueueOrderModel,
|
|
||||||
QueueTicketModel,
|
|
||||||
QueueItemModel,
|
|
||||||
QueueModel,
|
|
||||||
QueueBucketModel,
|
|
||||||
],
|
],
|
||||||
synchronize: false,
|
synchronize: false,
|
||||||
}),
|
}),
|
||||||
|
@ -178,7 +155,6 @@ import { QueueBucketModel } from './modules/queue/data/models/queue-bucket.model
|
||||||
ItemCategoryModule,
|
ItemCategoryModule,
|
||||||
ItemModule,
|
ItemModule,
|
||||||
ItemRateModule,
|
ItemRateModule,
|
||||||
ItemQueueModule,
|
|
||||||
|
|
||||||
// transaction
|
// transaction
|
||||||
PaymentMethodModule,
|
PaymentMethodModule,
|
||||||
|
@ -206,14 +182,11 @@ import { QueueBucketModel } from './modules/queue/data/models/queue-bucket.model
|
||||||
ReportModule,
|
ReportModule,
|
||||||
ReportBookmarkModule,
|
ReportBookmarkModule,
|
||||||
ReportExportModule,
|
ReportExportModule,
|
||||||
ReportSummaryModule,
|
|
||||||
|
|
||||||
// superset
|
// superset
|
||||||
SupersetModule,
|
SupersetModule,
|
||||||
|
|
||||||
GateScanModule,
|
GateScanModule,
|
||||||
|
|
||||||
QueueModule,
|
|
||||||
],
|
],
|
||||||
controllers: [],
|
controllers: [],
|
||||||
providers: [
|
providers: [
|
||||||
|
|
|
@ -8,9 +8,7 @@ import { diskStorage } from 'multer';
|
||||||
const MB = 1024 * 1024;
|
const MB = 1024 * 1024;
|
||||||
|
|
||||||
const fileFilter = (req, file, callback) => {
|
const fileFilter = (req, file, callback) => {
|
||||||
if (
|
if (file.mimetype.match(/\/(jpg|jpeg|png)$/)) {
|
||||||
file.mimetype.match(/\/(jpg|jpeg|png|flv|mp4|m3u8|ts|3gp|mov|avi|wmv)$/)
|
|
||||||
) {
|
|
||||||
callback(null, true);
|
callback(null, true);
|
||||||
} else {
|
} else {
|
||||||
callback(
|
callback(
|
||||||
|
|
|
@ -32,7 +32,7 @@ export abstract class BaseManager {
|
||||||
|
|
||||||
setUser() {
|
setUser() {
|
||||||
try {
|
try {
|
||||||
this.user = this.userProvider?.user ?? BLANK_USER;
|
this.user = this.userProvider?.user;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.user = BLANK_USER;
|
this.user = BLANK_USER;
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ export abstract class BaseCreateManager<Entity> extends BaseManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
async publishEvents() {
|
async publishEvents() {
|
||||||
this.eventBus?.publish(
|
this.eventBus.publish(
|
||||||
new RecordLog({
|
new RecordLog({
|
||||||
id: this.result['id'],
|
id: this.result['id'],
|
||||||
old: null,
|
old: null,
|
||||||
|
|
|
@ -50,7 +50,7 @@ export abstract class BaseIndexManager<Entity> extends BaseReadManager {
|
||||||
|
|
||||||
// jika searching status terdapat dalam enum, maka dia mencari specific data
|
// jika searching status terdapat dalam enum, maka dia mencari specific data
|
||||||
// ? karena jika tidak, ketika dia search "active" maka "inactive" juga ikut
|
// ? karena jika tidak, ketika dia search "active" maka "inactive" juga ikut
|
||||||
return `'${STATUS[statusData.toUpperCase()]}'`;
|
return `'${STATUS[statusData.toUpperCase()]}'` ?? `'%${statusData}%'`;
|
||||||
});
|
});
|
||||||
|
|
||||||
const exist = specificFilter.find((item) => item.isStatus);
|
const exist = specificFilter.find((item) => item.isStatus);
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
import { ValidateRelationHelper } from 'src/core/helpers/validation/validate-relation.helper';
|
import { ValidateRelationHelper } from 'src/core/helpers/validation/validate-relation.helper';
|
||||||
import { BaseManager } from '../base.manager';
|
import { BaseManager } from '../base.manager';
|
||||||
import {
|
import { OPERATION, STATUS } from 'src/core/strings/constants/base.constants';
|
||||||
OPERATION,
|
|
||||||
QUEUE_STATUS,
|
|
||||||
STATUS,
|
|
||||||
} from 'src/core/strings/constants/base.constants';
|
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
import { RecordLog } from 'src/modules/configuration/log/domain/entities/log.event';
|
import { RecordLog } from 'src/modules/configuration/log/domain/entities/log.event';
|
||||||
|
|
||||||
|
@ -12,12 +8,12 @@ export abstract class BaseUpdateStatusManager<Entity> extends BaseManager {
|
||||||
protected dataId: string;
|
protected dataId: string;
|
||||||
protected result: Entity;
|
protected result: Entity;
|
||||||
protected oldData: Entity;
|
protected oldData: Entity;
|
||||||
protected dataStatus: STATUS | QUEUE_STATUS;
|
protected dataStatus: STATUS;
|
||||||
protected relations = [];
|
protected relations = [];
|
||||||
protected duplicateColumn: string[];
|
protected duplicateColumn: string[];
|
||||||
abstract get entityTarget(): any;
|
abstract get entityTarget(): any;
|
||||||
|
|
||||||
setData(id: string, status: STATUS | QUEUE_STATUS): void {
|
setData(id: string, status: STATUS): void {
|
||||||
/**
|
/**
|
||||||
* // TODO: Handle case confirm multiple tabs;
|
* // TODO: Handle case confirm multiple tabs;
|
||||||
* Pola id yang dikirim dirubah menjadi data_id___updated_at
|
* Pola id yang dikirim dirubah menjadi data_id___updated_at
|
||||||
|
|
|
@ -23,7 +23,6 @@ export class BaseFilterDto implements BaseFilterEntity {
|
||||||
@IsNumber()
|
@IsNumber()
|
||||||
limit = 10;
|
limit = 10;
|
||||||
|
|
||||||
@ApiProperty({ type: String, required: false })
|
|
||||||
q: string;
|
q: string;
|
||||||
|
|
||||||
@ApiProperty({ type: ['string'], required: false })
|
@ApiProperty({ type: ['string'], required: false })
|
||||||
|
|
|
@ -6,6 +6,5 @@ export interface UsersSession {
|
||||||
name: string;
|
name: string;
|
||||||
role: UserRole;
|
role: UserRole;
|
||||||
source?: AppSource;
|
source?: AppSource;
|
||||||
item_id?: string;
|
|
||||||
user_privilege_id: string;
|
user_privilege_id: string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,11 +15,6 @@ export enum STATUS {
|
||||||
WAITING = 'waiting',
|
WAITING = 'waiting',
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum QUEUE_STATUS {
|
|
||||||
DONE = 'done',
|
|
||||||
CALLED = 'called',
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum ORDER_TYPE {
|
export enum ORDER_TYPE {
|
||||||
ASC = 'ASC',
|
ASC = 'ASC',
|
||||||
DESC = 'DESC',
|
DESC = 'DESC',
|
||||||
|
|
|
@ -4,7 +4,6 @@ export enum MODULE_NAME {
|
||||||
GATE = 'gates',
|
GATE = 'gates',
|
||||||
ITEM = 'items',
|
ITEM = 'items',
|
||||||
ITEM_CATEGORY = 'item-categories',
|
ITEM_CATEGORY = 'item-categories',
|
||||||
ITEM_QUEUE = 'item-queues',
|
|
||||||
ITEM_RATE = 'item-rates',
|
ITEM_RATE = 'item-rates',
|
||||||
NEWS = 'news',
|
NEWS = 'news',
|
||||||
PAYMENT_METHOD = 'payment-methods',
|
PAYMENT_METHOD = 'payment-methods',
|
||||||
|
@ -25,7 +24,4 @@ export enum MODULE_NAME {
|
||||||
REPORT = 'report',
|
REPORT = 'report',
|
||||||
REPORT_BOOKMARK = 'report-bookmark',
|
REPORT_BOOKMARK = 'report-bookmark',
|
||||||
REPORT_EXPORT = 'report-export',
|
REPORT_EXPORT = 'report-export',
|
||||||
REPORT_SUMMARY = 'report-summary',
|
|
||||||
|
|
||||||
QUEUE = 'queue',
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ export enum TABLE_NAME {
|
||||||
FAQ = 'faqs',
|
FAQ = 'faqs',
|
||||||
ITEM = 'items',
|
ITEM = 'items',
|
||||||
ITEM_CATEGORY = 'item_categories',
|
ITEM_CATEGORY = 'item_categories',
|
||||||
ITEM_QUEUE = 'item_queues',
|
|
||||||
ITEM_RATE = 'item_rates',
|
ITEM_RATE = 'item_rates',
|
||||||
GATE = 'gates',
|
GATE = 'gates',
|
||||||
LOG = 'logs',
|
LOG = 'logs',
|
||||||
|
@ -23,8 +22,6 @@ export enum TABLE_NAME {
|
||||||
TRANSACTION_ITEM = 'transaction_items',
|
TRANSACTION_ITEM = 'transaction_items',
|
||||||
TRANSACTION_ITEM_BREAKDOWN = 'transaction_item_breakdowns',
|
TRANSACTION_ITEM_BREAKDOWN = 'transaction_item_breakdowns',
|
||||||
TRANSACTION_TAX = 'transaction_taxes',
|
TRANSACTION_TAX = 'transaction_taxes',
|
||||||
TRANSACTION_ITEM_TAX = 'transaction_item_taxes',
|
|
||||||
TRANSACTION_ITEM_BREAKDOWN_TAX = 't_breakdown_item_taxes',
|
|
||||||
TRANSACTION_DEMOGRAPHY = 'transaction_demographies',
|
TRANSACTION_DEMOGRAPHY = 'transaction_demographies',
|
||||||
USER = 'users',
|
USER = 'users',
|
||||||
USER_LOGIN = 'users_login',
|
USER_LOGIN = 'users_login',
|
||||||
|
@ -36,10 +33,4 @@ export enum TABLE_NAME {
|
||||||
|
|
||||||
REPORT_BOOKMARK = 'report_bookmark',
|
REPORT_BOOKMARK = 'report_bookmark',
|
||||||
EXPORT_REPORT_HISTORY = 'export_report_history',
|
EXPORT_REPORT_HISTORY = 'export_report_history',
|
||||||
|
|
||||||
QUEUE = 'queues',
|
|
||||||
QUEUE_ORDER = 'queue_orders',
|
|
||||||
QUEUE_TICKET = 'queue_tickets',
|
|
||||||
QUEUE_ITEM = 'queue_items',
|
|
||||||
QUEUE_BUCKET = 'queue_bucket',
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ export class AddEstimationToItem1723801180604 implements MigrationInterface {
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
await queryRunner.query(
|
await queryRunner.query(
|
||||||
`ALTER TABLE "items" ADD "play_estimation" numeric`,
|
`ALTER TABLE "items" ADD "play_estimation" integer`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,73 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class AddTaxItemTransaction1726045820711 implements MigrationInterface {
|
|
||||||
name = 'AddTaxItemTransaction1726045820711';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`CREATE TABLE "transaction_item_taxes" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "tax_id" character varying, "tax_name" character varying, "taxt_value" numeric, "tax_total_value" numeric, "transaction_id" uuid, CONSTRAINT "PK_fc5f6da61b24eb5bfdd503b0a0d" PRIMARY KEY ("id"))`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`CREATE TABLE "t_breakdown_item_taxes" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "tax_id" character varying, "tax_name" character varying, "taxt_value" numeric, "tax_total_value" numeric, "transaction_id" uuid, CONSTRAINT "PK_a1ef08d2c68169a50102aa70eca" PRIMARY KEY ("id"))`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_items" ADD "total_profit_share" numeric`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_item_breakdowns" ADD "total_profit_share" numeric`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_item_taxes" ADD CONSTRAINT "FK_f5c4966a381d903899cafb4b5ba" FOREIGN KEY ("transaction_id") REFERENCES "transaction_items"("id") ON DELETE CASCADE ON UPDATE CASCADE`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "t_breakdown_item_taxes" ADD CONSTRAINT "FK_74bedce7e94f6707ddf26ef0c0f" FOREIGN KEY ("transaction_id") REFERENCES "transaction_item_breakdowns"("id") ON DELETE CASCADE ON UPDATE CASCADE`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_items" ADD "payment_total_dpp" numeric`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_item_breakdowns" ADD "payment_total_dpp" numeric`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_items" ADD "payment_total_tax" numeric`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_item_breakdowns" ADD "payment_total_tax" numeric`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_item_breakdowns" ADD "total_share_tenant" numeric`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "t_breakdown_item_taxes" DROP CONSTRAINT "FK_74bedce7e94f6707ddf26ef0c0f"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_item_taxes" DROP CONSTRAINT "FK_f5c4966a381d903899cafb4b5ba"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_item_breakdowns" DROP COLUMN "total_profit_share"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_items" DROP COLUMN "total_profit_share"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(`DROP TABLE "t_breakdown_item_taxes"`);
|
|
||||||
await queryRunner.query(`DROP TABLE "transaction_item_taxes"`);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_item_breakdowns" DROP COLUMN "payment_total_dpp"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_items" DROP COLUMN "payment_total_dpp"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_item_breakdowns" DROP COLUMN "payment_total_tax"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_items" DROP COLUMN "payment_total_tax"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_item_breakdowns" DROP COLUMN "total_share_tenant"`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class AddFormulaToTax1726365023179 implements MigrationInterface {
|
|
||||||
name = 'AddFormulaToTax1726365023179';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`ALTER TABLE "taxes" ADD "formula_render" json`);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "taxes" ADD "formula_string" character varying`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`ALTER TABLE "taxes" DROP COLUMN "formula_string"`);
|
|
||||||
await queryRunner.query(`ALTER TABLE "taxes" DROP COLUMN "formula_render"`);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,43 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class AddDiscountForItemTransaction1726824289989
|
|
||||||
implements MigrationInterface
|
|
||||||
{
|
|
||||||
name = 'AddDiscountForItemTransaction1726824289989';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_items" ADD "subtotal" numeric`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_items" ADD "discount_value" numeric`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_item_breakdowns" ADD "subtotal" numeric`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_item_breakdowns" ADD "discount_value" numeric`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_item_breakdowns" ADD "total_price" numeric`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_item_breakdowns" DROP COLUMN "total_price"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_item_breakdowns" DROP COLUMN "discount_value"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_item_breakdowns" DROP COLUMN "subtotal"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_items" DROP COLUMN "discount_value"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_items" DROP COLUMN "subtotal"`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class ChangeColumnName1726830293878 implements MigrationInterface {
|
|
||||||
name = 'ChangeColumnName1726830293878';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_items" RENAME COLUMN "subtotal" TO "total_net_price"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_item_breakdowns" RENAME COLUMN "subtotal" TO "total_net_price"`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_item_breakdowns" RENAME COLUMN "total_net_price" TO "subtotal"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_items" RENAME COLUMN "total_net_price" TO "subtotal"`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class AddDiscountValueToVoucher1728377112337
|
|
||||||
implements MigrationInterface
|
|
||||||
{
|
|
||||||
name = 'AddDiscountValueToVoucher1728377112337';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "vip_codes" ADD "discount_value" numeric`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "vip_codes" ALTER COLUMN "discount" DROP NOT NULL`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "vip_codes" ALTER COLUMN "discount" SET NOT NULL`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "vip_codes" DROP COLUMN "discount_value"`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class ItemVideoAndVipPass1729072422409 implements MigrationInterface {
|
|
||||||
name = 'ItemVideoAndVipPass1729072422409';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "items" ADD "video_url" character varying`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "vip_categories" ADD "has_vip_pass" boolean NOT NULL DEFAULT false`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "vip_categories" DROP COLUMN "has_vip_pass"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(`ALTER TABLE "items" DROP COLUMN "video_url"`);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,43 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class QueueTable1729151429165 implements MigrationInterface {
|
|
||||||
name = 'QueueTable1729151429165';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`CREATE TABLE "queue_orders" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "code" character varying NOT NULL, "customer" character varying, "phone" character varying, "date" bigint NOT NULL, CONSTRAINT "PK_b139e4cc9ca3e709c152f820d2e" PRIMARY KEY ("id"))`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`CREATE TABLE "queue_tickets" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "code" character varying NOT NULL, "customer" character varying, "phone" character varying, "date" bigint NOT NULL, "order_id" uuid, CONSTRAINT "PK_1b903aa90bcc04136caa6540c55" PRIMARY KEY ("id"))`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`CREATE TABLE "queue_items" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "qty" integer NOT NULL, "ticket_id" uuid, "item_id" uuid, CONSTRAINT "PK_2245e11ac3517494bacfe932773" PRIMARY KEY ("id"))`,
|
|
||||||
);
|
|
||||||
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "queue_tickets" ADD CONSTRAINT "FK_0e9823b8b7ca9523b3be73878e5" FOREIGN KEY ("order_id") REFERENCES "queue_orders"("id") ON DELETE SET NULL ON UPDATE CASCADE`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "queue_items" ADD CONSTRAINT "FK_25352739034765f6917757df74b" FOREIGN KEY ("ticket_id") REFERENCES "queue_tickets"("id") ON DELETE CASCADE ON UPDATE CASCADE`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "queue_items" ADD CONSTRAINT "FK_ab15c053aeb4f739ebf533b61cd" FOREIGN KEY ("item_id") REFERENCES "items"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "queue_items" DROP CONSTRAINT "FK_ab15c053aeb4f739ebf533b61cd"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "queue_items" DROP CONSTRAINT "FK_25352739034765f6917757df74b"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "queue_tickets" DROP CONSTRAINT "FK_0e9823b8b7ca9523b3be73878e5"`,
|
|
||||||
);
|
|
||||||
|
|
||||||
await queryRunner.query(`DROP TABLE "queue_items"`);
|
|
||||||
await queryRunner.query(`DROP TABLE "queue_tickets"`);
|
|
||||||
await queryRunner.query(`DROP TABLE "queue_orders"`);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class VideoUrlToJson1729248576381 implements MigrationInterface {
|
|
||||||
name = 'VideoUrlToJson1729248576381';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`ALTER TABLE "items" DROP COLUMN "video_url"`);
|
|
||||||
await queryRunner.query(`ALTER TABLE "items" ADD "video_url" json`);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`ALTER TABLE "items" DROP COLUMN "video_url"`);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "items" ADD "video_url" character varying`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(`DROP TABLE "item_queues"`);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class ItemQueues1729570177597 implements MigrationInterface {
|
|
||||||
name = 'ItemQueues1729570177597';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`CREATE TYPE "public"."item_queues_status_enum" AS ENUM('active', 'cancel', 'confirmed', 'draft', 'expired', 'inactive', 'partial refund', 'pending', 'proses refund', 'refunded', 'rejected', 'settled', 'waiting')`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`CREATE TYPE "public"."item_queues_item_type_enum" AS ENUM('tiket masuk', 'wahana', 'bundling', 'free gift', 'other')`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`CREATE TABLE "item_queues" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "creator_id" character varying(36), "creator_name" character varying(125), "editor_id" character varying(36), "editor_name" character varying(125), "created_at" bigint NOT NULL, "updated_at" bigint NOT NULL, "status" "public"."item_queues_status_enum" NOT NULL DEFAULT 'draft', "name" character varying NOT NULL, "item_type" "public"."item_queues_item_type_enum" NOT NULL DEFAULT 'tiket masuk', CONSTRAINT "PK_e19adb0b99d995e8f10c189985f" PRIMARY KEY ("id"))`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(`ALTER TABLE "items" ADD "item_queue_id" uuid`);
|
|
||||||
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "items" ADD CONSTRAINT "FK_2cbbeb03e176addcf60d65f7c9c" FOREIGN KEY ("item_queue_id") REFERENCES "item_queues"("id") ON DELETE CASCADE ON UPDATE CASCADE`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "items" DROP CONSTRAINT "FK_2cbbeb03e176addcf60d65f7c9c"`,
|
|
||||||
);
|
|
||||||
|
|
||||||
await queryRunner.query(`ALTER TABLE "items" DROP COLUMN "item_queue_id"`);
|
|
||||||
await queryRunner.query(`DROP TABLE "item_queues"`);
|
|
||||||
await queryRunner.query(`DROP TYPE "public"."item_queues_item_type_enum"`);
|
|
||||||
await queryRunner.query(`DROP TYPE "public"."item_queues_status_enum"`);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class ItemQueueOnDelete1729582398827 implements MigrationInterface {
|
|
||||||
name = 'ItemQueueOnDelete1729582398827';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "items" DROP CONSTRAINT "FK_2cbbeb03e176addcf60d65f7c9c"`,
|
|
||||||
);
|
|
||||||
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "items" ADD CONSTRAINT "FK_2cbbeb03e176addcf60d65f7c9c" FOREIGN KEY ("item_queue_id") REFERENCES "item_queues"("id") ON DELETE SET NULL ON UPDATE CASCADE`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "items" DROP CONSTRAINT "FK_2cbbeb03e176addcf60d65f7c9c"`,
|
|
||||||
);
|
|
||||||
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "items" ADD CONSTRAINT "FK_2cbbeb03e176addcf60d65f7c9c" FOREIGN KEY ("item_queue_id") REFERENCES "item_queues"("id") ON DELETE CASCADE ON UPDATE CASCADE`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class AddTransactionIdToQueueOrder1729653046392
|
|
||||||
implements MigrationInterface
|
|
||||||
{
|
|
||||||
name = 'AddTransactionIdToQueueOrder1729653046392';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "queue_orders" ADD "transaction_id" character varying NOT NULL`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "queue_orders" DROP COLUMN "transaction_id"`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class AddQueueTable1729756969674 implements MigrationInterface {
|
|
||||||
name = 'AddQueueTable1729756969674';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`CREATE TABLE "queues" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "code" character varying NOT NULL, "status" character varying NOT NULL, "time" bigint NOT NULL, "call_time" bigint NOT NULL, "vip" boolean NOT NULL, "item_id" uuid NOT NULL, "qty" integer NOT NULL, CONSTRAINT "PK_d966f9eb39a9396658387071bb3" PRIMARY KEY ("id"))`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "queues" ADD CONSTRAINT "FK_435954e9a0d9967f17e043d54b4" FOREIGN KEY ("item_id") REFERENCES "queue_items"("id") ON DELETE CASCADE ON UPDATE CASCADE`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "queues" DROP CONSTRAINT "FK_435954e9a0d9967f17e043d54b4"`,
|
|
||||||
);
|
|
||||||
|
|
||||||
await queryRunner.query(`DROP TABLE "queues"`);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class AddQueueBaseModel1729838994129 implements MigrationInterface {
|
|
||||||
name = 'AddQueueBaseModel1729838994129';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "queues" ADD "creator_id" character varying(36)`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "queues" ADD "creator_name" character varying(125)`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "queues" ADD "editor_id" character varying(36)`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "queues" ADD "editor_name" character varying(125)`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "queues" ADD "created_at" bigint NOT NULL`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "queues" ADD "updated_at" bigint NOT NULL`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "queues" ALTER COLUMN "call_time" DROP NOT NULL`,
|
|
||||||
);
|
|
||||||
|
|
||||||
await queryRunner.query(`ALTER TABLE "queues" DROP COLUMN "updated_at"`);
|
|
||||||
await queryRunner.query(`ALTER TABLE "queues" DROP COLUMN "created_at"`);
|
|
||||||
await queryRunner.query(`ALTER TABLE "queues" DROP COLUMN "editor_name"`);
|
|
||||||
await queryRunner.query(`ALTER TABLE "queues" DROP COLUMN "editor_id"`);
|
|
||||||
await queryRunner.query(`ALTER TABLE "queues" DROP COLUMN "creator_name"`);
|
|
||||||
await queryRunner.query(`ALTER TABLE "queues" DROP COLUMN "creator_id"`);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class AddQueueBucket1730859187883 implements MigrationInterface {
|
|
||||||
name = 'AddQueueBucket1730859187883';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`CREATE TABLE "queue_bucket" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "queue_item_id" character varying NOT NULL, "date" bigint NOT NULL, "regular" integer NOT NULL, "vip" integer NOT NULL, CONSTRAINT "PK_cdd58b0d9e93e4be922da9d8bd6" PRIMARY KEY ("id"))`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`DROP TABLE "queue_bucket"`);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,50 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class AddTransactionAndItemRelation1731383726542
|
|
||||||
implements MigrationInterface
|
|
||||||
{
|
|
||||||
name = 'AddTransactionAndItemRelation1731383726542';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_items" DROP COLUMN "item_id"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_items" ADD "item_id" uuid`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transactions" DROP COLUMN "customer_category_id"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transactions" ADD "customer_category_id" uuid`,
|
|
||||||
);
|
|
||||||
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_items" ADD CONSTRAINT "FK_edb934ab033f847e3f7ed4fc0fc" FOREIGN KEY ("item_id") REFERENCES "items"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transactions" ADD CONSTRAINT "FK_08dc8138714894a66e94820766d" FOREIGN KEY ("customer_category_id") REFERENCES "vip_categories"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transactions" DROP CONSTRAINT "FK_08dc8138714894a66e94820766d"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_items" DROP CONSTRAINT "FK_edb934ab033f847e3f7ed4fc0fc"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transactions" DROP COLUMN "customer_category_id"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transactions" ADD "customer_category_id" character varying`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_items" DROP COLUMN "item_id"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_items" ADD "item_id" character varying`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class AddItemQueueToQueue1731498661938 implements MigrationInterface {
|
|
||||||
name = 'AddItemQueueToQueue1731498661938';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "queues" ADD "item_queue_id" character varying`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`ALTER TABLE "queues" DROP COLUMN "item_queue_id"`);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class AddInformationToItemQueue1731570311609
|
|
||||||
implements MigrationInterface
|
|
||||||
{
|
|
||||||
name = 'AddInformationToItemQueue1731570311609';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "item_queues" ADD "information" character varying`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "item_queues" DROP COLUMN "information"`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class ItemQueueAddTimeAndPeakLevel1733199330134
|
|
||||||
implements MigrationInterface
|
|
||||||
{
|
|
||||||
name = 'ItemQueueAddTimeAndPeakLevel1733199330134';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "item_queues" ADD "max_peak_level" integer NOT NULL DEFAULT '100'`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "item_queues" ADD "call_preparation" integer NOT NULL DEFAULT '5'`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "item_queues" DROP COLUMN "call_preparation"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "item_queues" DROP COLUMN "max_peak_level"`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class AddNotificationConfigToItemQueue1734717058658
|
|
||||||
implements MigrationInterface
|
|
||||||
{
|
|
||||||
name = 'AddNotificationConfigToItemQueue1734717058658';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "item_queues" ADD "use_notification" boolean NOT NULL DEFAULT true`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "item_queues" ADD "requiring_notification" boolean NOT NULL DEFAULT false`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "item_queues" DROP COLUMN "requiring_notification"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "item_queues" DROP COLUMN "use_notification"`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class AddLastNotificationToQueue1734718462106
|
|
||||||
implements MigrationInterface
|
|
||||||
{
|
|
||||||
name = 'AddLastNotificationToQueue1734718462106';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "queues" ADD "last_notification" bigint NULL`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "queues" DROP COLUMN "last_notification"`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -73,14 +73,13 @@ export class LoginAdminQueueManager extends BaseCustomManager<UserEntity> {
|
||||||
message: `Akun anda sudah login di item "${hasLoginAsQueue?.item_name}"`,
|
message: `Akun anda sudah login di item "${hasLoginAsQueue?.item_name}"`,
|
||||||
error: 'Unauthorized',
|
error: 'Unauthorized',
|
||||||
});
|
});
|
||||||
|
} else if (itemLogin && itemLogin.user_id !== this.userLogin.id) {
|
||||||
|
throw new UnauthorizedException({
|
||||||
|
statusCode: HttpStatus.UNAUTHORIZED,
|
||||||
|
message: `"${userLoginItem.name}" masih login sebagai admin antrian `,
|
||||||
|
error: 'Unauthorized',
|
||||||
|
});
|
||||||
}
|
}
|
||||||
// else if (itemLogin && itemLogin.user_id !== this.userLogin.id) {
|
|
||||||
// throw new UnauthorizedException({
|
|
||||||
// statusCode: HttpStatus.UNAUTHORIZED,
|
|
||||||
// message: `"${userLoginItem.name}" masih login sebagai admin antrian `,
|
|
||||||
// error: 'Unauthorized',
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// * Disini untuk isi token
|
// * Disini untuk isi token
|
||||||
const tokenData = {
|
const tokenData = {
|
||||||
|
|
|
@ -19,7 +19,6 @@ export class CouchService {
|
||||||
}
|
}
|
||||||
|
|
||||||
async onModuleInit() {
|
async onModuleInit() {
|
||||||
// return;
|
|
||||||
const nano = this.nanoInstance;
|
const nano = this.nanoInstance;
|
||||||
for (const database of DatabaseListen) {
|
for (const database of DatabaseListen) {
|
||||||
const db = nano.db.use(database);
|
const db = nano.db.use(database);
|
||||||
|
@ -96,41 +95,4 @@ export class CouchService {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getUnixTimestampLast7Days() {
|
|
||||||
const date = new Date();
|
|
||||||
date.setDate(date.getDate() - 4);
|
|
||||||
date.setHours(0, 0, 0, 0);
|
|
||||||
return date.getTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
public async clearTransactions() {
|
|
||||||
const nano = this.nanoInstance;
|
|
||||||
const transaction = nano.use('transaction');
|
|
||||||
|
|
||||||
const expiredDate = this.getUnixTimestampLast7Days();
|
|
||||||
|
|
||||||
const selectorPayment = {
|
|
||||||
created_at: {
|
|
||||||
$lt: expiredDate,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const transactions = await transaction.find({
|
|
||||||
selector: selectorPayment,
|
|
||||||
fields: ['_id', '_rev'],
|
|
||||||
limit: 100000,
|
|
||||||
});
|
|
||||||
|
|
||||||
const { docs } = transactions;
|
|
||||||
console.log(docs.length);
|
|
||||||
const deletedDocs = {
|
|
||||||
docs: docs.map((doc) => ({
|
|
||||||
_id: doc._id,
|
|
||||||
_rev: doc._rev,
|
|
||||||
_deleted: true,
|
|
||||||
})),
|
|
||||||
};
|
|
||||||
await transaction.bulk(deletedDocs);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,9 @@ export class ChangeStatusBookingHandler
|
||||||
},
|
},
|
||||||
relations: ['items', 'items.bundling_items'],
|
relations: ['items', 'items.bundling_items'],
|
||||||
});
|
});
|
||||||
|
console.log('change status', { dataID, couchData, booking });
|
||||||
mappingTransaction(booking);
|
mappingTransaction(booking);
|
||||||
|
console.log('after mapping');
|
||||||
|
|
||||||
if (!couchData) {
|
if (!couchData) {
|
||||||
console.log('save data to couch');
|
console.log('save data to couch');
|
||||||
|
|
|
@ -5,17 +5,13 @@ import { Public } from 'src/core/guards';
|
||||||
import * as Nano from 'nano';
|
import * as Nano from 'nano';
|
||||||
import { CreateUserPrivilegeDto } from 'src/modules/user-related/user-privilege/infrastructure/dto/create-user-privilege.dto';
|
import { CreateUserPrivilegeDto } from 'src/modules/user-related/user-privilege/infrastructure/dto/create-user-privilege.dto';
|
||||||
import { ConfigService } from '@nestjs/config';
|
import { ConfigService } from '@nestjs/config';
|
||||||
import { CouchService } from '../data/services/couch.service';
|
|
||||||
|
|
||||||
@ApiTags(`couch`)
|
@ApiTags(`couch`)
|
||||||
@Controller('v1/couch')
|
@Controller('v1/couch')
|
||||||
@Public()
|
@Public()
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class CouchDataController {
|
export class CouchDataController {
|
||||||
constructor(
|
constructor(private configService: ConfigService) {}
|
||||||
private configService: ConfigService,
|
|
||||||
private couchService: CouchService,
|
|
||||||
) {}
|
|
||||||
|
|
||||||
get nanoInstance() {
|
get nanoInstance() {
|
||||||
const couchConfiguration = this.configService.get<string>('COUCHDB_CONFIG');
|
const couchConfiguration = this.configService.get<string>('COUCHDB_CONFIG');
|
||||||
|
@ -68,11 +64,4 @@ export class CouchDataController {
|
||||||
// return people.get();
|
// return people.get();
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Public(true)
|
|
||||||
@Get('clear-transactions')
|
|
||||||
async clearTransactions(): Promise<string> {
|
|
||||||
await this.couchService.clearTransactions();
|
|
||||||
return 'OK';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,13 +40,11 @@ export class SupersetService {
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
const cookie = response.headers['set-cookie'];
|
return { loginToken, csrfToken: response.data.result };
|
||||||
|
|
||||||
return { loginToken, csrfToken: response.data.result, cookie };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getGuestToken(uuid: string) {
|
async getGuestToken(uuid: string) {
|
||||||
const { loginToken, csrfToken, cookie } = await this.getCSRFToken();
|
const { loginToken, csrfToken } = await this.getCSRFToken();
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
resources: [{ type: 'dashboard', id: uuid }],
|
resources: [{ type: 'dashboard', id: uuid }],
|
||||||
|
@ -54,14 +52,11 @@ export class SupersetService {
|
||||||
user: { username: 'pos_embed', first_name: 'pos', last_name: 'embed' },
|
user: { username: 'pos_embed', first_name: 'pos', last_name: 'embed' },
|
||||||
};
|
};
|
||||||
|
|
||||||
const [requestCookie] = cookie[0].split(';');
|
|
||||||
|
|
||||||
const headers = {
|
const headers = {
|
||||||
Authorization: `Bearer ${loginToken}`,
|
|
||||||
Cookie: requestCookie,
|
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
Authorization: `Bearer ${loginToken}`,
|
||||||
'X-CSRFToken': `${csrfToken}`,
|
'X-CSRFToken': `${csrfToken}`,
|
||||||
'Access-Control-Allow-Credentials': true,
|
Referer: `${this.supersetURL}/v1/security/guest_token/`,
|
||||||
};
|
};
|
||||||
|
|
||||||
const response = await firstValueFrom(
|
const response = await firstValueFrom(
|
||||||
|
|
|
@ -3,9 +3,3 @@ export interface GateScanEntity {
|
||||||
type: string;
|
type: string;
|
||||||
uuid: string;
|
uuid: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GateLogEntity {
|
|
||||||
gate_id: string;
|
|
||||||
code: string;
|
|
||||||
error: any;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
import { IsNotEmpty, IsString } from 'class-validator';
|
|
||||||
import { GateLogEntity } from '../../domain/entity/gate-request.entity';
|
|
||||||
import { ApiProperty } from '@nestjs/swagger';
|
|
||||||
|
|
||||||
export class GateLogDto implements GateLogEntity {
|
|
||||||
@ApiProperty({
|
|
||||||
type: String,
|
|
||||||
required: true,
|
|
||||||
})
|
|
||||||
@IsNotEmpty()
|
|
||||||
@IsString()
|
|
||||||
gate_id: string;
|
|
||||||
|
|
||||||
@ApiProperty({
|
|
||||||
type: String,
|
|
||||||
required: true,
|
|
||||||
})
|
|
||||||
@IsNotEmpty()
|
|
||||||
@IsString()
|
|
||||||
code: string;
|
|
||||||
|
|
||||||
@ApiProperty({
|
|
||||||
required: false,
|
|
||||||
})
|
|
||||||
error: any;
|
|
||||||
}
|
|
|
@ -8,7 +8,6 @@ import {
|
||||||
GateResponseEntity,
|
GateResponseEntity,
|
||||||
} from '../domain/entity/gate-response.entity';
|
} from '../domain/entity/gate-response.entity';
|
||||||
import { Gate } from 'src/core/response';
|
import { Gate } from 'src/core/response';
|
||||||
import { GateLogDto } from './dto/logs.dto';
|
|
||||||
|
|
||||||
const masterGates = [
|
const masterGates = [
|
||||||
'319b6d3e-b661-4d19-8695-0dd6fb76465e',
|
'319b6d3e-b661-4d19-8695-0dd6fb76465e',
|
||||||
|
@ -73,13 +72,6 @@ export class GateController {
|
||||||
return responseValue;
|
return responseValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('logs')
|
|
||||||
async logs(@Body() data: GateLogDto): Promise<GateResponseEntity> {
|
|
||||||
console.log(data);
|
|
||||||
|
|
||||||
return { code: 1, message: 'success' };
|
|
||||||
}
|
|
||||||
|
|
||||||
@Get(':id/master')
|
@Get(':id/master')
|
||||||
async detail(@Param('id') id: string): Promise<GateMasterEntity> {
|
async detail(@Param('id') id: string): Promise<GateMasterEntity> {
|
||||||
if (id == '1') return { codes: masterGates };
|
if (id == '1') return { codes: masterGates };
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
export enum ItemType {
|
|
||||||
TIKET_MASUK = 'tiket masuk',
|
|
||||||
WAHANA = 'wahana',
|
|
||||||
BUNDLING = 'bundling',
|
|
||||||
FREE_GIFT = 'free gift',
|
|
||||||
OTHER = 'other',
|
|
||||||
}
|
|
|
@ -1,42 +0,0 @@
|
||||||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
|
||||||
import { ItemQueueEntity } from '../../domain/entities/item-queue.entity';
|
|
||||||
import { Column, Entity, OneToMany } from 'typeorm';
|
|
||||||
import { BaseStatusModel } from 'src/core/modules/data/model/base-status.model';
|
|
||||||
import { ItemType } from '../../constants';
|
|
||||||
import { ItemModel } from 'src/modules/item-related/item/data/models/item.model';
|
|
||||||
|
|
||||||
@Entity(TABLE_NAME.ITEM_QUEUE)
|
|
||||||
export class ItemQueueModel
|
|
||||||
extends BaseStatusModel<ItemQueueEntity>
|
|
||||||
implements ItemQueueEntity
|
|
||||||
{
|
|
||||||
@Column('int', { default: 100 })
|
|
||||||
max_peak_level: number;
|
|
||||||
|
|
||||||
@Column('int', { default: 5 })
|
|
||||||
call_preparation: number;
|
|
||||||
|
|
||||||
@Column('varchar', { name: 'name' })
|
|
||||||
name: string;
|
|
||||||
|
|
||||||
@Column('varchar', { name: 'information', nullable: true })
|
|
||||||
information: string;
|
|
||||||
|
|
||||||
@Column('enum', {
|
|
||||||
name: 'item_type',
|
|
||||||
enum: ItemType,
|
|
||||||
default: ItemType.TIKET_MASUK,
|
|
||||||
})
|
|
||||||
item_type: ItemType;
|
|
||||||
|
|
||||||
@OneToMany(() => ItemModel, (model) => model.item_queue, {
|
|
||||||
onUpdate: 'CASCADE',
|
|
||||||
})
|
|
||||||
items: ItemModel[];
|
|
||||||
|
|
||||||
@Column('boolean', { default: true })
|
|
||||||
use_notification: boolean;
|
|
||||||
|
|
||||||
@Column('boolean', { default: false })
|
|
||||||
requiring_notification: boolean;
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import { BaseDataService } from 'src/core/modules/data/service/base-data.service';
|
|
||||||
import { ItemQueueEntity } from '../../domain/entities/item-queue.entity';
|
|
||||||
import { InjectRepository } from '@nestjs/typeorm';
|
|
||||||
import { ItemQueueModel } from '../models/item-queue.model';
|
|
||||||
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
|
||||||
import { Repository } from 'typeorm';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class ItemQueueDataService extends BaseDataService<ItemQueueEntity> {
|
|
||||||
constructor(
|
|
||||||
@InjectRepository(ItemQueueModel, CONNECTION_NAME.DEFAULT)
|
|
||||||
private repo: Repository<ItemQueueModel>,
|
|
||||||
) {
|
|
||||||
super(repo);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import { ItemQueueEntity } from '../../domain/entities/item-queue.entity';
|
|
||||||
import { InjectRepository } from '@nestjs/typeorm';
|
|
||||||
import { ItemQueueModel } from '../models/item-queue.model';
|
|
||||||
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
|
||||||
import { Repository } from 'typeorm';
|
|
||||||
import { BaseReadService } from 'src/core/modules/data/service/base-read.service';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class ItemQueueReadService extends BaseReadService<ItemQueueEntity> {
|
|
||||||
constructor(
|
|
||||||
@InjectRepository(ItemQueueModel, CONNECTION_NAME.DEFAULT)
|
|
||||||
private repo: Repository<ItemQueueModel>,
|
|
||||||
) {
|
|
||||||
super(repo);
|
|
||||||
}
|
|
||||||
|
|
||||||
async list(): Promise<ItemQueueEntity[]> {
|
|
||||||
return this.repo.find();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
import { BaseFilterEntity } from 'src/core/modules/domain/entities/base-filter.entity';
|
|
||||||
|
|
||||||
export interface FilterItemQueueEntity extends BaseFilterEntity {
|
|
||||||
item_types: string[];
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
import { BaseStatusEntity } from 'src/core/modules/domain/entities/base-status.entity';
|
|
||||||
import { ItemType } from '../../constants';
|
|
||||||
import { ItemEntity } from 'src/modules/item-related/item/domain/entities/item.entity';
|
|
||||||
|
|
||||||
export interface ItemQueueEntity extends BaseStatusEntity {
|
|
||||||
name: string;
|
|
||||||
item_type: ItemType;
|
|
||||||
information?: string;
|
|
||||||
max_peak_level: number;
|
|
||||||
call_preparation: number;
|
|
||||||
items: ItemEntity[];
|
|
||||||
use_notification?: boolean;
|
|
||||||
requiring_notification?: boolean;
|
|
||||||
}
|
|
|
@ -1,122 +0,0 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import { CreateItemQueueManager } from './managers/create-item-queue.manager';
|
|
||||||
import { ItemQueueDataService } from '../../data/services/item-queue-data.service';
|
|
||||||
import { ItemQueueEntity } from '../entities/item-queue.entity';
|
|
||||||
import { DeleteItemQueueManager } from './managers/delete-item-queue.manager';
|
|
||||||
import { UpdateItemQueueManager } from './managers/update-item-queue.manager';
|
|
||||||
import { BaseDataTransactionOrchestrator } from 'src/core/modules/domain/usecase/orchestrators/base-data-transaction.orchestrator';
|
|
||||||
import { ActiveItemQueueManager } from './managers/active-item-queue.manager';
|
|
||||||
import { InactiveItemQueueManager } from './managers/inactive-item-queue.manager';
|
|
||||||
import { ConfirmItemQueueManager } from './managers/confirm-item-queue.manager';
|
|
||||||
import { STATUS } from 'src/core/strings/constants/base.constants';
|
|
||||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
|
||||||
import { BatchConfirmItemQueueManager } from './managers/batch-confirm-item-queue.manager';
|
|
||||||
import { BatchInactiveItemQueueManager } from './managers/batch-inactive-item-queue.manager';
|
|
||||||
import { BatchActiveItemQueueManager } from './managers/batch-active-item-queue.manager';
|
|
||||||
import { BatchDeleteItemQueueManager } from './managers/batch-delete-item-queue.manager';
|
|
||||||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class ItemQueueDataOrchestrator extends BaseDataTransactionOrchestrator<ItemQueueEntity> {
|
|
||||||
constructor(
|
|
||||||
private createManager: CreateItemQueueManager,
|
|
||||||
private updateManager: UpdateItemQueueManager,
|
|
||||||
private deleteManager: DeleteItemQueueManager,
|
|
||||||
private activeManager: ActiveItemQueueManager,
|
|
||||||
private confirmManager: ConfirmItemQueueManager,
|
|
||||||
private inactiveManager: InactiveItemQueueManager,
|
|
||||||
private batchDeleteManager: BatchDeleteItemQueueManager,
|
|
||||||
private batchActiveManager: BatchActiveItemQueueManager,
|
|
||||||
private batchConfirmManager: BatchConfirmItemQueueManager,
|
|
||||||
private batchInactiveManager: BatchInactiveItemQueueManager,
|
|
||||||
private serviceData: ItemQueueDataService,
|
|
||||||
) {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
async create(data): Promise<ItemQueueEntity> {
|
|
||||||
data.items = data.item_ids.map((id) => {
|
|
||||||
return { id };
|
|
||||||
});
|
|
||||||
this.createManager.setData(data);
|
|
||||||
this.createManager.setService(this.serviceData, TABLE_NAME.ITEM_CATEGORY);
|
|
||||||
await this.createManager.execute();
|
|
||||||
await this.createManager.generateConfig();
|
|
||||||
return this.createManager.getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
async update(dataId, data): Promise<ItemQueueEntity> {
|
|
||||||
this.updateManager.setData(dataId, data);
|
|
||||||
this.updateManager.setService(this.serviceData, TABLE_NAME.ITEM_CATEGORY);
|
|
||||||
await this.updateManager.execute();
|
|
||||||
return this.updateManager.getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
async delete(dataId): Promise<string> {
|
|
||||||
this.deleteManager.setData(dataId);
|
|
||||||
this.deleteManager.setService(this.serviceData, TABLE_NAME.ITEM_CATEGORY);
|
|
||||||
await this.deleteManager.execute();
|
|
||||||
return this.deleteManager.getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
async batchDelete(dataIds: string[]): Promise<BatchResult> {
|
|
||||||
this.batchDeleteManager.setData(dataIds);
|
|
||||||
this.batchDeleteManager.setService(
|
|
||||||
this.serviceData,
|
|
||||||
TABLE_NAME.ITEM_CATEGORY,
|
|
||||||
);
|
|
||||||
await this.batchDeleteManager.execute();
|
|
||||||
return this.batchDeleteManager.getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
async active(dataId): Promise<string> {
|
|
||||||
this.activeManager.setData(dataId, STATUS.ACTIVE);
|
|
||||||
this.activeManager.setService(this.serviceData, TABLE_NAME.ITEM_CATEGORY);
|
|
||||||
await this.activeManager.execute();
|
|
||||||
return this.activeManager.getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
async batchActive(dataIds: string[]): Promise<BatchResult> {
|
|
||||||
this.batchActiveManager.setData(dataIds, STATUS.ACTIVE);
|
|
||||||
this.batchActiveManager.setService(
|
|
||||||
this.serviceData,
|
|
||||||
TABLE_NAME.ITEM_CATEGORY,
|
|
||||||
);
|
|
||||||
await this.batchActiveManager.execute();
|
|
||||||
return this.batchActiveManager.getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
async confirm(dataId): Promise<string> {
|
|
||||||
this.confirmManager.setData(dataId, STATUS.ACTIVE);
|
|
||||||
this.confirmManager.setService(this.serviceData, TABLE_NAME.ITEM_CATEGORY);
|
|
||||||
await this.confirmManager.execute();
|
|
||||||
return this.confirmManager.getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
async batchConfirm(dataIds: string[]): Promise<BatchResult> {
|
|
||||||
this.batchConfirmManager.setData(dataIds, STATUS.ACTIVE);
|
|
||||||
this.batchConfirmManager.setService(
|
|
||||||
this.serviceData,
|
|
||||||
TABLE_NAME.ITEM_CATEGORY,
|
|
||||||
);
|
|
||||||
await this.batchConfirmManager.execute();
|
|
||||||
return this.batchConfirmManager.getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
async inactive(dataId): Promise<string> {
|
|
||||||
this.inactiveManager.setData(dataId, STATUS.INACTIVE);
|
|
||||||
this.inactiveManager.setService(this.serviceData, TABLE_NAME.ITEM_CATEGORY);
|
|
||||||
await this.inactiveManager.execute();
|
|
||||||
return this.inactiveManager.getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
async batchInactive(dataIds: string[]): Promise<BatchResult> {
|
|
||||||
this.batchInactiveManager.setData(dataIds, STATUS.INACTIVE);
|
|
||||||
this.batchInactiveManager.setService(
|
|
||||||
this.serviceData,
|
|
||||||
TABLE_NAME.ITEM_CATEGORY,
|
|
||||||
);
|
|
||||||
await this.batchInactiveManager.execute();
|
|
||||||
return this.batchInactiveManager.getResult();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,38 +0,0 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import { IndexItemQueueManager } from './managers/index-item-queue.manager';
|
|
||||||
import { ItemQueueReadService } from '../../data/services/item-queue-read.service';
|
|
||||||
import { ItemQueueEntity } from '../entities/item-queue.entity';
|
|
||||||
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
|
|
||||||
import { BaseReadOrchestrator } from 'src/core/modules/domain/usecase/orchestrators/base-read.orchestrator';
|
|
||||||
import { DetailItemQueueManager } from './managers/detail-item-queue.manager';
|
|
||||||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class ItemQueueReadOrchestrator extends BaseReadOrchestrator<ItemQueueEntity> {
|
|
||||||
constructor(
|
|
||||||
private indexManager: IndexItemQueueManager,
|
|
||||||
private detailManager: DetailItemQueueManager,
|
|
||||||
private serviceData: ItemQueueReadService,
|
|
||||||
) {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
async index(params): Promise<PaginationResponse<ItemQueueEntity>> {
|
|
||||||
this.indexManager.setFilterParam(params);
|
|
||||||
this.indexManager.setService(this.serviceData, TABLE_NAME.ITEM_QUEUE);
|
|
||||||
await this.indexManager.execute();
|
|
||||||
return this.indexManager.getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
async list(): Promise<ItemQueueEntity[]> {
|
|
||||||
const items = await this.serviceData.list();
|
|
||||||
return items;
|
|
||||||
}
|
|
||||||
|
|
||||||
async detail(dataId: string): Promise<ItemQueueEntity> {
|
|
||||||
this.detailManager.setData(dataId);
|
|
||||||
this.detailManager.setService(this.serviceData, TABLE_NAME.ITEM_QUEUE);
|
|
||||||
await this.detailManager.execute();
|
|
||||||
return this.detailManager.getResult();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import { BaseUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-update-status.manager';
|
|
||||||
import { ItemQueueEntity } from '../../entities/item-queue.entity';
|
|
||||||
import {
|
|
||||||
EventTopics,
|
|
||||||
validateRelations,
|
|
||||||
} from 'src/core/strings/constants/interface.constants';
|
|
||||||
import { ItemQueueModel } from '../../../data/models/item-queue.model';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class ActiveItemQueueManager extends BaseUpdateStatusManager<ItemQueueEntity> {
|
|
||||||
getResult(): string {
|
|
||||||
return `Success active data ${this.result.name}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
async validateProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async beforeProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async afterProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
get validateRelations(): validateRelations[] {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
get entityTarget(): any {
|
|
||||||
return ItemQueueModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
get eventTopics(): EventTopics[] {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
import { BaseBatchUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-batch-update-status.manager';
|
|
||||||
import { ItemQueueEntity } from '../../entities/item-queue.entity';
|
|
||||||
import {
|
|
||||||
EventTopics,
|
|
||||||
validateRelations,
|
|
||||||
} from 'src/core/strings/constants/interface.constants';
|
|
||||||
import { ItemQueueModel } from '../../../data/models/item-queue.model';
|
|
||||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class BatchActiveItemQueueManager extends BaseBatchUpdateStatusManager<ItemQueueEntity> {
|
|
||||||
validateData(data: ItemQueueEntity): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
beforeProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
afterProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
get validateRelations(): validateRelations[] {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
get entityTarget(): any {
|
|
||||||
return ItemQueueModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
get eventTopics(): EventTopics[] {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
getResult(): BatchResult {
|
|
||||||
return this.result;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
import { BaseBatchUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-batch-update-status.manager';
|
|
||||||
import { ItemQueueEntity } from '../../entities/item-queue.entity';
|
|
||||||
import {
|
|
||||||
EventTopics,
|
|
||||||
validateRelations,
|
|
||||||
} from 'src/core/strings/constants/interface.constants';
|
|
||||||
import { ItemQueueModel } from '../../../data/models/item-queue.model';
|
|
||||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class BatchConfirmItemQueueManager extends BaseBatchUpdateStatusManager<ItemQueueEntity> {
|
|
||||||
validateData(data: ItemQueueEntity): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
beforeProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
afterProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
get validateRelations(): validateRelations[] {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
get entityTarget(): any {
|
|
||||||
return ItemQueueModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
get eventTopics(): EventTopics[] {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
getResult(): BatchResult {
|
|
||||||
return this.result;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,46 +0,0 @@
|
||||||
import { BaseBatchDeleteManager } from 'src/core/modules/domain/usecase/managers/base-batch-delete.manager';
|
|
||||||
import { ItemQueueEntity } from '../../entities/item-queue.entity';
|
|
||||||
import {
|
|
||||||
EventTopics,
|
|
||||||
validateRelations,
|
|
||||||
} from 'src/core/strings/constants/interface.constants';
|
|
||||||
import { ItemQueueModel } from '../../../data/models/item-queue.model';
|
|
||||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class BatchDeleteItemQueueManager extends BaseBatchDeleteManager<ItemQueueEntity> {
|
|
||||||
async beforeProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async validateData(data: ItemQueueEntity): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async afterProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
get validateRelations(): validateRelations[] {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
relation: 'items',
|
|
||||||
message:
|
|
||||||
'Gagal! tidak dapat mengubah tipe item karena sudah berelasi dengan item',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
get entityTarget(): any {
|
|
||||||
return ItemQueueModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
get eventTopics(): EventTopics[] {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
getResult(): BatchResult {
|
|
||||||
return this.result;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,46 +0,0 @@
|
||||||
import { BaseBatchUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-batch-update-status.manager';
|
|
||||||
import { ItemQueueEntity } from '../../entities/item-queue.entity';
|
|
||||||
import {
|
|
||||||
EventTopics,
|
|
||||||
validateRelations,
|
|
||||||
} from 'src/core/strings/constants/interface.constants';
|
|
||||||
import { ItemQueueModel } from '../../../data/models/item-queue.model';
|
|
||||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class BatchInactiveItemQueueManager extends BaseBatchUpdateStatusManager<ItemQueueEntity> {
|
|
||||||
validateData(data: ItemQueueEntity): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
beforeProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
afterProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
get validateRelations(): validateRelations[] {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
relation: 'items',
|
|
||||||
message:
|
|
||||||
'Gagal! tidak dapat mengubah tipe item karena sudah berelasi dengan item',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
get entityTarget(): any {
|
|
||||||
return ItemQueueModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
get eventTopics(): EventTopics[] {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
getResult(): BatchResult {
|
|
||||||
return this.result;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import { BaseUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-update-status.manager';
|
|
||||||
import { ItemQueueEntity } from '../../entities/item-queue.entity';
|
|
||||||
import {
|
|
||||||
EventTopics,
|
|
||||||
validateRelations,
|
|
||||||
} from 'src/core/strings/constants/interface.constants';
|
|
||||||
import { ItemQueueModel } from '../../../data/models/item-queue.model';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class ConfirmItemQueueManager extends BaseUpdateStatusManager<ItemQueueEntity> {
|
|
||||||
getResult(): string {
|
|
||||||
return `Success active data ${this.result.name}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
async validateProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async beforeProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async afterProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
get validateRelations(): validateRelations[] {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
get entityTarget(): any {
|
|
||||||
return ItemQueueModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
get eventTopics(): EventTopics[] {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,43 +0,0 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import {
|
|
||||||
EventTopics,
|
|
||||||
columnUniques,
|
|
||||||
validateRelations,
|
|
||||||
} from 'src/core/strings/constants/interface.constants';
|
|
||||||
import { ItemQueueEntity } from '../../entities/item-queue.entity';
|
|
||||||
import { ItemQueueModel } from '../../../data/models/item-queue.model';
|
|
||||||
import { BaseCreateManager } from 'src/core/modules/domain/usecase/managers/base-create.manager';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class CreateItemQueueManager extends BaseCreateManager<ItemQueueEntity> {
|
|
||||||
async beforeProcess(): Promise<void> {
|
|
||||||
Object.assign(this.data, {
|
|
||||||
item_type: this.data.item_type.toLowerCase(),
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async afterProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async generateConfig(): Promise<void> {
|
|
||||||
// TODO: Implement logic here
|
|
||||||
}
|
|
||||||
|
|
||||||
get validateRelations(): validateRelations[] {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
get uniqueColumns(): columnUniques[] {
|
|
||||||
return [{ column: 'name' }];
|
|
||||||
}
|
|
||||||
|
|
||||||
get eventTopics(): EventTopics[] {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
get entityTarget(): any {
|
|
||||||
return ItemQueueModel;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import { BaseDeleteManager } from 'src/core/modules/domain/usecase/managers/base-delete.manager';
|
|
||||||
import { ItemQueueEntity } from '../../entities/item-queue.entity';
|
|
||||||
import {
|
|
||||||
EventTopics,
|
|
||||||
validateRelations,
|
|
||||||
} from 'src/core/strings/constants/interface.constants';
|
|
||||||
import { ItemQueueModel } from '../../../data/models/item-queue.model';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class DeleteItemQueueManager extends BaseDeleteManager<ItemQueueEntity> {
|
|
||||||
getResult(): string {
|
|
||||||
return `Success`;
|
|
||||||
}
|
|
||||||
|
|
||||||
async validateProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async beforeProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async afterProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
get validateRelations(): validateRelations[] {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
get entityTarget(): any {
|
|
||||||
return ItemQueueModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
get eventTopics(): EventTopics[] {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,72 +0,0 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import { BaseDetailManager } from 'src/core/modules/domain/usecase/managers/base-detail.manager';
|
|
||||||
import { ItemQueueEntity } from '../../entities/item-queue.entity';
|
|
||||||
import { RelationParam } from 'src/core/modules/domain/entities/base-filter.entity';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class DetailItemQueueManager extends BaseDetailManager<ItemQueueEntity> {
|
|
||||||
async prepareData(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async beforeProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async afterProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
get relations(): RelationParam {
|
|
||||||
return {
|
|
||||||
joinRelations: [],
|
|
||||||
selectRelations: ['items'],
|
|
||||||
countRelations: [],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
get selects(): string[] {
|
|
||||||
return [
|
|
||||||
`${this.tableName}.id`,
|
|
||||||
`${this.tableName}.status`,
|
|
||||||
`${this.tableName}.name`,
|
|
||||||
`${this.tableName}.information`,
|
|
||||||
`${this.tableName}.item_type`,
|
|
||||||
`${this.tableName}.created_at`,
|
|
||||||
`${this.tableName}.creator_name`,
|
|
||||||
`${this.tableName}.updated_at`,
|
|
||||||
`${this.tableName}.editor_name`,
|
|
||||||
`${this.tableName}.max_peak_level`,
|
|
||||||
`${this.tableName}.call_preparation`,
|
|
||||||
`${this.tableName}.use_notification`,
|
|
||||||
`${this.tableName}.requiring_notification`,
|
|
||||||
|
|
||||||
`items.id`,
|
|
||||||
`items.created_at`,
|
|
||||||
`items.status`,
|
|
||||||
`items.item_type`,
|
|
||||||
`items.name`,
|
|
||||||
`items.hpp`,
|
|
||||||
`items.limit_type`,
|
|
||||||
`items.limit_value`,
|
|
||||||
`items.base_price`,
|
|
||||||
`items.share_profit`,
|
|
||||||
`items.play_estimation`,
|
|
||||||
`items.video_url`,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
get setFindProperties(): any {
|
|
||||||
return {
|
|
||||||
id: this.dataId,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
getResult(): ItemQueueEntity {
|
|
||||||
const videos = this.result.items.map((item) => {
|
|
||||||
return item.video_url ?? [];
|
|
||||||
});
|
|
||||||
this.result['videos'] = videos.flat();
|
|
||||||
return this.result;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,45 +0,0 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import { BaseUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-update-status.manager';
|
|
||||||
import { ItemQueueEntity } from '../../entities/item-queue.entity';
|
|
||||||
import {
|
|
||||||
EventTopics,
|
|
||||||
validateRelations,
|
|
||||||
} from 'src/core/strings/constants/interface.constants';
|
|
||||||
import { ItemQueueModel } from '../../../data/models/item-queue.model';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class InactiveItemQueueManager extends BaseUpdateStatusManager<ItemQueueEntity> {
|
|
||||||
getResult(): string {
|
|
||||||
return `Success inactive data ${this.result.name}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
async validateProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async beforeProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async afterProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
get validateRelations(): validateRelations[] {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
relation: 'items',
|
|
||||||
message:
|
|
||||||
'Gagal! tidak dapat mengubah tipe item karena sudah berelasi dengan item',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
get entityTarget(): any {
|
|
||||||
return ItemQueueModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
get eventTopics(): EventTopics[] {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,79 +0,0 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import { BaseIndexManager } from 'src/core/modules/domain/usecase/managers/base-index.manager';
|
|
||||||
import { ItemQueueEntity } from '../../entities/item-queue.entity';
|
|
||||||
import { SelectQueryBuilder } from 'typeorm';
|
|
||||||
import {
|
|
||||||
Param,
|
|
||||||
RelationParam,
|
|
||||||
} from 'src/core/modules/domain/entities/base-filter.entity';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class IndexItemQueueManager extends BaseIndexManager<ItemQueueEntity> {
|
|
||||||
async prepareData(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async beforeProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async afterProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
get relations(): RelationParam {
|
|
||||||
return {
|
|
||||||
joinRelations: [],
|
|
||||||
selectRelations: ['items'],
|
|
||||||
countRelations: [],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
get selects(): string[] {
|
|
||||||
return [
|
|
||||||
`${this.tableName}.id`,
|
|
||||||
`${this.tableName}.status`,
|
|
||||||
`${this.tableName}.name`,
|
|
||||||
`${this.tableName}.item_type`,
|
|
||||||
`${this.tableName}.created_at`,
|
|
||||||
`${this.tableName}.creator_name`,
|
|
||||||
`${this.tableName}.updated_at`,
|
|
||||||
`${this.tableName}.editor_name`,
|
|
||||||
`${this.tableName}.max_peak_level`,
|
|
||||||
`${this.tableName}.call_preparation`,
|
|
||||||
`${this.tableName}.use_notification`,
|
|
||||||
`${this.tableName}.requiring_notification`,
|
|
||||||
|
|
||||||
`items.id`,
|
|
||||||
`items.created_at`,
|
|
||||||
`items.status`,
|
|
||||||
`items.item_type`,
|
|
||||||
`items.name`,
|
|
||||||
`items.hpp`,
|
|
||||||
`items.limit_type`,
|
|
||||||
`items.limit_value`,
|
|
||||||
`items.base_price`,
|
|
||||||
`items.share_profit`,
|
|
||||||
`items.play_estimation`,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
get specificFilter(): Param[] {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
cols: `${this.tableName}.name`,
|
|
||||||
data: this.filterParam.names,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
cols: `${this.tableName}.item_type::text`,
|
|
||||||
data: this.filterParam.item_types,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
setQueryFilter(
|
|
||||||
queryBuilder: SelectQueryBuilder<ItemQueueEntity>,
|
|
||||||
): SelectQueryBuilder<ItemQueueEntity> {
|
|
||||||
return queryBuilder;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,53 +0,0 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import { BaseUpdateManager } from 'src/core/modules/domain/usecase/managers/base-update.manager';
|
|
||||||
import { ItemQueueEntity } from '../../entities/item-queue.entity';
|
|
||||||
import { ItemQueueModel } from '../../../data/models/item-queue.model';
|
|
||||||
import {
|
|
||||||
EventTopics,
|
|
||||||
columnUniques,
|
|
||||||
validateRelations,
|
|
||||||
} from 'src/core/strings/constants/interface.constants';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class UpdateItemQueueManager extends BaseUpdateManager<ItemQueueEntity> {
|
|
||||||
async validateProcess(): Promise<void> {
|
|
||||||
Object.assign(this.data, {
|
|
||||||
item_type: this.data.item_type.toLowerCase(),
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async beforeProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async afterProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
get validateRelations(): validateRelations[] {
|
|
||||||
if (this.data.item_type != this.oldData.item_type) {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
relation: 'items',
|
|
||||||
message:
|
|
||||||
'Gagal! tidak dapat mengubah tipe item karena sudah berelasi dengan item',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
} else {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
get uniqueColumns(): columnUniques[] {
|
|
||||||
return [{ column: 'name' }];
|
|
||||||
}
|
|
||||||
|
|
||||||
get entityTarget(): any {
|
|
||||||
return ItemQueueModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
get eventTopics(): EventTopics[] {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
import { BaseFilterDto } from 'src/core/modules/infrastructure/dto/base-filter.dto';
|
|
||||||
import { FilterItemQueueEntity } from '../../domain/entities/filter-item-queue.entity';
|
|
||||||
import { ApiProperty } from '@nestjs/swagger';
|
|
||||||
import { Transform } from 'class-transformer';
|
|
||||||
|
|
||||||
export class FilterItemQueueDto
|
|
||||||
extends BaseFilterDto
|
|
||||||
implements FilterItemQueueEntity
|
|
||||||
{
|
|
||||||
@ApiProperty({ type: ['string'], required: false })
|
|
||||||
@Transform((body) => {
|
|
||||||
return Array.isArray(body.value) ? body.value : [body.value];
|
|
||||||
})
|
|
||||||
item_types: string[];
|
|
||||||
}
|
|
|
@ -1,58 +0,0 @@
|
||||||
import { BaseStatusDto } from 'src/core/modules/infrastructure/dto/base-status.dto';
|
|
||||||
import { ItemQueueEntity } from '../../domain/entities/item-queue.entity';
|
|
||||||
import { IsArray, IsNumber, IsString } from 'class-validator';
|
|
||||||
import { ItemType } from '../../constants';
|
|
||||||
import { ApiProperty } from '@nestjs/swagger';
|
|
||||||
import { ItemEntity } from 'src/modules/item-related/item/domain/entities/item.entity';
|
|
||||||
import { Exclude, Transform } from 'class-transformer';
|
|
||||||
|
|
||||||
export class ItemQueueDto extends BaseStatusDto implements ItemQueueEntity {
|
|
||||||
@ApiProperty({
|
|
||||||
name: 'max_peak_level',
|
|
||||||
required: false,
|
|
||||||
example: 'Menentukan level peak maksimal penuhnya wahana',
|
|
||||||
default: 100,
|
|
||||||
})
|
|
||||||
@IsNumber()
|
|
||||||
max_peak_level: number;
|
|
||||||
|
|
||||||
@ApiProperty({
|
|
||||||
name: 'call_preparation',
|
|
||||||
required: false,
|
|
||||||
example: 'Waktu persiapan untuk memanggil antrian dalam menit',
|
|
||||||
default: 5,
|
|
||||||
})
|
|
||||||
@IsNumber()
|
|
||||||
call_preparation: number;
|
|
||||||
|
|
||||||
@Exclude()
|
|
||||||
items: ItemEntity[];
|
|
||||||
|
|
||||||
@ApiProperty({ name: 'name', required: true, example: 'Bundling w Entrance' })
|
|
||||||
@IsString()
|
|
||||||
name: string;
|
|
||||||
|
|
||||||
@ApiProperty({
|
|
||||||
name: 'information',
|
|
||||||
required: false,
|
|
||||||
example: 'Running text untuk display antrian',
|
|
||||||
})
|
|
||||||
@IsString()
|
|
||||||
information: string;
|
|
||||||
|
|
||||||
@ApiProperty({
|
|
||||||
type: 'string',
|
|
||||||
required: true,
|
|
||||||
description: `Select (${JSON.stringify(Object.values(ItemType))})`,
|
|
||||||
example: ItemType.BUNDLING,
|
|
||||||
})
|
|
||||||
item_type: ItemType;
|
|
||||||
|
|
||||||
@ApiProperty({ type: [String], required: true })
|
|
||||||
@Transform((body) => {
|
|
||||||
return Array.isArray(body.value) ? body.value : [body.value];
|
|
||||||
})
|
|
||||||
@IsArray()
|
|
||||||
@IsString({ each: true })
|
|
||||||
item_ids: string[];
|
|
||||||
}
|
|
|
@ -1,78 +0,0 @@
|
||||||
import {
|
|
||||||
Body,
|
|
||||||
Controller,
|
|
||||||
Delete,
|
|
||||||
Param,
|
|
||||||
Patch,
|
|
||||||
Post,
|
|
||||||
Put,
|
|
||||||
} from '@nestjs/common';
|
|
||||||
import { ItemQueueDataOrchestrator } from '../domain/usecases/item-queue-data.orchestrator';
|
|
||||||
import { ItemQueueDto } from './dto/item-queue.dto';
|
|
||||||
import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
|
|
||||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
|
||||||
import { ItemQueueEntity } from '../domain/entities/item-queue.entity';
|
|
||||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
|
||||||
import { BatchIdsDto } from 'src/core/modules/infrastructure/dto/base-batch.dto';
|
|
||||||
import { Public } from 'src/core/guards';
|
|
||||||
|
|
||||||
@ApiTags(`${MODULE_NAME.ITEM_QUEUE.split('-').join(' ')} - data`)
|
|
||||||
@Controller(`v1/${MODULE_NAME.ITEM_QUEUE}`)
|
|
||||||
@Public(false)
|
|
||||||
@ApiBearerAuth('JWT')
|
|
||||||
export class ItemQueueDataController {
|
|
||||||
constructor(private orchestrator: ItemQueueDataOrchestrator) {}
|
|
||||||
|
|
||||||
@Post()
|
|
||||||
async create(@Body() data: ItemQueueDto): Promise<ItemQueueEntity> {
|
|
||||||
return await this.orchestrator.create(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Put('/batch-delete')
|
|
||||||
async batchDeleted(@Body() body: BatchIdsDto): Promise<BatchResult> {
|
|
||||||
return await this.orchestrator.batchDelete(body.ids);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Patch(':id/active')
|
|
||||||
async active(@Param('id') dataId: string): Promise<string> {
|
|
||||||
return await this.orchestrator.active(dataId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Put('/batch-active')
|
|
||||||
async batchActive(@Body() body: BatchIdsDto): Promise<BatchResult> {
|
|
||||||
return await this.orchestrator.batchActive(body.ids);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Patch(':id/confirm')
|
|
||||||
async confirm(@Param('id') dataId: string): Promise<string> {
|
|
||||||
return await this.orchestrator.confirm(dataId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Put('/batch-confirm')
|
|
||||||
async batchConfirm(@Body() body: BatchIdsDto): Promise<BatchResult> {
|
|
||||||
return await this.orchestrator.batchConfirm(body.ids);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Patch(':id/inactive')
|
|
||||||
async inactive(@Param('id') dataId: string): Promise<string> {
|
|
||||||
return await this.orchestrator.inactive(dataId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Put('/batch-inactive')
|
|
||||||
async batchInactive(@Body() body: BatchIdsDto): Promise<BatchResult> {
|
|
||||||
return await this.orchestrator.batchInactive(body.ids);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Put(':id')
|
|
||||||
async update(
|
|
||||||
@Param('id') dataId: string,
|
|
||||||
@Body() data: ItemQueueDto,
|
|
||||||
): Promise<ItemQueueEntity> {
|
|
||||||
return await this.orchestrator.update(dataId, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Delete(':id')
|
|
||||||
async delete(@Param('id') dataId: string): Promise<string> {
|
|
||||||
return await this.orchestrator.delete(dataId);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,57 +0,0 @@
|
||||||
import {
|
|
||||||
Controller,
|
|
||||||
Get,
|
|
||||||
Param,
|
|
||||||
Query,
|
|
||||||
UnauthorizedException,
|
|
||||||
} from '@nestjs/common';
|
|
||||||
import { FilterItemQueueDto } from './dto/filter-item-queue.dto';
|
|
||||||
import { Pagination } from 'src/core/response';
|
|
||||||
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
|
|
||||||
import { ItemQueueEntity } from '../domain/entities/item-queue.entity';
|
|
||||||
import { ItemQueueReadOrchestrator } from '../domain/usecases/item-queue-read.orchestrator';
|
|
||||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
|
||||||
import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
|
|
||||||
import { Public } from 'src/core/guards';
|
|
||||||
import { validate as isValidUUID } from 'uuid';
|
|
||||||
|
|
||||||
@ApiTags(`${MODULE_NAME.ITEM_QUEUE.split('-').join(' ')} - read`)
|
|
||||||
@Controller(`v1/${MODULE_NAME.ITEM_QUEUE}`)
|
|
||||||
@Public(false)
|
|
||||||
@ApiBearerAuth('JWT')
|
|
||||||
export class ItemQueueReadController {
|
|
||||||
constructor(private orchestrator: ItemQueueReadOrchestrator) {}
|
|
||||||
|
|
||||||
@Get()
|
|
||||||
@Pagination()
|
|
||||||
async index(
|
|
||||||
@Query() params: FilterItemQueueDto,
|
|
||||||
): Promise<PaginationResponse<ItemQueueEntity>> {
|
|
||||||
return await this.orchestrator.index(params);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Get('list')
|
|
||||||
@Public(true)
|
|
||||||
async list() {
|
|
||||||
const list = await this.orchestrator.list();
|
|
||||||
return list.map(({ id, name, item_type }) => {
|
|
||||||
return {
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
item_type,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Get(':id')
|
|
||||||
async detail(@Param('id') id: string): Promise<ItemQueueEntity> {
|
|
||||||
return await this.orchestrator.detail(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Get('display/:id')
|
|
||||||
@Public(true)
|
|
||||||
async detailPublic(@Param('id') id: string): Promise<ItemQueueEntity> {
|
|
||||||
if (!isValidUUID(id)) throw new UnauthorizedException('id is required');
|
|
||||||
return await this.orchestrator.detail(id);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,54 +0,0 @@
|
||||||
import { Module } from '@nestjs/common';
|
|
||||||
import { ConfigModule } from '@nestjs/config';
|
|
||||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
|
||||||
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
|
||||||
import { ItemQueueDataService } from './data/services/item-queue-data.service';
|
|
||||||
import { ItemQueueReadService } from './data/services/item-queue-read.service';
|
|
||||||
import { ItemQueueReadController } from './infrastructure/item-queue-read.controller';
|
|
||||||
import { ItemQueueReadOrchestrator } from './domain/usecases/item-queue-read.orchestrator';
|
|
||||||
import { ItemQueueDataController } from './infrastructure/item-queue-data.controller';
|
|
||||||
import { ItemQueueDataOrchestrator } from './domain/usecases/item-queue-data.orchestrator';
|
|
||||||
import { CreateItemQueueManager } from './domain/usecases/managers/create-item-queue.manager';
|
|
||||||
import { CqrsModule } from '@nestjs/cqrs';
|
|
||||||
import { IndexItemQueueManager } from './domain/usecases/managers/index-item-queue.manager';
|
|
||||||
import { DeleteItemQueueManager } from './domain/usecases/managers/delete-item-queue.manager';
|
|
||||||
import { UpdateItemQueueManager } from './domain/usecases/managers/update-item-queue.manager';
|
|
||||||
import { ActiveItemQueueManager } from './domain/usecases/managers/active-item-queue.manager';
|
|
||||||
import { ConfirmItemQueueManager } from './domain/usecases/managers/confirm-item-queue.manager';
|
|
||||||
import { InactiveItemQueueManager } from './domain/usecases/managers/inactive-item-queue.manager';
|
|
||||||
import { DetailItemQueueManager } from './domain/usecases/managers/detail-item-queue.manager';
|
|
||||||
import { BatchDeleteItemQueueManager } from './domain/usecases/managers/batch-delete-item-queue.manager';
|
|
||||||
import { BatchActiveItemQueueManager } from './domain/usecases/managers/batch-active-item-queue.manager';
|
|
||||||
import { BatchConfirmItemQueueManager } from './domain/usecases/managers/batch-confirm-item-queue.manager';
|
|
||||||
import { BatchInactiveItemQueueManager } from './domain/usecases/managers/batch-inactive-item-queue.manager';
|
|
||||||
import { ItemQueueModel } from './data/models/item-queue.model';
|
|
||||||
|
|
||||||
@Module({
|
|
||||||
imports: [
|
|
||||||
ConfigModule.forRoot(),
|
|
||||||
TypeOrmModule.forFeature([ItemQueueModel], CONNECTION_NAME.DEFAULT),
|
|
||||||
CqrsModule,
|
|
||||||
],
|
|
||||||
controllers: [ItemQueueDataController, ItemQueueReadController],
|
|
||||||
providers: [
|
|
||||||
IndexItemQueueManager,
|
|
||||||
DetailItemQueueManager,
|
|
||||||
CreateItemQueueManager,
|
|
||||||
DeleteItemQueueManager,
|
|
||||||
UpdateItemQueueManager,
|
|
||||||
ActiveItemQueueManager,
|
|
||||||
ConfirmItemQueueManager,
|
|
||||||
InactiveItemQueueManager,
|
|
||||||
BatchDeleteItemQueueManager,
|
|
||||||
BatchActiveItemQueueManager,
|
|
||||||
BatchConfirmItemQueueManager,
|
|
||||||
BatchInactiveItemQueueManager,
|
|
||||||
|
|
||||||
ItemQueueDataService,
|
|
||||||
ItemQueueReadService,
|
|
||||||
|
|
||||||
ItemQueueDataOrchestrator,
|
|
||||||
ItemQueueReadOrchestrator,
|
|
||||||
],
|
|
||||||
})
|
|
||||||
export class ItemQueueModule {}
|
|
|
@ -16,7 +16,6 @@ import { ItemCategoryModel } from 'src/modules/item-related/item-category/data/m
|
||||||
import { UserModel } from 'src/modules/user-related/user/data/models/user.model';
|
import { UserModel } from 'src/modules/user-related/user/data/models/user.model';
|
||||||
import { ItemRateModel } from 'src/modules/item-related/item-rate/data/models/item-rate.model';
|
import { ItemRateModel } from 'src/modules/item-related/item-rate/data/models/item-rate.model';
|
||||||
import { GateModel } from 'src/modules/web-information/gate/data/models/gate.model';
|
import { GateModel } from 'src/modules/web-information/gate/data/models/gate.model';
|
||||||
import { ItemQueueModel } from 'src/modules/item-related/item-queue/data/models/item-queue.model';
|
|
||||||
|
|
||||||
@Entity(TABLE_NAME.ITEM)
|
@Entity(TABLE_NAME.ITEM)
|
||||||
export class ItemModel
|
export class ItemModel
|
||||||
|
@ -29,9 +28,6 @@ export class ItemModel
|
||||||
@Column('varchar', { name: 'image_url', nullable: true })
|
@Column('varchar', { name: 'image_url', nullable: true })
|
||||||
image_url: string;
|
image_url: string;
|
||||||
|
|
||||||
@Column('json', { nullable: true })
|
|
||||||
video_url: string[];
|
|
||||||
|
|
||||||
@Column('enum', {
|
@Column('enum', {
|
||||||
name: 'item_type',
|
name: 'item_type',
|
||||||
enum: ItemType,
|
enum: ItemType,
|
||||||
|
@ -54,7 +50,7 @@ export class ItemModel
|
||||||
@Column('bigint', { name: 'base_price', nullable: true })
|
@Column('bigint', { name: 'base_price', nullable: true })
|
||||||
base_price: number;
|
base_price: number;
|
||||||
|
|
||||||
@Column('decimal', { name: 'play_estimation', nullable: true })
|
@Column('int', { name: 'play_estimation', nullable: true })
|
||||||
play_estimation: number;
|
play_estimation: number;
|
||||||
|
|
||||||
@Column('boolean', { name: 'use_queue', default: false })
|
@Column('boolean', { name: 'use_queue', default: false })
|
||||||
|
@ -86,16 +82,6 @@ export class ItemModel
|
||||||
@JoinColumn({ name: 'item_category_id' })
|
@JoinColumn({ name: 'item_category_id' })
|
||||||
item_category: ItemCategoryModel;
|
item_category: ItemCategoryModel;
|
||||||
|
|
||||||
@ManyToOne(() => ItemQueueModel, (model) => model.items, {
|
|
||||||
onUpdate: 'CASCADE',
|
|
||||||
onDelete: 'SET NULL',
|
|
||||||
})
|
|
||||||
@JoinColumn({ name: 'item_queue_id' })
|
|
||||||
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,7 +6,6 @@ export interface ItemEntity extends BaseStatusEntity {
|
||||||
name: string;
|
name: string;
|
||||||
item_type: ItemType;
|
item_type: ItemType;
|
||||||
image_url: string;
|
image_url: string;
|
||||||
video_url?: string[];
|
|
||||||
|
|
||||||
hpp: number;
|
hpp: number;
|
||||||
sales_margin: number;
|
sales_margin: number;
|
||||||
|
|
|
@ -34,7 +34,6 @@ export class DetailItemManager extends BaseDetailManager<ItemEntity> {
|
||||||
return [
|
return [
|
||||||
`${this.tableName}.id`,
|
`${this.tableName}.id`,
|
||||||
`${this.tableName}.image_url`,
|
`${this.tableName}.image_url`,
|
||||||
`${this.tableName}.video_url`,
|
|
||||||
`${this.tableName}.created_at`,
|
`${this.tableName}.created_at`,
|
||||||
`${this.tableName}.status`,
|
`${this.tableName}.status`,
|
||||||
`${this.tableName}.item_type`,
|
`${this.tableName}.item_type`,
|
||||||
|
|
|
@ -84,12 +84,6 @@ export class IndexItemManager extends BaseIndexManager<ItemEntity> {
|
||||||
setQueryFilter(
|
setQueryFilter(
|
||||||
queryBuilder: SelectQueryBuilder<ItemEntity>,
|
queryBuilder: SelectQueryBuilder<ItemEntity>,
|
||||||
): SelectQueryBuilder<ItemEntity> {
|
): SelectQueryBuilder<ItemEntity> {
|
||||||
if (this.filterParam.q) {
|
|
||||||
queryBuilder.andWhere(
|
|
||||||
`${this.tableName}.name ILIKE '%${this.filterParam.q}%'`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.filterParam.tenant_ids?.length) {
|
if (this.filterParam.tenant_ids?.length) {
|
||||||
queryBuilder.andWhere(`${this.tableName}.tenant_id In (:...tenantIds)`, {
|
queryBuilder.andWhere(`${this.tableName}.tenant_id In (:...tenantIds)`, {
|
||||||
tenantIds: this.filterParam.tenant_ids,
|
tenantIds: this.filterParam.tenant_ids,
|
||||||
|
|
|
@ -12,7 +12,6 @@ import {
|
||||||
ValidateIf,
|
ValidateIf,
|
||||||
} from 'class-validator';
|
} from 'class-validator';
|
||||||
import { ItemCategoryEntity } from 'src/modules/item-related/item-category/domain/entities/item-category.entity';
|
import { ItemCategoryEntity } from 'src/modules/item-related/item-category/domain/entities/item-category.entity';
|
||||||
import { Transform } from 'class-transformer';
|
|
||||||
|
|
||||||
export class ItemDto extends BaseStatusDto implements ItemEntity {
|
export class ItemDto extends BaseStatusDto implements ItemEntity {
|
||||||
@ApiProperty({
|
@ApiProperty({
|
||||||
|
@ -32,18 +31,6 @@ export class ItemDto extends BaseStatusDto implements ItemEntity {
|
||||||
@ValidateIf((body) => body.image)
|
@ValidateIf((body) => body.image)
|
||||||
image_url: string;
|
image_url: string;
|
||||||
|
|
||||||
@ApiProperty({
|
|
||||||
isArray: true,
|
|
||||||
required: false,
|
|
||||||
})
|
|
||||||
// @IsString()
|
|
||||||
@ValidateIf((body) => body.video_url)
|
|
||||||
@Transform(({ value }) => {
|
|
||||||
if (!value) return [];
|
|
||||||
return Array.isArray(value) ? value : [value];
|
|
||||||
})
|
|
||||||
video_url: string[];
|
|
||||||
|
|
||||||
@ApiProperty({
|
@ApiProperty({
|
||||||
type: 'string',
|
type: 'string',
|
||||||
required: true,
|
required: true,
|
||||||
|
|
|
@ -41,18 +41,18 @@ export class ItemReadController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ApiTags(`Item Queue - Read`)
|
@ApiTags(`Item Queue - Read`)
|
||||||
// @Controller(`v1/item-queue`)
|
@Controller(`v1/item-queue`)
|
||||||
// @Public(true)
|
@Public(true)
|
||||||
// export class ItemReadQueueController {
|
export class ItemReadQueueController {
|
||||||
// constructor(private orchestrator: ItemReadOrchestrator) {}
|
constructor(private orchestrator: ItemReadOrchestrator) {}
|
||||||
|
|
||||||
// @Get()
|
@Get()
|
||||||
// @Pagination()
|
@Pagination()
|
||||||
// @ExcludePrivilege()
|
@ExcludePrivilege()
|
||||||
// async indexQueue(
|
async indexQueue(
|
||||||
// @Query() params: FilterItemDto,
|
@Query() params: FilterItemDto,
|
||||||
// ): Promise<PaginationResponse<ItemEntity>> {
|
): Promise<PaginationResponse<ItemEntity>> {
|
||||||
// return await this.orchestrator.indexQueue(params);
|
return await this.orchestrator.indexQueue(params);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { ItemDataService } from './data/services/item-data.service';
|
||||||
import { ItemReadService } from './data/services/item-read.service';
|
import { ItemReadService } from './data/services/item-read.service';
|
||||||
import {
|
import {
|
||||||
ItemReadController,
|
ItemReadController,
|
||||||
// ItemReadQueueController,
|
ItemReadQueueController,
|
||||||
} from './infrastructure/item-read.controller';
|
} from './infrastructure/item-read.controller';
|
||||||
import { ItemReadOrchestrator } from './domain/usecases/item-read.orchestrator';
|
import { ItemReadOrchestrator } from './domain/usecases/item-read.orchestrator';
|
||||||
import { ItemDataController } from './infrastructure/item-data.controller';
|
import { ItemDataController } from './infrastructure/item-data.controller';
|
||||||
|
@ -44,7 +44,7 @@ import { IndexItemQueueManager } from './domain/usecases/managers/index-queue-it
|
||||||
controllers: [
|
controllers: [
|
||||||
ItemDataController,
|
ItemDataController,
|
||||||
ItemReadController,
|
ItemReadController,
|
||||||
// ItemReadQueueController,
|
ItemReadQueueController,
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
IndexItemManager,
|
IndexItemManager,
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
|
|
||||||
import { QueueBucket } from '../../domain/entities/queue-bucket.entity';
|
|
||||||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
|
||||||
|
|
||||||
@Entity(TABLE_NAME.QUEUE_BUCKET)
|
|
||||||
export class QueueBucketModel implements QueueBucket {
|
|
||||||
@PrimaryGeneratedColumn('uuid')
|
|
||||||
id: string;
|
|
||||||
|
|
||||||
@Column('varchar')
|
|
||||||
queue_item_id: string;
|
|
||||||
|
|
||||||
@Column({ type: 'bigint', nullable: false })
|
|
||||||
date: number;
|
|
||||||
|
|
||||||
@Column('int')
|
|
||||||
regular: number;
|
|
||||||
|
|
||||||
@Column('int')
|
|
||||||
vip: number;
|
|
||||||
}
|
|
|
@ -1,145 +0,0 @@
|
||||||
import { BaseCoreModel } from 'src/core/modules/data/model/base-core.model';
|
|
||||||
import { QueueOrder } from '../../domain/entities/order.entity';
|
|
||||||
import { Column, Entity, JoinColumn, ManyToOne, OneToMany } from 'typeorm';
|
|
||||||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
|
||||||
import { QueueTicket } from '../../domain/entities/ticket.entity';
|
|
||||||
import { QueueItem } from '../../domain/entities/queue-item.entity';
|
|
||||||
|
|
||||||
import { ItemModel } from 'src/modules/item-related/item/data/models/item.model';
|
|
||||||
import { Queue } from '../../domain/entities/queue.entity';
|
|
||||||
import { BaseModel } from 'src/core/modules/data/model/base.model';
|
|
||||||
|
|
||||||
@Entity(TABLE_NAME.QUEUE_ORDER)
|
|
||||||
export class QueueOrderModel
|
|
||||||
extends BaseCoreModel<QueueOrderModel>
|
|
||||||
implements QueueOrder
|
|
||||||
{
|
|
||||||
@Column('varchar')
|
|
||||||
code: string;
|
|
||||||
|
|
||||||
@Column('varchar', { nullable: true })
|
|
||||||
customer: string;
|
|
||||||
|
|
||||||
@Column('varchar', { nullable: true })
|
|
||||||
phone: string;
|
|
||||||
|
|
||||||
@Column('varchar', { nullable: false })
|
|
||||||
transaction_id: string;
|
|
||||||
|
|
||||||
@OneToMany(() => QueueTicketModel, (model) => model.order, {
|
|
||||||
cascade: true,
|
|
||||||
onDelete: 'CASCADE',
|
|
||||||
onUpdate: 'CASCADE',
|
|
||||||
})
|
|
||||||
tickets: QueueTicket[];
|
|
||||||
|
|
||||||
@Column({ type: 'bigint' })
|
|
||||||
date: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Entity(TABLE_NAME.QUEUE_TICKET)
|
|
||||||
export class QueueTicketModel
|
|
||||||
extends BaseCoreModel<QueueTicketModel>
|
|
||||||
implements QueueTicket
|
|
||||||
{
|
|
||||||
@Column('varchar')
|
|
||||||
code: string;
|
|
||||||
|
|
||||||
@Column('varchar', { nullable: true })
|
|
||||||
customer: string;
|
|
||||||
|
|
||||||
@Column('varchar', { nullable: true })
|
|
||||||
phone: string;
|
|
||||||
|
|
||||||
@ManyToOne(() => QueueOrderModel, (model) => model.tickets, {
|
|
||||||
onDelete: 'CASCADE',
|
|
||||||
onUpdate: 'CASCADE',
|
|
||||||
})
|
|
||||||
@JoinColumn({ name: 'order_id' })
|
|
||||||
order: QueueOrder;
|
|
||||||
|
|
||||||
@Column('varchar')
|
|
||||||
order_id: string;
|
|
||||||
|
|
||||||
@Column({ type: 'bigint' })
|
|
||||||
date: number;
|
|
||||||
|
|
||||||
@OneToMany(() => QueueItemModel, (model) => model.ticket, {
|
|
||||||
cascade: true,
|
|
||||||
onDelete: 'CASCADE',
|
|
||||||
onUpdate: 'CASCADE',
|
|
||||||
})
|
|
||||||
items: QueueItemModel[];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Entity(TABLE_NAME.QUEUE_ITEM)
|
|
||||||
export class QueueItemModel
|
|
||||||
extends BaseCoreModel<QueueItemModel>
|
|
||||||
implements QueueItem
|
|
||||||
{
|
|
||||||
@ManyToOne(() => QueueTicketModel, (model) => model.items, {
|
|
||||||
onDelete: 'CASCADE',
|
|
||||||
onUpdate: 'CASCADE',
|
|
||||||
})
|
|
||||||
@JoinColumn({ name: 'ticket_id' })
|
|
||||||
ticket: QueueTicket;
|
|
||||||
|
|
||||||
@Column('varchar')
|
|
||||||
ticket_id: string;
|
|
||||||
|
|
||||||
@OneToMany(() => QueueModel, (model) => model.item, {
|
|
||||||
onDelete: 'CASCADE',
|
|
||||||
onUpdate: 'CASCADE',
|
|
||||||
})
|
|
||||||
queue: QueueModel[];
|
|
||||||
|
|
||||||
@Column('varchar')
|
|
||||||
item_id: string;
|
|
||||||
|
|
||||||
@ManyToOne(() => ItemModel)
|
|
||||||
@JoinColumn({ name: 'item_id' })
|
|
||||||
item: ItemModel;
|
|
||||||
|
|
||||||
@Column('int')
|
|
||||||
qty: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Entity(TABLE_NAME.QUEUE)
|
|
||||||
export class QueueModel extends BaseModel<Queue> implements Queue {
|
|
||||||
@Column('varchar')
|
|
||||||
code: string;
|
|
||||||
|
|
||||||
@Column('varchar')
|
|
||||||
status: string;
|
|
||||||
|
|
||||||
@Column({ type: 'bigint' })
|
|
||||||
time: number;
|
|
||||||
|
|
||||||
@Column({ type: 'bigint', nullable: true })
|
|
||||||
last_notification: number;
|
|
||||||
|
|
||||||
@Column({ type: 'bigint' })
|
|
||||||
call_time: number;
|
|
||||||
|
|
||||||
@Column({ type: 'boolean' })
|
|
||||||
vip: boolean;
|
|
||||||
|
|
||||||
@ManyToOne(() => QueueItemModel, (model) => model.queue, {
|
|
||||||
onDelete: 'CASCADE',
|
|
||||||
onUpdate: 'CASCADE',
|
|
||||||
})
|
|
||||||
@JoinColumn({ name: 'item_id' })
|
|
||||||
item: QueueItemModel;
|
|
||||||
|
|
||||||
@Column('varchar')
|
|
||||||
item_id: string;
|
|
||||||
|
|
||||||
@Column('varchar', { nullable: true })
|
|
||||||
item_queue_id: string;
|
|
||||||
|
|
||||||
@Column('int')
|
|
||||||
qty: number;
|
|
||||||
|
|
||||||
average = 0;
|
|
||||||
peak_level = 100;
|
|
||||||
}
|
|
|
@ -1,62 +0,0 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
|
|
||||||
import { InjectRepository } from '@nestjs/typeorm';
|
|
||||||
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
|
||||||
import { Between, Repository } from 'typeorm';
|
|
||||||
import { BaseReadService } from 'src/core/modules/data/service/base-read.service';
|
|
||||||
import { QueueBucketModel } from '../models/queue-bucket.model';
|
|
||||||
import * as moment from 'moment';
|
|
||||||
import { QueueItemModel } from '../models/queue.model';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class QueueBucketReadService extends BaseReadService<QueueBucketModel> {
|
|
||||||
constructor(
|
|
||||||
@InjectRepository(QueueBucketModel, CONNECTION_NAME.DEFAULT)
|
|
||||||
private repo: Repository<QueueBucketModel>,
|
|
||||||
|
|
||||||
@InjectRepository(QueueItemModel, CONNECTION_NAME.DEFAULT)
|
|
||||||
private item: Repository<QueueItemModel>,
|
|
||||||
) {
|
|
||||||
super(repo);
|
|
||||||
}
|
|
||||||
|
|
||||||
async getQueue(item_id: string, vip = false): Promise<number> {
|
|
||||||
const start = moment().startOf('day').valueOf();
|
|
||||||
const end = moment().endOf('day').valueOf();
|
|
||||||
|
|
||||||
const queue = await this.repo.findOne({
|
|
||||||
where: {
|
|
||||||
queue_item_id: item_id,
|
|
||||||
date: Between(start, end),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!queue) {
|
|
||||||
const regularNumber = vip ? 0 : 1;
|
|
||||||
const vipNumber = vip ? 1 : 0;
|
|
||||||
await this.repo.save({
|
|
||||||
queue_item_id: item_id,
|
|
||||||
date: start,
|
|
||||||
regular: regularNumber,
|
|
||||||
vip: vipNumber,
|
|
||||||
});
|
|
||||||
return Promise.resolve(1);
|
|
||||||
} else {
|
|
||||||
const field = vip ? 'vip' : 'regular';
|
|
||||||
const data = await this.repo
|
|
||||||
.createQueryBuilder('bucket')
|
|
||||||
.update(QueueBucketModel)
|
|
||||||
.set({
|
|
||||||
[field]: () => `${field} + 1`,
|
|
||||||
})
|
|
||||||
.where('id = :key', {
|
|
||||||
key: queue.id,
|
|
||||||
})
|
|
||||||
.returning(field)
|
|
||||||
.updateEntity(true)
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
return data.raw[0]?.[field] ?? 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,256 +0,0 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
|
|
||||||
import { InjectDataSource, InjectRepository } from '@nestjs/typeorm';
|
|
||||||
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
|
||||||
import { Between, DataSource, In, Not, Repository } from 'typeorm';
|
|
||||||
import {
|
|
||||||
QueueItemModel,
|
|
||||||
QueueModel,
|
|
||||||
QueueOrderModel,
|
|
||||||
} from '../models/queue.model';
|
|
||||||
import { BaseReadService } from 'src/core/modules/data/service/base-read.service';
|
|
||||||
import { BaseDataService } from 'src/core/modules/data/service/base-data.service';
|
|
||||||
import { ItemQueueModel } from 'src/modules/item-related/item-queue/data/models/item-queue.model';
|
|
||||||
import * as moment from 'moment';
|
|
||||||
import * as math from 'mathjs';
|
|
||||||
import { ItemModel } from 'src/modules/item-related/item/data/models/item.model';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class QueueDataService extends BaseReadService<QueueModel> {
|
|
||||||
constructor(
|
|
||||||
@InjectRepository(QueueModel, CONNECTION_NAME.DEFAULT)
|
|
||||||
private repo: Repository<QueueModel>,
|
|
||||||
|
|
||||||
@InjectRepository(ItemQueueModel, CONNECTION_NAME.DEFAULT)
|
|
||||||
private itemQueueRepo: Repository<ItemQueueModel>,
|
|
||||||
) {
|
|
||||||
super(repo);
|
|
||||||
}
|
|
||||||
|
|
||||||
async waitingQueue(item_queue_id: string) {
|
|
||||||
const start = moment().startOf('day').valueOf();
|
|
||||||
const end = moment().endOf('day').valueOf();
|
|
||||||
return this.repo.find({
|
|
||||||
where: {
|
|
||||||
time: Between(start, end),
|
|
||||||
item_queue_id,
|
|
||||||
status: 'waiting',
|
|
||||||
},
|
|
||||||
order: {
|
|
||||||
time: 'ASC',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async doneQueue(item_queue_id: string) {
|
|
||||||
const start = moment().startOf('day').valueOf();
|
|
||||||
const end = moment().endOf('day').valueOf();
|
|
||||||
return this.repo.find({
|
|
||||||
where: {
|
|
||||||
time: Between(start, end),
|
|
||||||
item_queue_id,
|
|
||||||
status: In(['done', 'called']),
|
|
||||||
},
|
|
||||||
order: {
|
|
||||||
time: 'ASC',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async exclude(item_queue_id: string[]) {
|
|
||||||
const queues = await this.itemQueueRepo.find({
|
|
||||||
relations: ['items'],
|
|
||||||
where: {
|
|
||||||
id: Not(In(item_queue_id)),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
return queues.filter((q) => q.items.length > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
async allQueue() {
|
|
||||||
const queues = await this.itemQueueRepo.find({
|
|
||||||
relations: ['items'],
|
|
||||||
});
|
|
||||||
|
|
||||||
return queues.filter((q) => q.items.length > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
async lastQueue(item_queue_id: string) {
|
|
||||||
const start = moment().startOf('day').valueOf();
|
|
||||||
const end = moment().endOf('day').valueOf();
|
|
||||||
return this.repo.findOne({
|
|
||||||
where: {
|
|
||||||
time: Between(start, end),
|
|
||||||
item_queue_id,
|
|
||||||
status: 'called',
|
|
||||||
},
|
|
||||||
order: {
|
|
||||||
call_time: 'DESC',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
* Change to QueueTimeFormula (queue-time.formula.ts)
|
|
||||||
* @param item_queue_id
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
async queueTimes(item_queue_id: string): Promise<any> {
|
|
||||||
const queueTimes = {};
|
|
||||||
let now = moment().valueOf();
|
|
||||||
const itemQueue = await this.itemQueueRepo.findOne({
|
|
||||||
relations: ['items'],
|
|
||||||
where: {
|
|
||||||
id: item_queue_id,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const times = itemQueue.items.map((item) => item.play_estimation ?? 0);
|
|
||||||
const average = math.mean(times) * 60 * 1000; // change average minute to milliseconds
|
|
||||||
const queues = await this.repo.find({
|
|
||||||
where: {
|
|
||||||
item_queue_id,
|
|
||||||
status: 'waiting',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
queueTimes[queues[0].id] = now; // first queue will be now
|
|
||||||
|
|
||||||
for (let i = 1; i < queues.length; i++) {
|
|
||||||
const queue = queues[i];
|
|
||||||
// duration will be total qty multiple by average
|
|
||||||
const duration = queue.qty * average;
|
|
||||||
|
|
||||||
// time to call will be now + duration
|
|
||||||
const time = now + duration;
|
|
||||||
queueTimes[queue.id] = time;
|
|
||||||
|
|
||||||
// update now to last call time
|
|
||||||
now = time;
|
|
||||||
}
|
|
||||||
|
|
||||||
return queueTimes;
|
|
||||||
}
|
|
||||||
|
|
||||||
async queueItems(item_queue_id: string[]): Promise<QueueModel[]> {
|
|
||||||
return this.repo.find({
|
|
||||||
relations: ['item', 'item.item', 'item.item.item_queue'],
|
|
||||||
where: {
|
|
||||||
item: { item: { item_queue: { id: In(item_queue_id) } } },
|
|
||||||
},
|
|
||||||
order: {
|
|
||||||
time: 'DESC',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class QueueService extends BaseDataService<QueueModel> {
|
|
||||||
constructor(
|
|
||||||
@InjectRepository(QueueModel, CONNECTION_NAME.DEFAULT)
|
|
||||||
private repo: Repository<QueueModel>,
|
|
||||||
|
|
||||||
@InjectRepository(QueueItemModel, CONNECTION_NAME.DEFAULT)
|
|
||||||
private item: Repository<QueueItemModel>,
|
|
||||||
|
|
||||||
@InjectRepository(ItemModel, CONNECTION_NAME.DEFAULT)
|
|
||||||
private itemMaster: Repository<ItemModel>,
|
|
||||||
|
|
||||||
@InjectDataSource(CONNECTION_NAME.DEFAULT)
|
|
||||||
private dataSource: DataSource,
|
|
||||||
) {
|
|
||||||
super(repo);
|
|
||||||
}
|
|
||||||
|
|
||||||
async queueTicket(queueId: string) {
|
|
||||||
return this.repo.findOne({
|
|
||||||
relations: ['item', 'item.ticket'],
|
|
||||||
where: {
|
|
||||||
id: queueId,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async queues(ids: string[]) {
|
|
||||||
const start = moment().startOf('day').valueOf();
|
|
||||||
const end = moment().endOf('day').valueOf();
|
|
||||||
const playEstimations = {};
|
|
||||||
const queuePeakLevel = {};
|
|
||||||
|
|
||||||
for (const id of ids) {
|
|
||||||
const est = await this.itemAverageTimeEstimation(id);
|
|
||||||
playEstimations[id] = est.average;
|
|
||||||
queuePeakLevel[id] = est.peakLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
const queues = await this.repo.find({
|
|
||||||
where: {
|
|
||||||
item_queue_id: In(ids),
|
|
||||||
time: Between(start, end),
|
|
||||||
},
|
|
||||||
order: {
|
|
||||||
time: 'ASC',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
queues.forEach((queue) => {
|
|
||||||
queue.average = playEstimations[queue.item_queue_id];
|
|
||||||
queue.peak_level = queuePeakLevel[queue.item_queue_id];
|
|
||||||
});
|
|
||||||
|
|
||||||
return queues;
|
|
||||||
}
|
|
||||||
|
|
||||||
async itemAverageTimeEstimation(item_queue_id: string) {
|
|
||||||
const items = await this.itemMaster.find({
|
|
||||||
relations: ['item_queue'],
|
|
||||||
where: {
|
|
||||||
item_queue_id,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const times = items.map((item) => item.play_estimation ?? 0);
|
|
||||||
const average = times.length > 0 ? math.mean(times) * 60 * 1000 : 0; // change average minute to milliseconds
|
|
||||||
const peakLevel = items[0]?.item_queue?.max_peak_level ?? 100;
|
|
||||||
return { average, peakLevel };
|
|
||||||
}
|
|
||||||
|
|
||||||
async getTicketItems(ticket_id: string, item_id: string) {
|
|
||||||
return this.item.findOneOrFail({
|
|
||||||
relations: ['item'],
|
|
||||||
where: [
|
|
||||||
{
|
|
||||||
ticket_id,
|
|
||||||
item_id,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ticket_id,
|
|
||||||
item: { item_queue_id: item_id },
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async updateLastNotification(queue_id: string, time: number) {
|
|
||||||
const query = `UPDATE queues SET last_notification = ${time} WHERE id = '${queue_id}'`;
|
|
||||||
this.dataSource.query(query);
|
|
||||||
}
|
|
||||||
|
|
||||||
async updateItemQty(item_id: string, qty: number): Promise<void> {
|
|
||||||
const query = `UPDATE queue_items SET qty = qty - ${qty} WHERE id = '${item_id}'`;
|
|
||||||
this.dataSource.query(query);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class QueueOrderService extends BaseDataService<QueueOrderModel> {
|
|
||||||
constructor(
|
|
||||||
@InjectRepository(QueueOrderModel, CONNECTION_NAME.DEFAULT)
|
|
||||||
private repo: Repository<QueueOrderModel>,
|
|
||||||
) {
|
|
||||||
super(repo);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,304 +0,0 @@
|
||||||
import { Injectable, UnprocessableEntityException } from '@nestjs/common';
|
|
||||||
import { BaseDataService } from 'src/core/modules/data/service/base-data.service';
|
|
||||||
import { InjectRepository } from '@nestjs/typeorm';
|
|
||||||
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
|
||||||
import { Between, In, IsNull, Like, Not, Repository } from 'typeorm';
|
|
||||||
import { QueueTicket } from '../../domain/entities/ticket.entity';
|
|
||||||
import {
|
|
||||||
QueueItemModel,
|
|
||||||
QueueOrderModel,
|
|
||||||
QueueTicketModel,
|
|
||||||
} from '../models/queue.model';
|
|
||||||
import { QueueOrder } from '../../domain/entities/order.entity';
|
|
||||||
import * as moment from 'moment';
|
|
||||||
import { TransactionModel } from 'src/modules/transaction/transaction/data/models/transaction.model';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class TicketDataService extends BaseDataService<QueueTicket> {
|
|
||||||
constructor(
|
|
||||||
@InjectRepository(QueueTicketModel, CONNECTION_NAME.DEFAULT)
|
|
||||||
private repo: Repository<QueueTicketModel>,
|
|
||||||
|
|
||||||
@InjectRepository(QueueOrderModel, CONNECTION_NAME.DEFAULT)
|
|
||||||
private order: Repository<QueueOrderModel>,
|
|
||||||
|
|
||||||
@InjectRepository(QueueItemModel, CONNECTION_NAME.DEFAULT)
|
|
||||||
private item: Repository<QueueItemModel>,
|
|
||||||
|
|
||||||
@InjectRepository(TransactionModel, CONNECTION_NAME.DEFAULT)
|
|
||||||
private transaction: Repository<TransactionModel>,
|
|
||||||
) {
|
|
||||||
super(repo);
|
|
||||||
}
|
|
||||||
|
|
||||||
async createQueueOrder(order: QueueOrder): Promise<QueueOrderModel> {
|
|
||||||
return await this.order.save(order);
|
|
||||||
}
|
|
||||||
|
|
||||||
async updateQueueTicket(ticket: QueueTicket): Promise<QueueTicketModel> {
|
|
||||||
return await this.repo.save(ticket);
|
|
||||||
}
|
|
||||||
|
|
||||||
async loginQueue(id: string): Promise<QueueOrder> {
|
|
||||||
const order = await this.order.findOne({
|
|
||||||
relations: ['tickets'],
|
|
||||||
where: [
|
|
||||||
{ transaction_id: id },
|
|
||||||
{ 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[]> {
|
|
||||||
return this.repo.find({
|
|
||||||
where: {
|
|
||||||
code: Like(`${code}%`),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async ticketByUser(user: string, phone: string): Promise<QueueTicket> {
|
|
||||||
const start = moment().startOf('day').valueOf();
|
|
||||||
const end = moment().endOf('day').valueOf();
|
|
||||||
|
|
||||||
return this.repo.findOne({
|
|
||||||
relations: ['items'],
|
|
||||||
where: {
|
|
||||||
customer: user,
|
|
||||||
phone: phone,
|
|
||||||
date: Between(start, end),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async loginPhone(user: string, phone: string): Promise<QueueOrder> {
|
|
||||||
const start = moment().startOf('day').valueOf();
|
|
||||||
const end = moment().endOf('day').valueOf();
|
|
||||||
|
|
||||||
return this.order.findOneOrFail({
|
|
||||||
relations: ['tickets'],
|
|
||||||
where: {
|
|
||||||
customer: user,
|
|
||||||
phone: `+${phone}`,
|
|
||||||
date: Between(start, end),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async orders(order_id: string): Promise<QueueOrderModel[]> {
|
|
||||||
const order = await this.order.findOneOrFail({
|
|
||||||
where: {
|
|
||||||
id: order_id,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (order.transaction_id != null) {
|
|
||||||
return this.order.find({
|
|
||||||
where: {
|
|
||||||
code: order.code,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return [order];
|
|
||||||
}
|
|
||||||
|
|
||||||
async transactions(transaction_id: string): Promise<QueueOrderModel[]> {
|
|
||||||
const order = await this.order.findOneOrFail({
|
|
||||||
where: {
|
|
||||||
transaction_id,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (order.transaction_id != null) {
|
|
||||||
return this.order.find({
|
|
||||||
where: {
|
|
||||||
code: order.code,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return [order];
|
|
||||||
}
|
|
||||||
|
|
||||||
async deleteQueue(transaction_id: string): Promise<void> {
|
|
||||||
try {
|
|
||||||
const transactions = await this.transactions(transaction_id);
|
|
||||||
await this.order.remove(transactions);
|
|
||||||
} catch (error) {
|
|
||||||
console.log('transaction not found');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async orderIds(order_id: string): Promise<string[]> {
|
|
||||||
const orders = await this.orders(order_id);
|
|
||||||
|
|
||||||
return orders.map((order) => order.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
async orderItems(
|
|
||||||
order_id: string,
|
|
||||||
item_ids: string[],
|
|
||||||
): Promise<QueueOrderModel> {
|
|
||||||
const order = await this.orderIds(order_id);
|
|
||||||
try {
|
|
||||||
const ticket = await this.order.findOneOrFail({
|
|
||||||
relations: ['tickets', 'tickets.items'],
|
|
||||||
where: {
|
|
||||||
tickets: {
|
|
||||||
order_id: In(order),
|
|
||||||
items: {
|
|
||||||
id: In(item_ids),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
return ticket;
|
|
||||||
} catch (error) {
|
|
||||||
throw new UnprocessableEntityException('Ticket tidak dapat ditemukan');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async queuePosTickets(order_id: string): Promise<QueueTicketModel[]> {
|
|
||||||
return this.repo.find({
|
|
||||||
relations: [
|
|
||||||
'items',
|
|
||||||
'items.queue',
|
|
||||||
'items.item',
|
|
||||||
'items.item.item_queue',
|
|
||||||
],
|
|
||||||
where: {
|
|
||||||
order_id,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async queueTickets(order_id: string): Promise<QueueTicketModel[]> {
|
|
||||||
const order = await this.orderIds(order_id);
|
|
||||||
const start = moment().startOf('day').valueOf();
|
|
||||||
const end = moment().endOf('day').valueOf();
|
|
||||||
return this.repo.find({
|
|
||||||
relations: [
|
|
||||||
'items',
|
|
||||||
'items.queue',
|
|
||||||
'items.item',
|
|
||||||
'items.item.item_queue',
|
|
||||||
],
|
|
||||||
where: {
|
|
||||||
order_id: In(order),
|
|
||||||
date: Between(start, end),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async queueUniqueTickets(order_id: string): Promise<QueueTicketModel[]> {
|
|
||||||
const start = moment().startOf('day').valueOf();
|
|
||||||
const end = moment().endOf('day').valueOf();
|
|
||||||
return this.repo.find({
|
|
||||||
relations: [
|
|
||||||
'items',
|
|
||||||
'items.queue',
|
|
||||||
'items.item',
|
|
||||||
'items.item.item_queue',
|
|
||||||
],
|
|
||||||
where: {
|
|
||||||
order_id: order_id,
|
|
||||||
date: Between(start, end),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async queueTicketItems(
|
|
||||||
order_id: string,
|
|
||||||
ticket_id: string,
|
|
||||||
): Promise<QueueTicketModel[]> {
|
|
||||||
const order = await this.orderIds(order_id);
|
|
||||||
return this.repo.find({
|
|
||||||
relations: [
|
|
||||||
'items',
|
|
||||||
'items.queue',
|
|
||||||
'items.item',
|
|
||||||
'items.item.item_queue',
|
|
||||||
],
|
|
||||||
where: {
|
|
||||||
order_id: In(order),
|
|
||||||
id: ticket_id,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async queueTicketActive(
|
|
||||||
order_id: string,
|
|
||||||
ticket_id: string,
|
|
||||||
): Promise<QueueTicketModel[]> {
|
|
||||||
// const order = await this.orderIds(order_id);
|
|
||||||
return this.repo.find({
|
|
||||||
relations: ['items', 'items.queue'],
|
|
||||||
where: {
|
|
||||||
// order_id: In(order),
|
|
||||||
id: ticket_id,
|
|
||||||
// items: {
|
|
||||||
// queue: {
|
|
||||||
// status: In(['waiting']),
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async queueItemTickets(
|
|
||||||
order_id: string,
|
|
||||||
item_id: string,
|
|
||||||
): Promise<QueueTicketModel[]> {
|
|
||||||
const order = await this.orderIds(order_id);
|
|
||||||
return this.repo.find({
|
|
||||||
relations: [
|
|
||||||
'items',
|
|
||||||
'items.queue',
|
|
||||||
'items.item',
|
|
||||||
'items.item.item_queue',
|
|
||||||
],
|
|
||||||
where: {
|
|
||||||
order_id: In(order),
|
|
||||||
items: [{ item_id }, { item: { item_queue: { id: item_id } } }],
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async queueItems(order_id: string): Promise<QueueItemModel[]> {
|
|
||||||
const order = await this.orderIds(order_id);
|
|
||||||
return this.item.find({
|
|
||||||
relations: ['queue', 'ticket'],
|
|
||||||
where: {
|
|
||||||
ticket: {
|
|
||||||
order_id: In(order),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
export interface FilterQueueEntity {
|
|
||||||
vip: boolean;
|
|
||||||
status: string[];
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
import { BaseCoreEntity } from 'src/core/modules/domain/entities/base-core.entity';
|
|
||||||
import { QueueTicket } from './ticket.entity';
|
|
||||||
|
|
||||||
export interface QueueOrder extends BaseCoreEntity {
|
|
||||||
code: string;
|
|
||||||
customer: string;
|
|
||||||
phone: string;
|
|
||||||
date: number;
|
|
||||||
transaction_id: string;
|
|
||||||
tickets: QueueTicket[];
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
export interface QueueBucket {
|
|
||||||
id: string;
|
|
||||||
queue_item_id: string;
|
|
||||||
date: number;
|
|
||||||
regular: number;
|
|
||||||
vip: number;
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
import { BaseCoreEntity } from 'src/core/modules/domain/entities/base-core.entity';
|
|
||||||
import { ItemEntity } from 'src/modules/item-related/item/domain/entities/item.entity';
|
|
||||||
import { QueueTicket } from './ticket.entity';
|
|
||||||
import { QueueModel } from '../../data/models/queue.model';
|
|
||||||
|
|
||||||
export interface QueueItem extends BaseCoreEntity {
|
|
||||||
ticket?: QueueTicket;
|
|
||||||
item?: ItemEntity;
|
|
||||||
item_id: string;
|
|
||||||
qty: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface MergedItemQueue extends BaseCoreEntity {
|
|
||||||
id: string;
|
|
||||||
queue_item_id: string;
|
|
||||||
item_id: string;
|
|
||||||
title: string;
|
|
||||||
image_url: string;
|
|
||||||
qty: number;
|
|
||||||
queues: QueueModel[];
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
import { BaseCoreEntity } from 'src/core/modules/domain/entities/base-core.entity';
|
|
||||||
import { QueueItem } from './queue-item.entity';
|
|
||||||
|
|
||||||
export interface Queue extends BaseCoreEntity {
|
|
||||||
code: string;
|
|
||||||
qty: number;
|
|
||||||
status: string;
|
|
||||||
time: number;
|
|
||||||
vip: boolean;
|
|
||||||
call_time: number;
|
|
||||||
item: QueueItem;
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
import { BaseCoreEntity } from 'src/core/modules/domain/entities/base-core.entity';
|
|
||||||
import { QueueOrder } from './order.entity';
|
|
||||||
import { QueueItem } from './queue-item.entity';
|
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
||||||
export interface QueueTicket extends BaseCoreEntity {
|
|
||||||
code: string;
|
|
||||||
customer: string;
|
|
||||||
phone: string;
|
|
||||||
date: number;
|
|
||||||
order?: QueueOrder;
|
|
||||||
order_id?: string;
|
|
||||||
items: QueueItem[];
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
import * as moment from 'moment';
|
|
||||||
|
|
||||||
export function toTime(timestamp: number): string {
|
|
||||||
const date = moment.unix(timestamp / 1000).add(7, 'hours');
|
|
||||||
|
|
||||||
const hours = date.hours();
|
|
||||||
const minutes = date.minutes();
|
|
||||||
return `${hours < 10 ? '0' : ''}${hours}:${
|
|
||||||
minutes < 10 ? '0' : ''
|
|
||||||
}${minutes}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function phoneNumberOnly(phone: string): string {
|
|
||||||
return phone.replace(/[^0-9]/g, '');
|
|
||||||
}
|
|
||||||
|
|
||||||
export function timeIsBefore(
|
|
||||||
currentTime: number,
|
|
||||||
time: number,
|
|
||||||
diffInMilliseconds: number,
|
|
||||||
): boolean {
|
|
||||||
return time < currentTime + diffInMilliseconds;
|
|
||||||
}
|
|
|
@ -1,101 +0,0 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import { QueueDataService, QueueService } from '../data/services/queue.service';
|
|
||||||
import { IndexQueueManager } from './usecases/index-queue.manager';
|
|
||||||
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
|
|
||||||
import { Queue } from './entities/queue.entity';
|
|
||||||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
|
||||||
import {
|
|
||||||
CallQueueManager,
|
|
||||||
DoneQueueManager,
|
|
||||||
} from './usecases/call-queue.manager';
|
|
||||||
import {
|
|
||||||
ORDER_TYPE,
|
|
||||||
QUEUE_STATUS,
|
|
||||||
} from 'src/core/strings/constants/base.constants';
|
|
||||||
import { QueueTimeFormula } from './usecases/formula/queue-time.formula';
|
|
||||||
import * as moment from 'moment';
|
|
||||||
import { timeIsBefore } from './helpers/time.helper';
|
|
||||||
import { WhatsappService } from 'src/services/whatsapp/whatsapp.service';
|
|
||||||
import { WhatsappQueue } from 'src/services/whatsapp/entity/whatsapp-queue.entity';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class QueueAdminOrchestrator {
|
|
||||||
constructor(
|
|
||||||
private readonly dataService: QueueDataService,
|
|
||||||
private readonly service: QueueService,
|
|
||||||
private indexManager: IndexQueueManager,
|
|
||||||
private callManager: CallQueueManager,
|
|
||||||
private doneManager: DoneQueueManager,
|
|
||||||
private readonly queueTimeFormula: QueueTimeFormula,
|
|
||||||
) {}
|
|
||||||
|
|
||||||
async index(params): Promise<PaginationResponse<Queue>> {
|
|
||||||
this.indexManager.setFilterParam({ order_type: ORDER_TYPE.ASC, ...params });
|
|
||||||
this.indexManager.setService(this.dataService, TABLE_NAME.QUEUE);
|
|
||||||
await this.indexManager.execute();
|
|
||||||
return this.indexManager.getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
async call(dataId): Promise<string> {
|
|
||||||
this.callManager.setData(dataId, QUEUE_STATUS.CALLED);
|
|
||||||
this.callManager.setService(this.service, TABLE_NAME.QUEUE);
|
|
||||||
await this.callManager.execute();
|
|
||||||
return this.callManager.getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
async done(dataId): Promise<string> {
|
|
||||||
this.doneManager.setData(dataId, QUEUE_STATUS.DONE);
|
|
||||||
this.doneManager.setService(this.service, TABLE_NAME.QUEUE);
|
|
||||||
await this.doneManager.execute();
|
|
||||||
return this.doneManager.getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
async job(): Promise<void> {
|
|
||||||
const notification = new WhatsappService();
|
|
||||||
const itemMasters = await this.dataService.allQueue();
|
|
||||||
const currentTime = moment().valueOf();
|
|
||||||
|
|
||||||
for (const queueItem of itemMasters) {
|
|
||||||
const queueTimes = await this.queueTimeFormula.items(queueItem.id);
|
|
||||||
const call_preparation = queueItem.call_preparation * 60 * 1000;
|
|
||||||
if (!queueItem.use_notification) continue;
|
|
||||||
|
|
||||||
for (const queueId in queueTimes) {
|
|
||||||
const callTime = queueTimes[queueId];
|
|
||||||
|
|
||||||
const queueTicket = await this.service.queueTicket(queueId);
|
|
||||||
if (
|
|
||||||
queueItem.requiring_notification ||
|
|
||||||
(timeIsBefore(currentTime, callTime, call_preparation) &&
|
|
||||||
queueTicket.time > currentTime)
|
|
||||||
) {
|
|
||||||
const payload: WhatsappQueue = {
|
|
||||||
id: queueId,
|
|
||||||
phone: queueTicket.item.ticket.phone,
|
|
||||||
code: queueTicket.code,
|
|
||||||
name: queueTicket.item.ticket.customer,
|
|
||||||
item_name: queueItem.name,
|
|
||||||
time: callTime,
|
|
||||||
};
|
|
||||||
|
|
||||||
// console.table([
|
|
||||||
// {
|
|
||||||
// code: queueTicket.code,
|
|
||||||
// currentTime: toTime(currentTime),
|
|
||||||
// callTime: toTime(callTime),
|
|
||||||
// lastNotification: toTime(queueTicket.last_notification),
|
|
||||||
// },
|
|
||||||
// ]);
|
|
||||||
|
|
||||||
if (
|
|
||||||
queueTicket.item.ticket.phone != null &&
|
|
||||||
queueTicket.last_notification < currentTime - call_preparation
|
|
||||||
) {
|
|
||||||
await notification.queueProcess(payload);
|
|
||||||
this.service.updateLastNotification(queueId, currentTime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,242 +0,0 @@
|
||||||
import { Injectable, UnauthorizedException } from '@nestjs/common';
|
|
||||||
import { TicketDataService } from '../data/services/ticket.service';
|
|
||||||
import { QueueOrder } from './entities/order.entity';
|
|
||||||
import { Queue } from './entities/queue.entity';
|
|
||||||
import {
|
|
||||||
QueueDataService,
|
|
||||||
QueueOrderService,
|
|
||||||
QueueService,
|
|
||||||
} from '../data/services/queue.service';
|
|
||||||
import { RegisterQueueManager } from './usecases/register-queue.manager';
|
|
||||||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
|
||||||
import { RegisterQueueDto } from '../infrastructure/controllers/dto/register-queue.dto';
|
|
||||||
import { CustomerQueueSummaryManager } from './usecases/queue/customer-queue-summary.manager';
|
|
||||||
import { CustomerQueueDetailManager } from './usecases/queue/customer-queue-detail.manager';
|
|
||||||
import { CustomerQueueItemManager } from './usecases/queue/customer-queue-item.manager';
|
|
||||||
import { CustomerQueueItemListManager } from './usecases/queue/customer-queue-item-list.manager';
|
|
||||||
import { CustomerQueueListManager } from './usecases/queue/customer-queue-list.manager';
|
|
||||||
import { SplitQueueDto } from '../infrastructure/controllers/dto/split-queue.dto';
|
|
||||||
import { SplitQueueManager } from './usecases/split-queue.manager';
|
|
||||||
import { LoginQueueDto } from '../infrastructure/controllers/dto/login-queue.dto';
|
|
||||||
import * as moment from 'moment';
|
|
||||||
import { CustomerQueueTicketSummaryManager } from './usecases/queue/customer-queue-ticket.manager';
|
|
||||||
import { TransactionDataService } from 'src/modules/transaction/transaction/data/services/transaction-data.service';
|
|
||||||
import { CustomerQueuePosItemManager } from './usecases/queue/customer-queue-pos-item.manager';
|
|
||||||
import {
|
|
||||||
QueueModel,
|
|
||||||
QueueOrderModel,
|
|
||||||
QueueTicketModel,
|
|
||||||
} from '../data/models/queue.model';
|
|
||||||
import { CustomerQueueRecommendManager } from './usecases/queue/customer-queue-recommend.manager';
|
|
||||||
import { GenerateQueueManager } from './usecases/generate-queue.manager';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class QueueOrchestrator {
|
|
||||||
constructor(
|
|
||||||
public readonly dataService: TicketDataService,
|
|
||||||
public readonly transactionService: TransactionDataService,
|
|
||||||
private readonly queueService: QueueService,
|
|
||||||
private readonly queueOrderService: QueueOrderService,
|
|
||||||
private readonly registerQueueManager: RegisterQueueManager,
|
|
||||||
private readonly splitQueueManager: SplitQueueManager,
|
|
||||||
private readonly queueDataService: QueueDataService,
|
|
||||||
private readonly generateQueueManager: GenerateQueueManager,
|
|
||||||
) {}
|
|
||||||
|
|
||||||
async generate(data: any): Promise<QueueModel[]> {
|
|
||||||
return await this.generateQueueManager.generate(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
async loginCustomer(id: string): Promise<QueueOrder> {
|
|
||||||
try {
|
|
||||||
const order = await this.dataService.loginQueue(id);
|
|
||||||
const code = order.tickets[0].code ?? order.code;
|
|
||||||
const tickets = await this.dataService.ticketByCode(code);
|
|
||||||
order.tickets = tickets;
|
|
||||||
return order;
|
|
||||||
} catch (error) {
|
|
||||||
throw new UnauthorizedException({
|
|
||||||
message: 'Invoice tidak ditemukan',
|
|
||||||
error: 'INVOICE_NOT_FOUND',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async loginPhone(login: LoginQueueDto): Promise<QueueOrder> {
|
|
||||||
const { name, phone } = login;
|
|
||||||
const now = moment().format('DD/MM/YYYY');
|
|
||||||
try {
|
|
||||||
const order = await this.dataService.loginPhone(name, phone);
|
|
||||||
const code = order.tickets[0].code ?? order.code;
|
|
||||||
const tickets = await this.dataService.ticketByCode(code);
|
|
||||||
order.tickets = tickets;
|
|
||||||
return order;
|
|
||||||
} catch (error) {
|
|
||||||
throw new UnauthorizedException({
|
|
||||||
message: `Antrian atas nama ${name} dan nomor telepon ${phone} pada tanggal ${now} tidak ditemukan`,
|
|
||||||
error: 'INVOICE_NOT_FOUND',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async create(data: RegisterQueueDto): Promise<Queue> {
|
|
||||||
const queue = await this.queueService.getTicketItems(
|
|
||||||
data.ticket_id,
|
|
||||||
data.item_id,
|
|
||||||
);
|
|
||||||
const queueRequest: any = {
|
|
||||||
qty: data.qty,
|
|
||||||
item_id: queue.id,
|
|
||||||
};
|
|
||||||
this.registerQueueManager.setData(queueRequest);
|
|
||||||
this.registerQueueManager.setService(this.queueService, TABLE_NAME.QUEUE);
|
|
||||||
await this.registerQueueManager.execute();
|
|
||||||
return this.registerQueueManager.getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
async split(data: SplitQueueDto): Promise<QueueOrder> {
|
|
||||||
const queueIds = data.items.map((i) => i.queue_item_id);
|
|
||||||
const queue = await this.dataService.orderItems(data.order_id, queueIds);
|
|
||||||
|
|
||||||
const existTicket = await this.dataService.ticketByUser(
|
|
||||||
data.name,
|
|
||||||
data.phone,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (existTicket) {
|
|
||||||
const itemTickets = this.itemsFromOrder(queue);
|
|
||||||
|
|
||||||
const items = data.items.map((item) => {
|
|
||||||
const item_id = itemTickets[item.queue_item_id];
|
|
||||||
return {
|
|
||||||
item_queue_id: item_id,
|
|
||||||
item_id: item_id,
|
|
||||||
qty: item.qty,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
existTicket.items.push(...items);
|
|
||||||
await this.dataService.updateQueueTicket(existTicket);
|
|
||||||
|
|
||||||
data.items.forEach((item) => {
|
|
||||||
this.queueService.updateItemQty(item.queue_item_id, item.qty);
|
|
||||||
});
|
|
||||||
|
|
||||||
return queue;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.splitQueueManager.setRequestData(data);
|
|
||||||
this.splitQueueManager.setData(queue);
|
|
||||||
this.splitQueueManager.setService(
|
|
||||||
this.queueOrderService,
|
|
||||||
TABLE_NAME.QUEUE_ORDER,
|
|
||||||
);
|
|
||||||
await this.splitQueueManager.execute();
|
|
||||||
return this.splitQueueManager.getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
itemsFromOrder(order: QueueOrderModel) {
|
|
||||||
const itemTickets = {};
|
|
||||||
order.tickets.forEach((ticket) => {
|
|
||||||
ticket.items.forEach((item) => {
|
|
||||||
itemTickets[item.id] = item.item_id;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
return itemTickets;
|
|
||||||
}
|
|
||||||
|
|
||||||
async queuePOSTickets(order_id: string): Promise<any> {
|
|
||||||
const tickets = await this.dataService.queuePosTickets(order_id);
|
|
||||||
const manager = new CustomerQueuePosItemManager(tickets);
|
|
||||||
return manager.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
async queueTickets(order_id: string): Promise<any> {
|
|
||||||
const tickets = await this.dataService.queueTickets(order_id);
|
|
||||||
const manager = new CustomerQueueSummaryManager(tickets);
|
|
||||||
return manager.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
async queueTicketDetail(order_id: string, ticket_id: string): Promise<any> {
|
|
||||||
const tickets = await this.dataService.queueTicketItems(
|
|
||||||
order_id,
|
|
||||||
ticket_id,
|
|
||||||
);
|
|
||||||
|
|
||||||
const queueItemIds = this.getQueueItemFromTickets(tickets);
|
|
||||||
const queues = await this.queueService.queues(queueItemIds);
|
|
||||||
const manager = new CustomerQueueDetailManager(tickets);
|
|
||||||
manager.currentQueues(queues);
|
|
||||||
return manager.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
async queueTicketSummary(order_id: string, ticket_id: string): Promise<any> {
|
|
||||||
const tickets = await this.dataService.queueTicketActive(
|
|
||||||
order_id,
|
|
||||||
ticket_id,
|
|
||||||
);
|
|
||||||
|
|
||||||
const manager = new CustomerQueueTicketSummaryManager(tickets);
|
|
||||||
return manager.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
async queueItemDetail(order_id: string, item_id: string): Promise<any> {
|
|
||||||
const tickets = await this.dataService.queueItemTickets(order_id, item_id);
|
|
||||||
const manager = new CustomerQueueItemManager(tickets);
|
|
||||||
return manager.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
async queueItemRecommendation(order_id: string): Promise<any> {
|
|
||||||
const tickets = await this.dataService.queueTickets(order_id);
|
|
||||||
const queueItemIds = this.getQueueItemFromTickets(tickets);
|
|
||||||
const recommendItems = await this.queueDataService.exclude(queueItemIds);
|
|
||||||
const recommendIds = recommendItems.map((item) => item.id);
|
|
||||||
const queues = await this.queueService.queues(recommendIds);
|
|
||||||
const manager = new CustomerQueueRecommendManager(tickets);
|
|
||||||
manager.currentQueues(queues);
|
|
||||||
return manager.recommend(recommendItems);
|
|
||||||
}
|
|
||||||
|
|
||||||
async queueItemSummary(): Promise<any> {
|
|
||||||
const recommendItems = await this.queueDataService.allQueue();
|
|
||||||
const recommendIds = recommendItems.map((item) => item.id);
|
|
||||||
const queues = await this.queueService.queues(recommendIds);
|
|
||||||
const manager = new CustomerQueueRecommendManager(null);
|
|
||||||
manager.currentQueues(queues);
|
|
||||||
return manager.recommend(recommendItems);
|
|
||||||
}
|
|
||||||
|
|
||||||
async queueItems(order_id: string): Promise<any> {
|
|
||||||
const tickets = await this.dataService.queueTickets(order_id);
|
|
||||||
const queueItemIds = this.getQueueItemFromTickets(tickets);
|
|
||||||
const queues = await this.queueService.queues(queueItemIds);
|
|
||||||
const manager = new CustomerQueueItemListManager(tickets);
|
|
||||||
manager.currentQueues(queues);
|
|
||||||
return manager.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
async queueUniqueItems(order_id: string): Promise<any> {
|
|
||||||
const tickets = await this.dataService.queueUniqueTickets(order_id);
|
|
||||||
const queueItemIds = this.getQueueItemFromTickets(tickets);
|
|
||||||
const queues = await this.queueService.queues(queueItemIds);
|
|
||||||
const manager = new CustomerQueueItemListManager(tickets);
|
|
||||||
manager.currentQueues(queues);
|
|
||||||
return manager.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
async queueOrderItems(order_id: string): Promise<any> {
|
|
||||||
const tickets = await this.dataService.queueTickets(order_id);
|
|
||||||
const manager = new CustomerQueueListManager(tickets);
|
|
||||||
return manager.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
getQueueItemFromTickets(tickets: QueueTicketModel[]) {
|
|
||||||
const queueItemIds = tickets.map((ticket) => {
|
|
||||||
return ticket.items.map((item) => {
|
|
||||||
return item.item.item_queue_id;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
return queueItemIds.flat();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,47 +0,0 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import { BaseUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-update-status.manager';
|
|
||||||
import {
|
|
||||||
EventTopics,
|
|
||||||
validateRelations,
|
|
||||||
} from 'src/core/strings/constants/interface.constants';
|
|
||||||
import { Queue } from '../entities/queue.entity';
|
|
||||||
import { QueueModel } from '../../data/models/queue.model';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class CallQueueManager extends BaseUpdateStatusManager<Queue> {
|
|
||||||
getResult(): string {
|
|
||||||
return `Success call Queue ${this.result.code}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
async validateProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async beforeProcess(): Promise<void> {
|
|
||||||
this.data.call_time = new Date().getTime();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async afterProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
get validateRelations(): validateRelations[] {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
get entityTarget(): any {
|
|
||||||
return QueueModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
get eventTopics(): EventTopics[] {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class DoneQueueManager extends CallQueueManager {
|
|
||||||
async beforeProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,84 +0,0 @@
|
||||||
import { QueueModel } from 'src/modules/queue/data/models/queue.model';
|
|
||||||
import { toTime } from '../../helpers/time.helper';
|
|
||||||
import * as math from 'mathjs';
|
|
||||||
import { QueueTimeFormula } from './queue-time.formula';
|
|
||||||
import * as moment from 'moment';
|
|
||||||
|
|
||||||
export class QueueCondition {
|
|
||||||
private ticketItems = {};
|
|
||||||
constructor(readonly items: QueueModel[]) {
|
|
||||||
items.forEach((item) => {
|
|
||||||
const item_id = item.item_queue_id;
|
|
||||||
const currentItem = this.ticketItems[item_id];
|
|
||||||
this.ticketItems[item_id] = currentItem ? [...currentItem, item] : [item];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
condition(item_id: string) {
|
|
||||||
const queues: QueueModel[] = this.ticketItems[item_id] ?? [];
|
|
||||||
const playEstimation = queues[0]?.average ?? 0;
|
|
||||||
const peakLevel = queues[0]?.peak_level ?? 100;
|
|
||||||
const [time, last] = this.queueTime(queues, playEstimation);
|
|
||||||
const nearest = time ? toTime(time) : 0;
|
|
||||||
const lastTime = last ? toTime(last + playEstimation) : 0;
|
|
||||||
|
|
||||||
const queuePeople = this.queuePeople(queues, peakLevel);
|
|
||||||
|
|
||||||
return {
|
|
||||||
available: queuePeople == 0,
|
|
||||||
average: this.averageTime(queues),
|
|
||||||
nearest: nearest,
|
|
||||||
crowded_level: queuePeople,
|
|
||||||
available_time: lastTime,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
queuePeople(queues: QueueModel[], peakLevel): number {
|
|
||||||
const queue = this.activeQueue(queues);
|
|
||||||
const level = peakLevel / 100;
|
|
||||||
const queuePeople = queue.reduce((acc, q) => {
|
|
||||||
return acc + q.qty;
|
|
||||||
}, 0);
|
|
||||||
return queuePeople * level;
|
|
||||||
}
|
|
||||||
|
|
||||||
activeQueue(queues: QueueModel[]) {
|
|
||||||
return queues.filter((q) => q.status == 'waiting');
|
|
||||||
}
|
|
||||||
|
|
||||||
queueTime(queues: QueueModel[], average = 0): number[] {
|
|
||||||
const calledQueue = queues.filter((q) =>
|
|
||||||
['called', 'done'].includes(q.status),
|
|
||||||
);
|
|
||||||
const lastCalledQueue = calledQueue[calledQueue.length - 1];
|
|
||||||
const activeQueues = this.activeQueue(queues);
|
|
||||||
|
|
||||||
const queueTimes = QueueTimeFormula.queueTime(
|
|
||||||
activeQueues,
|
|
||||||
lastCalledQueue,
|
|
||||||
average,
|
|
||||||
);
|
|
||||||
|
|
||||||
const queueEstimation = Object.values<number>(queueTimes);
|
|
||||||
|
|
||||||
const first = queueEstimation[0] ?? moment().valueOf();
|
|
||||||
const last = queueEstimation[queueEstimation.length - 1] ?? 0;
|
|
||||||
return [first, last];
|
|
||||||
}
|
|
||||||
|
|
||||||
averageTime(queues: QueueModel[]) {
|
|
||||||
if (queues.length == 0) return 0;
|
|
||||||
const calledQueue = queues.filter((q) =>
|
|
||||||
['called', 'done'].includes(q.status),
|
|
||||||
);
|
|
||||||
|
|
||||||
if (calledQueue.length < 1) return 0;
|
|
||||||
|
|
||||||
const times = calledQueue.map((queue) => {
|
|
||||||
return (queue.call_time - queue.time) / 1000;
|
|
||||||
});
|
|
||||||
|
|
||||||
const avg = Math.ceil(math.mean(times));
|
|
||||||
return Math.max(0, avg);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,73 +0,0 @@
|
||||||
import { InjectRepository } from '@nestjs/typeorm';
|
|
||||||
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
|
||||||
import { ItemQueueModel } from 'src/modules/item-related/item-queue/data/models/item-queue.model';
|
|
||||||
import { QueueDataService } from 'src/modules/queue/data/services/queue.service';
|
|
||||||
import { Repository } from 'typeorm';
|
|
||||||
import * as moment from 'moment';
|
|
||||||
import * as math from 'mathjs';
|
|
||||||
import { QueueModel } from 'src/modules/queue/data/models/queue.model';
|
|
||||||
|
|
||||||
export class QueueTimeFormula {
|
|
||||||
constructor(
|
|
||||||
private readonly queueDataService: QueueDataService,
|
|
||||||
@InjectRepository(ItemQueueModel, CONNECTION_NAME.DEFAULT)
|
|
||||||
private itemQueueRepo: Repository<ItemQueueModel>,
|
|
||||||
) {}
|
|
||||||
|
|
||||||
public average = 0;
|
|
||||||
|
|
||||||
async items(item_queue_id: string) {
|
|
||||||
const queues = await this.queueDataService.waitingQueue(item_queue_id);
|
|
||||||
if (queues.length == 0) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
const itemQueue = await this.itemQueueRepo.findOne({
|
|
||||||
relations: ['items'],
|
|
||||||
where: {
|
|
||||||
id: item_queue_id,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const times = itemQueue.items.map((item) => item.play_estimation ?? 0);
|
|
||||||
const average = times.length > 0 ? math.mean(times) * 60 * 1000 : 0; // change average minute to milliseconds
|
|
||||||
this.average = Math.floor(average);
|
|
||||||
|
|
||||||
const calledQueue = await this.queueDataService.lastQueue(item_queue_id);
|
|
||||||
|
|
||||||
return QueueTimeFormula.queueTime(queues, calledQueue, average);
|
|
||||||
}
|
|
||||||
|
|
||||||
static queueTime(
|
|
||||||
queues: QueueModel[],
|
|
||||||
lastQueue: QueueModel,
|
|
||||||
average: number,
|
|
||||||
) {
|
|
||||||
const queueTimes = {};
|
|
||||||
if (queues.length < 1) return queueTimes;
|
|
||||||
const timeNow = moment().valueOf();
|
|
||||||
const lastCall = lastQueue?.call_time ?? timeNow - average;
|
|
||||||
|
|
||||||
const callTime = +lastCall + average;
|
|
||||||
const currentQueueCallTime = timeNow > callTime ? timeNow : callTime;
|
|
||||||
|
|
||||||
queueTimes[queues[0].id] = currentQueueCallTime;
|
|
||||||
let now = currentQueueCallTime;
|
|
||||||
|
|
||||||
for (let i = 1; i < queues.length; i++) {
|
|
||||||
const before = queues[i - 1];
|
|
||||||
// duration will be total qty multiple by average from last queue
|
|
||||||
const duration = before.qty * average;
|
|
||||||
|
|
||||||
const queue = queues[i];
|
|
||||||
// time to call will be now + duration
|
|
||||||
const time = now + duration;
|
|
||||||
queueTimes[queue.id] = time;
|
|
||||||
|
|
||||||
// update now to last call time
|
|
||||||
now = time;
|
|
||||||
}
|
|
||||||
|
|
||||||
return queueTimes;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,161 +0,0 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import * as moment from 'moment';
|
|
||||||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
|
||||||
import { TransactionUserType } from 'src/modules/transaction/transaction/constants';
|
|
||||||
import { TransactionItemModel } from 'src/modules/transaction/transaction/data/models/transaction-item.model';
|
|
||||||
import { QueueBucketReadService } from '../../data/services/queue-bucket';
|
|
||||||
import { QueueService } from '../../data/services/queue.service';
|
|
||||||
import { TicketDataService } from '../../data/services/ticket.service';
|
|
||||||
import { RegisterQueueDto } from '../../infrastructure/controllers/dto/register-queue.dto';
|
|
||||||
import { QueueOrder } from '../entities/order.entity';
|
|
||||||
import { QueueItem } from '../entities/queue-item.entity';
|
|
||||||
import { QueueTicket } from '../entities/ticket.entity';
|
|
||||||
import { QueueTimeFormula } from './formula/queue-time.formula';
|
|
||||||
import { RegisterQueueManager } from './register-queue.manager';
|
|
||||||
import { TransactionModel } from 'src/modules/transaction/transaction/data/models/transaction.model';
|
|
||||||
import { QueueModel } from '../../data/models/queue.model';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class GenerateQueueManager {
|
|
||||||
constructor(
|
|
||||||
private readonly ticketService: TicketDataService,
|
|
||||||
private readonly queueService: QueueService,
|
|
||||||
private readonly bucketService: QueueBucketReadService,
|
|
||||||
private readonly queueTimeFormula: QueueTimeFormula,
|
|
||||||
) {}
|
|
||||||
|
|
||||||
async generate(transaction: TransactionModel) {
|
|
||||||
const date = transaction.booking_date ?? transaction.invoice_date;
|
|
||||||
const queue_date = moment(date, 'YYYY-MM-DD').unix();
|
|
||||||
|
|
||||||
const { id, customer_name, customer_phone, invoice_code } = transaction;
|
|
||||||
|
|
||||||
const customerOrder = {
|
|
||||||
code: invoice_code,
|
|
||||||
customer: customer_name,
|
|
||||||
phone: customer_phone,
|
|
||||||
date: queue_date * 1000,
|
|
||||||
transaction_id: id,
|
|
||||||
};
|
|
||||||
|
|
||||||
const items = this.generateItems(transaction.items);
|
|
||||||
|
|
||||||
const existTicket = await this.ticketService.ticketByUser(
|
|
||||||
customer_name,
|
|
||||||
customer_phone,
|
|
||||||
);
|
|
||||||
|
|
||||||
const insertTickets: QueueTicket[] = [];
|
|
||||||
if (customer_name && customer_phone && existTicket) {
|
|
||||||
existTicket.items.push(...items);
|
|
||||||
await this.ticketService.updateQueueTicket(existTicket);
|
|
||||||
|
|
||||||
existTicket.items = items;
|
|
||||||
insertTickets.push(existTicket);
|
|
||||||
} else {
|
|
||||||
const ticket: QueueTicket = { ...customerOrder, items };
|
|
||||||
const order: QueueOrder = { ...customerOrder, tickets: [ticket] };
|
|
||||||
|
|
||||||
const queueOrder = await this.ticketService.createQueueOrder(order);
|
|
||||||
insertTickets.push(...queueOrder.tickets);
|
|
||||||
}
|
|
||||||
|
|
||||||
const results: QueueModel[] = [];
|
|
||||||
const vipCustomer =
|
|
||||||
transaction.customer_category?.has_vip_pass ||
|
|
||||||
transaction.customer_type === TransactionUserType.VIP;
|
|
||||||
if (vipCustomer || transaction.creator_counter_no != null) {
|
|
||||||
for (const ticket of insertTickets) {
|
|
||||||
const ticket_id = ticket.id;
|
|
||||||
const items = {};
|
|
||||||
|
|
||||||
ticket.items.forEach((item) => {
|
|
||||||
const item_id = item['item_queue_id'];
|
|
||||||
const currentItem = items[item_id];
|
|
||||||
|
|
||||||
if (currentItem) {
|
|
||||||
currentItem.qty += item.qty;
|
|
||||||
}
|
|
||||||
items[item_id] = currentItem
|
|
||||||
? currentItem
|
|
||||||
: {
|
|
||||||
item_id,
|
|
||||||
ticket_id,
|
|
||||||
qty: item.qty,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
for (const payload of Object.values(items)) {
|
|
||||||
const isVip = vipCustomer || transaction.creator_counter_no == null;
|
|
||||||
const result = await this.create(payload as any, isVip);
|
|
||||||
results.push(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
generateItems(items: TransactionItemModel[]): QueueItem[] {
|
|
||||||
const transactionItems = [];
|
|
||||||
|
|
||||||
items.forEach((item) => {
|
|
||||||
if (item.item.use_queue) {
|
|
||||||
transactionItems.push({
|
|
||||||
item_queue_id: item.item.item_queue_id,
|
|
||||||
item_id: item.item_id,
|
|
||||||
qty: item.qty,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (item.item.bundling_items.length > 0) {
|
|
||||||
item.item.bundling_items.forEach((bundling_item) => {
|
|
||||||
if (bundling_item.use_queue) {
|
|
||||||
transactionItems.push({
|
|
||||||
item_queue_id: bundling_item.item_queue_id,
|
|
||||||
item_id: bundling_item.id,
|
|
||||||
qty: item.qty,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return this.mergeQueueItems(transactionItems);
|
|
||||||
}
|
|
||||||
|
|
||||||
mergeQueueItems(arr) {
|
|
||||||
const result = {};
|
|
||||||
arr.forEach((item) => {
|
|
||||||
if (result[item.item_id]) {
|
|
||||||
result[item.item_id].qty += item.qty;
|
|
||||||
} else {
|
|
||||||
result[item.item_id] = { ...item };
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return Object.values<QueueItem>(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
async create(data: RegisterQueueDto, isVip = false): Promise<QueueModel> {
|
|
||||||
const queue = await this.queueService.getTicketItems(
|
|
||||||
data.ticket_id,
|
|
||||||
data.item_id,
|
|
||||||
);
|
|
||||||
const queueRequest: any = {
|
|
||||||
qty: data.qty,
|
|
||||||
item_id: queue.id,
|
|
||||||
vip: isVip,
|
|
||||||
};
|
|
||||||
const registerQueueManager = new RegisterQueueManager(
|
|
||||||
this.bucketService,
|
|
||||||
this.queueTimeFormula,
|
|
||||||
);
|
|
||||||
registerQueueManager.setData(queueRequest);
|
|
||||||
registerQueueManager.setService(this.queueService, TABLE_NAME.QUEUE);
|
|
||||||
await registerQueueManager.execute();
|
|
||||||
|
|
||||||
const result = await registerQueueManager.getResult();
|
|
||||||
result.time = null;
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,111 +0,0 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import { BaseIndexManager } from 'src/core/modules/domain/usecase/managers/base-index.manager';
|
|
||||||
import { SelectQueryBuilder } from 'typeorm';
|
|
||||||
import {
|
|
||||||
Param,
|
|
||||||
RelationParam,
|
|
||||||
} from 'src/core/modules/domain/entities/base-filter.entity';
|
|
||||||
import { Queue } from '../entities/queue.entity';
|
|
||||||
import * as moment from 'moment';
|
|
||||||
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
|
|
||||||
import { QueueTimeFormula } from './formula/queue-time.formula';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class IndexQueueManager extends BaseIndexManager<Queue> {
|
|
||||||
constructor(private readonly queueTimeFormula: QueueTimeFormula) {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
private queueTimes = {};
|
|
||||||
async prepareData(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async beforeProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async afterProcess(): Promise<void> {
|
|
||||||
this.queueTimes = await this.queueTimeFormula.items(
|
|
||||||
this.filterParam.queue_id,
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
get relations(): RelationParam {
|
|
||||||
return {
|
|
||||||
joinRelations: [],
|
|
||||||
selectRelations: ['item', 'item.ticket'],
|
|
||||||
countRelations: [],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
getResult(): PaginationResponse<Queue> {
|
|
||||||
const result = this.result;
|
|
||||||
|
|
||||||
return {
|
|
||||||
total: result.total,
|
|
||||||
data: result.data.map((queue) => {
|
|
||||||
return {
|
|
||||||
...queue,
|
|
||||||
estimation: this.queueTimes[queue.id],
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
get selects(): string[] {
|
|
||||||
return [
|
|
||||||
`${this.tableName}.id`,
|
|
||||||
`${this.tableName}.code`,
|
|
||||||
`${this.tableName}.status`,
|
|
||||||
`${this.tableName}.time`,
|
|
||||||
`${this.tableName}.call_time`,
|
|
||||||
`${this.tableName}.vip`,
|
|
||||||
`${this.tableName}.item`,
|
|
||||||
`${this.tableName}.qty`,
|
|
||||||
`${this.tableName}.created_at`,
|
|
||||||
|
|
||||||
`item.id`,
|
|
||||||
`ticket.customer`,
|
|
||||||
`ticket.phone`,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
get specificFilter(): Param[] {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
cols: `${this.tableName}.status`,
|
|
||||||
data: this.filterParam.status,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
setQueryFilter(
|
|
||||||
queryBuilder: SelectQueryBuilder<Queue>,
|
|
||||||
): SelectQueryBuilder<Queue> {
|
|
||||||
const start = moment().startOf('day').valueOf();
|
|
||||||
const end = moment().endOf('day').valueOf();
|
|
||||||
|
|
||||||
console.log({ start, end, item_queue_id: this.filterParam.queue_id });
|
|
||||||
|
|
||||||
queryBuilder.andWhere(
|
|
||||||
`${this.tableName}.created_at BETWEEN :start AND :end`,
|
|
||||||
{
|
|
||||||
start,
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
queryBuilder.andWhere(`${this.tableName}.item_queue_id = :item_queue_id`, {
|
|
||||||
item_queue_id: this.filterParam.queue_id,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (this.filterParam.vip != null) {
|
|
||||||
queryBuilder.andWhere(`${this.tableName}.vip = :vip`, {
|
|
||||||
vip: this.filterParam.vip,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return queryBuilder;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,48 +0,0 @@
|
||||||
import { QueueModel } from 'src/modules/queue/data/models/queue.model';
|
|
||||||
import { CustomerQueueManager } from './customer-queue.manager';
|
|
||||||
import { QueueCondition } from '../formula/queue-condition.formula';
|
|
||||||
|
|
||||||
export class CustomerQueueDetailManager extends CustomerQueueManager {
|
|
||||||
private queues: QueueModel[] = [];
|
|
||||||
currentQueues(queues: QueueModel[]) {
|
|
||||||
this.queues = queues;
|
|
||||||
}
|
|
||||||
get data() {
|
|
||||||
const queueCondition = new QueueCondition(this.queues);
|
|
||||||
return this.tickets.map((ticket) => {
|
|
||||||
const queueItems = this.mergeQueueItems(ticket);
|
|
||||||
return {
|
|
||||||
id: ticket.id,
|
|
||||||
code: ticket.code,
|
|
||||||
customer: ticket.customer,
|
|
||||||
phone: ticket.phone,
|
|
||||||
date: ticket.date,
|
|
||||||
summary: this.summaryTicket(ticket),
|
|
||||||
items: queueItems.map((item) => {
|
|
||||||
return {
|
|
||||||
id: item.id,
|
|
||||||
item_queue_id: item.queue_item_id,
|
|
||||||
title: item.title,
|
|
||||||
image_url: item.image_url,
|
|
||||||
summary: {
|
|
||||||
total_tickets: item.qty,
|
|
||||||
total_used: this.totalUsedItems(item.queues),
|
|
||||||
total_queue: this.totalQueueItems(item.queues),
|
|
||||||
},
|
|
||||||
queue: item.queues
|
|
||||||
.sort((a, b) => b.time - a.time)
|
|
||||||
.map((q) => {
|
|
||||||
return {
|
|
||||||
code: q.code,
|
|
||||||
qty: q.qty,
|
|
||||||
time: this.toTime(q.time),
|
|
||||||
status: q.status,
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
queue_condition: queueCondition.condition(item.queue_item_id),
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,62 +0,0 @@
|
||||||
import {
|
|
||||||
QueueItemModel,
|
|
||||||
QueueModel,
|
|
||||||
} from 'src/modules/queue/data/models/queue.model';
|
|
||||||
import { CustomerQueueManager } from './customer-queue.manager';
|
|
||||||
import { QueueCondition } from '../formula/queue-condition.formula';
|
|
||||||
|
|
||||||
export class CustomerQueueItemListManager extends CustomerQueueManager {
|
|
||||||
protected queues: QueueModel[] = [];
|
|
||||||
currentQueues(queues: QueueModel[]) {
|
|
||||||
this.queues = queues;
|
|
||||||
}
|
|
||||||
get data() {
|
|
||||||
const tickets = this.tickets;
|
|
||||||
const ticketCount = {};
|
|
||||||
const queueCondition = new QueueCondition(this.queues);
|
|
||||||
|
|
||||||
const ticketItems = {};
|
|
||||||
tickets.forEach((ticket) => {
|
|
||||||
const itemsInTicket = [];
|
|
||||||
ticket.items.forEach((item) => {
|
|
||||||
const item_id = item.item.item_queue?.id ?? item.item.id;
|
|
||||||
const currentItem = ticketItems[item_id];
|
|
||||||
ticketItems[item_id] = currentItem ? [...currentItem, item] : [item];
|
|
||||||
itemsInTicket.push(item_id);
|
|
||||||
});
|
|
||||||
|
|
||||||
const uniqueTicket = Array.from(new Set(itemsInTicket));
|
|
||||||
|
|
||||||
uniqueTicket.forEach((item_id) => {
|
|
||||||
ticketCount[item_id] = ticketCount[item_id]
|
|
||||||
? ticketCount[item_id] + 1
|
|
||||||
: 1;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
return Object.values<QueueItemModel[]>(ticketItems).map((items) => {
|
|
||||||
const item = items[0];
|
|
||||||
const item_qty = items.reduce((acc, item) => acc + item.qty, 0);
|
|
||||||
const queue_qty = this.queueItemQty(items);
|
|
||||||
const queueItem = item.item.item_queue ?? item.item;
|
|
||||||
return {
|
|
||||||
id: queueItem.id,
|
|
||||||
queue_item_id: item.id,
|
|
||||||
title: queueItem.name,
|
|
||||||
image_url: item.item.image_url,
|
|
||||||
qty: item_qty - queue_qty,
|
|
||||||
ticket: ticketCount[queueItem.id],
|
|
||||||
|
|
||||||
queue_condition: queueCondition.condition(queueItem.id),
|
|
||||||
...queueCondition.condition(queueItem.id),
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected queueItemQty(queues: QueueItemModel[]) {
|
|
||||||
return queues.reduce(
|
|
||||||
(acc, item) => acc + item.queue.reduce((acc, q) => acc + q.qty, 0),
|
|
||||||
0,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
import { CustomerQueueManager } from './customer-queue.manager';
|
|
||||||
|
|
||||||
export class CustomerQueueItemManager extends CustomerQueueManager {
|
|
||||||
get data() {
|
|
||||||
return this.tickets.map((ticket) => {
|
|
||||||
const queueItems = this.mergeQueueItems(ticket);
|
|
||||||
const item = ticket.items[0];
|
|
||||||
|
|
||||||
return {
|
|
||||||
id: ticket.id,
|
|
||||||
code: ticket.code,
|
|
||||||
customer: ticket.customer,
|
|
||||||
phone: ticket.phone,
|
|
||||||
date: ticket.date,
|
|
||||||
image_url: item.item.image_url,
|
|
||||||
summary: this.summaryTicket(ticket),
|
|
||||||
queue: queueItems[0].queues
|
|
||||||
.sort((a, b) => b.time - a.time)
|
|
||||||
.map((q) => {
|
|
||||||
return {
|
|
||||||
code: q.code,
|
|
||||||
qty: q.qty,
|
|
||||||
time: this.toTime(q.time),
|
|
||||||
status: q.status,
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,80 +0,0 @@
|
||||||
import {
|
|
||||||
QueueModel,
|
|
||||||
QueueTicketModel,
|
|
||||||
} from 'src/modules/queue/data/models/queue.model';
|
|
||||||
import { CustomerQueueManager } from './customer-queue.manager';
|
|
||||||
|
|
||||||
export class CustomerQueueListManager extends CustomerQueueManager {
|
|
||||||
private ticketToQueues(tickets: QueueTicketModel[]): QueueModel[] {
|
|
||||||
const ticket = tickets.map((ticket) => {
|
|
||||||
const queue = ticket.items.map((item) => {
|
|
||||||
return item.queue;
|
|
||||||
});
|
|
||||||
|
|
||||||
return queue.flat();
|
|
||||||
});
|
|
||||||
|
|
||||||
return ticket.flat().sort((a, b) => b.time - a.time);
|
|
||||||
}
|
|
||||||
|
|
||||||
get data() {
|
|
||||||
const tickets = this.tickets;
|
|
||||||
const ticketItems = {};
|
|
||||||
|
|
||||||
tickets.forEach((ticket) => {
|
|
||||||
ticket.items.forEach((item) => {
|
|
||||||
const item_id = item.item.item_queue?.id ?? item.item.id;
|
|
||||||
const currentItem = ticketItems[item_id];
|
|
||||||
const ticketQueue = { ...ticket, items: [item] };
|
|
||||||
|
|
||||||
ticketItems[item_id] = currentItem
|
|
||||||
? [...currentItem, ticketQueue]
|
|
||||||
: [ticketQueue];
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
return Object.keys(ticketItems)
|
|
||||||
.map((item_id) => {
|
|
||||||
const tickets: QueueTicketModel[] = ticketItems[item_id];
|
|
||||||
const item = tickets[0].items[0];
|
|
||||||
const uniqueTicket = tickets.filter(
|
|
||||||
(obj1, i, arr) => arr.findIndex((obj2) => obj2.id === obj1.id) === i,
|
|
||||||
);
|
|
||||||
let totalQueue = 0;
|
|
||||||
|
|
||||||
const currentTickets = uniqueTicket.map((ticket) => {
|
|
||||||
const currentTicket = tickets.filter((t) => t.id === ticket.id);
|
|
||||||
const queues = this.ticketToQueues(currentTicket);
|
|
||||||
const currentQueues = queues.map((q) => {
|
|
||||||
return {
|
|
||||||
code: q.code,
|
|
||||||
qty: q.qty,
|
|
||||||
time: this.toTime(q.time),
|
|
||||||
status: q.status,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
totalQueue += currentQueues.length;
|
|
||||||
return currentQueues.length > 0
|
|
||||||
? {
|
|
||||||
code: ticket.code,
|
|
||||||
customer: ticket.customer,
|
|
||||||
phone: ticket.phone,
|
|
||||||
id: ticket.id,
|
|
||||||
queue: currentQueues,
|
|
||||||
}
|
|
||||||
: null;
|
|
||||||
});
|
|
||||||
|
|
||||||
return currentTickets.filter(Boolean).length > 0
|
|
||||||
? {
|
|
||||||
id: item.item_id,
|
|
||||||
title: item.item.item_queue?.name ?? item.item.name,
|
|
||||||
image_url: item.item.image_url,
|
|
||||||
qty: totalQueue,
|
|
||||||
items: currentTickets.filter(Boolean),
|
|
||||||
}
|
|
||||||
: null;
|
|
||||||
})
|
|
||||||
.filter(Boolean);
|
|
||||||
}
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue