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)
|
records = append(records, payload)
|
||||||
}
|
}
|
||||||
return &RecordPageResponse{
|
return &RecordPageResponse{
|
||||||
Records: records,
|
Records: records,
|
||||||
Total: total,
|
Total: total,
|
||||||
Current: cursor,
|
Current: cursor,
|
||||||
Size: limit,
|
Size: limit,
|
||||||
TotalPaidGold: summary.TotalPaidGold,
|
TotalPaidGold: summary.TotalPaidGold,
|
||||||
TotalRewardGold: summary.TotalRewardGold,
|
TotalRewardGold: summary.TotalRewardGold,
|
||||||
TotalDrawTimes: summary.TotalDrawTimes,
|
TotalGiftRewardGold: summary.TotalGiftRewardGold,
|
||||||
ParticipantCount: summary.ParticipantCount,
|
TotalDecorationRewardGold: summary.TotalDecorationRewardGold,
|
||||||
StartTime: formatDateTime(filter.StartTime),
|
TotalDrawTimes: summary.TotalDrawTimes,
|
||||||
EndTime: formatDateTime(filter.EndTime),
|
ParticipantCount: summary.ParticipantCount,
|
||||||
|
StartTime: formatDateTime(filter.StartTime),
|
||||||
|
EndTime: formatDateTime(filter.EndTime),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,10 +252,12 @@ type wheelAdminRecordFilter struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type wheelAdminRecordSummary struct {
|
type wheelAdminRecordSummary struct {
|
||||||
TotalPaidGold int64
|
TotalPaidGold int64
|
||||||
TotalRewardGold int64
|
TotalRewardGold int64
|
||||||
TotalDrawTimes int64
|
TotalGiftRewardGold int64
|
||||||
ParticipantCount int64
|
TotalDecorationRewardGold int64
|
||||||
|
TotalDrawTimes int64
|
||||||
|
ParticipantCount int64
|
||||||
}
|
}
|
||||||
|
|
||||||
func newWheelAdminRecordFilter(sysOrigin string, category string, userID int64, status string, startRaw string, endRaw string) (wheelAdminRecordFilter, error) {
|
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) {
|
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)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -307,16 +307,18 @@ type DrawRecordPayload struct {
|
|||||||
|
|
||||||
// RecordPageResponse is an admin record page.
|
// RecordPageResponse is an admin record page.
|
||||||
type RecordPageResponse struct {
|
type RecordPageResponse struct {
|
||||||
Records []DrawRecordPayload `json:"records"`
|
Records []DrawRecordPayload `json:"records"`
|
||||||
Total int64 `json:"total"`
|
Total int64 `json:"total"`
|
||||||
Current int `json:"current"`
|
Current int `json:"current"`
|
||||||
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"`
|
||||||
TotalDrawTimes int64 `json:"totalDrawTimes,omitempty"`
|
TotalGiftRewardGold int64 `json:"totalGiftRewardGold,omitempty"`
|
||||||
ParticipantCount int64 `json:"participantCount,omitempty"`
|
TotalDecorationRewardGold int64 `json:"totalDecorationRewardGold,omitempty"`
|
||||||
StartTime string `json:"startTime,omitempty"`
|
TotalDrawTimes int64 `json:"totalDrawTimes,omitempty"`
|
||||||
EndTime string `json:"endTime,omitempty"`
|
ParticipantCount int64 `json:"participantCount,omitempty"`
|
||||||
|
StartTime string `json:"startTime,omitempty"`
|
||||||
|
EndTime string `json:"endTime,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func normalizeSysOrigin(sysOrigin string) string {
|
func normalizeSysOrigin(sysOrigin string) string {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user