@@ -0,0 +1,42 @@
|
||||
package userser
|
||||
|
||||
import (
|
||||
"91porn-server/models/v/advanceordermod"
|
||||
"errors"
|
||||
)
|
||||
|
||||
const (
|
||||
TypeCoinVideo = "coinVideo"
|
||||
TypeLuckDraw = "luckDraw"
|
||||
TypeAiUndress = "aiUndress"
|
||||
TypeDownload = "download"
|
||||
)
|
||||
|
||||
type ConsumeReq struct {
|
||||
PrivilegeType string `form:"privilegeType" json:"privilegeType" binding:"required"` // coinVideo:金币视频 luckDraw:抽奖 aiUndress:AI脱衣 download:下载
|
||||
Count int64 `form:"count" json:"count" binding:"required"`
|
||||
}
|
||||
|
||||
// Consume 消费预付权益次数
|
||||
func Consume(uid uint64, privilegeType string, count int64) error {
|
||||
if count < 1 {
|
||||
return errors.New("debit count illegal")
|
||||
}
|
||||
|
||||
debitPlan := advanceordermod.DebitPlan{}
|
||||
switch privilegeType {
|
||||
case TypeCoinVideo:
|
||||
debitPlan.CoinVideoCount = &count
|
||||
//case TypeLuckDraw:
|
||||
// debitPlan.LuckyDrawCount = &count
|
||||
//case TypeAiUndress:
|
||||
// debitPlan.AiUndressCount = &count
|
||||
case TypeDownload:
|
||||
debitPlan.DownloadCount = &count
|
||||
default:
|
||||
return errors.New("debit type illegal")
|
||||
}
|
||||
|
||||
err := advanceordermod.Debit(nil, uid, debitPlan)
|
||||
return err
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package userser
|
||||
|
||||
import (
|
||||
"91porn-server/models/v/vidmod"
|
||||
)
|
||||
|
||||
type VideoListResp struct {
|
||||
List []*vidmod.VideoInfoResp `json:"list"` // 视频列表
|
||||
HasNext bool `json:"hasNext"` // 是否还有下一页
|
||||
Total int64 `json:"total"` // 视频总数
|
||||
}
|
||||
|
||||
type ILikeListRep struct {
|
||||
List any `json:"list"` // 视频,acg 列表
|
||||
HasNext bool `json:"hasNext"` // 是否还有下一页
|
||||
}
|
||||
|
||||
// RegisterRequestH5 H5注册请求
|
||||
type RegisterRequestH5 struct {
|
||||
Mobile string `json:"mobile" form:"mobile"` // 手机号
|
||||
Email string `json:"email" form:"email"` // 邮箱
|
||||
Code string `json:"code" form:"code"` // 验证码
|
||||
PassWord string `json:"passWord" form:"passWord"` // 密码
|
||||
Account string `json:"account" form:"account"` // 账号
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user