transfer project in github

This commit is contained in:
hamid.zarghami1@gmail.com
2024-05-12 15:29:27 +03:30
commit e644edbd65
348 changed files with 164991 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
const mongoose = require('mongoose')
const Cart_ItemSchema = mongoose.Schema({
user_id: {type: mongoose.ObjectId, ref: 'User'},
product_id: {type: mongoose.ObjectId, ref: 'Food'},
branchId: {type: mongoose.ObjectId, ref: 'StoreInfo'},
quantity: Number,
// createdAt : {type : Date , expires : 3600 , default : Date.now()}
})
module.exports = mongoose.model('CartItem', Cart_ItemSchema)
+13
View File
@@ -0,0 +1,13 @@
const mongoose = require('mongoose')
const mongoosePaginate = require('mongoose-paginate-v2');
const contactUsSchema = mongoose.Schema({
name: String,
phone: String,
email: String,
message: String,
read: Boolean
})
contactUsSchema.plugin(mongoosePaginate);
module.exports = mongoose.model('ContactUs', contactUsSchema)
+17
View File
@@ -0,0 +1,17 @@
const mongoose = require('mongoose')
const mongoosePaginate = require('mongoose-paginate-v2');
const DiscountSchema = mongoose.Schema({
discount_code: String,
discount_amount: Number,
discount_expire_date: String,
discount_user_id: {type: mongoose.ObjectId, ref: 'User'},
menuTypeId: {type: mongoose.ObjectId, ref: 'MenuType'},
isPublic: {type: Boolean, default: false},
used_by: [{type: mongoose.ObjectId, ref: 'User'}],
branchId: {type: mongoose.ObjectId, ref: 'StoreInfo'}
})
DiscountSchema.plugin(mongoosePaginate);
module.exports = mongoose.model('DiscountCode', DiscountSchema)
+49
View File
@@ -0,0 +1,49 @@
const mongoose = require('mongoose')
const mongoosePaginate = require('mongoose-paginate-v2');
function image(img) {
if (img) return '/uploads/images/food/' + img
}
const RateSchema = mongoose.Schema({
user_id: {type: mongoose.ObjectId, ref: 'User'},
rate: {
type: Number,
enum: [0, 1, 2, 3, 4, 5],
default: 0
},
comment: String,
order_id : String,
replay: String,
replied_by: {type: mongoose.ObjectId, ref: 'User'},
confirmed: {type: Boolean, default: false},
confirmed_by: {type: mongoose.ObjectId, ref: 'User'},
})
const FoodSchema = mongoose.Schema({
branchId: {type: mongoose.ObjectId, ref: 'StoreInfo'},
club : {type : Boolean , default : false},
clubQuantity : {type : Number , default : 1},
point: {type : Number , default : 0},
sale : {type : Boolean , default : true},
name: String,
image: {type: String, get: image},
price: {type: Number, default: 0},
special : {type : Boolean , default : false},
description: String,
short_description: String,
estimated_time: Number,
stock: {type: Number, default: 0},
category: {type: mongoose.ObjectId, ref: 'FoodCategory'},
static_discount: {type: Number, default: 0},
rate: {type: Number, default: 0},
ratings: [RateSchema],
index: Number,
havePoint : {type: Boolean ,default : true},
canReview : {type :Array , default: []},
// deleted : {type: Boolean , default : false}
})
FoodSchema.plugin(mongoosePaginate);
module.exports = mongoose.model('Food', FoodSchema)
+18
View File
@@ -0,0 +1,18 @@
const mongoose = require('mongoose')
const mongoosePaginate = require('mongoose-paginate-v2');
function cover(img) {
return '/uploads/images/foodCategories/' + img
}
const FoodCategorySchema = mongoose.Schema({
name: String,
branchId: {type: mongoose.ObjectId, ref: 'StoreInfo'},
cover: {type: String, get: cover},
type: {type: mongoose.ObjectId, ref: 'MenuType'},
index: Number
})
FoodCategorySchema.plugin(mongoosePaginate);
module.exports = mongoose.model('FoodCategory', FoodCategorySchema)
+20
View File
@@ -0,0 +1,20 @@
const mongoose = require('mongoose')
const mongoosePaginate = require('mongoose-paginate-v2');
function image(file) {
return `/uploads/images/gallery/${file}`
}
const gallerySchema = mongoose.Schema({
image: {type: String, get: image},
caption: String,
shortCaption: String
})
gallerySchema.virtual('thumb').get(function () {
return '/uploads/images/gallery/thumb/thumb_' + this.image.split('gallery/')[1]
})
gallerySchema.plugin(mongoosePaginate);
module.exports = mongoose.model('Gallery', gallerySchema)
+8
View File
@@ -0,0 +1,8 @@
const mongoose = require('mongoose');
const GetTokenLimitSchema = mongoose.Schema({
phone : String,
createdAt : {type : Date , expires : 120 , default : Date.now()}
});
module.exports = mongoose.model('GetTokenLimit', GetTokenLimitSchema);
+11
View File
@@ -0,0 +1,11 @@
const mongoose = require('mongoose')
const mongoosePaginate = require('mongoose-paginate-v2');
const JobSchema = mongoose.Schema({
name: String,
index: Number
})
JobSchema.plugin(mongoosePaginate);
module.exports = mongoose.model('Job', JobSchema)
+14
View File
@@ -0,0 +1,14 @@
const mongoose = require('mongoose')
const mongoosePaginate = require('mongoose-paginate-v2');
const MenuTypeSchema = mongoose.Schema({
name: String,
showOnWebSite: {type: Boolean, default: true},
branchId: {type: mongoose.ObjectId, ref: 'StoreInfo'},
isCafeMenu: {type: Boolean, default: false},
index: Number
})
MenuTypeSchema.plugin(mongoosePaginate);
module.exports = mongoose.model('MenuType', MenuTypeSchema)
+71
View File
@@ -0,0 +1,71 @@
const mongoose = require('mongoose')
const mongoosePaginate = require('mongoose-paginate-v2');
const StatusSchema = mongoose.Schema({
status: {
type: String,
enum: ['canceled', 'void', 'incomplete', 'processing', 'sent', 'delivered'],
default: 'incomplete'
},
user_id: {type: mongoose.ObjectId, ref: 'User'},
})
const OrderItemsSchema = mongoose.Schema({
product_id: {type: mongoose.ObjectId, ref: 'Food'},
name: String,
quantity: Number,
price: Number,
point : Number,
static_discount: {type: Number, default: 0},
havePoint: Boolean
})
const OrderSchema = mongoose.Schema({
user_id: {type: mongoose.ObjectId, ref: 'User'},
branchId: {type: mongoose.ObjectId, ref: 'StoreInfo'},
rating: {
rate: {
type: Number,
enum: [0, 1, 2, 3, 4, 5],
default: 0
},
reasonForBad: Array
},
description: String,
orderType : {type : String , default : 'online'},
bag: {type: Boolean, default: false},
bagCost: {type: Number, default: 0},
score: {type: Boolean, default: false},
scoreCost: {type: Number, default: 0},
scorePoint: {type: Number, default: 0},
pricePoint: {type: Number, default: 0},
number: Number,
address: {type: Object, default: {}},
statuses: [StatusSchema],
createdOn: Date,
payment: [{type: mongoose.ObjectId, ref: 'Payment' , default:[]}],
paymentStatus: {
type: String,
enum: ['refund', 'unpaid', 'paid'],
default: 'unpaid'
},
status: {
type: String,
enum: ['canceled', 'void', 'incomplete', 'processing', 'sent', 'delivered'],
default: 'incomplete'
},
order_items: [OrderItemsSchema],
discount_code: String,
discount_amount: Number,
discount_menuType: String,
sum: Number,
routePrice: Number,
tax: Number,
percent: Number,
total: Number,
payTotal: Number
})
OrderSchema.plugin(mongoosePaginate);
module.exports = mongoose.model('Order', OrderSchema)
+19
View File
@@ -0,0 +1,19 @@
const mongoose = require('mongoose')
const mongoosePaginate = require('mongoose-paginate-v2');
function image(img) {
if (img) return '/uploads/images/partySet/' + img
}
const PartySetSchema = mongoose.Schema({
title: String,
description: String,
index: Number,
price: {type: Number, default: 0},
active: {type: Boolean, default: true},
image: {type: String, get: image}
})
PartySetSchema.plugin(mongoosePaginate);
module.exports = mongoose.model('PartySet', PartySetSchema)
+29
View File
@@ -0,0 +1,29 @@
const mongoose = require('mongoose')
const mongoosePaginate = require('mongoose-paginate-v2');
const PaymentSchema = mongoose.Schema({
user_id: {type: mongoose.ObjectId, ref: 'User'},
order_id : {type: mongoose.ObjectId, ref: 'Order'},
transactionId : String,
getPayment : {type : Boolean , default: false},
action : {
type : String,
enum: ['increaseBag', 'decreaseBag', 'payOrder'],
default: 'payOrder'
},
status : {
type : String,
enum: ['refund', 'unpaid', 'paid'],
default: 'unpaid'
},
cost : Number,
refId : String,
fee_type: String,
card_hash: String,
card_pan:String,
fee: Number
})
PaymentSchema.plugin(mongoosePaginate);
module.exports = mongoose.model('Payment', PaymentSchema)
+15
View File
@@ -0,0 +1,15 @@
const mongoose = require('mongoose')
const mongoosePaginate = require('mongoose-paginate-v2');
function image(img) {
return '/uploads/images/slider/' + img
}
const SliderSchema = mongoose.Schema({
image: {type: String, get: image},
caption: String
})
SliderSchema.plugin(mongoosePaginate);
module.exports = mongoose.model('Slide', SliderSchema)
+52
View File
@@ -0,0 +1,52 @@
const mongoose = require('mongoose')
function image(img) {
return '/uploads/images/icon/' + img
}
const StoreInfoSchema = mongoose.Schema({
title: {type: String , default: ''},
// image: {type: String, get: image},
caption: String,
message : {type : String , default:''},
socials : {
whatsaap : {type : String ,default : ''},
twitter : {type : String ,default : ''},
facebook : {type : String ,default : ''},
instagram : {type : String ,default : ''},
googlePlus : {type : String ,default : ''},
},
email : String,
shippingCost : Number,
shippingType : {type : Boolean , default: true}, /// true yani sabet va false yani bar asas kilometer
tel : String,
address : String,
location : { type: {type : String , default : 'Point'} , coordinates: [Number]},
tax : {type : Boolean , default : true},
closeStore : {type : Boolean , default : false},
firstStartTime : {type : String , default : '12:00'},
firstEndTime : {type : String , default : '15:00'},
secondStartTime : {type : String , default : '17:00'},
secondEndTime : {type : String , default : '22:00'},
utcStartTime : {type : String , default : '8:30'},
utcEndTime : {type : String , default : '18:30'},
timezone : {type : String , default : 'Asia/Tehran'},
usePointWhenPay : {type : Boolean , default : false},
userRegistrationScore : {type : Number , default : 0},
userEmailVerifyScore : {type : Number , default : 0},
pointBirthDate : {type : Number , default : 0},
pointMarriageDate : {type : Number , default : 0},
invitePoint : {type : Number , default : 0},
pointForBuy : {type : Number , default : 0},
totalPricePoint : {type : Number , default : 0},
priceForChange : {type : Number , default : 0},
pointForChange : {type : Number , default : 0},
limitPrice : {type : Number , default : 0},
useSpecialMenu : {type : Boolean , default : true},
updateApp : {type : String , default : null},
active : {type : Boolean , default : true}
})
StoreInfoSchema.index({'location': '2dsphere'});
module.exports = mongoose.model('StoreInfo', StoreInfoSchema)
+16
View File
@@ -0,0 +1,16 @@
const mongoose = require('mongoose')
const mongoosePaginate = require('mongoose-paginate-v2');
const subscribersSchema = mongoose.Schema({
full_name: String,
birth_date: String,
job: String,
marrage_date: String,
email: String,
mobile: String,
address: String
})
subscribersSchema.plugin(mongoosePaginate);
module.exports = mongoose.model('Subscribers', subscribersSchema)
+78
View File
@@ -0,0 +1,78 @@
const mongoose = require('mongoose')
const mongoosePaginate = require('mongoose-paginate-v2');
function image(img) {
if (img) return '/uploads/images/users/' + img
}
const AddressesSchema = mongoose.Schema({
title : {type : String , default : null},
province: String,
city: String,
address: String,
used : {type : Boolean , default : true},
useRate : {type : Number , default : 0},
location : { type: {type : String , default : 'Point'} , coordinates: [Number]}
})
const ScoreLogSchema = mongoose.Schema({
score: Number,
order_id : {type: mongoose.ObjectId, ref: 'Order'},
branchId: {type: mongoose.ObjectId, ref: 'StoreInfo'},
forWhat : {
type: String,
enum: ['birthDate', 'marriageDate', 'buy', 'register', 'invite', 'emailVerify']
},
action : {
type: String,
enum: ['increase', 'decrease']
},
})
const UserSchema = mongoose.Schema({
// mutual
first_name: String,
last_name: String,
birth_date: Date,
birthDateChange : {type : String, default : ''},
showBirthDate : {type : Boolean , default : false},
marriage_date : Date,
marriageDateChange : {type : String , default : ''},
job: String,
national_code: String,
password: String,
scope: {type: Array, default: ['user']},
branches: [{type: mongoose.ObjectId, ref: 'StoreInfo'}],
token: String,
currentBranch: {type: mongoose.ObjectId, ref: 'StoreInfo'},
// for user
business_code: Number,
mobile_number: String,
invitation : Number,
// discount_codes: Array
// this will be an Array and will be filled while querying database,
bagAmount: {type : Number , default : 0},
score: {type : Number , default : 0},
scoreLogs:[ScoreLogSchema],
email: String,
addresses: [AddressesSchema],
registration_done: {type: Boolean, default: false},
// for admin
profile_pic: {type: String, get: image},
_creator: {type: mongoose.ObjectId, ref: 'User'},
username: String,
permissions: Array,
branchPermission: Array,
private: {type: Boolean, default: false},
deviceId : String,
platform : String,
deviceName : String,
fcmToken : String,
fromWhere :{type : String, default : 'app'},
})
UserSchema.index({'addresses.location': '2dsphere'});
UserSchema.plugin(mongoosePaginate);
module.exports = mongoose.model('User', UserSchema)