format amount split
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import type { PackageConfigStatus } from "@/types/Package";
|
||||
import type { FundOperationType, FundRecordStatus } from "@/types/SalesOrder";
|
||||
import { formatCentsAmount } from "@/utils/money";
|
||||
|
||||
/** 生成套餐业务幂等请求号。每次新操作必须重新生成。 */
|
||||
export function createPackageRequestNo(): string {
|
||||
@@ -8,14 +9,7 @@ export function createPackageRequestNo(): string {
|
||||
|
||||
/** 将分转换为金额展示文本,不用浮点数做金额格式化。 */
|
||||
export function formatPackageAmount(cents?: number | null): string {
|
||||
if (cents === undefined || cents === null) {
|
||||
return "未设置";
|
||||
}
|
||||
const negative = cents < 0;
|
||||
const absolute = Math.abs(Math.trunc(cents));
|
||||
const yuan = Math.floor(absolute / 100);
|
||||
const fen = String(absolute % 100).padStart(2, "0");
|
||||
return `${negative ? "-" : ""}${yuan}.${fen}`;
|
||||
return formatCentsAmount(cents);
|
||||
}
|
||||
|
||||
/** 将分转换为金额输入框文本。 */
|
||||
|
||||
Reference in New Issue
Block a user