Commerce 定價 API

本文介紹了 Microsoft Dynamics 365 Commerce 定價引擎所提供的各種定價 API。

Dynamics 365 Commerce 定價引擎提供以下零售伺服器 API,供外部應用程式支援各種定價情境:

  • GetActivePrices – 此 API 會取得產品的計算價格,包括簡單的折扣。
  • CalculateSalesDocument – 此 API 會計算指定數量產品的價格和折扣 (如果一起購買)。
  • GetAvailablePromotions – 此 API 能取得購物車中產品的適用折扣。
  • AddCoupons – 此 API 會將優惠券新增到購物車。
  • RemoveCoupons – 此 API 會從購物車中移除優惠券。

有關如何在外部應用程式中使用零售伺服器 API 的詳細資訊,請參閱在外部應用程式中使用零售伺服器 API

GetActivePrices

GetActivePrices API 是在 Commerce 版本 10.0.4 發行版本中引入的。 此 API 會取得產品的計算價格,包括簡單的折扣。 它不會計算多明細折扣,並它會假定 API 要求中的每個產品數量為 1。 該 API 還可以將產品的清單視為輸入,並大量查詢個別產品的價格。

GetActivePrices API 支援 員工客戶匿名應用程式 Commerce 角色。

GetActivePrices API 的主要使用案例是產品詳細資訊頁面 (PDP),零售商可在其中顯示產品的最佳價格,包括任何有效折扣。

備註

如果您發現 GetActivePrices 呼叫傳回的產品較少,您可以追蹤通路商品銷售設定驗證程式來驗證您的商品銷售設定。

下表顯示 GetActivePrices API 的輸入參數。

名稱 子名稱 類型 必要/選擇性 描述
projectDomain ProjectionDomain 必填
ChannelId long 必填
CatalogId long 必填
productIds IEnummer<long> 必填 要計算價格之產品的清單。
activeDate DateTimeOffset 必填 計算價格的日期。
customerId 字串 可選項目 客戶帳號。
affiliationLoyaltyTiers IEnumerable<AffiliationLoyaltyTier> 可選項目 入會和酬賓會員層級。
AffiliationId long 必填 入會識別碼。
LoyaltyTierId long 可選項目 酬賓會員層級識別碼。
includeSimpleDiscountsInContextualPrice 布林 可選項目 將此參數設定為 true 以在定價計算中包括簡單折扣。 預設值為 False
includeVariantPriceRange 布林 可選項目 將此參數設定為 true 以取得主產品所有變型中的最低和最高價格。 預設值為 False
includeAttainablePricesAndDiscounts 布林 可選項目 將此參數設定為 true 以取得可實現的價格和折扣。 預設值為 False
樣本要求本文
{
    "projectDomain": 
    {
        "ChannelId": 5637144592,
        "CatalogId": 0
    },
    "productIds": 
    [
        68719489871
    ],
    "activeDate": "2022-06-20T14:40:05.873+08:00",
    "includeSimpleDiscountsInContextualPrice": true,
    "includeVariantPriceRange": false
}
樣本回覆本文
{
    "value": 
    [
        {
            "ProductId": 68719489871,
            "ListingId": 68719489871,
            "BasePrice": 0,
            "TradeAgreementPrice": 0,
            "AdjustedPrice": 0,
            "MaxVariantPrice": 0,
            "MinVariantPrice": 0,
            "CustomerContextualPrice": 0,
            "DiscountAmount": 0,
            "CurrencyCode": "USD",
            "ItemId": "82000",
            "InventoryDimensionId": null,
            "UnitOfMeasure": "ea",
            "ValidFrom": "2022-06-20T01:40:05.873-05:00",
            "ProductLookupId": 0,
            "ChannelId": 5637144592,
            "CatalogId": 0,
            "SalesAgreementPrice": 0,
            "PriceSourceTypeValue": 1,
            "DiscountLines": [],
            "AttainablePriceLines": [],
        }
    ]
}

