修复微信扫码区服识别
This commit is contained in:
@@ -382,10 +382,11 @@ func buildExternalListingTitle(rank string, insurance string, hafCoinM float64,
|
||||
|
||||
func serverRegionFromLoginMethod(value string) string {
|
||||
value = strings.TrimSpace(value)
|
||||
normalized := strings.ToLower(value)
|
||||
switch {
|
||||
case strings.Contains(value, "微信"):
|
||||
case strings.Contains(value, "微信"), strings.HasPrefix(normalized, "vx"), strings.HasPrefix(normalized, "wx"):
|
||||
return "微信"
|
||||
case strings.Contains(strings.ToLower(value), "steam"):
|
||||
case strings.Contains(normalized, "steam"):
|
||||
return "Steam"
|
||||
default:
|
||||
return "QQ"
|
||||
|
||||
@@ -566,6 +566,28 @@ func TestExternalAccountToCreateRequestMapsUploadFields(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestServerRegionFromLoginMethod(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
loginMethod string
|
||||
want string
|
||||
}{
|
||||
{name: "QQ账号密码", loginMethod: "QQ账号密码", want: "QQ"},
|
||||
{name: "微信扫码", loginMethod: "微信扫码", want: "微信"},
|
||||
{name: "VX扫码", loginMethod: "VX扫码", want: "微信"},
|
||||
{name: "小写WX扫码", loginMethod: "wx扫码", want: "微信"},
|
||||
{name: "Steam", loginMethod: "Steam令牌", want: "Steam"},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := serverRegionFromLoginMethod(tt.loginMethod); got != tt.want {
|
||||
t.Fatalf("serverRegionFromLoginMethod(%q) = %q, want %q", tt.loginMethod, got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestExternalAccountToCreateRequestSeparatesPureCoinAndExtraItems(t *testing.T) {
|
||||
req := externalAccountToCreateRequest("客服1", 1772526103000, ExternalAccountData{
|
||||
LoginMethod: "QQ账号密码",
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
-- +goose Up
|
||||
|
||||
-- 修正历史外部上传中以 VX/WX 表示微信扫码、但被默认归类为 QQ 的账号。
|
||||
UPDATE game_accounts AS a
|
||||
JOIN rental_listings AS l ON l.account_id = a.id
|
||||
SET a.server_region = '微信'
|
||||
WHERE a.server_region = 'QQ'
|
||||
AND EXISTS (
|
||||
SELECT 1
|
||||
FROM listing_uploads AS lu
|
||||
WHERE lu.listing_id = l.id
|
||||
)
|
||||
AND (
|
||||
a.login_platform LIKE '%微信%'
|
||||
OR LOWER(TRIM(a.login_platform)) LIKE 'vx%'
|
||||
OR LOWER(TRIM(a.login_platform)) LIKE 'wx%'
|
||||
);
|
||||
|
||||
-- +goose Down
|
||||
|
||||
-- 此数据修复不可逆,避免将已修正的微信账号错误回退为 QQ。
|
||||
Reference in New Issue
Block a user