master^2
Bhaskar 3 months ago
parent b5ca5672d5
commit f6aaa50e53

@ -9996,7 +9996,7 @@ if (!orders.length) {
exports.sendToStoreHardwareList = async (req, reply) => { exports.sendToStoreHardwareList = async (req, reply) => {
try { try {
const { supportId, customerId } = req.params; const { supportId, customerId } = req.params;
const { storeId } = req.body; const { storeId, type } = req.body;
if (!supportId || !customerId) { if (!supportId || !customerId) {
return reply.code(400).send({ error: "supportId and customerId are required in path params" }); return reply.code(400).send({ error: "supportId and customerId are required in path params" });
@ -10156,16 +10156,20 @@ exports.sendToStoreHardwareList = async (req, reply) => {
} }
// ✅ Step: Update storeId in Orders where matching master_connections.hardwareId // ✅ Step: Update storeId in Orders where matching master_connections.hardwareId
const updatedHardwareIds = disconnectedIssues.map(item => item.hardwareId); // ✅ Step: Update storeId and type in Orders where matching master_connections.hardwareId
await Order.updateMany( const updatedHardwareIds = disconnectedIssues.map(item => item.hardwareId);
{ await Order.updateMany(
customerId, {
"master_connections.hardwareId": { $in: updatedHardwareIds } customerId,
}, "master_connections.hardwareId": { $in: updatedHardwareIds }
{ },
$set: { storeId } {
} $set: {
); storeId,
type: type // Fallback if type is not passed
}
}
);
return reply.send({ return reply.send({
status_code: 200, status_code: 200,

@ -830,6 +830,7 @@ const orderSchema = new mongoose.Schema({
switch_type_quantity_price: { type: String, default: null }, switch_type_quantity_price: { type: String, default: null },
switch_type_total_price: { type: String, default: null }, switch_type_total_price: { type: String, default: null },
qutation_total_price: { type: String, default: null }, qutation_total_price: { type: String, default: null },
type: { type: String, default: null },
status: { type: String, default: "pending" }, status: { type: String, default: "pending" },
quatation_status: { type: String, default: "pending" }, quatation_status: { type: String, default: "pending" },

@ -910,6 +910,8 @@ module.exports = function (fastify, opts, next) {
required: ["storeId"], required: ["storeId"],
properties: { properties: {
storeId: { type: "string" }, storeId: { type: "string" },
type: { type: "string" },
}, },
}, },
}, },

Loading…
Cancel
Save