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.
Files changed (2) hide show
  1. package/lib/index.js +13 -24
  2. 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
- assetHoldings: result.assetHoldings,
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 assetHoldings = result.assetHoldings;
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
- if (hasBalance)
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 (hasBalance) {
1058
- if (isPreview) {
1059
- const projectedBalance = balance - toNumber(total);
1060
- lines.push(`当前余额:${formatNumber(balance)}${currency}`);
1061
- lines.push(projectedBalance >= 0
1062
- ? `预计结账后余额:${formatNumber(projectedBalance)}${currency}`
1063
- : `预计结账后余额:余额不足(还差 ${formatNumber(-projectedBalance)}${currency})`);
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koishi-plugin-prism",
3
- "version": "0.1.34",
3
+ "version": "0.1.35",
4
4
  "description": "PRiSM Next 计费与设备管理系统的 Koishi 机器人集成插件",
5
5
  "main": "./lib/index.js",
6
6
  "exports": {