a350ec7990
- Implemented AccountsService for managing consumer accounts including create, update, delete, and find operations. - Created DTOs for account creation and updates. - Developed BusinessActivitiesController and BusinessActivitiesService for handling business activities related to consumers. - Added complexes management with ComplexesController and ComplexesService. - Introduced POS management with ComplexPosesController and ComplexPosesService. - Created necessary DTOs for business activities and POS. - Established Licenses management with LicensesController and LicensesService. - Integrated consumer management with PartnerConsumersController and PartnerConsumersService. - Added Prisma module imports and service connections across modules.
62 lines
1.6 KiB
TypeScript
62 lines
1.6 KiB
TypeScript
import { PartnerAccountQuotaAllocationWhereInput } from '@/generated/prisma/models'
|
|
import { PrismaService } from '@/prisma/prisma.service'
|
|
import { Injectable } from '@nestjs/common'
|
|
import { ResponseMapper } from 'common/response/response-mapper'
|
|
|
|
@Injectable()
|
|
export class PartnerAllocatedAccountsService {
|
|
constructor(private readonly prisma: PrismaService) {}
|
|
|
|
async findAll(partner_id: string, page = 1, pageSize = 10) {
|
|
const defaultWhere: PartnerAccountQuotaAllocationWhereInput = {
|
|
charge_transaction: {
|
|
partner_id,
|
|
},
|
|
}
|
|
|
|
const [allocations, count] = await this.prisma.$transaction(async tx => [
|
|
await tx.partnerAccountQuotaAllocation.findMany({
|
|
where: defaultWhere,
|
|
skip: (page - 1) * pageSize,
|
|
take: pageSize,
|
|
select: {
|
|
id: true,
|
|
created_at: true,
|
|
updated_at: true,
|
|
charge_transaction_id: true,
|
|
license_id: true,
|
|
charge_transaction: {
|
|
select: {
|
|
id: true,
|
|
tracking_code: true,
|
|
purchased_count: true,
|
|
created_at: true,
|
|
},
|
|
},
|
|
license: {
|
|
select: {
|
|
id: true,
|
|
accounts_limit: true,
|
|
activation: {
|
|
select: {
|
|
id: true,
|
|
business_activity_id: true,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}),
|
|
await tx.partnerAccountQuotaAllocation.count({
|
|
where: defaultWhere,
|
|
}),
|
|
])
|
|
|
|
return ResponseMapper.paginate(allocations, {
|
|
page,
|
|
pageSize,
|
|
count,
|
|
})
|
|
}
|
|
}
|