koishi-plugin-prism-neo 0.0.13 → 0.0.15

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 +22 -7
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -228,6 +228,17 @@ var formatBilling = /* @__PURE__ */ __name((res) => {
228
228
  message.push("--- 账单详情 ---");
229
229
  message.push(`入场: ${formatDateTime(res.session.createdAt)}`);
230
230
  message.push(`结算: ${formatDateTime(res.billing.endTime)}`);
231
+ const startTime = new Date(res.session.createdAt).getTime();
232
+ const endTime = new Date(res.billing.endTime).getTime();
233
+ const durationMs = endTime - startTime;
234
+ const totalMinutes = Math.floor(durationMs / (1e3 * 60));
235
+ let durationStr = `${totalMinutes}分钟`;
236
+ if (totalMinutes >= 60) {
237
+ const hours = Math.floor(totalMinutes / 60);
238
+ const mins = totalMinutes % 60;
239
+ durationStr = `${hours}小时${mins}分钟`;
240
+ }
241
+ message.push(`时长: ${durationStr}`);
231
242
  message.push("---");
232
243
  const originalCost = res.discount ? res.discount.originalCost : res.billing.totalCost;
233
244
  let finalCost = res.discount ? res.discount.finalCost : res.billing.totalCost;
@@ -267,8 +278,15 @@ var formatBilling = /* @__PURE__ */ __name((res) => {
267
278
  } else {
268
279
  timeString = `${formatDate(start)} ${formatTime(start)} - ${formatDate(end)} ${formatTime(end)}`;
269
280
  }
281
+ let segDurationStr = `${seg.durationMinutes}分钟`;
282
+ if (seg.durationMinutes >= 60) {
283
+ const hours = Math.floor(seg.durationMinutes / 60);
284
+ const mins = seg.durationMinutes % 60;
285
+ segDurationStr = `${hours}小时${mins}分钟`;
286
+ }
270
287
  message.push(`- ${seg.ruleName}`);
271
288
  message.push(` 时段: ${timeString}`);
289
+ message.push(` 时长: ${segDurationStr}`);
272
290
  message.push(` 费用: ${seg.cost} 月饼 ${seg.isCapped ? "(已封顶)" : ""}`);
273
291
  }
274
292
  });
@@ -303,13 +321,9 @@ async function handleLoginCmd(context, user) {
303
321
  const { error, userId } = await getTargetUserId(context, user);
304
322
  if (error) return error;
305
323
  await login(context, userId);
306
- const pwd = await getLock(context, userId);
307
- if (user) {
308
- return `✅ 已为用户 ${await getUserName(context.session, userId)} 入场,该用户的门锁密码是: ${pwd.password}
309
- 注意! 门锁密码有效期为三分钟`;
310
- }
311
- return `✅ 入场成功,你的门锁密码是: ${pwd.password}
312
- 注意! 门锁密码有效期为三分钟`;
324
+ let [_, lockMessage] = await Promise.all([login(context, userId), handleLockCmd(context)]);
325
+ let message = "✅ 入场成功\n\n" + lockMessage;
326
+ return message;
313
327
  }
314
328
  __name(handleLoginCmd, "handleLoginCmd");
315
329
  async function handleLogoutCmd(context, user) {
@@ -430,6 +444,7 @@ async function handleLockCmd(context) {
430
444
  return [
431
445
  "获取密码成功",
432
446
  `你的门锁密码是: ${res.password}`,
447
+ `输入完成后按 # 结束`,
433
448
  "注意! 门锁密码有效期为三分钟"
434
449
  ].join("\n");
435
450
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-prism-neo",
3
3
  "description": "prism koishi前端",
4
- "version": "0.0.13",
4
+ "version": "0.0.15",
5
5
  "main": "lib/index.js",
6
6
  "files": [
7
7
  "lib",