Compare commits
No commits in common. "3639cad4848aa0b88a0679978c9127b467eb3334" and "e4911e773240e3c8f5d1dd804c0dc59bc236b9bf" have entirely different histories.
3639cad484
...
e4911e7732
@ -235,14 +235,13 @@ type OfficialNoticeCustomizeRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type RewardGroupItem struct {
|
type RewardGroupItem struct {
|
||||||
ID Int64Value `json:"id"`
|
ID Int64Value `json:"id"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Content string `json:"content"`
|
Content string `json:"content"`
|
||||||
Quantity Int64Value `json:"quantity"`
|
Quantity Int64Value `json:"quantity"`
|
||||||
Cover string `json:"cover"`
|
Cover string `json:"cover"`
|
||||||
SourceURL string `json:"sourceUrl"`
|
Remark string `json:"remark"`
|
||||||
Remark string `json:"remark"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type RewardGroupDetail struct {
|
type RewardGroupDetail struct {
|
||||||
|
|||||||
@ -76,12 +76,12 @@ func (VoiceRoomRedPacket) TableName() string { return "voice_room_red_packet" }
|
|||||||
|
|
||||||
// VoiceRoomRedPacketSlice 保存红包预拆分份额。
|
// VoiceRoomRedPacketSlice 保存红包预拆分份额。
|
||||||
type VoiceRoomRedPacketSlice struct {
|
type VoiceRoomRedPacketSlice struct {
|
||||||
ID int64 `gorm:"column:id;primaryKey;index:idx_voice_room_red_packet_slice_claim_order,priority:4"`
|
ID int64 `gorm:"column:id;primaryKey"`
|
||||||
PacketID int64 `gorm:"column:packet_id;uniqueIndex:uk_voice_room_red_packet_slice,priority:1;index:idx_voice_room_red_packet_slice_claim,priority:1;index:idx_voice_room_red_packet_slice_claim_order,priority:1"`
|
PacketID int64 `gorm:"column:packet_id;uniqueIndex:uk_voice_room_red_packet_slice,priority:1;index:idx_voice_room_red_packet_slice_claim,priority:1"`
|
||||||
PacketNo string `gorm:"column:packet_no;size:64"`
|
PacketNo string `gorm:"column:packet_no;size:64"`
|
||||||
SortNo int `gorm:"column:sort_no;uniqueIndex:uk_voice_room_red_packet_slice,priority:2;index:idx_voice_room_red_packet_slice_claim_order,priority:3"`
|
SortNo int `gorm:"column:sort_no;uniqueIndex:uk_voice_room_red_packet_slice,priority:2"`
|
||||||
Amount int64 `gorm:"column:amount"`
|
Amount int64 `gorm:"column:amount"`
|
||||||
Status string `gorm:"column:status;size:32;index:idx_voice_room_red_packet_slice_claim,priority:2;index:idx_voice_room_red_packet_slice_claim_order,priority:2"`
|
Status string `gorm:"column:status;size:32;index:idx_voice_room_red_packet_slice_claim,priority:2"`
|
||||||
ClaimUserID *int64 `gorm:"column:claim_user_id"`
|
ClaimUserID *int64 `gorm:"column:claim_user_id"`
|
||||||
ClaimRecordID *int64 `gorm:"column:claim_record_id"`
|
ClaimRecordID *int64 `gorm:"column:claim_record_id"`
|
||||||
CreateTime time.Time `gorm:"column:create_time"`
|
CreateTime time.Time `gorm:"column:create_time"`
|
||||||
|
|||||||
@ -124,7 +124,7 @@ func rewardItemsFromGroup(detail integration.RewardGroupDetail) []RewardItem {
|
|||||||
Name: strings.TrimSpace(item.Name),
|
Name: strings.TrimSpace(item.Name),
|
||||||
Content: strings.TrimSpace(item.Content),
|
Content: strings.TrimSpace(item.Content),
|
||||||
Quantity: int64(item.Quantity),
|
Quantity: int64(item.Quantity),
|
||||||
Cover: firstNonEmpty(item.Cover, item.SourceURL),
|
Cover: strings.TrimSpace(item.Cover),
|
||||||
Remark: strings.TrimSpace(item.Remark),
|
Remark: strings.TrimSpace(item.Remark),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,43 +43,6 @@ func TestSaveConfigReturnsRewardItems(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSaveConfigReturnsVipCoverFromSourceURL(t *testing.T) {
|
|
||||||
service, gateway, _ := newTestService(t)
|
|
||||||
gateway.groups[2001] = integration.RewardGroupDetail{
|
|
||||||
ID: integration.Int64Value(2001),
|
|
||||||
Name: "VIP礼包",
|
|
||||||
RewardConfigList: []integration.RewardGroupItem{
|
|
||||||
{
|
|
||||||
ID: integration.Int64Value(11),
|
|
||||||
Type: "PROPS",
|
|
||||||
Name: "VIP 1",
|
|
||||||
Content: "2049402425177018400",
|
|
||||||
Quantity: integration.Int64Value(30),
|
|
||||||
Cover: "",
|
|
||||||
SourceURL: "https://example.com/vip-short-badge.png",
|
|
||||||
Remark: "30 天",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
resp, err := service.SaveConfig(context.Background(), mustDecodeSaveConfigRequest(t, `{
|
|
||||||
"sysOrigin": "LIKEI",
|
|
||||||
"enabled": true,
|
|
||||||
"levelConfigs": [
|
|
||||||
{"level": 1, "rechargeAmount": "9.99", "rewardGroupId": "2001", "rewardGroupName": "VIP礼包", "enabled": true}
|
|
||||||
]
|
|
||||||
}`))
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("SaveConfig() error = %v", err)
|
|
||||||
}
|
|
||||||
if len(resp.LevelConfigs) != 1 || len(resp.LevelConfigs[0].RewardItems) != 1 {
|
|
||||||
t.Fatalf("reward items = %+v", resp.LevelConfigs)
|
|
||||||
}
|
|
||||||
if got := resp.LevelConfigs[0].RewardItems[0].Cover; got != "https://example.com/vip-short-badge.png" {
|
|
||||||
t.Fatalf("vip cover = %q", got)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestProcessRechargeEventFiltersAndGrantsOnce(t *testing.T) {
|
func TestProcessRechargeEventFiltersAndGrantsOnce(t *testing.T) {
|
||||||
service, gateway, db := newTestService(t)
|
service, gateway, db := newTestService(t)
|
||||||
gateway.groups[1001] = testRewardGroup(1001, "首冲礼包")
|
gateway.groups[1001] = testRewardGroup(1001, "首冲礼包")
|
||||||
|
|||||||
@ -182,12 +182,6 @@ func (s *Service) completeClaimWallet(ctx context.Context, claim model.VoiceRoom
|
|||||||
}
|
}
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
if err := s.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
|
if err := s.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
|
||||||
var lockedPacket model.VoiceRoomRedPacket
|
|
||||||
if err := tx.Clauses(clause.Locking{Strength: "UPDATE"}).
|
|
||||||
Where("id = ?", claim.PacketID).
|
|
||||||
First(&lockedPacket).Error; err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := tx.Model(&model.VoiceRoomRedPacketClaim{}).
|
if err := tx.Model(&model.VoiceRoomRedPacketClaim{}).
|
||||||
Where("id = ?", claim.ID).
|
Where("id = ?", claim.ID).
|
||||||
Updates(map[string]any{
|
Updates(map[string]any{
|
||||||
@ -206,7 +200,7 @@ func (s *Service) completeClaimWallet(ctx context.Context, claim model.VoiceRoom
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return tx.Model(&model.VoiceRoomRedPacket{}).
|
return tx.Model(&model.VoiceRoomRedPacket{}).
|
||||||
Where("id = ? AND remain_count = 0 AND status = ?", lockedPacket.ID, packetStatusActive).
|
Where("id = ? AND remain_count = 0 AND status = ?", claim.PacketID, packetStatusActive).
|
||||||
Updates(map[string]any{
|
Updates(map[string]any{
|
||||||
"status": packetStatusFinished,
|
"status": packetStatusFinished,
|
||||||
"update_time": now,
|
"update_time": now,
|
||||||
|
|||||||
@ -1,29 +0,0 @@
|
|||||||
SET @current_schema := DATABASE();
|
|
||||||
|
|
||||||
SET @voice_room_red_packet_slice_claim_order_idx_columns := (
|
|
||||||
SELECT GROUP_CONCAT(column_name ORDER BY seq_in_index)
|
|
||||||
FROM information_schema.statistics
|
|
||||||
WHERE table_schema = @current_schema
|
|
||||||
AND table_name = 'voice_room_red_packet_slice'
|
|
||||||
AND index_name = 'idx_voice_room_red_packet_slice_claim_order'
|
|
||||||
);
|
|
||||||
|
|
||||||
SET @drop_voice_room_red_packet_slice_claim_order_idx_sql := IF(
|
|
||||||
@voice_room_red_packet_slice_claim_order_idx_columns IS NOT NULL
|
|
||||||
AND @voice_room_red_packet_slice_claim_order_idx_columns <> 'packet_id,status,sort_no,id',
|
|
||||||
'ALTER TABLE `voice_room_red_packet_slice` DROP INDEX `idx_voice_room_red_packet_slice_claim_order`',
|
|
||||||
'SELECT 1'
|
|
||||||
);
|
|
||||||
PREPARE drop_voice_room_red_packet_slice_claim_order_idx_stmt FROM @drop_voice_room_red_packet_slice_claim_order_idx_sql;
|
|
||||||
EXECUTE drop_voice_room_red_packet_slice_claim_order_idx_stmt;
|
|
||||||
DEALLOCATE PREPARE drop_voice_room_red_packet_slice_claim_order_idx_stmt;
|
|
||||||
|
|
||||||
SET @add_voice_room_red_packet_slice_claim_order_idx_sql := IF(
|
|
||||||
@voice_room_red_packet_slice_claim_order_idx_columns IS NULL
|
|
||||||
OR @voice_room_red_packet_slice_claim_order_idx_columns <> 'packet_id,status,sort_no,id',
|
|
||||||
'ALTER TABLE `voice_room_red_packet_slice` ADD INDEX `idx_voice_room_red_packet_slice_claim_order` (`packet_id`, `status`, `sort_no`, `id`)',
|
|
||||||
'SELECT 1'
|
|
||||||
);
|
|
||||||
PREPARE add_voice_room_red_packet_slice_claim_order_idx_stmt FROM @add_voice_room_red_packet_slice_claim_order_idx_sql;
|
|
||||||
EXECUTE add_voice_room_red_packet_slice_claim_order_idx_stmt;
|
|
||||||
DEALLOCATE PREPARE add_voice_room_red_packet_slice_claim_order_idx_stmt;
|
|
||||||
Loading…
x
Reference in New Issue
Block a user