11 KiB
Requirements Document
Introduction
本文档定义了用户管理系统从PHP迁移到.NET 8的需求规范。用户管理系统包括用户资产管理、VIP等级系统、优惠券系统、任务系统、推荐关系管理、排行榜系统、兑换码系统和福利屋系统等功能模块。
Glossary
- User_Management_System: 用户管理系统,负责管理用户资产、等级、优惠券等功能
- Asset_Service: 资产服务,处理用户余额、积分、吧唧币等资产变更
- VIP_Service: VIP服务,处理用户VIP等级计算和升级
- Coupon_Service: 优惠券服务,处理优惠券的分享、领取、合成等功能
- Task_Service: 任务服务,处理每日/每周任务的进度计算和奖励发放
- Invitation_Service: 推荐服务,处理用户推荐关系和奖励
- Rank_Service: 排行榜服务,处理周榜和月榜排名
- Redeem_Service: 兑换码服务,处理兑换码验证和奖励发放
- Welfare_Service: 福利屋服务,处理福利活动的展示和参与
Requirements
Requirement 1: 用户资产明细查询
User Story: As a user, I want to view my asset transaction records, so that I can track my balance, integral, and score changes.
Acceptance Criteria
- WHEN a user requests balance records with type filter, THE Asset_Service SHALL return paginated balance change records matching the filter criteria
- WHEN a user requests integral records with type filter, THE Asset_Service SHALL return paginated integral change records matching the filter criteria
- WHEN a user requests score records with type filter, THE Asset_Service SHALL return paginated score change records matching the filter criteria
- WHEN a user requests payment records, THE Asset_Service SHALL return paginated payment records
- FOR ALL asset record queries, THE Asset_Service SHALL format timestamps as "Y-m-d H:i:s" format
- FOR ALL asset record queries, THE Asset_Service SHALL return last_page for pagination
Requirement 2: VIP等级系统
User Story: As a user, I want to view my VIP level and upgrade progress, so that I can understand my membership benefits.
Acceptance Criteria
- WHEN a user requests VIP information, THE VIP_Service SHALL calculate current VIP level based on total order consumption
- WHEN a user's consumption meets upgrade threshold, THE VIP_Service SHALL automatically upgrade the user's VIP level
- WHEN a user requests VIP list, THE VIP_Service SHALL return all VIP levels with conditions and privileges
- THE VIP_Service SHALL calculate upgrade progress percentage based on current consumption and next level threshold
- WHEN a user reaches maximum VIP level (5), THE VIP_Service SHALL indicate no further upgrades available
Requirement 3: 优惠券列表查询
User Story: As a user, I want to view my coupons, so that I can manage and use them.
Acceptance Criteria
- WHEN a user requests coupon list with status=1, THE Coupon_Service SHALL return unused coupons ordered by id desc
- WHEN a user requests coupon list with status=2, THE Coupon_Service SHALL return shared coupons ordered by share_time desc
- FOR ALL coupons, THE Coupon_Service SHALL return level_text and level_img based on coupon level (1=特级赏券, 2=终极赏券, 3=高级赏券, 4=普通赏券)
- THE Coupon_Service SHALL return y_count (today's claimed count), z_count (total limit=50), user_integral, ke_hc_count (max synthesis=20), sun_hao (loss rate=10%)
Requirement 4: 优惠券详情查询
User Story: As a user, I want to view coupon details, so that I can see who claimed my shared coupon.
Acceptance Criteria
- WHEN a user requests coupon detail, THE Coupon_Service SHALL return coupon information including level, share_time, num, own2
- THE Coupon_Service SHALL return yl_count (claimed count) and yl_integral_count (total claimed integral)
- THE Coupon_Service SHALL return share_user information (nickname, headimg)
- THE Coupon_Service SHALL return yl_list with claimer details and lucky_king flag for highest amount
Requirement 5: 优惠券分享
User Story: As a user, I want to share my coupon, so that others can claim it.
Acceptance Criteria
- WHEN a user shares a coupon, THE Coupon_Service SHALL update coupon status to 2 (shared)
- WHEN a user shares a coupon, THE Coupon_Service SHALL set share_time to current timestamp
- IF the coupon does not belong to the user, THEN THE Coupon_Service SHALL return error
Requirement 6: 优惠券领取
User Story: As a user, I want to claim shared coupons, so that I can get integral rewards.
Acceptance Criteria
- WHEN a user claims a coupon, THE Coupon_Service SHALL generate random amount from remaining pool
- WHEN a user claims a coupon, THE Coupon_Service SHALL add integral to user's account
- IF the user is the coupon owner, THEN THE Coupon_Service SHALL return error with code 2222
- IF the user already claimed this coupon, THEN THE Coupon_Service SHALL return error with code 2222
- IF the user reached daily claim limit, THEN THE Coupon_Service SHALL return error
- IF the coupon has no remaining amount, THEN THE Coupon_Service SHALL return error with code 2222
- WHEN a coupon is claimed, THE Coupon_Service SHALL give share reward to coupon owner
Requirement 7: 优惠券合成
User Story: As a user, I want to synthesize multiple coupons into a higher level coupon, so that I can get better rewards.
Acceptance Criteria
- WHEN a user calculates synthesis, THE Coupon_Service SHALL return new coupon level based on total value
- THE Coupon_Service SHALL apply 10% loss rate to synthesis
- IF any coupon is level 1 or 2 (特级/终极), THEN THE Coupon_Service SHALL return error
- IF coupon count exceeds 20, THEN THE Coupon_Service SHALL return error
- WHEN synthesis is confirmed, THE Coupon_Service SHALL delete original coupons and create new coupon
Requirement 8: 任务系统
User Story: As a user, I want to complete tasks and claim rewards, so that I can earn extra benefits.
Acceptance Criteria
- WHEN a user requests task list, THE Task_Service SHALL return tasks with completion status and progress
- FOR daily tasks (type=1), THE Task_Service SHALL calculate progress within current day
- FOR weekly tasks (type=2), THE Task_Service SHALL calculate progress within current week (Monday to Sunday)
- FOR invitation tasks (cate=1), THE Task_Service SHALL count new referrals in the period
- FOR lottery tasks (cate=2), THE Task_Service SHALL count paid orders in the period
- WHEN a user claims task reward, THE Task_Service SHALL verify task completion and add ou_qi reward
- IF the user already claimed the task in current period, THEN THE Task_Service SHALL return error
Requirement 9: 推荐关系管理
User Story: As a user, I want to invite friends and track my referrals, so that I can earn referral rewards.
Acceptance Criteria
- WHEN a user requests invitation info, THE Invitation_Service SHALL return referral code and statistics
- THE Invitation_Service SHALL return recent referrals with nickname, headimg, register_time, and reward
- WHEN a user binds invite code, THE Invitation_Service SHALL update user's pid to inviter's id
- IF the invite code is invalid, THEN THE Invitation_Service SHALL return error
- IF the user already has a referrer, THEN THE Invitation_Service SHALL return error
Requirement 10: 排行榜系统
User Story: As a user, I want to view consumption rankings, so that I can see my position among other users.
Acceptance Criteria
- WHEN a user requests week ranking, THE Rank_Service SHALL return top 30 users by weekly consumption
- WHEN a user requests month ranking, THE Rank_Service SHALL return top 30 users by monthly consumption
- THE Rank_Service SHALL return user's own rank and consumption amount
- THE Rank_Service SHALL return prize information for each rank position
- THE Rank_Service SHALL return date range and end_date for the ranking period
Requirement 11: 兑换码系统
User Story: As a user, I want to use redemption codes, so that I can get rewards.
Acceptance Criteria
- WHEN a user submits a redemption code, THE Redeem_Service SHALL verify code validity
- IF the code is valid, THEN THE Redeem_Service SHALL grant reward and mark code as used
- IF the code is invalid or already used, THEN THE Redeem_Service SHALL return error
- THE Redeem_Service SHALL return reward type and amount after successful redemption
Requirement 12: 福利屋列表
User Story: As a user, I want to view welfare house activities, so that I can participate and win prizes.
Acceptance Criteria
- WHEN a user requests welfare list with type=1, THE Welfare_Service SHALL return ongoing activities
- WHEN a user requests welfare list with type=3, THE Welfare_Service SHALL return completed activities ordered by open_time desc
- THE Welfare_Service SHALL filter activities by user's unlock_amount (total consumption)
- FOR ALL activities, THE Welfare_Service SHALL return join_count (participation count)
- THE Welfare_Service SHALL format time fields as "Y-m-d H:i:s"
Requirement 13: 福利屋详情
User Story: As a user, I want to view welfare house details, so that I can understand the activity rules and prizes.
Acceptance Criteria
- WHEN a user requests welfare detail, THE Welfare_Service SHALL verify user meets unlock_amount requirement
- THE Welfare_Service SHALL return goods info, prize list, join_count, and user's participation count
- THE Welfare_Service SHALL return user's consumption data within activity period
- THE Welfare_Service SHALL return activity status (waiting/ongoing/ended/to_open/opened)
Requirement 14: 福利屋参与记录
User Story: As a user, I want to view welfare house participation and winning records, so that I can track my activities.
Acceptance Criteria
- WHEN a user requests participants list, THE Welfare_Service SHALL return users who participated in the activity
- WHEN a user requests winning records, THE Welfare_Service SHALL return users who won prizes
- WHEN a user requests own participation records, THE Welfare_Service SHALL return user's participation history
- WHEN a user requests own winning records, THE Welfare_Service SHALL return user's winning history
Requirement 15: API文档更新
User Story: As a developer, I want the API documentation to reflect migration status, so that I can track migration progress.
Acceptance Criteria
- WHEN an interface is migrated, THE Documentation SHALL be updated with migration status marker
- THE Documentation SHALL include new interface address for migrated endpoints
- THE Documentation SHALL maintain backward compatibility information