fix
This commit is contained in:
@@ -63,28 +63,30 @@ module.exports.changeStatus = [
|
|||||||
case "accept": {
|
case "accept": {
|
||||||
const data = await RequestGPS.findByIdAndUpdate(req.params.id,
|
const data = await RequestGPS.findByIdAndUpdate(req.params.id,
|
||||||
{
|
{
|
||||||
status:1
|
status: 1
|
||||||
},
|
},
|
||||||
{ new: true })
|
{ new: true })
|
||||||
const userPreData = await User.findById(data.userId)
|
const userPreData = await User.findById(data.userId).select('walletBalance dollarBalance score')
|
||||||
const userData = await User.findByIdAndUpdate(
|
const userData = await User.findByIdAndUpdate(
|
||||||
data.userId,
|
data.userId,
|
||||||
{
|
{
|
||||||
shopName: data.shopName,
|
shopName: data.shopName,
|
||||||
shopNumber: data.shopNumber,
|
shopNumber: data.shopNumber,
|
||||||
shopAddress: data.shopAddress,
|
shopAddress: data.shopAddress,
|
||||||
birthDate: data.birthDate,
|
birthDate: data.birthDate,
|
||||||
walletBalance:userPreData?.walletBalance | 0
|
walletBalance: userPreData?.walletBalance | 0,
|
||||||
},
|
dollarBalance: userPreData?.dollarBalance | 0,
|
||||||
{ new: true }
|
score: userPreData?.score | 0
|
||||||
)
|
},
|
||||||
res.status(200).json({ msg: 'با موفقیت به روز شد', data:userData })
|
{ new: true }
|
||||||
|
)
|
||||||
|
res.status(200).json({ msg: 'با موفقیت به روز شد', data: userData })
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "reject": {
|
case "reject": {
|
||||||
const data = await RequestGPS.findByIdAndUpdate(req.params.id,
|
const data = await RequestGPS.findByIdAndUpdate(req.params.id,
|
||||||
{
|
{
|
||||||
status:2
|
status: 2
|
||||||
},
|
},
|
||||||
{ new: true })
|
{ new: true })
|
||||||
|
|
||||||
|
|||||||
@@ -68,6 +68,16 @@ const UserSchema = mongoose.Schema({
|
|||||||
min:0,
|
min:0,
|
||||||
default:0
|
default:0
|
||||||
},
|
},
|
||||||
|
dollarBalance:{
|
||||||
|
type:Number,
|
||||||
|
min:0,
|
||||||
|
default:0
|
||||||
|
},
|
||||||
|
score:{
|
||||||
|
type:Number,
|
||||||
|
min:0,
|
||||||
|
default:0
|
||||||
|
},
|
||||||
cardBank:[BankSchema],
|
cardBank:[BankSchema],
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user