feat: add customer request cancel detail
This commit is contained in:
parent
1f2a063974
commit
57641681ea
1 changed files with 66 additions and 0 deletions
|
|
@ -1,9 +1,11 @@
|
|||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
Head,
|
||||
Path,
|
||||
Post,
|
||||
Put,
|
||||
Query,
|
||||
Request,
|
||||
|
|
@ -776,6 +778,70 @@ export class LineController extends Controller {
|
|||
|
||||
return record;
|
||||
}
|
||||
|
||||
@Post("request/{requestDataId}/request-cancel")
|
||||
@Security("line")
|
||||
async customerRequestCancel(
|
||||
@Path() requestDataId: string,
|
||||
@Request() req: RequestWithLineUser,
|
||||
@Body() body: { reason: string },
|
||||
) {
|
||||
const result = await prisma.requestData.updateMany({
|
||||
where: {
|
||||
id: requestDataId,
|
||||
quotation: {
|
||||
customerBranch: {
|
||||
OR: [
|
||||
{ userId: req.user.sub },
|
||||
{
|
||||
customer: {
|
||||
branch: { some: { userId: req.user.sub } },
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
data: {
|
||||
customerRequestCancel: true,
|
||||
customerRequestCancelReason: body.reason,
|
||||
},
|
||||
});
|
||||
if (result.count <= 0) throw notFoundError("Request Data");
|
||||
}
|
||||
|
||||
@Post("request-work/{requestWorkId}/request-cancel")
|
||||
@Security("line")
|
||||
async customerRequestCancelWork(
|
||||
@Path() requestWorkId: string,
|
||||
@Request() req: RequestWithLineUser,
|
||||
@Body() body: { reason: string },
|
||||
) {
|
||||
const result = await prisma.requestWork.updateMany({
|
||||
where: {
|
||||
id: requestWorkId,
|
||||
request: {
|
||||
quotation: {
|
||||
customerBranch: {
|
||||
OR: [
|
||||
{ userId: req.user.sub },
|
||||
{
|
||||
customer: {
|
||||
branch: { some: { userId: req.user.sub } },
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
data: {
|
||||
customerRequestCancel: true,
|
||||
customerRequestCancelReason: body.reason,
|
||||
},
|
||||
});
|
||||
if (result.count <= 0) throw notFoundError("Request Data");
|
||||
}
|
||||
}
|
||||
|
||||
@Route("api/v1/line/customer-branch/{branchId}")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue