1
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
const logic = require("../service/biz_subscription_logic");
|
const logic = require("../service/biz_subscription_logic");
|
||||||
|
const audit = require("../service/biz_audit_service");
|
||||||
|
|
||||||
function getRequestBody(ctx) {
|
function getRequestBody(ctx) {
|
||||||
if (ctx.request && ctx.request.body && Object.keys(ctx.request.body).length > 0) {
|
if (ctx.request && ctx.request.body && Object.keys(ctx.request.body).length > 0) {
|
||||||
@@ -14,11 +15,25 @@ module.exports = {
|
|||||||
"POST /biz_payment/confirm-offline": async (ctx) => {
|
"POST /biz_payment/confirm-offline": async (ctx) => {
|
||||||
const body = getRequestBody(ctx);
|
const body = getRequestBody(ctx);
|
||||||
const row = await logic.confirmOfflinePayment(body);
|
const row = await logic.confirmOfflinePayment(body);
|
||||||
|
await audit.logAudit({
|
||||||
|
admin_user_id: audit.pickAdminId(ctx),
|
||||||
|
action: "biz_payment.confirm_offline",
|
||||||
|
resource_type: "biz_subscription",
|
||||||
|
resource_id: body.subscription_id,
|
||||||
|
detail: { payment_ref: body.payment_ref },
|
||||||
|
});
|
||||||
ctx.success(row);
|
ctx.success(row);
|
||||||
},
|
},
|
||||||
"POST /biz_payment/confirm-link": async (ctx) => {
|
"POST /biz_payment/confirm-link": async (ctx) => {
|
||||||
const body = getRequestBody(ctx);
|
const body = getRequestBody(ctx);
|
||||||
const row = await logic.confirmLinkPayment(body);
|
const row = await logic.confirmLinkPayment(body);
|
||||||
|
await audit.logAudit({
|
||||||
|
admin_user_id: audit.pickAdminId(ctx),
|
||||||
|
action: "biz_payment.confirm_link",
|
||||||
|
resource_type: "biz_subscription",
|
||||||
|
resource_id: body.subscription_id,
|
||||||
|
detail: { payment_ref: body.payment_ref },
|
||||||
|
});
|
||||||
ctx.success(row);
|
ctx.success(row);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,16 +1,8 @@
|
|||||||
const crud = require("../service/biz_admin_crud");
|
const crud = require("../service/biz_admin_crud");
|
||||||
|
const { getRequestBody } = crud;
|
||||||
const baseModel = require("../../middleware/baseModel");
|
const baseModel = require("../../middleware/baseModel");
|
||||||
const logic = require("../service/biz_subscription_logic");
|
const logic = require("../service/biz_subscription_logic");
|
||||||
|
const audit = require("../service/biz_audit_service");
|
||||||
function getRequestBody(ctx) {
|
|
||||||
if (ctx.request && ctx.request.body && Object.keys(ctx.request.body).length > 0) {
|
|
||||||
return ctx.request.body;
|
|
||||||
}
|
|
||||||
if (typeof ctx.getBody === "function") {
|
|
||||||
return ctx.getBody() || {};
|
|
||||||
}
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
"POST /biz_subscription/page": async (ctx) => {
|
"POST /biz_subscription/page": async (ctx) => {
|
||||||
@@ -36,21 +28,53 @@ module.exports = {
|
|||||||
"POST /biz_subscription/open": async (ctx) => {
|
"POST /biz_subscription/open": async (ctx) => {
|
||||||
const body = getRequestBody(ctx);
|
const body = getRequestBody(ctx);
|
||||||
const row = await logic.openSubscription(body);
|
const row = await logic.openSubscription(body);
|
||||||
|
await audit.logAudit({
|
||||||
|
admin_user_id: audit.pickAdminId(ctx),
|
||||||
|
biz_user_id: body.user_id,
|
||||||
|
action: "biz_subscription.open",
|
||||||
|
resource_type: "biz_subscription",
|
||||||
|
resource_id: row.id,
|
||||||
|
detail: { plan_id: body.plan_id, status: row.status },
|
||||||
|
});
|
||||||
ctx.success(row);
|
ctx.success(row);
|
||||||
},
|
},
|
||||||
"POST /biz_subscription/upgrade": async (ctx) => {
|
"POST /biz_subscription/upgrade": async (ctx) => {
|
||||||
const body = getRequestBody(ctx);
|
const body = getRequestBody(ctx);
|
||||||
const row = await logic.upgradeSubscription(body);
|
const row = await logic.upgradeSubscription(body);
|
||||||
|
await audit.logAudit({
|
||||||
|
admin_user_id: audit.pickAdminId(ctx),
|
||||||
|
action: "biz_subscription.upgrade",
|
||||||
|
resource_type: "biz_subscription",
|
||||||
|
resource_id: body.subscription_id,
|
||||||
|
detail: { new_plan_id: body.new_plan_id },
|
||||||
|
});
|
||||||
ctx.success(row);
|
ctx.success(row);
|
||||||
},
|
},
|
||||||
"POST /biz_subscription/renew": async (ctx) => {
|
"POST /biz_subscription/renew": async (ctx) => {
|
||||||
const body = getRequestBody(ctx);
|
const body = getRequestBody(ctx);
|
||||||
const row = await logic.renewSubscription(body);
|
const row = await logic.renewSubscription(body);
|
||||||
|
await audit.logAudit({
|
||||||
|
admin_user_id: audit.pickAdminId(ctx),
|
||||||
|
action: "biz_subscription.renew",
|
||||||
|
resource_type: "biz_subscription",
|
||||||
|
resource_id: body.subscription_id,
|
||||||
|
});
|
||||||
ctx.success(row);
|
ctx.success(row);
|
||||||
},
|
},
|
||||||
"POST /biz_subscription/cancel": async (ctx) => {
|
"POST /biz_subscription/cancel": async (ctx) => {
|
||||||
const body = getRequestBody(ctx);
|
const body = getRequestBody(ctx);
|
||||||
const row = await logic.cancelSubscription(body);
|
const row = await logic.cancelSubscription(body);
|
||||||
|
await audit.logAudit({
|
||||||
|
admin_user_id: audit.pickAdminId(ctx),
|
||||||
|
action: "biz_subscription.cancel",
|
||||||
|
resource_type: "biz_subscription",
|
||||||
|
resource_id: body.subscription_id,
|
||||||
|
});
|
||||||
ctx.success(row);
|
ctx.success(row);
|
||||||
},
|
},
|
||||||
|
"POST /biz_subscription/export": async (ctx) => {
|
||||||
|
const body = getRequestBody(ctx);
|
||||||
|
const res = await crud.exportCsv("biz_subscription", body);
|
||||||
|
ctx.success(res);
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -31,4 +31,20 @@ module.exports = {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
"POST /biz_token/revoke": async (ctx) => {
|
"POST /biz_token/revoke": async (ctx) => {
|
||||||
const body = getRequestBody(ct
|
const body = getRequestBody(ctx);
|
||||||
|
const row = await tokenLogic.revokeToken(body);
|
||||||
|
await audit.logAudit({
|
||||||
|
admin_user_id: audit.pickAdminId(ctx),
|
||||||
|
biz_user_id: row.user_id,
|
||||||
|
action: "biz_token.revoke",
|
||||||
|
resource_type: "biz_api_token",
|
||||||
|
resource_id: row.id,
|
||||||
|
});
|
||||||
|
ctx.success({ id: row.id, status: row.status });
|
||||||
|
},
|
||||||
|
"POST /biz_token/export": async (ctx) => {
|
||||||
|
const body = getRequestBody(ctx);
|
||||||
|
const res = await crud.exportCsv("biz_api_token", body);
|
||||||
|
ctx.success(res);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user