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",
|
giftId: "rose",
|
||||||
giftPointAmount: 1,
|
giftPointAmount: 1,
|
||||||
giftTypeCode: "normal",
|
giftTypeCode: "normal",
|
||||||
heatValue: 1,
|
|
||||||
name: "Rose",
|
name: "Rose",
|
||||||
presentationJson: "{}",
|
presentationJson: "{}",
|
||||||
priceVersion: "default",
|
priceVersion: "default",
|
||||||
@ -138,7 +137,6 @@ test("resource APIs use generated admin paths", async () => {
|
|||||||
giftId: "rose",
|
giftId: "rose",
|
||||||
giftPointAmount: 1,
|
giftPointAmount: 1,
|
||||||
giftTypeCode: "normal",
|
giftTypeCode: "normal",
|
||||||
heatValue: 1,
|
|
||||||
name: "Rose",
|
name: "Rose",
|
||||||
presentationJson: "{}",
|
presentationJson: "{}",
|
||||||
priceVersion: "default",
|
priceVersion: "default",
|
||||||
|
|||||||
@ -128,7 +128,6 @@ export interface GiftDto {
|
|||||||
chargeAssetType?: string;
|
chargeAssetType?: string;
|
||||||
coinPrice?: number;
|
coinPrice?: number;
|
||||||
giftPointAmount?: number;
|
giftPointAmount?: number;
|
||||||
heatValue?: number;
|
|
||||||
effectiveFromMs?: number;
|
effectiveFromMs?: number;
|
||||||
effectiveToMs?: number;
|
effectiveToMs?: number;
|
||||||
effectTypes?: string[];
|
effectTypes?: string[];
|
||||||
@ -162,7 +161,6 @@ export interface GiftPayload {
|
|||||||
chargeAssetType: string;
|
chargeAssetType: string;
|
||||||
coinPrice: number;
|
coinPrice: number;
|
||||||
giftPointAmount: number;
|
giftPointAmount: number;
|
||||||
heatValue: number;
|
|
||||||
effectiveAtMs: number;
|
effectiveAtMs: number;
|
||||||
effectiveFromMs: number;
|
effectiveFromMs: number;
|
||||||
effectiveToMs: number;
|
effectiveToMs: number;
|
||||||
|
|||||||
@ -113,7 +113,6 @@ const emptyGiftForm = (gift = {}) => ({
|
|||||||
giftId: gift.giftId || "",
|
giftId: gift.giftId || "",
|
||||||
giftPointAmount: gift.giftPointAmount === 0 || gift.giftPointAmount ? String(gift.giftPointAmount) : "0",
|
giftPointAmount: gift.giftPointAmount === 0 || gift.giftPointAmount ? String(gift.giftPointAmount) : "0",
|
||||||
giftTypeCode: gift.giftTypeCode || "normal",
|
giftTypeCode: gift.giftTypeCode || "normal",
|
||||||
heatValue: gift.heatValue === 0 || gift.heatValue ? String(gift.heatValue) : "0",
|
|
||||||
name: gift.name || "",
|
name: gift.name || "",
|
||||||
presentationJson: gift.presentationJson || "{}",
|
presentationJson: gift.presentationJson || "{}",
|
||||||
priceVersion: gift.priceVersion || "default",
|
priceVersion: gift.priceVersion || "default",
|
||||||
@ -137,12 +136,10 @@ export function applyGiftResourceSelection(form, resource, fillIdentity = true)
|
|||||||
|
|
||||||
export function applyGiftPriceDefaults(form, coinPrice) {
|
export function applyGiftPriceDefaults(form, coinPrice) {
|
||||||
const priceValue = String(coinPrice ?? "");
|
const priceValue = String(coinPrice ?? "");
|
||||||
const priceNumber = Number(priceValue);
|
|
||||||
return {
|
return {
|
||||||
...form,
|
...form,
|
||||||
coinPrice: priceValue,
|
coinPrice: priceValue,
|
||||||
giftPointAmount: 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(),
|
giftId: form.giftId.trim(),
|
||||||
giftPointAmount: Number(form.coinPrice || 0),
|
giftPointAmount: Number(form.coinPrice || 0),
|
||||||
giftTypeCode: form.giftTypeCode,
|
giftTypeCode: form.giftTypeCode,
|
||||||
heatValue: Number(form.heatValue || 0),
|
|
||||||
name: form.name.trim(),
|
name: form.name.trim(),
|
||||||
presentationJson: form.presentationJson?.trim() || "{}",
|
presentationJson: form.presentationJson?.trim() || "{}",
|
||||||
priceVersion: form.priceVersion.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 = {
|
const form = {
|
||||||
coinPrice: "",
|
coinPrice: "",
|
||||||
giftPointAmount: "0",
|
giftPointAmount: "0",
|
||||||
heatValue: "0",
|
|
||||||
name: "Rose",
|
name: "Rose",
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(applyGiftPriceDefaults(form, "100")).toMatchObject({
|
expect(applyGiftPriceDefaults(form, "100")).toMatchObject({
|
||||||
coinPrice: "100",
|
coinPrice: "100",
|
||||||
giftPointAmount: "100",
|
giftPointAmount: "100",
|
||||||
heatValue: "1",
|
|
||||||
});
|
});
|
||||||
expect(applyGiftPriceDefaults(form, "101")).toMatchObject({
|
expect(applyGiftPriceDefaults(form, "101")).toMatchObject({
|
||||||
coinPrice: "101",
|
coinPrice: "101",
|
||||||
giftPointAmount: "101",
|
giftPointAmount: "101",
|
||||||
heatValue: "2",
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -72,14 +72,9 @@ const baseColumns = (giftTypeOptions) => [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "income",
|
key: "income",
|
||||||
label: "积分 / 热度",
|
label: "积分",
|
||||||
width: "minmax(140px, 0.8fr)",
|
width: "minmax(140px, 0.8fr)",
|
||||||
render: (gift) => (
|
render: (gift) => formatNumber(gift.giftPointAmount),
|
||||||
<div className={styles.stack}>
|
|
||||||
<span>{formatNumber(gift.giftPointAmount)}</span>
|
|
||||||
<span className={styles.meta}>{formatNumber(gift.heatValue)}</span>
|
|
||||||
</div>
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "regions",
|
key: "regions",
|
||||||
@ -319,13 +314,6 @@ function GiftFormDialog({ disabled, form, loading, mode, onClose, onSubmit, open
|
|||||||
<AdminFormFieldGrid columns="repeat(2, minmax(0, 1fr))">
|
<AdminFormFieldGrid columns="repeat(2, minmax(0, 1fr))">
|
||||||
<TextField disabled label="价格" required type="number" value={form.coinPrice} />
|
<TextField disabled label="价格" required type="number" value={form.coinPrice} />
|
||||||
<TextField disabled label="积分" type="number" value={form.giftPointAmount} />
|
<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
|
<TextField
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
label="排序"
|
label="排序"
|
||||||
|
|||||||
@ -182,7 +182,6 @@ export const giftFormSchema = z
|
|||||||
.min(1, "请选择礼物类型")
|
.min(1, "请选择礼物类型")
|
||||||
.max(32, "礼物类型不能超过 32 个字符")
|
.max(32, "礼物类型不能超过 32 个字符")
|
||||||
.regex(/^[a-z][a-z0-9_]*$/, "礼物类型只能使用小写字母、数字和下划线"),
|
.regex(/^[a-z][a-z0-9_]*$/, "礼物类型只能使用小写字母、数字和下划线"),
|
||||||
heatValue: z.union([z.string(), z.number()]).optional(),
|
|
||||||
name: z.string().trim().min(1, "请输入礼物名称").max(128, "礼物名称不能超过 128 个字符"),
|
name: z.string().trim().min(1, "请输入礼物名称").max(128, "礼物名称不能超过 128 个字符"),
|
||||||
presentationJson: z.string().trim().optional(),
|
presentationJson: z.string().trim().optional(),
|
||||||
priceVersion: z.string().trim().min(1, "请输入价格版本").max(64, "价格版本不能超过 64 个字符"),
|
priceVersion: z.string().trim().min(1, "请输入价格版本").max(64, "价格版本不能超过 64 个字符"),
|
||||||
@ -194,7 +193,6 @@ export const giftFormSchema = z
|
|||||||
const resourceId = Number(value.resourceId);
|
const resourceId = Number(value.resourceId);
|
||||||
const coinPrice = Number(value.coinPrice);
|
const coinPrice = Number(value.coinPrice);
|
||||||
const giftPointAmount = Number(value.giftPointAmount || 0);
|
const giftPointAmount = Number(value.giftPointAmount || 0);
|
||||||
const heatValue = Number(value.heatValue || 0);
|
|
||||||
const effectiveFromMs = datetimeLocalToMs(value.effectiveFrom);
|
const effectiveFromMs = datetimeLocalToMs(value.effectiveFrom);
|
||||||
const effectiveToMs = datetimeLocalToMs(value.effectiveTo);
|
const effectiveToMs = datetimeLocalToMs(value.effectiveTo);
|
||||||
|
|
||||||
@ -226,13 +224,6 @@ export const giftFormSchema = z
|
|||||||
path: ["giftPointAmount"],
|
path: ["giftPointAmount"],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (!Number.isInteger(heatValue) || heatValue < 0) {
|
|
||||||
context.addIssue({
|
|
||||||
code: "custom",
|
|
||||||
message: "请输入有效热度",
|
|
||||||
path: ["heatValue"],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (effectiveFromMs < 0) {
|
if (effectiveFromMs < 0) {
|
||||||
context.addIssue({
|
context.addIssue({
|
||||||
code: "custom",
|
code: "custom",
|
||||||
|
|||||||
@ -130,7 +130,6 @@ describe("resource form schema", () => {
|
|||||||
giftId: "rose",
|
giftId: "rose",
|
||||||
giftPointAmount: "10",
|
giftPointAmount: "10",
|
||||||
giftTypeCode: "normal",
|
giftTypeCode: "normal",
|
||||||
heatValue: "2",
|
|
||||||
name: "Rose",
|
name: "Rose",
|
||||||
presentationJson: "{}",
|
presentationJson: "{}",
|
||||||
priceVersion: "default",
|
priceVersion: "default",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user