This commit is contained in:
payacom
2026-09-24 21:03:27 +03:30
parent 7f0ddfde70
commit 806471241e
43 changed files with 2166 additions and 144 deletions

View File

@@ -0,0 +1,24 @@
const mongoose = require('mongoose')
const timestamp = require('mongoose-timestamp')
// قانونِ قیمت‌گذاریِ ادمین برای یه «سناریو»ی تبلیغ — هر فیلدِ null یعنی وایلدکارت
// (روی هر مقداری از اون بعد صدق می‌کنه)؛ utils/adPricing.js دقیق‌ترین قانونِ منطبق
// (بیشترین فیلدِ غیرِnull) رو انتخاب می‌کنه
const adPricingRuleSchema = new mongoose.Schema({
ad_type: {
type: String,
enum: ['first_post', 'first_story', 'notification', 'project', 'product', 'shop', 'billboard'],
required: true
},
province_id: { type: Number, default: null },
gender: { type: String, enum: ['female', 'male'], default: null },
expertise: { type: String, trim: true, default: null },
sub_expertise: { type: String, trim: true, default: null },
price: { type: Number, required: true }
})
adPricingRuleSchema.index({ ad_type: 1 })
adPricingRuleSchema.plugin(timestamp)
const AdPricingRuleModel = mongoose.model('AdPricingRule', adPricingRuleSchema)
module.exports = AdPricingRuleModel