使用 PriceLookupContext

Commerce 10.0.37 版本引入了 PriceLookupContext 類別。 此類別包含 GetActivePrices API 的所有查詢條件。 它取代了之前的 productIds、activeDate、customerId 和 affiliationLoyaltyTiers 參數。 該類別還有額外的屬性,開發者可以在折扣查詢時用來篩選折扣。

根據貴組織的需求,GetActivePrices API 可以接受先前的參數,或是與 PriceLookupContext 類別相關的新參數。

輸入參數

名稱 子名稱 類型 必要/選擇性 描述
projectDomain ProjectionDomain 必填
ChannelId long 必填
CatalogId long 必填
priceLookupContext PriceLookupContext 必填
HeaderContext PriceLookupHeaderContext 必填 包含 CustomerAccountNumber、AffiliationLoyaltyTierLines 和 SalesOrderProperties
LineContexts IEnumerable<PriceLookupLineContext> 必填 包含 ProductRecordId、UnitOfMeasureSymbol、InventorySiteId、InventoryLocationId、DeliveryMode、CatalogId 及 SalesLineProperties。
includeSimpleDiscountsInContextualPrice 布林 可選項目 將此參數設定為 true 以在定價計算中包括簡單折扣。 預設值為 False
includeVariantPriceRange 布林 可選項目 將此參數設定為 true 以取得主產品所有變型中的最低和最高價格。 預設值為 False
includeAttainablePricesAndDiscounts 布林 可選項目 將此參數設定為 true 以取得可實現的價格和折扣。 預設值為 False

如需更多資訊,請參閱PriceLookupContext

CalculateSalesDocument

CalculateSalesDocument API 是在 Commerce 版本 10.0.25 發行版本中引入的。 此 API 會計算指定數量產品的價格和折扣 (如果一起放入訂單中)。 CalculateSalesDocument API 背後的定價計算同時考慮單行折扣與多行折扣。

CalculateSalesDocument API 的主要使用案例是完整購物車上下文不持續的情況下的定價計算 (例如銷售報價)。 銷售點 (POS) 和 Commerce 電子商務中的情境也可以從此使用案例中受益。 當購物車商品以一組計算(例如獨立組合、連結或推薦產品,或是已在購物車中的產品)時,較低的總價格可能會說服顧客將商品加入購物車。

CalculateSalesDocument API 的要求和回覆資料模型都是購物車。 但是,在此 API 的上下文中,資料模型名為 SalesDocument。 由於大多數屬性都是選用,且只有少數屬性會影響定價計算,因此下表中僅顯示與定價有關的欄位。 API 請求中不要包含其他欄位。

CalculateSalesDocument API 的範圍只是計算價格和折扣。 不涉及稅金和費用。

下表顯示輸入參數中名為 salesDocument 的物件。

