Files
hi-frontend/packages/ui/src/services/admin/lottery.ts
T
shanshanzhong147 a30d83505f feat(抽奖): 开放人工奖(crypto/physical/manual_other) + 领奖工单管理 + REST 对齐
- prize-form: 解禁 crypto/physical/manual_other 并加各自 config;权重改为中奖概率(%),
  合计校验;vpn_duration 加"无订阅时新建订阅套餐"
- prize-grid: 概率合计=100% 校验告警;卡片渲染真实 config(时长/金额)
- claims-panel(新): 领奖工单列表 + 审核通过/驳回/标记发放
- activity-detail: 新增"领奖工单"Tab
- service: 奖品改/删 id 走 /prizes/:id(对齐后端 REST);新增 claims 5 个接口 + 类型
- i18n: 补齐 zh-CN/en-US lottery 文案

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-17 00:19:03 -07:00

376 lines
9.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/* eslint-disable */
import request from "@workspace/ui/lib/request";
/**
* 创建抽奖活动
* POST /v1/admin/lottery/activities
* @param body - 创建抽奖活动请求参数
* @param options - 可选的请求配置
* @returns 创建结果
*/
export async function createLotteryActivity(
body: API.CreateLotteryActivityRequest,
options?: { [key: string]: any }
) {
return request<API.Response & { data?: API.LotteryActivity }>(
`${import.meta.env.VITE_API_PREFIX || ""}/v1/admin/lottery/activities`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
data: body,
...(options || {}),
}
);
}
/**
* 更新抽奖活动
* PUT /v1/admin/lottery/activities
* @param body - 更新抽奖活动请求参数
* @param options - 可选的请求配置
* @returns 更新结果
*/
export async function updateLotteryActivity(
body: API.UpdateLotteryActivityRequest,
options?: { [key: string]: any }
) {
return request<API.Response & { data?: API.LotteryActivity }>(
`${import.meta.env.VITE_API_PREFIX || ""}/v1/admin/lottery/activities`,
{
method: "PUT",
headers: {
"Content-Type": "application/json",
},
data: body,
...(options || {}),
}
);
}
/**
* 获取抽奖活动分页列表
* GET /v1/admin/lottery/activities
* @param params - 分页及筛选参数
* @param options - 可选的请求配置
* @returns 抽奖活动列表及总数
*/
export async function getLotteryActivityList(
params: API.GetLotteryActivityListParams,
options?: { [key: string]: any }
) {
return request<API.Response & { data?: API.GetLotteryActivityListResponse }>(
`${import.meta.env.VITE_API_PREFIX || ""}/v1/admin/lottery/activities`,
{
method: "GET",
params: {
...params,
},
...(options || {}),
}
);
}
/**
* 获取抽奖活动详情
* GET /v1/admin/lottery/activities/detail
* @param params - 活动 ID 参数
* @param options - 可选的请求配置
* @returns 抽奖活动详情
*/
export async function getLotteryActivityDetail(
params: API.GetLotteryActivityDetailParams,
options?: { [key: string]: any }
) {
return request<API.Response & { data?: API.LotteryActivity }>(
`${import.meta.env.VITE_API_PREFIX || ""}/v1/admin/lottery/activities/detail`,
{
method: "GET",
params: {
...params,
},
...(options || {}),
}
);
}
/**
* 上架抽奖活动(draft → running
* POST /v1/admin/lottery/activities/publish
* @param body - 上架活动请求参数
* @param options - 可选的请求配置
* @returns 上架结果
*/
export async function publishLotteryActivity(
body: API.PublishLotteryActivityRequest,
options?: { [key: string]: any }
) {
return request<API.Response & { data?: any }>(
`${import.meta.env.VITE_API_PREFIX || ""}/v1/admin/lottery/activities/publish`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
data: body,
...(options || {}),
}
);
}
/**
* 暂停抽奖活动
* POST /v1/admin/lottery/activities/pause
* @param body - 暂停活动请求参数
* @param options - 可选的请求配置
* @returns 暂停结果
*/
export async function pauseLotteryActivity(
body: API.PauseLotteryActivityRequest,
options?: { [key: string]: any }
) {
return request<API.Response & { data?: any }>(
`${import.meta.env.VITE_API_PREFIX || ""}/v1/admin/lottery/activities/pause`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
data: body,
...(options || {}),
}
);
}
/**
* 更新抽奖活动规则(eligibility + chance_sources
* PUT /v1/admin/lottery/activities/rules
* @param body - 更新活动规则请求参数
* @param options - 可选的请求配置
* @returns 更新结果
*/
export async function updateLotteryActivityRules(
body: API.UpdateLotteryActivityRulesRequest,
options?: { [key: string]: any }
) {
return request<API.Response & { data?: any }>(
`${import.meta.env.VITE_API_PREFIX || ""}/v1/admin/lottery/activities/rules`,
{
method: "PUT",
headers: {
"Content-Type": "application/json",
},
data: body,
...(options || {}),
}
);
}
/**
* 创建抽奖奖品
* POST /v1/admin/lottery/prizes
* @param body - 创建奖品请求参数
* @param options - 可选的请求配置
* @returns 创建结果
*/
export async function createLotteryPrize(
body: API.CreateLotteryPrizeRequest,
options?: { [key: string]: any }
) {
return request<API.Response & { data?: API.LotteryPrize }>(
`${import.meta.env.VITE_API_PREFIX || ""}/v1/admin/lottery/prizes`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
data: body,
...(options || {}),
}
);
}
/**
* 更新抽奖奖品
* PUT /v1/admin/lottery/prizes
* @param body - 更新奖品请求参数
* @param options - 可选的请求配置
* @returns 更新结果
*/
export async function updateLotteryPrize(
body: API.UpdateLotteryPrizeRequest,
options?: { [key: string]: any }
) {
const { id, ...rest } = body;
return request<API.Response & { data?: API.LotteryPrize }>(
`${import.meta.env.VITE_API_PREFIX || ""}/v1/admin/lottery/prizes/${id}`,
{
method: "PUT",
headers: {
"Content-Type": "application/json",
},
data: rest,
...(options || {}),
}
);
}
/**
* 删除抽奖奖品
* DELETE /v1/admin/lottery/prizes
* @param body - 删除奖品请求参数
* @param options - 可选的请求配置
* @returns 删除结果
*/
export async function deleteLotteryPrize(
body: API.DeleteLotteryPrizeRequest,
options?: { [key: string]: any }
) {
return request<API.Response & { data?: any }>(
`${import.meta.env.VITE_API_PREFIX || ""}/v1/admin/lottery/prizes/${body.id}`,
{
method: "DELETE",
...(options || {}),
}
);
}
/**
* 获取抽奖奖品列表
* GET /v1/admin/lottery/prizes
* @param params - 活动 ID 筛选参数
* @param options - 可选的请求配置
* @returns 奖品列表
*/
export async function getLotteryPrizeList(
params: API.GetLotteryPrizeListParams,
options?: { [key: string]: any }
) {
return request<API.Response & { data?: API.GetLotteryPrizeListResponse }>(
`${import.meta.env.VITE_API_PREFIX || ""}/v1/admin/lottery/prizes`,
{
method: "GET",
params: {
...params,
},
...(options || {}),
}
);
}
/**
* 手动发放抽奖次数
* POST /v1/admin/lottery/chances/grant
* @param body - 发放次数请求参数(source_ref 为幂等键)
* @param options - 可选的请求配置
* @returns 发放结果
*/
export async function grantLotteryChances(
body: API.GrantLotteryChancesRequest,
options?: { [key: string]: any }
) {
return request<API.Response & { data?: any }>(
`${import.meta.env.VITE_API_PREFIX || ""}/v1/admin/lottery/chances/grant`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
data: body,
...(options || {}),
}
);
}
/**
* 领奖工单列表(Stage 2 人工奖)
* GET /v1/admin/lottery/claims
*/
export async function getLotteryClaimList(
params: API.GetLotteryClaimListParams,
options?: { [key: string]: any }
) {
return request<API.Response & { data?: API.ListLotteryClaimsResponse }>(
`${import.meta.env.VITE_API_PREFIX || ""}/v1/admin/lottery/claims`,
{
method: "GET",
params: { ...params },
...(options || {}),
}
);
}
/**
* 领奖工单统计(各类型 reviewing/paying + 逾期)
* GET /v1/admin/lottery/claims/summary
*/
export async function getLotteryClaimsSummary(options?: {
[key: string]: any;
}) {
return request<API.Response & { data?: API.LotteryClaimsSummary }>(
`${import.meta.env.VITE_API_PREFIX || ""}/v1/admin/lottery/claims/summary`,
{
method: "GET",
...(options || {}),
}
);
}
/**
* 审核通过领奖工单(reviewing → paying
* POST /v1/admin/lottery/claims/approve
*/
export async function approveLotteryClaim(
body: API.ApproveLotteryClaimRequest,
options?: { [key: string]: any }
) {
return request<API.Response & { data?: any }>(
`${import.meta.env.VITE_API_PREFIX || ""}/v1/admin/lottery/claims/approve`,
{
method: "POST",
headers: { "Content-Type": "application/json" },
data: body,
...(options || {}),
}
);
}
/**
* 驳回领奖工单(reviewing/paying → rejectedreason 必填)
* POST /v1/admin/lottery/claims/reject
*/
export async function rejectLotteryClaim(
body: API.RejectLotteryClaimRequest,
options?: { [key: string]: any }
) {
return request<API.Response & { data?: any }>(
`${import.meta.env.VITE_API_PREFIX || ""}/v1/admin/lottery/claims/reject`,
{
method: "POST",
headers: { "Content-Type": "application/json" },
data: body,
...(options || {}),
}
);
}
/**
* 标记已发放(paying → paid),填 tx_hash / delivery_ref
* POST /v1/admin/lottery/claims/mark-paid
*/
export async function markPaidLotteryClaim(
body: API.MarkPaidLotteryClaimRequest,
options?: { [key: string]: any }
) {
return request<API.Response & { data?: any }>(
`${import.meta.env.VITE_API_PREFIX || ""}/v1/admin/lottery/claims/mark-paid`,
{
method: "POST",
headers: { "Content-Type": "application/json" },
data: body,
...(options || {}),
}
);
}