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