设置针对特定员工的价格或特定时间的价格

以下教程介绍了如何实现 Feed,以根据关联的工作人员、时段和/或星期几区分服务价格。

每名教职员工/时段的价格

需要设置以下 4 项:

  • 在商家 Feed 中,为每个价格选项设置一个 Merchant.payment_option

    • 将所需的 price 设置为特定时间/员工的服务价格
    • payment_option_id 在整个集成中必须是唯一的,因为 payment_option_id 值将在同一集合商家的所有商家之间共享。为了避免产生任何混淆并简化问题排查和管理,我们建议您为每个商家(重新)定义该商家通过唯一 payment_option_id 使用的所有 payment_option 值(即使其他商家使用了相同的 payment_option)。

      • 对于按教职员工价格,我们建议您将 payment_option_id 作为 merchant_idservice_idstaff_id 的组合生成,以便更轻松地进行跟踪并确保 payment_option_id 在整个集成中是唯一的
      • 对于按时价格,我们建议您将 merchant_idservice_id 和表示此时间的字符串(eveningweekendssundayafternoon ...)的组合生成 payment_option_id,以便更轻松地进行跟踪并确保 payment_option_id 在整个集成中具有唯一性
      • 当用于可用性级价格(本教程的用例)时,名称和说明主要用于调试目的
      • 请勿为单个商家设置超过 100 个 payment_option 值。如果您希望实现超过 100 个 payment_option 值,请让您的 Google 联系人运行此实现
      • 对于此用例,可以忽略所有其他 payment_option 字段
  • 在可用性 Feed 中,将 Availability.payment_option_id 设置为单项数组(其中包含您在 Merchant 级别定义的 payment_optionpayment_option_id

  • 在服务 Feed 中,将 Service.price 设置为此服务价格范围的最低值,并将 Service.price_interpretation 设置为 STARTS_AT

每位教职员工价格示例

在此示例中,Robert(ID:1)是比 Jane 更有经验的理发师(ID:2),因此沙龙所有者决定为 Robert 预订价格更高的 5 美元。短发的费用默认为 20 美元,长发的费用默认为 30 美元。如果用户选择 Robert,则扣除费用分别为 25 美元或 35 美元。

工作人员姓名 短发 长发理发
Jane $20* $30*
Robert $25 $35

*默认服务价格

商家

{
  "metadata": {
    "processing_instruction": "PROCESS_AS_COMPLETE",
    "generation_timestamp": 1503638100,
    "total_shards": 1
  },
  "merchant": [
    {
      "category": "beauty_salon",
      "merchant_id": "beauty-per-staff-price",
      "name": "Beauty Salon",
      "url": "www.merchantspublicsite.com",
      "telephone": "+1 123-456-7890",
      "geo": {
        "latitude": 37.422113,
        "longitude": -122.084041,
        "address": {
          "locality": "Mountain View",
          "country": "US",
          "region": "CA",
          "street_address": "1600 Amphitheatre Pkwy",
          "postal_code": "94043"
        }
      },
      "payment_option": [
        {
          "payment_option_id": "beauty-per-staff-price-haircut-short-1",
          "name": "Short haircut (Robert)",
          "description": "Short hair haircut price for Robert",
          "price": {
            "currency_code": "USD",
            "price_micros": 25000000
          }
        },
        {
          "payment_option_id": "beauty-per-staff-price-haircut-short-default",
          "name": "Short haircut (Default)",
          "description": "Normal short hair haircut price",
          "price": {
            "currency_code": "USD",
            "price_micros": 20000000
          }
        },
        {
          "payment_option_id": "beauty-per-staff-price-haircut-long-1",
          "name": "Long haircut (Robert)",
          "description": "Long hair haircut price for Robert",
          "price": {
            "currency_code": "USD",
            "price_micros": 35000000
          }
        },
        {
          "payment_option_id": "beauty-per-staff-price-haircut-long-default",
          "name": "Long haircut (Default)",
          "description": "Normal long hair haircut price",
          "price": {
            "currency_code": "USD",
            "price_micros": 30000000
          }
        }
      ]
    }
  ]
}

服务

{
  "metadata": {
    "processing_instruction": "PROCESS_AS_COMPLETE",
    "generation_timestamp": 1535437200,
    "total_shards": 1
  },
  "service": [
    {
      "service_id": "haircut-short",
      "prepayment_type": "NOT_SUPPORTED",
      "merchant_id": "beauty-per-staff-price",
      "price": {
        "currency_code": "USD",
        "price_micros": 20000000
      },
      "localized_service_name": {
        "value": "Haircut (shorter than shoulder)",
        "localized_value": [
          {
            "locale": "en",
            "value": "Haircut (shorter than shoulder)"
          }
        ]
      },
      "localized_description": {
        "value": "Awesome haircut for short hair",
        "localized_value": [
          {
            "locale": "en",
            "value": "Awesome haircut for short hair"
          }
        ]
      }
    },
    {
      "service_id": "haircut-long",
      "prepayment_type": "NOT_SUPPORTED",
      "merchant_id": "beauty-per-staff-price",
      "price": {
        "currency_code": "USD",
        "price_micros": 30000000
      },
      "localized_service_name": {
        "value": "Haircut (longer than shoulder)",
        "localized_value": [
          {
            "locale": "en",
            "value": "Haircut (longer than shoulder)"
          }
        ]
      },
      "localized_description": {
        "value": "Awesome haircut for long hair",
        "localized_value": [
          {
            "locale": "en",
            "value": "Awesome haircut for long hair"
          }
        ]
      }
    }
  ]
}

可用性

{
  "metadata": {
    "processing_instruction": "PROCESS_AS_COMPLETE",
    "generation_timestamp": 1535178900,
    "total_shards": 1
  },
  "service_availability": [
    {
      "availability": [
        {
          "spots_total": 1,
          "start_sec": 1535806800,
          "spots_open": 1,
          "duration_sec": 3600,
          "recurrence": {
            "repeat_until_sec": 1535846340,
            "repeat_every_sec": 3600
          },
          "service_id": "haircut-short",
          "merchant_id": "beauty-per-staff-price",
          "resources": {
            "staff_name": "Robert",
            "staff_id": "1"
          },
          "payment_option_id": ["beauty-per-staff-price-haircut-short-1"]
        },
        {
          "spots_total": 1,
          "start_sec": 1535806800,
          "spots_open": 1,
          "duration_sec": 3600,
          "recurrence": {
            "repeat_until_sec": 1535846340,
            "repeat_every_sec": 3600
          },
          "service_id": "haircut-long",
          "merchant_id": "beauty-per-staff-price",
          "resources": {
            "staff_name": "Robert",
            "staff_id": "1"
          },
          "payment_option_id": ["beauty-per-staff-price-haircut-long-1"]
        },
        {
          "spots_total": 1,
          "start_sec": 1535806800,
          "spots_open": 1,
          "duration_sec": 3600,
          "recurrence": {
            "repeat_until_sec": 1535846340,
            "repeat_every_sec": 3600
          },
          "service_id": "haircut-short",
          "merchant_id": "beauty-per-staff-price",
          "resources": {
            "staff_name": "Jane",
            "staff_id": "2"
          },
          "payment_option_id": ["beauty-per-staff-price-haircut-short-default"]
        },
        {
          "spots_total": 1,
          "start_sec": 1535806800,
          "spots_open": 1,
          "duration_sec": 3600,
          "recurrence": {
            "repeat_until_sec": 1535846340,
            "repeat_every_sec": 3600
          },
          "service_id": "haircut-long",
          "merchant_id": "beauty-per-staff-price",
          "resources": {
            "staff_name": "Jane",
            "staff_id": "2"
          },
          "payment_option_id": ["beauty-per-staff-price-haircut-long-default"]
        }
      ]
    }
  ]
}

按时间计费示例

在此示例中,发廊从 10:00 营业到 20:00。沙龙店主决定在 18:00 以后的预订额外收取 5 美元的费用。

可用性示例定义为 2018 年 9 月 1 日星期六(太平洋时间)。1535821200 是当天 10:00,1535850000 是当天 18:00,1535857200 是 20:00。

时段 短发 长发理发
10:00 ~ 11:00 $20 $30
11:00 ~ 12:00 $20 $30
中午 12:00 至 13:00 $20 $30
13:00 ~ 14:00 $20 $30
14:00 ~ 15:00 $20 $30
15:00 ~ 16:00 $20 $30
16:00 ~ 17:00 $20 $30
17:00 ~ 18:00 $20 $30
18:00 ~ 19:00 $25 $35
19:00 ~ 20:00 $25 $35

商家

{
  "metadata": {
    "processing_instruction": "PROCESS_AS_COMPLETE",
    "generation_timestamp": 1503638100,
    "total_shards": 1
  },
  "merchant": [
    {
      "category": "beauty_salon",
      "merchant_id": "beauty-per-time-price",
      "name": "Beauty Salon",
      "url": "www.merchantspublicsite.com",
      "telephone": "+1 123-456-7890",
      "geo": {
        "latitude": 37.422113,
        "longitude": -122.084041,
        "address": {
          "locality": "Mountain View",
          "country": "US",
          "region": "CA",
          "street_address": "1600 Amphitheatre Pkwy",
          "postal_code": "94043"
        }
      },
      "payment_option": [
        {
          "payment_option_id": "beauty-per-time-price-haircut-short-evening",
          "name": "Short haircut (Evening)",
          "description": "Short hair haircut price for the evening",
          "price": {
            "currency_code": "USD",
            "price_micros": 25000000
          }
        },
        {
          "payment_option_id": "beauty-per-time-price-haircut-short-default",
          "name": "Short haircut (Normal)",
          "description": "Short hair haircut price for the rest of the day",
          "price": {
            "currency_code": "USD",
            "price_micros": 21000000
          }
        },
        {
          "payment_option_id": "beauty-per-time-price-haircut-long-evening",
          "name": "Long haircut (Evening)",
          "description": "Long hair haircut price for the evening",
          "price": {
            "currency_code": "USD",
            "price_micros": 35000000
          }
        },
        {
          "payment_option_id": "beauty-per-time-price-haircut-long-default",
          "name": "Long haircut (Normal)",
          "description": "Long hair haircut price for the rest of the day",
          "price": {
            "currency_code": "USD",
            "price_micros": 31000000
          }
        }
      ]
    }
  ]
}

服务

{
  "metadata": {
    "processing_instruction": "PROCESS_AS_COMPLETE",
    "generation_timestamp": 1535437200,
    "total_shards": 1
  },
  "service": [
    {
      "service_id": "haircut-short",
      "prepayment_type": "NOT_SUPPORTED",
      "merchant_id": "beauty-per-time-price",
      "price": {
        "currency_code": "USD",
        "price_micros": 2100000
      },
      "localized_service_name": {
        "value": "Haircut (shorter than shoulder)",
        "localized_value": [
          {
            "locale": "en",
            "value": "Haircut (shorter than shoulder)"
          }
        ]
      },
      "localized_description": {
        "value": "Awesome haircut for short hair",
        "localized_value": [
          {
            "locale": "en",
            "value": "Awesome haircut for short hair"
          }
        ]
      }
    },
    {
      "service_id": "haircut-long",
      "prepayment_type": "NOT_SUPPORTED",
      "merchant_id": "beauty-per-time-price",
      "price": {
        "currency_code": "USD",
        "price_micros": 31000000
      },
      "localized_service_name": {
        "value": "Haircut (longer than shoulder)",
        "localized_value": [
          {
            "locale": "en",
            "value": "Haircut (longer than shoulder)"
          }
        ]
      },
      "localized_description": {
        "value": "Awesome haircut for long hair",
        "localized_value": [
          {
            "locale": "en",
            "value": "Awesome haircut for long hair"
          }
        ]
      }
    }
  ]
}

可用性

{
  "metadata": {
    "processing_instruction": "PROCESS_AS_COMPLETE",
    "generation_timestamp": 1535178900,
    "total_shards": 1
  },
  "service_availability": [
    {
      "availability": [
        {
          "spots_total": 1,
          "start_sec": 1535821200,
          "spots_open": 1,
          "duration_sec": 3600,
          "recurrence": {
            "repeat_until_sec": 1535849940,
            "repeat_every_sec": 3600
          },
          "service_id": "haircut-short",
          "merchant_id": "beauty-per-time-price",
          "payment_option_id": ["beauty-per-time-price-haircut-short-default"]
        },
        {
          "spots_total": 1,
          "start_sec": 1535821200,
          "spots_open": 1,
          "duration_sec": 3600,
          "recurrence": {
            "repeat_until_sec": 1535849940,
            "repeat_every_sec": 3600
          },
          "service_id": "haircut-long",
          "merchant_id": "beauty-per-time-price",
          "payment_option_id": ["beauty-per-time-price-haircut-long-default"]
        },
        {
          "spots_total": 1,
          "start_sec": 1535850000,
          "spots_open": 1,
          "duration_sec": 3600,
          "recurrence": {
            "repeat_until_sec": 1535857140,
            "repeat_every_sec": 3600
          },
          "service_id": "haircut-short",
          "merchant_id": "beauty-per-time-price",
          "payment_option_id": ["beauty-per-time-price-haircut-short-evening"]
        },
        {
          "spots_total": 1,
          "start_sec": 1535850000,
          "spots_open": 1,
          "duration_sec": 3600,
          "recurrence": {
            "repeat_until_sec": 1535857140,
            "repeat_every_sec": 3600
          },
          "service_id": "haircut-long",
          "merchant_id": "beauty-per-time-price",
          "payment_option_id": ["beauty-per-time-price-haircut-long-evening"]
        }
      ]
    }
  ]
}