const WalletTransactionModel = require('../models/WalletTransactionModel') /** Paid to the selected user in full when the creator accepts/pays to select them. */ const PROJECT_ACCEPT_RATE = 0.3 /** Platform commission taken from the remaining amount paid at project completion. */ const PROJECT_COMPLETION_COMMISSION_RATE = 0.1 /** Credits the selected user's project wallet bucket and pushes a live notification if possible. */ async function creditProjectShare (io, userId, amount, referenceId, description) { if (!userId || amount <= 0) return await WalletTransactionModel.create({ user: userId, bucket: 'project', type: 'credit', amount, referenceType: 'payment', referenceId, description }) if (io) { try { io.to(`user:${String(userId)}`).emit('notification', { type: 'project_commission', title: 'واریز به کیف پول', description }) } catch (_) {} } } module.exports = { PROJECT_ACCEPT_RATE, PROJECT_COMPLETION_COMMISSION_RATE, creditProjectShare }