feat(wheel): split gift and decoration reward values
This commit is contained in:
parent
8147b5981f
commit
cbe388b071
@ -132,6 +132,8 @@ func (s *Service) PageAdminRecords(
|
|||||||
Size: limit,
|
Size: limit,
|
||||||
TotalPaidGold: summary.TotalPaidGold,
|
TotalPaidGold: summary.TotalPaidGold,
|
||||||
TotalRewardGold: summary.TotalRewardGold,
|
TotalRewardGold: summary.TotalRewardGold,
|
||||||
|
TotalGiftRewardGold: summary.TotalGiftRewardGold,
|
||||||
|
TotalDecorationRewardGold: summary.TotalDecorationRewardGold,
|
||||||
TotalDrawTimes: summary.TotalDrawTimes,
|
TotalDrawTimes: summary.TotalDrawTimes,
|
||||||
ParticipantCount: summary.ParticipantCount,
|
ParticipantCount: summary.ParticipantCount,
|
||||||
StartTime: formatDateTime(filter.StartTime),
|
StartTime: formatDateTime(filter.StartTime),
|
||||||
@ -252,6 +254,8 @@ type wheelAdminRecordFilter struct {
|
|||||||
type wheelAdminRecordSummary struct {
|
type wheelAdminRecordSummary struct {
|
||||||
TotalPaidGold int64
|
TotalPaidGold int64
|
||||||
TotalRewardGold int64
|
TotalRewardGold int64
|
||||||
|
TotalGiftRewardGold int64
|
||||||
|
TotalDecorationRewardGold int64
|
||||||
TotalDrawTimes int64
|
TotalDrawTimes int64
|
||||||
ParticipantCount int64
|
ParticipantCount int64
|
||||||
}
|
}
|
||||||
@ -348,9 +352,16 @@ func (s *Service) adminRecordQuery(ctx context.Context, filter wheelAdminRecordF
|
|||||||
|
|
||||||
func (s *Service) adminRecordSummary(ctx context.Context, filter wheelAdminRecordFilter) (wheelAdminRecordSummary, error) {
|
func (s *Service) adminRecordSummary(ctx context.Context, filter wheelAdminRecordFilter) (wheelAdminRecordSummary, error) {
|
||||||
var summary wheelAdminRecordSummary
|
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).
|
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).
|
Select(`
|
||||||
Scan(&summary.TotalRewardGold).Error; err != nil {
|
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
|
return summary, err
|
||||||
}
|
}
|
||||||
if err := s.adminRecordQuery(ctx, filter).
|
if err := s.adminRecordQuery(ctx, filter).
|
||||||
|
|||||||
@ -104,8 +104,8 @@ func TestPageAdminRecordsIncludesUserInfoAndRangeSummary(t *testing.T) {
|
|||||||
PaidGold: 200,
|
PaidGold: 200,
|
||||||
RewardType: rewardTypeResource,
|
RewardType: rewardTypeResource,
|
||||||
ResourceID: &giftID,
|
ResourceID: &giftID,
|
||||||
ResourceType: resourceTypeGift,
|
ResourceType: "AVATAR_FRAME",
|
||||||
ResourceName: "Gift B",
|
ResourceName: "Frame B",
|
||||||
DisplayGoldAmount: 30,
|
DisplayGoldAmount: 30,
|
||||||
Probability: 500000,
|
Probability: 500000,
|
||||||
Status: drawStatusSuccess,
|
Status: drawStatusSuccess,
|
||||||
@ -149,6 +149,12 @@ func TestPageAdminRecordsIncludesUserInfoAndRangeSummary(t *testing.T) {
|
|||||||
if resp.TotalRewardGold != 150 {
|
if resp.TotalRewardGold != 150 {
|
||||||
t.Fatalf("total reward = %d, want 150", resp.TotalRewardGold)
|
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 {
|
if resp.TotalDrawTimes != 12 {
|
||||||
t.Fatalf("total draw times = %d, want 12", resp.TotalDrawTimes)
|
t.Fatalf("total draw times = %d, want 12", resp.TotalDrawTimes)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -313,6 +313,8 @@ type RecordPageResponse struct {
|
|||||||
Size int `json:"size"`
|
Size int `json:"size"`
|
||||||
TotalPaidGold int64 `json:"totalPaidGold,omitempty"`
|
TotalPaidGold int64 `json:"totalPaidGold,omitempty"`
|
||||||
TotalRewardGold int64 `json:"totalRewardGold,omitempty"`
|
TotalRewardGold int64 `json:"totalRewardGold,omitempty"`
|
||||||
|
TotalGiftRewardGold int64 `json:"totalGiftRewardGold,omitempty"`
|
||||||
|
TotalDecorationRewardGold int64 `json:"totalDecorationRewardGold,omitempty"`
|
||||||
TotalDrawTimes int64 `json:"totalDrawTimes,omitempty"`
|
TotalDrawTimes int64 `json:"totalDrawTimes,omitempty"`
|
||||||
ParticipantCount int64 `json:"participantCount,omitempty"`
|
ParticipantCount int64 `json:"participantCount,omitempty"`
|
||||||
StartTime string `json:"startTime,omitempty"`
|
StartTime string `json:"startTime,omitempty"`
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user