refactor: filter to registered user
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 7s
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 7s
This commit is contained in:
parent
95fc06ce5f
commit
db4d21bb62
1 changed files with 43 additions and 37 deletions
|
|
@ -68,37 +68,37 @@ export class WebHookController extends Controller {
|
|||
const userIdLine = payload.events[0]?.source?.userId;
|
||||
const dataNow = dayjs().tz("Asia/Bangkok").startOf("day");
|
||||
|
||||
// const dataUser = await prisma.customerBranch.findFirst({
|
||||
// where:{
|
||||
// userId:userIdLine
|
||||
// }
|
||||
// })
|
||||
if (payload?.events[0]?.message) {
|
||||
const message = payload.events[0].message.text;
|
||||
|
||||
const dataEmployee = await prisma.employeePassport.findMany({
|
||||
select: {
|
||||
firstName: true,
|
||||
firstNameEN: true,
|
||||
lastName: true,
|
||||
lastNameEN: true,
|
||||
employeeId: true,
|
||||
expireDate: true,
|
||||
employee: {
|
||||
if (message === "เมนูหลัก > ข้อความ") {
|
||||
const dataEmployee = await prisma.employeePassport.findMany({
|
||||
select: {
|
||||
firstName: true,
|
||||
firstNameEN: true,
|
||||
lastName: true,
|
||||
customerBranch: {
|
||||
lastNameEN: true,
|
||||
employeeId: true,
|
||||
expireDate: true,
|
||||
employee: {
|
||||
select: {
|
||||
firstName: true,
|
||||
firstNameEN: true,
|
||||
lastName: true,
|
||||
lastNameEN: true,
|
||||
customerName: true,
|
||||
customer: {
|
||||
customerBranch: {
|
||||
select: {
|
||||
customerType: true,
|
||||
registeredBranch: {
|
||||
firstName: true,
|
||||
firstNameEN: true,
|
||||
lastName: true,
|
||||
lastNameEN: true,
|
||||
customerName: true,
|
||||
customer: {
|
||||
select: {
|
||||
telephoneNo: true,
|
||||
customerType: true,
|
||||
registeredBranch: {
|
||||
select: {
|
||||
telephoneNo: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -106,22 +106,28 @@ export class WebHookController extends Controller {
|
|||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
where: {
|
||||
expireDate: {
|
||||
lt: dataNow.add(30, "day").toDate(),
|
||||
},
|
||||
},
|
||||
orderBy: {
|
||||
expireDate: "asc",
|
||||
},
|
||||
});
|
||||
where: {
|
||||
employee: {
|
||||
customerBranch: {
|
||||
OR: [
|
||||
{ userId: userIdLine },
|
||||
{
|
||||
customer: {
|
||||
branch: { some: { userId: userIdLine } },
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
expireDate: {
|
||||
lt: dataNow.add(30, "day").toDate(),
|
||||
},
|
||||
},
|
||||
orderBy: {
|
||||
expireDate: "asc",
|
||||
},
|
||||
});
|
||||
|
||||
if (payload?.events[0]?.message) {
|
||||
const message = payload.events[0].message.text;
|
||||
|
||||
if (message === "เมนูหลัก > ข้อความ") {
|
||||
const dataUser = userIdLine;
|
||||
const textHead = "JWS ALERT:";
|
||||
let textData = "";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue