Files
rootandClaude Opus 5 8679200f41 Initial commit
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-15 13:57:10 +08:00

247 lines
7.0 KiB
Go

package walletctrl
import (
"91porn-server/app/service/walletser"
"91porn-server/common"
"91porn-server/common/stderr"
"91porn-server/models/commod"
"91porn-server/models/l/payvidlgmod"
"91porn-server/models/v/txnmod"
"91porn-server/models/v/usermod"
"github.com/gin-gonic/gin"
)
// GetBill doc
// @Summary --我的账单
// @Description 我的账单
// @Tags 钱包
// @Accept mpfd,json
// @Produce json,html
// @Param pageNumber formData int true "页码"
// @Param pageSize formData int true "条数"
// @Success 200 {string} json "{"msg": "操作成功"}"
// @Failure 400 {string} json "{"msg": "操作失败"}"
// @Router /api/app/mine/bills [get]
func GetBill(ctx *gin.Context) {
uid, err := common.GetUID(ctx)
if err != nil {
common.ServeJSON(ctx, stderr.ErrNoToken, err)
return
}
var arg struct {
Timestamp int64 `form:"timeline"`
}
if err = ctx.ShouldBind(&arg); err != nil {
common.ServeJSON(ctx, stderr.ErrParamError, err)
return
}
data, hasNext, nextTimeline, err := walletser.GetBills(uid, arg.Timestamp)
if err != nil {
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
return
}
common.ServeJSON(ctx, stderr.Success, gin.H{
"hasNext": hasNext,
"list": data,
"timeline": nextTimeline,
})
}
// GetNewBill doc
// @Summary --我的账单新
// @Description 我的账单
// @Tags 钱包
// @Accept mpfd,json
// @Produce json,html
// @Param year query string true "年"
// @Param month query string true "月"
// @Param pageNumber query int true "页码"
// @Param pageSize query int true "条数"
// @Success 200 {object} txnmod.Bills1Res "{"msg": "操作成功"}"
// @Failure 400 {string} json "{"msg": "操作失败"}"
// @Router /api/app/mine/zhangdan [get]
func GetNewBill(ctx *gin.Context) {
uid, err := common.GetUID(ctx)
if err != nil {
common.ServeJSON(ctx, stderr.ErrNoToken, err)
return
}
var arg struct {
Month int `form:"month"`
Year int `form:"year"`
commod.Page
}
if err = ctx.ShouldBind(&arg); err != nil {
common.ServeJSON(ctx, stderr.ErrParamError, err)
return
}
data, err := walletser.GetBills1(uid, arg.Year, arg.Month, arg.PageNumber, arg.PageSize)
if err != nil {
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
return
}
common.ServeJSON(ctx, stderr.Success, data)
}
// GetWorksIncome doc
// @Summary 我的作品--帖子收入记录详情
// @Description 查询收入记录详情
// @Tags 钱包
// @Accept mpfd,json
// @Produce json,html
// @Param pageNumber formData int true "页码"
// @Param pageSize formData int true "条数"
// @Success 200 {string} json "{"msg": "操作成功"}"
// @Failure 400 {string} json "{"msg": "操作失败"}"
// @Router /api/app/mine/income/works [get]
func GetWorksIncome(ctx *gin.Context) {
uid, err := common.GetUID(ctx)
if err != nil {
common.ServeJSON(ctx, stderr.ErrNoToken, err)
return
}
var page commod.Page
if err = ctx.ShouldBind(&page); err != nil {
common.ServeJSON(ctx, stderr.ErrParamError, err)
return
}
//total, totalAmount, data, hasNext, err := payvidlgmod.FindThreeMonthVideoPayRecord(uid, arg.PageNumber, arg.PageSize)
//if err != nil {
// common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
// return
//}
//common.ServeJSON(ctx, stderr.Success, gin.H{
// "total": total,
// "totalIncome": totalAmount,
// "history": data,
// "list": data,
// "hasNext": hasNext,
//})
list, next, err := payvidlgmod.GetWorksIncomeList(uid, page)
if err != nil {
common.ServeJSON(ctx, stderr.ErrDbQueryError, nil)
return
}
common.ServeJSON(ctx, stderr.Success, gin.H{
"list": list,
"hasNext": next,
})
}
// GetIncome doc
// @Summary --收益明细
// @Description 收益明细
// @Tags 钱包
// @Accept mpfd,json
// @Produce json,html
// @Param startTime query string false "开始时间"
// @Param endTime query string false "结束时间"
// @Param pageNumber formData int true "页码"
// @Param pageSize formData int true "条数"
// @Success 200 {object} txnmod.TransactionLog "{"list": [],"hasNext":false}"
// @Failure 400 {string} json "{"msg": "操作失败"}"
// @Router /app/mine/iIncomes [get]
func GetIncome(ctx *gin.Context) {
uid, err := common.GetUID(ctx)
if err != nil {
common.ServeJSON(ctx, stderr.ErrNoToken, err)
return
}
var arg struct {
commod.Page
}
if err = ctx.ShouldBind(&arg); err != nil {
common.ServeJSON(ctx, stderr.ErrParamError, err)
return
}
data, hasNext, err := txnmod.FindIncome(uid, arg.PageNumber, arg.PageSize)
if err != nil {
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
return
}
var rechargeIds []uint64
for _, d := range data {
rechargeIds = append(rechargeIds, d.RechargeId)
}
if len(rechargeIds) > 0 {
// 获取用户信息
users, err := usermod.FindUsersMapByUID(rechargeIds)
if err != nil {
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
return
}
mUser := make(map[uint64]*txnmod.RechargeUserInfo)
if len(users) > 0 {
for _, u := range users {
ru := txnmod.RechargeUserInfo{
UID: u.UID,
Name: u.Name,
Portrait: u.Portrait,
}
mUser[u.UID] = &ru
}
}
for _, d := range data {
if d.RechargeId != 0 {
d.RechargeUser = *mUser[d.RechargeId]
}
}
}
common.ServeJSON(ctx, stderr.Success, gin.H{
"list": data,
"hasNext": hasNext,
})
}
// GetAllIncome doc
// @Summary --收益明细
// @Description 收益明细
// @Tags 钱包
// @Accept mpfd,json
// @Produce json,html
// @Param startTime query string false "开始时间"
// @Param endTime query string false "结束时间"
// @Param pageNumber formData int true "页码"
// @Param pageSize formData int true "条数"
// @Success 200 {string} json "{"msg": "操作成功"}"
// @Failure 400 {string} json "{"msg": "操作失败"}"
// @Router /api/app/mine/getAllIncome [get]
func GetAllIncome(ctx *gin.Context) {
uid, err := common.GetUID(ctx)
if err != nil {
common.ServeJSON(ctx, stderr.ErrNoToken, err)
return
}
data, err := walletser.GetIncome(uid)
if err != nil {
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
return
}
common.ServeJSON(ctx, stderr.Success, data)
}
func FruitCoinBill(c *gin.Context) {
uid, err := common.GetUID(c)
if err != nil {
common.ServeJSON(c, stderr.ErrNoToken, err)
return
}
var in = new(walletser.FruitCoinBillCond)
if err = c.ShouldBindQuery(&in); err != nil {
common.ServeJSON(c, stderr.ErrParamError, err)
return
}
data, code := walletser.FruitCoinBill(uid, in)
if code != stderr.Success {
common.ServeJSON(c, code, nil)
return
}
common.ServeJSON(c, code, data)
}