This commit is contained in:
payacom
2026-08-31 20:45:41 +03:30
parent fa9f23c61d
commit 3f416a7a60
367 changed files with 621895 additions and 6443 deletions

View File

@@ -0,0 +1,35 @@
const WalletTransactionModel = require('../models/WalletTransactionModel')
/** Deposit required at booking time, when the provider has enabled it. */
const BOOKING_DEPOSIT_RATE = 0.3
/** Platform commission taken from the deposit amount. */
const BOOKING_COMMISSION_RATE = 0.05
/** Credits the provider's booking wallet bucket (net of platform commission) and pushes a live notification if possible. */
async function creditBookingShare (io, userId, amount, referenceId, description) {
if (!userId || amount <= 0) return
await WalletTransactionModel.create({
user: userId,
bucket: 'booking',
type: 'credit',
amount,
referenceType: 'payment',
referenceId,
description
})
if (io) {
try {
io.to(`user:${String(userId)}`).emit('notification', {
type: 'booking_commission',
title: 'واریز به کیف پول',
description
})
} catch (_) {}
}
}
module.exports = {
BOOKING_DEPOSIT_RATE,
BOOKING_COMMISSION_RATE,
creditBookingShare
}