Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#156 택시 탑승이 혼자인 경우, 자동으로 결제 완료 및 과거 참여 방으로 이동 #194

Open
wants to merge 22 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
a6e3101
Add: change searchByUserHandler
Hyogyeong8 Nov 25, 2022
2762aba
Fix: searchByUserHandler
Hyogyeong8 Nov 25, 2022
fa7f01f
Fix: searchByUserHandler app crash
Hyogyeong8 Nov 26, 2022
98537e4
Fix: searchByUserHandler
Hyogyeong8 Nov 26, 2022
88d5899
Fix(rooms.js): searchByUserHandler remove lean
Hyogyeong8 Nov 29, 2022
97a4ad5
Fix: searchByUserHandler moving operation
Hyogyeong8 Nov 29, 2022
36136a6
Merge branch 'main' into #156-move-rooms-to-the-past-room-list-and-ch…
Hyogyeong8 Nov 29, 2022
a231e2d
Docs: searchByUserHandler
Hyogyeong8 Nov 30, 2022
739cdcc
Merge branch 'dev' into #156-move-rooms-to-the-past-room-list-and-cha…
14KGun Jan 7, 2023
dd928dc
Merge branch '#156-move-rooms-to-the-past-room-list-and-change-settle…
Hyogyeong8 Feb 28, 2023
18d2822
Merge branch 'dev' into #156-move-rooms-to-the-past-room-list-and-cha…
14KGun Sep 8, 2023
11cfed9
Remove: setTimestamp
14KGun Sep 8, 2023
fea3b9a
Merge pull request #483 from sparcs-kaist/dev
kmc7468 Mar 3, 2024
6c2ef72
Merge pull request #491 from sparcs-kaist/dev
kmc7468 Mar 10, 2024
66595a9
Merge pull request #494 from sparcs-kaist/dev
kmc7468 Mar 11, 2024
551e3bc
Merge pull request #496 from sparcs-kaist/dev
kmc7468 Mar 11, 2024
63acbe7
Merge pull request #501 from sparcs-kaist/dev
kmc7468 Mar 19, 2024
356e56e
Merge pull request #507 from sparcs-kaist/dev
kmc7468 Mar 26, 2024
620b67d
Merge remote-tracking branch 'origin/main' into #156-move-rooms-to-th…
cokia Apr 2, 2024
abda400
fix: autoProcessingRoom cron logic
cokia Apr 23, 2024
e0c6415
Merge branch 'dev' into #156-move-rooms-to-the-past-room-list-and-cha…
cokia May 21, 2024
534bdd3
Merge branch 'dev' into #156-move-rooms-to-the-past-room-list-and-cha…
cokia Sep 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/route/rooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ router.get(
);

// 로그인된 사용자의 모든 방들을 반환한다.
router.get("/searchByUser", roomHandlers.searchByUserHandler);
router.get("/searchByUser", setTimestamp, roomHandlers.searchByUserHandler);

router.post(
"/commitPayment",
Expand Down
40 changes: 40 additions & 0 deletions src/service/rooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,46 @@ const searchByUserHandler = async (req, res) => {
})
.lean();
14KGun marked this conversation as resolved.
Show resolved Hide resolved

// ongoingRoom 중 이미 출발했고, 혼자 참여중인 방은
// 정산 상태를 완료로 바꾸고 doneRoom으로 옮긴다.
const moving = user.ongoingRoom.filter(
(room) => room.part.length == 1 && room.time <= req.timestamp
);

moving.forEach(async function (room) {
let changingRoomObject = await roomModel
.findOneAndUpdate(
{ _id: room._id },
{
settlementTotal: 1,
isDeparted: true,
$set: { "part[0].settlementStatus": "paid" },
},
{ raw: true }
)
.lean()
.populate(roomPopulateOption);

if (!changingRoomObject) {
return res.status(404).json({
error: "Rooms/searchByUser/:id : cannot find settlement info",
});
}

user.doneRoom.push(room._id);

const movingRoomIndex = user.ongoingRoom.indexOf(room._id);
if (movingRoomIndex === -1) {
await user.save();
return res.status(500).json({
error: "Rooms/searchByUser/:id : internal server error",
});
}
user.ongoingRoom.splice(movingRoomIndex, 1);

await user.save();
14KGun marked this conversation as resolved.
Show resolved Hide resolved
});

// 정산완료여부 기준으로 진행중인 방과 완료된 방을 분리해서 응답을 전송합니다.
const response = {};
response.ongoing = user.ongoingRoom.map((room) =>
Expand Down