feat 钱包/储值卡管理

This commit is contained in:
bootx
2024-02-18 21:36:49 +08:00
parent f0d3165ebd
commit 20de0062d6
13 changed files with 1096 additions and 11 deletions

View File

@@ -0,0 +1,53 @@
import { defHttp } from '/@/utils/http/axios'
import { Result, PageResult } from '/#/axios'
import { BaseEntity } from '/#/web'
/**
* 导入
*/
export function voucherImport(params) {
return defHttp.post<Result>({
url: '/voucher/import',
data: params,
})
}
/**
* 分页
*/
export function page(params) {
return defHttp.get<Result<PageResult<Voucher[]>>>({
url: '/voucher/page',
params,
})
}
/**
* 查询详情
*/
export function get(id) {
return defHttp.get<Result<Voucher>>({
url: '/voucher/findById',
params: { id },
})
}
/**
* 储值卡
*/
export interface Voucher extends BaseEntity {
// 卡号
cardNo?: string
// 面值
faceValue?: number
// 余额
balance?: string
// 是否长期有效
enduring?: boolean
// 开始时间
startTime?: string
// 结束时间
endTime?: string
// 状态
status?: string
}

View File

@@ -0,0 +1,146 @@
<template>
<basic-modal
title="储值卡生成"
v-bind="$attrs"
:loading="confirmLoading"
:width="modalWidth"
:visible="visible"
:mask-closable="false"
@cancel="handleCancel"
>
<a-form
class="small-from-item"
ref="formRef"
:model="form"
:rules="rules"
:validate-trigger="['blur', 'change']"
:label-col="labelCol"
:wrapper-col="wrapperCol"
>
<a-form-item label="卡号" name="cardNo">
<a-input v-model:value="form.cardNo" placeholder="输入储值卡卡号" />
</a-form-item>
<a-form-item label="面值(分)" name="faceValue">
<a-input-number
:precision="0"
:max="9999999"
:min="1"
v-model:value="form.faceValue"
placeholder="输入储值卡面值(分)"
style="width: 100%"
/>
</a-form-item>
<a-form-item label="余额(分)" name="balance">
<a-input-number
:precision="0"
:max="form.faceValue"
:min="1"
v-model:value="form.balance"
placeholder="输入储值卡面值(分)"
style="width: 100%"
/>
</a-form-item>
<a-form-item label="有效期" name="enduring">
<a-switch checkedChildren="长期" unCheckedChildren="期限" v-model:checked="form.enduring" />
</a-form-item>
<a-form-item label="有效期" name="enduring" v-if="!form.enduring">
<a-range-picker valueFormat="YYYY-MM-DD" @change="changeTime" />
</a-form-item>
<a-form-item label="默认状态" name="status">
<a-radio-group v-model:value="form.status">
<a-radio :value="VoucherEnum.STATUS_NORMAL">启用</a-radio>
<a-radio :value="VoucherEnum.STATUS_FORBIDDEN">停用</a-radio>
</a-radio-group>
</a-form-item>
</a-form>
<template #footer>
<a-button key="cancel" @click="handleCancel">取消</a-button>
<a-button key="forward" :loading="confirmLoading" type="primary" @click="handleOk">提交</a-button>
</template>
</basic-modal>
</template>
<script setup lang="ts">
import useFormEdit from '/@/hooks/bootx/useFormEdit'
import { useMessage } from '/@/hooks/web/useMessage'
import { $ref } from 'vue/macros'
import { FormInstance, Rule } from 'ant-design-vue/lib/form'
import { computed, nextTick } from 'vue'
import BasicModal from '/@/components/Modal/src/BasicModal.vue'
import { VoucherEnum } from '/@/enums/payment/voucherEnum'
import { voucherImport } from '/@/views/payment/channel/voucher/manager/Voucher.api'
const { handleCancel, labelCol, wrapperCol, modalWidth, title, confirmLoading, visible, editable, showable, formEditType } = useFormEdit()
const { createMessage } = useMessage()
// 表单
const formRef = $ref<FormInstance>()
const form = $ref({
faceValue: 2000,
balance: 2000,
enduring: true,
dataTime: null,
startTime: null,
endTime: null,
status: VoucherEnum.STATUS_NORMAL,
})
const rules = computed<Record<string, Rule[]>>(() => {
return {
cardNo: [{ required: true, message: '请输入储值卡卡号' }],
faceValue: [{ required: true, message: '请输入储值卡的面值' }],
balance: [{ required: true, message: '请输入储值卡的余额' }],
enduring: [{ required: true, message: '请选择储值卡有效期类型' }],
dataTime: [{ required: form.enduring, message: '请选择有效时间范围' }],
status: [{ required: true, message: '请选择默认状态' }],
}
})
const emits = defineEmits(['ok'])
/**
* 初始化
*/
function init() {
visible.value = true
resetForm()
confirmLoading.value = false
}
/**
* 时间范围变动
*/
function changeTime(_, times) {
form.startTime = (times[0] + ' 00:00:00') as any
form.endTime = (times[1] + ' 23:59:59') as any
}
/**
* 生成储值卡
*/
function handleOk() {
formRef?.validate().then(async () => {
confirmLoading.value = true
form.dataTime = null
if (form.enduring) {
form.startTime = null
form.endTime = null
}
await voucherImport(form)
visible.value = false
confirmLoading.value = false
emits('ok')
})
}
// 重置表单
function resetForm() {
nextTick(() => {
formRef?.resetFields()
})
}
defineExpose({ init })
</script>
<style scoped lang="less"></style>

