Initial commit

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-15 13:57:10 +08:00
co-authored by Claude Opus 5
commit 8679200f41
1897 changed files with 257900 additions and 0 deletions
+57
View File
@@ -0,0 +1,57 @@
package withdrawctrl
import (
"bytes"
"errors"
"fmt"
"net/http"
"strconv"
"91porn-server/common/log"
"91porn-server/common/rchgutil"
"91porn-server/web/service/withdrawser"
"github.com/gin-gonic/gin"
)
// GoldFishCallBack 金鱼结构回调函数
func GoldFishCallBack(ctx *gin.Context) {
if err := func() error {
exchg := rchgutil.GoldFishExchangeRes{}
e := rchgutil.GoldFishExchange{}
if err := ctx.ShouldBindJSON(&exchg); err != nil {
log.Error(fmt.Sprintf("GoldFish callback parameter bind fail error:%+v:", err))
return err
}
log.Info(fmt.Sprintf("GoldFish callback parameter data:%+v:", exchg))
buf := bytes.Buffer{}
buf.WriteString(strconv.Itoa(exchg.Code))
buf.WriteString(exchg.Mark)
buf.WriteString(exchg.MercID)
buf.WriteString(exchg.Money)
buf.WriteString(exchg.OID)
buf.WriteString(exchg.Status)
buf.WriteString(exchg.TradeNo)
buf.WriteString(e.GetAppSecret())
if !rchgutil.VerifySign(exchg.Sign, buf.String()) {
log.Error("GoldFish callback sign verify fail")
return errors.New("check sign fail")
}
moneyf, err := strconv.ParseFloat(exchg.Money, 64)
if err != nil {
log.Error(fmt.Sprintf("GoldFish callback ParseFloat fail error:%+v:", err))
return err
}
moneyf = moneyf * 100
money := int64(moneyf)
if err = withdrawser.ExchgCallBack(exchg.TradeNo, exchg.OID, money, exchg.Status, exchg.Mark); err != nil {
log.Error(fmt.Sprintf("GoldFish RechargeCallBack fail error:%+v:", err))
return err
}
return nil
}(); err != nil {
ctx.String(http.StatusBadRequest, "fail")
return
}
ctx.String(http.StatusOK, "success")
}
+58
View File
@@ -0,0 +1,58 @@
package withdrawctrl
import (
"91porn-server/common"
"91porn-server/common/stderr"
"91porn-server/models/v/txnactmod"
"github.com/gin-gonic/gin"
"go.mongodb.org/mongo-driver/bson/primitive"
)
func FindAct(ctx *gin.Context) {
q := txnactmod.Query{}
if err := ctx.ShouldBind(&q); err != nil {
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
return
}
infos, err := txnactmod.FindMany(q)
if err != nil {
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
return
}
common.ServeJSON(ctx, stderr.Success, infos)
}
func EditAct(ctx *gin.Context) {
var p struct {
ID primitive.ObjectID `json:"id"`
txnactmod.TransactionActSelector
}
if err := ctx.ShouldBind(&p); err != nil {
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
return
}
c, err := txnactmod.Update(p.ID, &p.TransactionActSelector)
if err != nil || c < 0 {
common.ServeJSON(ctx, stderr.ErrDbUpdateError, err.Error())
return
}
common.ServeJSON(ctx, stderr.Success, "")
}
func DelAct(ctx *gin.Context) {
var p struct {
ID primitive.ObjectID `json:"id"`
}
if err := ctx.ShouldBind(&p); err != nil {
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
return
}
c, err := txnactmod.DeleteByID(p.ID)
if err != nil || c < 0 {
common.ServeJSON(ctx, stderr.ErrDbDeleteError, err.Error())
return
}
common.ServeJSON(ctx, stderr.Success, "")
}
+244
View File
@@ -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, "")
}
+198
View File
@@ -0,0 +1,198 @@
package withdrawctrl
import (
"encoding/json"
"fmt"
"time"
"91porn-server/common"
"91porn-server/common/constant"
"91porn-server/common/constant/redisconst"
"91porn-server/common/log"
"91porn-server/common/stderr"
"91porn-server/models/l/operatorlgmod"
"91porn-server/models/v/wdchannmod"
"91porn-server/models/v/wdtaxmod"
"91porn-server/web/service/withdrawser"
"91porn-server/web/webg"
"github.com/gin-gonic/gin"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
)
// GetChannel doc
// @Summary 获取提现渠道
// @Description 获取提现渠道
// @Tags withdraw
// @Accept mpfd,json
// @Produce json,html
// @Success 200 {string} json "{"msg": "操作成功"}"
// @Failure 400 {string} json "{"msg": "操作失败"}"
// @Router /api/web/withdraw/channel/list [get]
func GetChannel(ctx *gin.Context) {
infos, err := withdrawser.WithdrawType()
if err != nil {
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
return
}
common.ServeJSON(ctx, stderr.Success, infos)
}
// ChannelInsert doc
// @Summary 新增
// @Description 新增
// @Tags withdraw
// @Accept mpfd,json
// @Produce json,html
// @Param reachargeDetails formData wdchannmod.ChannelReq ture "product卡"
// @Success 200 {string} json "{"msg": "操作成功"}"
// @Failure 400 {string} json "{"msg": "操作失败"}"
// @Router /api/web/withdraw/channel/add [post]
func ChannelInsert(ctx *gin.Context) {
manager, err := common.GetAdminAct(ctx)
if err != nil {
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
return
}
req := wdchannmod.ChannelReq{}
if err = ctx.ShouldBind(&req); err != nil {
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
return
}
pc := wdchannmod.WithdrawChannel{
ChannelName: req.ChannelName,
CID: req.CID,
PayType: req.PayType,
MinMoney: req.MinMoney,
QpMinMoney: req.QpMinMoney,
MaxMoney: req.MaxMoney,
Weight: req.Weight,
UpdatedAt: time.Now(),
CreatedAt: time.Now(),
}
if err = wdchannmod.InsertWithdrawChannel(&pc); err != nil {
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
return
}
common.Go(func() {
_, _ = webg.Redis.Del(redisconst.WithdrawCfgCacheKey())
})
log, _ := json.Marshal(req)
_ = operatorlgmod.RecordOperation(manager, constant.TradeManageWithdrawType, constant.Add, string(log), ctx.Request.URL.RequestURI())
common.ServeJSON(ctx, stderr.Success, nil)
}
// ChannelUpdate doc
// @Summary 编辑提现渠道
// @Description 编辑提现渠道
// @Tags withdraw
// @Accept mpfd,json
// @Produce json,html
// @Success 200 {string} json "{"msg": "操作成功"}"
// @Failure 400 {string} json "{"msg": "操作失败"}"
// @Router /api/web/withdraw/channel/update [post]
func ChannelUpdate(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"`
wdchannmod.WithdrawChannelSelector
}
if err = ctx.ShouldBind(&arg); err != nil {
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
return
}
cnt, err := wdchannmod.UpdateWithdrawChannel(arg.ID, &arg.WithdrawChannelSelector)
if err != nil {
common.ServeJSON(ctx, stderr.ErrDbUpdateError, err.Error())
return
}
common.Go(func() {
_, _ = webg.Redis.Del(redisconst.WithdrawCfgCacheKey())
})
log, _ := json.Marshal(arg)
_ = operatorlgmod.RecordOperation(manager, constant.TradeManageWithdrawType, constant.Modify, string(log), ctx.Request.URL.RequestURI())
common.ServeJSON(ctx, stderr.Success, wdchannmod.OpeResp{Count: cnt})
}
// ChannelDelete doc
// @Summary 删除
// @Description 删除
// @Tags withdraw
// @Accept mpfd,json
// @Produce json,html
// @Param id formData int true "product等级""
// @Success 200 {string} json "{"msg": "操作成功"}"
// @Failure 400 {string} json "{"msg": "操作失败"}"
// @Router /api/web/withdraw/channel/delete [delete]
func ChannelDelete(ctx *gin.Context) {
manager, err := common.GetAdminAct(ctx)
if err != nil {
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
return
}
req := wdchannmod.DelReq{}
if err = ctx.ShouldBind(&req); err != nil {
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
return
}
oids := make([]primitive.ObjectID, 0, len(req.IDs))
for _, id := range req.IDs {
oid, err := primitive.ObjectIDFromHex(id)
if err != nil {
log.Error(fmt.Sprintf("exchange string(%s) to objectID error.", id))
continue
}
oids = append(oids, oid)
}
cond := bson.M{"_id": bson.M{"$in": oids}}
cnt, err := wdchannmod.DeleteWithdrawChannel(cond)
if err != nil {
common.ServeJSON(ctx, stderr.ErrDbDeleteError, err.Error())
return
}
common.Go(func() {
_, _ = webg.Redis.Del(redisconst.WithdrawCfgCacheKey())
})
log, _ := json.Marshal(req)
_ = operatorlgmod.RecordOperation(manager, constant.TradeManageWithdrawType, constant.Delete, string(log), ctx.Request.URL.RequestURI())
common.ServeJSON(ctx, stderr.Success, wdchannmod.OpeResp{Count: cnt})
}
// ChannelBatch doc
// @Summary 编辑提现税率
// @Description 编辑提现税率
// @Tags withdraw
// @Accept mpfd,json
// @Produce json,html
// @Success 200 {string} json "{"msg": "操作成功"}"
// @Failure 400 {string} json "{"msg": "操作失败"}"
// @Router /api/web/withdraw/channel/batch [post]
func ChannelBatch(ctx *gin.Context) {
manager, err := common.GetAdminAct(ctx)
if err != nil {
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
return
}
set := wdtaxmod.WithdrawTariffSelector{}
if err = ctx.ShouldBind(&set); err != nil {
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
return
}
cnt, err := wdtaxmod.UpdateWithDrawTariff(set)
if err != nil {
common.ServeJSON(ctx, stderr.ErrDbUpdateError, err.Error())
return
}
common.Go(func() {
_, _ = webg.Redis.Del(redisconst.WithdrawTariffCacheKey())
})
log, _ := json.Marshal(set)
_ = operatorlgmod.RecordOperation(manager, constant.TradeManageWithdrawType, constant.Modify, string(log), ctx.Request.URL.RequestURI())
common.ServeJSON(ctx, stderr.Success, wdchannmod.OpeResp{Count: cnt})
}
+34
View File
@@ -0,0 +1,34 @@
package withdrawctrl
import (
"fmt"
"net/http"
"91porn-server/common/log"
"91porn-server/common/rchgutil"
"91porn-server/common/stderr"
"91porn-server/web/service/withdrawser"
"github.com/gin-gonic/gin"
)
// GoldFishCallBack 金鱼结构回调函数
func YinseCallBack(ctx *gin.Context) {
ctx.JSON(http.StatusOK, func() (msg rchgutil.ExchgBackMsg) {
exchg := rchgutil.ExchgBack{}
msg.Code = int(stderr.Failure)
if err := ctx.ShouldBindJSON(&exchg); err != nil {
msg.Err = fmt.Sprintf("GoldFish callback parameter bind fail error:%+v:", err)
log.Error(msg.Err)
return
}
log.Info(fmt.Sprintf("GoldFish callback parameter data:%+v:", exchg))
if err := withdrawser.ExchgCallBack(exchg.TradeNo, exchg.OID, exchg.Money, exchg.Status, exchg.Mark); err != nil {
msg.Err = fmt.Sprintf("GoldFish RechargeCallBack fail error:%+v:", err)
log.Error(msg.Err)
return
}
msg.Code = int(stderr.Success)
return
}())
}