배포됩니다.

**로직:**
- 1차 시도: 캡차 요청 → 지급
- 성공 → 즉시 다음 쿠폰으로
- 40103(OCR 오인식) → **30초 대기** → 2차 재시도 (이때 WOS 레이트 리밋 완전 리셋)
- 2차도 실패 → 그냥 실패 처리
This commit is contained in:
hyoseung930 2026-05-19 18:19:17 +09:00
parent e19c08b725
commit 8c70714ed6

View File

@ -113,6 +113,12 @@ export class WosService {
fid: string, fid: string,
code: string, code: string,
): Promise<{ success: boolean; message: string; err_code?: number }> { ): Promise<{ success: boolean; message: string; err_code?: number }> {
for (let attempt = 1; attempt <= 2; attempt++) {
if (attempt > 1) {
this.logger.warn(`[${fid}] ${code} 캡차 오인식, 30초 대기 후 재시도`);
await new Promise((r) => setTimeout(r, 30000));
}
let captchaCode: string; let captchaCode: string;
try { try {
captchaCode = await this.solveCaptcha(fid); captchaCode = await this.solveCaptcha(fid);
@ -129,15 +135,20 @@ export class WosService {
); );
const data = response.data; const data = response.data;
this.logger.log(`[${fid}] ${code} captcha=${captchaCode} → code=${data.code} err=${data.err_code} msg=${data.msg}`); this.logger.log(`[${fid}] ${code} attempt=${attempt} captcha=${captchaCode} → code=${data.code} err=${data.err_code} msg=${data.msg}`);
if (data.code === 0) return { success: true, message: SUCCESS_MSG };
if (data.err_code === 40103 && attempt < 2) continue;
return { return {
success: data.code === 0, success: false,
message: data.code === 0 ? SUCCESS_MSG : (data.msg || `실패 (${data.err_code})`), message: data.msg || `실패 (${data.err_code})`,
err_code: data.err_code, err_code: data.err_code,
}; };
} }
return { success: false, message: '알 수 없는 오류' };
}
async redeemAll(fid: string) { async redeemAll(fid: string) {
const activeCoupons = await this.wosCouponRepo.find({ const activeCoupons = await this.wosCouponRepo.find({
where: { is_expired: false }, where: { is_expired: false },