View File

@@ -0,0 +1,101 @@
<template>
<basic-modal
title="查看"
v-bind="$attrs"
:loading="confirmLoading"
:width="modalWidth"
:visible="visible"
:mask-closable="showable"
@cancel="handleCancel"
>
<a-spin :spinning="confirmLoading">
<a-descriptions bordered title="" :column="{ md: 1, sm: 1, xs: 1 }">
<a-descriptions-item label="钱包ID">
{{ voucher.id }}
</a-descriptions-item>
<a-descriptions-item label="卡号">
{{ voucher.cardNo }}
</a-descriptions-item>
<a-descriptions-item label="余额">
{{ voucher.balance }}
</a-descriptions-item>
<a-descriptions-item label="余额">
{{ voucher.balance }}
</a-descriptions-item>
<a-descriptions-item label="余额(分)">
{{ voucher.balance }}
</a-descriptions-item>
<a-descriptions-item label="长期有效">
<a-tag>{{ voucher.enduring ? '长期' : '期限' }}</a-tag>
</a-descriptions-item>
<template v-if="!voucher.enduring">
<a-descriptions-item label="开始时间">
{{ voucher.startTime }}
</a-descriptions-item>
<a-descriptions-item label="结束时间">
{{ voucher.endTime }}
</a-descriptions-item>
</template>
<a-descriptions-item label="状态">
<a-tag>{{ dictConvert('VoucherStatus', voucher.status) }}</a-tag>
</a-descriptions-item>
<a-descriptions-item label="导入时间">
{{ voucher.createTime }}
</a-descriptions-item>
</a-descriptions>
</a-spin>
<template #footer>
<a-button key="cancel" @click="handleCancel">取消</a-button>
</template>
</basic-modal>
</template>
<script setup lang="ts">
import { get, Voucher } from './Voucher.api'
import { $ref } from 'vue/macros'
import { BasicModal } from '/@/components/Modal'
import useFormEdit from '/@/hooks/bootx/useFormEdit'
import { useDict } from '/@/hooks/bootx/useDict'
const {
initFormEditType,
handleCancel,
search,
labelCol,
wrapperCol,
modalWidth,
title,
confirmLoading,
visible,
editable,
showable,
formEditType,
} = useFormEdit()
const { dictConvert } = useDict()
let loading = $ref(false)
let voucher = $ref<Voucher>({})
/**
* 入口
*/
function init(record: Voucher) {
visible.value = true
voucher = record
initData(record.id as string)
}
/**
* 初始化数据
*/
async function initData(voucherId) {
loading = true
const { data } = await get(voucherId)
loading = false
voucher = data
}
defineExpose({ init })
</script>
<style scoped lang="less"></style>

View File

