feat(wheel): split gift and decoration reward values
This commit is contained in:
parent
8147b5981f
commit
cbe388b071
@ -126,16 +126,18 @@ func (s *Service) PageAdminRecords(
|
||||
records = append(records, payload)
|
||||
}
|
||||
return &RecordPageResponse{
|
||||
Records: records,
|
||||
Total: total,
|
||||
Current: cursor,
|
||||
Size: limit,
|
||||
TotalPaidGold: summary.TotalPaidGold,
|
||||
TotalRewardGold: summary.TotalRewardGold,
|
||||
TotalDrawTimes: summary.TotalDrawTimes,
|
||||
ParticipantCount: summary.ParticipantCount,
|
||||
StartTime: formatDateTime(filter.StartTime),
|
||||
EndTime: formatDateTime(filter.EndTime),
|
||||
Records: records,
|
||||
Total: total,
|
||||
Current: cursor,
|
||||
Size: limit,
|
||||
TotalPaidGold: summary.TotalPaidGold,
|
||||
TotalRewardGold: summary.TotalRewardGold,
|
||||
TotalGiftRewardGold: summary.TotalGiftRewardGold,
|
||||
TotalDecorationRewardGold: summary.TotalDecorationRewardGold,
|
||||
TotalDrawTimes: summary.TotalDrawTimes,
|
||||
ParticipantCount: summary.ParticipantCount,
|
||||
StartTime: formatDateTime(filter.StartTime),
|
||||
EndTime: formatDateTime(filter.EndTime),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -250,10 +252,12 @@ type wheelAdminRecordFilter struct {
|
||||
}
|
||||
|
||||
type wheelAdminRecordSummary struct {
|
||||
TotalPaidGold int64
|
||||
TotalRewardGold int64
|
||||
TotalDrawTimes int64
|
||||
ParticipantCount int64
|
||||
TotalPaidGold int64
|
||||
TotalRewardGold int64
|
||||
TotalGiftRewardGold int64
|
||||
TotalDecorationRewardGold int64
|
||||
TotalDrawTimes int64
|
||||
ParticipantCount int64
|
||||
}
|
||||
|
||||
func newWheelAdminRecordFilter(sysOrigin string, category string, userID int64, status string, startRaw string, endRaw string) (wheelAdminRecordFilter, error) {
|
||||
@ -348,9 +352,16 @@ func (s *Service) adminRecordQuery(ctx context.Context, filter wheelAdminRecordF
|
||||
|
||||
func (s *Service) adminRecordSummary(ctx context.Context, filter wheelAdminRecordFilter) (wheelAdminRecordSummary, error) {
|
||||
var summary wheelAdminRecordSummary
|
||||
// totalRewardGold keeps the historical dashboard number, including direct gold rewards.
|
||||
// The two split fields only count RESOURCE rewards: GIFT is the gift value, every other
|
||||
// resourceType is treated as decoration value for the admin cards.
|
||||
if err := s.adminRecordQuery(ctx, filter).
|
||||
Select("COALESCE(SUM(CASE WHEN status = ? THEN CASE WHEN reward_type = ? THEN gold_amount ELSE display_gold_amount END ELSE 0 END), 0)", drawStatusSuccess, rewardTypeGold).
|
||||
Scan(&summary.TotalRewardGold).Error; err != nil {
|
||||
Select(`
|
||||
COALESCE(SUM(CASE WHEN status = ? THEN CASE WHEN reward_type = ? THEN gold_amount ELSE display_gold_amount END ELSE 0 END), 0) AS total_reward_gold,
|
||||
COALESCE(SUM(CASE WHEN status = ? AND reward_type = ? AND UPPER(resource_type) = ? THEN display_gold_amount ELSE 0 END), 0) AS total_gift_reward_gold,
|
||||
COALESCE(SUM(CASE WHEN status = ? AND reward_type = ? AND UPPER(resource_type) <> ? THEN display_gold_amount ELSE 0 END), 0) AS total_decoration_reward_gold
|
||||
`, drawStatusSuccess, rewardTypeGold, drawStatusSuccess, rewardTypeResource, resourceTypeGift, drawStatusSuccess, rewardTypeResource, resourceTypeGift).
|
||||
Scan(&summary).Error; err != nil {
|
||||
return summary, err
|
||||
}
|
||||
if err := s.adminRecordQuery(ctx, filter).
|
||||
|
||||
@ -104,8 +104,8 @@ func TestPageAdminRecordsIncludesUserInfoAndRangeSummary(t *testing.T) {
|
||||
PaidGold: 200,
|
||||
RewardType: rewardTypeResource,
|
||||
ResourceID: &giftID,
|
||||
ResourceType: resourceTypeGift,
|
||||
ResourceName: "Gift B",
|
||||
ResourceType: "AVATAR_FRAME",
|
||||
ResourceName: "Frame B",
|
||||
DisplayGoldAmount: 30,
|
||||
Probability: 500000,
|
||||
Status: drawStatusSuccess,
|
||||
@ -149,6 +149,12 @@ func TestPageAdminRecordsIncludesUserInfoAndRangeSummary(t *testing.T) {
|
||||
if resp.TotalRewardGold != 150 {
|
||||
t.Fatalf("total reward = %d, want 150", resp.TotalRewardGold)
|
||||
}
|
||||
if resp.TotalGiftRewardGold != 50 {
|
||||
t.Fatalf("total gift reward = %d, want 50", resp.TotalGiftRewardGold)
|
||||
}
|
||||
if resp.TotalDecorationRewardGold != 30 {
|
||||
t.Fatalf("total decoration reward = %d, want 30", resp.TotalDecorationRewardGold)
|
||||
}
|
||||
if resp.TotalDrawTimes != 12 {
|
||||
t.Fatalf("total draw times = %d, want 12", resp.TotalDrawTimes)
|
||||
}
|
||||
|
||||
@ -307,16 +307,18 @@ type DrawRecordPayload struct {
|
||||
|
||||
// RecordPageResponse is an admin record page.
|
||||
type RecordPageResponse struct {
|
||||
Records []DrawRecordPayload `json:"records"`
|
||||
Total int64 `json:"total"`
|
||||
Current int `json:"current"`
|
||||
Size int `json:"size"`
|
||||
TotalPaidGold int64 `json:"totalPaidGold,omitempty"`
|
||||
TotalRewardGold int64 `json:"totalRewardGold,omitempty"`
|
||||
TotalDrawTimes int64 `json:"totalDrawTimes,omitempty"`
|
||||
ParticipantCount int64 `json:"participantCount,omitempty"`
|
||||
StartTime string `json:"startTime,omitempty"`
|
||||
EndTime string `json:"endTime,omitempty"`
|
||||
Records []DrawRecordPayload `json:"records"`
|
||||
Total int64 `json:"total"`
|
||||
Current int `json:"current"`
|
||||
Size int `json:"size"`
|
||||
TotalPaidGold int64 `json:"totalPaidGold,omitempty"`
|
||||
TotalRewardGold int64 `json:"totalRewardGold,omitempty"`
|
||||
TotalGiftRewardGold int64 `json:"totalGiftRewardGold,omitempty"`
|
||||
TotalDecorationRewardGold int64 `json:"totalDecorationRewardGold,omitempty"`
|
||||
TotalDrawTimes int64 `json:"totalDrawTimes,omitempty"`
|
||||
ParticipantCount int64 `json:"participantCount,omitempty"`
|
||||
StartTime string `json:"startTime,omitempty"`
|
||||
EndTime string `json:"endTime,omitempty"`
|
||||
}
|
||||
|
||||
func normalizeSysOrigin(sysOrigin string) string {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user