feat: accept task notification
This commit is contained in:
parent
f583448e5f
commit
b518488112
1 changed files with 29 additions and 12 deletions
|
|
@ -997,20 +997,37 @@ export class UserTaskController extends Controller {
|
||||||
|
|
||||||
await prisma.$transaction(async (tx) => {
|
await prisma.$transaction(async (tx) => {
|
||||||
const promises = body.taskOrderId.flatMap((taskOrderId) => [
|
const promises = body.taskOrderId.flatMap((taskOrderId) => [
|
||||||
tx.taskOrder.update({
|
tx.taskOrder
|
||||||
where: { id: taskOrderId },
|
.update({
|
||||||
data: {
|
where: { id: taskOrderId },
|
||||||
taskOrderStatus: TaskOrderStatus.InProgress,
|
data: {
|
||||||
userTask: {
|
taskOrderStatus: TaskOrderStatus.InProgress,
|
||||||
deleteMany: { userId: req.user.sub },
|
userTask: {
|
||||||
create: {
|
deleteMany: { userId: req.user.sub },
|
||||||
userId: req.user.sub,
|
create: {
|
||||||
userTaskStatus: UserTaskStatus.Accept,
|
userId: req.user.sub,
|
||||||
acceptedAt: new Date(),
|
userTaskStatus: UserTaskStatus.Accept,
|
||||||
|
acceptedAt: new Date(),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
})
|
||||||
}),
|
.then(async (v) => {
|
||||||
|
await tx.notification.createMany({
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
title: "สถานะใบส่งงานมีการเปลี่ยนแปลง / Order Status Changed",
|
||||||
|
detail: "รหัสใบสั่งงาน / Order : " + v.code + " InProgress",
|
||||||
|
receiverId: v.createdByUserId,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "มีการรับงาน / Task Accepted",
|
||||||
|
detail: "รหัสใบสั่งงาน / Order : " + v.code,
|
||||||
|
receiverId: v.createdByUserId,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}),
|
||||||
tx.task.updateMany({
|
tx.task.updateMany({
|
||||||
where: {
|
where: {
|
||||||
taskOrderId: taskOrderId,
|
taskOrderId: taskOrderId,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue