This commit is contained in:
morteza-mortezai
2025-12-02 09:42:09 +03:30
parent 0d902aff1a
commit 5b9d14ee44
+10 -6
View File
@@ -216,11 +216,12 @@ module.exports.updateInstalled = [
],
checkValidations(validationResult),
async (req, res) => {
console.log('updateInstalled ******************', req.params.id, req.params.type)
const installedDevice = await InstalledDevice.findById(req.params.id)
if (!installedDevice) {
return res.status(404).json({ msg: 'این ایدی وجود ندارد' })
} else {
try {
console.log('updateInstalled ******************', req.params.id, req.params.type)
const installedDevice = await InstalledDevice.findById(req.params.id)
if (!installedDevice) {
return res.status(404).json({ msg: 'این ایدی وجود ندارد' })
}
console.log('installedDevice ******************')
// const user = await User.findById(installedDevice.userId).select('walletBalance score totalScore')
switch (req.params.type) {
@@ -271,7 +272,7 @@ module.exports.updateInstalled = [
console.log('userGPS updated ******************')
}
await Score.delete({ deviceId: installedDevice.id })
await Score.deleteMany({ deviceId: installedDevice.id })
console.log('Score deleted ******************')
notifyAdmin('newInstallDeviceRequest', installedDevice.userId)
@@ -284,6 +285,9 @@ module.exports.updateInstalled = [
break
}
}
} catch (error) {
console.error('Error in updateInstalled:', error?.message)
return res.status(500).json({ msg: 'خطا در به‌روزرسانی وضعیت دستگاه' })
}
}
]