mirror of
https://gitee.com/bootx/dax-pay-ui.git
synced 2025-09-02 02:24:29 +00:00
feat 钱包管理
This commit is contained in:
123
src/views/payment/channel/wallet/manager/CreateWalletModel.vue
Normal file
123
src/views/payment/channel/wallet/manager/CreateWalletModel.vue
Normal file
@@ -0,0 +1,123 @@
|
||||
<template>
|
||||
<basic-modal
|
||||
title="退款申请"
|
||||
v-bind="$attrs"
|
||||
:loading="confirmLoading"
|
||||
:width="modalWidth"
|
||||
:visible="visible"
|
||||
:mask-closable="showable"
|
||||
@cancel="handleCancel"
|
||||
>
|
||||
<a-form ref="formRef" :model="form" :rules="rules" :label-col="labelCol" :wrapper-col="wrapperCol">
|
||||
<a-form-item validate-first label="用户ID" name="userId">
|
||||
<a-input v-model:value="form.userId" placeholder="请输入要开通的用户ID" />
|
||||
</a-form-item>
|
||||
<a-form-item label="钱包名称" name="name">
|
||||
<a-input v-model:value="form.name" placeholder="请输入钱包名称" />
|
||||
</a-form-item>
|
||||
<a-form-item label="余额(分)" name="balance">
|
||||
<a-input-number :min="0" :precision="0" v-model:value="form.balance" />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
<template #footer>
|
||||
<a-space>
|
||||
<a-button key="cancel" @click="handleCancel">取消</a-button>
|
||||
<a-button key="forward" :loading="confirmLoading" type="primary" @click="handleOk">确定</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
</basic-modal>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { $ref } from 'vue/macros'
|
||||
import useFormEdit from '/@/hooks/bootx/useFormEdit'
|
||||
import { useDict } from '/@/hooks/bootx/useDict'
|
||||
import BasicModal from '/@/components/Modal/src/BasicModal.vue'
|
||||
import { FormInstance, Rule } from 'ant-design-vue/lib/form'
|
||||
import { useMessage } from '/@/hooks/web/useMessage'
|
||||
import { nextTick } from 'vue'
|
||||
import { create, existsByUserId } from '/@/views/payment/channel/wallet/manager/Wallet.api'
|
||||
|
||||
const {
|
||||
initFormEditType,
|
||||
handleCancel,
|
||||
search,
|
||||
labelCol,
|
||||
wrapperCol,
|
||||
modalWidth,
|
||||
title,
|
||||
confirmLoading,
|
||||
visible,
|
||||
editable,
|
||||
showable,
|
||||
formEditType,
|
||||
} = useFormEdit()
|
||||
const { createMessage, createConfirm } = useMessage()
|
||||
const { dictConvert } = useDict()
|
||||
|
||||
const formRef = $ref<FormInstance>()
|
||||
let form = $ref({
|
||||
userId: '',
|
||||
name: '',
|
||||
balance: 0,
|
||||
})
|
||||
|
||||
const rules = {
|
||||
userId: [
|
||||
{ required: true, message: '用户ID不能为空' },
|
||||
{ validator: validateBindPhone, trigger: 'blur' },
|
||||
],
|
||||
name: [{ required: true, message: '钱包名称不能为空' }],
|
||||
balance: [{ required: true, message: '钱包余额不能为空' }],
|
||||
} as Record<string, Rule[]>
|
||||
|
||||
const emits = defineEmits(['ok'])
|
||||
|
||||
/**
|
||||
* 入口
|
||||
*/
|
||||
async function init() {
|
||||
resetForm()
|
||||
visible.value = true
|
||||
}
|
||||
|
||||
/**
|
||||
* 开通钱包
|
||||
*/
|
||||
function handleOk() {
|
||||
formRef?.validate().then(() => {
|
||||
createConfirm({
|
||||
iconType: 'warning',
|
||||
title: '警告',
|
||||
content: '确实要开通钱包!',
|
||||
onOk: async () => {
|
||||
confirmLoading.value = true
|
||||
await create(form)
|
||||
confirmLoading.value = false
|
||||
visible.value = false
|
||||
emits('ok')
|
||||
},
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 后台校验手机号是否被使用
|
||||
*/
|
||||
async function validateBindPhone() {
|
||||
const { data } = await existsByUserId(form.userId)
|
||||
return data ? Promise.reject('该用户已经开通钱包') : Promise.resolve()
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置表单
|
||||
*/
|
||||
function resetForm() {
|
||||
nextTick(() => {
|
||||
formRef?.resetFields()
|
||||
})
|
||||
}
|
||||
defineExpose({ init })
|
||||
</script>
|
||||
|
||||
<style scoped lang="less"></style>
|
77
src/views/payment/channel/wallet/manager/Wallet.api.ts
Normal file
77
src/views/payment/channel/wallet/manager/Wallet.api.ts
Normal file
@@ -0,0 +1,77 @@
|
||||
import { defHttp } from '/@/utils/http/axios'
|
||||
import { PageResult, Result } from '/#/axios'
|
||||
import { BaseEntity } from '/#/web'
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
export function page(params) {
|
||||
return defHttp.get<Result<PageResult<Wallet>>>({
|
||||
url: '/wallet/page',
|
||||
params,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单条
|
||||
*/
|
||||
export function get(id) {
|
||||
return defHttp.get<Result<Wallet>>({
|
||||
url: '/wallet/findById',
|
||||
params: { id },
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断用户是否开通了钱包
|
||||
*/
|
||||
export function existsByUserId(userId: string){
|
||||
return defHttp.get<Result<boolean>>({
|
||||
url: '/wallet/existsByUserId',
|
||||
params: { userId },
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 开通钱包
|
||||
*/
|
||||
export function create(params) {
|
||||
return defHttp.post<Result<Wallet>>({
|
||||
url: '/wallet/create',
|
||||
data: params,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 充值
|
||||
*/
|
||||
export function recharge(params) {
|
||||
return defHttp.post<Result<Wallet>>({
|
||||
url: '/wallet/recharge',
|
||||
data: params,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 扣减
|
||||
*/
|
||||
export function deduct(params) {
|
||||
return defHttp.post<Result<Wallet>>({
|
||||
url: '/wallet/deduct',
|
||||
data: params,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 钱包
|
||||
*/
|
||||
export interface Wallet extends BaseEntity {
|
||||
// 钱包关联的账号ID
|
||||
userId?: string
|
||||
// 钱包名称
|
||||
name?: string
|
||||
// 钱包余额
|
||||
balance?: string
|
||||
// 状态
|
||||
status?: string
|
||||
}
|
127
src/views/payment/channel/wallet/manager/WalletList.vue
Normal file
127
src/views/payment/channel/wallet/manager/WalletList.vue
Normal file
@@ -0,0 +1,127 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="m-3 p-3 pt-5 bg-white">
|
||||
<b-query :query-params="model.queryParam" :fields="fields" @query="queryPage" @reset="resetQueryParams" />
|
||||
</div>
|
||||
<div class="m-3 p-3 bg-white">
|
||||
<vxe-toolbar ref="xToolbar" custom :refresh="{ queryMethod: queryPage }">
|
||||
<template #buttons>
|
||||
<a-button type="primary" @click="create">钱包开通</a-button>
|
||||
</template>
|
||||
</vxe-toolbar>
|
||||
<vxe-table
|
||||
row-id="id"
|
||||
ref="xTable"
|
||||
:data="pagination.records"
|
||||
:loading="loading"
|
||||
:sort-config="{ remote: true, trigger: 'cell' }"
|
||||
@sort-change="sortChange"
|
||||
>
|
||||
<vxe-column type="seq" title="序号" width="60" />
|
||||
<vxe-column field="id" title="钱包ID" width="170" />
|
||||
<vxe-column field="userId" title="用户ID" />
|
||||
<vxe-column field="name" title="钱包名称" />
|
||||
<vxe-column field="balance" title="余额(分)" sortable />
|
||||
<vxe-column field="status" title="异步支付方式">
|
||||
<template #default="{ row }">
|
||||
<a-tag>{{ dictConvert('WalletStatus', row.status) || '无' }}</a-tag>
|
||||
</template>
|
||||
</vxe-column>
|
||||
<vxe-column field="createTime" title="创建时间" sortable />
|
||||
<vxe-column fixed="right" width="200" :showOverflow="false" title="操作">
|
||||
<template #default="{ row }">
|
||||
<a-link @click="show(row)">查看</a-link>
|
||||
<a-divider type="vertical" />
|
||||
<a-link @click="showChannel(row)">充值</a-link>
|
||||
<a-divider type="vertical" />
|
||||
<a-link @click="showChannel(row)">扣减</a-link>
|
||||
<a-divider type="vertical" />
|
||||
<a-link @click="showChannel(row)">流水</a-link>
|
||||
</template>
|
||||
</vxe-column>
|
||||
</vxe-table>
|
||||
<vxe-pager
|
||||
size="medium"
|
||||
:loading="loading"
|
||||
:current-page="pagination.current"
|
||||
:page-size="pagination.size"
|
||||
:total="pagination.total"
|
||||
@page-change="handleTableChange"
|
||||
/>
|
||||
</div>
|
||||
<create-wallet-model ref="createWalletModel" @ok="queryPage" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted } from 'vue'
|
||||
import { $ref } from 'vue/macros'
|
||||
import { page } from './Wallet.api'
|
||||
import useTablePage from '/@/hooks/bootx/useTablePage'
|
||||
import BQuery from '/@/components/Bootx/Query/BQuery.vue'
|
||||
import { useMessage } from '/@/hooks/web/useMessage'
|
||||
import { QueryField, STRING } from '/@/components/Bootx/Query/Query'
|
||||
import { useDict } from '/@/hooks/bootx/useDict'
|
||||
import { VxeTableInstance, VxeToolbarInstance, VxePager, VxeTable, VxeToolbar } from 'vxe-table'
|
||||
import ALink from '/@/components/Link/Link.vue'
|
||||
import CreateWalletModel from './CreateWalletModel.vue'
|
||||
|
||||
// 使用hooks
|
||||
const { handleTableChange, pageQueryResHandel, sortChange, resetQueryParams, pagination, pages, sortParam, model, loading } =
|
||||
useTablePage(queryPage)
|
||||
const { notification, createMessage, createConfirm } = useMessage()
|
||||
const { dictConvert, dictDropDown } = useDict()
|
||||
|
||||
// 查询条件
|
||||
const fields = computed(() => {
|
||||
return [
|
||||
{ field: 'walletId', type: STRING, name: '钱包ID', placeholder: '请输入完整钱包ID' },
|
||||
{ field: 'userId', type: STRING, name: '用户ID', placeholder: '请输入完整用户ID' },
|
||||
] as QueryField[]
|
||||
})
|
||||
|
||||
let createWalletModel = $ref<any>()
|
||||
|
||||
const xTable = $ref<VxeTableInstance>()
|
||||
const xToolbar = $ref<VxeToolbarInstance>()
|
||||
|
||||
onMounted(() => {
|
||||
vxeBind()
|
||||
queryPage()
|
||||
})
|
||||
function vxeBind() {
|
||||
xTable?.connect(xToolbar as VxeToolbarInstance)
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
function queryPage() {
|
||||
loading.value = true
|
||||
page({
|
||||
...model.queryParam,
|
||||
...sortParam,
|
||||
...pages,
|
||||
}).then(({ data }) => {
|
||||
pageQueryResHandel(data)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 开通钱包
|
||||
*/
|
||||
function create() {
|
||||
createWalletModel.init()
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
function show(record) {}
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
function showChannel(record) {}
|
||||
</script>
|
||||
|
||||
<style scoped lang="less"></style>
|
@@ -23,6 +23,7 @@ export function getOrder(id) {
|
||||
params: { id },
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单扩展信息
|
||||
*/
|
||||
|
@@ -32,7 +32,7 @@
|
||||
import { $ref } from 'vue/macros'
|
||||
import useFormEdit from '/@/hooks/bootx/useFormEdit'
|
||||
import { useDict } from '/@/hooks/bootx/useDict'
|
||||
import { refund, RefundableInfo } from '../refund/RefundOrder.api'
|
||||
import { refund } from '../refund/RefundOrder.api'
|
||||
import BasicModal from '/@/components/Modal/src/BasicModal.vue'
|
||||
import { FormInstance } from 'ant-design-vue/lib/form'
|
||||
import { useMessage } from '/@/hooks/web/useMessage'
|
||||
|
Reference in New Issue
Block a user