名稱 子名稱 類型 必要/選擇性 描述
識別碼 字串 必填 銷售文件的識別碼。
CartLines IList<CartLine> 可選項目 要為其計算價格和折扣之明細的清單。
產品識別碼 long 在 CartLine 範圍內是必填 產品記錄識別碼。
品項識別碼 字串 可選項目 品項識別碼。 如果提供了值,則必須符合 ProductId 參數的值 。
InventoryDimensionId 字串 可選項目 庫存維度識別碼。 如果提供了值,則 ItemIdInventoryDimensionId 值的組合必須符合 ProductId 參數的值 。
數量 十進位 在 CartLine 範圍內是必填 產品的數量。
UnitOfMeasureSymbol 字串 可選項目 產品的單位。 根據預設,如果未提供值,則 API 會使用產品的銷售單位。
CustomerId 字串 可選項目 客戶帳號。
LoyaltyCardId 字串 可選項目 會員卡識別碼。 與會員卡有關的的任何客戶帳戶都必須符合 CustomerId 參數的值 (如果提供)。 如果未找到該會員卡或其狀態為已封鎖,則不加以考慮。
AffiliationLines IList<關聯忠誠等級> 可選項目 入會酬賓會員層級明細。 如果提供了 CustomerId 和/或 LoyaltyCardId 的值,則相應的入會酬賓會員層級明細將和在AffiliationLines 值中提供的明細合併。
AffiliationId long 在 AffiliationLoyaltyTier 範圍內是必填 入會記錄識別碼。
LoyaltyTierId long 在 AffiliationLoyaltyTier 範圍內是必填 酬賓會員層級紀錄識別碼。
AffiliationTypeValue int 在 AffiliationLoyaltyTier 範圍內是必填 一個指出入會明細是一般類型 (0) 或 酬賓會員類型 (1) 的值。 如果參數設定為 0,則 API 會將 AffiliationId 值作為識別碼,並忽略 LoyaltyTierId 值。 如果參數設定為 1,則 API 會將 LoyaltyTierId 值作為識別碼,並忽略 AffiliationId 值。
ReasonCodeLines 收藏<ReasonCodeLine> 在 AffiliationLoyaltyTier 範圍內是必填 原因代碼明細。 此參數對定價計算沒有影響,但作為 AffiliationLoyaltyTier 物件的一部分是必需的。
CustomerId 字串 在 AffiliationLoyaltyTier 範圍內是必填 客戶帳號。
優惠券 IList<優惠券> 可選項目 不適用 (無效、過期或未找到) 的優惠券不會在定價計算中被考慮。
Code 字串 在優惠券範圍內是必填 優惠券代碼。
CodeId 字串 可選項目 優惠券代碼識別碼。 如果提供了值,則必須符合 Code 參數的值 。
DiscountOfferId 字串 可選項目 折扣識別碼。 如果提供了值,則必須符合 Code 參數的值 。
樣本要求本文
{
    "salesDocument": 
    {
        "Id": "CalculateSalesDocument",
        "CartLines": 
        [
            {
                "ProductId": 68719491408,
                "ItemId": "91003",
                "InventoryDimensionId": "",
                "Quantity": 1,
                "UnitOfMeasureSymbol": "ea"
            },
            {
                "ProductId": 68719493014,
                "Quantity": 2,
                "UnitOfMeasureSymbol": "ea"
            }
        ],
        "CustomerId": "3003",
        "AffiliationLines": 
        [
            {
                "AffiliationId": 68719476742,
                "LoyaltyTierId": 0,
                "AffiliationTypeValue": 0,
                "ReasonCodeLines": [],
                "CustomerId": null
            }
        ],
        "LoyaltyCardId": "55103",
        "Coupons": 
        [
            {
                "CodeId": "CODE-0005",
                "Code": "CPN0004",
                "DiscountOfferId": "ST100077"
            }
        ]
    }
}

整個購物車物件將作為回覆本文傳回。 要查詢價格與折扣,請聚焦於下表中的欄位。

名稱 子名稱 類型 描述
NetPrice 十進位 套用任何折扣之前,整個銷售文件的凈價。
DiscountAmount 十進位 整個銷售文件的總折扣金額。
TotalAmount 十進位 整個銷售文件的總金額。
CartLines IList<CartLine> 包含價格和折扣詳細資訊的計算明細。
價格 十進位 產品的單價。
NetPrice 十進位 套用任何折扣之前,明細的凈價 (= 價格 × 數量) 。
DiscountAmount 十進位 折扣金額。
TotalAmount 十進位 明細的最終總定價結果。
PriceLines IList<價格線> 價格詳細資訊,包括價格來源 (基本價格、價格調整,或貿易協議) 和金額。
DiscountLines IList<折扣線> 折扣詳細資訊。

GetAvailablePromotions

有兩個類似的 GetAvailablePromotions API 可用:

  • Carts/GetAvailablePromotions 接受購物車行識別碼清單作為參數。
  • GetAvailablePromotions 接受 DiscountsSearchCriteria 物件作為參數。

Carts/GetAvailablePromotions

