|
|
@ -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,
|
|
|
|