mirror of
https://github.com/nsnail/NetAdmin.git
synced 2025-07-04 09:38:15 +08:00
feat: ✨ 营销管理-返佣比率
This commit is contained in:
@ -14,6 +14,14 @@ public record Sys_UserInvite : VersionEntity, IFieldOwner
|
|||||||
[Navigate(nameof(OwnerId))]
|
[Navigate(nameof(OwnerId))]
|
||||||
public IEnumerable<Sys_UserInvite> Children { get; init; }
|
public IEnumerable<Sys_UserInvite> Children { get; init; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 返佣比率
|
||||||
|
/// </summary>
|
||||||
|
[Column]
|
||||||
|
[CsvIgnore]
|
||||||
|
[JsonIgnore]
|
||||||
|
public virtual int CommissionRatio { get; init; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 归属
|
/// 归属
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -3,4 +3,9 @@ namespace NetAdmin.Domain.Dto.Sys.UserInvite;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 请求:创建用户邀请
|
/// 请求:创建用户邀请
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public record CreateUserInviteReq : Sys_UserInvite;
|
public record CreateUserInviteReq : Sys_UserInvite
|
||||||
|
{
|
||||||
|
/// <inheritdoc cref="Sys_UserInvite.CommissionRatio" />
|
||||||
|
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
|
||||||
|
public override int CommissionRatio { get; init; }
|
||||||
|
}
|
@ -10,6 +10,10 @@ public record QueryUserInviteRsp : Sys_UserInvite
|
|||||||
/// <inheritdoc cref="Sys_UserInvite.Children" />
|
/// <inheritdoc cref="Sys_UserInvite.Children" />
|
||||||
public new virtual IEnumerable<QueryUserInviteRsp> Children { get; init; }
|
public new virtual IEnumerable<QueryUserInviteRsp> Children { get; init; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="Sys_UserInvite.CommissionRatio" />
|
||||||
|
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
|
||||||
|
public override int CommissionRatio { get; init; }
|
||||||
|
|
||||||
/// <inheritdoc cref="IFieldCreatedTime.CreatedTime" />
|
/// <inheritdoc cref="IFieldCreatedTime.CreatedTime" />
|
||||||
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
|
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
|
||||||
public override DateTime CreatedTime { get; init; }
|
public override DateTime CreatedTime { get; init; }
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
namespace NetAdmin.Domain.Dto.Sys.UserInvite;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 请求:设置返佣比率
|
||||||
|
/// </summary>
|
||||||
|
public record SetCommissionRatioReq : CreateUserInviteReq
|
||||||
|
{
|
||||||
|
/// <inheritdoc cref="EntityBase{T}.Id" />
|
||||||
|
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
|
||||||
|
public override long Id { get; init; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="IFieldVersion.Version" />
|
||||||
|
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
|
||||||
|
public override long Version { get; init; }
|
||||||
|
}
|
@ -9,4 +9,10 @@ public interface IUserInviteModule : ICrudModule<CreateUserInviteReq, QueryUserI
|
|||||||
, EditUserInviteReq // 编辑类型
|
, EditUserInviteReq // 编辑类型
|
||||||
, QueryUserInviteReq, QueryUserInviteRsp // 查询类型
|
, QueryUserInviteReq, QueryUserInviteRsp // 查询类型
|
||||||
, DelReq // 删除类型
|
, DelReq // 删除类型
|
||||||
>;
|
>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 设置返佣比率
|
||||||
|
/// </summary>
|
||||||
|
Task<int> SetCommissionRatioAsync(SetCommissionRatioReq req);
|
||||||
|
}
|
@ -108,6 +108,13 @@ public sealed class UserInviteService(BasicRepository<Sys_UserInvite, long> rpo)
|
|||||||
return ret.Adapt<IEnumerable<QueryUserInviteRsp>>();
|
return ret.Adapt<IEnumerable<QueryUserInviteRsp>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public Task<int> SetCommissionRatioAsync(SetCommissionRatioReq req)
|
||||||
|
{
|
||||||
|
req.ThrowIfInvalid();
|
||||||
|
return UpdateAsync(req with { CommissionRatio = req.CommissionRatio }, [nameof(req.CommissionRatio)], null, a => a.Id == req.Id, null, true);
|
||||||
|
}
|
||||||
|
|
||||||
private ISelect<Sys_UserInvite> QueryInternal(QueryReq<QueryUserInviteReq> req)
|
private ISelect<Sys_UserInvite> QueryInternal(QueryReq<QueryUserInviteReq> req)
|
||||||
{
|
{
|
||||||
var ret = Rpo.Select.WhereDynamicFilter(req.DynamicFilter).WhereDynamic(req.Filter);
|
var ret = Rpo.Select.WhereDynamicFilter(req.DynamicFilter).WhereDynamic(req.Filter);
|
||||||
|
@ -65,4 +65,10 @@ public sealed class UserInviteCache(IDistributedCache cache, IUserInviteService
|
|||||||
{
|
{
|
||||||
return Service.QueryAsync(req);
|
return Service.QueryAsync(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public Task<int> SetCommissionRatioAsync(SetCommissionRatioReq req)
|
||||||
|
{
|
||||||
|
return Service.SetCommissionRatioAsync(req);
|
||||||
|
}
|
||||||
}
|
}
|
@ -93,4 +93,12 @@ public sealed class UserInviteController(IUserInviteCache cache) : ControllerBas
|
|||||||
{
|
{
|
||||||
return Cache.QueryAsync(req);
|
return Cache.QueryAsync(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设置返佣比率
|
||||||
|
/// </summary>
|
||||||
|
public Task<int> SetCommissionRatioAsync(SetCommissionRatioReq req)
|
||||||
|
{
|
||||||
|
return Cache.SetCommissionRatioAsync(req);
|
||||||
|
}
|
||||||
}
|
}
|
@ -103,4 +103,15 @@ export default {
|
|||||||
return await http.post(this.url, data, config)
|
return await http.post(this.url, data, config)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置返佣比率
|
||||||
|
*/
|
||||||
|
setCommissionRatio: {
|
||||||
|
url: `${config.API_URL}/api/sys/user.invite/set.commission.ratio`,
|
||||||
|
name: `设置返佣比率`,
|
||||||
|
post: async function (data = {}, config = {}) {
|
||||||
|
return await http.post(this.url, data, config)
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
@ -44,14 +44,16 @@
|
|||||||
</el-icon>
|
</el-icon>
|
||||||
</el-button>
|
</el-button>
|
||||||
<template #dropdown>
|
<template #dropdown>
|
||||||
<el-dropdown-menu> </el-dropdown-menu>
|
<el-dropdown-menu>
|
||||||
|
<el-dropdown-item @click="setCommissionRatio">设置返佣比率</el-dropdown-item>
|
||||||
|
</el-dropdown-menu>
|
||||||
</template>
|
</template>
|
||||||
</el-dropdown>
|
</el-dropdown>
|
||||||
</div>
|
</div>
|
||||||
</el-header>
|
</el-header>
|
||||||
<el-main class="nopadding">
|
<el-main class="nopadding">
|
||||||
<scTable
|
<scTable
|
||||||
:context-menus="['id', 'user.userName', 'createdTime']"
|
:context-menus="['id', 'user.userName', 'createdTime', 'commissionRatio']"
|
||||||
:context-opers="[]"
|
:context-opers="[]"
|
||||||
:default-sort="{ prop: 'sort', order: 'descending' }"
|
:default-sort="{ prop: 'sort', order: 'descending' }"
|
||||||
:params="query"
|
:params="query"
|
||||||
@ -73,7 +75,13 @@
|
|||||||
<el-table-column type="selection" width="50" />
|
<el-table-column type="selection" width="50" />
|
||||||
<el-table-column :label="$t('用户编号')" prop="id" sortable="custom" />
|
<el-table-column :label="$t('用户编号')" prop="id" sortable="custom" />
|
||||||
<naColAvatar :label="$t('用户名')" prop="user.userName" />
|
<naColAvatar :label="$t('用户名')" prop="user.userName" />
|
||||||
<el-table-column :label="$t('注册时间')" prop="createdTime" sortable="custom" />
|
<el-table-column
|
||||||
|
:formatter="(row) => `${(row.commissionRatio / 100).toFixed(2)}%`"
|
||||||
|
:label="$t('返佣比率')"
|
||||||
|
align="right"
|
||||||
|
prop="commissionRatio"
|
||||||
|
sortable="custom" />
|
||||||
|
<el-table-column :label="$t('注册时间')" align="right" prop="createdTime" sortable="custom" />
|
||||||
</scTable>
|
</scTable>
|
||||||
</el-main>
|
</el-main>
|
||||||
</el-container>
|
</el-container>
|
||||||
@ -117,6 +125,29 @@ export default {
|
|||||||
},
|
},
|
||||||
inject: ['reload'],
|
inject: ['reload'],
|
||||||
methods: {
|
methods: {
|
||||||
|
async setCommissionRatio() {
|
||||||
|
let loading
|
||||||
|
try {
|
||||||
|
const prompt = await this.$prompt(this.$t('1 代表 0.01%'), this.$t('设置返佣比率'), {
|
||||||
|
inputPattern: /^[0-9]\d*$/,
|
||||||
|
inputErrorMessage: this.$t('返佣比率不正确'),
|
||||||
|
})
|
||||||
|
loading = this.$loading()
|
||||||
|
const res = await Promise.all(
|
||||||
|
this.selection.map((x) => this.$API.sys_userinvite.setCommissionRatio.post(Object.assign(x, { commissionRatio: prompt.value }))),
|
||||||
|
)
|
||||||
|
this.$message.success(
|
||||||
|
this.$t(`操作成功 {count}/{total} 项`, {
|
||||||
|
count: this.selection.length,
|
||||||
|
total: res.map((x) => x.data ?? 0).reduce((a, b) => a + b, 0),
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
this.$refs.table.refresh()
|
||||||
|
} catch {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
loading?.close()
|
||||||
|
},
|
||||||
async getStatistics() {
|
async getStatistics() {
|
||||||
this.statistics.total = this.$refs.table?.tableData?.length
|
this.statistics.total = this.$refs.table?.tableData?.length
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user