給定一個具有多條購物車明細的購物車,Carts/GetAvailablePromotions API 會傳回購物車明細的所有適用折扣。

Carts/GetAvailablePromotions API 的主要使用案例是購物車頁面,零售商可在其中顯示目前購物車套用的折扣或可用優惠券。

下表列出 Carts/GetAvailablePromotions API 的輸入參數。

名稱 類型 必要/選擇性 描述
Key 字串 必填 購物車識別碼。
cartLineIds IEnumerable<字串> 可選項目 設定此參數以僅傳回所選購物車明細的折扣。
樣本回覆本文
{
    "value": 
    [
        {
            "LineId": "f495ffa507bc4f63a47a409cd8713dd7",
            "Promotion": {
                "OfferId": "ST100012",
                "OfferName": "Loyalty 5% off over $100",
                "PeriodicDiscountTypeValue": 4,
                "IsDiscountCodeRequired": false,
                "ValidationPeriodId": null,
                "AdditionalRestrictions": null,
                "Description": "All loyalty members get 5% with transaction total above $10 unless some exclusive or best price discounts are already applied on the transaction",
                "ValidFromDate": "2022-06-20T06:52:56.2460219Z",
                "ValidToDate": "2022-06-20T06:52:56.2460224Z",
                "CouponCodes": [],
                "ValidationPeriod": null
            }
        }
    ]
}

GetAvailablePromotions

GetAvailablePromotions API 會傳回指定通路的所有適用折扣。

GetAvailablePromotions API 的主要使用情境是「所有折扣」頁面,零售商在此顯示目前頻道的所有折扣。

下表列出 GetAvailablePromotions API 的輸入參數。

