🎨 新增提现功能
This commit is contained in:
@@ -8,6 +8,7 @@ type ApiGroup struct {
|
||||
OrderApi
|
||||
TeacherVip
|
||||
RedeemCodeApi
|
||||
WithApi
|
||||
}
|
||||
|
||||
var userService = service.ServiceGroupApp.UserServiceGroup.UserService
|
||||
@@ -16,3 +17,4 @@ var bannerService = service.ServiceGroupApp.AppServiceGroup.BannerService
|
||||
var orderService = service.ServiceGroupApp.AppServiceGroup.OrderService
|
||||
var teacherVipService = service.ServiceGroupApp.AppServiceGroup.TeacherVipService
|
||||
var redeemCodeService = service.ServiceGroupApp.AppServiceGroup.RedeemCodeService
|
||||
var withService = service.ServiceGroupApp.AppServiceGroup.WithService
|
||||
|
||||
142
api/v1/app/with.go
Normal file
142
api/v1/app/with.go
Normal file
@@ -0,0 +1,142 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user