feat(sdy): 新增分销商订单管理功能

- 添加分销商订单模型定义及API接口- 实现分销商订单导入导出功能- 完善订单编辑页面字段展示和校验逻辑- 调整订单列表页展示字段及操作按钮- 移除三级分销相关字段和功能- 修改订单状态标签文案和样式
- 增加订单删除确认弹窗- 优化导入弹窗组件及上传逻辑
- 调整搜索组件布局并增加导入按钮
- 更新订单详情弹窗标题和结算按钮文案
- 移除订单详情查看功能及相关代码
- 调整表格列配置和数据渲染方式
- 修复未签约订单提示逻辑
- 移除语言参数传递逻辑- 增加新窗口打开链接工具函数引入
This commit is contained in:
2025-10-01 18:48:14 +08:00
parent 52bd53eb70
commit 320a1939b6
18 changed files with 676 additions and 539 deletions

View File

@@ -1,5 +1,5 @@
VITE_APP_NAME=后台管理(开发环境)
#VITE_API_URL=http://127.0.0.1:9200/api
VITE_API_URL=http://127.0.0.1:9200/api
#VITE_SERVER_API_URL=http://127.0.0.1:8000/api

View File

@@ -6,7 +6,6 @@ import {SERVER_API_URL} from '@/config/setting';
import { Company } from '@/api/system/company/model';
import { CmsWebsite } from '@/api/cms/cmsWebsite/model';
import {Menu} from "@/api/system/menu/model";
import {getLang} from "@/utils/common";
/**
* 获取当前登录的用户信息、菜单、权限、角色
@@ -28,9 +27,7 @@ export async function getSiteInfo() {
const res = await request.get<ApiResult<CmsWebsite>>(
'/shop/getShopInfo',
{
params: {
lang: getLang()
}
params: {}
}
);
if (res.data.code === 0 && res.data.data) {

View File

@@ -0,0 +1,120 @@
import request from '@/utils/request';
import type {ApiResult} from '@/api';
import type {ShopDealerOrder, ShopDealerOrderParam} from './model';
import {utils, writeFile} from 'xlsx';
import {message} from 'ant-design-vue';
import {getTenantId} from '@/utils/domain';
import {listShopDealerOrder} from "@/api/shop/shopDealerOrder";
/**
* 导入分销商订单
*/
export async function importSdyDealerOrder(file: File) {
const formData = new FormData();
formData.append('file', file);
const res = await request.post<ApiResult<unknown>>(
'/sdy/sdy-dealer-order/import',
formData
);
if (res.data.code === 0) {
return res.data.message;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 导出分销商订单
*/
export async function exportSdyDealerOrder(params?: ShopDealerOrderParam) {
// 显示导出加载提示
message.loading('正在准备导出数据...', 0);
try {
// 获取数据
const list = await listShopDealerOrder(params);
if (!list || list.length === 0) {
message.destroy();
message.warning('没有数据可以导出');
return;
}
// 构建导出数据
const array: (string | number)[][] = [
[
'订单ID',
'买家用户ID',
'订单总金额',
'一级分销商ID',
'一级佣金',
'二级分销商ID',
'二级佣金',
'三级分销商ID',
'三级佣金',
'订单状态',
'结算状态',
'结算时间',
'创建时间'
]
];
list.forEach((order: ShopDealerOrder) => {
array.push([
order.orderId || '',
order.userId || '',
order.orderPrice || '0',
order.firstUserId || '',
order.firstMoney || '0',
order.secondUserId || '',
order.secondMoney || '0',
order.thirdUserId || '',
order.thirdMoney || '0',
order.isInvalid === 0 ? '有效' : '失效',
order.isSettled === 0 ? '未结算' : '已结算',
order.settleTime ? new Date(order.settleTime).toLocaleString() : '',
order.createTime || ''
]);
});
// 创建工作簿
const sheetName = `shop_dealer_order_${getTenantId()}`;
const workbook = {
SheetNames: [sheetName],
Sheets: {}
};
const sheet = utils.aoa_to_sheet(array);
workbook.Sheets[sheetName] = sheet;
// 设置列宽
sheet['!cols'] = [
{wch: 15}, // 订单ID
{wch: 12}, // 买家用户ID
{wch: 12}, // 订单总金额
{wch: 15}, // 一级分销商ID
{wch: 12}, // 一级佣金
{wch: 15}, // 二级分销商ID
{wch: 12}, // 二级佣金
{wch: 15}, // 三级分销商ID
{wch: 12}, // 三级佣金
{wch: 10}, // 订单状态
{wch: 10}, // 结算状态
{wch: 20}, // 结算时间
{wch: 20} // 创建时间
];
message.destroy();
message.loading('正在生成Excel文件...', 0);
// 延迟写入文件,确保消息提示显示
setTimeout(() => {
writeFile(workbook, `${sheetName}.xlsx`);
message.destroy();
message.success(`成功导出 ${list.length} 条记录`);
}, 1000);
} catch (error: any) {
message.destroy();
message.error(error.message || '导出失败,请重试');
}
}

View File

@@ -0,0 +1,53 @@
import type { PageParam } from '@/api';
/**
* 分销商订单记录表
*/
export interface ShopDealerOrder {
// 主键ID
id?: number;
// 买家用户ID
userId?: number;
// 订单ID
orderId?: number;
// 订单总金额(不含运费)
orderPrice?: string;
// 分销商用户id(一级)
firstUserId?: number;
// 分销商用户id(二级)
secondUserId?: number;
// 分销商用户id(三级)
thirdUserId?: number;
// 分销佣金(一级)
firstMoney?: string;
// 分销佣金(二级)
secondMoney?: string;
// 分销佣金(三级)
thirdMoney?: string;
// 订单是否失效(0未失效 1已失效)
isInvalid?: number;
// 佣金结算(0未结算 1已结算)
isSettled?: number;
// 结算时间
settleTime?: number;
// 商城ID
tenantId?: number;
// 创建时间
createTime?: string;
// 修改时间
updateTime?: string;
}
/**
* 分销商订单记录表搜索条件
*/
export interface ShopDealerOrderParam extends PageParam {
id?: number;
orderId?: number;
orderNo?: string;
productName?: string;
userId?: number;
isInvalid?: number;
isSettled?: number;
keywords?: string;
}

View File

@@ -1,6 +1,9 @@
import request from '@/utils/request';
import type { ApiResult, PageResult } from '@/api';
import type { ShopDealerOrder, ShopDealerOrderParam } from './model';
import { utils, writeFile } from 'xlsx';
import { message } from 'ant-design-vue';
import { getTenantId } from '@/utils/domain';
/**
* 分页查询分销商订单记录表
@@ -103,3 +106,116 @@ export async function getShopDealerOrder(id: number) {
}
return Promise.reject(new Error(res.data.message));
}
/**
* 导入分销商订单
*/
export async function importShopDealerOrder(file: File) {
const formData = new FormData();
formData.append('file', file);
const res = await request.post<ApiResult<unknown>>(
'/shop/shop-dealer-order/import',
formData
);
if (res.data.code === 0) {
return res.data.message;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 导出分销商订单
*/
export async function exportShopDealerOrder(params?: ShopDealerOrderParam) {
// 显示导出加载提示
message.loading('正在准备导出数据...', 0);
try {
// 获取数据
const list = await listShopDealerOrder(params);
if (!list || list.length === 0) {
message.destroy();
message.warning('没有数据可以导出');
return;
}
// 构建导出数据
const array: (string | number)[][] = [
[
'订单ID',
'买家用户ID',
'订单总金额',
'一级分销商ID',
'一级佣金',
'二级分销商ID',
'二级佣金',
'三级分销商ID',
'三级佣金',
'订单状态',
'结算状态',
'结算时间',
'创建时间'
]
];
list.forEach((order: ShopDealerOrder) => {
array.push([
order.orderId || '',
order.userId || '',
order.orderPrice || '0',
order.firstUserId || '',
order.firstMoney || '0',
order.secondUserId || '',
order.secondMoney || '0',
order.thirdUserId || '',
order.thirdMoney || '0',
order.isInvalid === 0 ? '有效' : '失效',
order.isSettled === 0 ? '未结算' : '已结算',
order.settleTime ? new Date(order.settleTime).toLocaleString() : '',
order.createTime || ''
]);
});
// 创建工作簿
const sheetName = `shop_dealer_order_${getTenantId()}`;
const workbook = {
SheetNames: [sheetName],
Sheets: {}
};
const sheet = utils.aoa_to_sheet(array);
workbook.Sheets[sheetName] = sheet;
// 设置列宽
sheet['!cols'] = [
{ wch: 15 }, // 订单ID
{ wch: 12 }, // 买家用户ID
{ wch: 12 }, // 订单总金额
{ wch: 15 }, // 一级分销商ID
{ wch: 12 }, // 一级佣金
{ wch: 15 }, // 二级分销商ID
{ wch: 12 }, // 二级佣金
{ wch: 15 }, // 三级分销商ID
{ wch: 12 }, // 三级佣金
{ wch: 10 }, // 订单状态
{ wch: 10 }, // 结算状态
{ wch: 20 }, // 结算时间
{ wch: 20 } // 创建时间
];
message.destroy();
message.loading('正在生成Excel文件...', 0);
// 延迟写入文件,确保消息提示显示
setTimeout(() => {
writeFile(workbook, `${sheetName}.xlsx`);
message.destroy();
message.success(`成功导出 ${list.length} 条记录`);
}, 1000);
} catch (error: any) {
message.destroy();
message.error(error.message || '导出失败,请重试');
}
}

View File

@@ -8,6 +8,8 @@ export interface ShopDealerOrder {
id?: number;
// 买家用户ID
userId?: number;
// 买家用户昵称
nickname?: string;
// 订单ID
orderId?: number;
// 订单总金额(不含运费)
@@ -24,12 +26,24 @@ export interface ShopDealerOrder {
secondMoney?: string;
// 分销佣金(三级)
thirdMoney?: string;
// 一级分销商昵称
firstNickname?: string;
// 二级分销商昵称
secondNickname?: string;
// 三级分销商昵称
thirdNickname?: string;
// 分销比例
rate?: number;
// 商品单价
price?: string;
// 订单是否失效(0未失效 1已失效)
isInvalid?: number;
// 佣金结算(0未结算 1已结算)
isSettled?: number;
// 结算时间
settleTime?: number;
// 订单备注
comments?: string;
// 商城ID
tenantId?: number;
// 创建时间

View File

@@ -20,6 +20,10 @@ export interface ShopDealerUser {
freezeMoney?: string;
// 累积提现佣金
totalMoney?: string;
// 佣金比例
rate?: string;
// 单价
price?: string;
// 推荐人用户ID
refereeId?: number;
// 成员数量(一级)

View File

@@ -141,7 +141,7 @@ import {
FullscreenExitOutlined
} from '@ant-design/icons-vue';
import {storeToRefs} from 'pinia';
import {copyText, openUrl} from '@/utils/common';
import {copyText, openNew, openUrl} from '@/utils/common';
import {useThemeStore} from '@/store/modules/theme';
import HeaderNotice from './header-notice.vue';
import PasswordModal from './password-modal.vue';

View File

@@ -131,7 +131,6 @@ const { form, resetFields, assignFields } = useFormData<CmsLink>({
name: '',
url: '',
sortNumber: 100,
lang: getLang(),
categoryId: undefined,
comments: undefined
});

View File

@@ -139,11 +139,11 @@ const datasource: DatasourceFunction = ({
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: 'ID',
dataIndex: 'applyId',
key: 'applyId',
title: '用户ID',
dataIndex: 'userId',
key: 'userId',
align: 'center',
width: 80,
width: 90,
fixed: 'left'
},
{
@@ -425,7 +425,7 @@ const customRow = (record: ShopDealerApply) => {
},
// 行双击事件
onDblclick: () => {
// openEdit(record);
openEdit(record);
}
};
};
@@ -438,67 +438,3 @@ export default {
};
</script>
<style lang="less" scoped>
.sys-org-table {
:deep(.ant-table-thead > tr > th) {
background-color: #fafafa;
font-weight: 600;
}
:deep(.ant-table-tbody > tr:hover > td) {
background-color: #f8f9fa;
}
}
.detail-item {
p {
margin: 4px 0;
color: #666;
}
strong {
color: #1890ff;
font-size: 14px;
}
}
.ele-text-primary {
color: #1890ff;
&:hover {
color: #40a9ff;
}
}
.ele-text-info {
color: #13c2c2;
&:hover {
color: #36cfc9;
}
}
.ele-text-success {
color: #52c41a;
&:hover {
color: #73d13d;
}
}
.ele-text-warning {
color: #faad14;
&:hover {
color: #ffc53d;
}
}
.ele-text-danger {
color: #ff4d4f;
&:hover {
color: #ff7875;
}
}
</style>

View File

@@ -0,0 +1,79 @@
<!-- 经销商订单导入弹窗 -->
<template>
<ele-modal
:width="520"
:footer="null"
title="导入分销订单"
:visible="visible"
@update:visible="updateVisible"
>
<a-spin :spinning="loading">
<a-upload-dragger
accept=".xls,.xlsx"
:show-upload-list="false"
:customRequest="doUpload"
style="padding: 24px 0; margin-bottom: 16px"
>
<p class="ant-upload-drag-icon">
<cloud-upload-outlined/>
</p>
<p class="ant-upload-hint">将文件拖到此处或点击上传</p>
</a-upload-dragger>
</a-spin>
</ele-modal>
</template>
<script lang="ts" setup>
import {ref} from 'vue';
import {message} from 'ant-design-vue/es';
import {CloudUploadOutlined} from '@ant-design/icons-vue';
import {importSdyDealerOrder} from "@/api/sdy/sdyDealerOrder";
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
defineProps<{
// 是否打开弹窗
visible: boolean;
}>();
// 导入请求状态
const loading = ref(false);
/* 上传 */
const doUpload = ({file}) => {
if (
![
'application/vnd.ms-excel',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
].includes(file.type)
) {
message.error('只能选择 excel 文件');
return false;
}
if (file.size / 1024 / 1024 > 10) {
message.error('大小不能超过 10MB');
return false;
}
loading.value = true;
importSdyDealerOrder(file)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
return false;
};
/* 更新 visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
</script>

View File

@@ -1,6 +1,5 @@
<!-- 搜索表单 -->
<template>
<div class="search-container">
<div class="flex items-center gap-20">
<!-- 搜索表单 -->
<a-form
:model="searchForm"
@@ -8,23 +7,6 @@
class="search-form"
@finish="handleSearch"
>
<a-form-item label="订单编号">
<a-input
v-model:value="searchForm.orderId"
placeholder="请输入订单编号"
allow-clear
style="width: 160px"
/>
</a-form-item>
<a-form-item label="商品名称">
<a-input
v-model:value="searchForm.productName"
placeholder="请输入商品名称"
allow-clear
style="width: 160px"
/>
</a-form-item>
<a-form-item label="订单状态">
<a-select
@@ -54,7 +36,7 @@
<a-space>
<a-button type="primary" html-type="submit" class="ele-btn-icon">
<template #icon>
<SearchOutlined />
<SearchOutlined/>
</template>
搜索
</a-button>
@@ -64,89 +46,110 @@
</a-space>
</a-form-item>
</a-form>
<!-- 操作按钮 -->
<div class="action-buttons">
<a-space>
<a-button
type="primary"
:disabled="!selection?.length"
@click="batchSettle"
class="ele-btn-icon"
>
<template #icon>
<DollarOutlined />
</template>
批量结算
</a-button>
</a-space>
</div>
<a-divider type="vertical"/>
<a-space>
<!-- <a-button @click="exportData" class="ele-btn-icon">-->
<!-- <template #icon>-->
<!-- <ExportOutlined />-->
<!-- </template>-->
<!-- 导出数据-->
<!-- </a-button>-->
<a-button @click="openImport" class="ele-btn-icon">
<template #icon>
<UploadOutlined/>
</template>
导入数据
</a-button>
<a-button
type="primary"
@click="batchSettle"
class="ele-btn-icon"
>
<template #icon>
<DollarOutlined/>
</template>
批量结算
</a-button>
</a-space>
</div>
<!-- 导入弹窗 -->
<Import v-model:visible="showImport" @done="emit('importDone')"/>
</template>
<script lang="ts" setup>
import { reactive } from 'vue';
import {
SearchOutlined,
DollarOutlined,
ExportOutlined
} from '@ant-design/icons-vue';
import type { ShopDealerOrderParam } from '@/api/shop/shopDealerOrder/model';
import {reactive, ref} from 'vue';
import {
SearchOutlined,
DollarOutlined,
UploadOutlined
} from '@ant-design/icons-vue';
import type {ShopDealerOrderParam} from '@/api/shop/shopDealerOrder/model';
import Import from './Import.vue';
const props = withDefaults(
defineProps<{
// 选中的数据
selection?: any[];
}>(),
{
selection: () => []
const props = withDefaults(
defineProps<{
// 选中的数据
selection?: any[];
}>(),
{
selection: () => []
}
);
const emit = defineEmits<{
(e: 'search', where?: ShopDealerOrderParam): void;
(e: 'batchSettle'): void;
(e: 'export'): void;
(e: 'importDone'): void;
}>();
// 是否显示导入弹窗
const showImport = ref(false);
// 搜索表单
const searchForm = reactive<ShopDealerOrderParam>({
orderId: undefined,
orderNo: '',
productName: '',
isInvalid: undefined,
isSettled: undefined
});
// 搜索
const handleSearch = () => {
const searchParams = {...searchForm};
// 清除空值
Object.keys(searchParams).forEach(key => {
if (searchParams[key] === '' || searchParams[key] === undefined) {
delete searchParams[key];
}
);
const emit = defineEmits<{
(e: 'search', where?: ShopDealerOrderParam): void;
(e: 'batchSettle'): void;
(e: 'export'): void;
}>();
// 搜索表单
const searchForm = reactive<ShopDealerOrderParam>({
orderId: undefined,
orderNo: '',
productName: '',
isInvalid: undefined,
isSettled: undefined
});
emit('search', searchParams);
};
// 搜索
const handleSearch = () => {
const searchParams = { ...searchForm };
// 清除空值
Object.keys(searchParams).forEach(key => {
if (searchParams[key] === '' || searchParams[key] === undefined) {
delete searchParams[key];
}
});
emit('search', searchParams);
};
// 重置搜索
const resetSearch = () => {
Object.keys(searchForm).forEach(key => {
searchForm[key] = key === 'orderId' ? undefined : '';
});
emit('search', {});
};
// 重置搜索
const resetSearch = () => {
Object.keys(searchForm).forEach(key => {
searchForm[key] = key === 'orderId' ? undefined : '';
});
emit('search', {});
};
// 批量结算
const batchSettle = () => {
emit('batchSettle');
};
// 批量结算
const batchSettle = () => {
emit('batchSettle');
};
// 导出数据
const exportData = () => {
emit('export');
};
// 导出数据
const exportData = () => {
emit('export');
};
// 打开导入弹窗
const openImport = () => {
showImport.value = true;
};
</script>
<style lang="less" scoped>

View File

@@ -5,9 +5,10 @@
:visible="visible"
:maskClosable="false"
:maxable="maxable"
:title="isUpdate ? '编辑分销订单记录' : '添加分销订单记录'"
:title="isUpdate ? '分销订单' : '分销订单'"
:body-style="{ paddingBottom: '28px' }"
@update:visible="updateVisible"
:okText="`立即结算`"
@ok="save"
>
<a-form
@@ -19,53 +20,51 @@
>
<!-- 订单基本信息 -->
<a-divider orientation="left">
<span style="color: #1890ff; font-weight: 600;">订单基本信息</span>
<span style="color: #1890ff; font-weight: 600;">基本信息</span>
</a-divider>
<a-row :gutter="16">
<a-col :span="12">
<a-form-item label="买家用户ID" name="userId">
<a-input-number
:min="1"
placeholder="请输入买家用户ID"
v-model:value="form.userId"
style="width: 100%"
/>
<a-form-item label="用户ID" name="userId">
{{ form.userId }}
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="订单ID" name="orderId">
<a-input-number
:min="1"
placeholder="请输入订单ID"
v-model:value="form.orderId"
style="width: 100%"
/>
<a-form-item label="客户名称" name="comments">
{{ form.comments }}
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="费率" name="rate">
{{ form.rate }}
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="结算电量" name="orderPrice">
{{ parseFloat(form.orderPrice || 0).toFixed(2) }}
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="实发金额" name="payPrice">
{{ (form.orderPrice * form.rate * 1000).toFixed(2) }}
</a-form-item>
</a-col>
</a-row>
<a-form-item label="订单总金额" name="orderPrice">
<a-input-number
:min="0"
:precision="2"
placeholder="请输入订单总金额(不含运费)"
v-model:value="form.orderPrice"
style="width: 300px"
>
<template #addonAfter></template>
</a-input-number>
</a-form-item>
<!-- 分销商信息 -->
<a-divider orientation="left">
<span style="color: #1890ff; font-weight: 600;">分销商信息</span>
<span style="color: #1890ff; font-weight: 600;">推荐收益</span>
</a-divider>
<!-- 一级分销商 -->
<div class="dealer-section">
<h4 class="dealer-title">
<a-tag color="red">一级分销商</a-tag>
<a-tag color="red">推荐收益</a-tag>
</h4>
<a-row :gutter="16">
<a-col :span="12">
@@ -97,7 +96,7 @@
<!-- 二级分销商 -->
<div class="dealer-section">
<h4 class="dealer-title">
<a-tag color="orange">二级分销商</a-tag>
<a-tag color="orange">简推收益</a-tag>
</h4>
<a-row :gutter="16">
<a-col :span="12">
@@ -126,62 +125,6 @@
</a-row>
</div>
<!-- 三级分销商 -->
<div class="dealer-section">
<h4 class="dealer-title">
<a-tag color="gold">三级分销商</a-tag>
</h4>
<a-row :gutter="16">
<a-col :span="12">
<a-form-item label="用户ID" name="thirdUserId">
<a-input-number
:min="1"
placeholder="请输入三级分销商用户ID"
v-model:value="form.thirdUserId"
style="width: 100%"
/>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="分销佣金" name="thirdMoney">
<a-input-number
:min="0"
:precision="2"
placeholder="请输入三级分销佣金"
v-model:value="form.thirdMoney"
style="width: 100%"
>
<template #addonAfter></template>
</a-input-number>
</a-form-item>
</a-col>
</a-row>
</div>
<!-- 状态信息 -->
<a-divider orientation="left">
<span style="color: #1890ff; font-weight: 600;">状态信息</span>
</a-divider>
<a-row :gutter="16">
<a-col :span="12">
<a-form-item label="订单状态" name="isInvalid">
<a-radio-group v-model:value="form.isInvalid">
<a-radio :value="0">有效</a-radio>
<a-radio :value="1">失效</a-radio>
</a-radio-group>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="结算状态" name="isSettled">
<a-radio-group v-model:value="form.isSettled">
<a-radio :value="0">未结算</a-radio>
<a-radio :value="1">已结算</a-radio>
</a-radio-group>
</a-form-item>
</a-col>
</a-row>
<a-form-item label="结算时间" name="settleTime" v-if="form.isSettled === 1">
<a-date-picker
v-model:value="form.settleTime"
@@ -238,6 +181,7 @@
const form = reactive<ShopDealerOrder>({
id: undefined,
userId: undefined,
nickname: undefined,
orderId: undefined,
orderPrice: undefined,
firstUserId: undefined,
@@ -246,6 +190,11 @@
firstMoney: undefined,
secondMoney: undefined,
thirdMoney: undefined,
firstNickname: undefined,
secondNickname: undefined,
thirdNickname: undefined,
rate: undefined,
comments: undefined,
isInvalid: 0,
isSettled: 0,
settleTime: undefined,
@@ -261,13 +210,6 @@
// 表单验证规则
const rules = reactive({
userId: [
{
required: true,
message: '请输入买家用户ID',
trigger: 'blur'
}
],
orderId: [
{
required: true,
@@ -275,13 +217,6 @@
trigger: 'blur'
}
],
orderPrice: [
{
required: true,
message: '请输入订单总金额',
trigger: 'blur'
}
],
firstUserId: [
{
validator: (rule: any, value: any) => {
@@ -359,6 +294,10 @@
if (!formRef.value) {
return;
}
if(form.userId == 0){
message.error('未签约');
return;
}
formRef.value
.validate()
.then(() => {

View File

@@ -3,7 +3,7 @@
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="shopDealerOrderId"
row-key="id"
:columns="columns"
:datasource="datasource"
:customRow="customRow"
@@ -15,7 +15,8 @@
@search="reload"
:selection="selection"
@batchSettle="batchSettle"
@export="exportData"
@export="handleExport"
@importDone="reload"
/>
</template>
<template #bodyCell="{ column, record }">
@@ -26,6 +27,26 @@
</div>
</template>
<template v-if="column.key === 'orderPrice'">
{{ parseFloat(record.orderPrice).toFixed(2) }}
</template>
<template v-if="column.key === 'orderPrice1000'">
{{ (record.orderPrice * 1000).toFixed(2) }}
</template>
<template v-if="column.key === 'price'">
{{ (record.price || 0).toFixed(2) }}
</template>
<template v-if="column.key === 'settledPrice'">
{{ (record.orderPrice * record.rate * 1000).toFixed(2) }}
</template>
<template v-if="column.key === 'payPrice'">
{{ (record.orderPrice * record.rate).toFixed(2) }}
</template>
<template v-if="column.key === 'dealerInfo'">
<div class="dealer-info">
<div v-if="record.firstUserId" class="dealer-level">
@@ -44,40 +65,53 @@
</template>
<template v-if="column.key === 'isInvalid'">
<a-tag v-if="record.isInvalid === 0" color="success">有效</a-tag>
<a-tag v-if="record.isInvalid === 1" color="error">失效</a-tag>
<a-tag v-if="record.isInvalid === 0" color="success">已签约</a-tag>
<a-tag v-if="record.isInvalid === 1" color="error" @click="invalidateOrder(record)">未签约</a-tag>
</template>
<template v-if="column.key === 'isSettled'">
<a-tag v-if="record.isSettled === 0" color="processing">未结算</a-tag>
<a-tag v-if="record.isSettled === 0" color="orange">未结算</a-tag>
<a-tag v-if="record.isSettled === 1" color="success">已结算</a-tag>
</template>
<template v-if="column.key === 'createTime'">
<div class="flex flex-col">
<a-tooltip title="创建时间">
<span class="text-gray-500">{{ record.createTime }}</span>
</a-tooltip>
<a-tooltip title="结算时间">
<span class="text-purple-500">{{ record.settleTime }}</span>
</a-tooltip>
</div>
</template>
<template v-if="column.key === 'action'">
<a @click="viewDetail(record)" class="ele-text-info">
<EyeOutlined/>
详情
</a>
<template v-if="record.isSettled === 0 && record.isInvalid === 0">
<a-divider type="vertical"/>
<a @click="settleOrder(record)" class="ele-text-success">
<DollarOutlined/>
结算
</a>
</template>
<template v-if="record.isInvalid === 0">
<a-divider type="vertical"/>
<a-popconfirm
title="确定要标记此订单为失效吗?"
@confirm="invalidateOrder(record)"
placement="topRight"
>
<a class="ele-text-warning">
<CloseOutlined/>
失效
</a>
</a-popconfirm>
</template>
<!-- <template v-if="record.isInvalid === 0">-->
<!-- <a-popconfirm-->
<!-- title="确定要标记此订单为失效吗?"-->
<!-- @confirm="invalidateOrder(record)"-->
<!-- placement="topRight"-->
<!-- >-->
<!-- <a class="text-purple-500">-->
<!-- 验证-->
<!-- </a>-->
<!-- </a-popconfirm>-->
<!-- </template>-->
<a-popconfirm
title="确定要删除吗?"
@confirm="remove(record)"
placement="topRight"
>
<a class="text-red-500">
删除
</a>
</a-popconfirm>
</template>
</template>
</ele-pro-table>
@@ -93,12 +127,9 @@ import {createVNode, ref} from 'vue';
import {message, Modal} from 'ant-design-vue';
import {
ExclamationCircleOutlined,
EyeOutlined,
DollarOutlined,
CloseOutlined
} from '@ant-design/icons-vue';
import type {EleProTable} from 'ele-admin-pro';
import {toDateString} from 'ele-admin-pro';
import type {
DatasourceFunction,
ColumnItem
@@ -108,6 +139,7 @@ import {getPageTitle} from '@/utils/common';
import ShopDealerOrderEdit from './components/shopDealerOrderEdit.vue';
import {pageShopDealerOrder, removeShopDealerOrder, removeBatchShopDealerOrder} from '@/api/shop/shopDealerOrder';
import type {ShopDealerOrder, ShopDealerOrderParam} from '@/api/shop/shopDealerOrder/model';
import {exportSdyDealerOrder} from "@/api/sdy/sdyDealerOrder";
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
@@ -118,11 +150,12 @@ const selection = ref<ShopDealerOrder[]>([]);
const current = ref<ShopDealerOrder | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 加载状态
const loading = ref(true);
// 当前搜索条件
const currentWhere = ref<ShopDealerOrderParam>({});
// 表格数据源
const datasource: DatasourceFunction = ({
page,
@@ -134,6 +167,8 @@ const datasource: DatasourceFunction = ({
if (filters) {
where.status = filters.status;
}
// 保存当前搜索条件用于导出
currentWhere.value = {...where};
return pageShopDealerOrder({
...where,
...orders,
@@ -145,86 +180,76 @@ const datasource: DatasourceFunction = ({
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: '商品信息',
key: 'productInfo',
align: 'left',
width: 200,
customRender: ({record}) => {
return `商品ID: ${record.productId || '-'}`;
}
},
{
title: '单价/数量',
key: 'priceInfo',
align: 'center',
width: 120,
customRender: ({record}) => {
return `¥${parseFloat(record.unitPrice || '0').toFixed(2)} × ${record.quantity || 1}`;
}
},
{
title: '订单信息',
key: 'orderInfo',
align: 'left',
width: 180
},
{
title: '买家',
title: '用户ID',
dataIndex: 'userId',
key: 'userId',
align: 'center',
width: 100,
customRender: ({text}) => `用户${text || '-'}`
width: 90,
},
{
title: '分销商信息',
key: 'dealerInfo',
align: 'left',
width: 300
title: '客户名称',
dataIndex: 'comments',
key: 'comments'
},
{
title: '订单状态',
title: '结算电量',
dataIndex: 'orderPrice',
key: 'orderPrice',
align: 'center'
},
{
title: '换算成度',
dataIndex: 'orderPrice1000',
key: 'orderPrice1000',
align: 'center'
},
{
title: '结算单价',
dataIndex: 'price',
key: 'price',
align: 'center'
},
{
title: '结算金额',
dataIndex: 'settledPrice',
key: 'settledPrice',
align: 'center'
},
{
title: '税费',
dataIndex: 'rate',
key: 'rate',
align: 'center'
},
{
title: '实发金额',
dataIndex: 'payPrice',
key: 'payPrice',
align: 'center'
},
{
title: '签约状态',
dataIndex: 'isInvalid',
key: 'isInvalid',
align: 'center',
width: 100,
filters: [
{text: '有效', value: 0},
{text: '失效', value: 1}
]
width: 100
},
{
title: '结算状态',
dataIndex: 'isSettled',
key: 'isSettled',
align: 'center',
width: 100,
filters: [
{text: '未结算', value: 0},
{text: '已结算', value: 1}
]
},
{
title: '结算时间',
dataIndex: 'settleTime',
key: 'settleTime',
align: 'center',
width: 120,
customRender: ({text}) => text ? toDateString(new Date(text), 'yyyy-MM-dd HH:mm') : '-'
width: 100
},
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
align: 'center',
width: 180,
sorter: true,
customRender: ({text}) => toDateString(text, 'yyyy-MM-dd HH:mm')
align: 'center'
},
{
title: '操作',
key: 'action',
width: 240,
width: 180,
fixed: 'right',
align: 'center',
hideInSetting: true
@@ -237,64 +262,6 @@ const reload = (where?: ShopDealerOrderParam) => {
tableRef?.value?.reload({where: where});
};
/* 查看订单详情 */
const viewDetail = (row: ShopDealerOrder) => {
Modal.info({
title: '分销订单详情',
width: 800,
content: createVNode('div', {style: 'max-height: 500px; overflow-y: auto;'}, [
createVNode('div', {class: 'detail-section'}, [
createVNode('h4', null, '订单基本信息'),
createVNode('p', null, `订单ID: ${row.orderId || '-'}`),
createVNode('p', null, `买家用户ID: ${row.userId || '-'}`),
createVNode('p', null, `订单金额: ¥${parseFloat(row.orderPrice || '0').toFixed(2)}`),
createVNode('p', null, `创建时间: ${row.createTime ? toDateString(row.createTime, 'yyyy-MM-dd HH:mm:ss') : '-'}`),
]),
createVNode('div', {class: 'detail-section', style: 'margin-top: 16px;'}, [
createVNode('h4', null, '分销商信息'),
...(row.firstUserId ? [
createVNode('div', {style: 'margin: 8px 0; padding: 8px; background: #fff2f0; border-left: 3px solid #ff4d4f;'}, [
createVNode('strong', null, '一级分销商'),
createVNode('p', null, `用户ID: ${row.firstUserId}`),
createVNode('p', null, `佣金: ¥${parseFloat(row.firstMoney || '0').toFixed(2)}`)
])
] : []),
...(row.secondUserId ? [
createVNode('div', {style: 'margin: 8px 0; padding: 8px; background: #fff7e6; border-left: 3px solid #fa8c16;'}, [
createVNode('strong', null, '二级分销商'),
createVNode('p', null, `用户ID: ${row.secondUserId}`),
createVNode('p', null, `佣金: ¥${parseFloat(row.secondMoney || '0').toFixed(2)}`)
])
] : []),
...(row.thirdUserId ? [
createVNode('div', {style: 'margin: 8px 0; padding: 8px; background: #fffbe6; border-left: 3px solid #fadb14;'}, [
createVNode('strong', null, '三级分销商'),
createVNode('p', null, `用户ID: ${row.thirdUserId}`),
createVNode('p', null, `佣金: ¥${parseFloat(row.thirdMoney || '0').toFixed(2)}`)
])
] : [])
]),
createVNode('div', {class: 'detail-section', style: 'margin-top: 16px;'}, [
createVNode('h4', null, '状态信息'),
createVNode('p', null, [
'订单状态: ',
createVNode('span', {
style: `color: ${row.isInvalid === 0 ? '#52c41a' : '#ff4d4f'}; font-weight: bold;`
}, row.isInvalid === 0 ? '有效' : '失效')
]),
createVNode('p', null, [
'结算状态: ',
createVNode('span', {
style: `color: ${row.isSettled === 1 ? '#52c41a' : '#1890ff'}; font-weight: bold;`
}, row.isSettled === 1 ? '已结算' : '未结算')
]),
createVNode('p', null, `结算时间: ${row.settleTime ? toDateString(new Date(row.settleTime), 'yyyy-MM-dd HH:mm:ss') : '-'}`),
])
]),
okText: '关闭'
});
};
/* 结算单个订单 */
const settleOrder = (row: ShopDealerOrder) => {
const totalCommission = (parseFloat(row.firstMoney || '0') +
@@ -373,13 +340,9 @@ const batchSettle = () => {
};
/* 导出数据 */
const exportData = () => {
const hide = message.loading('正在导出数据...', 0);
// 这里调用导出API
setTimeout(() => {
hide();
message.success('数据导出成功');
}, 2000);
const handleExport = () => {
// 调用导出API传入当前搜索条件
exportSdyDealerOrder(currentWhere.value);
};
/* 打开编辑弹窗 */

View File

@@ -187,13 +187,11 @@ import {
QrcodeOutlined,
ShopOutlined,
ClockCircleOutlined,
SettingOutlined,
AccountBookOutlined,
FileTextOutlined,
ClearOutlined,
UngroupOutlined,
MoneyCollectOutlined,
ReloadOutlined
MoneyCollectOutlined
} from '@ant-design/icons-vue';
import {message} from 'ant-design-vue/es';
import {openNew} from "@/utils/common";

View File

@@ -1,4 +1,3 @@
<!-- 搜索表单 -->
<template>
<div class="search-container">
<!-- 搜索表单 -->
@@ -70,7 +69,6 @@
<a-space>
<a-button
type="primary"
:disabled="!selection?.length"
@click="batchSettle"
class="ele-btn-icon"
>
@@ -79,29 +77,36 @@
</template>
批量结算
</a-button>
<a-button
:disabled="!selection?.length"
@click="exportData"
class="ele-btn-icon"
>
<a-button @click="exportData" class="ele-btn-icon">
<template #icon>
<ExportOutlined />
</template>
导出数据
</a-button>
<a-button @click="openImport" class="ele-btn-icon">
<template #icon>
<UploadOutlined />
</template>
导入数据
</a-button>
</a-space>
</div>
</div>
<!-- 导入弹窗 -->
<Import v-model:visible="showImport" @done="emit('importDone')" />
</template>
<script lang="ts" setup>
import { reactive } from 'vue';
import { reactive, ref } from 'vue';
import {
SearchOutlined,
DollarOutlined,
ExportOutlined
ExportOutlined,
UploadOutlined
} from '@ant-design/icons-vue';
import type { ShopDealerOrderParam } from '@/api/shop/shopDealerOrder/model';
import Import from './Import.vue';
const props = withDefaults(
defineProps<{
@@ -117,8 +122,12 @@
(e: 'search', where?: ShopDealerOrderParam): void;
(e: 'batchSettle'): void;
(e: 'export'): void;
(e: 'importDone'): void;
}>();
// 是否显示导入弹窗
const showImport = ref(false);
// 搜索表单
const searchForm = reactive<ShopDealerOrderParam>({
orderId: undefined,
@@ -157,6 +166,11 @@
const exportData = () => {
emit('export');
};
// 打开导入弹窗
const openImport = () => {
showImport.value = true;
};
</script>
<style lang="less" scoped>

View File

@@ -15,7 +15,8 @@
@search="reload"
:selection="selection"
@batchSettle="batchSettle"
@export="exportData"
@export="handleExport"
@importDone="reload"
/>
</template>
<template #bodyCell="{ column, record }">
@@ -106,7 +107,7 @@ import type {
import Search from './components/search.vue';
import {getPageTitle} from '@/utils/common';
import ShopDealerOrderEdit from './components/shopDealerOrderEdit.vue';
import {pageShopDealerOrder, removeShopDealerOrder, removeBatchShopDealerOrder} from '@/api/shop/shopDealerOrder';
import {pageShopDealerOrder, removeShopDealerOrder, removeBatchShopDealerOrder, exportShopDealerOrder} from '@/api/shop/shopDealerOrder';
import type {ShopDealerOrder, ShopDealerOrderParam} from '@/api/shop/shopDealerOrder/model';
// 表格实例
@@ -123,6 +124,9 @@ const showMove = ref(false);
// 加载状态
const loading = ref(true);
// 当前搜索条件
const currentWhere = ref<ShopDealerOrderParam>({});
// 表格数据源
const datasource: DatasourceFunction = ({
page,
@@ -134,6 +138,8 @@ const datasource: DatasourceFunction = ({
if (filters) {
where.status = filters.status;
}
// 保存当前搜索条件用于导出
currentWhere.value = { ...where };
return pageShopDealerOrder({
...where,
...orders,
@@ -373,13 +379,9 @@ const batchSettle = () => {
};
/* 导出数据 */
const exportData = () => {
const hide = message.loading('正在导出数据...', 0);
// 这里调用导出API
setTimeout(() => {
hide();
message.success('数据导出成功');
}, 2000);
const handleExport = () => {
// 调用导出API传入当前搜索条件
exportShopDealerOrder(currentWhere.value);
};
/* 打开编辑弹窗 */
@@ -503,4 +505,4 @@ export default {
:deep(.ant-tag) {
margin: 2px 4px 2px 0;
}
</style>
</style>

View File

@@ -1,100 +0,0 @@
# 分销商用户管理模块
## 功能说明
本模块提供了完整的分销商用户管理功能,包括:
### 基础功能
- ✅ 用户列表查看
- ✅ 用户信息编辑
- ✅ 用户详情查看
- ✅ 用户删除(单个/批量)
- ✅ 关键词搜索
### 导入导出功能
- ✅ Excel 数据导出
- ✅ Excel 数据导入
- ✅ 导入数据验证
- ✅ 错误处理
## 导入导出使用说明
### 导出功能
1. 点击"导出xls"按钮
2. 系统会根据当前搜索条件导出数据
3. 导出的Excel文件包含以下字段
- 用户ID
- 姓名
- 手机号
- 可提现佣金
- 冻结佣金
- 累计提现
- 推荐人ID
- 一级成员数
- 二级成员数
- 三级成员数
- 专属二维码
- 状态
- 创建时间
- 更新时间
### 导入功能
1. 点击"导入xls"按钮
2. 拖拽或选择Excel文件支持.xls和.xlsx格式
3. 文件大小限制10MB以内
4. 导入格式要求:
- 必填字段用户ID、姓名、手机号
- 佣金字段请填写数字,不要包含货币符号
- 状态字段:正常 或 已删除
- 推荐人ID必须是已存在的用户ID
### 数据格式示例
| 用户ID | 姓名 | 手机号 | 可提现佣金 | 冻结佣金 | 累计提现 | 推荐人ID | 一级成员数 | 二级成员数 | 三级成员数 | 专属二维码 | 状态 |
|--------|------|--------|------------|----------|----------|----------|------------|------------|------------|------------|------|
| 1001 | 张三 | 13800138000 | 100.50 | 50.00 | 200.00 | 1000 | 5 | 3 | 2 | DEALER_1001_xxx | 正常 |
| 1002 | 李四 | 13900139000 | 200.00 | 0.00 | 150.00 | | 2 | 1 | 0 | | 正常 |
## 技术实现
### 文件结构
```
src/views/shop/shopDealerUser/
├── index.vue # 主页面
├── components/
│ ├── search.vue # 搜索组件(包含导入导出功能)
│ ├── Import.vue # 导入弹窗组件
│ └── shopDealerUserEdit.vue # 编辑弹窗组件
└── README.md # 说明文档
```
### API 接口
```typescript
// 导入接口
POST /shop/shop-dealer-user/import
Content-Type: multipart/form-data
// 导出接口
GET /shop/shop-dealer-user/export
Response-Type: blob
```
### 依赖库
- `xlsx`: Excel文件处理
- `dayjs`: 日期格式化
- `ant-design-vue`: UI组件库
## 注意事项
1. **数据安全**:导入功能会直接操作数据库,请确保导入的数据准确无误
2. **性能考虑**:大量数据导入时可能需要较长时间,请耐心等待
3. **错误处理**:导入失败时会显示具体错误信息,请根据提示修正数据
4. **权限控制**:确保用户有相应的导入导出权限
## 更新日志
### v1.0.0 (2024-12-19)
- ✅ 实现基础的导入导出功能
- ✅ 添加数据验证和错误处理
- ✅ 优化用户体验和界面交互
- ✅ 完善文档说明