trade: 增加交易中心配置表

This commit is contained in:
owen 2023-09-05 22:31:35 +08:00
parent 73f8cef3b4
commit 35664d1f32
4 changed files with 235 additions and 139 deletions

View File

@ -0,0 +1,24 @@
import request from '@/config/axios'
export interface ConfigVO {
brokerageEnabled: boolean
brokerageEnabledCondition: number
brokerageBindMode: number
brokeragePostUrls: string
brokerageFirstPercent: number
brokerageSecondPercent: number
brokerageWithdrawMinPrice: number
brokerageBankNames: string
brokerageFrozenDays: number
brokerageWithdrawType: string
}
// 查询交易中心配置详情
export const getTradeConfig = async () => {
return await request.get({ url: `/trade/config/get` })
}
// 保存交易中心配置
export const saveTradeConfig = async (data: ConfigVO) => {
return await request.put({ url: `/trade/config/save`, data })
}

View File

@ -6,16 +6,6 @@ export interface ConfigVO {
tradeDeductUnitPrice: number tradeDeductUnitPrice: number
tradeDeductMaxPrice: number tradeDeductMaxPrice: number
tradeGivePoint: number tradeGivePoint: number
brokerageEnabled: boolean
brokerageEnabledCondition: number
brokerageBindMode: number
brokeragePostUrls: string[]
brokerageFirstPercent: number
brokerageSecondPercent: number
brokerageWithdrawMinPrice: number
brokerageBankNames: number[]
brokerageFrozenDays: number
brokerageWithdrawType: number[]
} }
// 查询积分设置详情 // 查询积分设置详情

View File

