这是用户在 2025-5-10 9:12 为 https://confluence.shopee.io/display/SPPT/%5BSPPT-111292%5D+%5BTD%5D+Price+Standardization+2.0 保存的双语快照页面,由 沉浸式翻译 提供双语支持。了解如何保存?
Skip to end of metadata
Go to start of metadata

Epic  史诗

SPPT-110551 - Jira issue doesn't exist or you don't have permission to view it.
SPPT-110551 - Jira 问题不存在或您没有查看权限。

Product Manager  产品经理
Developer(s)  开发人员QA Engineer(s)  测试工程师
Development Reviewer(s)  开发审核员Planned Release Date  计划发布日期

 

Project Manager  项目经理Status  状态

FINALIZED


ChangeLog


Version  版本
Date  日期
Change Log  更改日志
PIC
Color  颜色
v0

 

Draft the TD  起草 TDDefault  默认
v1

 

Details added after 1st External TD review
在第一次外部 TD 审查后添加了详细信息
Blue  蓝色
v2

 

Added internal TD details
添加了内部 TD 细节
Default  默认
v3

 

Updates after Internal TD Review:
内部 TD 审核后的更新:

  • new cache design  新的缓存设计
  • new section for IAS + ITS dependency 
    新增 IAS + ITS 依赖部分
  • updated effort estimate  更新的工作量估算
Purple  紫色
v4

 

  • Added OPA (off-platform-ads)
    添加了离线广告 (OPA)
Orange  橙色
v5

 

  • Added Dep. QPS Estimate  添加了依赖 QPS 估算
Green  绿色
v6

 

Post dev updates:  发布开发更新:

  • Rebate formula change  折扣公式变更
  • Rate inflation  汇率通货膨胀
  • Tax rate calculation formula
    税率计算公式
  • (updated) Internal overview diagram
    (已更新)内部概述图
  • Tax value & rate calculation data source / implementation
    税值和税率计算数据源/实现
  • propagate_error toggle to return when calculation-related deps return error (we no longer forcefully return error when it is downgraded).
    propagate_error 切换为当计算相关依赖返回错误时返回(我们现在不再在降级时强制返回错误)。
  • Add API perm tickets to Estimated QPS to Dependencies section.
    在预计 QPS 依赖部分添加 API 权限票。
  • Add AB Testing Design  添加 A/B 测试设计
  • Update Voucher Parameters
    更新代金券参数
  • Add more downgrades to "Downgrade Flow" section
    在"降级流程"部分添加更多降级内容
  • Fix Listing + Label Information sequence diagram
    修复列表+标签信息序列图
  • Add some notes to circuit breaker design
    为断路器设计添加一些注释
  • Add some notes to common/concurrency design
    为通用/并发设计添加一些注释
  • Update request and response protos to latest (based on what is published to feature topic)
    更新请求和响应原型到最新版本(基于发布到特性主题的内容)
  • Update scene / scenario config naming
    更新场景/场景配置命名
Maroon  深红色

Background  背景

To support the Price Standardization long term project, we should enable the (previously called) price.central service to support more scenarios such as the Buyer-Default scenario.
为了支持价格标准化长期项目,我们应该启用(以前称为) price.central 服务以支持更多场景,例如买家默认场景。

This aligns with some new client requirements from Video Chat & Shop Chat team which is defined in the project PRD.
这与视频聊天和店铺聊天团队定义的一些新客户需求一致,这些需求在项目 PRD 中定义。

In addition to supporting these requirements, we should also take another step to achieve our long term price architecture through this project.
除了支持这些要求外,我们还应通过这个项目再迈出一步,以实现我们的长期价格架构。

