fix: remove gift heat from admin resources

This commit is contained in:
zhx 2026-06-05 13:57:36 +08:00
parent 58be420ae9
commit a33474ec5f
7 changed files with 3 additions and 36 deletions

View File

@ -86,7 +86,6 @@ test("resource APIs use generated admin paths", async () => {
giftId: "rose",
giftPointAmount: 1,
giftTypeCode: "normal",
heatValue: 1,
name: "Rose",
presentationJson: "{}",
priceVersion: "default",
@ -138,7 +137,6 @@ test("resource APIs use generated admin paths", async () => {
giftId: "rose",
giftPointAmount: 1,
giftTypeCode: "normal",
heatValue: 1,
name: "Rose",
presentationJson: "{}",
priceVersion: "default",

View File

@ -128,7 +128,6 @@ export interface GiftDto {
chargeAssetType?: string;
coinPrice?: number;
giftPointAmount?: number;
heatValue?: number;
effectiveFromMs?: number;
effectiveToMs?: number;
effectTypes?: string[];
@ -162,7 +161,6 @@ export interface GiftPayload {
chargeAssetType: string;
coinPrice: number;
giftPointAmount: number;
heatValue: number;
effectiveAtMs: number;
effectiveFromMs: number;
effectiveToMs: number;

View File

@ -113,7 +113,6 @@ const emptyGiftForm = (gift = {}) => ({
giftId: gift.giftId || "",
giftPointAmount: gift.giftPointAmount === 0 || gift.giftPointAmount ? String(gift.giftPointAmount) : "0",
giftTypeCode: gift.giftTypeCode || "normal",
heatValue: gift.heatValue === 0 || gift.heatValue ? String(gift.heatValue) : "0",
name: gift.name || "",
presentationJson: gift.presentationJson || "{}",
priceVersion: gift.priceVersion || "default",
@ -137,12 +136,10 @@ export function applyGiftResourceSelection(form, resource, fillIdentity = true)
export function applyGiftPriceDefaults(form, coinPrice) {
const priceValue = String(coinPrice ?? "");
const priceNumber = Number(priceValue);
return {
...form,
coinPrice: priceValue,
giftPointAmount: priceValue,
heatValue: priceValue.trim() && Number.isFinite(priceNumber) ? String(Math.ceil(priceNumber / 100)) : "",
};
}
@ -1420,7 +1417,6 @@ function buildGiftPayload(form) {
giftId: form.giftId.trim(),
giftPointAmount: Number(form.coinPrice || 0),
giftTypeCode: form.giftTypeCode,
heatValue: Number(form.heatValue || 0),
name: form.name.trim(),
presentationJson: form.presentationJson?.trim() || "{}",
priceVersion: form.priceVersion.trim(),

View File

@ -25,22 +25,19 @@ test("fills gift name and id from selected gift resource", () => {
});
});
test("fills gift points and heat from gift price", () => {
test("fills gift points from gift price", () => {
const form = {
coinPrice: "",
giftPointAmount: "0",
heatValue: "0",
name: "Rose",
};
expect(applyGiftPriceDefaults(form, "100")).toMatchObject({
coinPrice: "100",
giftPointAmount: "100",
heatValue: "1",
});
expect(applyGiftPriceDefaults(form, "101")).toMatchObject({
coinPrice: "101",
giftPointAmount: "101",
heatValue: "2",
});
});

View File

@ -72,14 +72,9 @@ const baseColumns = (giftTypeOptions) => [
},
{
key: "income",
label: "积分 / 热度",
label: "积分",
width: "minmax(140px, 0.8fr)",
render: (gift) => (
<div className={styles.stack}>
<span>{formatNumber(gift.giftPointAmount)}</span>
<span className={styles.meta}>{formatNumber(gift.heatValue)}</span>
</div>
),
render: (gift) => formatNumber(gift.giftPointAmount),
},
{
key: "regions",
@ -319,13 +314,6 @@ function GiftFormDialog({ disabled, form, loading, mode, onClose, onSubmit, open
<AdminFormFieldGrid columns="repeat(2, minmax(0, 1fr))">
<TextField disabled label="价格" required type="number" value={form.coinPrice} />
<TextField disabled label="积分" type="number" value={form.giftPointAmount} />
<TextField
disabled={disabled}
label="热度"
type="number"
value={form.heatValue}
onChange={(event) => page.setForm({ ...form, heatValue: event.target.value })}
/>
<TextField
disabled={disabled}
label="排序"

View File

@ -182,7 +182,6 @@ export const giftFormSchema = z
.min(1, "请选择礼物类型")
.max(32, "礼物类型不能超过 32 个字符")
.regex(/^[a-z][a-z0-9_]*$/, "礼物类型只能使用小写字母、数字和下划线"),
heatValue: z.union([z.string(), z.number()]).optional(),
name: z.string().trim().min(1, "请输入礼物名称").max(128, "礼物名称不能超过 128 个字符"),
presentationJson: z.string().trim().optional(),
priceVersion: z.string().trim().min(1, "请输入价格版本").max(64, "价格版本不能超过 64 个字符"),
@ -194,7 +193,6 @@ export const giftFormSchema = z
const resourceId = Number(value.resourceId);
const coinPrice = Number(value.coinPrice);
const giftPointAmount = Number(value.giftPointAmount || 0);
const heatValue = Number(value.heatValue || 0);
const effectiveFromMs = datetimeLocalToMs(value.effectiveFrom);
const effectiveToMs = datetimeLocalToMs(value.effectiveTo);
@ -226,13 +224,6 @@ export const giftFormSchema = z
path: ["giftPointAmount"],
});
}
if (!Number.isInteger(heatValue) || heatValue < 0) {
context.addIssue({
code: "custom",
message: "请输入有效热度",
path: ["heatValue"],
});
}
if (effectiveFromMs < 0) {
context.addIssue({
code: "custom",

View File

@ -130,7 +130,6 @@ describe("resource form schema", () => {
giftId: "rose",
giftPointAmount: "10",
giftTypeCode: "normal",
heatValue: "2",
name: "Rose",
presentationJson: "{}",
priceVersion: "default",