Initial commit

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-15 13:57:10 +08:00
co-authored by Claude Opus 5
commit 8679200f41
1897 changed files with 257900 additions and 0 deletions
+103
View File
@@ -0,0 +1,103 @@
package userser
import (
"context"
"fmt"
"net/http"
"time"
"91porn-server/app/appg"
"91porn-server/common/httputil"
"91porn-server/common/log"
"91porn-server/models/commod"
)
type UserDistrictReq struct {
AppId int32 `form:"appId" json:"appId" binding:"required"` // APPID
DistrictCode string `json:"dc"` // 剪切板信息 dc(渠道)
PromSeqe string `json:"pc"` // 剪切板信息 pc(代理)
IP string `json:"ip"` // IP信息
SysType string `json:"sysType"` // 操作系统类型 安卓 IOS
}
type UserDistrictInfo struct {
IsDirect bool `json:"isDirect"` // 是否是直推
DistrictCode string `json:"districtCode"` // 渠道码
ParentPromCode string `json:"parentPromCode"` // 全民代理 上级用户推广码
ParentId uint64 `json:"parentId"` // 全名代理 上级用户
ParentInviteCount int64 `json:"parentInviteCount"` // 全名代理 上级用户下级用户
}
type ShareUrlReq struct {
AppId int32 `from:"appid" json:"appid"` // AppID
}
// 落地页获取显示的按钮信息
type ShareUrlResp struct {
Url []string `from:"url" json:"url"` // 分享地址
}
func GetUserDistictInfo(dc, pc, ip, sysType string) (dictrictInfo UserDistrictInfo) {
url := appg.Conf.URL.ProductUrl + "/api/stat/userInvite/district"
// 设置默认值
request := UserDistrictReq{
AppId: commod.KFK_APPID,
SysType: sysType,
DistrictCode: dc,
PromSeqe: pc,
IP: ip,
}
//限制有渠道码or分享码的就不请求统计中心参与补量查询
if dc != "" || pc != "" {
if pc != "" {
dictrictInfo.IsDirect = false
dictrictInfo.ParentPromCode = pc
} else {
dictrictInfo.IsDirect = true
dictrictInfo.DistrictCode = dc
}
return
}
// 2秒超时
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
defer cancel()
if err := httpRequest(ctx, url, &request, &dictrictInfo); err != nil {
log.Error("GetUserDistictInfo HttpRequest", log.Any("url", url), log.Any("request", request), log.E(err))
if pc != "" {
dictrictInfo.IsDirect = false
dictrictInfo.ParentPromCode = pc
} else {
dictrictInfo.IsDirect = true
dictrictInfo.DistrictCode = dc
}
return
}
fmt.Println("resp", dictrictInfo)
return dictrictInfo
}
func httpRequest(ctx context.Context, url string, request interface{}, resp interface{}) error {
code, err := httputil.DefaultClientPostJsonWithRespWithCtx(ctx, resp, url, nil, &request)
if err != nil {
log.Error("HttpRequest err", log.Any("Url", url), log.E(err))
return err
}
if code != http.StatusOK {
log.Error("HttpRequest err", log.Any("code", code))
return fmt.Errorf("code err, %d", code)
}
return nil
}
func UserShareList(ctx context.Context) (urls []string, err error) {
request := ShareUrlReq{
AppId: commod.KFK_APPID,
}
url := appg.Conf.URL.ProductUrl + "/api/stat/share/list"
resp := &ShareUrlResp{}
if err = httpRequest(ctx, url, &request, resp); err != nil {
log.Error("UserInviteRechargeHandle HttpRequest", log.Any("url", url), log.Any("request", request), log.E(err))
return nil, err
}
return resp.Url, nil
}