forked from all_user/stat_center
Initial commit
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
package userinviteser
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"stat/api/proto"
|
||||
"stat/common/log"
|
||||
"stat/models/channelmod"
|
||||
"stat/models/downloadinfo"
|
||||
"stat/models/registermod"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
)
|
||||
|
||||
func UserDistictInfo(ctx context.Context, param proto.UserDistrictReq) (data interface{}, err error) {
|
||||
dictrictInfo := proto.UserDistrictInfo{}
|
||||
dictrictInfo.IsDirect = true
|
||||
dictrictInfo.DistrictCode = param.DistrictCode
|
||||
|
||||
if param.IP != "" {
|
||||
if param.DistrictCode != "" {
|
||||
channelInfo, _ := channelmod.FindOneChannelInfo(ctx, bson.M{channelmod.FN.ChannelInfo.Channel: param.DistrictCode})
|
||||
if channelInfo == nil || channelInfo.Channel != param.DistrictCode {
|
||||
param.DistrictCode = ""
|
||||
}
|
||||
}
|
||||
if param.DistrictCode == "" {
|
||||
// 根据IP查询是否下载
|
||||
data, _ := downloadinfo.FindOneChannelIP(ctx, param.AppId, param.IP, param.SysType)
|
||||
if data.DC != "" {
|
||||
log.Info("channel info by IP ", log.Any("IP", param.IP), log.Any("app", param.AppId), log.Any("dc", data.DC))
|
||||
dictrictInfo.IsDirect = true
|
||||
dictrictInfo.DistrictCode = data.DC
|
||||
}
|
||||
if data.PC != "" && param.PromSeqe == "" {
|
||||
log.Info("channel info by IP ", log.Any("IP", param.IP), log.Any("app", param.AppId), log.Any("dc", data.DC))
|
||||
dictrictInfo.IsDirect = false
|
||||
dictrictInfo.ParentPromCode = data.PC
|
||||
}
|
||||
}
|
||||
}
|
||||
return dictrictInfo, nil
|
||||
}
|
||||
|
||||
func UserDistrictCodeInfo(ctx context.Context, param proto.UserDistrictCodeReq) (data interface{}, err error) {
|
||||
resp := proto.UserDistrictCodeResp{
|
||||
UserList: make([]proto.UserDistrictCodeInfo, 0),
|
||||
}
|
||||
for _, userId := range param.UserIds {
|
||||
registerInfo, _ := registermod.GetRegisterInfo(ctx, userId, param.AppId)
|
||||
codeInfo := proto.UserDistrictCodeInfo{
|
||||
UserId: registerInfo.UserId,
|
||||
RegisterTime: registerInfo.RegisterTime,
|
||||
DistrictCode: registerInfo.DistrictCode,
|
||||
}
|
||||
resp.UserList = append(resp.UserList, codeInfo)
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
Reference in New Issue
Block a user