Compare commits
No commits in common. "99847ce85b3e2329d56d8045ed8804c7713bd60e" and "56e7d25acd3f6bcbb286508193c518995231e54b" have entirely different histories.
99847ce85b
...
56e7d25acd
|
@ -75,21 +75,11 @@ export abstract class BaseCreateManager<Entity> extends BaseManager {
|
||||||
|
|
||||||
if (!this.eventTopics.length) return;
|
if (!this.eventTopics.length) return;
|
||||||
for (const topic of this.eventTopics) {
|
for (const topic of this.eventTopics) {
|
||||||
let data;
|
|
||||||
if (!topic.data) {
|
|
||||||
data = await this.dataService.getOneByOptions({
|
|
||||||
where: {
|
|
||||||
id: this.result['id'],
|
|
||||||
},
|
|
||||||
relations: topic.relations,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
this.eventBus.publishAll([
|
this.eventBus.publishAll([
|
||||||
new topic.topic({
|
new topic.topic({
|
||||||
id: data?.['id'] ?? topic?.data?.['id'],
|
id: this.result['id'],
|
||||||
old: null,
|
old: null,
|
||||||
data: data ?? topic.data,
|
data: topic.data,
|
||||||
user: this.user,
|
user: this.user,
|
||||||
description: '',
|
description: '',
|
||||||
module: this.tableName,
|
module: this.tableName,
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
export const DatabaseListen = ['transaction', 'vip_code'];
|
export const DatabaseListen = ['transaction'];
|
||||||
|
|
|
@ -37,7 +37,6 @@ import { TransactionDataService } from 'src/modules/transaction/transaction/data
|
||||||
import { TransactionModel } from 'src/modules/transaction/transaction/data/models/transaction.model';
|
import { TransactionModel } from 'src/modules/transaction/transaction/data/models/transaction.model';
|
||||||
import { TransactionTaxModel } from 'src/modules/transaction/transaction/data/models/transaction-tax.model';
|
import { TransactionTaxModel } from 'src/modules/transaction/transaction/data/models/transaction-tax.model';
|
||||||
import { TransactionItemModel } from 'src/modules/transaction/transaction/data/models/transaction-item.model';
|
import { TransactionItemModel } from 'src/modules/transaction/transaction/data/models/transaction-item.model';
|
||||||
import { VipCodeCreatedHandler } from './domain/managers/vip-code.handler';
|
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
|
@ -60,7 +59,6 @@ import { VipCodeCreatedHandler } from './domain/managers/vip-code.handler';
|
||||||
BookingDeletedEvent,
|
BookingDeletedEvent,
|
||||||
PaymentMethodDeletedHandler,
|
PaymentMethodDeletedHandler,
|
||||||
PaymentMethodUpdatedHandler,
|
PaymentMethodUpdatedHandler,
|
||||||
VipCodeCreatedHandler,
|
|
||||||
VipCategoryDeletedHandler,
|
VipCategoryDeletedHandler,
|
||||||
VipCategoryUpdatedHandler,
|
VipCategoryUpdatedHandler,
|
||||||
SeasonPeriodDeletedHandler,
|
SeasonPeriodDeletedHandler,
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
import { EventsHandler, IEventHandler } from '@nestjs/cqrs';
|
|
||||||
import { CouchService } from '../../data/services/couch.service';
|
|
||||||
import { VipCodeCreatedEvent } from 'src/modules/transaction/vip-code/domain/entities/event/vip-code-created.event';
|
|
||||||
|
|
||||||
@EventsHandler(VipCodeCreatedEvent)
|
|
||||||
export class VipCodeCreatedHandler
|
|
||||||
implements IEventHandler<VipCodeCreatedEvent>
|
|
||||||
{
|
|
||||||
constructor(private couchService: CouchService) {}
|
|
||||||
|
|
||||||
async handle(event: VipCodeCreatedEvent) {
|
|
||||||
const data = event.data.data;
|
|
||||||
|
|
||||||
await this.couchService.createDoc(
|
|
||||||
{
|
|
||||||
_id: data.id,
|
|
||||||
...data,
|
|
||||||
},
|
|
||||||
'vip_code',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -45,7 +45,6 @@ export class IndexReconciliationManager extends BaseIndexManager<TransactionEnti
|
||||||
`${this.tableName}.reconciliation_confirm_by`,
|
`${this.tableName}.reconciliation_confirm_by`,
|
||||||
|
|
||||||
`${this.tableName}.customer_name`,
|
`${this.tableName}.customer_name`,
|
||||||
`${this.tableName}.creator_counter_no`,
|
|
||||||
|
|
||||||
`${this.tableName}.payment_type`,
|
`${this.tableName}.payment_type`,
|
||||||
`${this.tableName}.payment_type_method_id`,
|
`${this.tableName}.payment_type_method_id`,
|
||||||
|
|
|
@ -99,10 +99,6 @@ export function mappingRevertTransaction(data, type) {
|
||||||
season_period_name: data.season_period?.holiday_name ?? null,
|
season_period_name: data.season_period?.holiday_name ?? null,
|
||||||
season_period_type_id: data.season_period?.season_type?.id ?? null,
|
season_period_type_id: data.season_period?.season_type?.id ?? null,
|
||||||
season_period_type_name: data.season_period?.season_type?.name ?? null,
|
season_period_type_name: data.season_period?.season_type?.name ?? null,
|
||||||
payment_type_method_id: data.payment_type_method?.id,
|
|
||||||
payment_type_method_number: data.payment_type_method?.account_number,
|
|
||||||
payment_type_method_name: data.payment_type_method?.issuer_name,
|
|
||||||
payment_type_method_qr: data.payment_type_method?.qr_image,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
data.items?.map((item) => {
|
data.items?.map((item) => {
|
||||||
|
|
|
@ -1,40 +0,0 @@
|
||||||
import { EventsHandler, IEventHandler } from '@nestjs/cqrs';
|
|
||||||
import { ChangeDocEvent } from 'src/modules/configuration/couch/domain/events/change-doc.event';
|
|
||||||
import { VipCodeDataService } from '../../../data/services/vip-code-data.service';
|
|
||||||
import { VipCodeModel } from '../../../data/models/vip-code.model';
|
|
||||||
import { CouchService } from 'src/modules/configuration/couch/data/services/couch.service';
|
|
||||||
|
|
||||||
@EventsHandler(ChangeDocEvent)
|
|
||||||
export class CreateVipCodeHandler implements IEventHandler<ChangeDocEvent> {
|
|
||||||
constructor(
|
|
||||||
private dataService: VipCodeDataService,
|
|
||||||
private couchService: CouchService,
|
|
||||||
) {}
|
|
||||||
|
|
||||||
async handle(event: ChangeDocEvent) {
|
|
||||||
const database = event.data.database;
|
|
||||||
const data = event.data.data;
|
|
||||||
|
|
||||||
if (database != 'vip_code') return;
|
|
||||||
|
|
||||||
const queryRunner = this.dataService
|
|
||||||
.getRepository()
|
|
||||||
.manager.connection.createQueryRunner();
|
|
||||||
|
|
||||||
// jika delete
|
|
||||||
if (data._deleted ?? false) {
|
|
||||||
} else {
|
|
||||||
const dataMapped = {
|
|
||||||
...data,
|
|
||||||
id: data._id ?? data.id,
|
|
||||||
vip_category_id: data.vip_category?._id ?? data.vip_category?.id,
|
|
||||||
};
|
|
||||||
|
|
||||||
try {
|
|
||||||
await this.dataService.create(queryRunner, VipCodeModel, dataMapped);
|
|
||||||
} catch (error) {
|
|
||||||
await this.couchService.createDoc(data, 'error_vip_code');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -35,7 +35,7 @@ export class CreateVipCodeManager extends BaseCreateManager<VipCodeEntity> {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
topic: VipCodeCreatedEvent,
|
topic: VipCodeCreatedEvent,
|
||||||
relations: ['vip_category'],
|
data: this.data,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,6 @@ import { CqrsModule } from '@nestjs/cqrs';
|
||||||
import { IndexVipCodeManager } from './domain/usecases/managers/index-vip-code.manager';
|
import { IndexVipCodeManager } from './domain/usecases/managers/index-vip-code.manager';
|
||||||
import { VipCodeModel } from './data/models/vip-code.model';
|
import { VipCodeModel } from './data/models/vip-code.model';
|
||||||
import { GenerateVipCodeManager } from './domain/usecases/managers/geneate-vip-code.manager';
|
import { GenerateVipCodeManager } from './domain/usecases/managers/geneate-vip-code.manager';
|
||||||
import { CreateVipCodeHandler } from './domain/usecases/handlers/create-vip-code.handler';
|
|
||||||
import { CouchService } from 'src/modules/configuration/couch/data/services/couch.service';
|
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
|
@ -24,13 +22,10 @@ import { CouchService } from 'src/modules/configuration/couch/data/services/couc
|
||||||
],
|
],
|
||||||
controllers: [VipCodeDataController, VipCodeReadController],
|
controllers: [VipCodeDataController, VipCodeReadController],
|
||||||
providers: [
|
providers: [
|
||||||
CreateVipCodeHandler,
|
|
||||||
|
|
||||||
IndexVipCodeManager,
|
IndexVipCodeManager,
|
||||||
CreateVipCodeManager,
|
CreateVipCodeManager,
|
||||||
GenerateVipCodeManager,
|
GenerateVipCodeManager,
|
||||||
|
|
||||||
CouchService,
|
|
||||||
VipCodeDataService,
|
VipCodeDataService,
|
||||||
VipCodeReadService,
|
VipCodeReadService,
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue