Skip to content

Commit e5a0f92

Browse files
tknsnail
authored andcommitted
feat: ✨ 营销管理-返佣比率
1 parent 62ac779 commit e5a0f92

10 files changed

Lines changed: 106 additions & 5 deletions

File tree

src/backend/NetAdmin/NetAdmin.Domain/DbMaps/Sys/Sys_UserInvite.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ public record Sys_UserInvite : VersionEntity, IFieldOwner
1414
[Navigate(nameof(OwnerId))]
1515
public IEnumerable<Sys_UserInvite> Children { get; init; }
1616

17+
/// <summary>
18+
/// 返佣比率
19+
/// </summary>
20+
[Column]
21+
[CsvIgnore]
22+
[JsonIgnore]
23+
public virtual int CommissionRatio { get; init; }
24+
1725
/// <summary>
1826
/// 归属
1927
/// </summary>

src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/UserInvite/CreateUserInviteReq.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,9 @@ namespace NetAdmin.Domain.Dto.Sys.UserInvite;
33
/// <summary>
44
/// 请求:创建用户邀请
55
/// </summary>
6-
public record CreateUserInviteReq : Sys_UserInvite;
6+
public record CreateUserInviteReq : Sys_UserInvite
7+
{
8+
/// <inheritdoc cref="Sys_UserInvite.CommissionRatio" />
9+
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
10+
public override int CommissionRatio { get; init; }
11+
}

src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/UserInvite/QueryUserInviteRsp.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ public record QueryUserInviteRsp : Sys_UserInvite
1010
/// <inheritdoc cref="Sys_UserInvite.Children" />
1111
public new virtual IEnumerable<QueryUserInviteRsp> Children { get; init; }
1212

13+
/// <inheritdoc cref="Sys_UserInvite.CommissionRatio" />
14+
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
15+
public override int CommissionRatio { get; init; }
16+
1317
/// <inheritdoc cref="IFieldCreatedTime.CreatedTime" />
1418
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
1519
public override DateTime CreatedTime { get; init; }
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace NetAdmin.Domain.Dto.Sys.UserInvite;
2+
3+
/// <summary>
4+
/// 请求:设置返佣比率
5+
/// </summary>
6+
public record SetCommissionRatioReq : CreateUserInviteReq
7+
{
8+
/// <inheritdoc cref="EntityBase{T}.Id" />
9+
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
10+
public override long Id { get; init; }
11+
12+
/// <inheritdoc cref="IFieldVersion.Version" />
13+
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
14+
public override long Version { get; init; }
15+
}

src/backend/NetAdmin/NetAdmin.SysComponent.Application/Modules/Sys/IUserInviteModule.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,10 @@ public interface IUserInviteModule : ICrudModule<CreateUserInviteReq, QueryUserI
99
, EditUserInviteReq // 编辑类型
1010
, QueryUserInviteReq, QueryUserInviteRsp // 查询类型
1111
, DelReq // 删除类型
12-
>;
12+
>
13+
{
14+
/// <summary>
15+
/// 设置返佣比率
16+
/// </summary>
17+
Task<int> SetCommissionRatioAsync(SetCommissionRatioReq req);
18+
}

src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/UserInviteService.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@ public async Task<IEnumerable<QueryUserInviteRsp>> QueryAsync(QueryReq<QueryUser
108108
return ret.Adapt<IEnumerable<QueryUserInviteRsp>>();
109109
}
110110

