134 lines
3.7 KiB
Go
134 lines
3.7 KiB
Go
package proxyctrl
|
|
|
|
import (
|
|
"91porn-server/common"
|
|
"91porn-server/common/stderr"
|
|
"91porn-server/models/v/proxyincomemod"
|
|
"91porn-server/models/v/proxymod"
|
|
"91porn-server/web/service/proxyser"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// ProxyLog doc
|
|
// @Summary 用户推广日志
|
|
// @Description 用户推广日志
|
|
// @Tags product
|
|
// @Accept mpfd,json
|
|
// @Produce json,html
|
|
// @Success 200 {string} json "{"msg": "操作成功"}"
|
|
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
|
// @Router /proxy/log [get]
|
|
func ProxyLog(ctx *gin.Context) {
|
|
var arg struct {
|
|
common.StandQuery
|
|
proxymod.InvitationQueryReq
|
|
}
|
|
if err := ctx.ShouldBind(&arg); err != nil {
|
|
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
|
return
|
|
}
|
|
total, data, err := proxymod.FindMany(common.StandQueryMap(arg.StandQuery, arg.InvitationQueryReq))
|
|
if err != nil {
|
|
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
|
return
|
|
}
|
|
common.ServeJSON(ctx, stderr.Success, map[string]interface{}{
|
|
"total": total,
|
|
"history": data,
|
|
})
|
|
}
|
|
|
|
// AllIncome doc
|
|
// @Summary 代理列表
|
|
// @Description 代理列表
|
|
// @Tags product
|
|
// @Accept mpfd,json
|
|
// @Produce json,html
|
|
// @Success 200 {string} json "{"msg": "操作成功"}"
|
|
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
|
// @Router /proxy/allIncome [get]
|
|
func AllIncome(ctx *gin.Context) {
|
|
var arg struct {
|
|
UID uint64 `json:"uid" form:"uid"`
|
|
}
|
|
if err := ctx.ShouldBind(&arg); err != nil {
|
|
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
|
return
|
|
}
|
|
data, err := proxyser.FindTotalIncome(arg.UID)
|
|
if err != nil {
|
|
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
|
return
|
|
}
|
|
common.ServeJSON(ctx, stderr.Success, data)
|
|
}
|
|
|
|
// IncomeDetails doc
|
|
// @Summary 代理列表
|
|
// @Description 查询收益详情
|
|
// @Tags product
|
|
// @Accept mpfd,json
|
|
// @Produce json,html
|
|
// @Success 200 {string} json "{"msg": "操作成功"}"
|
|
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
|
// @Router /proxy/i/income/details [get]
|
|
func IncomeDetails(ctx *gin.Context) {
|
|
var arg struct {
|
|
proxyincomemod.StandReq
|
|
common.StandQuery
|
|
}
|
|
if err := ctx.ShouldBind(&arg); err != nil {
|
|
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
|
return
|
|
}
|
|
total, data, err := proxyincomemod.FindList(common.StandQueryMap(arg.StandQuery, arg.StandReq))
|
|
if err != nil {
|
|
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
|
return
|
|
}
|
|
//获取条件下总收益
|
|
totalIncome, err := proxyincomemod.GetTotalIncome(arg.UID, arg.StartTime, arg.EndTime)
|
|
if err != nil {
|
|
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
|
return
|
|
}
|
|
common.ServeJSON(ctx, stderr.Success, gin.H{
|
|
"total": total,
|
|
"data": data,
|
|
"totalIncome": totalIncome,
|
|
})
|
|
}
|
|
|
|
// PromotionQuery doc
|
|
// @Summary 推广查询
|
|
// @Description 推广查询
|
|
// @Tags product
|
|
// @Accept mpfd,json
|
|
// @Produce json,html
|
|
// @Success 200 {string} json "{"msg": "操作成功"}"
|
|
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
|
// @Router /proxy/promotion [get]
|
|
func PromotionQuery(ctx *gin.Context) {
|
|
var arg struct {
|
|
UID uint64 `json:"uid" form:"uid"`
|
|
Type string `json:"type" form:"type"`
|
|
}
|
|
err := ctx.ShouldBind(&arg)
|
|
if err != nil {
|
|
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
|
return
|
|
}
|
|
var data interface{}
|
|
if arg.Type == "up" { //获取上级代理
|
|
data, err = proxyser.GetInvrDetails(arg.UID)
|
|
} else { //获取下级代理
|
|
data, err = proxyser.GetInveUsers(arg.UID)
|
|
}
|
|
if err != nil {
|
|
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
|
return
|
|
}
|
|
common.ServeJSON(ctx, stderr.Success, data)
|
|
}
|