Abbreviations:  缩写:

  1. PBI: Promotion Bass Item (price team's service)
    PBI:促销基础项目(价格团队的服务)
  2. IIB: Item Info Bass (service, team)
    IIB:项目信息基础(服务,团队)
  3. PBS: Price Business (service)
    PBS:价格业务(服务)
  4. PCS: Price Central Service (price team's service)
    PCS:价格中央服务(价格团队的服务)
  5. IPB: Item Promotion Business (price team's proposed service)
    IPB:商品促销业务(价格团队提议的服务)
  6. IAS: Item Aggregation Service (listing team's service)
    IAS:商品聚合服务(列表团队的服务)
  7. LAS: Listing Aggregation Service (listing team's service)
    LAS:商品聚合服务(商品团队的服务)
  8. ITS: Item Tag Service (listing tag team's service)
    ITS:商品标签服务(商品标签团队的服务)

Related Documents:  相关文档:

  1. [PRD][Price] Support AI & Shop chat bot to get Final Price Info Based on Model ID
    [PRD][价格] 支持 AI 和店铺聊天机器人根据模型 ID 获取最终价格信息
  2. [PRD] Price Standardization 2.0
    [PRD] 价格标准化 2.0
  3. [HLS] Price Standardization 2.0
    [HLS] 价格标准化 2.0
  4. Voucher TD: Voucher Backend - 2024-12-06 - Price Standardisation 2.0
    优惠券 TD:优惠券后端 - 2024-12-06 - 价格标准化 2.0
  5. (Price)(TD) Price Standardization 1.0 - https://confluence.shopee.io/pages/viewpage.action?spaceKey=SPPT&title=%5BTD%5D%5BSPPT-101112%5D+Price+Standardization+-+Phase+1+-+Support+SPU+real+time+calculation
    (价格)(TD) 价格标准化 1.0 - https://confluence.shopee.io/pages/viewpage.action?spaceKey=SPPT&title=%5BTD%5D%5BSPPT-101112%5D+价格标准化+-+第一阶段+-+支持 SPU 实时计算
  6. (Price)(TD) Streaming Price Revamp - https://confluence.shopee.io/display/SPPT/%5BTD%5D%5BPBI%2C+PBS%2C+PCP%5D+Streaming+Price+Revamp
    (价格)(TD) 流价改版 - https://confluence.shopee.io/display/SPPT/%5BTD%5D%5BPBI%2C+PBS%2C+PCP%5D+Streaming+Price+Revamp
  7. (Price)(TD) Price Support Live Streaming Whitelist - https://confluence.shopee.io/display/SPPT/%5BTD%5D+Price+Support+Live+Streaming+Whitelist#heading-2112TheLSRoomEntryFlow
    (价格)(TD) 价格支持直播白名单 - https://confluence.shopee.io/display/SPPT/%5BTD%5D+Price+Support+Live+Streaming+Whitelist#heading-2112TheLSRoomEntryFlow
  8. (Price)(TD) Take Over Upcoming PSP Banner Display Logic from LS - https://confluence.shopee.io/display/SPPT/%5BTD%5D+Takeover+Upcoming+PSP+Banner+Display+Logic+from+LS
    (价格)(TD) 从 LS 接管即将到来的 PSP 横幅显示逻辑 - https://confluence.shopee.io/display/SPPT/%5BTD%5D+Takeover+Upcoming+PSP+Banner+Display+Logic+from+LS
  9. (Price)(TD) Support ROI 3.0 Advertising Smart Voucher - [SPPT-108545] [Price/ItemCard] Support ROI3.0 Advertising Smart Voucher
    (价格)(TD) 支持 ROI 3.0 广告智能券 - [SPPT-108545] [价格/商品卡] 支持 ROI3.0 广告智能券
  10. (Repo) WSA Common - http://git.garena.com/shopee/mall-server/wsa-common
    (代码库) WSA 通用 - http://git.garena.com/shopee/mall-server/wsa-common

Product Requirements:  产品需求:

TBC:  待确认:

  • Pending requirement clarifications in the PRD:
    PRD 中待明确的需求澄清:
    • MPI requested for Best / Lowest Price, what's the definition here?
      MPI 请求最佳/最低价格,这里的定义是什么?
  • Provide Buyer-Default scenario for clients
    为客户提供买家默认场景
  • Provide Buyer-NonLogin scenario for clients
    为客户提供买家未登录场景

Technical Requirements:  技术要求:

  • Determine a new name for price.central  service
    确定新名称为 price.central 服务
    • TBC: item_promotion_business   待定: item_promotion_business
  • item_promotion_business  商品促销业务
    • Setup    设置
      • Repo  仓库
      • CMDB
      • Packaging  包装
        • Decide on a standardized package management for the service
          确定服务的标准化包管理方案
    • Provide Buyer-default flow
      提供买家默认流程
      • EP Calculation  EP 计算
      • WP Calculation  WP 计算
      • LS Calculation  LS 计算
      • Parallelize the API calls (consider using concurrency library)
        并行化 API 调用(考虑使用并发库)
    • Provide Buyer-nonlogin flow
      提供买家未登录流程
    • Scenario Management  场景管理
      • API Proto change  API 协议变更
      • Split by client and scenario (define the scope)
        按客户和场景进行拆分(定义范围)
    • Configs  配置
      • Move applicable configs from PBS to IPB
        将适用的配置从 PBS 移动到 IPB
    •  Caching  缓存
      • Cache data in PCS to reduce API calls to PBS
        在 PCS 中缓存数据以减少对 PBS 的 API 调用
    • Nice to have(s):  其他建议:
      • Add remaining scenarios supported by Price Central Service
        添加 Price Central Service 支持的其他场景
      • Monitoring  监控
        • Add a new grafana board for IPB
          为 IPB 添加一个新的 Grafana 看板
        • Add feature-related metrics
          添加与功能相关的指标
      • API Verification  API 验证
        • Create API verification SDU for IPB
          为 IPB 创建 API 验证 SDU
      • Stress Test  压力测试
        • Integrate with price stress test framework
          与价格压力测试框架集成
  • price.business
    • Provide a lean API which skips:
      提供一个精简的 API,它跳过:
      • (TBC) cache  (待定) 缓存
        • This is to align with future architecture direction where we don't plan on caching in PBS.
          这是为了与未来的架构方向保持一致,我们计划不在 PBS 中缓存。

          To minimize impact, maybe we can make it configurable (toggle on / off) first.
          为了最小化影响,我们或许可以先将其设置为可配置(开/关)。
      • filtering logic (e.g. by model_id / promotion_type)
        过滤逻辑(例如按 model_id / 促销类型)
        • This is because if we cache the data in the new service, we shouldn't cache filtered data
          这是因为如果我们在新服务中缓存数据,就不应该缓存过滤后的数据
      • eligibility check  资格审查
      • tax calculation  税收计算
      • rebate data query  退税数据查询
      • etc. (basically it should only provide price-stock-soldout calculation)
        等。基本上它应该只提供价格-库存-售罄计算
    • Remove these definitions from the lean API:
      从精简 API 中删除这些定义:
      • display_price / display_stock
        显示价格 / 显示库存
      • rebate  折扣
      • aggregated price / stock info
        汇总价格/库存信息
      • ongoing / upcoming price  进行中/即将到来的价格
      • status  状态
    • PSSO query layer  PSSO 查询层



1. System Overview  1. 系统概述

To support [PRD][Price] Support AI & Shop chat bot to get Final Price Info Based on Model ID, we need to provide Shop Chat and Video AI Chat team with the promotion data that they require.
为了支持 [PRD][价格] 支持 AI & 店铺聊天机器人获取基于模型 ID 的最终价格信息,我们需要向店铺聊天和视频 AI 聊天团队提供他们所需的促销数据。

We are aiming to take a further step to revamp our Calc / Price Architecture together with this project, by implementing the changes in a new service instead of in PBS.
我们希望通过这个项目进一步改进我们的计算/价格架构,通过在一个新服务中实施这些更改,而不是在 PBS 中实施。



2. Cross Team Technical Design
2. 跨团队技术设计

2.1. Definitions  2.1. 定义

2.1.1. Item Promotion Business Service
2.1.1. 商品推广业务服务

In this project, we are introducing a new service called item_promotion_business service.
在此项目中,我们引入了一个名为 item_promotion_business 服务的新服务。

In the future, this service will be the entry point (gateway) for external & internal clients to query Product Promo Info (Price / Price+Stock) information.
在未来,该服务将成为外部和内部客户查询产品促销信息(价格/价格+库存)信息的入口(网关)。

Function - This service will function as:
功能 - 该服务将作为以下功能:

  1. Facade - to hide the complexities of calculating product promotion info (price / price + stock)
    外观 - 用于隐藏计算产品促销信息(价格/价格+库存)的复杂性
  2. Gateway - as the centralized entry point for clients to obtain price information
    网关 - 作为客户端获取价格信息的集中式入口
  3. Core Engine - as the main calculator of complex queries and business logic
    核心引擎 - 作为复杂查询和业务逻辑的主要计算器

Scope - the service will only return promotion related information to its clients.
范围 - 该服务仅向其客户端返回与促销相关的信息。

Style - the service will serve requests in terms of scenario_id and client_ids (encapsulated with flow_id).
样式 - 该服务将根据场景 ID 和客户端 ID(封装在流程 ID 中)来处理请求。

The business logic / features to apply / return will differ depending on the applicable scenario_id and client_id passed in the request.
应用的业务逻辑/功能/返回结果将根据请求中传递的场景 ID 和客户端 ID 而有所不同。

2.2. Solution  2.2. 解决方案

2.2.1. Requirements Summary
2.2.1. 需求摘要

We will provide clients with a service & API to provide:
我们将向客户提供服务和 API 以提供:

  1. Promotion Information  促销信息
    1. Price  价格
    2. Stock  库存
  2. Final Price Information  最终价格信息
    1. E.g. price after voucher & product promo discount
      例如。使用优惠券和商品促销折扣后的价格
  3. User Eligibility Check  用户资格检查
    1. This will disable some promotions if the users are not eligible for them.
      如果用户不符合资格,这将禁用一些促销活动。

      e.g.  例如
      1. Live Streaming promotions
        直播促销活动
      2. Exclusive Price promotions
        独家价格促销活动
      3. Welcome Package promotions
        欢迎套餐促销
  4. Tax Selection  税项选择
    1. Will apply tax when applicable (based on the default tax requirements)
      适用时将应用税(基于默认税项要求)
    2. total tax  总税额
  5. Rebate  返利
    1. product promo rebate  产品促销返利
    2. voucher rebate  优惠券返利
    3. total rebate  总返利

2.2.2. Overview Diagram  2.2.2. 概述图



2.2.3. API Design  2.2.3. API 设计

2.2.3.1. Namespace  2.2.3.1. 命名空间

API Name: calculation.item_promotion_business.get_promotion_info
API 名称:计算.商品促销业务.获取促销信息

2.2.3.2. Expected QPS From Clients + Traffic Type (Response Required)
2.2.3.2. 客户预期 QPS+流量类型(需要响应)

Scene ID  场景 ID
Client  客户
Estimated QPS  预计 QPS
Type of Traffic  流量类型
5Shop Chat  购物聊天

Normal: 15k  普通价格:15k
Peak: 20k  高峰价格:20k

Campaign Peak: 45K  活动高峰:45K

The above is total sum(all regions) QPS.
以上是总合计(所有地区)的 QPS。

ID QPS is about 50% of the total (cc zheqing.zhu@shopee.com ).
ID QPS 大约占总量的 50%(联系 cc zheqing.zhu@shopee.com)。

Therefore peak per region → daily 10k (campaign: 25k)
因此每个地区的峰值→每天 10k(活动:25k)

  • Offline / Cron / Data Brushing
    线下/计划任务/数据刷取
6Shop Chatbot

Feb 25: 140  2 月 25 日:140
Dec 25: 1000  12 月 25 日:1000

  • Offline / Cron / Data Brushing
    离线 / 定时任务 / 数据清理
7Video AI Chat  视频 AI 聊天< 10 , max(50)
8Off-Platform Ads  站外广告6,800
  • Buyer Traffic  买家流量

2.2.3.3. Estimated QPS to Dependencies
2.2.3.3. 对依赖的估计 QPS

For some flows, QPS is still 0 and the flow is toggled off (e.g. by SPEX Configs).
对于某些流程,QPS 仍然为 0 并且流程被关闭(例如通过 SPEX 配置关闭)。

In this case, it's OK for dep. teams to choose not to accept the API permission in this phase of the project.
在此情况下,项目该阶段,部门团队选择不接受 API 权限是可以的。


Dep. API  部门 APICached?  缓存?Clients  客户Expected Peak QPS (for 1 region)
预期峰值 QPS(针对 1 个区域)
API Permission Ticket  API 权限票据
1price.business.get_price_stock_sold_out_infoN
  • shop chat  店铺聊天
  • shop chat bot  店铺聊天机器人
  • video ai chat  视频 AI 聊天
  • off-platform ads  离平台广告

Daily: 18 k  每日:18k

Campaign: 33k  活动:33k

https://space.shopee.io/utility/swp/detail/3860198
2promotion.discount.base.main.get_discount_item_snapshot_list
获取促销折扣基础的主要折扣项快照列表
N
  • shop chat  店铺聊天
  • shop chat bot  店铺聊天机器人
  • video ai chat  视频人工智能聊天

Update: no rebate info needed
更新:无需提供返利信息

0https://space.shopee.io/utility/swp/detail/3857296
3promotion.exclusive_price.check_exclusive_price
促销。专属价格。检查专属价格
N
  • shop chat  店铺聊天
  • shop chat bot  店铺聊天机器人
  • video ai chat  视频 AI 聊天

Daily: 11 k  每日:11k

Campaign: 26k  活动:26k

https://space.shopee.io/utility/swp/detail/3857475
4promotion.exclusive_price.check_streaming_price_user_eligibility
检查用户是否符合专属价格流媒体价格资格
N
  • shop chat  店铺聊天
  • shop chat bot  店铺聊天机器人
  • video ai chat  视频 AI 聊天

Daily: 11 k  每日:11k

Campaign: 26k  活动:26k

5growth.welcome_package.validate_user_with_cacheN
  • shop chat  店铺聊天
  • shop chat bot  店铺聊天机器人
  • video ai chat  视频 AI 聊天

Daily: 11 k  每日:11k

Campaign: 26k  活动:26k

https://space.shopee.io/utility/swp/detail/3857506
6marketplace.listing.aggregation.bass.iteminfo.get_batch_item
市场列表聚合.bass 物品信息批量获取
NUpdate: all should call IAS + ITS
更新:所有应该调用 IAS + ITS
0https://space.shopee.io/utility/swp/detail/3857533
7marketplace.listing.item.itemaggregation.iteminfo.get_product_infoN
  • shop chat  店铺聊天
  • shop chat bot  店铺聊天机器人
  • video ai chat  视频 AI 聊天
  • off-platform ads  离线广告

Daily: 18 k  每日:18k

Campaign: 33k  活动:33k

https://space.shopee.io/utility/swp/detail/3857547
8marketplace.listing.itemtagservice.querying_api.get_item_labels
市场列表项标签服务查询 API 获取项标签
N
  • shop chat  店铺聊天
  • shop chat bot  店铺聊天机器人
  • video ai chat  视频人工智能聊天
  • off-platform ads  离线平台广告

Daily: 18 k  每日:18 k

Campaign: 33k  活动:33k

https://space.shopee.io/utility/swp/detail/3857556
9voucher.mp.usage.get_best_vouchers_by_items_from_poolN
  • shop chat
  • shop chat bot
  • video ai chat  视频 AI 聊天
  • off-platform ads  离平台广告

Daily: 18 k  每日:18 k

Campaign: 33k  活动:33k

https://space.shopee.io/utility/swp/detail/3857567

2.2.3.4. Constants  2.2.3.4. 常量

Constants Expand source


2.2.3.5. Request  2.2.3.5. 请求

Request Schema Expand source


2.2.3.5.1. Optional Fields (Response Required)
2.2.3.5.1. 可选字段(响应必需)

The table below indicates the list of optional fields we have in the API request schema, and its explanation on the usage.
下列表格显示了 API 请求模式中可选字段的列表及其使用说明。



Do you have this field to pass to Price (Calc) API?
你有这个字段要传递给价格(计算)API 吗?
Field Name  字段名Usage  使用说明Shop Chat  购物聊天Shop ChatbotVideo AI Chat  视频 AI 聊天Off-Platform Ads  离线平台广告
ModelQuery.model_idTo indicate which model 's promo info you are interested in.
用于指示您感兴趣的是哪个模型的促销信息。

If not filled, the API will return all model promo infos under the item.
如果未填写,API 将返回该项目下所有模型促销信息。
  • Yes  
  • Yes  
  • Yes  
  • No  
user_path  用户路径For voucher validation.  用于优惠券验证。
  • Yes  
  • Yes  
  • Yes  
live_stream_streamer_idFor voucher & live streaming promo discount validation.
用于优惠券和直播促销折扣验证。
  • Yes  
  • Yes  
  • Yes  
  • Yes  
shopee_video_creator_id  视频创作者 IDFor voucher validation.  用于优惠券验证。
  • Yes  
  • Yes  
  • Yes  
live_stream_discount_token
直播优惠券令牌

(also known as  (也称为
live_streaming_price_eligibility_token)
直播价格资格令牌)
For live streaming promo discount validation.
用于直播促销折扣验证。
  • Yes  
  • Yes  
  • Yes  
  • Yes  
client_platform  客户平台For voucher validation.  用于优惠券验证。
  • No  
  • Yes  
  • No  
  • Yes  
ads_id  广告 IDFor voucher validation (Ads Voucher).
用于优惠券验证(广告优惠券)。
  • Yes  
  • Yes  
  • Yes  
  • Yes  


2.2.3.5.2. Sample  2.2.3.5.2. 示例
Request Sample Expand source



2.2.3.6. Response  2.2.3.6. 响应

Response Schema Expand source
2.2.3.6.1. Sample  2.2.3.6.1. 示例
Response Sample Expand source


2.2.4. Error Flow  2.2.4. 错误流程

This API will return error when encountering errors from order-critical dependencies (e.g. Price service, Stock service).
当遇到来自订单关键依赖项(例如价格服务、库存服务)的错误时,此 API 将返回错误。

However this API will not return error when receiving errors from other services such as Voucher (display) service → on such cases the service will assume that there are no applicable vouchers for the item / model.
然而,当收到来自其他服务(如代金券(显示)服务)的错误时,此 API 不会返回错误,在这种情况下,服务将假定该商品/型号没有适用的代金券。

2.2.4.1. Accuracy vs. Availability (Response Required)
2.2.4.1. 准确性 vs. 可用性 (需要回复)

We will not return error when final price feature is downgraded.
当最终价格功能降级时,我们不会返回错误。

This is because on some regions (e.g. BR and TW), the final price feature is downgraded all of the time (during the time of writing).
这是因为在某些地区(例如巴西和台湾),最终价格功能一直处于降级状态(截至撰写本文时)。

Therefore to avoid returning error all the time in BR and TW, we should still return price-after-voucher during dependency / feature downgrades.
因此,为了避免在巴西和台湾一直返回错误,我们应在依赖项/功能降级期间仍然返回使用优惠券后的价格。

In this case, we define whether a price is accurate if → no calculation-related dependencies return error.
在这种情况下,我们定义价格是否准确的条件是:没有计算相关的依赖项返回错误。

(Downgrades don't count as errors, because usually we skip the API call).
(降级不计为错误,因为通常我们会跳过 API 调用)。


In case where clients prefer data accuracy over API availability, we're going to provide an option for clients to choose whether a scene should be downgraded when any of the Price calculation factor is downgradedreturn error when a final-price-related-dependency API fails (returns error).
如果客户更倾向于数据准确性而非 API 可用性,我们将提供一个选项,让客户选择在任一价格计算因素被降级时是否应降低场景级别。当与最终价格相关的依赖 API 失败(返回错误)时,返回错误。

For example:  例如:

  • If Voucher API returns an error, do you want our API to return an error, or return price-before-voucher?
    如果代金券 API 返回错误,您希望我们的 API 返回错误,还是返回使用代金券前的价格?
  • If price-after-voucher is downgraded, do you want our API to return an error, or return price-before-voucher?
    如果使用优惠券后的价格降低了,您希望我们的 API 返回错误,还是返回使用优惠券前的价格?

Client Name  客户名称
Scenario  场景
Scene  场景
Preference  偏好
1Shop Chat  购物聊天Buyer - Default  买家 - 默认5
  • If price inaccurate, don't return error
    如果价格不准确,不要返回错误
2Shop ChatbotBuyer - Default  买家 - 默认6
  • If price inaccurate, don't return error
    如果价格不准确,不返回错误
3Video AI Chat  视频 AI 聊天Buyer - Default  买家 - 默认7
  • If price inaccurate, don't return error
    如果价格不准确,不返回错误
4Off-Platform Ads  站外广告Buyer - Nonlogin  买家 - 未登录8
  • If price inaccurate, don't return error
    如果价格不准确,不要返回错误

2.2.5. Downgrade Flow  2.2.5. 降级流程

Available downgrades:  可用的降级选项:

Downgrade Name  降级名称Impact  影响Remarks  备注Changes  变更
Downgrade Price After Voucher
优惠券使用后降价
  • IPB will not call Voucher API for price after voucher logic.
    IPB 将不会在优惠券逻辑后调用 Voucher API 进行价格查询。
  • Final price will only contain price before voucher (similar to what happens when there's no applicable voucher at all for the item / model).
    最终价格将仅包含优惠券前的价格(类似于商品/型号没有任何适用的优惠券时发生的情况)。
Last triggered on 9.9 / 10.10 2024.
最后触发于 2024 年 9 月 9 日 / 10 月 10 日。

After this project:  在此项目之后:

  • IPB service will pass the downgraded voucher pool to Voucher.
    IPB 服务将降级优惠券池传递给优惠券。
  • If downgraded voucher pool in Calc configs are empty, then IPB will not call voucher service. (We will assume that we don't have any applicable vouchers to display).
    如果计算配置中的降级优惠券池为空,则 IPB 不会调用优惠券服务。(我们将假设我们没有任何适用的优惠券来显示)。
Downgrade Exclusive Price
降级专享价格
  • IPB will not call EP / LS / WP dep. API to check for eligibility
    IPB 不会调用 EP/LS/WP 部门 API 来检查资格
  • IPB will filter out EP / LS / WP promotions if the scene is login_mode=true
    IPB 将会过滤掉 EP / LS / WP 促销活动,如果场景是 login_mode=true
Has never been triggered in the past 2 years.
过去两年从未被触发。

No changes.  没有变化。

These toggles are implemented to mirror the downgrade capabilities of price.business.
这些开关是为了实现与 price.business 的降级功能相匹配。

Downgrade Live Streaming Price
降级直播价格
Downgrade Welcome Package Price
降级欢迎套餐价格

2.2.6. Scenario Settings  2.2.6. 场景设置

2.2.6.1. Summary  2.2.6.1. 摘要



Shop Chat  购物聊天
(Scene 5)  (场景 5)

Shop Chatbot
(Scene 6)  (场景 6)

Video AI Chat  视频 AI 聊天
(Scene 7)  (场景 7)
Scenario: Buyer - Default
场景:买家 - 默认
Product Promotion Eligibility Check
产品推广资格检查
Enabled (login mode)  已启用(登录模式)
Price After Voucher  使用优惠券后的价格Apply platform & seller/shop voucher to final price
将平台和卖家/店铺优惠券应用于最终价格
Time  时间Real time  实时
Rebate  折扣Price without rebate (buyer price)
未折扣价格(买家价格)
Model Price Selection  模型价格选择Default (Promo Priority based)
默认(促销优先)
Specific Rules - Calc  具体规则 - CalcExcluded Product Promotion Types
排除商品促销类型

None, include all buyer price:
无,包含所有买家价格

  • original price  原价
  • platform promotions  平台促销
  • seller promotions  卖家促销
  • user exclusive promotions (EP, WP, LS)
    用户专属促销(EP、WP、LS)
Granularity  粒度Model-level display promo (one promo price per model)
模型级显示促销(每个型号一个促销价格)
Stock  库存Requires available stock / quantity information
需要库存/数量信息
Tax  

Requires:  需要

  • tax value  税值
  • tax rate  税率

No requirement to return tax breakdown.
无需返回税项明细

Rebate  折扣

Requires:

  • product promo rebate  产品促销返利
    • value  数值
    • rate  比率
  • voucher rebate  优惠券返利
    • value  数值
  • total rebate  总返利
    • value  数值
    • rate  速率

No rebate information needed (cc weiyi.zhang@shopee.com )
无返利信息需要(联系 weiyi.zhang@shopee.com)

Specific Rules - Voucher  具体规则 - 优惠券Bypass Validation  跳过验证None  

Bypass video voucher eligibility checks
绕过视频优惠券资格检查

Clients can provide shopee video creator id and user path, therefore no bypass needed (cc junbang.tan@shopee.com )
客户可以提供 Shopee 视频创作者 ID 和用户路径,因此无需绕过(联系 junbang.tan@shopee.com)

2.2.6.2. Eligibility Check
2.2.6.2. 资格审查

Since both Shop Chat and Video AI Chat require login mode, we will enable promotion eligibility check in the price logic.
由于 Shop Chat 和 Video AI Chat 都需要登录模式,我们将在价格逻辑中启用促销资格检查。

We have aligned that since Chat team requires LS Eligibility Logic based on PDP (by token & stored user eligibility).
我们已经确定,由于 Chat 团队需要基于 PDP 的 LS 资格逻辑(通过 token 和存储的用户资格)。

2.2.7. Voucher Information
2.2.7. 优惠券信息

2.2.7.1. Requirements  2.2.7.1. 要求

Reference: [PRD][Price] Support AI & Shop chat bot to get Final Price Info Based on Model ID
参考:[PRD][价格] 支持 AI 和店铺聊天机器人以根据模型 ID 获取最终价格信息

  1. For both Shop Chat & Video AI Chat
    适用于店铺聊天和视频 AI 聊天
    1. Require the same voucher requirements as item card.
      需要和商品卡片相同的优惠券要求
  2. Video AI Chat:  视频 AI 聊天:
    1. Bypass video voucher eligibility checks
      绕过视频优惠券资格检查

2.2.7.2. Request Parameters
2.2.7.2. 请求参数

Reference: Voucher Backend - 2024-12-06 - Price Standardisation 2.0
参考:代金券后端 - 2024-12-06 - 价格标准化 2.0

Scene ID  场景 ID
Client  客户
Shop Voucher Pool  优惠券池
Platform Voucher Pool  平台优惠券池
Bypass Validation  跳过验证
5Shop Chat  购物聊天

BAU:  常规业务

  • SHOP_VOUCHER_POOL_ALL_SHOP_VOUCHERS
    所有店铺优惠券池

Downgrade:  降级

  • SHOP_VOUCHER_POOL_NON_HIDDEN_DISCOUNT_SHOP_VOUCHERS_WITHOUT_USER_CONDITIONS
    未隐藏的店铺优惠券池中的无用户条件的优惠券

BAU:  常规

  • PLATFORM_VOUCHER_POOL_ALL_PLATFORM_VOUCHERS
    平台优惠券池中的所有平台优惠券

Downgrade:  降级

  • PLATFORM_VOUCHER_POOL_DISCOUNT_GLOBAL_VOUCHER_WITHOUT_USER_CONDITIONS
    平台代金券池折扣-无用户条件通用代金券

None  

6Shop Chatbot

BAU:  常规操作

  • SHOP_VOUCHER_POOL_ALL_SHOP_VOUCHERS
    商店代金券池-所有商店代金券

Downgrade:  降级

  • SHOP_VOUCHER_POOL_NON_HIDDEN_DISCOUNT_SHOP_VOUCHERS_WITHOUT_USER_CONDITIONS

BAU:  常规

  • PLATFORM_VOUCHER_POOL_ALL_PLATFORM_VOUCHERS
    平台代金券池所有平台代金券

Downgrade:  降级

  • PLATFORM_VOUCHER_POOL_DISCOUNT_GLOBAL_VOUCHER_WITHOUT_USER_CONDITIONS
    平台代金券池折扣-全局代金券-无用户条件
None  
7Video AI Chat  视频 AI 聊天

BAU:  常规操作

  • SHOP_VOUCHER_POOL_ALL_SHOP_VOUCHERS

Downgrade:  降级:

  • SHOP_VOUCHER_POOL_NON_HIDDEN_DISCOUNT_SHOP_VOUCHERS_WITHOUT_USER_CONDITIONS

BAU:  常规操作

  • PLATFORM_VOUCHER_POOL_ALL_PLATFORM_VOUCHERS

Downgrade:  降级

  • PLATFORM_VOUCHER_POOL_DISCOUNT_GLOBAL_VOUCHER_WITHOUT_USER_CONDITIONS
    平台代金券池折扣-无用户条件

BYPASS_VALIDATION_RULE_VIDEO_VOUCHER
跳过验证规则-视频代金券

None  

2.2.8. Listing + Label Information
2.2.8. 商品+标签信息

In order to query the voucher API to get the best recommended vouchers (price after voucher feature), we need to provide voucher with some item basic information and label information.
为了查询代金券 API 以获取最佳推荐代金券(使用代金券后的价格功能),我们需要提供一些商品基本信息和标签信息。

Currently we have several different flows of doing so:
目前我们有多种不同的处理流程:

Flow  流程
Listing Datasource  商品数据源
Label ID v2 Datasource  标签 ID v2 数据源
Remarks  备注
Item Card  商品卡片marketplace.listing.aggregation.bass.iteminfo.get_batch_itemmarketplace.listing.aggregation.bass.iteminfo.get_batch_item
PDPfrom PDP (client)  从 PDP(客户端)from PDP (client)  从 PDP(客户端)
Live Streaming Room  直播房间marketplace.listing.aggregation.listing_aggr_service.get_batch_listing_aggregationmarketplace.listing.aggregation.listing_aggr_service.get_batch_listing_aggregationUnder migration planning.
正在迁移规划中。

According to Listing team, we should move this to marketplace.listing.aggregation.bass.iteminfo.get_batch_item.
根据 Listing 团队,我们应该将这个移至 marketplace.listing.aggregation.bass.iteminfo.get_batch_item。
Price Central   价格中心
(price.business with sdu=central )
(价格业务,sdu=中央)
marketplace.listing.item.itemaggregation.iteminfo.get_product_infomarketplace.listing.item.itemaggregation.iteminfo.get_product_info (wrong)
marketplace.listing.item.itemaggregation.iteminfo.get_product_info(错误)

We're calling IAS in this flow because this is what was recommended by Listing team during the project's TD phase.
我们在这个流程中调用 IAS,因为这是清单团队在项目 TD 阶段推荐的。

However after double checking during the migration project above, we have confirmed that this API does not return the Label ID V2 data that we require.
但是在上述迁移项目中进行双重检查后,我们确认这个 API 不会返回我们所需的 V2 标签 ID 数据。

We have only realized this when the project has been delivered.
我们直到项目交付时才意识到这一点。

Therefore right now this flow is actually erroneous.
因此,目前这个流程实际上是错误的。

According to Listing team, here's how we can retrieve Item Label V2 (which is by calling Item Tag Service).

If you want to call the ITS service to get the label_ids_v2 data, I think u can call marketplace.listing.itemtagservice.querying_api.get_item_labels_with_model_labels by yourself.

the request should be:

&item_label_pb.GetItemLabelsWithModelLabelsRequest{
    ItemIds: itemIDs,
    RequestFlags: []uint32{
       uint32(item_label_pb.Constant_NEED_AUTO_LABEL),
    },
}

And the label_ids_v2 field is from the resp.ItemModelLabels[*].ItemLabelIdList.

each element in resp.ItemModelLabels represent item and model labels of one specified item.

Item Promotion Business  商品促销业务

marketplace.listing.item.itemaggregation.iteminfo.get_product_info

marketplace.listing.itemtagservice.querying_api.get_item_labelsAccording to Listing Tag team, we can call marketplace.listing.itemtagservice.querying_api.get_item_labels if we only need item-level label data. Therefore in this project, we will call get_item_labels API instead.
根据列表标签团队的说法,如果我们只需要商品级别的标签数据,可以调用 marketplace.listing.itemtagservice.querying_api.get_item_labels。因此在这个项目中,我们将调用 get_item_labels API。

 According to Listing team:
根据列表团队:

We can give out a new doc to clarify the usage and differences of IIB and IAS next week(before 10 Jan). And before that point, I think u can choose IAS for all scenarios if possible. 
我们可以在下周(1 月 10 号之前)发布一份新文档来阐明 IIB 和 IAS 的使用方法和区别。在那之前,我认为如果可能的话,你可以选择使用 IAS 处理所有场景。

Therefore we should implement the IAS+ITS solution in this project for IPB service, by default.
因此,我们应在此项目中为 IPB 服务默认实施 IAS+ITS 解决方案。

Estimated QPS: refer to Section above: Expected QPS From Clients + Traffic Type
预计每秒请求数(QPS):参考上方:来自客户端的预期 QPS + 流量类型

Since the estimated QPS is expected to be small, we won't be caching IAS & ITS response in this phase.
由于预计的 QPS 较小,在本阶段我们不会缓存 IAS & ITS 的响应。

We should consider caching the data only when we find it's necessary in the future.
我们应在未来发现有必要时再考虑缓存数据。

The diagram below explains the query logic for IAS & ITS to calculate Price After Voucher:
下面的图表解释了 IAS 和 ITS 如何计算使用优惠券后的价格:


ACK:  确认:

2.2.9. Rebate Calculation
2.2.9. 折扣计算

In this project, there is an update to the calculation formula of rebate rate (field name: rebate.rate ).
在此项目中,折扣率的计算公式(字段名: rebate.rate )有更新。

Previously in the Price Advisor Project, rebate rate is calculated by:
在价格顾问项目中,折扣率是通过以下方式计算的:

total_rebate = product_promo_rebate + shop_voucher_rebate + platform_voucher_rebate
total_rebate_rate = 1e5 * (total_rebate / final_price_without_adding_back_rebate)

This formula can cause inconsistencies for scenes where we're adding back the rebate to the final price.
此公式可能导致在将返利加回最终价格的场景中产生不一致。

given:
---
seller_price = 100 (price with rebate)
rebate = 10
 
buyer_price = seller_price - rebate
buyer_price = 90 (price without rebate -> stored in Price DB)
 
shop_voucher_discount = 5
shop_voucher_rebate = 0
 
need_to_add_back_rebate_to_price = TRUE (e.g. seller flow)
 
---
final_price = min(0, buyer_price - shop_voucher_discount - platform_voucher_discount) + rebate
final_price = (90 - 5) + 10
final_price = 95
 
promotion_price = 90 (same as buyer_price)
 
---
total_rebate_rate = 1e5 * (total_rebate / final_price_without_adding_back_rebate)
total_rebate_rate = 1e5 * (10 / (95 - 10))
total_rebate_rate = 1e5 * (10 / 85) -> // we never return this 85 value in any field of the response, why are we using it here?

After discussion with Price/Calc PM, we received a confirmation so that we update the formula to be:
在与价格/计算产品经理讨论后,我们确认可以更新公式为:

total_rebate = product_promo_rebate + shop_voucher_rebate + platform_voucher_rebate
total_rebate_rate = 1e5 * (total_rebate / final_price) // this can be with or without rebate, depending on the scene


2.2.10. Rate Inflation & Precision
2.2.10. 汇率通胀与精度

In IPB response structure, we are returning fields called tax.rate and rebate.rate .
在 IPB 响应结构中,我们返回了名为 tax.raterebate.rate 的字段。

Following the common (and existing) style of rate calculation, IPB will return the rate value inflated by 1e5 (multiplied by 100,000).
遵循常见的(现有的)利率计算风格,IPB 将返回的利率值会膨胀 1e5(乘以 100,000)。

In this case 100% will be 100,000, and 50% will be 50,000.
在这种情况下,100%将是 100,000,50%将是 50,000。

This way, clients can freely decide how to round the values (up to 3 decimal points).
这样,客户端可以自由决定如何四舍五入这些值(最多保留三位小数)。

For reference, existing Price (e.g. price.business), Discount and Voucher services also follow this pattern.
参考而言,现有的价格(例如 price.business)、折扣和代金券服务也遵循此模式。


2.2.11. Tax Rate Calculation
2.2.11. 税率计算

Tax rate calculation follows the implementation in Price Advisor project, which is also an existing formula since 2023.
税率计算遵循价格顾问项目中的实现,这也是自 2023 年以来现有的公式。

tax_rate = 1e5 * (tax_value / pre_tax_price)


3. Internal Technical Design - Item Promotion Business
3. 内部技术设计 - 商品促销业务

Create a new Item Promotion Business to serve as a long-term replacement for Price Central Service, as the next step towards the new Calculation Architecture.
创建一个新的商品促销业务,作为价格中央服务长期替代方案,也是迈向新计算架构的下一步。

3.1.1. Entities  3.1.1. 实体

The core of IPB's scenario management lies in the scene entity.
IPB 场景管理的核心在于场景实体。

This scene is linked to a scenario (a predefined configuration), and a client (client information).
该场景链接到一个场景(预定义的配置),以及一个客户端(客户端信息)。

This scene may contain scene / flow-specific configurations which may differ from client-to-client, and scenario-to-scenario.
此场景可能包含场景/流程特定的配置,这些配置可能因客户而异,也可能因场景而异。

3.1.2. Scenario Management
3.1.2. 场景管理

3.1.2.1. Responsibility and Long Term Plan
3.1.2.1. 职责和长期计划

The table below defines the responsibility of each entity in the proposed scene management design.
下表定义了在拟议的场景管理设计中每个实体的职责。


Client  客户
Scenario  场景
Exclusion Rule  排除规则
Scene  场景
Responsibility  责任Describe the list of clients calling IPB.
描述调用 IPB 的客户端列表。

The client is not restricted to a logical client service or team.
客户端不限于逻辑客户端服务或团队。

A service may have more than 1 client ID if they have a different use-case.
如果有不同的用例,一个服务可以有多个客户端 ID。

Describe the preconfigured settings or templates that can be applied to handle clients' needs.
描述可以应用于处理客户端需求的预配置设置或模板。

The configs should handle:
配置应该处理:

  • The style / mode / type of executing a business module.
    执行业务模块的风格/模式/类型。
    • E.g. tax selection strategy
      例如税收选择策略

Describe the preconfigured exclusion logic that can be applied for clients' use cases.
描述可应用于客户用例的预配置排除逻辑。

Describes custom settings to be applied to a specific client x scenario (e.g. use-case or flow-level configurations).
描述应应用于特定客户端 x 场景(例如用例或流程级配置)的自定义设置。

The configs should handle:
配置应处理:

  • Scope Management (due to sensitivity / tech cost)
    范围管理(由于敏感性 / 技术成本)

    • E.g. some clients should not have access to rebate / tax / stock information. On such cases, we shouldn't return them the detailed info / breakdown when not needed.
      例如,某些客户端不应访问返利 / 税收 / 库存信息。在这种情况下,当不需要时,我们不应向他们返回详细信息 / 分解。
    • This will determine fields to return per-client-use-case in a detailed manner.
      这将详细地确定每个客户端使用场景要返回的字段。
      • We should avoid doing per-field toggle as we don't want to over-engineer this field control. Doing per-field toggle basically means we should switch to a GraphQL design instead.
        我们应该避免按字段进行切换,因为我们不想过度设计这个字段控制。按字段切换基本上意味着我们应该切换到 GraphQL 设计。
  • Exclusion Management  排除管理
Configurations  配置
  • client_id  客户 ID
  • client_name  客户名称
  • scenario_id  场景 ID
  • scenario_name  场景名称
  • promotion  促销
    • voucher  优惠券
      • shop_voucher_pool_id  店铺优惠券池 ID
      • platform_voucher_pool_id  平台优惠券池 ID
    • product_promotion  商品促销
      • promo_eligibility  促销资格
        • login_mode  登录模式
          • If TRUE, user-exclusive-promotions will be validated with user eligibility check. If not eligible, they will be filtered out.
            如果为真,用户专属促销将根据用户资格进行验证。如果不符合资格,将被过滤掉。
          • If FALSE, all promotions will be eligible by default.
            如果是 FALSE,所有促销活动都将默认符合资格。
      • model_display_promo_info  显示促销信息模型
        • main_product_promo_sorting (promo priority / lowest-price)
          主产品促销排序(促销优先级/最低价)
    • rebate  折扣
      • add_back_rebate_to_final_price
        添加回扣到最终价格
    • tax  
      • tax_selection_mode (regional / pre-tax / post-tax)
        税选择模式(区域 / 税前 / 税后)
  • exclusion_rule_id  排除规则 ID
  • exclusion_rule_name  排除规则名称
  • promotion  促销
    • product_promotion  产品促销
      • excluded_price_rule_types
        排除价格规则类型
  • scene_id  场景 ID
  • client_id  客户 ID
  • scenario_id  场景 ID
  • promotion  促销
    • voucher  优惠券
      • need_applied_voucher_detail
        需要应用优惠券详情
      • voucher_bypass_validation_id
        优惠券绕过验证 ID
    • product_promotion  产品促销
      • exclusion_rule_id   排除规则 ID
      • granularity  粒度
        • need_price_detail   需要价格详情
          • E.g. applied_price, and possibly input_price, price in the future
            例如适用价格,以及可能输入价格,未来价格
      • model_display_promo_info  模型展示促销信息
        • need_model_main_promo   需要模型主促销
          • E.g. Cart model-level display
            例如购物车模型级别展示
    • rebate  折扣
      • need_rebate_info  需要返利信息
        • This will make IPB return the value / rate of total rebate, and product-promo / voucher (when the need_xxx_detail is enabled).
          这将使 IPB 返回总返利的值/比率,以及产品促销/优惠券(当 need_xxx_detail 启用时)。
    • tax  
      • need_tax_info   需要税信息
        • Just like need_rebate_info, but for tax
          和 need_rebate_info 类似,但用于税收
  • stock  库存
    • need_stock  需要库存
  • downgrade  降级
    • propagate_error_when_final_price_related_dependency_fails
      当最终价格相关依赖失败时传播错误
Long Term Comparison  长期比较-

Maroon: long-term (will not be introduced in this phase).
深红色:长期(在本阶段不会引入)。

Short Term
Long Term
  • scenario_id
  • scenario_name
  • promotion
    • voucher
      • shop_voucher_pool_id
      • platform_voucher_pool_id
    • product_promotion
      • promo_eligibility
        • login_mode
          • If TRUE, user-exclusive-promotions will be validated with user eligibility check. If not eligible, they will be filtered out.
          • If FALSE, all promotions will be eligible by default.
      • model_display_promo_info
        • main_product_promo_sorting (promo priority / lowest-price)
    • rebate
      • add_back_rebate_to_final_price
    • tax
      • tax_selection_mode (regional / pre-tax / post-tax)
  • scenario_id
  • scenario_name
  • promotion
    • voucher
      • shop_voucher_pool_id
      • platform_voucher_pool_id
    • product_promotion
      • promo_eligibility
        • login_mode
          • If TRUE, user-exclusive-promotions will be validated with user eligibility check. If not eligible, they will be filtered out.
          • If FALSE, all promotions will be eligible by default.
        • automatically_enable_ongoing_live_stream_promotions
          • This is for Item Card's LS eligibility logic (where we rely on LS session ongoing status in addition to eligibility check).
          • For LS Room's eligibility logic (streamer whitelist + user eligibility), we won't set a toggle for this, but we'll simply enable the logic when clients pass us live_streaming_streamer_id in the parameters.
      • model_display_promo_info
        • main_product_promo_sorting (promo priority / lowest-price)
        • teaser_product_promo_sorting (earliest start time / etc.)
      • item_display_promo_info
        • main_product_promo_sorting (promo priority / gmv)
        • teaser_product_promo_sorting (earliest start time / etc.)
        • teaser_product_promo_strictness_mode (no check / strict with applicability check)
          • E.g. in LS room, LS is showing upcoming label / banner for PSPs only if they are applicable for the users when the promotion start. This leads to a more strict logic where we need to ensure that the upcoming PSP will be applicable for the user when the time comes.
          • If need applicability checking, we'll need to keep track of all of the product promo that will potentially be ongoing during the teaser promo period (includes ongoing and upcoming).
        • allow_teaser_to_coexist_with_featured_promo (true / false)
          • For LS upcoming label as well
    • rebate
      • add_back_rebate_to_final_price
    • tax
      • tax_selection_mode (regional / pre-tax / post-tax)
-

Maroon: long-term (will not be introduced in this phase).
深红色:长期(在本阶段不会推出)。

Short Term
Long Term
  • scene_id
  • client_id
  • scenario_id
  • promotion
    • voucher
      • need_applied_voucher_detail
      • voucher_bypass_validation_id
      • downgraded_shop_voucher_pool
      • downgraded_platform_voucher_pool
    • product_promotion
      • exclusion_rule_id 
      • need_price_detail 
        • E.g. applied_price, and possibly input_price, price in the future
      • model_display_promo_info
        • need_model_main_promo 
          • E.g. Cart model-level display
    • rebate
      • need_rebate_info
        • This will make IPB return the value / rate of total rebate, and product-promo / voucher (when the need_xxx_detail is enabled).
    • tax
      • need_tax_info 
        • Just like need_rebate_info, but for tax
  • stock
    • need_stock
  • downgrade
    • is_downgraded
    • automatically_downgrade_to_ensure_price_accuracy
  • scene_id
  • client_id
  • scenario_id
  • promotion
    • voucher
      • need_applied_voucher_detail
      • voucher_bypass_validation_id
      • downgraded_shop_voucher_pool
      • downgraded_platform_voucher_pool
      • need_applicable_best_rcmd_vouchers
      • need_next_best_rcmd_vouchers
      • need_highest_tier_rcmd_vouchers
    • product_promotion
      • exclusion_rule_id
      • inclusion_rule_id
        • E.g. in case there's a page where we only need to show a specific group of promos such as FS page. This does not control / make sure that the promo is eligible to use.
      • need_price_detail 
        • E.g. applied_price, and possibly input_price, price in the future
      • need_ongoing_model_promo_info 
        • When clients pass this, it means that they need raw data (only ongoing)
      • need_upcoming_model_promo_info
          • Just like the above field, but for upcoming.
      • model_display_promo_info
        • need_model_main_promo 
          • E.g. Cart model-level display
        • need_model_main_promo_decoration
          • E.g. cart main promo label
        • need_model_teaser_promo 
          • E.g. cart teaser promo
        • need_model_teaser_promo_decoration
          • E.g. cart teaser label
        • need_model_original_promo
          • E.g. for displaying strikethrough price / original price of model (Cart, ATC Panel)
        • need_sold_out_flexible_live_stream_promo
      • item_display_promo_info
        • need_item_main_promo 
          • For item-level main promotions (e.g. Item Card, PDP)
        • need_item_main_promo_decoration
          • E.g. Item Card & PDP banners and labels
        • need_item_teaser_promo 
          • For item-level teaser promotions (e.g. PDP)
        • need_item_teaser_promo_decoration
          • E.g. Item Card & PDP teaser banners and labels
        • need_item_original_promo
          • E.g. for displaying strikethrough price / original price of item (item card, PDP)
        • item_teaser_promo_inclusion_rule_id
          • E.g. for LS page it will be X, containing all of the LS promos which require teaser labels.
    • item_decoration
      • need_item_info_decoration
    • package_promotion
      • need_package_promotions
      • etc...
    • rebate
      • need_rebate_info
        • This will make IPB return the value / rate of total rebate, and product-promo / voucher (when the need_xxx_detail is enabled).
    • tax
      • need_tax_info 
        • Just like need_rebate_info, but for tax
  • stock
    • need_stock
    • need_stock_breakdown
      • E.g. this can add payload size / marshal cost, so let's not expose this if clients don't need them
    • need_timeslot_stocks
      • E.g. for streamer-side LS room
    • need_to_apply_purchase_limit
  • downgrade
    • propagate_error_when_final_price_related_dependency_fails

Not in this scope:  不在本范围内:

  • Settlement Price  结算价格
    • Settlement price: considering that this is not a promotion to display, I feel that this deserves a separate API.
      结算价格:考虑到这不是一个用于展示的促销活动,我认为这值得一个单独的 API。
  • Membership Offer Price  会员优惠价格
    • TBC: need to double-check the use case, whether it's necessary to introduce.
      TBC:需要再次确认用例,是否需要引入。
  • Flash Sale Page's preview info
    闪购页面的预览信息
    • If we need custom logic for FS page (e.g. for their preview-display), we should introduce it on IPB's client instead.
      如果我们需要为闪购页面定制逻辑(例如,用于预览显示),我们应该在 IPB 客户端上引入它。

      As much as possible, IPB should handle requests in a uniform, general way of calculation.
      尽可能让 IPB 以统一、通用的方式处理请求计算。

      IPB can still return FS information (based on filters & sorting & applicability check if required) if applicable to the current logic.
      如果适用,IPB 仍然可以根据当前逻辑返回 FS 信息(基于过滤器、排序和适用性检查)。


Can be discussed:  可以讨论:

  • Should we place purchase-limit  (apply / don't apply) in scene, or scenario?
    我们应该在场景还是场景中放置购买限制(应用/不应用)?

    • This depends on how we see this in the future.
      这取决于我们未来如何看待这个问题。
      • Do we want to automatically apply PL for logged-in-users?
        我们是否希望对登录用户自动应用 PL?
      • Do we consider purchase-limit as a calculation style?
        我们是否将购买限额视为一种计算方式?
      • Do we want non-promotion configurations to be bound to our Scenario?
        我们是否希望非促销配置绑定到我们的场景?


3.1.2.2. (Long-Term) Existing Scenarios - Config Mapping
3.1.2.2. (长期)现有场景 - 配置映射

The section below describes the scenario configs we're planning to add for existing scenarios.
以下部分描述了我们计划为现有场景添加的场景配置。

Note that we will only add existing scenarios & scenes (#0 - #7) into account, and will consider the rest as long-term considerations only.
注意,我们只考虑现有的场景和场景(#0 - #7),其余的只作为长期考虑。

We should revisit each scene's requirements again when we are doing the migration of each respective clients to ensure feature details accuracy.
在进行每个相应客户端的迁移时,我们应该再次审查每个场景的需求,以确保功能细节的准确性。

3.1.2.2.1. Scenarios  3.1.2.2.1. 场景
Scenario ID  场景 ID
Scenario Name  场景名称
Configuration  配置
Scenes  场景
0Template   模板
template Expand source
-
1Buyer - Default  买家 - 默认
 Expand source
  • Shop Chat  购物聊天
  • Shop Chatbot
  • Video AI Chatbot  视频 AI 聊天机器人
  • Item Card - FS Page*
    商品卡片 - FS 页面*
  • PDP - Main Page  商品详情页 - 主页
  • PDP - ATC Panel  商品详情页 - 自动推荐面板
  • Cart Page  购物车页面
  • Checkout Page  结账页面

*to be double checked  需要二次确认

XBuyer - Default (with GMV Logic)
买家 - 默认(含 GMV 逻辑)
 Expand source
  • Item Card - FS Page*
    商品卡片 - FS 页面*
  • PDP - Main Page*  产品详情页 - 主页面*

*to be double checked  需要二次确认

2Buyer - Non-user-exclusive
买家 - 非用户专属
 Expand source
  • MPI CSPU (Buyer)  MPI CSPU(买家)
  • SLS Future Final Price  SLS 未来最终价格
  • Cart Page - Guest  购物车页面 - 游客
3Future Final Price  最终价格-We don't need to differentiate by scenario as it's identical to Buyer - Non-user-exclusive.
我们不需要按场景区分,因为它是与买家 - 非用户专属相同的。
4Seller - Default  卖家 - 默认
 Expand source
  • Price Advisor - S2S*  价格顾问 - S2S*
  • Price Advisor - CSPU (Seller)
    价格顾问 - CSPU(卖家)

*in the future, S2S will also have voucher applied.
*未来,S2S 也将应用优惠券。

5Buyer - Login Mode with Session-based LS Eligibility
买家 - 基于会话的 LS 资格登录模式
 Expand source
  • Search Page  搜索页面
  • Daily Discover  每日发现
  • Other Item Cards following SRP logic
    其他遵循 SRP 逻辑的商品卡片
6Buyer - Login Mode with Session-based LS Eligibility (with GMV Logic)
买家 - 基于会话的 LS 资格登录模式(含 GMV 逻辑)
 Expand source
  • Search Page  搜索页面
  • Daily Discover  每日发现
  • Other Item Cards following SRP logic
    其他遵循 SRP 逻辑的商品卡片
7

Buyer - Login Mode with Strict, Coexisting Teaser Promo
买家 - 严格模式下的登录方式与促销预告共存

 Expand source
  • LS Room (Buyer)  买家房间
  • LS Room (Streamer)*  主播房间*

*double check requirements
*请再次检查需求

8Buyer - Login Mode with Strict, Coexisting Teaser Promo (with GMV Logic)
买家 - 严格登录模式,共存预告促销(含 GMV 逻辑)
 Expand source
  • LS Room (Buyer)  买家房间
  • LS Room (Streamer)*  主播房间*

*double check requirements
*重新检查要求

3.1.2.2.2. Scenes  3.1.2.2.2. 场景
Scene ID  场景 ID
Scene Name  场景名称
Configuration  配置
Scenario Name  场景名称
0Template  模板
 Expand source
-
1MPI CSPU (Buyer)  MPI CSPU(买家)
 Expand source
Buyer - Non-user-exclusive
买家 - 非用户专属
2SLS Future Price  SLS 未来价格
 Expand source
Buyer - Non-user-exclusive
买家 - 非用户专属
3Price Advisor - S2S
价格顾问 - S2S
 Expand source
Seller - Default  卖家 - 默认
4Price Advisor - CSPU (Seller)
价格顾问 - CSPU(卖家)
 Expand source
Seller - Default  卖家 - 默认
5Shop Chat  购物聊天
 Expand source
Buyer - Default  买家 - 默认
6Shop Chatbot  店铺聊天机器人
 Expand source
Buyer - Default  买家 - 默认
7Video AI Chat  视频 AI 聊天
 Expand source
Buyer - Default  买家 - 默认
8Item Card - SRP
商品卡片 - SRP
 Expand source
  • Buyer - Login Mode with Session-based LS Eligibility
    买家 - 基于会话的 LS 资格登录模式
  • Buyer - Login Mode with Session-based LS Eligibility (with GMV Logic)
    买家 - 基于会话的登录模式,符合 GMV 逻辑


9Item Card - Live Streaming
商品卡片 - 直播
 Expand source
*A round of checking is required before we move LS to IPB.
在我们将 LS 迁移到 IPB 之前,需要进行一轮检查。

On some flows, LS actually requires model-level data (even when their display is item-level).
在某些流程中,LS 实际上需要模型级别的数据(即使它们的显示是商品级别的)。

This is because they have some model-level related logic (e.g. for their cron-job, or for determining which item is considered an LS item).
这是因为它们有一些与模型级别相关的逻辑(例如,用于它们的定时任务,或用于确定哪个项目被视为 LS 项目)。

one model contain PSP/SSP/ESP we will regraded it as SP item. 
一个模型包含 PSP/SSP/ESP,我们将将其视为 SP 项目。

I think item level price information couldn't cover it.
我认为项目级别的价格信息无法涵盖这一点。

such as  model A is FS(which is highest priority) model B is PSP
例如,模型 A 是 FS(最高优先级),模型 B 是 PSP。

for ls side it should be the sp item.(edited)
对于 ls 端,应该是 sp 商品。(已编辑)

One solution is by introducing a concept called post-calculation-filter where we apply the filter after a certain calculation instead of before.
一种解决方案是通过引入一个称为“后计算过滤器”的概念,我们在计算之后应用过滤器,而不是在计算之前。

In the current proposal, all of the filters are applied before the calculation (e.g. price rule type filter, teaser promo inclusion rule id, etc.).
在当前提案中,所有过滤器都在计算之前应用(例如价格规则类型过滤器、悬念促销包含规则 ID 等)。

  • Buyer - Login Mode with Strict, Coexisting Teaser Promo
    买家 - 带有严格模式、共存悬念促销
  • Buyer - Login Mode with Strict, Coexisting Teaser Promo (with GMV Logic)
    买家 - 严格登录模式,共存预热促销(含 GMV 逻辑)
10Live Streaming - Streamer
直播 - 主播
 Expand source
  • Buyer - Login Mode with Strict, Coexisting Teaser Promo
    买家 - 严格登录模式,共存预热促销
  • Buyer - Login Mode with Strict, Coexisting Teaser Promo (with GMV Logic)
    买家 - 严格登录模式,共存预热促销(含 GMV 逻辑)
11Item Card - Flash Sale
商品卡片 - 限时抢购
 Expand source
Buyer - Default  买家 - 默认
12PDP - Main Page
产品详情页 - 主页
 Expand source
Buyer - Default  买家 - 默认
13PDP - ATC Panel
商品详情页 - 自动调价面板
 Expand source
Buyer - Default  买家 - 默认
14Cart Page  购物车页面
 Expand source
Buyer - Default  买家 - 默认
15Cart Page - Guest
购物车页面 - 游客
 Expand source
Buyer - Non-user-exclusive
买家 - 非用户专属
16Checkout Page  结账页面
 Expand source
Buyer - Default  买家 - 默认


3.1.3. Impacted Business Modules
3.1.3. 影响的业务模块


Price Business   价格业务
Item Promotion Business  商品促销业务
Breakdown  拆分
  1. Price Stock Sold-Out Query
    价格库存售罄查询

    1. New aggregation logic and structure
      新的聚合逻辑和结构
  1. Price Stock Sold-Out Query
    价格库存售罄查询

      1. New structure, support new cache logic & purge cycle
        新结构,支持新的缓存逻辑和清除周期
  2. Price Stock Grouping  价格库存分组
  3. Promo Eligibility Check  促销资格检查
    1. Parallelize API calls, refactor
      并行 API 调用,重构
  4. Tax Selection  税项选择
  5. Model Display Promo  模型显示促销
  6. Query Rebate & Voucher (Parallelize)
    查询返利与代金券(并行化)
    1. Rebate Query  返利查询
    2. Best Rcmd Voucher Query  最佳推荐代金券查询
  7. Final Price Calculation  最终价格计算
  8. Final Price Detail Calculation
    最终价格详情计算
    1. Tax Rate Calculation  税率计算
    2. Rebate Rate Calculation  折扣率计算
  9. Result Building  结果构建


3.1.3.1. Item Display Promo - Consideration
3.1.3.1. 商品展示促销 - 考虑因素

On we received an inquiry on whether it is feasible to include Item Display Promo calculation in this phase.
我们收到一个询问,关于是否在本阶段包含商品展示促销计算是否可行。

Below is the effort analysis:
以下是工作量分析:

  • TD
    • Additional 1-3 days of design and discussions (e.g. to reach a good long-term design)
      额外 1-3 天的设计和讨论时间(例如,以达到良好的长期设计)
  • Item Display Promo - 6-7 days
    商品展示促销 - 6-7 天
    • GMV-based  基于 GMV
      • Add GMV cache logic in IPB - 4 days
        在 IPB 中添加 GMV 缓存逻辑 - 4 天
        • Code change in IPB  IPB 中的代码更改
        • Code change in GMV cache cron-job
          GMV 缓存计划任务中的代码更改
    • Promo Priority-based - 2-3 days
      基于促销优先级的 - 2-3 天

3.1.4. Long Term Proto  3.1.4.长期原型

Snippet (under discussion): https://git.garena.com/-/snippets/4454
提示(讨论中):https://git.garena.com/-/snippets/4454

3.1.5. Overview Diagram  3.1.5. 概述图


3.1.6. Tax Value & Rate Calculation
3.1.6. 税值与税率计算

In this project, we're changing the data source of tax rate and value calculation.
在这个项目中,我们正在更改税率和值计算的来源。

Previously in price.central , these values are calculated by calling TaxRateCalculator.
之前在 price.central 中,这些值是通过调用 TaxRateCalculator 来计算的。

However, since this value and rate is already calculated in price.basic, we're going to reuse the existing calculation result and return them in IPB (instead of creating a new implementation / calculation logic in IPB which is redundant).
然而,由于这个值和税率已经在 price.basic 中计算过了,我们将重用现有的计算结果,并在 IPB 中返回它们(而不是在 IPB 中创建新的实现/计算逻辑,这是多余的)。

3.1.7. AB Testing Design  3.1.7. A/B 测试设计

We will be doing an AB Test in this project to measure the impact of the Price Standardization project (in the current phase).
我们将在该项目中进行 A/B 测试,以衡量价格标准化项目(当前阶段)的影响。

To perform this we can do either of these AB Testing solution
为了进行这项测试,我们可以选择以下 A/B 测试解决方案之一

  1. Client-side AB Testing  客户端 A/B 测试
    This should lead to the most accurate AB Testing result, as the client gets to determine whether to call the old flow or new flow (IPB) based on AB Testing.
    这应该能得出最准确的 A/B 测试结果,因为客户端可以根据 A/B 测试决定是否调用旧流程或新流程(IPB)。

    However this is not ideal as we have several clients, and thus it has additional cost to maintain the AB Testing phase.
    然而,这对于我们有多个客户来说并不理想,因此维护 A/B 测试阶段会产生额外的成本。


  2. Server-side AB Testing (tick)
    服务器端 A/B 测试 (tick)

    As an alternative, we can get IPB to implement the AB Testing logic instead.
    作为另一种选择,我们可以让 IPB 实现 A/B 测试逻辑。

    This will not be 100% comparable to the old vs. new flow, but we can simulate the comparison by enabling / disabling the price-after-voucher feature of IPB through AB-Testing.
    这将无法与旧流程和新流程完全比较,但我们可以通过启用/禁用 IPB 的价格-优惠券功能来进行 A/B 测试来模拟比较。

    This is because before this Price Standardization project, the price value that clients obtain are price without voucher.
    这是因为在此价格标准化项目之前,客户获得的价格值是没有优惠券的价格。

3.1.7.1. Control  3.1.7.1. 控制

Control: The AB Test will be controlled through the AB Testing platform.
控制:AB 测试将通过 AB 测试平台进行控制。

On top of the AB Testing platform, we will only enable the AB Testing logic based on scene configurations (not all scenes will have AB-T logic).
除了 AB 测试平台之外,我们只将基于场景配置启用 AB 测试逻辑(并非所有场景都将有 AB-T 逻辑)。

By default, scenes that are not included in the AB-T will always have price-after-voucher enabled.
默认情况下,未包含在 AB-T 中的场景将始终启用价格-优惠券功能。

3.1.7.2. ABT Configs  3.1.7.2. ABT 配置

ab_test_management Expand source


3.1.7.3. Scene Configs  3.1.7.3. 场景配置

Note: should be enabled on scene 5 and 6 (Shop Chat & Shop Chat Bot).
注意:应在场景 5 和 6(店铺聊天 & 店铺聊天机器人)上启用。

scene_management Expand source


3.1.8. Cache Design  3.1.8. 缓存设计

In Phase 0 of this project, we will not add any cache layer to the promotion info that we calculate.
在此项目的第一阶段,我们将不会为计算出的促销信息添加任何缓存层。

3.1.8.1. Summary

In Phase 0 of this project, we will not add any cache layer to the promotion info that we calculate.
We should add the cache in a separate phase, where we also introduce a new price pipeline which handles the responsibility of clean-wsa-cache from both price and stock services (however it purges IPB cache instead of PBI).
This is to align with our principle, where the cache owner should also own the logic for the entire cache lifecycle (which includes the pipeline for the cache purging mechanism).

Since we're expecting low-to-medium QPS in the early Phases, we will reuse PBS existing cache resources (cluster).
We will follow PBI's caching pattern in IPB, meaning we will cache price-stock data as a single structure while purging based on cache purger's cycle.
Note: this pattern is intended for display flows. When we are going to serve order flow in the future, we should make adjustments to the API call so that we bypass price-stock cache.

Why do we need to cache stock data?
This is because we want to reduce the amount of API calls from IPB → PBS, which potentially reduces CPU usage by avoiding unnecessary API response unmarshalling process.

Why do we combine price+stock data and cache this combined data instead?
This is because in IPB, we handle data in terms of Promo-info which is essentially made up of (product promo) price+stock+sold out info.
The product promo price should be the main unit, while the stock and sold-out-info is something that is bound to the product promo price (everything follows the product promo price).
We can look into splitting the cache when necessary in the future (e.g. for extendability purposes).

To implement cache on IPB, we'll need several phases of changes.
The phase is virtually named as 0.0, 0.1, and 0.2, but we can freely  rename the phase or combine with an ongoing project phase (e.g. together with adding more features to IPB) whenever necessary.

3.1.8.2. Phase 0 (No Cache)

3.1.8.2.1. Overview

In the initial Phase 0, we will not add any cache to IPB.

3.1.8.3. Phase 0.1 (price-stock-cache)

  • Implement price-stock-cache in IPB
  • Create a new cache-purging endpoint (API) in IPB
    • →  calculation.item_promotion_business.delete_price_stock_cache
  • Develop new cache-purging pipeline to purge IPB cache
    • → pricepipeline-cleanipbpricestockcache
  • Integrate with Cache Purger
3.1.8.3.1. Overview

Cache Purger integration guide: 

Benefits of cache purger:

  • Broadcasts cache purging API logic to multiple IDCs
  • Acts as an additional layer of debounce

Estimated latency impact after cache purger implementation: https://grafana.shopee.io/d/PovMzMAMk/live-wsa-cache-purge-rate-alert?orgId=2&viewPanel=72


After Phase 0, we should introduce price-stock cache to IPB:
At this phase, Calculation should also take control of the cache purge cycle by integrating with cache purger.

3.1.8.3.2. Cache Purging

To purge the cache, we should introduce a new price-pipeline which is called clean-ipb-price-stock-cache which consumes the messages consumed by price and stock's clean-wsa-cache pipeline.
Basically, it's a combination of price and stock clean-wsa-cache.
This is designed so that Calculation can take over the ownership of clean-wsa-cache, to ensure that we have full control of the cache's purging cycle.


3.1.8.4. Phase 0.2 (pso + price-stock-cache) - Long Term

  • Implement price-sold-out-info in IPB
  • Create a new cache-purging endpoint (API) in IPB
    • →  calculation.item_promotion_business.delete_price_sold_out_info_cache
  • Develop new cache-purging pipeline to purge IPB cache
    • → pricepipeline-cleanipbpricesoldoutinfocache
  • Integrate with Cache Purger
  • Deprecate PBS cache
    • → this should be reviewed again when we have migrated PBS clients away from PBS.
  • Deprecate PBI & PBI cache
    • → this should be reviewed again when we have migrated PBI clients away from PBI
3.1.8.4.1. Summary

This second phase is to extend a new price sold out info cache in IPB.
The purpose of this cache is to minimize the cost of querying stock data when it's not necessary.
Currently, price calculation requires sold-out-info for its promo selection / sorting logic.
Therefore, we can add a price-sold-out-info cache in IPB to reduce the amount of times we need to unmarshal stock data (which can be big if it has many breakdowns) when calling stock API / querying from the cache.

When do we need this: We should add this new price sold out info cache when we observe that there are more and more clients who only require price data without stock.
If this is only a small amount, then adding the new cache doesn't have much benefit.

Query Patterns:


Client only needs Price
Client needs Price + Stock
Client is part of order flow
Flow
  1. Query price-soldout-info-cache
  2. If miss
    1. Call PBS for Price + Soldout Info
  1. Query price-stock-cache
  2. If miss
    1. Call PBS for Price + Stock Info
  1. Skip cache
  2. Call PBS

 


3.1.8.4.2. Cache Purging

We should introduce a new pipeline and integrate with cache purger for purging the price-sold-out-info cache.


3.1.9. Circuit Breaker Design
3.1.9. 断路器设计

To support Voucher's automatic downgrade behavior mechanism, Item Promotion Business should support a custom circuit breaker logic for Voucher.
为了支持优惠券的自动降级行为机制,商品促销业务应支持针对优惠券的自定义断路器逻辑。

Logic:  逻辑:

  1. Voucher API circuit breaker should be calculated per Cmd-Scene_id instead of per Cmd name only.
    优惠券 API 断路器应该按 Cmd-场景_id 计算,而不仅仅是按 Cmd 名称计算。
  2. When the circuit breaker triggers for Voucher API in any of the scenes, Voucher API should enter downgraded mode.
    当断路器在任何场景中触发时,优惠券 API 应进入降级模式。
  3. When downgraded, IPB will pass the downgraded_voucher_pool of each respective scenarios as configured.
    当降级时,IPB 将根据配置将每个相应场景的 downgraded_voucher_pool 传递。
    1. If the downgraded_voucher_pools (shop and platform) are empty, skip Voucher API call.
      如果降级优惠券池(商店和平台)为空,则跳过优惠券 API 调用。

This way, when any of the scenes has an abnormal error / latency rate, we can do partial downgrade by (for example) not calling Voucher (by emptying the downgraded voucher pool) for item card scenario.
这样,当任何场景出现异常错误/延迟率时,我们可以通过(例如)不调用优惠券(通过清空降级优惠券池)来对商品卡片场景进行部分降级。

This capability must be added before we introduce a high-QPS client to IPB service.
在我们引入高 QPS 客户到 IPB 服务之前,必须添加此功能。

This requirement is a nice-to-have and shouldn't block this project.
此需求是锦上添花,不应阻塞此项目。

Update: this feature will not be implemented in this phase due to time constraints.
更新:由于时间限制,此功能在本阶段不会实施。

3.1.10. Downgrade Design  3.1.10. 降级设计

In the future, we might have clients who prefer data accuracy compared to API availability.
在未来,我们可能会有客户更倾向于数据准确性而不是 API 可用性。

To support this requirement, we will introduce a scene-level toggle called propagate_error_when_final_price_related_dependency_fails to determine whether IPB should return error when any of the final price related dependencies fail (returns error).
为了支持这一需求,我们将引入一个场景级别的开关 propagate_error_when_final_price_related_dependency_fails ,以确定当任何最终价格相关的依赖项失败时,IPB 是否应返回错误(返回错误)。

Note that when the feature is downgraded instead (e.g. price-after-voucher is downgraded in BR and TW) → we will not do any special handling (if the API call is skipped due to the downgrade → then we'll simply skip them and return price before voucher).
注意,如果功能被降级(例如,在巴西和台湾地区,价格-优惠券被降级)→ 我们将不会进行任何特殊处理(如果由于降级而跳过 API 调用→ 那么我们将简单地跳过它们并返回优惠券前的价格)。

3.1.11. Config Design  3.1.11. 配置设计

Configs which need to be introduced to IPB:
需要引入到 IPB 的配置:

  1. batch_limit → batch_size_management
  2. calculation_scenario → split
    计算场景 → 分割
    1. scenario_management  场景管理
    2. scene_management  场景管理
    3. client_management  客户管理
  3. circuit_breaker  断路器
  4. dependency_api_timeout  依赖 API 超时
  5. gas.cache  gas 缓存
  6. gas.engine  gas 引擎
  7. gas.log  日志记录
  8. gas.shark  鲨鱼
  9. gas.spex.client  气体特惠客户端
  10. gas.spex.server  气体特惠服务器
  11. monitoring  监控
    1. enabled_metrics_map  启用指标映射
    2. enabled_edge_case_reporting
      启用边缘情况报告
  12. price_business_downgrade_config → downgrade_management
    价格业务降级配置 → 降级管理
  13. price_stock_soldout_config + remote_cache_config → cache_management (e.g. for TTL)
    price_stock_soldout_config + remote_cache_config → cache_management (例如用于 TTL)
  14. rebate_management

3.1.12. Concurrency Design
3.1.12. 并发设计

When implementing the concurrency logic for EP / WP / LS eligibility check, we should look into integrating with https://git.garena.com/shopee/common/concurrency.
在实现 EP / WP / LS 资格检查的并发逻辑时,我们应该考虑与 https://git.garena.com/shopee/common/concurrency 集成。

This should potentially lead to a cleaner interface when trying to parallelize dependency API calls.
这可能会在尝试并行化依赖 API 调用时带来一个更清晰的界面。

Update: this will not be implemented in this phase due to time constraints.
更新:由于时间限制,本阶段不会实施此功能。

3.1.13. Package Design  3.1.13. 软件包设计

  • config  配置
  • deploy  部署
  • dm  管理员
    • aggregator  聚合器
      • Contains the main logic to aggregate / query / calculate data for processor response.
        包含用于聚合/查询/计算处理器响应的主要逻辑。
      • factory  工厂
        • Creates factory components / factories.
          创建工厂组件/工厂。
      • result_builder  结果构建器
        • Builds the result of an aggregator.
          构建聚合器的结果
    • business  商业
      • Contains business logic. Should call service layer instead of directly calling dependencies.
        包含业务逻辑。应该调用服务层而不是直接调用依赖项。
    • data  数据
      • Contains intermediate structures / Data Transfer Objects.
        包含中间结构 / 数据传输对象。
      • converter  转换器
        • For conversion of data package (if necessary).
          用于数据套餐转换(如有必要)。
  • docs  文档
  • etc  等等
  • logs  日志
  • middleware  中间件
    • circuit_breaker  电路断路器
    • interceptor  拦截器
      • E.g. Custom SPEX server / client interceptors.
        例如定制的 SPEX 服务器/客户端拦截器。
  • mock  模拟
  • mod  模块
    • GAS module.go  GAS 模块.go
  • processor  处理器
    • API entry point, simple validations and error handling.
      API 入口,简单的验证和错误处理。
  • scripts  脚本
  • service  服务
    • ab_test  A/B 测试
    • cache  缓存
    • cron_job  定时任务
    • health_check  健康检查
    • http
    • monitoring  监控
    • rpc  远程过程调用
  • templates  模板
    • E.g. for generating documents, boilerplate code, etc.
      例如,用于生成文档、样板代码等。
  • utils  工具
    • Should only contain low-level utilities.
      应仅包含低级实用工具。

      Should not depend on config, data, or any other internal packages.
      不应依赖于配置、数据或任何其他内部包。


4. Internal Technical Design - Price Business
4. 内部技术设计 - 价格业务

In the long run, PBS serves as the aggregator / mixer for price & stock data and its query logic.
从长远来看,PBS 作为价格和库存数据的聚合器/混合器,其查询逻辑。

Therefore it should only expose price and stock information necessarily.
因此它应该只暴露必要的价格和库存信息。

Metrics: we should expose a feature metric to show how many % of our QPS needs stock API query.
指标:我们应该暴露一个功能指标来显示我们有多少百分比的 QPS 需要库存 API 查询。

If this percentage low, we can consider some optimizations such as letting PBS expose price stock sold out info (and then cache price+soldOutInfo on IPB to reduce price+stock queries).
如果这个百分比低,我们可以考虑一些优化措施,例如让 PBS 公开已售罄的价格信息(然后在 IPB 上缓存价格+已售罄信息,以减少价格+库存查询)。

4.1.1. API Design  4.1.1. API 设计

price.business.get_price_stock_info Expand source


4.1.2. Cache Design  4.1.2. 缓存设计


Details  详细信息
Existing Flows in PBS  PBS 中现有的流程

No changes.  没有变化。

price.business.get_price_stock_sold_out_info
  • Should cache promotionprice  and sold out info  data separately.
    应分别缓存 promotionpricesold out info 数据。
  • Should enable promotion in-memory cache for all promotion types/
    应为所有促销类型启用 promotion 内存缓存。
  • Should not cache stock data (no change compared to current implementation).
    不应缓存 stock 数据(与当前实现相比无变化)。
  • Should use built-in cache Load() functions.
    应使用内置缓存 Load() 函数。
    • Enable cache stampede mitigation.
      启用缓存风暴缓解。

Update: cache changes are not implemented in this phase due to time constraints.
更新:由于时间限制,此阶段未实现缓存更改。



5. Backward Compatibility
5. 向后兼容性

This is a new flow for our clients, so the change is backwards compatible.
这是一个面向我们客户的新流程,因此变更具有向后兼容性。



6. Dependency & Performance Implications
6. 依赖与性能影响

There should be additional cost which is proportional to the QPS of the new flows from Shop Chat and Video AI CHat.
新的 Shop Chat 和 Video AI Chat 流程应该会产生额外的成本,该成本与 QPS 成正比。

Refer to the Expected QPS From Clients section above.
请参考上述“来自客户的预期 QPS”部分。



7. Stress Test  压力测试

Nice to have (but not a blocker), and should be scheduled after the project is finished.
比较理想(但不是障碍),并且应该在项目完成后安排。

This is because we're expecting a low-to-medium QPS from our clients.
这是因为我们预计客户的 QPS(每秒请求数)将较低到中等。



8. Monitoring and Alert  8. 监控和警报

8.1. Performance Monitoring
8.1. 性能监控

We should create new metrics and dashboards for Item Promotion Business service. (not a blocker)
我们应该为商品推广业务服务创建新的指标和仪表板。(不是障碍)

Aside from that, we should add more metrics based on the new scene management framework (e.g. metrics based on scene_id).
此外,我们应该根据新的场景管理框架添加更多指标(例如基于场景_id 的指标)。

8.1.1. Business Metrics  8.1.1. 业务指标


Metric Name  指标名称
Purpose  目的
1pbs_api_call_without_stock_requirement_request_count
无库存需求请求次数
  • Analyze the percentage of QPS from IPB → PBS that actually does not need stock information.
    分析从 IPB 到 PBS 的 QPS 中,实际不需要库存信息的比例
  • If a lot of % of the QPS does not need stock info, we should optimize such that IPB stores sold-out information.
    如果大量的 QPS 不需要库存信息,我们应该优化,使得 IPB 存储售罄信息。
2

QPS of requests per scene, with labels including:
每个场景的请求 QPS,标签包括:

  • client_id
  • scenario_id

8.2. Data Correctness Monitoring
8.2. 数据正确性监控

We should integrate Item Promotion Business with API verification. (not a blocker)
我们应该将商品促销业务与 API 验证集成。(不是障碍)



9. Deployment  9. 部署

9.1. Deliverables  9.1. 可交付成果

9.1.1. Task Breakdown  9.1.1. 任务分解


Service  服务
Task  任务
Dev Effort*  开发工作量*
QA Effort*  质量保证工作*
JIRA
1Item Promotion Business  商品推广业务
  • (0.5d) Setup  (0.5 天) 设置
    • repo  仓库
    • CMDB
    • packaging (discussion)  包装(讨论)
  • (0.5d) Configs  (0.5 天)配置
    • Migrate and cherry-pick useful configs for IPB
      迁移并挑选对 IPB 有用的配置
  • (1d) Cache (separate phase)
    (1d) 缓存(单独阶段)
    • Introduce Cache Layer for Price-Stock structure
      引入价格-库存结构的缓存层
    • Integrate with Cache Purger
      与缓存清理器集成
  • (6.5d) calculation.item_promotion_business.get_promotion_info
    • (0.5d) Data Structures  (0.5 天)数据结构
      • Re-introduce data structures that will be used in IPB
        重新引入将在 IPB 中使用的结构
    • Business Modules  业务模块
      • (0.5d) PSSO Query  (0.5 天)PSSO 查询
      • (0.5d) Price Stocks Grouping
        (0.5 天) 价格库存分组
      • (1.5d) Promo Eligibility Filter
        (1.5 天) 促销资格过滤器
          • Implement with  common/concurrency library
            使用通用/并发库实现
        • EP
        • LS
        • WP
      • (0.5d) Tax Selection  (0.5d) 税费选择
      • (0.5d) Model Display Promo Selection
        (0.5d) 模型展示促销选择
      • (0.5d) Rebate Info Query  (0.5d) 折扣信息查询
      • (1d) Best Rcmd Voucher Query (query IAS + ITS)
        (1d) 最佳推荐券查询(查询 IAS + ITS)
      • (0.5d) Final Price Calculation
        (0.5d) 最终价格计算
      • (0.5d) Final Price Detail Calculation
        (0.5d) 最终价格详情计算
        • Total Tax  总税额
        • Total Rebate  总返利
  • (0.5d) calculation.item_promotion_business.delete_price_stock_cache (separate phase)
    (0.5d) 计算项促销业务删除价格库存缓存(分阶段)
    • Lean, batch API to clear price-stock cache for Cache Purger
      精简、批量 API 清除价格-库存缓存,用于缓存清理程序
  • (3.5d) Nice-to-have(s)  (3.5d) 有益功能
    • (0.5d) Monitoring (feature metrics & edge cases)
      (0.5d) 监控(功能指标和边缘情况)
    • (0.5d) API-scene-level Circuit Breaker (for Voucher risk mitigation)
      (0.5d) API 场景级断路器(用于优惠券风险缓解)
    • (0.5d) Downgrades  (0.5d) 降级
      • Scene-level downgrade  场景级降级
      • Auto-downgrade toggle logic (for response accuracy)
        自动降级开关逻辑(用于提高响应准确性)
      • Return error toggle logic (for response accuracy)
        返回错误开关逻辑(用于提高响应准确性)
    • (1d) Integrate with price verify
      (1d)与价格验证集成
    • (1d) Integrate with price stress test
      (1d) 与价格压力测试集成
    • (0.1d) Integrate with go-auto-max-procs
      (0.1d) 与 go-auto-max-procs 集成

Main: 8d - 11d  主要:8d - 11d

Total: 12d - 15d  总计:12d - 15d


SPPT-112480 - Jira issue doesn't exist or you don't have permission to view it.
SPPT-112480 - Jira 问题不存在或您没有查看权限。

2Price Business  价格业务
  • (2.5d) price.business.get_price_stock_sold_out_info
    (2.5d) 获取价格库存售罄信息

    • (1d) aggregation logic based on legacy design
      (1d) 基于旧设计的聚合逻辑
    • (0.5d) new intermediate data structure
      (0.5 天) 新的中间数据结构
    • (1d) new cache logic  (1 天) 新的缓存逻辑
      • use loader  使用加载器
      • enable stampede mitigation
        启用避峰措施
      • enable promotion in-memory cache by default
        默认启用内存缓存中的促销
  • Nice-to-have(s)  可选功能
    • (0.1d) Remove / toggle off json.Diff cost from PBS
      (0.1 天) 从 PBS 中移除/关闭 json.Diff 成本

      • (1d) Do stress-test to measure changes
        (1 天) 进行压力测试以衡量变化
    • (0.1d) Integrate with go-auto-max-procs
      (0.1 天) 与 go-auto-max-procs 集成
      • (1d) Do stress-test to measure changes
        (1 天) 进行压力测试以测量变化

Main: 3d - 4d  主要:3 天 - 4 天

Total: 5d - 6d  总计:5 天 - 6 天


SPPT-112479 - Jira issue doesn't exist or you don't have permission to view it.
SPPT-112479 - Jira 问题不存在或您没有查看它的权限。

3API Verification - Price Business
API 验证 - 价格业务
  • (0.5d) price.business API verification
    (0.5 天)价格业务 API 验证
0.5d - 1d  0.5 天 - 1 天

SPPT-112481 - Jira issue doesn't exist or you don't have permission to view it.
SPPT-112481 - Jira 问题不存在或您没有查看权限。

*Estimate in days  估计天数

9.1.2. Total Effort Estimation
9.1.2. 总工作量估计

PIC
Effort  工作量
Remarks  备注
  • Dev  开发
  • API Verification  API 验证

Main: 11d - 15d  主要:11 天 - 15 天
Tota (with nice-to-haves): 17d - 21d
总计(含锦上添花):17 天 - 21 天

TBCY days  多久QA testing  测试

9.1.3. Tickets  票据

type  类型 key   summary  摘要 assignee  指派 reporter  报告 priority  优先级 status  状态 resolution  解决方案 created  创建 updated  已更新 due  即将

Jira project doesn't exist or you don't have permission to view it.
Jira 项目不存在或您没有查看权限。

View these issues in Jira
查看这些 Jira 问题

9.2. Deployment Sequence  部署顺序 9.2

  1. PBS deployment  PBS 部署
  2. IPB deployment  IPB 部署
  3. Client deployment  客户端部署

9.3. Rollback Plan  9.3. 回滚计划

Client must have a fallback logic when IPB returns an error.
客户必须在 IPB 返回错误时具有回退逻辑。

For full compatibility, clients need to rollback first before IPB does rollback.
为了完全兼容,客户需要在 IPB 回滚之前先进行回滚。

Another alternative is they can toggle off their feature when IPB is rolled back.
另一种替代方案是,当 IPB 回滚时,他们可以关闭他们的功能。



Acknowledgements  致谢


Team  团队
PIC
Sign-off  签署
1Price  价格krishna.kannan  克里希那·坎南
  • The proposed solution LGTM
    提出的解决方案看起来不错
2Price  价格yin.yuan  银元
  • The proposed solution LGTM
    LGTM


Risk Assessment  风险评估

Risk level  风险等级

MEDIUM

Detail  详情

This project   这个项目

  • Involves changes on a critical price repository
    涉及对关键价格库的更改
Risks  风险Wrong price value.  价格值错误。
Detection  检测Price value in some pages are wrong
一些页面的价格值是错误的
Prevention  预防
  1. Unit testing  单元测试
  2. API verification  API 验证
Mitigation  缓解
  • Hotfix  热修复
RC & Sign-off  RC & 最终批准
  • krishna.kannan

1 Comment   1 条评论

  1. Things to add to TD:
    需要添加到 TD 的内容:

    v rebate formula (denominator stuff)
    v 退款公式(分母部分)

    v "_rate" formatting (inflated by 1e5)
    v "_rate" 格式(增加了 1e5)

    v tax formula  税费公式
    * overview diagram (we remove some calculators)
    * 概览图(我们移除了一些计算器)

    ** weak promoe  ** 弱促销
    ** timeslot recalculation
    ** 时间段重新计算

    ** tax rate data source
    **税率数据源

    * tax rate comes from PBS
    *税率来自 PBS

    * propagate error no longer fails during downgrade for tw and br compatibility purposes
    *在向下兼容 tw 和 br 的目的下,传播错误不再失败

    * API permission links  *API 权限链接
    * ab-test strategy  * A/B 测试策略
    * voucher flag during downgrade
    * 降级期间的优惠券标志

    * cross-feature interactions
    * 跨功能交互

    ** timeslot recalculation
    ** 时间段重新计算

    ** weak promotion recalculation
    ** 弱推广重新计算

    * Downgrades (EP, WP, LS)
    * 降级(EP,WP,LS)

    * Update voucher information -> request parameters
    * 更新优惠券信息 -> 请求参数

    * fix error in listing + label information
    * 修复商品列表错误 + 标签信息

    * circuit breaker  断路器
    * downgrade_design  降级设计
    * common/concurrency - no time
    常用/并发 - 无时间

    * PBS design - update
    PBS 设计 - 更新

    * stock filter logic  * 库存过滤逻辑

    Checklist:  清单:
    * add metrics board  * 添加指标看板
    * price-core  * 价格核心

Write a comment...  写一个评论...
Table of Contents  目录