koishi-plugin-prism 0.1.34 → 0.1.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +13 -24
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -577,7 +577,7 @@ class PrismKoishiService {
|
|
|
577
577
|
checkoutAdjustments,
|
|
578
578
|
pricingCapAdjustments,
|
|
579
579
|
globalCapWindows: result.globalCapWindows,
|
|
580
|
-
|
|
580
|
+
wallet: result.wallet,
|
|
581
581
|
};
|
|
582
582
|
const receipt = await this.formatCheckoutPreview(synthetic, sender, title, false);
|
|
583
583
|
const recipients = [...new Set([...(this.config.staffUserIds ?? []), ...(this.config.logoutNotifyUserIds ?? [])])];
|
|
@@ -960,26 +960,18 @@ class PrismKoishiService {
|
|
|
960
960
|
const sessionPreviews = result.sessionPreviews;
|
|
961
961
|
const pricingCapAdjustments = result.pricingCapAdjustments;
|
|
962
962
|
const checkoutAdjustments = result.checkoutAdjustments;
|
|
963
|
-
const
|
|
963
|
+
const wallet = result.wallet;
|
|
964
|
+
const balanceBefore = toNumber(wallet?.balanceBefore ?? 0);
|
|
965
|
+
const balanceAfter = toNumber(wallet?.balanceAfter ?? 0);
|
|
964
966
|
const lines = [];
|
|
965
967
|
lines.push(title);
|
|
966
968
|
lines.push(await this.resolvePlayerDisplay(sender, playerId));
|
|
967
|
-
let balance = 0;
|
|
968
|
-
let hasBalance = false;
|
|
969
|
-
for (const holding of assetHoldings) {
|
|
970
|
-
const code = String(holding?.assetCode ?? "").toLowerCase();
|
|
971
|
-
if (code.includes("paid") || code.includes("free") || code.includes("currency")) {
|
|
972
|
-
balance += toNumber(holding?.quantity ?? 0);
|
|
973
|
-
hasBalance = true;
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
969
|
const hasNonZeroSessionTotal = sessionPreviews.some((session) => toNumber(session?.total ?? 0) !== 0);
|
|
977
970
|
const hasNonZeroAdjustment = hasAdjustmentEntries(checkoutAdjustments, sessionPreviews);
|
|
978
971
|
if (!hasNonZeroSessionTotal && !hasNonZeroAdjustment) {
|
|
979
972
|
lines.push("");
|
|
980
973
|
lines.push("本次未产生费用");
|
|
981
|
-
|
|
982
|
-
lines.push(`余额:${formatNumber(balance)}${currency}`);
|
|
974
|
+
lines.push(`余额:${formatNumber(isPreview ? balanceBefore : balanceAfter)}${currency}`);
|
|
983
975
|
return lines.join("\n");
|
|
984
976
|
}
|
|
985
977
|
const validStarts = sessionPreviews.map((s) => parseDateTime(s?.startedAt)).filter(Boolean);
|
|
@@ -1054,17 +1046,14 @@ class PrismKoishiService {
|
|
|
1054
1046
|
lines.push("");
|
|
1055
1047
|
lines.push(`${hasManualAdjustment ? "调整后价格" : "优惠后价格"}:${formatNumber(total)}${currency}`);
|
|
1056
1048
|
}
|
|
1057
|
-
if (
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
}
|
|
1065
|
-
else {
|
|
1066
|
-
lines.push(`扣款后余额:${formatNumber(balance)}${currency}`);
|
|
1067
|
-
}
|
|
1049
|
+
if (isPreview) {
|
|
1050
|
+
lines.push(`当前余额:${formatNumber(balanceBefore)}${currency}`);
|
|
1051
|
+
lines.push(balanceAfter >= 0
|
|
1052
|
+
? `预计结账后余额:${formatNumber(balanceAfter)}${currency}`
|
|
1053
|
+
: `预计结账后余额:余额不足(还差 ${formatNumber(-balanceAfter)}${currency})`);
|
|
1054
|
+
}
|
|
1055
|
+
else {
|
|
1056
|
+
lines.push(`扣款后余额:${formatNumber(balanceAfter)}${currency}`);
|
|
1068
1057
|
}
|
|
1069
1058
|
return lines.join("\n");
|
|
1070
1059
|
}
|