|
@@ -87,7 +87,7 @@ export async function handleBookEvent(ctx: Context, env: Env): Promise<void> {
|
|
|
}
|
|
}
|
|
|
keyboard.text(
|
|
keyboard.text(
|
|
|
`${coupon.code} (${discountText})`,
|
|
`${coupon.code} (${discountText})`,
|
|
|
- `select_coupon_${eventId}_${slotIndex}_${coupon.code}`
|
|
|
|
|
|
|
+ `select_coupon:${eventId}:${slotIndex}:${coupon.code}`
|
|
|
);
|
|
);
|
|
|
if (index < coupons.length - 1) {
|
|
if (index < coupons.length - 1) {
|
|
|
keyboard.row();
|
|
keyboard.row();
|
|
@@ -95,7 +95,7 @@ export async function handleBookEvent(ctx: Context, env: Env): Promise<void> {
|
|
|
});
|
|
});
|
|
|
// Add option to book without coupon
|
|
// Add option to book without coupon
|
|
|
keyboard.row();
|
|
keyboard.row();
|
|
|
- keyboard.text('不使用优惠码', `select_coupon_${eventId}_${slotIndex}_none`);
|
|
|
|
|
|
|
+ keyboard.text('不使用优惠码', `select_coupon:${eventId}:${slotIndex}:none`);
|
|
|
|
|
|
|
|
await ctx.reply(
|
|
await ctx.reply(
|
|
|
`请选择要使用的优惠码:\n\n` +
|
|
`请选择要使用的优惠码:\n\n` +
|
|
@@ -168,16 +168,16 @@ export async function handleCouponSelection(
|
|
|
action: string
|
|
action: string
|
|
|
): Promise<void> {
|
|
): Promise<void> {
|
|
|
try {
|
|
try {
|
|
|
- // Parse action: select_coupon_{event_id}_{slot_index}_{coupon_code}
|
|
|
|
|
- const parts = action.split('_');
|
|
|
|
|
- if (parts.length < 5 || parts[0] !== 'select' || parts[1] !== 'coupon') {
|
|
|
|
|
|
|
+ // Parse action: select_coupon:{event_id}:{slot_index}:{coupon_code}
|
|
|
|
|
+ const parts = action.split(':');
|
|
|
|
|
+ if (parts.length < 4 || parts[0] !== 'select_coupon') {
|
|
|
await ctx.editMessageText("无效的优惠码选择");
|
|
await ctx.editMessageText("无效的优惠码选择");
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const eventId = parts[2];
|
|
|
|
|
- const slotIndex = parseInt(parts[3]);
|
|
|
|
|
- const couponCode = parts[4] === 'none' ? undefined : parts[4];
|
|
|
|
|
|
|
+ const eventId = parts[1];
|
|
|
|
|
+ const slotIndex = parseInt(parts[2]);
|
|
|
|
|
+ const couponCode = parts[3] === 'none' ? undefined : parts[3];
|
|
|
|
|
|
|
|
// Get user credentials from KV storage
|
|
// Get user credentials from KV storage
|
|
|
const telegramUserId = ctx.from?.id.toString();
|
|
const telegramUserId = ctx.from?.id.toString();
|