名稱 子名稱 類型 必要/選擇性 描述
searchCriteria DiscountsSearchCriteria 必填
ChannelId long 必填
Keyword 字串 可選項目
IsDiscountCodeRequired 布林 可選項目 指出是否需要優惠券代碼。 若 null 通過,API 會取回所有折扣,不論優惠券代碼需求如何。
StartDate DateTimeOffset 必填 開始日期 (包括)。
EndDate DateTimeOffset 必填 結束日期 (包括)。
樣本要求本文
{
    "searchCriteria": {
        "ChannelId": 5637144592,
        "StartDate": "1900-01-01T00:00:00Z",
        "EndDate": "2154-12-31T00:00:00Z"
    }
}
樣本回覆本文
{
    "@odata.context": "https://usnconeboxax1ret.cloud.onebox.dynamics.com/Commerce/$metadata#Collection(Microsoft.Dynamics.Commerce.Runtime.DataModel.Promotion)",
    "value": [
        {
            "OfferId": "ST100024",
            "OfferName": "Weekly ad",
            "PeriodicDiscountTypeValue": 2,
            "IsDiscountCodeRequired": true,
            "ValidationPeriodId": "",
            "AdditionalRestrictions": "",
            "Description": "",
            "ValidFromDate": "1900-01-01T00:00:00Z",
            "ValidToDate": "2154-12-31T00:00:00Z",
            "CouponCodes": [],
            "ExtensionProperties": [
                {
                    "Key": "DATAAREAID",
                    "Value": {
                        "StringValue": "usrt"
                    }
                },
                {
                    "Key": "DATEVALIDATIONTYPE",
                    "Value": {
                        "IntegerValue": 1
                    }
                }
            ]
        },
        {
            "OfferId": "ST100019",
            "OfferName": "Take 20 off anything",
            "PeriodicDiscountTypeValue": 2,
            "IsDiscountCodeRequired": true,
            "ValidationPeriodId": "",
            "AdditionalRestrictions": "",
            "Description": "",
            "ValidFromDate": "1900-01-01T00:00:00Z",
            "ValidToDate": "2154-12-31T00:00:00Z",
            "CouponCodes": [],
            "ExtensionProperties": [
                {
                    "Key": "DATAAREAID",
                    "Value": {
                        "StringValue": "usrt"
                    }
                },
                {
                    "Key": "DATEVALIDATIONTYPE",
                    "Value": {
                        "IntegerValue": 1
                    }
                }
            ]
        },
        {
            "OfferId": "ST100015",
            "OfferName": "Watches",
            "PeriodicDiscountTypeValue": 2,
            "IsDiscountCodeRequired": false,
            "ValidationPeriodId": "",
            "AdditionalRestrictions": "",
            "Description": "",
            "ValidFromDate": "1900-01-01T00:00:00Z",
            "ValidToDate": "2154-12-31T00:00:00Z",
            "CouponCodes": [],
            "ExtensionProperties": [
                {
                    "Key": "DATAAREAID",
                    "Value": {
                        "StringValue": "usrt"
                    }
                },
                {
                    "Key": "DATEVALIDATIONTYPE",
                    "Value": {
                        "IntegerValue": 1
                    }
                }
            ]
        },
        {
            "OfferId": "ST100012",
            "OfferName": "Loyalty 5% off over $100",
            "PeriodicDiscountTypeValue": 4,
            "IsDiscountCodeRequired": false,
            "ValidationPeriodId": "",
            "AdditionalRestrictions": "",
            "Description": "All loyalty members get 5% with transaction total above $10 unless some exclusive or best price discounts are already applied on the transaction",
            "ValidFromDate": "1900-01-01T00:00:00Z",
            "ValidToDate": "2154-12-31T00:00:00Z",
            "CouponCodes": [],
            "ExtensionProperties": [
                {
                    "Key": "DATAAREAID",
                    "Value": {
                        "StringValue": "usrt"
                    }
                },
                {
                    "Key": "DATEVALIDATIONTYPE",
                    "Value": {
                        "IntegerValue": 1
                    }
                }
            ]
        },
        {
            "OfferId": "ST100011",
            "OfferName": "Loyalty 50% off sunglasses",
            "PeriodicDiscountTypeValue": 1,
            "IsDiscountCodeRequired": false,
            "ValidationPeriodId": "",
            "AdditionalRestrictions": "",
            "Description": "Gold tier Loyalty customers get 50% on Sunglasses when purchased with a Top, Scarf or Men's Casual shirts",
            "ValidFromDate": "1900-01-01T00:00:00Z",
            "ValidToDate": "2154-12-31T00:00:00Z",
            "CouponCodes": [],
            "ExtensionProperties": [
                {
                    "Key": "DATAAREAID",
                    "Value": {
                        "StringValue": "usrt"
                    }
                },
                {
                    "Key": "DATEVALIDATIONTYPE",
                    "Value": {
                        "IntegerValue": 1
                    }
                }
            ]
        },
        {
            "OfferId": "ST100009",
            "OfferName": "Student discount",
            "PeriodicDiscountTypeValue": 2,
            "IsDiscountCodeRequired": false,
            "ValidationPeriodId": "",
            "AdditionalRestrictions": "",
            "Description": "Students get 10% off for on Jeans and Backpacks",
            "ValidFromDate": "1900-01-01T00:00:00Z",
            "ValidToDate": "2154-12-31T00:00:00Z",
            "CouponCodes": [],
            "ExtensionProperties": [
                {
                    "Key": "DATAAREAID",
                    "Value": {
                        "StringValue": "usrt"
                    }
                },
                {
                    "Key": "DATEVALIDATIONTYPE",
                    "Value": {
                        "IntegerValue": 1
                    }
                }
            ]
        },
        {
            "OfferId": "ST100004",
            "OfferName": "Soccer sale",
            "PeriodicDiscountTypeValue": 3,
            "IsDiscountCodeRequired": false,
            "ValidationPeriodId": "",
            "AdditionalRestrictions": "",
            "Description": "Providing you great discounts ranging from 10% to 20% on all branded Soccer balls.  We carry a full line of soccer balls.  Buy one for yourself or gift it to someone.  We promise you that you won't be disappointed.  If you don't see something that you are looking for please call us.  This offer is only valid at our Retail Malls.",
            "ValidFromDate": "1900-01-01T00:00:00Z",
            "ValidToDate": "2154-12-31T00:00:00Z",
            "CouponCodes": [],
            "ExtensionProperties": [
                {
                    "Key": "DATAAREAID",
                    "Value": {
                        "StringValue": "usrt"
                    }
                },
                {
                    "Key": "DATEVALIDATIONTYPE",
                    "Value": {
                        "IntegerValue": 1
                    }
                }
            ]
        },
        {
            "OfferId": "ST100003",
            "OfferName": "BMX helmet sale",
            "PeriodicDiscountTypeValue": 0,
            "IsDiscountCodeRequired": false,
            "ValidationPeriodId": "",
            "AdditionalRestrictions": "",
            "Description": "Get 20% off on all branded youth BMX helmets when you buy two or more.  Choose from our great selection of BMX bike helmets from top brands, including ProTec, Giro, Bell and SixSixOne BMX helmets.  This offer is only available at our Retail Mall stores",
            "ValidFromDate": "1900-01-01T00:00:00Z",
            "ValidToDate": "2154-12-31T00:00:00Z",
            "CouponCodes": [],
            "ExtensionProperties": [
                {
                    "Key": "DATAAREAID",
                    "Value": {
                        "StringValue": "usrt"
                    }
                },
                {
                    "Key": "DATEVALIDATIONTYPE",
                    "Value": {
                        "IntegerValue": 1
                    }
                }
            ]
        }
    ]
}

