123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277 |
- import Content from '@/sheep/layouts/content.vue';
- import { SELECT, CRUD } from '@/sheep/request/crud';
- import { request } from '@/sheep/request';
- import i18n from '@/locales';
- // 获取 t 函数
- const { t } = i18n.global;
- // 财务模块公共配置
- const financeConfig = {
- // 币种配置
- currencies: {
- 1: 'BDT',
- },
- // 状态配置
- status: {
- recharge: {
- 1: () => t('modules.recharge.processing'),
- 2: () => t('modules.recharge.success'),
- 3: () => t('modules.recharge.failed'),
- 4: () => t('modules.recharge.timeout'),
- },
- withdraw: {
- 1: () => t('modules.withdraw.processing'),
- 2: () => t('modules.withdraw.approved'),
- 3: () => t('modules.withdraw.rejected'),
- 4: () => t('modules.withdraw.success'),
- 5: () => t('modules.withdraw.failed'),
- 6: () => t('modules.withdraw.timeout'),
- },
- },
- // 账户类型配置
- accountTypes: {
- 1: () => t('modules.finance.walletBalance'),
- 2: () => t('modules.finance.accountEarnings'),
- },
- // 操作日志类型配置
- logTypes: {
- 1: () => t('modules.finance.submitRechargeOrder'),
- 2: () => t('modules.finance.rechargeCallThirdParty'),
- 3: () => t('modules.finance.rechargeCallbackSuccess'),
- 4: () => t('modules.finance.submitWithdrawApplication'),
- 5: () => t('modules.finance.withdrawApproved'),
- 6: () => t('modules.finance.withdrawRejected'),
- 7: () => t('modules.finance.withdrawCallThirdParty'),
- 8: () => t('modules.finance.withdrawCallbackSuccess'),
- },
- };
- // 公共工具函数
- const financeUtils = {
- // 获取币种文本
- getCurrencyText: (currency) => financeConfig.currencies[currency] || 'BDT',
- // 获取充值状态文本
- getRechargeStatusText: (status) => {
- const statusFn = financeConfig.status.recharge[status];
- return statusFn ? statusFn() : t('common.unknown');
- },
- // 获取提现状态文本
- getWithdrawStatusText: (status) => {
- const statusFn = financeConfig.status.withdraw[status];
- return statusFn ? statusFn() : t('common.unknown');
- },
- // 获取账户类型文本
- getAccountTypeText: (accountType) => {
- const typeFn = financeConfig.accountTypes[accountType];
- return typeFn ? typeFn() : t('common.unknown');
- },
- // 获取操作日志类型文本
- getLogTypeText: (type) => {
- const typeFn = financeConfig.logTypes[type];
- return typeFn ? typeFn() : t('modules.finance.unknownOperation');
- },
- // 获取状态类型(用于标签颜色)
- getStatusType: (status, type = 'withdraw') => {
- if (type === 'recharge') {
- const statusMap = {
- 1: 'warning', // 处理中
- 2: 'success', // 充值成功
- 3: 'danger', // 充值失败
- 4: 'info', // 超时取消
- };
- return statusMap[status] || 'info';
- } else {
- const statusMap = {
- 1: 'warning', // 处理中
- 2: 'success', // 审核通过
- 3: 'danger', // 审核拒绝
- 4: 'success', // 提现成功
- 5: 'danger', // 提现失败
- 6: 'info', // 超时取消
- };
- return statusMap[status] || 'info';
- }
- },
- // 获取渠道类型(用于标签颜色)
- getChannelType: (channel) => {
- const channelMap = {
- 1: 'info', // TKPAY
- 2: 'success', // 3QPAY
- };
- return channelMap[channel] || 'info';
- },
- // 佣金相关状态处理函数
- getCommissionStatusText: (status) => {
- const statusMap = {
- 1: () => t('modules.finance.unsettled'),
- 2: () => t('modules.finance.settled'),
- };
- const statusFn = statusMap[status];
- return statusFn ? statusFn() : t('common.unknown');
- },
- getCommissionStatusType: (status) => {
- const statusMap = {
- 1: 'warning', // 未结算
- 2: 'success', // 已结算
- };
- return statusMap[status] || 'info';
- },
- getBizTypeText: (bizType) => {
- const typeMap = {
- 1001: () => t('modules.finance.recharge'),
- 2001: () => t('modules.finance.withdraw'),
- 3001: () => t('modules.finance.groupPayment'),
- 3002: () => t('modules.finance.joinPayment'),
- 4001: () => t('modules.finance.incompleteRefund'),
- 4002: () => t('modules.finance.completeRefund'),
- 5001: () => t('modules.finance.groupRedPacketEarnings'),
- 5002: () => t('modules.finance.joinRedPacketEarnings'),
- 5003: () => t('modules.finance.signInRedPacketEarnings'),
- 5004: () => t('modules.finance.subordinateRedPacketCommission'),
- 5005: () => t('modules.finance.subSubordinateRedPacketCommission'),
- 6001: () => t('modules.finance.rechargeRebate'),
- 7001: () => t('modules.finance.withdrawalFee'),
- };
- const typeFn = typeMap[bizType];
- return typeFn ? typeFn() : t('modules.finance.unknownType');
- },
- // 格式化金额,保留两位小数
- formatAmount: (amount) => {
- if (amount === null || amount === undefined) return '0.00';
- return Number(amount || 0).toFixed(2);
- },
- // 格式化金额并添加货币符号
- formatCurrency: (amount, currency = 'BDT') => {
- const formattedAmount = financeUtils.formatAmount(amount);
- return `৳${formattedAmount}`;
- },
- };
- const route = {
- path: 'finance',
- name: 'shop.admin.finance',
- component: Content,
- meta: {
- title: '财务',
- },
- children: [
- {
- path: 'commission',
- name: 'shop.admin.finance.commission',
- component: () => import('@/app/shop/admin/finance/commission/index.vue'),
- meta: {
- title: '佣金管理',
- },
- },
- {
- path: 'recharge',
- name: 'shop.admin.finance.recharge',
- component: () => import('@/app/shop/admin/finance/recharge/index.vue'),
- meta: {
- title: '充值管理',
- },
- },
- {
- path: 'withdraw',
- name: 'shop.admin.finance.withdraw',
- component: () => import('@/app/shop/admin/finance/withdraw/index.vue'),
- meta: {
- title: '提现管理',
- },
- },
- {
- path: 'report',
- name: 'shop.admin.finance.report',
- component: () => import('@/app/shop/admin/finance/report/index.vue'),
- meta: {
- title: '财务报表',
- },
- },
- ],
- };
- const api = {
- // 佣金相关 API
- commission: {
- ...CRUD('/cif/red/envelope', ['list', 'detail', 'report']),
- // 获取佣金类型枚举
- getTypes: () =>
- request({
- url: '/cif/api/user/getEnum',
- method: 'GET',
- params: { id: 5 },
- }),
- },
- // 充值相关 API
- recharge: {
- ...CRUD('cif/recharge/record', ['list', 'detail', 'report']),
- recordDetail: (id) =>
- request({
- url: `cif/recharge/record/detail`,
- method: 'GET',
- params: { id },
- }),
- select: (params) => SELECT('shop/admin/finance/recharge', params),
- confirm: (id) => ({
- error: 0,
- msg: t('modules.finance.confirmSuccess'),
- data: null,
- }),
- batchConfirm: (ids) => ({
- error: 0,
- msg: t('modules.finance.batchConfirmSuccess'),
- data: null,
- }),
- },
- // 提现相关 API
- withdraw: {
- ...CRUD('/cif/withdraw/record', ['list', 'detail', 'report']),
- withdrawDetail: (id) =>
- request({
- url: `cif/withdraw/record/detail`,
- method: 'GET',
- params: { id },
- }),
- // 审核接口
- review: (data) =>
- request({
- url: 'cif/withdraw/record/review',
- method: 'POST',
- data,
- }),
- batchApprove: (ids) => ({
- error: 0,
- msg: t('modules.finance.batchApproveSuccess'),
- data: null,
- }),
- batchReject: (ids, data) => ({
- error: 0,
- msg: t('modules.finance.batchRejectSuccess'),
- data: null,
- }),
- },
- // 财务报表相关 API
- report: {
- ...CRUD('/cif/subject', ['list', 'export'], { exportMethod: 'GET' }),
- },
- };
- export { route, api, financeConfig, financeUtils };
|