@ -0,0 +1,209 @@
<template>
<ContentWrap>
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
label-width="120px"
v-loading="formLoading"
>
<el-form-item label="hideId" v-show="false">
<el-input v-model="formData.id" />
</el-form-item>
<el-tabs>
<el-tab-pane label="分销">
<el-form-item label="分佣启用" prop="brokerageEnabled">
<el-switch v-model="formData.brokerageEnabled" style="user-select: none" />
<el-text class="w-full" size="small" type="info"> 商城是否开启分销模式 </el-text>
</el-form-item>
<el-form-item label="分佣模式" prop="brokerageEnabledCondition">
<el-radio-group v-model="formData.brokerageEnabledCondition">
<el-radio
v-for="dict in getIntDictOptions(DICT_TYPE.BROKERAGE_ENABLED_CONDITION)"
:key="dict.value"
:label="dict.value"
>
{{ dict.label }}
</el-radio>
</el-radio-group>
<el-text class="w-full" size="small" type="info">
人人分销每个用户都可以成为推广员
</el-text>
<el-text class="w-full" size="small" type="info">
指定分销仅可在后台手动设置推广员
</el-text>
</el-form-item>
<el-form-item label="分销关系绑定" prop="brokerageBindMode">
<el-radio-group v-model="formData.brokerageBindMode">
<el-radio
v-for="dict in getIntDictOptions(DICT_TYPE.BROKERAGE_BIND_MODE)"
:key="dict.value"
:label="dict.value"
>
{{ dict.label }}
</el-radio>
</el-radio-group>
<el-text class="w-full" size="small" type="info">
没有推广人只要用户没有推广人随时都可以绑定推广关系
</el-text>
<el-text class="w-full" size="small" type="info">
新用户只有新用户注册时或首次进入系统时才可以绑定推广关系
</el-text>
</el-form-item>
<el-form-item label="分销海报图">
<UploadImgs v-model="formData.brokeragePostUrls" width="75px" height="125px" />
<el-text class="w-full" size="small" type="info">
个人中心分销海报图片建议尺寸600x1000
</el-text>
</el-form-item>
<el-form-item label="一级返佣比例" prop="brokerageFirstPercent">
<el-input-number
v-model="formData.brokerageFirstPercent"
placeholder="请输入一级返佣比例"
/>
<el-text class="w-full" size="small" type="info">
订单交易成功后给推广人返佣的百分比
</el-text>
</el-form-item>
<el-form-item label="二级返佣比例" prop="brokerageSecondPercent">
<el-input-number
v-model="formData.brokerageSecondPercent"
placeholder="请输入二级返佣比例"
/>
<el-text class="w-full" size="small" type="info">
订单交易成功后给推广人的推荐人返佣的百分比
</el-text>
</el-form-item>
<el-form-item label="佣金冻结天数" prop="brokerageFrozenDays">
<el-input-number
v-model="formData.brokerageFrozenDays"
placeholder="请输入佣金冻结天数"
/>
<el-text class="w-full" size="small" type="info">
防止用户退款佣金被提现了所以需要设置佣金冻结时间单位
</el-text>
</el-form-item>
<el-form-item label="提现最低金额" prop="brokerageWithdrawMinPrice">
<el-input-number
v-model="formData.brokerageWithdrawMinPrice"
placeholder="请输入用户提现最低金额"
/>
<el-text class="w-full" size="small" type="info">
用户提现最低金额限制单位
</el-text>
</el-form-item>
<el-form-item label="提现方式" prop="brokerageWithdrawType">
<el-checkbox-group v-model="formData.brokerageWithdrawType">
<el-checkbox
v-for="dict in getIntDictOptions(DICT_TYPE.BROKERAGE_WITHDRAW_TYPE)"
:key="dict.value"
:label="dict.value"
>
{{ dict.label }}
</el-checkbox>
</el-checkbox-group>
<el-text class="w-full" size="small" type="info"> 商城开通提现的付款方式 </el-text>
</el-form-item>
<el-form-item label="提现银行" prop="brokerageBankNames">
<el-select v-model="formData.brokerageBankNames" placeholder="请选择提现银行" multiple>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.BROKERAGE_BANK_NAME)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
<el-text class="w-full" size="small" type="info"> 商城开通提现的银行列表 </el-text>
</el-form-item>
</el-tab-pane>
</el-tabs>
<el-form-item>
<el-button type="primary" @click="submitForm" :loading="formLoading"> 保存 </el-button>
</el-form-item>
</el-form>
</ContentWrap>
</template>
<script setup lang="ts">
import * as ConfigApi from '@/api/mall/trade/config'
import { BrokerageBindModeEnum, BrokerageEnabledConditionEnum } from '@/utils/constants'
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
defineOptions({ name: 'TradeConfig' })
const message = useMessage() //
const formLoading = ref(false) // 12
const formRef = ref()
const formData = ref({
brokerageEnabled: true,
brokerageEnabledCondition: BrokerageEnabledConditionEnum.ALL.condition,
brokerageBindMode: BrokerageBindModeEnum.ANYTIME.mode,
brokeragePostUrls: [],
brokerageFirstPercent: 0,
brokerageSecondPercent: 0,
brokerageWithdrawMinPrice: 0,
brokerageBankNames: [],
brokerageFrozenDays: 0,
brokerageWithdrawType: []
})
const formRules = reactive({
brokerageEnabledCondition: [{ required: true, message: '分佣模式不能为空', trigger: 'blur' }],
brokerageBindMode: [{ required: true, message: '分销关系绑定模式不能为空', trigger: 'blur' }],
brokerageFirstPercent: [{ required: true, message: '一级返佣比例不能为空', trigger: 'blur' }],
brokerageSecondPercent: [{ required: true, message: '二级返佣比例不能为空', trigger: 'blur' }],
brokerageWithdrawMinPrice: [
{ required: true, message: '用户提现最低金额不能为空', trigger: 'blur' }
],
brokerageBankNames: [{ required: true, message: '提现银行不能为空', trigger: 'blur' }],
brokerageFrozenDays: [{ required: true, message: '佣金冻结时间不能为空', trigger: 'blur' }],
brokerageWithdrawType: [
{
required: true,
message: '提现方式不能为空',
trigger: 'change'
}
]
})
const submitForm = async () => {
if (formLoading.value) return
//
if (!formRef) return
const valid = await formRef.value.validate()
if (!valid) return
//
formLoading.value = true
try {
const data = formData.value as unknown as ConfigApi.ConfigVO
data.brokeragePostUrls = formData.value.brokeragePostUrls.map((item: any) => {
return item?.url ? item.url : item
})
await ConfigApi.saveTradeConfig(data)
message.success('保存成功')
} finally {
formLoading.value = false
}
}
/** 查询交易中心配置 */
const getConfig = async () => {
formLoading.value = true
try {
const data = await ConfigApi.getTradeConfig()
if (data != null) {
data.brokeragePostUrls = data.brokeragePostUrls.map((url) => ({ url }))
formData.value = data
}
} finally {
formLoading.value = false
}
}
/** 初始化 **/
onMounted(() => {
getConfig()
})
</script>