@@ -0,0 +1,141 @@
<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="importCard">导入储值卡</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="cardNo" title="卡号" />
<vxe-column field="faceValue" title="面值(分)" sortable />
<vxe-column field="balance" title="余额(分)" sortable />
<vxe-column field="enduring" title="是否长期有效">
<template #default="{ row }">
<a-tag>{{ row.enduring ? '长期' : '期限' }}</a-tag>
</template>
</vxe-column>
<vxe-column field="startTime" title="开始时间" sortable />
<vxe-column field="endTime" title="结束时间" sortable />
<vxe-column field="status" title="状态">
<template #default="{ row }">
<a-tag>{{ dictConvert('VoucherStatus', row.status) || '无' }}</a-tag>
</template>
</vxe-column>
<vxe-column field="createTime" title="创建时间" sortable />
<vxe-column fixed="right" width="100" :showOverflow="false" title="操作">
<template #default="{ row }">
<a-link @click="show(row)">查看</a-link>
<a-divider type="vertical" />
<a-link @click="showRecord(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>
<voucher-import-model ref="voucherImportModel" @ok="queryPage" />
<voucher-record-list ref="voucherRecordList" />
<voucher-info ref="voucherInfo" />
</div>
</template>
<script setup lang="ts">
import { computed, onMounted } from 'vue'
import { $ref } from 'vue/macros'
import { page } from './Voucher.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 VoucherImportModel from './VoucherImportModel.vue'
import VoucherInfo from './VoucherInfo.vue'
import VoucherRecordList from '/@/views/payment/channel/voucher/record/VoucherRecordList.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[]
})
const voucherImportModel = $ref<any>()
const voucherRecordList = $ref<any>()
const voucherInfo = $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 importCard() {
voucherImportModel.init()
}
/**
* 查看
*/
function show(record) {
voucherInfo.init(record)
}
/**
* 查看记录
*/
function showRecord(record) {
voucherRecordList.init(record)
}
</script>
<style scoped lang="less"></style>

View File

@@ -0,0 +1,43 @@
import { defHttp } from '/@/utils/http/axios'
import { Result, PageResult } from '/#/axios'
import { BaseEntity } from '/#/web'
/**
* 分页
*/
export function page(params) {
return defHttp.get<Result<PageResult<VoucherRecord>>>({
url: '/voucher/record/page',
params,
})
}
/**
* 获取详情
*/
export function get(id) {
return defHttp.get<Result<VoucherRecord>>({
url: '/voucher/record/findById',
params: { id },
})
}
/**
* 钱包记录
*/
export interface VoucherRecord extends BaseEntity {
// 储值卡 id
voucherId?: string
// 业务类型
type?: string
// 金额
amount?: string
// 变动之前的金额
oldAmount?: string
// 变动之后的金额
newAmount?: string
// 交易订单号
orderId?: string
// 终端ip
ip?: string
}

View File

@@ -0,0 +1,95 @@
<template>
<basic-drawer forceRender v-bind="$attrs" title="储值卡记录" width="60%" :visible="visible" @close="visible = false">
<vxe-toolbar ref="xToolbar" custom :refresh="{ queryMethod: queryPage }" />
<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="type" title="本地订单ID" min-width="170">
<template #default="{ row }">
<a-tag>{{ dictConvert('WalletRecordType', row.type) }}</a-tag>
</template>
</vxe-column>
<vxe-column field="amount" title="金额" />
<vxe-column field="oldAmount" title="变动之前的金额" />
<vxe-column field="newAmount" title="变动之后的金额" />
<vxe-column field="createTime" title="记录时间" sortable />
</vxe-table>
<vxe-pager
size="medium"
:loading="loading"
:current-page="pagination.current"
:page-size="pagination.size"
:total="pagination.total"
@page-change="handleTableChange"
/>
</basic-drawer>
</template>
<script setup lang="ts">
import { computed, onMounted } from 'vue'
import { $ref } from 'vue/macros'
import { page } from './VoucherRecord.api'
import useTablePage from '/@/hooks/bootx/useTablePage'
import { VxeTable, VxeTableInstance, VxeToolbarInstance } from 'vxe-table'
import { useMessage } from '/@/hooks/web/useMessage'
import { useDict } from '/@/hooks/bootx/useDict'
import BasicDrawer from '/@/components/Drawer/src/BasicDrawer.vue'
import { Voucher } from '../manager/Voucher.api'
// 使用hooks
const { handleTableChange, pageQueryResHandel, resetQueryParams, pagination, sortChange, sortParam, pages, model, loading } =
useTablePage(queryPage)
const { notification, createMessage, createConfirm } = useMessage()
const { dictConvert, dictDropDown } = useDict()
let visible = $ref<boolean>(false)
let voucher = $ref<Voucher>({})
const xTable = $ref<VxeTableInstance>()
const xToolbar = $ref<VxeToolbarInstance>()
onMounted(() => {
vxeBind()
})
/**
* 绑定
*/
function vxeBind() {
xTable?.connect(xToolbar as VxeToolbarInstance)
}
/**
* 初始化
*/
function init(record: Voucher) {
visible = true
voucher = record
queryPage()
}
/**
* 分页查询
*/
function queryPage() {
loading.value = true
page({
...model.queryParam,
...pages,
...sortParam,
voucherId: voucher.id,
}).then(({ data }) => {
pageQueryResHandel(data)
})
return Promise.resolve()
}
defineExpose({ init })
</script>
<style scoped lang="less"></style>

