feat: add consumer accounts and business activities management

- 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.
This commit is contained in:
2026-04-23 20:59:39 +03:30
parent f9e1ad69dc
commit a350ec7990
104 changed files with 13233 additions and 4105 deletions
+90 -57
View File
@@ -1,4 +1,5 @@
import { PasswordUtil } from '@/common/utils/password.util'
import { generateTrackingCode } from '@/common/utils/tracking-code-generator.util'
import { GoodPricingModel, POSType, UnitType } from '@/generated/prisma/enums'
import { GoodCreateInput, GoodCreateManyInput } from '@/generated/prisma/models'
import { prisma } from '../src/lib/prisma'
@@ -240,60 +241,9 @@ async function main() {
}
}
// ****************** BA Start ****************** //
const ba = await prisma.businessActivity.count()
if (!ba) {
await prisma.businessActivity.create({
data: {
name: 'طلا فروشی',
consumer: {
create: {
first_name: 'محمد',
last_name: 'زرگر',
mobile_number: '09120258155',
consumer_accounts: {
create: {
role: 'OWNER',
account: {
create: {
username: 'zargar',
password: await PasswordUtil.hash('123456'),
status: 'ACTIVE',
type: 'CONSUMER',
},
},
},
},
},
},
guild: {
connect: {
id: guilds[0].id,
},
},
complexes: {
create: {
name: 'فروشگاه طلای مرکزی',
address: 'تهران، خیابان جمهوری',
tax_id: '12312452345765',
pos_list: {
create: {
name: 'لاین ۱',
pos_type: POSType.WEB,
serial: '12312312',
status: 'ACTIVE',
},
},
},
},
},
})
}
// ****************** BA Start ****************** //
// ****************** partner Start ****************** //
let partner = await prisma.partner.findFirst()
let license = await prisma.license.findFirst()
if (!partner) {
partner = await prisma.partner.create({
data: {
@@ -316,7 +266,7 @@ async function main() {
},
})
}
if (partner) {
if (partner && !license) {
await prisma.$transaction(async tx => {
const startOfToday = new Date()
startOfToday.setHours(0, 0, 0, 0)
@@ -332,10 +282,11 @@ async function main() {
startOfToday.setFullYear(year)
startOfToday.setMonth(expMonth)
const transaction = await tx.chargedLicenseTransactions.create({
const transaction = await tx.licenseChargeTransaction.create({
data: {
activation_expires_at: startOfToday,
tracking_code: `LIC-${'random'}`,
purchased_count: 1,
tracking_code: generateTrackingCode('LIC', 6),
partner: {
connect: {
id: partner.id,
@@ -347,9 +298,9 @@ async function main() {
},
})
if (transaction)
await tx.license.create({
license = await tx.license.create({
data: {
charged_license_transaction: {
charge_transaction: {
connect: {
id: transaction.id,
},
@@ -359,6 +310,88 @@ async function main() {
})
}
// ****************** BA Start ****************** //
const ba = await prisma.businessActivity.count()
if (!ba && license) {
const startOfToday = new Date()
startOfToday.setHours(0, 0, 0, 0)
let year = startOfToday.getFullYear()
let expYear = year + 1
// if (expMonth > 11) {
// expMonth = expMonth - 11
// year = year + 1
// }
startOfToday.setFullYear(expYear)
await prisma.businessActivity.create({
data: {
name: 'طلا فروشی',
economic_code: '0111111111',
license_activation: {
create: {
expires_at: startOfToday,
starts_at: new Date(),
license: {
connect: {
id: license.id,
},
},
},
},
consumer: {
create: {
first_name: 'محمد',
last_name: 'زرگر',
mobile_number: '09120258155',
national_code: '1234567890',
consumer_accounts: {
create: {
role: 'OWNER',
account: {
create: {
username: 'zargar',
password: await PasswordUtil.hash('123456'),
status: 'ACTIVE',
type: 'CONSUMER',
},
},
},
},
partner: {
connect: {
id: partner.id,
},
},
},
},
guild: {
connect: {
id: guilds[0].id,
},
},
complexes: {
create: {
name: 'فروشگاه طلای مرکزی',
address: 'تهران، خیابان جمهوری',
branch_code: '12332',
pos_list: {
create: {
name: 'لاین ۱',
pos_type: POSType.WEB,
serial: '12312312',
status: 'ACTIVE',
},
},
},
},
},
})
}
// ****************** BA Start ****************** //
// ****************** provider Start ****************** //
const provider = await prisma.provider.count()
if (!provider) {