feat: implement WeChat cross-batch refund reconciliation and fix misc issues
WeChat cross-batch refund reconciliation: - Add OriginalAmount field to CleanedBill for accurate cumulative refund math - DeduplicateRawFile detects WeChat status-update rows (已退款/已全额退款) and emits WechatRefundUpdates for Go-side reconciliation (Scenario 1) - WechatPy cleaner surfaces -退款 income rows with no same-batch expense match as unresolved_refunds for Go ReconcileRefund (Scenario 2) - Add ReconcileWechatRefund to repository interface and MongoDB implementation - upload.go step 15 iterates WechatRefundUpdates and reconciles against bills_cleaned Bug fixes: - ReviewStats: add nil repo check to prevent panic when DB is not connected - JWT: remove hardcoded fallback secret; return 500/401 if JWTSecret not configured - Remove unused parsePageParam dead code and its strconv import - BillDetailDrawer: show 不计收支 amount in muted gray instead of red - test_jd_cleaner.py: replace hardcoded D:\Projects\BillAI path with dynamic __file__ resolution Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -54,7 +54,23 @@ class WechatCleaner(BaseCleaner):
|
||||
|
||||
# 第三步:处理退款(包括转账退款)
|
||||
final_expense_rows, income_rows = self._process_refunds(expense_rows, income_rows)
|
||||
|
||||
|
||||
# 收集跨批次未匹配的 -退款 行(当前批次无对应支出记录,需 Go 侧跨批次核销)
|
||||
expense_merchants = {exp[2].strip() for exp in expense_rows}
|
||||
for refund_row in refund_rows:
|
||||
if refund_row[2].strip() not in expense_merchants:
|
||||
amount = float(parse_amount(refund_row[5]))
|
||||
if amount > 0:
|
||||
self.unresolved_refunds.append({
|
||||
"order_no": "",
|
||||
"merchant_order_no": refund_row[9].strip() if len(refund_row) > 9 else "",
|
||||
"refund_order_no": refund_row[8].strip() if len(refund_row) > 8 else "",
|
||||
"amount": amount,
|
||||
"time": refund_row[0],
|
||||
"merchant": refund_row[2],
|
||||
"description": refund_row[3] if len(refund_row) > 3 else "",
|
||||
})
|
||||
|
||||
print(f"\n处理结果:")
|
||||
print(f" 全额退款删除: {self.stats['fully_refunded']} 条")
|
||||
print(f" 部分退款调整: {self.stats['partially_refunded']} 条")
|
||||
|
||||
Reference in New Issue
Block a user