View File

@@ -0,0 +1,126 @@
<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 label="钱包名称" name="name">
{{ wallet.name }}
</a-form-item>
<a-form-item label="余额(分)" name="balance">
{{ wallet.balance }}
</a-form-item>
<a-form-item label="扣减金额(分)" name="amount">
<a-input-number :min="1" :precision="0" v-model:value="form.amount" />
</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 { deduct, get, Wallet } from './Wallet.api'
import loading from '/@/directives/loading'
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 wallet = $ref<Wallet>({})
let form = $ref({
amount: 1,
})
const rules = {
amount: [{ required: true, message: '扣减金额不能为空' }],
} as Record<string, Rule[]>
const emits = defineEmits(['ok'])
/**
* 入口
*/
function init(walletId: string) {
resetForm()
visible.value = true
initData(walletId)
}
/**
* 初始化数据
*/
async function initData(walletId: string) {
confirmLoading.value = true
const { data } = await get(walletId)
confirmLoading.value = false
wallet = data
}
/**
* 扣减余额
*/
function handleOk() {
formRef?.validate().then(() => {
createConfirm({
iconType: 'warning',
title: '警告',
content: '确实扣减钱包余额!',
onOk: async () => {
confirmLoading.value = true
const params = {
...form,
walletId: wallet?.id,
}
await deduct(params)
confirmLoading.value = false
visible.value = false
emits('ok')
},
})
})
}
/**
* 重置表单
*/
function resetForm() {
nextTick(() => {
formRef?.resetFields()
})
}
defineExpose({ init })
</script>
<style scoped lang="less"></style>

View File

@@ -0,0 +1,87 @@
<template>
<basic-modal
title="查看"
v-bind="$attrs"
:loading="confirmLoading"
:width="modalWidth"
:visible="visible"
:mask-closable="showable"
@cancel="handleCancel"
>
<a-spin :spinning="confirmLoading">
<a-descriptions bordered title="" :column="{ md: 1, sm: 1, xs: 1 }">
<a-descriptions-item label="钱包ID">
{{ wallet.id }}
</a-descriptions-item>
<a-descriptions-item label="用户ID">
{{ wallet.userId }}
</a-descriptions-item>
<a-descriptions-item label="钱包名称">
{{ wallet.name }}
</a-descriptions-item>
<a-descriptions-item label="余额(分)">
{{ wallet.balance }}
</a-descriptions-item>
<a-descriptions-item label="状态">
<a-tag>{{ dictConvert('WalletStatus', wallet.status) }}</a-tag>
</a-descriptions-item>
<a-descriptions-item label="创建时间">
{{ wallet.createTime }}
</a-descriptions-item>
</a-descriptions>
</a-spin>
<template #footer>
<a-button key="cancel" @click="handleCancel">取消</a-button>
</template>
</basic-modal>
</template>
<script setup lang="ts">
import { get, Wallet } from './Wallet.api'
import { $ref } from 'vue/macros'
import { BasicModal } from '/@/components/Modal'
import useFormEdit from '/@/hooks/bootx/useFormEdit'
import { useDict } from '/@/hooks/bootx/useDict'
const {
initFormEditType,
handleCancel,
search,
labelCol,
wrapperCol,
modalWidth,
title,
confirmLoading,
visible,
editable,
showable,
formEditType,
} = useFormEdit()
const { dictConvert } = useDict()
let loading = $ref(false)
let wallet = $ref<Wallet>({})
/**
* 入口
*/
function init(record: Wallet) {
visible.value = true
wallet = record
initData(record.id as string)
}
/**
* 初始化数据
*/
async function initData(walletId: string) {
loading = true
const { data } = await get(walletId)
loading = false
wallet = data
}
defineExpose({ init })
</script>
<style scoped lang="less"></style>

