|
|
@@ -18,10 +18,10 @@
|
|
|
<ElTableColumn prop="balance" label="余额" />
|
|
|
<ElTableColumn v-if="isAdmin" prop="rate" label="费率" />
|
|
|
<ElTableColumn prop="send" label="已发送" />
|
|
|
- <ElTableColumn label="操作" align="center" width="300">
|
|
|
+ <ElTableColumn label="操作" align="center" width="350">
|
|
|
<template #default="{ row }">
|
|
|
- <ElButton plain @click="recharge(row.id)">余额划转</ElButton>
|
|
|
- <ElButton plain @click="recharge(row.id)">余额充值</ElButton>
|
|
|
+ <ElButton v-if="isApi" plain @click="transfer(row.id)">余额划转</ElButton>
|
|
|
+ <ElButton v-if="isSuperApi" plain @click="recharge(row.id)">余额充值</ElButton>
|
|
|
<ElButton v-if="isAdmin" plain @click="rate(row.id)">修改费率</ElButton>
|
|
|
<ElButton type="primary" size="small" @click="detail(row)">余额记录</ElButton>
|
|
|
</template>
|
|
|
@@ -55,8 +55,9 @@
|
|
|
<ElTableColumn prop="type" label="类型" align="center">
|
|
|
<template #default="{ row }">
|
|
|
<ElTag v-if="row.type === 'recharge'" type="success">充值</ElTag>
|
|
|
+ <ElTag v-else-if="row.type === 'transfer'" type="primary">划转</ElTag>
|
|
|
<ElTag v-else-if="row.type === 'consumption'" type="warning">消费</ElTag>
|
|
|
- <ElTag v-else-if="row.type === 'refund'" type="warning">退款</ElTag>
|
|
|
+ <ElTag v-else-if="row.type === 'refund'" type="danger">退款</ElTag>
|
|
|
<ElTag v-else-if="row.type === 'other'">其他</ElTag>
|
|
|
<ElTag v-else>未知</ElTag>
|
|
|
</template>
|
|
|
@@ -81,6 +82,7 @@ import { useUserStore } from '@/stores/user'
|
|
|
|
|
|
const isAdmin = inject('isAdmin')
|
|
|
const isSuperApi = inject('isSuperApi')
|
|
|
+const isApi = inject('isApi')
|
|
|
const where = ref({})
|
|
|
const timeFormatter = useTimeFormatter()
|
|
|
const table = ref(null)
|
|
|
@@ -117,7 +119,7 @@ const recharge = async (userId) => {
|
|
|
ElMessageBox.prompt('请输入充值金额', '余额充值', {
|
|
|
confirmButtonText: '确认',
|
|
|
cancelButtonText: '取消',
|
|
|
- inputPattern: /^\d+(\.\d{1,2})?$/,
|
|
|
+ inputPattern: /^-?\d+(\.\d{1,2})?$/,
|
|
|
inputErrorMessage: '金额不能超出俩位小数!'
|
|
|
}).then(async ({ value }) => {
|
|
|
const url = '/balance/recharge/' + userId + '/' + value
|
|
|
@@ -135,6 +137,40 @@ const recharge = async (userId) => {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+const transfer = async (userId) => {
|
|
|
+ ElMessageBox.prompt('请输入划转金额', '余额划转', {
|
|
|
+ confirmButtonText: '确认',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ inputPattern: /^\d+(\.\d{1,2})?$/,
|
|
|
+ inputErrorMessage: '金额不能超出俩位小数!'
|
|
|
+ }).then(async ({ value }) => {
|
|
|
+ const url = '/balance/transfer/' + userId + '/' + value
|
|
|
+ const res = await http.get(url)
|
|
|
+ table.value.refresh()
|
|
|
+ if (res === 'Balance not enough!') {
|
|
|
+ ElMessage({
|
|
|
+ type: 'warning',
|
|
|
+ message: '当前余额不足,无法划转,请先充值!'
|
|
|
+ })
|
|
|
+ } else if (res === 'Transfer success!') {
|
|
|
+ ElMessage({
|
|
|
+ type: 'success',
|
|
|
+ message: `划转成功`
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ ElMessage({
|
|
|
+ type: 'warning',
|
|
|
+ message: '划转失败,请联系管理员'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }).catch(() => {
|
|
|
+ ElMessage({
|
|
|
+ type: 'info',
|
|
|
+ message: '取消划转'
|
|
|
+ })
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
const rate = async (userId) => {
|
|
|
ElMessageBox.prompt('请输入最新费率', '修改费率', {
|
|
|
confirmButtonText: '确认',
|