Save
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<!---------------------- check for user login ---------------------->
|
<!---------------------- check for user login ---------------------->
|
||||||
<div v-if="!$auth.loggedIn || !$auth.hasScope('user')" class="panel not-logged-in">
|
<div v-if="!$auth.loggedIn || !$auth.hasScope('user') " class="panel not-logged-in">
|
||||||
<h3>
|
<h3>
|
||||||
<span> برای ثبت درخواست نمایندگی باید </span>
|
<span> برای ثبت درخواست نمایندگی باید </span>
|
||||||
<nuxt-link :to="{ name: 'auth-login-register', query: { path: 'representation-enroll' } }"
|
<nuxt-link :to="{ name: 'auth-login-register', query: { path: 'representation-enroll' } }"
|
||||||
@@ -20,6 +20,17 @@
|
|||||||
</nuxt-link>
|
</nuxt-link>
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
|
<!---------------------- check user for confirm ---------------------->
|
||||||
|
<div v-else-if="!userConfirm" class="panel is-agent">
|
||||||
|
<h3>
|
||||||
|
<span> برای ثبت درخواست نمایندگی باید </span>
|
||||||
|
<nuxt-link :to="{ name: 'account' }"
|
||||||
|
> حساب کاربری</nuxt-link
|
||||||
|
>
|
||||||
|
<span> خود را تایید کنید. </span>
|
||||||
|
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!---------------------- check if user already is agent ---------------------->
|
<!---------------------- check if user already is agent ---------------------->
|
||||||
<div v-else-if="$auth.loggedIn && $auth.hasScope('user') && user.isAgent" class="panel is-agent">
|
<div v-else-if="$auth.loggedIn && $auth.hasScope('user') && user.isAgent" class="panel is-agent">
|
||||||
@@ -63,6 +74,9 @@ export default {
|
|||||||
},
|
},
|
||||||
userFullName() {
|
userFullName() {
|
||||||
return this.user.first_name + ' ' + this.user.last_name
|
return this.user.first_name + ' ' + this.user.last_name
|
||||||
|
},
|
||||||
|
userConfirm() {
|
||||||
|
return this.user.confirmed
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {}
|
methods: {}
|
||||||
|
|||||||
@@ -173,148 +173,155 @@ module.exports.add_representation = [
|
|||||||
checkValidations(validationResult),
|
checkValidations(validationResult),
|
||||||
async (req, res) => {
|
async (req, res) => {
|
||||||
const { user_id } = req
|
const { user_id } = req
|
||||||
if (!user_id) throw new Error('invalid user id')
|
const userData = await User.findById(user_id)
|
||||||
const {
|
|
||||||
representation_type,
|
|
||||||
full_name,
|
|
||||||
birth_date,
|
|
||||||
id_number,
|
|
||||||
place_of_issue,
|
|
||||||
national_code,
|
|
||||||
fathers_name,
|
|
||||||
education_level,
|
|
||||||
military_status,
|
|
||||||
certificates,
|
|
||||||
store_name,
|
|
||||||
province_name,
|
|
||||||
province_id,
|
|
||||||
city_name,
|
|
||||||
city_id,
|
|
||||||
postal_code,
|
|
||||||
mobile_number,
|
|
||||||
tel_number,
|
|
||||||
fax_number,
|
|
||||||
economic_code,
|
|
||||||
email,
|
|
||||||
address,
|
|
||||||
business_license,
|
|
||||||
ownership_type,
|
|
||||||
total_area,
|
|
||||||
repair_area,
|
|
||||||
stock_area,
|
|
||||||
customer_reference_floor,
|
|
||||||
place_location,
|
|
||||||
geo_location,
|
|
||||||
banner_info,
|
|
||||||
repair_technicians,
|
|
||||||
repair_masters,
|
|
||||||
office_workers,
|
|
||||||
bike_deliveries,
|
|
||||||
computer_repair_exp,
|
|
||||||
multimedia_repair_exp,
|
|
||||||
business_exp,
|
|
||||||
know_asanServ_from,
|
|
||||||
introducer_info,
|
|
||||||
asanServ_products_knowledge,
|
|
||||||
computer_saling_exp,
|
|
||||||
computer_saling_description,
|
|
||||||
other_representations,
|
|
||||||
more_descriptions
|
|
||||||
} = req.body
|
|
||||||
const data = {
|
|
||||||
user_id,
|
|
||||||
representation_type,
|
|
||||||
full_name,
|
|
||||||
birth_date,
|
|
||||||
id_number,
|
|
||||||
place_of_issue,
|
|
||||||
national_code,
|
|
||||||
fathers_name,
|
|
||||||
education_level,
|
|
||||||
military_status,
|
|
||||||
certificates,
|
|
||||||
store_name,
|
|
||||||
province_name,
|
|
||||||
province_id,
|
|
||||||
city_name,
|
|
||||||
city_id,
|
|
||||||
postal_code,
|
|
||||||
mobile_number,
|
|
||||||
tel_number,
|
|
||||||
fax_number,
|
|
||||||
economic_code,
|
|
||||||
email,
|
|
||||||
address,
|
|
||||||
business_license,
|
|
||||||
ownership_type,
|
|
||||||
total_area,
|
|
||||||
repair_area,
|
|
||||||
stock_area,
|
|
||||||
customer_reference_floor,
|
|
||||||
place_location,
|
|
||||||
geo_location,
|
|
||||||
banner_info,
|
|
||||||
repair_technicians,
|
|
||||||
repair_masters,
|
|
||||||
office_workers,
|
|
||||||
bike_deliveries,
|
|
||||||
computer_repair_exp,
|
|
||||||
multimedia_repair_exp,
|
|
||||||
business_exp,
|
|
||||||
know_asanServ_from,
|
|
||||||
introducer_info,
|
|
||||||
asanServ_products_knowledge,
|
|
||||||
computer_saling_exp,
|
|
||||||
computer_saling_description,
|
|
||||||
other_representations,
|
|
||||||
more_descriptions
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
if (!userData || !userData.confirmed){
|
||||||
const checkUserRepresentations = await Representation.find({ user_id, archived: false })
|
res.status(400).json({msg:'اول شماره تلفن و ایمیل خود را تایید کنید'})
|
||||||
if (checkUserRepresentations.length)
|
|
||||||
return res406(res, 'تا زمانی که درخواست قبلی توسط کارشناسان تعیین وضعیت نشود نمیتوانید درخواست جدیدی ثبت کنید.')
|
|
||||||
const allRepresentations = await Representation.find()
|
|
||||||
const representation_code =
|
|
||||||
'ASAREP' +
|
|
||||||
moment(Date.now()).format('jMMM').toUpperCase() +
|
|
||||||
allRepresentations.length.toString().padStart(4, '0')
|
|
||||||
|
|
||||||
data.representation_code = representation_code
|
}else{
|
||||||
|
const {
|
||||||
const representation = new Representation(data)
|
representation_type,
|
||||||
const user = await User.findById(user_id)
|
full_name,
|
||||||
if(!user){
|
birth_date,
|
||||||
res404(res,"آین کاربر در دیتای ما وجود ندارد")
|
id_number,
|
||||||
}else{
|
place_of_issue,
|
||||||
await representation.save()
|
national_code,
|
||||||
|
fathers_name,
|
||||||
|
education_level,
|
||||||
|
military_status,
|
||||||
|
certificates,
|
||||||
|
store_name,
|
||||||
|
province_name,
|
||||||
|
province_id,
|
||||||
|
city_name,
|
||||||
|
city_id,
|
||||||
|
postal_code,
|
||||||
|
mobile_number,
|
||||||
|
tel_number,
|
||||||
|
fax_number,
|
||||||
|
economic_code,
|
||||||
|
email,
|
||||||
|
address,
|
||||||
|
business_license,
|
||||||
|
ownership_type,
|
||||||
|
total_area,
|
||||||
|
repair_area,
|
||||||
|
stock_area,
|
||||||
|
customer_reference_floor,
|
||||||
|
place_location,
|
||||||
|
geo_location,
|
||||||
|
banner_info,
|
||||||
|
repair_technicians,
|
||||||
|
repair_masters,
|
||||||
|
office_workers,
|
||||||
|
bike_deliveries,
|
||||||
|
computer_repair_exp,
|
||||||
|
multimedia_repair_exp,
|
||||||
|
business_exp,
|
||||||
|
know_asanServ_from,
|
||||||
|
introducer_info,
|
||||||
|
asanServ_products_knowledge,
|
||||||
|
computer_saling_exp,
|
||||||
|
computer_saling_description,
|
||||||
|
other_representations,
|
||||||
|
more_descriptions
|
||||||
|
} = req.body
|
||||||
|
const data = {
|
||||||
|
user_id,
|
||||||
|
representation_type,
|
||||||
|
full_name,
|
||||||
|
birth_date,
|
||||||
|
id_number,
|
||||||
|
place_of_issue,
|
||||||
|
national_code,
|
||||||
|
fathers_name,
|
||||||
|
education_level,
|
||||||
|
military_status,
|
||||||
|
certificates,
|
||||||
|
store_name,
|
||||||
|
province_name,
|
||||||
|
province_id,
|
||||||
|
city_name,
|
||||||
|
city_id,
|
||||||
|
postal_code,
|
||||||
|
mobile_number,
|
||||||
|
tel_number,
|
||||||
|
fax_number,
|
||||||
|
economic_code,
|
||||||
|
email,
|
||||||
|
address,
|
||||||
|
business_license,
|
||||||
|
ownership_type,
|
||||||
|
total_area,
|
||||||
|
repair_area,
|
||||||
|
stock_area,
|
||||||
|
customer_reference_floor,
|
||||||
|
place_location,
|
||||||
|
geo_location,
|
||||||
|
banner_info,
|
||||||
|
repair_technicians,
|
||||||
|
repair_masters,
|
||||||
|
office_workers,
|
||||||
|
bike_deliveries,
|
||||||
|
computer_repair_exp,
|
||||||
|
multimedia_repair_exp,
|
||||||
|
business_exp,
|
||||||
|
know_asanServ_from,
|
||||||
|
introducer_info,
|
||||||
|
asanServ_products_knowledge,
|
||||||
|
computer_saling_exp,
|
||||||
|
computer_saling_description,
|
||||||
|
other_representations,
|
||||||
|
more_descriptions
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const checkUserRepresentations = await Representation.find({ user_id, archived: false })
|
||||||
|
if (checkUserRepresentations.length)
|
||||||
|
return res406(res, 'تا زمانی که درخواست قبلی توسط کارشناسان تعیین وضعیت نشود نمیتوانید درخواست جدیدی ثبت کنید.')
|
||||||
|
const allRepresentations = await Representation.find()
|
||||||
|
const representation_code =
|
||||||
|
'ASAREP' +
|
||||||
|
moment(Date.now()).format('jMMM').toUpperCase() +
|
||||||
|
allRepresentations.length.toString().padStart(4, '0')
|
||||||
|
|
||||||
|
data.representation_code = representation_code
|
||||||
|
|
||||||
|
const representation = new Representation(data)
|
||||||
|
const user = await User.findById(user_id)
|
||||||
|
if(!user){
|
||||||
|
res404(res,"آین کاربر در دیتای ما وجود ندارد")
|
||||||
|
}else{
|
||||||
|
await representation.save()
|
||||||
|
}
|
||||||
|
user.askedForRepresentation = true
|
||||||
|
user.representation_code = representation_code
|
||||||
|
await user.save()
|
||||||
|
|
||||||
|
const smsMessage = [
|
||||||
|
' متقاضی گرامی درخواست شما با کد پیگیری ',
|
||||||
|
representation_code,
|
||||||
|
' در تاریخ ',
|
||||||
|
SmsDateFormat(Date.now()),
|
||||||
|
' در سامانه ثبت شد. ',
|
||||||
|
'\n',
|
||||||
|
' بعد از بررسی مدارک توسط کارشناسان نتیجه از طریق پیامک برای شما ارسال خواهد شد، همچنین میتوانید با کد پیگیری از طریق نشانی زیر وضعیت درخواست خود را بررسی کند. ',
|
||||||
|
'\n',
|
||||||
|
'https://asan-service.com/representation',
|
||||||
|
'\n',
|
||||||
|
phrases.signature
|
||||||
|
]
|
||||||
|
|
||||||
|
const responseMsg = ['درخواست شما باموفقیت ثبت شد.', '\n', ' کد پیگیری: ', representation_code]
|
||||||
|
|
||||||
|
SMS([mobile_number], smsMessage.join(''))
|
||||||
|
notifyAdmin('updateNewRepresentations')
|
||||||
|
return res.json({ message: responseMsg.join('') })
|
||||||
|
} catch (e) {
|
||||||
|
return res500(res, e)
|
||||||
}
|
}
|
||||||
user.askedForRepresentation = true
|
|
||||||
user.representation_code = representation_code
|
|
||||||
await user.save()
|
|
||||||
|
|
||||||
const smsMessage = [
|
|
||||||
' متقاضی گرامی درخواست شما با کد پیگیری ',
|
|
||||||
representation_code,
|
|
||||||
' در تاریخ ',
|
|
||||||
SmsDateFormat(Date.now()),
|
|
||||||
' در سامانه ثبت شد. ',
|
|
||||||
'\n',
|
|
||||||
' بعد از بررسی مدارک توسط کارشناسان نتیجه از طریق پیامک برای شما ارسال خواهد شد، همچنین میتوانید با کد پیگیری از طریق نشانی زیر وضعیت درخواست خود را بررسی کند. ',
|
|
||||||
'\n',
|
|
||||||
'https://asan-service.com/representation',
|
|
||||||
'\n',
|
|
||||||
phrases.signature
|
|
||||||
]
|
|
||||||
|
|
||||||
const responseMsg = ['درخواست شما باموفقیت ثبت شد.', '\n', ' کد پیگیری: ', representation_code]
|
|
||||||
|
|
||||||
SMS([mobile_number], smsMessage.join(''))
|
|
||||||
notifyAdmin('updateNewRepresentations')
|
|
||||||
return res.json({ message: responseMsg.join('') })
|
|
||||||
} catch (e) {
|
|
||||||
return res500(res, e)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@ const inHostUrl = 'mongodb://root:KPTt76tImNBBMm4Kor8QA9gB@asan-service:27017/as
|
|||||||
const outHostUrl = 'mongodb://root:KPTt76tImNBBMm4Kor8QA9gB@hotaka.liara.cloud:33794/asanserv_database?authSource=admin'
|
const outHostUrl = 'mongodb://root:KPTt76tImNBBMm4Kor8QA9gB@hotaka.liara.cloud:33794/asanserv_database?authSource=admin'
|
||||||
const init = ()=>{
|
const init = ()=>{
|
||||||
try {
|
try {
|
||||||
mongoose.connect(inHostUrl, {
|
mongoose.connect(outHostUrl, {
|
||||||
useNewUrlParser: true,
|
useNewUrlParser: true,
|
||||||
useUnifiedTopology: true,
|
useUnifiedTopology: true,
|
||||||
useFindAndModify: false,
|
useFindAndModify: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user