@@ -0,0 +1,244 @@
|
||||
package withdrawctrl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/commod"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/wdordmod"
|
||||
"91porn-server/web/service/withdrawser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
)
|
||||
|
||||
// Refund 手动对特定状态的提现订单执行退款
|
||||
func Refund(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var arg struct {
|
||||
ID string `json:"id" binding:"required"` // 订单id
|
||||
Status int `json:"status" binding:"required"` // 当前订单状态
|
||||
Desc string `json:"desc" binding:"required"` // 原因说明
|
||||
}
|
||||
if err = ctx.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if err = withdrawser.ExchangeRefuseByHand(arg.ID, arg.Status, arg.Desc); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrServerUnavailable, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(arg)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.TradeManageWithdrawOrder, constant.Modify, string(log),
|
||||
ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// Refuse doc
|
||||
// @Summary 拒绝提现
|
||||
// @Description 拒绝提现
|
||||
// @Tags 钱包
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /withdraw/Refuse [post]
|
||||
func Refuse(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var arg struct {
|
||||
ID string `json:"id"` //订单id
|
||||
StatusDesc string `json:"statusDesc"`
|
||||
}
|
||||
if err = ctx.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if err = withdrawser.ExchangeRefuse(arg.ID, arg.StatusDesc, manager); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrServerUnavailable, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(arg)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.TradeManageWithdrawOrder, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// Check doc
|
||||
// @Summary 通过提现
|
||||
// @Description 通过提现
|
||||
// @Tags 钱包
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /withdraw/check [post]
|
||||
func Check(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var arg struct {
|
||||
ID string `json:"id"` //订单id
|
||||
Type int `json:"type"` //0 拒绝 1通过
|
||||
StatusDesc string `json:"statusDesc"`
|
||||
UsdtRate float64 `json:"usdtRate"` //仅订单类型为usdt时必传
|
||||
}
|
||||
if err = ctx.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if arg.Type == 0 { //拒绝
|
||||
err = withdrawser.ExchangeRefuse(arg.ID, arg.StatusDesc, manager)
|
||||
} else if arg.Type == 1 { //通过
|
||||
err = withdrawser.ExchangeAllow(arg.ID, arg.UsdtRate, manager)
|
||||
} else {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, arg.Type)
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
if err.Error() == "unknown" {
|
||||
common.ServeJSON(ctx, stderr.UnkonwErr, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.ErrServerUnavailable, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(arg)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.TradeManageWithdrawOrder, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// ExchgOrder doc
|
||||
// @Summary 充值订单
|
||||
// @Description 充值订单
|
||||
// @Tags product
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /business/order/list [get]
|
||||
func ExchgOrder(ctx *gin.Context) {
|
||||
var arg struct {
|
||||
common.StandQuery
|
||||
wdordmod.WithdrawWebQueryReq
|
||||
}
|
||||
if err := ctx.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
cond, opt := common.StandQueryMap(arg.StandQuery, arg.WithdrawWebQueryReq)
|
||||
//兼容以前没有productType的订单
|
||||
if arg.ProductType != nil && *arg.ProductType == 0 {
|
||||
cond["productType"] = bson.M{"$in": bson.A{0, nil}}
|
||||
}
|
||||
total, data, err := withdrawser.GetAllOrders(cond, opt)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, map[string]interface{}{
|
||||
"total": total,
|
||||
"orders": data,
|
||||
})
|
||||
}
|
||||
|
||||
// ExchgLog doc
|
||||
// @Summary 充值订单
|
||||
// @Description 充值订单
|
||||
// @Tags product
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /business/order/list [get]
|
||||
func ExchgLog(ctx *gin.Context) {
|
||||
var arg struct {
|
||||
common.StandQuery
|
||||
wdordmod.WithdrawQueryReq
|
||||
}
|
||||
if err := ctx.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
total, data, err := wdordmod.FindOrders(common.StandQueryMap(arg.StandQuery, arg.WithdrawQueryReq))
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, map[string]interface{}{
|
||||
"total": total,
|
||||
"orders": data,
|
||||
})
|
||||
}
|
||||
|
||||
// RefundList doc
|
||||
// @Summary 提现退款列表
|
||||
// @Description 提现退款列表
|
||||
// @Tags withdraw
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id query string false "ID"
|
||||
// @Param districtCode query string false "商区码"
|
||||
// @Param uid query integer false "uid"
|
||||
// @Param pageNumber query integer true "当前页"
|
||||
// @Param pageSize query integer true "每页条数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/withdraw/refund/list [get]
|
||||
func RefundList(c *gin.Context) {
|
||||
var arg struct {
|
||||
withdrawser.HumanRefundQuery
|
||||
commod.Page
|
||||
}
|
||||
if err := c.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "districtctrl RefundList arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
page := withdrawser.HumanRefundPage(int64(arg.Skip()), int64(arg.Limit()), arg.HumanRefundQuery)
|
||||
common.ServeJSON(c, stderr.Success, page)
|
||||
}
|
||||
|
||||
// RefundDealWith doc
|
||||
// @Summary 提现退款处理
|
||||
// @Description 提现退款处理
|
||||
// @Tags withdraw
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id query string true "ID"
|
||||
// @Param remark query string false "备注"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/admin/withdraw/refund/dealwith [post]
|
||||
func RefundDealWith(c *gin.Context) {
|
||||
manager, err := common.GetAdminAct(c)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var arg struct {
|
||||
ID string `form:"id" json:"id" binding:"required"`
|
||||
Remark string `form:"remark" json:"remark" binding:"required"`
|
||||
}
|
||||
if err = c.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, "districtctrl RefundDealWith arg error "+err.Error())
|
||||
return
|
||||
}
|
||||
if err = withdrawser.DealWithUnkownOrder(arg.ID, arg.Remark); err != nil {
|
||||
common.ServeJSON(c, stderr.Failure, "districtctrl RefundDealWith error: "+err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(arg)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.TradeManageWithdrawRefund, constant.Modify, string(log), c.Request.URL.RequestURI())
|
||||
common.ServeJSON(c, stderr.Success, "")
|
||||
}
|
||||
Reference in New Issue
Block a user