143 lines
3.3 KiB
Go
143 lines
3.3 KiB
Go
package app
|
|
|
|
import (
|
|
"git.echol.cn/loser/lckt/global"
|
|
"git.echol.cn/loser/lckt/model/app"
|
|
"git.echol.cn/loser/lckt/model/app/request"
|
|
r "git.echol.cn/loser/lckt/model/common/response"
|
|
"git.echol.cn/loser/lckt/utils"
|
|
"github.com/gin-gonic/gin"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
// WithApi 提现接口
|
|
type WithApi struct{}
|
|
|
|
// Create 创建提现请求
|
|
func (w *WithApi) Create(c *gin.Context) {
|
|
var p app.With
|
|
if err := c.ShouldBind(&p); err != nil {
|
|
r.FailWithMessage("申请提现参数有误:", c)
|
|
global.GVA_LOG.Error("申请提现参数有误:", zap.Error(err))
|
|
return
|
|
}
|
|
|
|
userId := utils.GetUserID(c)
|
|
p.UserID = userId
|
|
p.Status = 1 // 设置状态为待处理
|
|
|
|
err := withService.Create(p)
|
|
if err != nil {
|
|
r.FailWithMessage("创建提现请求失败", c)
|
|
return
|
|
}
|
|
|
|
r.OkWithMessage("申请提现请求成功", c)
|
|
}
|
|
|
|
// GetList 获取提现列表
|
|
func (w *WithApi) GetList(c *gin.Context) {
|
|
var p request.GetWithList
|
|
if err := c.ShouldBind(&p); err != nil {
|
|
r.FailWithMessage("获取提现列表参数有误:", c)
|
|
global.GVA_LOG.Error("获取提现列表参数有误:", zap.Error(err))
|
|
return
|
|
}
|
|
|
|
userId := utils.GetUserID(c)
|
|
p.UserId = userId
|
|
|
|
list, total, err := withService.GetList(p)
|
|
if err != nil {
|
|
r.FailWithMessage("获取提现列表失败", c)
|
|
return
|
|
}
|
|
|
|
r.OkWithDetailed(r.PageResult{
|
|
List: list,
|
|
Total: total,
|
|
Page: p.Page,
|
|
PageSize: p.PageSize,
|
|
}, "获取提现列表成功", c)
|
|
}
|
|
|
|
// Cancel 取消提现请求
|
|
func (w *WithApi) Cancel(c *gin.Context) {
|
|
var p app.With
|
|
if err := c.ShouldBind(&p); err != nil {
|
|
r.FailWithMessage("取消提现请求参数有误:", c)
|
|
global.GVA_LOG.Error("取消提现请求参数有误:", zap.Error(err))
|
|
return
|
|
}
|
|
|
|
userId := utils.GetUserID(c)
|
|
p.UserID = userId
|
|
|
|
if p.ID == 0 {
|
|
r.FailWithMessage("提现ID不能为空", c)
|
|
return
|
|
}
|
|
|
|
p.Status = 4 // 设置状态为取消
|
|
|
|
err := withService.UpdateStatus(p)
|
|
if err != nil {
|
|
r.FailWithMessage("取消提现请求失败", c)
|
|
return
|
|
}
|
|
|
|
r.OkWithMessage("取消提现请求成功", c)
|
|
}
|
|
|
|
// =============管理后台接口=================
|
|
|
|
// GetAdminList 获取提现列表(管理员)
|
|
func (w *WithApi) GetAdminList(c *gin.Context) {
|
|
var p request.GetWithList
|
|
if err := c.ShouldBind(&p); err != nil {
|
|
r.FailWithMessage("获取提现列表参数有误:", c)
|
|
global.GVA_LOG.Error("获取提现列表参数有误:", zap.Error(err))
|
|
return
|
|
}
|
|
|
|
list, total, err := withService.GetList(p)
|
|
if err != nil {
|
|
r.FailWithMessage("获取提现列表失败", c)
|
|
return
|
|
}
|
|
|
|
r.OkWithDetailed(r.PageResult{
|
|
List: list,
|
|
Total: total,
|
|
Page: p.Page,
|
|
PageSize: p.PageSize,
|
|
}, "获取提现列表成功", c)
|
|
}
|
|
|
|
// UpdateStatus 更新提现状态(管理员)
|
|
func (w *WithApi) UpdateStatus(c *gin.Context) {
|
|
var p app.With
|
|
if err := c.ShouldBind(&p); err != nil {
|
|
r.FailWithMessage("更新提现状态参数有误:", c)
|
|
global.GVA_LOG.Error("更新提现状态参数有误:", zap.Error(err))
|
|
return
|
|
}
|
|
|
|
if p.ID == 0 {
|
|
r.FailWithMessage("提现ID不能为空", c)
|
|
return
|
|
}
|
|
if p.Status == 0 {
|
|
r.FailWithMessage("提现状态不能为空", c)
|
|
return
|
|
}
|
|
|
|
err := withService.UpdateStatus(p)
|
|
if err != nil {
|
|
r.FailWithMessage("更新提现状态失败", c)
|
|
return
|
|
}
|
|
|
|
r.OkWithMessage("更新提现状态成功", c)
|
|
}
|