init: web_hgdjc_server
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
package authser
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
"videoweb/app/appg"
|
||||
"videoweb/pub/common/log"
|
||||
"videoweb/pub/common/statcenter"
|
||||
"videoweb/pub/common/utils"
|
||||
)
|
||||
|
||||
// UserDistrictInfo 统计中心返回的渠道/直推信息
|
||||
type UserDistrictInfo struct {
|
||||
IsDirect bool `json:"isDirect"`
|
||||
DistrictCode string `json:"districtCode"`
|
||||
ParentPromCode string `json:"parentPromCode"`
|
||||
ParentId uint64 `json:"parentId"`
|
||||
ParentInviteCount int64 `json:"parentInviteCount"`
|
||||
}
|
||||
|
||||
type userDistrictReq struct {
|
||||
AppId int32 `json:"appId"`
|
||||
DistrictCode string `json:"dc"`
|
||||
PromSeqe string `json:"pc"`
|
||||
IP string `json:"ip"`
|
||||
SysType string `json:"sysType"`
|
||||
}
|
||||
|
||||
// resolveUserDistrict 有邀请码视为非直推;否则向统计中心查询补量/直推。
|
||||
func resolveUserDistrict(channel, inviteCode, ip, sysType string) UserDistrictInfo {
|
||||
inviteCode = strings.TrimSpace(inviteCode)
|
||||
if inviteCode != "" {
|
||||
return UserDistrictInfo{IsDirect: false, ParentPromCode: inviteCode}
|
||||
}
|
||||
return GetUserDistictInfo(channel, inviteCode, ip, sysType)
|
||||
}
|
||||
|
||||
// GetUserDistictInfo 查询统计中心用户渠道信息,对齐 ksx_server。
|
||||
func GetUserDistictInfo(dc, pc, ip, sysType string) (districtInfo UserDistrictInfo) {
|
||||
base := strings.TrimSpace(appg.Conf.NewProductUrl)
|
||||
if base == "" {
|
||||
return
|
||||
}
|
||||
request := userDistrictReq{
|
||||
AppId: statcenter.STAT_APPID,
|
||||
SysType: sysType,
|
||||
DistrictCode: dc,
|
||||
PromSeqe: pc,
|
||||
IP: ip,
|
||||
}
|
||||
bodyStr, err := json.Marshal(request)
|
||||
if err != nil {
|
||||
log.Info(fmt.Sprintf("GetUserDistictInfo json.Marshal is fail error:%+v/data:%+v", err, request))
|
||||
return
|
||||
}
|
||||
url := strings.TrimRight(base, "/") + "/api/stat/userInvite/district"
|
||||
code, err := utils.POSTWithJResp(&districtInfo, url, nil, bodyStr)
|
||||
if err != nil {
|
||||
log.Error("GetUserDistictInfo POSTWithJResp", log.Any("url", url), log.E(err))
|
||||
return
|
||||
}
|
||||
if code != http.StatusOK {
|
||||
log.Error("GetUserDistictInfo response status", log.Any("code", code))
|
||||
}
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user