fix: remove gift heat from admin resources
This commit is contained in:
parent
58be420ae9
commit
a33474ec5f
@ -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",
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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(),
|
||||
|
||||
@ -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",
|
||||
});
|
||||
});
|
||||
|
||||
@ -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="排序"
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -130,7 +130,6 @@ describe("resource form schema", () => {
|
||||
giftId: "rose",
|
||||
giftPointAmount: "10",
|
||||
giftTypeCode: "normal",
|
||||
heatValue: "2",
|
||||
name: "Rose",
|
||||
presentationJson: "{}",
|
||||
priceVersion: "default",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user