解冻之前被冻结的一分钱,修改返款记录布局

This commit is contained in:
db_huang 2026-11-05 15:39:42 +08:00
parent bd7a578252
commit 5a45708d67
5 changed files with 38 additions and 6 deletions

View File

@ -3908,14 +3908,14 @@ def export_refund_records(q: str = "", start_date: str = "", end_date: str = "",
query = _refund_record_query(user, q, start_date, end_date)
output = io.StringIO()
writer = csv.writer(output)
writer.writerow(["店铺名称", "电商平台", "商品ID", "转账时间", "订单号", "收款人", "收款账号", "返款金额(元)", "付款账户", "操作人", "支付宝流水"])
writer.writerow(["电商平台", "店铺名称", "商品ID", "转账时间", "订单号", "收款人", "收款账号", "返款金额(元)", "付款账户", "操作人", "支付宝流水"])
total = 0
def safe(value):
value = str(value or "")
return "'" + value if value.lstrip().startswith(("=", "+", "-", "@")) or value.startswith(("\t", "\r", "\n")) else value
for record in db.scalars(query.order_by(RefundRecord.transferred_at.desc(), RefundRecord.id.desc()).execution_options(yield_per=500)):
total += record.amount_fen
writer.writerow([safe(record.shop_name), safe(record.ecommerce_platform), safe(record.product_id), (record.transferred_at + timedelta(hours=8)).strftime("%Y-%m-%d %H:%M:%S"), safe(record.order_no), safe(record.payee_name), safe(record.payee_account), f"{record.amount_fen / 100:.2f}", safe(record.payer_account), safe(record.operator_name), safe(record.alipay_trade_no)])
writer.writerow([safe(record.ecommerce_platform), safe(record.shop_name), safe(record.product_id), (record.transferred_at + timedelta(hours=8)).strftime("%Y-%m-%d %H:%M:%S"), safe(record.order_no), safe(record.payee_name), safe(record.payee_account), f"{record.amount_fen / 100:.2f}", safe(record.payer_account), safe(record.operator_name), safe(record.alipay_trade_no)])
writer.writerow(["合计", "", "", "", "", "", "", f"{total / 100:.2f}", "", "", ""])
return Response(content="\ufeff" + output.getvalue(), media_type="text/csv; charset=utf-8", headers={"Content-Disposition": 'attachment; filename="refund-records.csv"'})

0
backend/data/app.db Normal file
View File

View File

@ -75,9 +75,22 @@ export default function RefundRecordsPage({ api }) {
{error && <p role="alert" className="refund-records-error">{error}</p>}
<div className="refund-account-table-wrap" aria-busy={loading}>
<table className="refund-account-table refund-records-table">
<thead><tr>{["店铺名称", "电商平台", "商品ID", "转账时间", "订单号", "收款人", "收款账号", "返款金额", "付款账户", "操作人", "支付宝流水"].map((title) => <th key={title}>{title}</th>)}</tr></thead>
<colgroup>
<col className="refund-col-platform" />
<col className="refund-col-shop" />
<col className="refund-col-product" />
<col className="refund-col-time" />
<col className="refund-col-order" />
<col className="refund-col-payee" />
<col className="refund-col-account" />
<col className="refund-col-amount" />
<col className="refund-col-payer" />
<col className="refund-col-operator" />
<col className="refund-col-trade" />
</colgroup>
<thead><tr>{["电商平台", "店铺名称", "商品ID", "转账时间", "订单号", "收款人", "收款账号", "返款金额", "付款账户", "操作人", "支付宝流水"].map((title) => <th key={title}>{title}</th>)}</tr></thead>
<tbody>{loading || error ? <tr><td colSpan={11}>{loading ? "加载中…" : "记录加载失败,请调整筛选或重新进入页面"}</td></tr> : data.items.length ? data.items.map((item) => <tr key={item.id}>
<td>{item.shop_name || "—"}</td><td>{item.ecommerce_platform || "—"}</td><td>{item.product_id || "—"}</td><td>{formatDateTime(item.transferred_at)}</td><td>{item.order_no}</td><td>{item.payee_name || "—"}</td><td>{item.payee_account || "—"}</td><td className="refund-account-balance">{money(item.amount_fen)}</td><td>{item.payer_account || "—"}</td><td>{item.operator_name || "—"}</td><td>{item.alipay_trade_no || "—"}</td>
<td className="refund-platform-cell">{item.ecommerce_platform || "—"}</td><td className="refund-shop-cell">{item.shop_name || "—"}</td><td className="refund-product-cell">{item.product_id || "—"}</td><td className="refund-time-cell">{formatDateTime(item.transferred_at)}</td><td className="refund-order-cell">{item.order_no}</td><td>{item.payee_name || "—"}</td><td className="refund-payee-account-cell">{item.payee_account || "—"}</td><td className="refund-account-balance">{money(item.amount_fen)}</td><td>{item.payer_account || "—"}</td><td>{item.operator_name || "—"}</td><td className="refund-trade-cell" title={item.alipay_trade_no || ""}>{item.alipay_trade_no || "—"}</td>
</tr>) : <tr><td colSpan={11}>暂无返款记录</td></tr>}</tbody>
{!loading && !error && <tfoot><tr><th colSpan={7}>合计(当前筛选全部记录)</th><td className="refund-account-balance">{money(data.total_amount_fen)}</td><td colSpan={3} /></tr></tfoot>}
</table>

View File

@ -6394,8 +6394,27 @@ html.dingtalk-mobile .answer-v2-footer {
.refund-records-toolbar input[type="date"] { padding: 9px; border: 1px solid #cbdaf2; border-radius: 8px; background: white; color: inherit; }
.refund-records-toolbar > .primary-button { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.refund-records-hint { color: #7186a5; font-size: 12px; margin: 16px 0; }
.refund-records-table { min-width: 1250px; }
.refund-records-table td { overflow-wrap: anywhere; max-width: 230px; }
.refund-records-table { width: 100%; min-width: 1540px; table-layout: fixed; }
.refund-records-table col.refund-col-platform { width: 90px; }
.refund-records-table col.refund-col-shop { width: 175px; }
.refund-records-table col.refund-col-product { width: 155px; }
.refund-records-table col.refund-col-time { width: 155px; }
.refund-records-table col.refund-col-order { width: 195px; }
.refund-records-table col.refund-col-payee { width: 85px; }
.refund-records-table col.refund-col-account { width: 125px; }
.refund-records-table col.refund-col-amount { width: 90px; }
.refund-records-table col.refund-col-payer { width: 90px; }
.refund-records-table col.refund-col-operator { width: 105px; }
.refund-records-table col.refund-col-trade { width: 275px; }
.refund-records-table td { max-width: none; overflow-wrap: normal; word-break: normal; }
.refund-records-table .refund-shop-cell { overflow-wrap: anywhere; }
.refund-records-table .refund-platform-cell,
.refund-records-table .refund-product-cell,
.refund-records-table .refund-time-cell,
.refund-records-table .refund-order-cell,
.refund-records-table .refund-payee-account-cell,
.refund-records-table .refund-trade-cell { white-space: nowrap; font-variant-numeric: tabular-nums; }
.refund-records-table .refund-trade-cell { font-size: 12px; }
.refund-records-table tfoot { background: #f6f8fc; }
.refund-records-error { color: #dc2626; }
.refund-record-fields { border: 0; padding: 0; margin: 12px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; text-align: left; }