Skip to content

Commit 74de8e9

Browse files
committed
trade:优化交易配置的参数校验
1 parent 2f82eff commit 74de8e9

File tree

2 files changed

+45
-18
lines changed

2 files changed

+45
-18
lines changed

src/utils/constants.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -278,24 +278,28 @@ export const PromotionDiscountTypeEnum = {
278278
*/
279279
export const BrokerageBindModeEnum = {
280280
ANYTIME: {
281-
mode: 0,
282-
name: '没有推广人'
281+
mode: 1,
282+
name: '首次绑定'
283283
},
284284
REGISTER: {
285-
mode: 1,
286-
name: '新用户'
285+
mode: 2,
286+
name: '注册绑定'
287+
},
288+
OVERRIDE: {
289+
mode: 3,
290+
name: '覆盖绑定'
287291
}
288292
}
289293
/**
290294
* 分佣模式枚举
291295
*/
292296
export const BrokerageEnabledConditionEnum = {
293297
ALL: {
294-
condition: 0,
298+
condition: 1,
295299
name: '人人分销'
296300
},
297301
ADMIN: {
298-
condition: 1,
302+
condition: 2,
299303
name: '指定分销'
300304
}
301305
}

src/views/mall/trade/config/index.vue

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<el-form-item label="hideId" v-show="false">
1111
<el-input v-model="formData.id" />
1212
</el-form-item>
13-
13+
<!-- 配送 -->
1414
<el-tabs>
1515
<el-tab-pane label="配送">
1616
<el-form-item label="启用包邮" prop="deliveryExpressFreeEnabled">
@@ -22,10 +22,15 @@
2222
v-model="formData.deliveryExpressFreePrice"
2323
placeholder="请输入满额包邮"
2424
class="!w-xs"
25+
:precision="2"
26+
:min="0"
2527
/>
26-
<el-text class="w-full" size="small" type="info"> 商城商品满多少金额即可包邮 </el-text>
28+
<el-text class="w-full" size="small" type="info">
29+
商城商品满多少金额即可包邮,单位:元
30+
</el-text>
2731
</el-form-item>
2832
</el-tab-pane>
33+
<!-- 分销 -->
2934
<el-tab-pane label="分销">
3035
<el-form-item label="分佣启用" prop="brokerageEnabled">
3136
<el-switch v-model="formData.brokerageEnabled" style="user-select: none" />
@@ -59,23 +64,25 @@
5964
</el-radio>
6065
</el-radio-group>
6166
<el-text class="w-full" size="small" type="info">
62-
没有推广人:只要用户没有推广人,随时都可以绑定推广关系
67+
首次绑定:只要用户没有推广人,随时都可以绑定推广关系
6368
</el-text>
6469
<el-text class="w-full" size="small" type="info">
65-
新用户:只有新用户注册时或首次进入系统时才可以绑定推广关系
70+
注册绑定:只有新用户注册时或首次进入系统时才可以绑定推广关系
6671
</el-text>
6772
</el-form-item>
6873
<el-form-item label="分销海报图">
6974
<UploadImgs v-model="formData.brokeragePosterUrls" width="75px" height="125px" />
7075
<el-text class="w-full" size="small" type="info">
71-
个人中心分销海报图片,建议尺寸600x1000
76+
个人中心分销海报图片,建议尺寸 600x1000
7277
</el-text>
7378
</el-form-item>
7479
<el-form-item label="一级返佣比例" prop="brokerageFirstPercent">
7580
<el-input-number
7681
v-model="formData.brokerageFirstPercent"
7782
placeholder="请输入一级返佣比例"
7883
class="!w-xs"
84+
:min="0"
85+
:max="100"
7986
/>
8087
<el-text class="w-full" size="small" type="info">
8188
订单交易成功后给推广人返佣的百分比
@@ -86,6 +93,8 @@
8693
v-model="formData.brokerageSecondPercent"
8794
placeholder="请输入二级返佣比例"
8895
class="!w-xs"
96+
:min="0"
97+
:max="100"
8998
/>
9099
<el-text class="w-full" size="small" type="info">
91100
订单交易成功后给推广人的推荐人返佣的百分比
@@ -96,6 +105,7 @@
96105
v-model="formData.brokerageFrozenDays"
97106
placeholder="请输入佣金冻结天数"
98107
class="!w-xs"
108+
:min="0"
99109
/>
100110
<el-text class="w-full" size="small" type="info">
101111
防止用户退款,佣金被提现了,所以需要设置佣金冻结时间,单位:天
@@ -106,6 +116,8 @@
106116
v-model="formData.brokerageWithdrawMinPrice"
107117
placeholder="请输入提现最低金额"
108118
class="!w-xs"
119+
:precision="2"
120+
:min="0"
109121
/>
110122
<el-text class="w-full" size="small" type="info">
111123
用户提现最低金额限制,单位:元
@@ -116,9 +128,12 @@
116128
v-model="formData.brokerageWithdrawFeePercent"
117129
placeholder="请输入提现手续费"
118130
class="!w-xs"
131+
:min="0"
132+
:max="100"
119133
/>
120134
<el-text class="w-full" size="small" type="info">
121-
提现手续费百分比,范围0-100,0为无提现手续费,例:设置10,即收取10%手续费,提现100元,到账90元,10元手续费
135+
提现手续费百分比,范围 0-100,0 为无提现手续费。例:设置 10,即收取 10% 手续费,提现
136+
10 元,到账 9 元,1 元手续费
122137
</el-text>
123138
</el-form-item>
124139
<el-form-item label="提现方式" prop="brokerageWithdrawTypes">
@@ -146,7 +161,7 @@
146161
</el-form-item>
147162
</el-tab-pane>
148163
</el-tabs>
149-
164+
<!-- 保存 -->
150165
<el-form-item>
151166
<el-button type="primary" @click="submitForm" :loading="formLoading"> 保存 </el-button>
152167
</el-form-item>
@@ -167,11 +182,11 @@ const formLoading = ref(false) // 表单的加载中:1)修改时的数据加
167182
const formRef = ref()
168183
const formData = ref({
169184
id: null,
170-
deliveryExpressFreeEnabled: true,
185+
deliveryExpressFreeEnabled: false,
171186
deliveryExpressFreePrice: 0,
172-
brokerageEnabled: true,
173-
brokerageEnabledCondition: BrokerageEnabledConditionEnum.ALL.condition,
174-
brokerageBindMode: BrokerageBindModeEnum.ANYTIME.mode,
187+
brokerageEnabled: false,
188+
brokerageEnabledCondition: undefined,
189+
brokerageBindMode: undefined,
175190
brokeragePosterUrls: [],
176191
brokerageFirstPercent: 0,
177192
brokerageSecondPercent: 0,
@@ -211,10 +226,15 @@ const submitForm = async () => {
211226
// 提交请求
212227
formLoading.value = true
213228
try {
214-
const data = formData.value as unknown as ConfigApi.ConfigVO
229+
const data = {
230+
...formData.value
231+
} as unknown as ConfigApi.ConfigVO
215232
data.brokeragePosterUrls = formData.value.brokeragePosterUrls.map((item: any) => {
216233
return item?.url ? item.url : item
217234
})
235+
// 金额放大
236+
data.deliveryExpressFreePrice = data.deliveryExpressFreePrice * 100
237+
data.brokerageWithdrawMinPrice = data.brokerageWithdrawMinPrice * 100
218238
await ConfigApi.saveTradeConfig(data)
219239
message.success('保存成功')
220240
} finally {
@@ -230,6 +250,9 @@ const getConfig = async () => {
230250
if (data != null) {
231251
data.brokeragePosterUrls = data.brokeragePosterUrls.map((url) => ({ url }))
232252
formData.value = data
253+
// 金额缩小
254+
formData.value.deliveryExpressFreePrice = data.deliveryExpressFreePrice / 100
255+
formData.value.brokerageWithdrawMinPrice = data.brokerageWithdrawMinPrice / 100
233256
}
234257
} finally {
235258
formLoading.value = false

0 commit comments

Comments
 (0)