6.5 KiB
Requirements Document
Introduction
本文档定义了将PHP商品系统迁移到.NET 8的需求规范。商品系统是抽赏平台的核心模块,包括商品列表、详情、分类、库存管理、收藏、中奖记录等功能。迁移过程需要保持与原PHP系统的功能一致性和API兼容性。
Glossary
- Goods_Service: 商品服务,负责商品列表、详情、配置等查询功能
- Collection_Service: 收藏服务,负责用户商品收藏管理
- Prize_Service: 奖品服务,负责奖品统计和中奖记录查询
- Cache_Service: 缓存服务,负责商品数据的Redis缓存管理
- GoodsType: 商品类型,包括一番赏、无限赏、擂台赏、积分赏等
- GoodsList: 商品奖品列表,包含每个商品的奖品配置
- GoodsExtend: 商品扩展配置,包含支付方式、抵扣设置等
- BoxNumber: 箱号,商品的分箱编号
- ShangId: 赏品分类ID,如A赏、B赏、C赏等
Requirements
Requirement 1: 商品列表查询
User Story: As a user, I want to browse goods list with category filtering, so that I can find products I'm interested in.
Acceptance Criteria
- WHEN a user requests goods list with type parameter, THE Goods_Service SHALL return paginated goods matching the specified type
- WHEN type parameter is -1, THE Goods_Service SHALL return all available goods
- WHEN a user requests goods list, THE Goods_Service SHALL include join_count from Redis cache or database
- THE Goods_Service SHALL filter out goods with status != 1 (inactive goods)
- THE Goods_Service SHALL apply unlock_amount filtering based on user's total consumption
- THE Goods_Service SHALL return goods sorted by sort field descending, then by id descending
Requirement 2: 商品详情查询
User Story: As a user, I want to view goods details including prize list and probability, so that I can make informed decisions.
Acceptance Criteria
- WHEN a user requests goods detail, THE Goods_Service SHALL return complete goods information including prize list
- WHEN goods_num is 0, THE Goods_Service SHALL automatically select an available box number
- THE Goods_Service SHALL calculate and return probability (pro) for each prize item
- THE Goods_Service SHALL return lock_info including lock status, lock user info, and remaining time
- THE Goods_Service SHALL return join_user list (recent participants' avatars)
- THE Goods_Service SHALL return collection_is indicating if user has collected this goods
- THE Goods_Service SHALL return limitInfo including daily and global purchase limits
Requirement 3: 商品子奖品查询
User Story: As a user, I want to view child prizes of a parent prize, so that I can see detailed prize breakdown.
Acceptance Criteria
- WHEN a user requests children prizes, THE Goods_Service SHALL return all child items for the specified goods_list_id
- THE Goods_Service SHALL calculate real_pro (real probability) for each child prize
- THE Goods_Service SHALL include shang_info for each child prize
Requirement 4: 商品扩展配置查询
User Story: As a user, I want to know available payment methods for a goods, so that I can choose my preferred payment.
Acceptance Criteria
- WHEN a user requests goods extend config, THE Goods_Service SHALL return payment method settings
- IF goods has specific extend config, THE Goods_Service SHALL return goods-specific settings
- IF goods has no specific extend config, THE Goods_Service SHALL return default settings from goods_type table
Requirement 5: 商品箱号管理
User Story: As a user, I want to browse and select different box numbers, so that I can choose my preferred box.
Acceptance Criteria
- WHEN a user requests box list, THE Goods_Service SHALL return paginated box groups (e.g., 1-10, 11-20)
- WHEN a user requests box detail, THE Goods_Service SHALL return boxes with surplus stock info
- THE Goods_Service SHALL support sorting by box number (asc/desc) and surplus stock (desc)
- THE Goods_Service SHALL include goodslist summary for each box
Requirement 6: 商品收藏功能
User Story: As a user, I want to collect/uncollect goods, so that I can easily find my favorite products.
Acceptance Criteria
- WHEN a user adds a goods to collection, THE Collection_Service SHALL create a collection record
- WHEN a user removes a goods from collection, THE Collection_Service SHALL delete the collection record
- IF user already collected the goods, THE Collection_Service SHALL return error when adding again
- WHEN a user requests collection list, THE Collection_Service SHALL return paginated collection with goods info
Requirement 7: 商品奖品统计
User Story: As a user, I want to see prize statistics, so that I can understand the prize distribution.
Acceptance Criteria
- WHEN a user requests prize count, THE Prize_Service SHALL return total and surplus count by category
- WHEN a user requests prize content, THE Prize_Service SHALL return detailed prize list for specified box
Requirement 8: 中奖记录查询
User Story: As a user, I want to view winning records, so that I can see who won what prizes.
Acceptance Criteria
- WHEN a user requests prize logs, THE Prize_Service SHALL return paginated winning records
- THE Prize_Service SHALL support filtering by shang_id (prize category)
- THE Prize_Service SHALL return category list for filtering options
- THE Prize_Service SHALL include user info, prize info, and winning time for each record
Requirement 9: 缓存管理
User Story: As a system, I want to cache frequently accessed data, so that I can improve response performance.
Acceptance Criteria
- THE Cache_Service SHALL cache goods list with 30 seconds expiry
- THE Cache_Service SHALL cache goods detail with 5 minutes expiry
- THE Cache_Service SHALL cache join_count with 5 minutes expiry
- WHEN goods data changes, THE Cache_Service SHALL invalidate related cache keys
Requirement 10: API兼容性
User Story: As a frontend developer, I want the new API to be compatible with existing calls, so that I don't need to modify frontend code.
Acceptance Criteria
- THE Goods_Service SHALL maintain the same request/response format as PHP API
- THE Goods_Service SHALL use POST method for endpoints that PHP uses POST
- THE Goods_Service SHALL return status, msg, data structure consistent with PHP API
- WHEN migration is complete, THE API documentation SHALL be updated with migration status