Compare commits
5 Commits
mobile-api
...
mobile-api
| Author | SHA1 | Date | |
|---|---|---|---|
| 9a967f0965 | |||
| 5e07dfb749 | |||
| 27259cd86c | |||
| a278470dbb | |||
| b209a12315 |
@@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.5.10](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.9...v1.5.10) (2025-11-03)
|
||||||
|
|
||||||
|
## [1.5.9](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.8...v1.5.9) (2025-10-30)
|
||||||
|
|
||||||
## [1.5.8](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.7...v1.5.8) (2025-10-29)
|
## [1.5.8](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.7...v1.5.8) (2025-10-29)
|
||||||
|
|
||||||
## [1.5.7](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.6...v1.5.7) (2025-10-28)
|
## [1.5.7](https://wibugit.wibudev.com/wibu/hipmi/compare/v1.5.6...v1.5.7) (2025-10-28)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hipmi",
|
"name": "hipmi",
|
||||||
"version": "1.5.8",
|
"version": "1.5.10",
|
||||||
"private": true,
|
"private": true,
|
||||||
"prisma": {
|
"prisma": {
|
||||||
"seed": "bun prisma/seed.ts"
|
"seed": "bun prisma/seed.ts"
|
||||||
|
|||||||
70
src/app/api/mobile/admin/investment/[id]/investor/route.ts
Normal file
70
src/app/api/mobile/admin/investment/[id]/investor/route.ts
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
import _ from "lodash";
|
||||||
|
import { NextResponse } from "next/server";
|
||||||
|
import prisma from "@/lib/prisma";
|
||||||
|
|
||||||
|
export async function GET(
|
||||||
|
request: Request,
|
||||||
|
{ params }: { params: { id: string } }
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
let fixData;
|
||||||
|
const { id } = params;
|
||||||
|
const { searchParams } = new URL(request.url);
|
||||||
|
const page = searchParams.get("page");
|
||||||
|
const status = searchParams.get("status");
|
||||||
|
const takeData = 10;
|
||||||
|
const skipData = Number(page) * takeData - takeData;
|
||||||
|
|
||||||
|
const fixStatus = _.startCase(status ? status : "");
|
||||||
|
|
||||||
|
const checkStatus = await prisma.investasiMaster_StatusInvoice.findFirst({
|
||||||
|
where: {
|
||||||
|
name: fixStatus,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = await prisma.investasi_Invoice.findMany({
|
||||||
|
take: page ? takeData : undefined,
|
||||||
|
skip: page ? skipData : undefined,
|
||||||
|
orderBy: {
|
||||||
|
createdAt: "desc",
|
||||||
|
},
|
||||||
|
where: {
|
||||||
|
investasiId: id,
|
||||||
|
isActive: true,
|
||||||
|
StatusInvoice: {
|
||||||
|
name: {
|
||||||
|
contains: checkStatus?.name,
|
||||||
|
mode: "insensitive",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
Author: true,
|
||||||
|
StatusInvoice: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
fixData = data;
|
||||||
|
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
success: true,
|
||||||
|
message: "Success get status transaksi",
|
||||||
|
data: fixData,
|
||||||
|
},
|
||||||
|
{ status: 200 }
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Eror get status transaksi", error);
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: "Error get status transaksi",
|
||||||
|
reason: (error as Error).message,
|
||||||
|
},
|
||||||
|
{ status: 500 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
178
src/app/api/mobile/admin/investment/[id]/invoice/route.ts
Normal file
178
src/app/api/mobile/admin/investment/[id]/invoice/route.ts
Normal file
@@ -0,0 +1,178 @@
|
|||||||
|
import { NextResponse } from "next/server";
|
||||||
|
import { prisma } from "@/lib";
|
||||||
|
|
||||||
|
export { GET, PUT };
|
||||||
|
|
||||||
|
async function GET(req: Request, { params }: { params: { id: string } }) {
|
||||||
|
const { id } = params;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const data = await prisma.investasi_Invoice.findUnique({
|
||||||
|
where: {
|
||||||
|
id: id,
|
||||||
|
},
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
investasiId: true,
|
||||||
|
nominal: true,
|
||||||
|
createdAt: true,
|
||||||
|
Author: true,
|
||||||
|
StatusInvoice: true,
|
||||||
|
imageId: true,
|
||||||
|
MasterBank: true,
|
||||||
|
lembarTerbeli: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
success: true,
|
||||||
|
message: "Berhasil mendapatkan data",
|
||||||
|
data: data,
|
||||||
|
},
|
||||||
|
{ status: 200 }
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: "Error get detail Investasi",
|
||||||
|
reason: (error as Error).message,
|
||||||
|
},
|
||||||
|
{ status: 500 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function PUT(req: Request, { params }: { params: { id: string } }) {
|
||||||
|
const { id } = params;
|
||||||
|
const { data } = await req.json();
|
||||||
|
const { searchParams } = new URL(req.url);
|
||||||
|
const category = searchParams.get("category");
|
||||||
|
|
||||||
|
console.log("[ID]", id);
|
||||||
|
console.log("[DATA]", data);
|
||||||
|
console.log("[CATEGORY]", category);
|
||||||
|
|
||||||
|
let fixData;
|
||||||
|
try {
|
||||||
|
if (category === "deny") {
|
||||||
|
const updt = await prisma.investasi_Invoice.update({
|
||||||
|
where: {
|
||||||
|
id: id,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
statusInvoiceId: "4",
|
||||||
|
},
|
||||||
|
// select: {
|
||||||
|
// StatusInvoice: true,
|
||||||
|
// authorId: true,
|
||||||
|
// },
|
||||||
|
});
|
||||||
|
|
||||||
|
fixData = updt;
|
||||||
|
} else if (category === "accept") {
|
||||||
|
const dataInvestasi: any = await prisma.investasi.findFirst({
|
||||||
|
where: {
|
||||||
|
id: data.investasiId,
|
||||||
|
},
|
||||||
|
select: {
|
||||||
|
totalLembar: true,
|
||||||
|
sisaLembar: true,
|
||||||
|
lembarTerbeli: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// Hitung TOTAL SISA LEMBAR
|
||||||
|
const investasi_sisaLembar = Number(dataInvestasi?.sisaLembar);
|
||||||
|
const invoice_lembarTerbeli = Number(data.lembarTerbeli);
|
||||||
|
const resultSisaLembar = investasi_sisaLembar - invoice_lembarTerbeli;
|
||||||
|
|
||||||
|
// TAMBAH LEMBAR TERBELI
|
||||||
|
const investasi_lembarTerbeli = Number(dataInvestasi?.lembarTerbeli);
|
||||||
|
const resultLembarTerbeli =
|
||||||
|
investasi_lembarTerbeli + invoice_lembarTerbeli;
|
||||||
|
|
||||||
|
// Progress
|
||||||
|
const investasi_totalLembar = Number(dataInvestasi?.totalLembar);
|
||||||
|
const progress = (resultLembarTerbeli / investasi_totalLembar) * 100;
|
||||||
|
const resultProgres = Number(progress).toFixed(2);
|
||||||
|
|
||||||
|
const updt = await prisma.investasi_Invoice.update({
|
||||||
|
where: {
|
||||||
|
id: id,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
statusInvoiceId: "1",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!updt) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: "Gagal Update Status",
|
||||||
|
reason: "Update status failed",
|
||||||
|
},
|
||||||
|
{ status: 500 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateInvestasi = await prisma.investasi.update({
|
||||||
|
where: {
|
||||||
|
id: data.investasiId,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
sisaLembar: resultSisaLembar.toString(),
|
||||||
|
lembarTerbeli: resultLembarTerbeli.toString(),
|
||||||
|
progress: resultProgres,
|
||||||
|
},
|
||||||
|
include: {
|
||||||
|
MasterStatusInvestasi: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!updateInvestasi) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: "Gagal Update Data Investasi",
|
||||||
|
reason: "Update data investasi failed",
|
||||||
|
},
|
||||||
|
{ status: 500 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
fixData = updt;
|
||||||
|
} else {
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: "Invalid category",
|
||||||
|
reason: "Invalid category",
|
||||||
|
},
|
||||||
|
{ status: 400 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
success: true,
|
||||||
|
message: "Berhasil update data",
|
||||||
|
data: fixData,
|
||||||
|
},
|
||||||
|
{ status: 200 }
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: "Error update detail Investasi",
|
||||||
|
reason: (error as Error).message,
|
||||||
|
},
|
||||||
|
{ status: 500 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
137
src/app/api/mobile/admin/investment/[id]/route.ts
Normal file
137
src/app/api/mobile/admin/investment/[id]/route.ts
Normal file
@@ -0,0 +1,137 @@
|
|||||||
|
import { NextResponse } from "next/server";
|
||||||
|
import { prisma } from "@/lib";
|
||||||
|
|
||||||
|
export { GET, PUT };
|
||||||
|
|
||||||
|
async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||||
|
const { id } = params;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const data = await prisma.investasi.findUnique({
|
||||||
|
where: {
|
||||||
|
id: id,
|
||||||
|
},
|
||||||
|
select: {
|
||||||
|
imageId: true,
|
||||||
|
prospektusFileId: true,
|
||||||
|
id: true,
|
||||||
|
author: {
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
username: true,
|
||||||
|
nomor: true,
|
||||||
|
Profile: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
title: true,
|
||||||
|
authorId: true,
|
||||||
|
hargaLembar: true,
|
||||||
|
targetDana: true,
|
||||||
|
totalLembar: true,
|
||||||
|
sisaLembar: true,
|
||||||
|
lembarTerbeli: true,
|
||||||
|
progress: true,
|
||||||
|
roi: true,
|
||||||
|
active: true,
|
||||||
|
createdAt: true,
|
||||||
|
updatedAt: true,
|
||||||
|
catatan: true,
|
||||||
|
imagesId: true,
|
||||||
|
MasterStatusInvestasi: true,
|
||||||
|
BeritaInvestasi: true,
|
||||||
|
DokumenInvestasi: true,
|
||||||
|
ProspektusInvestasi: true,
|
||||||
|
MasterPembagianDeviden: true,
|
||||||
|
MasterPencarianInvestor: true,
|
||||||
|
MasterPeriodeDeviden: true,
|
||||||
|
MasterProgresInvestasi: true,
|
||||||
|
masterStatusInvestasiId: true,
|
||||||
|
countDown: true,
|
||||||
|
Investasi_Invoice: {
|
||||||
|
where: {
|
||||||
|
statusInvoiceId: "2",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
success: true,
|
||||||
|
message: "Success get data investment",
|
||||||
|
data: data,
|
||||||
|
},
|
||||||
|
{ status: 200 }
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: "Error get data investment",
|
||||||
|
reason: (error as Error).message,
|
||||||
|
},
|
||||||
|
{ status: 500 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||||
|
const { id } = params;
|
||||||
|
const { data } = await request.json();
|
||||||
|
const { searchParams } = new URL(request.url);
|
||||||
|
const status = searchParams.get("status");
|
||||||
|
|
||||||
|
console.log("[=======Start Investment console=======]");
|
||||||
|
console.log("[ID]", id);
|
||||||
|
console.log("[DATA]", data);
|
||||||
|
console.log("[STATUS]", status);
|
||||||
|
console.log("[=======End Investment console=======]");
|
||||||
|
|
||||||
|
const publishTime = new Date();
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (status === "reject") {
|
||||||
|
const updatedData = await prisma.investasi.update({
|
||||||
|
where: {
|
||||||
|
id: id,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
catatan: data,
|
||||||
|
masterStatusInvestasiId: "4",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log("[UPDATE REJECT]", updatedData);
|
||||||
|
} else if (status === "publish") {
|
||||||
|
const updatedData = await prisma.investasi.update({
|
||||||
|
where: {
|
||||||
|
id: id,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
masterStatusInvestasiId: "1",
|
||||||
|
masterProgresInvestasiId: "1",
|
||||||
|
countDown: publishTime,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log("[UPDATE PUBLISH]", updatedData);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
success: true,
|
||||||
|
message: "Success update data investment",
|
||||||
|
},
|
||||||
|
{ status: 200 }
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: "Error update data investment",
|
||||||
|
reason: (error as Error).message,
|
||||||
|
},
|
||||||
|
{ status: 500 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
104
src/app/api/mobile/admin/investment/route.ts
Normal file
104
src/app/api/mobile/admin/investment/route.ts
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
import _ from "lodash";
|
||||||
|
import { NextResponse } from "next/server";
|
||||||
|
import { prisma } from "@/lib";
|
||||||
|
|
||||||
|
export { GET };
|
||||||
|
|
||||||
|
async function GET(request: Request) {
|
||||||
|
const { searchParams } = new URL(request.url);
|
||||||
|
const category = searchParams.get("category");
|
||||||
|
const search = searchParams.get("search");
|
||||||
|
const page = searchParams.get("page");
|
||||||
|
const takeData = 10;
|
||||||
|
const skipData = Number(page) * takeData - takeData;
|
||||||
|
|
||||||
|
console.log("[CATEGORY]", category);
|
||||||
|
console.log("[PAGE]", page);
|
||||||
|
|
||||||
|
let fixData;
|
||||||
|
try {
|
||||||
|
if (category === "dashboard") {
|
||||||
|
const publish = await prisma.investasi.count({
|
||||||
|
where: {
|
||||||
|
MasterStatusInvestasi: {
|
||||||
|
name: "Publish",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const review = await prisma.investasi.count({
|
||||||
|
where: {
|
||||||
|
MasterStatusInvestasi: {
|
||||||
|
name: "Review",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const reject = await prisma.investasi.count({
|
||||||
|
where: {
|
||||||
|
MasterStatusInvestasi: {
|
||||||
|
name: "Reject",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
fixData = {
|
||||||
|
publish,
|
||||||
|
review,
|
||||||
|
reject,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
const fixCategoryToStatus = _.startCase(category || "");
|
||||||
|
console.log("[STATUS]", fixCategoryToStatus);
|
||||||
|
|
||||||
|
const data = await prisma.investasi.findMany({
|
||||||
|
take: page ? takeData : undefined,
|
||||||
|
skip: page ? skipData : undefined,
|
||||||
|
orderBy: {
|
||||||
|
updatedAt: "desc",
|
||||||
|
},
|
||||||
|
where: {
|
||||||
|
active: true,
|
||||||
|
MasterStatusInvestasi: {
|
||||||
|
name: fixCategoryToStatus,
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
contains: search || "",
|
||||||
|
mode: "insensitive",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
title: true,
|
||||||
|
author: {
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
username: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
fixData = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
success: true,
|
||||||
|
message: "Success get data investment",
|
||||||
|
data: fixData,
|
||||||
|
},
|
||||||
|
{ status: 200 }
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("[ERROR GET DATA INVESTMENT]", error);
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: "Error get data investment",
|
||||||
|
reason: (error as Error).message,
|
||||||
|
},
|
||||||
|
{ status: 500 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
48
src/app/api/mobile/investment/[id]/investor/route.ts
Normal file
48
src/app/api/mobile/investment/[id]/investor/route.ts
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
import { NextResponse } from "next/server";
|
||||||
|
import prisma from "@/lib/prisma";
|
||||||
|
|
||||||
|
export { GET };
|
||||||
|
|
||||||
|
async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||||
|
const { id } = params;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const data = await prisma.investasi_Invoice.findMany({
|
||||||
|
where: {
|
||||||
|
investasiId: id,
|
||||||
|
statusInvoiceId: "1",
|
||||||
|
},
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
nominal: true,
|
||||||
|
Author: {
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
username: true,
|
||||||
|
Profile: {
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
name: true,
|
||||||
|
imageId: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return NextResponse.json({
|
||||||
|
status: 200,
|
||||||
|
success: true,
|
||||||
|
message: "Berhasil Mendapatkan Data",
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
return NextResponse.json({
|
||||||
|
status: 500,
|
||||||
|
success: false,
|
||||||
|
message: "Error Mendapatkan Data",
|
||||||
|
reason: (error as Error).message,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -48,6 +48,9 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
const category = searchParams.get("category");
|
const category = searchParams.get("category");
|
||||||
const authorId = searchParams.get("authorId");
|
const authorId = searchParams.get("authorId");
|
||||||
|
|
||||||
|
console.log("[ID INVOICE]", id);
|
||||||
|
|
||||||
|
|
||||||
let fixData;
|
let fixData;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -80,6 +83,8 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log("[DATA INVOICE]", data ? true : false);
|
||||||
|
|
||||||
const { ...allData } = data;
|
const { ...allData } = data;
|
||||||
const Investor = data?.Investasi?.Investasi_Invoice;
|
const Investor = data?.Investasi?.Investasi_Invoice;
|
||||||
fixData = { ...allData, Investor };
|
fixData = { ...allData, Investor };
|
||||||
|
|||||||
@@ -17,7 +17,11 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
|
|||||||
Profile: true,
|
Profile: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Investasi_Invoice: true,
|
Investasi_Invoice: {
|
||||||
|
where: {
|
||||||
|
statusInvoiceId: "1"
|
||||||
|
}
|
||||||
|
},
|
||||||
MasterStatusInvestasi: true,
|
MasterStatusInvestasi: true,
|
||||||
BeritaInvestasi: true,
|
BeritaInvestasi: true,
|
||||||
DokumenInvestasi: true,
|
DokumenInvestasi: true,
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import prisma from "@/lib/prisma";
|
|||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
|
|
||||||
export { POST, GET };
|
export { POST, GET };
|
||||||
|
|
||||||
async function POST(request: Request) {
|
async function POST(request: Request) {
|
||||||
const { data } = await request.json();
|
const { data } = await request.json();
|
||||||
console.log(["DATA INVESTASI"], data);
|
console.log(["DATA INVESTASI"], data);
|
||||||
@@ -46,82 +47,112 @@ async function POST(request: Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function GET(request: Request) {
|
async function GET(request: Request) {
|
||||||
let fixData;
|
|
||||||
const { searchParams } = new URL(request.url);
|
const { searchParams } = new URL(request.url);
|
||||||
|
const category = searchParams.get("category");
|
||||||
|
const authorId = searchParams.get("authorId");
|
||||||
|
|
||||||
|
console.log("[CATEGORY]", category);
|
||||||
|
console.log("[AUTHOR ID]", authorId);
|
||||||
|
let fixData;
|
||||||
try {
|
try {
|
||||||
const data = await prisma.investasi.findMany({
|
if (category === "bursa") {
|
||||||
where: {
|
const data = await prisma.investasi.findMany({
|
||||||
masterStatusInvestasiId: "1",
|
where: {
|
||||||
masterProgresInvestasiId: "1",
|
masterStatusInvestasiId: "1",
|
||||||
},
|
masterProgresInvestasiId: "1",
|
||||||
select: {
|
},
|
||||||
id: true,
|
select: {
|
||||||
MasterPencarianInvestor: true,
|
id: true,
|
||||||
countDown: true,
|
MasterPencarianInvestor: true,
|
||||||
progress: true,
|
countDown: true,
|
||||||
},
|
progress: true,
|
||||||
});
|
},
|
||||||
|
});
|
||||||
|
|
||||||
for (let a of data) {
|
for (let a of data) {
|
||||||
if (
|
if (
|
||||||
(a.MasterPencarianInvestor?.name as any) -
|
(a.MasterPencarianInvestor?.name as any) -
|
||||||
moment(new Date()).diff(new Date(a.countDown as any), "days") <=
|
moment(new Date()).diff(new Date(a.countDown as any), "days") <=
|
||||||
0
|
0
|
||||||
) {
|
) {
|
||||||
await prisma.investasi.update({
|
await prisma.investasi.update({
|
||||||
where: {
|
where: {
|
||||||
id: a.id,
|
id: a.id,
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
masterProgresInvestasiId: "3",
|
masterProgresInvestasiId: "3",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (a.progress === "100") {
|
||||||
|
await prisma.investasi.update({
|
||||||
|
where: {
|
||||||
|
id: a.id,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
masterProgresInvestasiId: "2",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a.progress === "100") {
|
const dataAwal = await prisma.investasi.findMany({
|
||||||
await prisma.investasi.update({
|
orderBy: [
|
||||||
where: {
|
{
|
||||||
id: a.id,
|
masterProgresInvestasiId: "asc",
|
||||||
},
|
},
|
||||||
data: {
|
{
|
||||||
masterProgresInvestasiId: "2",
|
countDown: "desc",
|
||||||
},
|
},
|
||||||
});
|
],
|
||||||
}
|
where: {
|
||||||
}
|
masterStatusInvestasiId: "1",
|
||||||
|
|
||||||
const dataAwal = await prisma.investasi.findMany({
|
|
||||||
orderBy: [
|
|
||||||
{
|
|
||||||
masterProgresInvestasiId: "asc",
|
|
||||||
},
|
},
|
||||||
{
|
select: {
|
||||||
countDown: "desc",
|
id: true,
|
||||||
},
|
imageId: true,
|
||||||
],
|
title: true,
|
||||||
where: {
|
progress: true,
|
||||||
masterStatusInvestasiId: "1",
|
countDown: true,
|
||||||
},
|
MasterPencarianInvestor: {
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
name: true,
|
||||||
imageId: true,
|
},
|
||||||
title: true,
|
|
||||||
progress: true,
|
|
||||||
countDown: true,
|
|
||||||
MasterPencarianInvestor: {
|
|
||||||
select: {
|
|
||||||
name: true,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
});
|
||||||
});
|
|
||||||
|
|
||||||
fixData = dataAwal.map((v: any) => ({
|
fixData = dataAwal.map((v: any) => ({
|
||||||
..._.omit(v, ["MasterPencarianInvestor"]),
|
..._.omit(v, ["MasterPencarianInvestor"]),
|
||||||
pencarianInvestor: v.MasterPencarianInvestor.name,
|
pencarianInvestor: v.MasterPencarianInvestor.name,
|
||||||
}));
|
}));
|
||||||
|
} else if (category === "my-holding") {
|
||||||
|
const data = await prisma.investasi_Invoice.findMany({
|
||||||
|
where: {
|
||||||
|
authorId: authorId,
|
||||||
|
statusInvoiceId: "1",
|
||||||
|
},
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
investasiId: true,
|
||||||
|
nominal: true,
|
||||||
|
lembarTerbeli: true,
|
||||||
|
Investasi: {
|
||||||
|
select: {
|
||||||
|
title: true,
|
||||||
|
progress: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
fixData = data.map((v: any) => ({
|
||||||
|
..._.omit(v, ["Investasi"]),
|
||||||
|
title: v.Investasi.title,
|
||||||
|
progress: v.Investasi.progress,
|
||||||
|
}));
|
||||||
|
}
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
status: 200,
|
status: 200,
|
||||||
success: true,
|
success: true,
|
||||||
|
|||||||
@@ -13,10 +13,10 @@ export async function adminInvestasi_funAcceptTransaksiById({
|
|||||||
invoiceId: string;
|
invoiceId: string;
|
||||||
investasiId: string;
|
investasiId: string;
|
||||||
lembarTerbeli: string;
|
lembarTerbeli: string;
|
||||||
}) {
|
}) {
|
||||||
console.log("Ini invoiceid", invoiceId)
|
console.log("Ini invoiceid", invoiceId);
|
||||||
console.log("Ini investasid", investasiId)
|
console.log("Ini investasid", investasiId);
|
||||||
console.log("Ini lembar terbeli", lembarTerbeli)
|
console.log("Ini lembar terbeli", lembarTerbeli);
|
||||||
|
|
||||||
const dataInvestasi: any = await prisma.investasi.findFirst({
|
const dataInvestasi: any = await prisma.investasi.findFirst({
|
||||||
where: {
|
where: {
|
||||||
@@ -50,7 +50,6 @@ export async function adminInvestasi_funAcceptTransaksiById({
|
|||||||
statusInvoiceId: "1",
|
statusInvoiceId: "1",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
if (!updt) {
|
if (!updt) {
|
||||||
return { status: 400, message: "Gagal Update Status" };
|
return { status: 400, message: "Gagal Update Status" };
|
||||||
@@ -87,6 +86,3 @@ export async function adminInvestasi_funAcceptTransaksiById({
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user