Initial import of WebUp Cloud
Verify control plane / verify (push) Canceled after 0s

This commit is contained in:
WebUp Cloud committed 2026-11-07 13:31:14 +08:00
commit db82325ed7
216 files changed
+33718

No files matched your search

+147
View File
@@ -0,0 +1,147 @@
<script setup lang="ts">
import { onMounted, reactive, ref } from "vue";
import { api, body } from "../api";
import { useSession } from "../store";
const store = useSession(),
wallet = ref<any>(null),
ledger = ref<any[]>([]),
error = ref(""),
success = ref(""),
busy = ref(false);
const adjust = reactive({
userId: "",
amount: "",
reason: "",
idempotencyKey: crypto.randomUUID(),
});
async function load() {
try {
[wallet.value, ledger.value] = await Promise.all([
api("/wallet"),
api("/wallet/ledger"),
]);
} catch (e) {
error.value = (e as Error).message;
}
}
async function save() {
if (!confirm("确认对指定用户进行资金调整?此操作将记入账本和审计日志。"))
return;
busy.value = true;
error.value = "";
try {
await api("/admin/wallets/" + adjust.userId + "/adjust", {
method: "POST",
body: body(adjust),
});
success.value = "余额调整已入账";
adjust.idempotencyKey = crypto.randomUUID();
await load();
} catch (e) {
error.value = (e as Error).message;
} finally {
busy.value = false;
}
}
onMounted(load);
</script>
<template>
<div class="page-heading">
<div>
<span class="eyebrow">WALLET & BILLING</span>
<h1>钱包与账本</h1>
<p>独立账本记录每笔变动,AI 预算预留与实际消费分开。</p>
</div>
<button class="secondary" @click="load">刷新</button>
</div>
<div class="alert error" v-if="error">{{ error }}</div>
<div class="alert success" v-if="success">{{ success }}</div>
<section class="stats" v-if="wallet">
<div class="stat-card">
<div>账户余额 · CNY</div>
<strong>¥ {{ wallet.balance }}</strong
><small>包含预留金额</small>
</div>
<div class="stat-card">
<div>可用余额 · CNY</div>
<strong>¥ {{ wallet.available }}</strong
><small>可用于新任务预算</small>
</div>
<div class="stat-card">
<div>任务预留 · CNY</div>
<strong>¥ {{ wallet.reserved }}</strong
><small>任务结束后释放未消费部分</small>
</div>
</section>
<div class="alert info">
在线支付渠道尚未配置和联调,当前不提供虚假的充值成功流程。管理员可通过有原因、有审计的余额调整入账。
</div>
<section class="panel table-panel">
<div class="panel-heading">
<h3>交易账本</h3>
<span class="muted">最近 200 条 · CNY</span>
</div>
<div class="table-scroll">
<table>
<thead>
<tr>
<th>时间</th>
<th>类型</th>
<th>变动金额</th>
<th>变动后余额</th>
<th>关联业务</th>
<th>原因</th>
</tr>
</thead>
<tbody>
<tr v-for="l in ledger" :key="l.id">
<td>{{ new Date(l.created_at).toLocaleString() }}</td>
<td>{{ l.kind }}</td>
<td :class="Number(l.amount) >= 0 ? 'good' : 'danger'">
{{ l.amount }}
</td>
<td>{{ l.balance_after }}</td>
<td class="truncate" :title="l.business_id">{{ l.business_id }}</td>
<td>{{ l.reason }}</td>
</tr>
<tr v-if="!ledger.length">
<td class="empty" colspan="6">
暂无交易,所有余额来自实际账本记录。
</td>
</tr>
</tbody>
</table>
</div>
</section>
<section
v-if="store.user?.permissions.includes('finance:write')"
class="panel form-panel settings-form"
>
<h3>管理员资金调整</h3>
<p class="muted">正数增加余额,负数扣除可用余额;不能动用已预留资金。</p>
<form @submit.prevent="save">
<label
>用户 UUID<input
v-model="adjust.userId"
required
placeholder="从用户管理获取" /></label
><label
>金额 · CNY<input
v-model="adjust.amount"
type="number"
step="0.00000001"
required /></label
><label
>调整原因<input
v-model="adjust.reason"
maxlength="500"
required /></label
><label
>幂等标识<input
v-model="adjust.idempotencyKey"
maxlength="200"
required /></label
><button class="primary" :disabled="busy">确认调整</button>
</form>
</section>
</template>