You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
2.0 KiB
87 lines
2.0 KiB
package guser |
|
|
|
import ( |
|
"encoding/json" |
|
"fmt" |
|
"server/call" |
|
"server/common" |
|
"server/db" |
|
"server/modules/backend/app" |
|
"server/modules/backend/values" |
|
|
|
"github.com/gin-gonic/gin" |
|
"github.com/liangdas/mqant/log" |
|
) |
|
|
|
// 将用户相关信息拉入黑名单 |
|
func AddUserBlackList(c *gin.Context) { |
|
a := app.NewApp(c) |
|
defer func() { |
|
a.Response() |
|
}() |
|
req := new(values.AddUserBlackListReq) |
|
if !a.S(req) { |
|
return |
|
} |
|
user, err := call.GetUserInfo(req.UID) |
|
if err != nil { |
|
log.Error("err:%v", err) |
|
a.Code = values.CodeRetry |
|
return |
|
} |
|
list := []common.RechargeOrder{} |
|
db.Mysql().QueryList(0, 20, fmt.Sprintf("uid = %v and event = %v", user.Id, common.CurrencyEventWithDraw), "", common.RechargeOrder{}, &list) |
|
banAccounts := map[string]struct{}{} |
|
for _, v := range list { |
|
info := common.WithdrawCommon{} |
|
json.Unmarshal([]byte(v.PayAccount), &info) |
|
acc := info.Number |
|
// if info.DrawType == common.WithdrawTypeBank { |
|
// if info.BankCardNo != "" { |
|
// acc = info.BankCardNo |
|
// } |
|
// } else if info.DrawType == common.WithdrawTypeUPI { |
|
// if info.BankCode != "" { |
|
// acc = info.BankCode |
|
// } |
|
// } |
|
if acc == "" { |
|
continue |
|
} |
|
if _, ok := banAccounts[acc]; !ok { |
|
banAccounts[acc] = struct{}{} |
|
} |
|
} |
|
if len(banAccounts) == 0 { |
|
black := &common.BlackList{ |
|
Phone: user.Mobile, |
|
IP: user.IP, |
|
} |
|
if user.DeviceId != "00000000-0000-0000-0000-000000000000" { |
|
black.DeviceID = user.DeviceId |
|
} |
|
err := db.Mysql().Create(black) |
|
if err != nil { |
|
log.Error("err:%v", err) |
|
a.Code = values.CodeParam |
|
a.Msg = "该用户信息已在黑名单里" |
|
} |
|
} else { |
|
for k := range banAccounts { |
|
black := &common.BlackList{ |
|
Phone: user.Mobile, |
|
IP: user.IP, |
|
PayAccount: k, |
|
} |
|
if user.DeviceId != "00000000-0000-0000-0000-000000000000" { |
|
black.DeviceID = user.DeviceId |
|
} |
|
err := db.Mysql().Create(black) |
|
if err != nil { |
|
log.Error("err:%v", err) |
|
a.Code = values.CodeParam |
|
a.Msg = "该用户信息已在黑名单里" |
|
} |
|
} |
|
} |
|
}
|
|
|