GuardMarket

commerce.tiered_pricing

阶梯用量定价

Apply graduated pricing to each tier's incremental quantity, rounding each band's cost to cents; final tier must cover quantity.

Version 1.0.0确定性数据处理Backend required

使用场景 / Purpose

Commerce: tiered pricing. 本技能对提供的参数执行计算,输入输出契约如下。文档例子来自已实现函数的固定验收样例;网页本身不执行代码。

输入字段 / Parameters

字段类型要求约束与说明
quantity"integer"必填 Required{"minimum": 0, "maximum": 1000000}
tiers"array"必填 Required{"items": {"type": "object", "properties": {"up_to": {"type": "integer", "minimum": 1, "maximum": 1000000}, "unit_price": {"type": "string", "minLength": 1, "maxLength": 32}}, "required": ["up_to", "unit_price"], "additionalProperties": false, "maxProperties": 1000}, "minItems": 1, "maxItems": 100}

输入例子 / Example input

{
  "quantity": 15,
  "tiers": [
    {
      "up_to": 10,
      "unit_price": "2.00"
    },
    {
      "up_to": 100,
      "unit_price": "1.00"
    }
  ]
}

预期输出 / Expected output

{
  "bands": [
    {
      "quantity": 10,
      "unit_price": "2.00",
      "cost": "20.00"
    },
    {
      "quantity": 5,
      "unit_price": "1.00",
      "cost": "5.00"
    }
  ],
  "total": "25.00"
}
完整输入 JSON Schema
{
  "type": "object",
  "properties": {
    "quantity": {
      "type": "integer",
      "minimum": 0,
      "maximum": 1000000
    },
    "tiers": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "up_to": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1000000
          },
          "unit_price": {
            "type": "string",
            "minLength": 1,
            "maxLength": 32
          }
        },
        "required": [
          "up_to",
          "unit_price"
        ],
        "additionalProperties": false,
        "maxProperties": 1000
      },
      "minItems": 1,
      "maxItems": 100
    }
  },
  "required": [
    "quantity",
    "tiers"
  ],
  "additionalProperties": false,
  "maxProperties": 1000
}
完整输出 JSON Schema
{
  "type": "object",
  "properties": {
    "bands": {
      "type": "array",
      "items": {
        "type": [
          "object",
          "array",
          "string",
          "number",
          "boolean",
          "null"
        ],
        "maxProperties": 1000,
        "maxItems": 1000,
        "maxLength": 60000,
        "minimum": -1e+100,
        "maximum": 1e+100
      },
      "minItems": 0,
      "maxItems": 10000
    },
    "total": {
      "type": "string",
      "minLength": 0,
      "maxLength": 128000
    }
  },
  "required": [
    "bands",
    "total"
  ],
  "additionalProperties": false,
  "maxProperties": 1000
}