1
This commit is contained in:
@@ -162,6 +162,9 @@ class AdminCreditRecordSummaryOut(BaseModel):
|
||||
total_recharge: float = 0.0
|
||||
total_consume: float = 0.0
|
||||
total_refund: float = 0.0
|
||||
# 净消耗 = 真实消费(预扣释放不算)- 退款,这才是真正的"消耗了多少积分"口径
|
||||
# 前端展示"总消耗积分"时应使用此字段,而不是 total_consume(含未退回的)
|
||||
net_consume: float = 0.0
|
||||
transaction_count: int = 0
|
||||
generation_count: int = 0
|
||||
generation_attempt_count: int = 0
|
||||
|
||||
@@ -320,10 +320,16 @@ async def list_admin_credit_records(
|
||||
if where_clause is not None:
|
||||
summary_query = summary_query.where(where_clause)
|
||||
s = (await db.execute(summary_query)).one()
|
||||
_total_recharge = _round2(s[0])
|
||||
_total_consume = _round2(s[1])
|
||||
_total_refund = _round2(s[2])
|
||||
# 净消耗 = 真实消费 - 退款;如果退款超过消费(连续退了跨周期的),下限为 0 避免负数
|
||||
_net_consume = _round2(max(_total_consume - _total_refund, 0.0))
|
||||
summary = {
|
||||
"total_recharge": _round2(s[0]),
|
||||
"total_consume": _round2(s[1]),
|
||||
"total_refund": _round2(s[2]),
|
||||
"total_recharge": _total_recharge,
|
||||
"total_consume": _total_consume,
|
||||
"total_refund": _total_refund,
|
||||
"net_consume": _net_consume,
|
||||
"transaction_count": int(s[3] or 0),
|
||||
"generation_count": int(s[4] or 0),
|
||||
"generation_attempt_count": int(s[5] or 0),
|
||||
|
||||
Reference in New Issue
Block a user