fix: CountScopedSubscribePurchaseOrders 包含续费单并排除赠送单
Some checks failed
Build docker and publish / build (20.15.1) (push) Has been cancelled

- type IN (1, 2):同时统计首购和续费历史,防止用户用续费绕过新人价限制
- amount > 0:排除 admin 赠送的免费订单(amount=0),避免误判新人资格

Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
shanshanzhong 2026-03-31 06:56:35 -07:00
parent 5733ebe40d
commit 40cfe46ba8

View File

@ -76,7 +76,7 @@ func CountScopedSubscribePurchaseOrders(
var count int64
query := db.WithContext(ctx).
Model(&modelOrder.Order{}).
Where("user_id IN ? AND subscribe_id = ? AND type = 1", scopeUserIDs, subscribeID)
Where("user_id IN ? AND subscribe_id = ? AND type IN ? AND amount > 0", scopeUserIDs, subscribeID, []int64{1, 2})
if len(statuses) > 0 {
query = query.Where("status IN ?", statuses)
}