diff --git a/admin_settings.php b/admin_settings.php index fee7c6b..93dfa0d 100755 --- a/admin_settings.php +++ b/admin_settings.php @@ -373,6 +373,62 @@ while ($row = $stmt->fetch()) { +
+

兑换码状态同步

+ $endTime) { + $syncResult = '
请选择有效的时间范围
'; + } else { + $stmt = $pdo->query("SELECT id, code, name, api_url, token FROM products WHERE status = 1 AND api_url IS NOT NULL AND api_url != ''"); + $products = $stmt->fetchAll(); + if (empty($products)) { + $syncResult = '
没有已配置接口地址的产品
'; + } else { + $output = ''; + foreach ($products as $p) { + $ret = syncCouponStatus($pdo, $p, $startTime, $endTime); + if ($ret['success']) { + $output .= "{$p['name']}: API返回{$ret['total']}条, 匹配{$ret['matched']}条, 更新{$ret['updated']}条"; + if (!empty($ret['matched_codes'])) { + $output .= '
✓ 已匹配 (' . count($ret['matched_codes']) . '个): ' . h(implode(', ', $ret['matched_codes'])) . ''; + } + if (!empty($ret['unmatched_codes'])) { + $output .= '
✗ 未匹配 (' . count($ret['unmatched_codes']) . '个): ' . h(implode(', ', array_slice($ret['unmatched_codes'], 0, 50))) . (count($ret['unmatched_codes']) > 50 ? '...' : '') . ''; + } + $output .= '
'; + } else { + $output .= "{$p['name']}: 失败 - {$ret['message']}
"; + } + } + $syncResult = '
' . $output . '
'; + } + } + } + ?> + +

通过远程接口查询兑换码的使用状态,并将已使用的兑换码更新到本地。

+
+ +
+ + + +
+
+ + + +
+ +
+
+