varun 2 years ago
commit 8a94b95074

@ -356,7 +356,9 @@ exports.deliveryboystartandstop = async (req, reply) => {
const start_water_level = parseInt(booking_data.initial_water_level.replace(/,/g, ''), 10)
const quantity_delivered = final_receiver_waterlevel-start_water_level
const distrubance_price = parseInt(quantity_delivered.replace(/,/g, ''), 10)*price_per_liter
// const distrubance_price = parseInt(quantity_delivered.replace(/,/g, ''), 10)*price_per_liter
const distrubance_price = quantity_delivered * price_per_liter
const amount_difference = price - distrubance_price
await Tankerbooking.findOneAndUpdate({bookingid:bookingId}, { $set: { final_water_level: final_receiver_waterlevel ,stop_time:stop_time,quantityDelivered:quantity_delivered,distrubance_price:distrubance_price,amount_difference:amount_difference,tankerRunningStatus:"0"} });
reply.send({ status_code: 200, "stop time": stop_time,"final water level":final_receiver_waterlevel});

@ -220,8 +220,8 @@ exports.tankerBooking = async (req, reply) => {
supplierId:req.body.supplierId,
tankName:req.body.tankName,
tankLocation:req.body.tankLocation,
// latitude: req.body.latitude,
// longitude: req.body.longitude,
latitude: req.body.latitude,
longitude: req.body.longitude,
//date: req.body.date,
// time: req.body.time,
customerPhone : customerPhone,
@ -254,8 +254,8 @@ exports.tankerBooking = async (req, reply) => {
tankersBookingData.supplierPhone = supplierPhone;
tankersBookingData.customerName = customerName;
tankersBookingData.supplierName = supplierName;
// tankersBookingData.latitude =usertobeInserted.latitude
// tankersBookingData.longitude=usertobeInserted.longitude
tankersBookingData.latitude =usertobeInserted.latitude
tankersBookingData.longitude=usertobeInserted.longitude
}
}

@ -1,5 +1,5 @@
//Get the data models
const { Supplier, DeliveryBoy } = require("../models/supplier");
const { Supplier, DeliveryBoy, profilePictureSupplier } = require("../models/supplier");
const { FriendRequest } = require("../models/supplier");
const { ProfilePicture, User } = require("../models/User");
const supplierController = require("../controllers/supplierController");
@ -173,7 +173,7 @@ exports.loginSupplier = async (request, reply) => {
var s_id = loginObject.supplier.supplierId;
console.log(s_id, "supplierId");
var profilePicture = await ProfilePicture.findOne({ supplierId: s_id });
var profilePicture = await profilePictureSupplier.findOne({ supplierId: s_id });
// request.session.set('supplierId', loginObject.supplier._id)
@ -1189,3 +1189,29 @@ exports.getconnectedCustomers = async (req, reply) => {
throw boom.boomify(err);
}
};
exports.uploadProfilePicture = async (req, reply) => {
try {
const supplierId = req.params.supplierId;
const picture = req.body.picture;
let profilePicture = await profilePictureSupplier.findOne({ supplierId });
console.log(profilePicture,"profile===")
if (!profilePicture) {
profilePicture = new profilePictureSupplier({
supplierId,
picture,
});
} else {
profilePicture.picture = picture;
}
await profilePicture.save();
reply.send({ message: 'Profile picture uploaded successfully' });
} catch (error) {
reply.status(500).send({ error: error.message });
}
};

@ -114,18 +114,37 @@ const userSchema = new mongoose.Schema(
{ versionKey: false }
);
// const profilePictureSchema = new Schema({
// customerId: {
// type: String,unique: true,
// required: true
// },
// picture: {
// type: String,
// required: true
// }
// });
const profilePictureSchema = new Schema({
customerId: {
type: String,unique: true,
type: String,
unique: true,
required: true
},
picture: {
type: {
type: String,
enum: ['jpeg', 'png', 'gif'], // add the file formats you support here
required: true
},
data: {
type: Buffer,
required: true
}
}
});
const ProfilePicture = mongoose.model('ProfilePicture', profilePictureSchema);
const Counter = mongoose.model('Counter', CounterSchema);
const User = mongoose.model("User", userSchema);

@ -131,12 +131,24 @@ const supplierSchema = new mongoose.Schema(
fcmId: { type: String, default: null },
});
const profilePictureSupplierSchema = new Schema({
supplierId: {
type: String,unique: true,
required: true
},
picture: {
type: String,
required: true
}
});
const Supplier = mongoose.model("Supplier", supplierSchema);
//const DeliveryAgent = mongoose.model("DeliveryAgent", deliveryAgent);
const FriendRequest = mongoose.model('FriendRequest', friendRequestSchema);
const DeliveryBoy = mongoose.model('DeliveryBoy', deliveryBoySchema);
const profilePictureSupplier = mongoose.model('ProfilePictureSupplier', profilePictureSupplierSchema);
module.exports = { Supplier, generateSupplierId, FriendRequest,DeliveryBoy}
module.exports = { Supplier, generateSupplierId, FriendRequest,DeliveryBoy, profilePictureSupplier}

@ -16,8 +16,8 @@ const tankersSchema = new mongoose.Schema({
tankerName: { type: String, default: null },
phoneNumber: { type: String, default: null },
alternative_phoneNumber: { type: String, default: null },
typeofwater: [{ typeofwater: String}],
price:[{ price: String}],
typeofwater: { type: String, default: null },
price:{ type: String, default: null },
capacity: { type: String},
supplier_address: { type: String, default: null },
supplier_name : { type: String, default: null },

@ -539,6 +539,42 @@ module.exports = function (fastify, opts, next) {
handler: supplierController.editCuurentSupplierInfo,
});
fastify.route({
method: "POST",
url: "/api/supplier/profile-picture/:supplierId",
schema: {
tags: ["Supplier"],
description: "This is for uploading profile picture supplier.",
summary: "This is for uploading profile picture supplier.",
params: {
type: "object",
properties: {
supplierId: {
type: "string",
description: "supplierId",
},
},
},
body: {
type: "object",
required: ["picture"],
properties: {
picture: {
type: 'string'
}
},
},
security: [
{
basicAuth: [],
},
],
},
handler: validationHandler.uploadProfilePicture,
});
next();
}

@ -454,15 +454,35 @@ module.exports = function (fastify, opts, next) {
},
},
},
// body: {
// type: "object",
// required: ["picture"],
// properties: {
// picture: {
// type: 'string'
// }
// },
// },
body: {
type: "object",
required: ["picture"],
properties: {
picture: {
type: 'string'
type: "object",
properties: {
type: {
type: "string",
enum: ['jpeg', 'png', 'gif']
},
data: {
type: "string",
format: "binary"
}
}
}
},
},
security: [
{
basicAuth: [],

Loading…
Cancel
Save