View File

@@ -22,7 +22,7 @@
<vxe-column field="userId" title="用户ID" />
<vxe-column field="name" title="钱包名称" />
<vxe-column field="balance" title="余额(分)" sortable />
<vxe-column field="status" title="异步支付方式">
<vxe-column field="status" title="状态">
<template #default="{ row }">
<a-tag>{{ dictConvert('WalletStatus', row.status) || '无' }}</a-tag>
</template>
@@ -32,11 +32,11 @@
<template #default="{ row }">
<a-link @click="show(row)">查看</a-link>
<a-divider type="vertical" />
<a-link @click="showChannel(row)">充值</a-link>
<a-link @click="showRecharge(row)">充值</a-link>
<a-divider type="vertical" />
<a-link @click="showChannel(row)">扣减</a-link>
<a-link @click="showDeduction(row)">扣减</a-link>
<a-divider type="vertical" />
<a-link @click="showChannel(row)">流水</a-link>
<a-link @click="showRecord(row)">流水</a-link>
</template>
</vxe-column>
</vxe-table>
@@ -49,7 +49,11 @@
@page-change="handleTableChange"
/>
</div>
<create-wallet-model ref="createWalletModel" @ok="queryPage" />
<wallet-info ref="walletInfo" />
<wallet-create-model ref="walletCreateModel" @ok="queryPage" />
<wallet-deduct-model ref="walletDeductModel" @ok="queryPage" />
<wallet-recharge-model ref="walletRechargeModel" @ok="queryPage" />
<wallet-record-list ref="walletRecordList" />
</div>
</template>
@@ -64,7 +68,11 @@
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'
import WalletCreateModel from './WalletCreateModel.vue'
import WalletRecordList from '../record/WalletRecordList.vue'
import WalletRechargeModel from './WalletRechargeModel.vue'
import WalletDeductModel from './WalletDeductModel.vue'
import WalletInfo from './WalletInfo.vue'
// 使用hooks
const { handleTableChange, pageQueryResHandel, sortChange, resetQueryParams, pagination, pages, sortParam, model, loading } =
@@ -80,7 +88,11 @@
] as QueryField[]
})
let createWalletModel = $ref<any>()
let walletInfo = $ref<any>()
let walletCreateModel = $ref<any>()
let walletDeductModel = $ref<any>()
let walletRechargeModel = $ref<any>()
let walletRecordList = $ref<any>()
const xTable = $ref<VxeTableInstance>()
const xToolbar = $ref<VxeToolbarInstance>()
@@ -111,17 +123,35 @@
* 开通钱包
*/
function create() {
createWalletModel.init()
walletCreateModel.init()
}
/**
* 查看
*/
function show(record) {}
function show(record) {
walletInfo.init(record)
}
/**
* 查看
* 充值
*/
function showChannel(record) {}
function showRecharge(record) {
walletRechargeModel.init(record.id)
}
/**
* 扣减
*/
function showDeduction(record) {
walletDeductModel.init(record.id)
}
/**
* 流水
*/
function showRecord(record) {
walletRecordList.init(record)
}
</script>
<style scoped lang="less"></style>

View File

@@ -0,0 +1,125 @@
<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 label="钱包名称" name="name">
{{ wallet.name }}
</a-form-item>
<a-form-item label="余额(分)" name="balance">
{{ wallet.balance }}
</a-form-item>
<a-form-item label="充值金额(分)" name="amount">
<a-input-number :min="1" :precision="0" v-model:value="form.amount" />
</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 { get, recharge, Wallet } from './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 wallet = $ref<Wallet>({})
let form = $ref({
amount: 1,
})
const rules = {
amount: [{ required: true, message: '充值金额不能为空' }],
} as Record<string, Rule[]>
const emits = defineEmits(['ok'])
/**
* 入口
*/
function init(walletId: string) {
resetForm()
visible.value = true
initData(walletId)
}
/**
* 初始化数据
*/
async function initData(walletId: string) {
confirmLoading.value = true
const { data } = await get(walletId)
confirmLoading.value = false
wallet = data
}
/**
* 充值
*/
function handleOk() {
formRef?.validate().then(() => {
createConfirm({
iconType: 'warning',
title: '警告',
content: '确实对钱包进行充值!',
onOk: async () => {
confirmLoading.value = true
const params = {
...form,
walletId: wallet?.id,
}
await recharge(params)
confirmLoading.value = false
visible.value = false
emits('ok')
},
})
})
}
/**
* 重置表单
*/
function resetForm() {
nextTick(() => {
formRef?.resetFields()
})
}
defineExpose({ init })
</script>
<style scoped lang="less"></style>