AddCoupons

AddCoupons API 支援將優惠券的清單新增到購物車。 新增優惠券後,它會返回購物車物件。

下表顯示 AddCoupons API 的輸入參數。

名稱 類型 必要/選擇性 描述
Key 字串 必填 購物車識別碼。
couponCodes IEnumerable<字串> 必填 要新增到購物車的優惠券代碼。
isLegacyDiscountCode 布林 可選項目 將此參數設定為 true 以指出優惠券是舊版折扣碼。 預設值為 False

RemoveCoupons

RemoveCoupons API 支援從購物車中移除優惠券的清單。 移除優惠券後,它會返回購物車物件。

下表顯示 RemoveCoupons API 的輸入參數。

名稱 類型 必要/選擇性 描述
Key 字串 必填 購物車識別碼。
couponCodes IEnumerable<字串> 必填 要從購物車中移除的優惠券代碼。

GetProductPromotions

GetProductPromotions API 是在 Commerce 版本 10.0.38 發行版本中引入的。 這個 API 會收到一份促銷產品清單,並附上特定產品折扣。 它也可以輸入產品折扣 ID 和價格上下文清單,並查詢相關的促銷產品。 GetProductPromotions API 的主要使用案例是在產品清單頁面上,零售商在其中展示具有折扣的產品。 此 API 同時支援屬性型定價模型和舊版定價模型。

下表顯示 GetProductPromotions API 的輸入參數。

名稱 子名稱 類型 必要/選擇性 描述
productDiscountIds IEnumerable<字串> 必填 用於查找促銷產品的產品折扣ID清單。
priceLookupContext PriceLookupContext 必填 定價的上下文。
activeDate DateTimeOffset 可選項目 會考慮促銷的日期。

限制與侷限性:

  • 最多只能輸入五個產品折扣識別碼。
  • 僅支援簡單折扣。