111+
/// <inheritdoc />
112+
public Task<int> SetCommissionRatioAsync(SetCommissionRatioReq req)
113+
{
114+
req.ThrowIfInvalid();
115+
return UpdateAsync(req with { CommissionRatio = req.CommissionRatio }, [nameof(req.CommissionRatio)], null, a => a.Id == req.Id, null, true);
116+
}
117+
111118
private ISelect<Sys_UserInvite> QueryInternal(QueryReq<QueryUserInviteReq> req)
112119
{
113120
var ret = Rpo.Select.WhereDynamicFilter(req.DynamicFilter).WhereDynamic(req.Filter);

src/backend/NetAdmin/NetAdmin.SysComponent.Cache/Sys/UserInviteCache.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,10 @@ public Task<IEnumerable<QueryUserInviteRsp>> QueryAsync(QueryReq<QueryUserInvite
6565
{
6666
return Service.QueryAsync(req);
6767
}
68+
69+
/// <inheritdoc />
70+
public Task<int> SetCommissionRatioAsync(SetCommissionRatioReq req)
71+
{
72+
return Service.SetCommissionRatioAsync(req);
73+
}
6874
}

src/backend/NetAdmin/NetAdmin.SysComponent.Host/Controllers/Sys/UserInviteController.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,12 @@ public Task<IEnumerable<QueryUserInviteRsp>> QueryAsync(QueryReq<QueryUserInvite
9393
{
9494
return Cache.QueryAsync(req);
9595
}
96+
97+
/// <summary>
98+
/// 设置返佣比率
99+
/// </summary>
100+
public Task<int> SetCommissionRatioAsync(SetCommissionRatioReq req)
101+
{
102+
return Cache.SetCommissionRatioAsync(req);
103+
}
96104
}

src/frontend/admin/src/api/sys/userinvite.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,15 @@ export default {
103103
return await http.post(this.url, data, config)
104104
},
105105
},
106+
107+
/**
108+
* 设置返佣比率
109+
*/
110+
setCommissionRatio: {
111+
url: `${config.API_URL}/api/sys/user.invite/set.commission.ratio`,
112+
name: `设置返佣比率`,
113+
post: async function (data = {}, config = {}) {
114+
return await http.post(this.url, data, config)
115+
},
116+
},
106117
}

src/frontend/admin/src/views/sys/invite/index.vue

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,16 @@
4444
</el-icon>
4545
</el-button>
4646
<template #dropdown>
47-
<el-dropdown-menu> </el-dropdown-menu>
47+
<el-dropdown-menu>
48+
<el-dropdown-item @click="setCommissionRatio">设置返佣比率</el-dropdown-item>
49+
</el-dropdown-menu>
4850
</template>
4951
</el-dropdown>
5052
</div>
5153
</el-header>
5254
<el-main class="nopadding">
5355
<scTable
54-
:context-menus="['id', 'user.userName', 'createdTime']"
56+
:context-menus="['id', 'user.userName', 'createdTime', 'commissionRatio']"
5557
:context-opers="[]"
5658
:default-sort="{ prop: 'sort', order: 'descending' }"
5759
:params="query"
@@ -73,7 +75,13 @@
7375
<el-table-column type="selection" width="50" />
7476
<el-table-column :label="$t('用户编号')" prop="id" sortable="custom" />
7577
<naColAvatar :label="$t('用户名')" prop="user.userName" />
76-
<el-table-column :label="$t('注册时间')" prop="createdTime" sortable="custom" />
78+
<el-table-column
79+
:formatter="(row) => `${(row.commissionRatio / 100).toFixed(2)}%`"
80+
:label="$t('返佣比率')"
81+
align="right"
82+
prop="commissionRatio"
83+
sortable="custom" />
84+
<el-table-column :label="$t('注册时间')" align="right" prop="createdTime" sortable="custom" />
7785
</scTable>
7886
</el-main>
7987
</el-container>
@@ -117,6 +125,29 @@ export default {
117125
},
118126
inject: ['reload'],
119127
methods: {
128+
async setCommissionRatio() {
129+
let loading
130+
try {
131+
const prompt = await this.$prompt(this.$t('1 代表 0.01%'), this.$t('设置返佣比率'), {
132+
inputPattern: /^[0-9]\d*$/,
133+
inputErrorMessage: this.$t('返佣比率不正确'),
134+
})
135+
loading = this.$loading()
136+
const res = await Promise.all(
137+
this.selection.map((x) => this.$API.sys_userinvite.setCommissionRatio.post(Object.assign(x, { commissionRatio: prompt.value }))),
138+
)
139+
this.$message.success(
140+
this.$t(`操作成功 {count}/{total} 项`, {
141+
count: this.selection.length,
142+
total: res.map((x) => x.data ?? 0).reduce((a, b) => a + b, 0),
143+
}),
144+
)
145+
this.$refs.table.refresh()
146+
} catch {
147+
//
148+
}
149+
loading?.close()
150+
},
120151
async getStatistics() {
121152
this.statistics.total = this.$refs.table?.tableData?.length
122153
},

0 commit comments

Comments
 (0)