View File

@@ -0,0 +1,43 @@
import { defHttp } from '/@/utils/http/axios'
import { Result, PageResult } from '/#/axios'
import { BaseEntity } from '/#/web'
/**
* 分页
*/
export function page(params) {
return defHttp.get<Result<PageResult<WalletRecord>>>({
url: '/wallet/record/page',
params,
})
}
/**
* 获取详情
*/
export function get(id) {
return defHttp.get<Result<WalletRecord>>({
url: '/wallet/record/findById',
params: { id },
})
}
/**
* 钱包记录
*/
export interface WalletRecord extends BaseEntity {
// 钱包id
walletId?: string
// 业务类型
type?: string
// 金额
amount?: string
// 变动之前的金额
oldAmount?: string
// 变动之后的金额
newAmount?: string
// 交易订单号
orderId?: string
// 终端ip
ip?: string
}

View File

@@ -0,0 +1,95 @@
<template>
<basic-drawer forceRender v-bind="$attrs" title="钱包记录" width="60%" :visible="visible" @close="visible = false">
<vxe-toolbar ref="xToolbar" custom :refresh="{ queryMethod: queryPage }" />
<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="type" title="本地订单ID" min-width="170">
<template #default="{ row }">
<a-tag>{{ dictConvert('WalletRecordType', row.type) }}</a-tag>
</template>
</vxe-column>
<vxe-column field="amount" title="金额" />
<vxe-column field="oldAmount" title="变动之前的金额" />
<vxe-column field="newAmount" title="变动之后的金额" />
<vxe-column field="createTime" title="记录时间" sortable />
</vxe-table>
<vxe-pager
size="medium"
:loading="loading"
:current-page="pagination.current"
:page-size="pagination.size"
:total="pagination.total"
@page-change="handleTableChange"
/>
</basic-drawer>
</template>
<script setup lang="ts">
import { computed, onMounted } from 'vue'
import { $ref } from 'vue/macros'
import { page, WalletRecord } from './WalletRecord.api'
import useTablePage from '/@/hooks/bootx/useTablePage'
import { VxeTable, VxeTableInstance, VxeToolbarInstance } from 'vxe-table'
import { useMessage } from '/@/hooks/web/useMessage'
import { useDict } from '/@/hooks/bootx/useDict'
import { Wallet } from '/@/views/payment/channel/wallet/manager/Wallet.api'
import BasicDrawer from '/@/components/Drawer/src/BasicDrawer.vue'
// 使用hooks
const { handleTableChange, pageQueryResHandel, resetQueryParams, pagination, sortChange, sortParam, pages, model, loading } =
useTablePage(queryPage)
const { notification, createMessage, createConfirm } = useMessage()
const { dictConvert, dictDropDown } = useDict()
let visible = $ref<boolean>(false)
let wallet = $ref<Wallet>({})
const xTable = $ref<VxeTableInstance>()
const xToolbar = $ref<VxeToolbarInstance>()
onMounted(() => {
vxeBind()
})
/**
* 绑定
*/
function vxeBind() {
xTable?.connect(xToolbar as VxeToolbarInstance)
}
/**
* 初始化
*/
function init(record: Wallet) {
visible = true
wallet = record
queryPage()
}
/**
* 分页查询
*/
function queryPage() {
loading.value = true
page({
...model.queryParam,
...pages,
...sortParam,
walletId: wallet.id,
}).then(({ data }) => {
pageQueryResHandel(data)
})
return Promise.resolve()
}
defineExpose({ init })
</script>
<style scoped lang="less"></style>