樣本要求本文
{
    {
    "productDiscountIds": 
    [
        "ST100009",
        "ST100024"
    ],
    "priceLookupContext": 
    {
        "HeaderContext": 
        {
            "AffiliationLoyaltyTierLines": 
            [
                {
                    "AffiliationId": 5637144577,
                    "LoyaltyTierId": 0, 
                    "AffiliationTypeValue": 0,
                    "ReasonCodeLines": [],
                    "CustomerId": "2001"
                }
            ]
        },
        "LineContexts": []
    },
    "activeDate": "2023-08-20T14:40:05.873+08:00",
    },
}
樣本回覆本文
{
    "value": 
    [
        {
            "ProductId": 68719489871,
            "ProductDiscounts":
            [
                {
                    "OfferId": "ST100009",
                    "OfferName": "Student discount",
                    "PeriodicDiscountTypeValue": 2,
                    "IsDiscountCodeRequired": false,
                    "ValidationPeriodId": null,
                    "AdditionalRestrictions": null,
                    "Description": "Students get 10% off on Jeans and Backpacks",
                    "ValidFromDate": "1900-01-01T00:00:00.0000000Z",
                    "ValidToDate": "2154-12-31T00:00:00.0000000Z",
                    "CouponCodes": [],
                    "DateValidationTypeValue": 1
                },
                {
                    "OfferId": "ST100024",
                    "OfferName": "Weekly ad",
                    "PeriodicDiscountTypeValue": 2,
                    "IsDiscountCodeRequired": false,
                    "ValidationPeriodId": null,
                    "AdditionalRestrictions": null,
                    "Description": "",
                    "ValidFromDate": "1900-01-01T00:00:00.0000000Z",
                    "ValidToDate": "2154-12-31T00:00:00.0000000Z",
                    "CouponCodes": [],
                    "DateValidationTypeValue": 1
                }
            ]   
        },
        {
            "ProductId": 68719489872,
            "ProductDiscounts":
            [
                {
                    "OfferId": "ST100009",
                    "OfferName": "Student discount",
                    "PeriodicDiscountTypeValue": 2,
                    "IsDiscountCodeRequired": false,
                    "ValidationPeriodId": null,
                    "AdditionalRestrictions": null,
                    "Description": "Students get 10% off on Jeans and Backpacks",
                    "ValidFromDate": "1900-01-01T00:00:00.0000000Z",
                    "ValidToDate": "2154-12-31T00:00:00.0000000Z",
                    "CouponCodes": [],
                    "DateValidationTypeValue": 1
                }
            ]   
        }
    ]
}

如需更多資訊,請參閱PriceLookupContext

PriceLookupContext

GetProductPromotionsGetActivePrices API 中,使用 PriceLookupContext 類別來建立基於房產的定價模型。

以下範例展示了 PriceLookupContext 類別的結構。

{
    HeaderContext: PriceLookupHeaderContext
    {
        CustomerAccountNumber: string
        AffiliationLoyaltyTierLines: IEnumerable<AffiliationLoyaltyTier>
        ChannelId: long?
        SalesOrderProperties: IEnumerable<AttributeValueBase>
    },
    LineContexts: IEnumerable<PriceLookupLineContext>
    [
        {
            ProductRecordId: string
            UnitOfMeasureSymbol: string
            InventorySiteId: string
            InventoryLocationId: string
            DeliveryMode: string
            CatalogId: string
            SalesLineProperties: IEnumerable<AttributeValueBase>
        },
    ]
}
樣本要求本文
"PriceLookupContext":
{
    "HeaderContext": 
    {
        "CustomerAccount": 2001,
        "AffiliationLoyaltyTierLines": 
        [
            {
                "AffiliationId": 5637144577,
                "LoyaltyTierId": 0, 
                "AffiliationTypeValue": 0,
                "ReasonCodeLines": [],
                "CustomerId": "2001"
            }
        ],
        "SalesOrderProperties":
        [
            {
                "@odata.type": "#Microsoft.Dynamics.Commerce.Runtime.DataModel.AttributeTextValue",
                "Name": "CalcDate",
                "TextValue": "2022-10-10"
            }
        ]
    },
    "LineContexts": []
}

備註

  • API 會根據客戶帳號推斷客戶群組,因此請求中不會在 PriceLookupHeaderContext 參數中指定客戶群組。
  • 你可以在 PriceLookupHeaderContext 參數中指定 ChannelId。 如果你沒指定,API 會用請求上下文中的 ChannelId(使用 Store Commerce 時的當前頻道)。