View File

@ -13,7 +13,7 @@
<el-tabs> <el-tabs>
<el-tab-pane label="积分"> <el-tab-pane label="积分">
<el-form-item label="积分抵扣" prop="tradeDeductEnable" class="item-bottom"> <el-form-item label="积分抵扣" prop="tradeDeductEnable">
<el-switch v-model="formData.tradeDeductEnable" style="user-select: none" /> <el-switch v-model="formData.tradeDeductEnable" style="user-select: none" />
<el-text class="w-full" size="small" type="info">下单积分是否抵用订单金额</el-text> <el-text class="w-full" size="small" type="info">下单积分是否抵用订单金额</el-text>
</el-form-item> </el-form-item>
@ -46,111 +46,6 @@
</el-text> </el-text>
</el-form-item> </el-form-item>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="分销">
<el-form-item label="分佣启用" prop="brokerageEnabled">
<el-switch v-model="formData.brokerageEnabled" style="user-select: none" />
<el-text class="w-full" size="small" type="info"> 商城是否开启分销模式 </el-text>
</el-form-item>
<el-form-item label="分佣模式" prop="brokerageEnabledCondition">
<el-radio-group v-model="formData.brokerageEnabledCondition">
<el-radio
v-for="dict in getIntDictOptions(DICT_TYPE.BROKERAGE_ENABLED_CONDITION)"
:key="dict.value"
:label="dict.value"
>
{{ dict.label }}
</el-radio>
</el-radio-group>
<el-text class="w-full" size="small" type="info">
人人分销每个用户都可以成为推广员
</el-text>
<el-text class="w-full" size="small" type="info">
指定分销仅可在后台手动设置推广员
</el-text>
</el-form-item>
<el-form-item label="分销关系绑定" prop="brokerageBindMode">
<el-radio-group v-model="formData.brokerageBindMode">
<el-radio
v-for="dict in getIntDictOptions(DICT_TYPE.BROKERAGE_BIND_MODE)"
:key="dict.value"
:label="dict.value"
>
{{ dict.label }}
</el-radio>
</el-radio-group>
<el-text class="w-full" size="small" type="info">
没有推广人只要用户没有推广人随时都可以绑定推广关系
</el-text>
<el-text class="w-full" size="small" type="info">
新用户只有新用户注册时或首次进入系统时才可以绑定推广关系
</el-text>
</el-form-item>
<el-form-item label="分销海报图">
<UploadImgs v-model="formData.brokeragePostUrls" width="75px" height="125px" />
<el-text class="w-full" size="small" type="info">
个人中心分销海报图片建议尺寸600x1000
</el-text>
</el-form-item>
<el-form-item label="一级返佣比例" prop="brokerageFirstPercent">
<el-input-number
v-model="formData.brokerageFirstPercent"
placeholder="请输入一级返佣比例"
/>
<el-text class="w-full" size="small" type="info">
订单交易成功后给推广人返佣的百分比
</el-text>
</el-form-item>
<el-form-item label="二级返佣比例" prop="brokerageSecondPercent">
<el-input-number
v-model="formData.brokerageSecondPercent"
placeholder="请输入二级返佣比例"
/>
<el-text class="w-full" size="small" type="info">
订单交易成功后给推广人的推荐人返佣的百分比
</el-text>
</el-form-item>
<el-form-item label="佣金冻结天数" prop="brokerageFrozenDays">
<el-input-number
v-model="formData.brokerageFrozenDays"
placeholder="请输入佣金冻结天数"
/>
<el-text class="w-full" size="small" type="info">
防止用户退款佣金被提现了所以需要设置佣金冻结时间单位
</el-text>
</el-form-item>
<el-form-item label="提现最低金额" prop="brokerageWithdrawMinPrice">
<el-input-number
v-model="formData.brokerageWithdrawMinPrice"
placeholder="请输入用户提现最低金额"
/>
<el-text class="w-full" size="small" type="info">
用户提现最低金额限制单位
</el-text>
</el-form-item>
<el-form-item label="提现方式" prop="brokerageWithdrawType">
<el-checkbox-group v-model="formData.brokerageWithdrawType">
<el-checkbox
v-for="dict in getIntDictOptions(DICT_TYPE.BROKERAGE_WITHDRAW_TYPE)"
:key="dict.value"
:label="dict.value"
>
{{ dict.label }}
</el-checkbox>
</el-checkbox-group>
<el-text class="w-full" size="small" type="info"> 商城开通提现的付款方式 </el-text>
</el-form-item>
<el-form-item label="提现银行" prop="brokerageBankNames">
<el-select v-model="formData.brokerageBankNames" placeholder="请选择提现银行" multiple>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.BROKERAGE_BANK_NAME)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
<el-text class="w-full" size="small" type="info"> 商城开通提现的银行列表 </el-text>
</el-form-item>
</el-tab-pane>
</el-tabs> </el-tabs>
<el-form-item> <el-form-item>
@ -161,8 +56,6 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import * as ConfigApi from '@/api/member/point/config' import * as ConfigApi from '@/api/member/point/config'
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { BrokerageBindModeEnum, BrokerageEnabledConditionEnum } from '@/utils/constants'
defineOptions({ name: 'MemberPointConfig' }) defineOptions({ name: 'MemberPointConfig' })
@ -176,17 +69,7 @@ const formData = ref({
tradeDeductEnable: true, tradeDeductEnable: true,
tradeDeductUnitPrice: 0, tradeDeductUnitPrice: 0,
tradeDeductMaxPrice: 0, tradeDeductMaxPrice: 0,
tradeGivePoint: 0, tradeGivePoint: 0
brokerageEnabled: true,
brokerageEnabledCondition: BrokerageEnabledConditionEnum.ALL.condition,
brokerageBindMode: BrokerageBindModeEnum.ANYTIME.mode,
brokeragePostUrls: [],
brokerageFirstPercent: 0,
brokerageSecondPercent: 0,
brokerageWithdrawMinPrice: 0,
brokerageBankNames: [],
brokerageFrozenDays: 0,
brokerageWithdrawType: []
}) })
// tradeDeductUnitPrice // tradeDeductUnitPrice
@ -210,9 +93,6 @@ const onSubmit = async () => {
formLoading.value = true formLoading.value = true
try { try {
const data = formData.value as unknown as ConfigApi.ConfigVO const data = formData.value as unknown as ConfigApi.ConfigVO
data.brokeragePostUrls = formData.value.brokeragePostUrls.map((item: any) => {
return item?.url ? item.url : item
})
await ConfigApi.saveConfig(data) await ConfigApi.saveConfig(data)
message.success(t('common.updateSuccess')) message.success(t('common.updateSuccess'))
dialogVisible.value = false dialogVisible.value = false
@ -228,7 +108,6 @@ const getConfig = async () => {
if (data === null) { if (data === null) {
return return
} }
data.brokeragePostUrls = data.brokeragePostUrls.map((url) => ({ url }))
formData.value = data formData.value = data
} finally { } finally {
} }
@ -238,9 +117,3 @@ onMounted(() => {
getConfig() getConfig()
}) })
</script> </script>
<style scoped>
.item-bottom {
margin-bottom: 0;
}
</style>