From dbb98d455ca62effdecb4bd00a6100f10ba57db5 Mon Sep 17 00:00:00 2001 From: Mr Swift Date: Thu, 26 Sep 2024 12:48:09 +0330 Subject: [PATCH 1/3] Save --- pages/admin/gps/withdraw/{Index.vue => g.vue} | 0 pages/enroll-representation/index.vue | 16 +- .../controllers/representationController.js | 283 +++++++++--------- server/database.js | 2 +- 4 files changed, 161 insertions(+), 140 deletions(-) rename pages/admin/gps/withdraw/{Index.vue => g.vue} (100%) diff --git a/pages/admin/gps/withdraw/Index.vue b/pages/admin/gps/withdraw/g.vue similarity index 100% rename from pages/admin/gps/withdraw/Index.vue rename to pages/admin/gps/withdraw/g.vue diff --git a/pages/enroll-representation/index.vue b/pages/enroll-representation/index.vue index 11241d1..1c278ac 100644 --- a/pages/enroll-representation/index.vue +++ b/pages/enroll-representation/index.vue @@ -7,7 +7,7 @@
-
+

برای ثبت درخواست نمایندگی باید

+ +
+

+ برای ثبت درخواست نمایندگی باید + حساب کاربری + خود را تایید کنید. + +

+
@@ -63,6 +74,9 @@ export default { }, userFullName() { return this.user.first_name + ' ' + this.user.last_name + }, + userConfirm() { + return this.user.confirmed } }, methods: {} diff --git a/server/controllers/representationController.js b/server/controllers/representationController.js index c57247d..fb45d96 100644 --- a/server/controllers/representationController.js +++ b/server/controllers/representationController.js @@ -173,148 +173,155 @@ module.exports.add_representation = [ checkValidations(validationResult), async (req, res) => { const { user_id } = req - if (!user_id) throw new Error('invalid 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 - } + const userData = await User.findById(user_id) - 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') + if (!userData || !userData.confirmed){ + res.status(400).json({msg:'اول شماره تلفن و ایمیل خود را تایید کنید'}) - 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() + }else{ + 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 { + 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) } + } ] diff --git a/server/database.js b/server/database.js index 0f6c099..d59a6d9 100644 --- a/server/database.js +++ b/server/database.js @@ -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 init = ()=>{ try { - mongoose.connect(inHostUrl, { + mongoose.connect(outHostUrl, { useNewUrlParser: true, useUnifiedTopology: true, useFindAndModify: false, From 78a136dcdcc976ddbcff76e1b37e14fc0122d256 Mon Sep 17 00:00:00 2001 From: Mr Swift Date: Thu, 26 Sep 2024 12:48:24 +0330 Subject: [PATCH 2/3] edit --- pages/admin/gps/withdraw/{g.vue => index.vue} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename pages/admin/gps/withdraw/{g.vue => index.vue} (100%) diff --git a/pages/admin/gps/withdraw/g.vue b/pages/admin/gps/withdraw/index.vue similarity index 100% rename from pages/admin/gps/withdraw/g.vue rename to pages/admin/gps/withdraw/index.vue From 8daeb51dc76bf0119317fdc0e66ab6450ecf876d Mon Sep 17 00:00:00 2001 From: Mr Swift Date: Thu, 26 Sep 2024 14:05:03 +0330 Subject: [PATCH 3/3] Update main.yml --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b849e71..7f2133f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest env: - DISCORD_WEBHOOK_URL: 'https://canary.discord.com/api/webhooks/1266738294226554953/xLG8rouRFIAJJGSgroDyjorzkh1vxn6b2QqlLM44Y1rONt8F0rGkAB5v5VKY1h_znQW6' + DISCORD_WEBHOOK_URL: 'https://discord.com/api/webhooks/1269741326543487006/NVr2BlA8FTrIfIybH6FqWkb4SAFqy5R7HRFs75HfI7gEegvkuuPZhHToimOC5mOtOeLG' LIARA_TOKEN: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySUQiOiI2NGVkY2ZmYWJiODUyOWZmNWFmOTU3YmEiLCJpYXQiOjE3MjQwMjIzNDh9._yOIB8GSaXuVmqsoACg68fgk0RrWR-Dp15_o02sobEI APP_NAME: asanservice