分销员管理界面初始化
This commit is contained in:
parent
ed47c26c63
commit
e555527410
@ -5,7 +5,7 @@ VITE_DEV=true
|
||||
|
||||
# 请求路径
|
||||
#VITE_BASE_URL='https://zysc.fjptzykj.com'
|
||||
VITE_BASE_URL='http://192.168.1.12:6127'
|
||||
VITE_BASE_URL='http://172.24.128.1:6127'
|
||||
|
||||
# 文件上传类型:server - 后端上传, client - 前端直连上传,仅支持 S3 服务
|
||||
VITE_UPLOAD_TYPE=server
|
||||
|
BIN
yudao-admin-vue3/.image/测试二维码.jpg
Normal file
BIN
yudao-admin-vue3/.image/测试二维码.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
@ -0,0 +1,50 @@
|
||||
import request from '@/config/axios'
|
||||
|
||||
// 分销员管理 VO
|
||||
export interface DistributeManageVO {
|
||||
id: number // id
|
||||
goodImage: string // 商品图片
|
||||
userInformation: string // 用户信息
|
||||
distributeLevel: number // 分销等级
|
||||
marketinguserNumber: number // 推广用户数量
|
||||
marketingorderNumber: number // 推广订单数量
|
||||
marketingorderMoney: number // 推广订单金额
|
||||
mercenarieMoney: number // 佣兵总金额
|
||||
alreadytokenMoney: number // 已提现金额
|
||||
untokenMoney: number // 未提现金额
|
||||
superiorPromoter: string // 上级推广人
|
||||
takeTimes: number // 提现次数
|
||||
}
|
||||
|
||||
// 分销员管理 API
|
||||
export const DistributeManageApi = {
|
||||
// 查询分销员管理分页
|
||||
getDistributeManagePage: async (params: any) => {
|
||||
return await request.get({ url: `/trade/distribute-manage/page`, params })
|
||||
},
|
||||
|
||||
// 查询分销员管理详情
|
||||
getDistributeManage: async (id: number) => {
|
||||
return await request.get({ url: `/trade/distribute-manage/get?id=` + id })
|
||||
},
|
||||
|
||||
// 新增分销员管理
|
||||
createDistributeManage: async (data: DistributeManageVO) => {
|
||||
return await request.post({ url: `/trade/distribute-manage/create`, data })
|
||||
},
|
||||
|
||||
// 修改分销员管理
|
||||
updateDistributeManage: async (data: DistributeManageVO) => {
|
||||
return await request.put({ url: `/trade/distribute-manage/update`, data })
|
||||
},
|
||||
|
||||
// 删除分销员管理
|
||||
deleteDistributeManage: async (id: number) => {
|
||||
return await request.delete({ url: `/trade/distribute-manage/delete?id=` + id })
|
||||
},
|
||||
|
||||
// 导出分销员管理 Excel
|
||||
exportDistributeManage: async (params) => {
|
||||
return await request.download({ url: `/trade/distribute-manage/export-excel`, params })
|
||||
},
|
||||
}
|
@ -0,0 +1,141 @@
|
||||
<template>
|
||||
<Dialog :title="dialogTitle" v-model="dialogVisible">
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-width="100px"
|
||||
v-loading="formLoading"
|
||||
>
|
||||
<el-form-item label="商品图片" prop="goodImage">
|
||||
<UploadImg v-model="formData.goodImage" />
|
||||
</el-form-item>
|
||||
<el-form-item label="用户信息" prop="userInformation">
|
||||
<el-input v-model="formData.userInformation" placeholder="请输入用户信息" />
|
||||
</el-form-item>
|
||||
<el-form-item label="分销等级" prop="distributeLevel">
|
||||
<el-input v-model="formData.distributeLevel" placeholder="请输入分销等级" />
|
||||
</el-form-item>
|
||||
<el-form-item label="推广用户数量" prop="marketinguserNumber">
|
||||
<el-input v-model="formData.marketinguserNumber" placeholder="请输入推广用户数量" />
|
||||
</el-form-item>
|
||||
<el-form-item label="推广订单数量" prop="marketingorderNumber">
|
||||
<el-input v-model="formData.marketingorderNumber" placeholder="请输入推广订单数量" />
|
||||
</el-form-item>
|
||||
<el-form-item label="推广订单金额" prop="marketingorderMoney">
|
||||
<el-input v-model="formData.marketingorderMoney" placeholder="请输入推广订单金额" />
|
||||
</el-form-item>
|
||||
<el-form-item label="佣兵总金额" prop="mercenarieMoney">
|
||||
<el-input v-model="formData.mercenarieMoney" placeholder="请输入佣兵总金额" />
|
||||
</el-form-item>
|
||||
<el-form-item label="已提现金额" prop="alreadytokenMoney">
|
||||
<el-input v-model="formData.alreadytokenMoney" placeholder="请输入已提现金额" />
|
||||
</el-form-item>
|
||||
<el-form-item label="未提现金额" prop="untokenMoney">
|
||||
<el-input v-model="formData.untokenMoney" placeholder="请输入未提现金额" />
|
||||
</el-form-item>
|
||||
<el-form-item label="上级推广人" prop="superiorPromoter">
|
||||
<el-input v-model="formData.superiorPromoter" placeholder="请输入上级推广人" />
|
||||
</el-form-item>
|
||||
<el-form-item label="提现次数" prop="takeTimes">
|
||||
<el-input v-model="formData.takeTimes" placeholder="请输入提现次数" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
</template>
|
||||
</Dialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { DistributeManageApi, DistributeManageVO } from '@/api/mall/trade/distributemanage'
|
||||
|
||||
/** 分销员管理 表单 */
|
||||
defineOptions({ name: 'DistributeManageForm' })
|
||||
|
||||
const { t } = useI18n() // 国际化
|
||||
const message = useMessage() // 消息弹窗
|
||||
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||
const dialogTitle = ref('') // 弹窗的标题
|
||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
||||
const formData = ref({
|
||||
id: undefined,
|
||||
goodImage: undefined,
|
||||
userInformation: undefined,
|
||||
distributeLevel: undefined,
|
||||
marketinguserNumber: undefined,
|
||||
marketingorderNumber: undefined,
|
||||
marketingorderMoney: undefined,
|
||||
mercenarieMoney: undefined,
|
||||
alreadytokenMoney: undefined,
|
||||
untokenMoney: undefined,
|
||||
superiorPromoter: undefined,
|
||||
takeTimes: undefined,
|
||||
})
|
||||
const formRules = reactive({
|
||||
})
|
||||
const formRef = ref() // 表单 Ref
|
||||
|
||||
/** 打开弹窗 */
|
||||
const open = async (type: string, id?: number) => {
|
||||
dialogVisible.value = true
|
||||
dialogTitle.value = t('action.' + type)
|
||||
formType.value = type
|
||||
resetForm()
|
||||
// 修改时,设置数据
|
||||
if (id) {
|
||||
formLoading.value = true
|
||||
try {
|
||||
formData.value = await DistributeManageApi.getDistributeManage(id)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||
|
||||
/** 提交表单 */
|
||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||
const submitForm = async () => {
|
||||
// 校验表单
|
||||
await formRef.value.validate()
|
||||
// 提交请求
|
||||
formLoading.value = true
|
||||
try {
|
||||
const data = formData.value as unknown as DistributeManageVO
|
||||
if (formType.value === 'create') {
|
||||
await DistributeManageApi.createDistributeManage(data)
|
||||
message.success(t('common.createSuccess'))
|
||||
} else {
|
||||
await DistributeManageApi.updateDistributeManage(data)
|
||||
message.success(t('common.updateSuccess'))
|
||||
}
|
||||
dialogVisible.value = false
|
||||
// 发送操作成功的事件
|
||||
emit('success')
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 重置表单 */
|
||||
const resetForm = () => {
|
||||
formData.value = {
|
||||
id: undefined,
|
||||
goodImage: undefined,
|
||||
userInformation: undefined,
|
||||
distributeLevel: undefined,
|
||||
marketinguserNumber: undefined,
|
||||
marketingorderNumber: undefined,
|
||||
marketingorderMoney: undefined,
|
||||
mercenarieMoney: undefined,
|
||||
alreadytokenMoney: undefined,
|
||||
untokenMoney: undefined,
|
||||
superiorPromoter: undefined,
|
||||
takeTimes: undefined,
|
||||
}
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
</script>
|
391
yudao-admin-vue3/src/views/mall/trade/distributemanage/index.vue
Normal file
391
yudao-admin-vue3/src/views/mall/trade/distributemanage/index.vue
Normal file
@ -0,0 +1,391 @@
|
||||
<template>
|
||||
<ContentWrap>
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form
|
||||
class="-mb-15px"
|
||||
:model="queryParams"
|
||||
ref="queryFormRef"
|
||||
:inline="true"
|
||||
label-width="68px"
|
||||
>
|
||||
<el-form-item label="用户信息" prop="userInformation">
|
||||
<el-input
|
||||
v-model="queryParams.userInformation"
|
||||
placeholder="请输入姓名,昵称,电话号码"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="分销等级" prop="distributeLevel">-->
|
||||
<!-- <el-input-->
|
||||
<!-- v-model="queryParams.distributeLevel"-->
|
||||
<!-- placeholder="请输入分销等级"-->
|
||||
<!-- clearable-->
|
||||
<!-- @keyup.enter="handleQuery"-->
|
||||
<!-- class="!w-240px"-->
|
||||
<!-- />-->
|
||||
<!-- </el-form-item>-->
|
||||
<!-- <el-form-item label="推广用户数量" prop="marketinguserNumber">-->
|
||||
<!-- <el-input-->
|
||||
<!-- v-model="queryParams.marketinguserNumber"-->
|
||||
<!-- placeholder="请输入推广用户数量"-->
|
||||
<!-- clearable-->
|
||||
<!-- @keyup.enter="handleQuery"-->
|
||||
<!-- class="!w-240px"-->
|
||||
<!-- />-->
|
||||
<!-- </el-form-item>-->
|
||||
<!-- <el-form-item label="推广订单数量" prop="marketingorderNumber">-->
|
||||
<!-- <el-input-->
|
||||
<!-- v-model="queryParams.marketingorderNumber"-->
|
||||
<!-- placeholder="请输入推广订单数量"-->
|
||||
<!-- clearable-->
|
||||
<!-- @keyup.enter="handleQuery"-->
|
||||
<!-- class="!w-240px"-->
|
||||
<!-- />-->
|
||||
<!-- </el-form-item>-->
|
||||
<!-- <el-form-item label="推广订单金额" prop="marketingorderMoney">-->
|
||||
<!-- <el-input-->
|
||||
<!-- v-model="queryParams.marketingorderMoney"-->
|
||||
<!-- placeholder="请输入推广订单金额"-->
|
||||
<!-- clearable-->
|
||||
<!-- @keyup.enter="handleQuery"-->
|
||||
<!-- class="!w-240px"-->
|
||||
<!-- />-->
|
||||
<!-- </el-form-item>-->
|
||||
<!-- <el-form-item label="佣兵总金额" prop="mercenarieMoney">-->
|
||||
<!-- <el-input-->
|
||||
<!-- v-model="queryParams.mercenarieMoney"-->
|
||||
<!-- placeholder="请输入佣兵总金额"-->
|
||||
<!-- clearable-->
|
||||
<!-- @keyup.enter="handleQuery"-->
|
||||
<!-- class="!w-240px"-->
|
||||
<!-- />-->
|
||||
<!-- </el-form-item>-->
|
||||
<!-- <el-form-item label="已提现金额" prop="alreadytokenMoney">-->
|
||||
<!-- <el-input-->
|
||||
<!-- v-model="queryParams.alreadytokenMoney"-->
|
||||
<!-- placeholder="请输入已提现金额"-->
|
||||
<!-- clearable-->
|
||||
<!-- @keyup.enter="handleQuery"-->
|
||||
<!-- class="!w-240px"-->
|
||||
<!-- />-->
|
||||
<!-- </el-form-item>-->
|
||||
<!-- <el-form-item label="未提现金额" prop="untokenMoney">-->
|
||||
<!-- <el-input-->
|
||||
<!-- v-model="queryParams.untokenMoney"-->
|
||||
<!-- placeholder="请输入未提现金额"-->
|
||||
<!-- clearable-->
|
||||
<!-- @keyup.enter="handleQuery"-->
|
||||
<!-- class="!w-240px"-->
|
||||
<!-- />-->
|
||||
<!-- </el-form-item>-->
|
||||
<!-- <el-form-item label="上级推广人" prop="superiorPromoter">-->
|
||||
<!-- <el-input-->
|
||||
<!-- v-model="queryParams.superiorPromoter"-->
|
||||
<!-- placeholder="请输入上级推广人"-->
|
||||
<!-- clearable-->
|
||||
<!-- @keyup.enter="handleQuery"-->
|
||||
<!-- class="!w-240px"-->
|
||||
<!-- />-->
|
||||
<!-- </el-form-item>-->
|
||||
<!-- <el-form-item label="提现次数" prop="takeTimes">-->
|
||||
<!-- <el-input-->
|
||||
<!-- v-model="queryParams.takeTimes"-->
|
||||
<!-- placeholder="请输入提现次数"-->
|
||||
<!-- clearable-->
|
||||
<!-- @keyup.enter="handleQuery"-->
|
||||
<!-- class="!w-240px"-->
|
||||
<!-- />-->
|
||||
<!-- </el-form-item>-->
|
||||
<el-form-item>
|
||||
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
||||
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
@click="openForm('create')"
|
||||
v-hasPermi="['trade:distribute-manage:create']"
|
||||
>
|
||||
<Icon icon="ep:plus" class="mr-5px" /> 新增
|
||||
</el-button>
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
@click="handleExport"
|
||||
:loading="exportLoading"
|
||||
v-hasPermi="['trade:distribute-manage:export']"
|
||||
>
|
||||
<Icon icon="ep:download" class="mr-5px" /> 导出
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 列表 -->
|
||||
<ContentWrap>
|
||||
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
||||
<el-table-column label="id" align="center" prop="id" />
|
||||
<!-- <el-table-column label="商品图片" align="center" prop="goodImage" />-->
|
||||
<el-table-column label="商品图片" align="center">
|
||||
<template #default="scope">
|
||||
<el-image
|
||||
:src="scope.row.goodImage"
|
||||
alt="商品图片"
|
||||
style="width: 100px; height: auto; cursor: pointer;"
|
||||
:preview-src-list="[scope.row.goodImage]"
|
||||
:initial-index="0"
|
||||
:zoom-rate="1.2"
|
||||
:max-scale="7"
|
||||
:min-scale="0.2"
|
||||
fit="cover"
|
||||
preview-teleported
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="用户信息" align="center" prop="userInformation" />
|
||||
<el-table-column label="分销等级" align="center" prop="distributeLevel" />
|
||||
<el-table-column label="推广用户数量" align="center" prop="marketinguserNumber" />
|
||||
<el-table-column label="推广订单数量" align="center" prop="marketingorderNumber" />
|
||||
<el-table-column label="推广订单金额" align="center" prop="marketingorderMoney" />
|
||||
<el-table-column label="佣兵总金额" align="center" prop="mercenarieMoney" />
|
||||
<el-table-column label="已提现金额" align="center" prop="alreadytokenMoney" />
|
||||
<el-table-column label="未提现金额" align="center" prop="untokenMoney" />
|
||||
<el-table-column label="上级推广人" align="center" prop="superiorPromoter" />
|
||||
<el-table-column
|
||||
label="创建时间"
|
||||
align="center"
|
||||
prop="createTime"
|
||||
:formatter="dateFormatter"
|
||||
width="180px"
|
||||
/>
|
||||
<el-table-column label="提现次数" align="center" prop="takeTimes" />
|
||||
<!-- 操作列 -->
|
||||
<el-table-column label="操作" align="center">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
@click="openPromoterDialog(scope.row.id)"
|
||||
v-hasPermi="['trade:distribute-manage:update']"
|
||||
>
|
||||
推广员
|
||||
</el-button>
|
||||
<el-dropdown
|
||||
trigger="click"
|
||||
@command="(command) => handleCommand(command, scope.row)"
|
||||
v-hasPermi="['trade:distribute-manage:delete', 'trade:distribute-manage:update']"
|
||||
>
|
||||
<el-button link type="danger">
|
||||
更多<icon icon="ep:arrow-down" class="el-icon--right" />
|
||||
</el-button>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item
|
||||
command="promoteQR"
|
||||
v-hasPermi="['trade:distribute-manage:qr']"
|
||||
>
|
||||
推广二维码
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item
|
||||
command="update"
|
||||
@click="openForm('update', scope.row.id)"
|
||||
v-hasPermi="['trade:distribute-manage:update']"
|
||||
>
|
||||
编辑分销员内容
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item
|
||||
command="cancelPromote"
|
||||
v-hasPermi="['trade:distribute-manage:delete']"
|
||||
>
|
||||
取消推广资格
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
|
||||
<!-- 推广员弹窗组件 -->
|
||||
<el-dialog
|
||||
v-model="promoterDialogVisible"
|
||||
title="推广员详情"
|
||||
width="80%"
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<PromoterIndex v-if="promoterDialogVisible" :promoter-id="currentPromoterId" />
|
||||
</el-dialog>
|
||||
<!-- 推广二维码弹窗组件 -->
|
||||
<el-dialog
|
||||
v-model="qrDialogVisible"
|
||||
title="公众号二维码"
|
||||
width="400px"
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<div style="text-align: center;">
|
||||
<el-image :src="qrCodeUrl" alt="公众号二维码" style="width: 200px; height: 200px;" />
|
||||
<p style="margin-top: 10px;">扫码关注公众号</p>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<!-- 分页 -->
|
||||
<Pagination
|
||||
:total="total"
|
||||
v-model:page="queryParams.pageNo"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 表单弹窗:添加/修改 -->
|
||||
<DistributeManageForm ref="formRef" @success="getList" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { dateFormatter } from '@/utils/formatTime'
|
||||
import download from '@/utils/download'
|
||||
import { DistributeManageApi, DistributeManageVO } from '@/api/mall/trade/distributemanage'
|
||||
import DistributeManageForm from './DistributeManageForm.vue'
|
||||
import { ref } from 'vue'
|
||||
import PromoterIndex from '@/views/mall/trade/brokerage/user/index.vue'
|
||||
import {ElMessage} from "element-plus";
|
||||
|
||||
/** 分销员管理 列表 */
|
||||
defineOptions({ name: 'DistributeManage' })
|
||||
|
||||
const message = useMessage() // 消息弹窗
|
||||
const { t } = useI18n() // 国际化
|
||||
|
||||
const loading = ref(true) // 列表的加载中
|
||||
const list = ref<DistributeManageVO[]>([]) // 列表的数据
|
||||
const total = ref(0) // 列表的总页数
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
goodImage: undefined,
|
||||
userInformation: undefined,
|
||||
distributeLevel: undefined,
|
||||
marketinguserNumber: undefined,
|
||||
marketingorderNumber: undefined,
|
||||
marketingorderMoney: undefined,
|
||||
mercenarieMoney: undefined,
|
||||
alreadytokenMoney: undefined,
|
||||
untokenMoney: undefined,
|
||||
superiorPromoter: undefined,
|
||||
takeTimes: undefined,
|
||||
})
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
const exportLoading = ref(false) // 导出的加载中
|
||||
|
||||
/** 查询列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await DistributeManageApi.getDistributeManagePage(queryParams)
|
||||
list.value = data.list
|
||||
total.value = data.total
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.pageNo = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value.resetFields()
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
/** 添加/修改操作 */
|
||||
const formRef = ref()
|
||||
const openForm = (type: string, id?: number) => {
|
||||
formRef.value.open(type, id)
|
||||
}
|
||||
|
||||
/** 处理下拉菜单命令 */
|
||||
const handleCommand = async (command: string, row: DistributeManageVO) => {
|
||||
switch (command) {
|
||||
case 'promoteQR':
|
||||
handlePromoteQRCode(row.id)
|
||||
break
|
||||
case 'updateLevel':
|
||||
handleUpdateLevel(row.id)
|
||||
break
|
||||
case 'cancelPromote':
|
||||
handleDelete(row.id)
|
||||
break
|
||||
}
|
||||
}
|
||||
/** 二维码弹窗相关状态 */
|
||||
const qrDialogVisible = ref(false)
|
||||
const qrCodeUrl = ref('') // 二维码地址
|
||||
|
||||
/** 处理推广二维码 */
|
||||
const handlePromoteQRCode = (id: number) => {
|
||||
// 模拟未找到二维码的情况
|
||||
const qrCodeFound = false // 如果找不到对应的二维码
|
||||
|
||||
if (!qrCodeFound) {
|
||||
ElMessage.error('暂未找到对应的推广二维码') // 显示错误信息
|
||||
qrCodeUrl.value = '/.image/测试二维码.jpg' // 本地二维码路径
|
||||
qrDialogVisible.value = true // 打开弹窗
|
||||
} else {
|
||||
// 如果找到二维码,可以调用 API 获取二维码地址
|
||||
// const response = await DistributeManageApi.getPromoteQRCode(id)
|
||||
// qrCodeUrl.value = response.data.qrCodeUrl
|
||||
// qrDialogVisible.value = true
|
||||
}
|
||||
}
|
||||
/** 处理修改分销等级 */
|
||||
const handleUpdateLevel = (id: number) => {
|
||||
}
|
||||
|
||||
/** 推广员弹窗相关状态 */
|
||||
const promoterDialogVisible = ref(false)
|
||||
const currentPromoterId = ref<number | null>(null)
|
||||
|
||||
/** 打开推广员弹窗 */
|
||||
const openPromoterDialog = (id: number) => {
|
||||
currentPromoterId.value = id
|
||||
promoterDialogVisible.value = true
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (id: number) => {
|
||||
try {
|
||||
// 删除的二次确认
|
||||
await message.delConfirm()
|
||||
// 发起删除
|
||||
await DistributeManageApi.deleteDistributeManage(id)
|
||||
message.success(t('common.delSuccess'))
|
||||
// 刷新列表
|
||||
await getList()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = async () => {
|
||||
try {
|
||||
// 导出的二次确认
|
||||
await message.exportConfirm()
|
||||
// 发起导出
|
||||
exportLoading.value = true
|
||||
const data = await DistributeManageApi.exportDistributeManage(queryParams)
|
||||
download.excel(data, '分销员管理.xls')
|
||||
} catch {
|
||||
} finally {
|
||||
exportLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 **/
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
@ -90,6 +90,7 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode BROKERAGE_BIND_OVERRIDE = new ErrorCode(1_011_007_006, "已绑定了推广人");
|
||||
ErrorCode BROKERAGE_BIND_LOOP = new ErrorCode(1_011_007_007, "下级不能绑定自己的上级");
|
||||
ErrorCode BROKERAGE_USER_LEVEL_NOT_SUPPORT = new ErrorCode(1_011_007_008, "目前只支持 level 小于等于 2");
|
||||
ErrorCode DISTRIBUTE_MANAGE_NOT_EXISTS = new ErrorCode(1_011_007_009, "分销员管理不存在");
|
||||
|
||||
// ========== 分销提现 模块 1-011-008-000 ==========
|
||||
ErrorCode BROKERAGE_WITHDRAW_NOT_EXISTS = new ErrorCode(1_011_008_000, "佣金提现记录不存在");
|
||||
|
@ -0,0 +1,95 @@
|
||||
package cn.iocoder.yudao.module.trade.controller.admin.distributemanage;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import cn.iocoder.yudao.module.trade.controller.admin.distributemanage.vo.*;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.distributemanage.DistributeManageDO;
|
||||
import cn.iocoder.yudao.module.trade.service.distributemanage.DistributeManageService;
|
||||
|
||||
@Tag(name = "管理后台 - 分销员管理")
|
||||
@RestController
|
||||
@RequestMapping("/trade/distribute-manage")
|
||||
@Validated
|
||||
public class DistributeManageController {
|
||||
|
||||
@Resource
|
||||
private DistributeManageService distributeManageService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建分销员管理")
|
||||
@PreAuthorize("@ss.hasPermission('trade:distribute-manage:create')")
|
||||
public CommonResult<Long> createDistributeManage(@Valid @RequestBody DistributeManageSaveReqVO createReqVO) {
|
||||
return success(distributeManageService.createDistributeManage(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新分销员管理")
|
||||
@PreAuthorize("@ss.hasPermission('trade:distribute-manage:update')")
|
||||
public CommonResult<Boolean> updateDistributeManage(@Valid @RequestBody DistributeManageSaveReqVO updateReqVO) {
|
||||
distributeManageService.updateDistributeManage(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除分销员管理")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('trade:distribute-manage:delete')")
|
||||
public CommonResult<Boolean> deleteDistributeManage(@RequestParam("id") Long id) {
|
||||
distributeManageService.deleteDistributeManage(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得分销员管理")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('trade:distribute-manage:query')")
|
||||
public CommonResult<DistributeManageRespVO> getDistributeManage(@RequestParam("id") Long id) {
|
||||
DistributeManageDO distributeManage = distributeManageService.getDistributeManage(id);
|
||||
return success(BeanUtils.toBean(distributeManage, DistributeManageRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得分销员管理分页")
|
||||
@PreAuthorize("@ss.hasPermission('trade:distribute-manage:query')")
|
||||
public CommonResult<PageResult<DistributeManageRespVO>> getDistributeManagePage(@Valid DistributeManagePageReqVO pageReqVO) {
|
||||
PageResult<DistributeManageDO> pageResult = distributeManageService.getDistributeManagePage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, DistributeManageRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出分销员管理 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('trade:distribute-manage:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportDistributeManageExcel(@Valid DistributeManagePageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<DistributeManageDO> list = distributeManageService.getDistributeManagePage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "分销员管理.xls", "数据", DistributeManageRespVO.class,
|
||||
BeanUtils.toBean(list, DistributeManageRespVO.class));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package cn.iocoder.yudao.module.trade.controller.admin.distributemanage.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 分销员管理分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class DistributeManagePageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "商品图片")
|
||||
private String goodImage;
|
||||
|
||||
@Schema(description = "用户信息", example = "姓名: 昵称: 电话:")
|
||||
private String userInformation;
|
||||
|
||||
@Schema(description = "分销等级", example = "--")
|
||||
private Integer distributeLevel;
|
||||
|
||||
@Schema(description = "推广订单金额", example = "0.0")
|
||||
private Double marketingorderMoney;
|
||||
|
||||
@Schema(description = "已提现金额", example = "0.0")
|
||||
private Double alreadytokenMoney;
|
||||
|
||||
@Schema(description = "未提现金额", example = "0.0")
|
||||
private Double untokenMoney;
|
||||
|
||||
@Schema(description = "上级推广人")
|
||||
private String superiorPromoter;
|
||||
|
||||
@Schema(description = "提现次数")
|
||||
private Integer takeTimes;
|
||||
|
||||
@Schema(description = "佣兵总金额")
|
||||
private Double mercenarieMoney;
|
||||
|
||||
@Schema(description = "推广用户数量")
|
||||
private Integer marketinguserNumber;
|
||||
|
||||
@Schema(description = "推广订单数量")
|
||||
private Integer marketingorderNumber;
|
||||
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package cn.iocoder.yudao.module.trade.controller.admin.distributemanage.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 分销员管理 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class DistributeManageRespVO {
|
||||
|
||||
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "29548")
|
||||
@ExcelProperty("id")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "商品图片")
|
||||
@ExcelProperty("商品图片")
|
||||
private String goodImage;
|
||||
|
||||
@Schema(description = "用户信息", example = "姓名: 昵称: 电话:")
|
||||
@ExcelProperty("用户信息")
|
||||
private String userInformation;
|
||||
|
||||
@Schema(description = "分销等级", example = "--")
|
||||
@ExcelProperty("分销等级")
|
||||
private Integer distributeLevel;
|
||||
|
||||
@Schema(description = "推广订单金额", example = "0.0")
|
||||
@ExcelProperty("推广订单金额")
|
||||
private Double marketingorderMoney;
|
||||
|
||||
@Schema(description = "已提现金额", example = "0.0")
|
||||
@ExcelProperty("已提现金额")
|
||||
private Double alreadytokenMoney;
|
||||
|
||||
@Schema(description = "未提现金额", example = "0.0")
|
||||
@ExcelProperty("未提现金额")
|
||||
private Double untokenMoney;
|
||||
|
||||
@Schema(description = "上级推广人")
|
||||
@ExcelProperty("上级推广人")
|
||||
private String superiorPromoter;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "提现次数")
|
||||
@ExcelProperty("提现次数")
|
||||
private Integer takeTimes;
|
||||
|
||||
@Schema(description = "佣兵总金额")
|
||||
@ExcelProperty("佣兵总金额")
|
||||
private Double mercenarieMoney;
|
||||
|
||||
@Schema(description = "推广用户数量")
|
||||
@ExcelProperty("推广用户数量")
|
||||
private Integer marketinguserNumber;
|
||||
|
||||
@Schema(description = "推广订单数量")
|
||||
@ExcelProperty("推广订单数量")
|
||||
private Integer marketingorderNumber;
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package cn.iocoder.yudao.module.trade.controller.admin.distributemanage.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 分销员管理新增/修改 Request VO")
|
||||
@Data
|
||||
public class DistributeManageSaveReqVO {
|
||||
|
||||
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "29548")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "商品图片")
|
||||
private String goodImage;
|
||||
|
||||
@Schema(description = "用户信息", example = "姓名: 昵称: 电话:")
|
||||
private String userInformation;
|
||||
|
||||
@Schema(description = "分销等级", example = "--")
|
||||
private Integer distributeLevel;
|
||||
|
||||
@Schema(description = "推广订单金额", example = "0.0")
|
||||
private Double marketingorderMoney;
|
||||
|
||||
@Schema(description = "已提现金额", example = "0.0")
|
||||
private Double alreadytokenMoney;
|
||||
|
||||
@Schema(description = "未提现金额", example = "0.0")
|
||||
private Double untokenMoney;
|
||||
|
||||
@Schema(description = "上级推广人")
|
||||
private String superiorPromoter;
|
||||
|
||||
@Schema(description = "提现次数")
|
||||
private Integer takeTimes;
|
||||
|
||||
@Schema(description = "佣兵总金额")
|
||||
private Double mercenarieMoney;
|
||||
|
||||
@Schema(description = "推广用户数量")
|
||||
private Integer marketinguserNumber;
|
||||
|
||||
@Schema(description = "推广订单数量")
|
||||
private Integer marketingorderNumber;
|
||||
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package cn.iocoder.yudao.module.trade.dal.dataobject.distributemanage;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 分销员管理 DO
|
||||
*
|
||||
* @author 管理员
|
||||
*/
|
||||
@TableName("trade_distribute_manage")
|
||||
@KeySequence("trade_distribute_manage_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DistributeManageDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 商品图片
|
||||
*/
|
||||
private String goodImage;
|
||||
/**
|
||||
* 用户信息
|
||||
*/
|
||||
private String userInformation;
|
||||
/**
|
||||
* 分销等级
|
||||
*/
|
||||
private Integer distributeLevel;
|
||||
/**
|
||||
* 推广订单金额
|
||||
*/
|
||||
private Double marketingorderMoney;
|
||||
/**
|
||||
* 已提现金额
|
||||
*/
|
||||
private Double alreadytokenMoney;
|
||||
/**
|
||||
* 未提现金额
|
||||
*/
|
||||
private Double untokenMoney;
|
||||
/**
|
||||
* 上级推广人
|
||||
*/
|
||||
private String superiorPromoter;
|
||||
/**
|
||||
* 提现次数
|
||||
*/
|
||||
private Integer takeTimes;
|
||||
/**
|
||||
* 佣兵总金额
|
||||
*/
|
||||
private Double mercenarieMoney;
|
||||
/**
|
||||
* 推广用户数量
|
||||
*/
|
||||
private Integer marketinguserNumber;
|
||||
/**
|
||||
* 推广订单数量
|
||||
*/
|
||||
private Integer marketingorderNumber;
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package cn.iocoder.yudao.module.trade.dal.mysql.distributemanage;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.distributemanage.DistributeManageDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.trade.controller.admin.distributemanage.vo.*;
|
||||
|
||||
/**
|
||||
* 分销员管理 Mapper
|
||||
*
|
||||
* @author 管理员
|
||||
*/
|
||||
@Mapper
|
||||
public interface DistributeManageMapper extends BaseMapperX<DistributeManageDO> {
|
||||
|
||||
default PageResult<DistributeManageDO> selectPage(DistributeManagePageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<DistributeManageDO>()
|
||||
.eqIfPresent(DistributeManageDO::getGoodImage, reqVO.getGoodImage())
|
||||
.eqIfPresent(DistributeManageDO::getUserInformation, reqVO.getUserInformation())
|
||||
.eqIfPresent(DistributeManageDO::getDistributeLevel, reqVO.getDistributeLevel())
|
||||
.eqIfPresent(DistributeManageDO::getMarketingorderMoney, reqVO.getMarketingorderMoney())
|
||||
.eqIfPresent(DistributeManageDO::getAlreadytokenMoney, reqVO.getAlreadytokenMoney())
|
||||
.eqIfPresent(DistributeManageDO::getUntokenMoney, reqVO.getUntokenMoney())
|
||||
.eqIfPresent(DistributeManageDO::getSuperiorPromoter, reqVO.getSuperiorPromoter())
|
||||
.eqIfPresent(DistributeManageDO::getTakeTimes, reqVO.getTakeTimes())
|
||||
.eqIfPresent(DistributeManageDO::getMercenarieMoney, reqVO.getMercenarieMoney())
|
||||
.eqIfPresent(DistributeManageDO::getMarketinguserNumber, reqVO.getMarketinguserNumber())
|
||||
.eqIfPresent(DistributeManageDO::getMarketingorderNumber, reqVO.getMarketingorderNumber())
|
||||
.orderByDesc(DistributeManageDO::getId));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package cn.iocoder.yudao.module.trade.service.distributemanage;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import cn.iocoder.yudao.module.trade.controller.admin.distributemanage.vo.*;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.distributemanage.DistributeManageDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
|
||||
/**
|
||||
* 分销员管理 Service 接口
|
||||
*
|
||||
* @author 管理员
|
||||
*/
|
||||
public interface DistributeManageService {
|
||||
|
||||
/**
|
||||
* 创建分销员管理
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createDistributeManage(@Valid DistributeManageSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新分销员管理
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateDistributeManage(@Valid DistributeManageSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除分销员管理
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteDistributeManage(Long id);
|
||||
|
||||
/**
|
||||
* 获得分销员管理
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 分销员管理
|
||||
*/
|
||||
DistributeManageDO getDistributeManage(Long id);
|
||||
|
||||
/**
|
||||
* 获得分销员管理分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 分销员管理分页
|
||||
*/
|
||||
PageResult<DistributeManageDO> getDistributeManagePage(DistributeManagePageReqVO pageReqVO);
|
||||
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
package cn.iocoder.yudao.module.trade.service.distributemanage;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.trade.controller.admin.distributemanage.vo.*;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.distributemanage.DistributeManageDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import cn.iocoder.yudao.module.trade.dal.mysql.distributemanage.DistributeManageMapper;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 分销员管理 Service 实现类
|
||||
*
|
||||
* @author 管理员
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class DistributeManageServiceImpl implements DistributeManageService {
|
||||
|
||||
@Resource
|
||||
private DistributeManageMapper distributeManageMapper;
|
||||
|
||||
@Override
|
||||
public Long createDistributeManage(DistributeManageSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
DistributeManageDO distributeManage = BeanUtils.toBean(createReqVO, DistributeManageDO.class);
|
||||
distributeManageMapper.insert(distributeManage);
|
||||
// 返回
|
||||
return distributeManage.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDistributeManage(DistributeManageSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateDistributeManageExists(updateReqVO.getId());
|
||||
// 更新
|
||||
DistributeManageDO updateObj = BeanUtils.toBean(updateReqVO, DistributeManageDO.class);
|
||||
distributeManageMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteDistributeManage(Long id) {
|
||||
// 校验存在
|
||||
validateDistributeManageExists(id);
|
||||
// 删除
|
||||
distributeManageMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateDistributeManageExists(Long id) {
|
||||
if (distributeManageMapper.selectById(id) == null) {
|
||||
throw exception(DISTRIBUTE_MANAGE_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DistributeManageDO getDistributeManage(Long id) {
|
||||
return distributeManageMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<DistributeManageDO> getDistributeManagePage(DistributeManagePageReqVO pageReqVO) {
|
||||
return distributeManageMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.iocoder.yudao.module.trade.dal.mysql.distributemanage.DistributeManageMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
@ -0,0 +1,170 @@
|
||||
package cn.iocoder.yudao.module.trade.service.distributemanage;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
|
||||
import cn.iocoder.yudao.module.trade.controller.admin.distributemanage.vo.*;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.distributemanage.DistributeManageDO;
|
||||
import cn.iocoder.yudao.module.trade.dal.mysql.distributemanage.DistributeManageMapper;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.hutool.core.util.RandomUtil.*;
|
||||
import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
/**
|
||||
* {@link DistributeManageServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author 管理员
|
||||
*/
|
||||
@Import(DistributeManageServiceImpl.class)
|
||||
public class DistributeManageServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private DistributeManageServiceImpl distributeManageService;
|
||||
|
||||
@Resource
|
||||
private DistributeManageMapper distributeManageMapper;
|
||||
|
||||
@Test
|
||||
public void testCreateDistributeManage_success() {
|
||||
// 准备参数
|
||||
DistributeManageSaveReqVO createReqVO = randomPojo(DistributeManageSaveReqVO.class).setId(null);
|
||||
|
||||
// 调用
|
||||
Long distributeManageId = distributeManageService.createDistributeManage(createReqVO);
|
||||
// 断言
|
||||
assertNotNull(distributeManageId);
|
||||
// 校验记录的属性是否正确
|
||||
DistributeManageDO distributeManage = distributeManageMapper.selectById(distributeManageId);
|
||||
assertPojoEquals(createReqVO, distributeManage, "id");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateDistributeManage_success() {
|
||||
// mock 数据
|
||||
DistributeManageDO dbDistributeManage = randomPojo(DistributeManageDO.class);
|
||||
distributeManageMapper.insert(dbDistributeManage);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
DistributeManageSaveReqVO updateReqVO = randomPojo(DistributeManageSaveReqVO.class, o -> {
|
||||
o.setId(dbDistributeManage.getId()); // 设置更新的 ID
|
||||
});
|
||||
|
||||
// 调用
|
||||
distributeManageService.updateDistributeManage(updateReqVO);
|
||||
// 校验是否更新正确
|
||||
DistributeManageDO distributeManage = distributeManageMapper.selectById(updateReqVO.getId()); // 获取最新的
|
||||
assertPojoEquals(updateReqVO, distributeManage);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateDistributeManage_notExists() {
|
||||
// 准备参数
|
||||
DistributeManageSaveReqVO updateReqVO = randomPojo(DistributeManageSaveReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> distributeManageService.updateDistributeManage(updateReqVO), DISTRIBUTE_MANAGE_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteDistributeManage_success() {
|
||||
// mock 数据
|
||||
DistributeManageDO dbDistributeManage = randomPojo(DistributeManageDO.class);
|
||||
distributeManageMapper.insert(dbDistributeManage);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
Long id = dbDistributeManage.getId();
|
||||
|
||||
// 调用
|
||||
distributeManageService.deleteDistributeManage(id);
|
||||
// 校验数据不存在了
|
||||
assertNull(distributeManageMapper.selectById(id));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteDistributeManage_notExists() {
|
||||
// 准备参数
|
||||
Long id = randomLongId();
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> distributeManageService.deleteDistributeManage(id), DISTRIBUTE_MANAGE_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetDistributeManagePage() {
|
||||
// mock 数据
|
||||
DistributeManageDO dbDistributeManage = randomPojo(DistributeManageDO.class, o -> { // 等会查询到
|
||||
o.setGoodImage(null);
|
||||
o.setUserInformation(null);
|
||||
o.setDistributeLevel(null);
|
||||
o.setMarketingorderMoney(null);
|
||||
o.setAlreadytokenMoney(null);
|
||||
o.setUntokenMoney(null);
|
||||
o.setSuperiorPromoter(null);
|
||||
o.setTakeTimes(null);
|
||||
o.setMercenarieMoney(null);
|
||||
o.setMarketinguserNumber(null);
|
||||
o.setMarketingorderNumber(null);
|
||||
});
|
||||
distributeManageMapper.insert(dbDistributeManage);
|
||||
// 测试 goodImage 不匹配
|
||||
distributeManageMapper.insert(cloneIgnoreId(dbDistributeManage, o -> o.setGoodImage(null)));
|
||||
// 测试 userInformation 不匹配
|
||||
distributeManageMapper.insert(cloneIgnoreId(dbDistributeManage, o -> o.setUserInformation(null)));
|
||||
// 测试 distributeLevel 不匹配
|
||||
distributeManageMapper.insert(cloneIgnoreId(dbDistributeManage, o -> o.setDistributeLevel(null)));
|
||||
// 测试 marketingorderMoney 不匹配
|
||||
distributeManageMapper.insert(cloneIgnoreId(dbDistributeManage, o -> o.setMarketingorderMoney(null)));
|
||||
// 测试 alreadytokenMoney 不匹配
|
||||
distributeManageMapper.insert(cloneIgnoreId(dbDistributeManage, o -> o.setAlreadytokenMoney(null)));
|
||||
// 测试 untokenMoney 不匹配
|
||||
distributeManageMapper.insert(cloneIgnoreId(dbDistributeManage, o -> o.setUntokenMoney(null)));
|
||||
// 测试 superiorPromoter 不匹配
|
||||
distributeManageMapper.insert(cloneIgnoreId(dbDistributeManage, o -> o.setSuperiorPromoter(null)));
|
||||
// 测试 takeTimes 不匹配
|
||||
distributeManageMapper.insert(cloneIgnoreId(dbDistributeManage, o -> o.setTakeTimes(null)));
|
||||
// 测试 mercenarieMoney 不匹配
|
||||
distributeManageMapper.insert(cloneIgnoreId(dbDistributeManage, o -> o.setMercenarieMoney(null)));
|
||||
// 测试 marketinguserNumber 不匹配
|
||||
distributeManageMapper.insert(cloneIgnoreId(dbDistributeManage, o -> o.setMarketinguserNumber(null)));
|
||||
// 测试 marketingorderNumber 不匹配
|
||||
distributeManageMapper.insert(cloneIgnoreId(dbDistributeManage, o -> o.setMarketingorderNumber(null)));
|
||||
// 准备参数
|
||||
DistributeManagePageReqVO reqVO = new DistributeManagePageReqVO();
|
||||
reqVO.setGoodImage(null);
|
||||
reqVO.setUserInformation(null);
|
||||
reqVO.setDistributeLevel(null);
|
||||
reqVO.setMarketingorderMoney(null);
|
||||
reqVO.setAlreadytokenMoney(null);
|
||||
reqVO.setUntokenMoney(null);
|
||||
reqVO.setSuperiorPromoter(null);
|
||||
reqVO.setTakeTimes(null);
|
||||
reqVO.setMercenarieMoney(null);
|
||||
reqVO.setMarketinguserNumber(null);
|
||||
reqVO.setMarketingorderNumber(null);
|
||||
|
||||
// 调用
|
||||
PageResult<DistributeManageDO> pageResult = distributeManageService.getDistributeManagePage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbDistributeManage, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user