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
+131
View File
@@ -0,0 +1,131 @@
package rchgutil
import (
"encoding/json"
"fmt"
"net/http"
"strconv"
"time"
"91porn-server/common/httputil"
"91porn-server/common/log"
"91porn-server/models/v/wdordmod"
"91porn-server/web/webg"
)
type Exchg struct {
TransNo string `json:"transNo" bson:"transNo"` //订单号
UID string `json:"uid" bson:"uid"` //用户id
Name string `json:"name" bson:"name"` //用户名
PayMoney int64 `json:"payMoney" bson:"payMoney"` //实际到账
PayType string `json:"payType" bson:"payType" binding:"required"` //提现方式,alipaybankcard
ActName string `json:"actName" bson:"actName"` //交易账户持有人
Act string `json:"act" bson:"act"` //交易账户
UserIP string `json:"userIp" bson:"userIp"` //用户ip
DeviceType string `json:"deviceType" bson:"deviceType"` //设备类型
DevID string `json:"devID" bson:"devID"` //设备id
CheckedAt time.Time `json:"checkedAt" bson:"checkedAt"` //审核时间
NotifyUrl string `json:"notifyUrl"` //回调地址
ProductType int `json:"productType"` //支付产品类型 0 站群 1 棋牌
Rate float64 `json:"rate"` //费率
PlatformID string `json:"platformID"`
BankCode string `json:"bankCode" bson:"bankCode"` //银行编码
}
type ExchgBack struct {
OID string `json:"oid" ` //支付平台订单号
Money int64 `json:"money"` //兑换金额
TradeNo string `json:"tradeNo"` //商户订单号
Status string `json:"status"`
Mark string `json:"mark"` //拒绝兑换理由
}
type ExchgBackMsg struct {
Code int `json:"code"`
Err string `json:"err"`
}
type ExchgMsg struct {
OID string `json:"oid"`
Code int `json:"code"`
Err string `json:"err"`
Msg string `json:"msg"`
}
// ToPay 支付发起
func (this *Exchg) ToPay() ExchgMsg {
var msg ExchgMsg
var errlog string
this.fill()
code, err := httputil.DefaultClientPostJsonWithResp(&msg, this.GetURL(), this.GetHeader(), this.GetBody())
if err != nil {
msg.Code = UNKNOWError
errlog = fmt.Sprintf("recharge ToPay Http.PostJson fail error:%+v/,data:%+v;", err, this)
msg.Err = errlog
log.Error(errlog)
return msg
}
if code != http.StatusOK {
msg.Code = UNKNOWError
errlog = fmt.Sprintf("recharge ToPay Http.PostJson fail error:%+v/,data:%+v;", err, code)
msg.Err = errlog
log.Error(errlog)
return msg
}
return msg
}
func (this *Exchg) fill() {
this.PlatformID = "91PO"
this.NotifyUrl = webg.Conf.URL.LocalAppUrl + "/3rd/defray/callback/echg/bill"
}
// GetBody 获取请求body
func (this *Exchg) GetBody() interface{} {
jsonStr, err := json.Marshal(this)
if err != nil {
log.Info(fmt.Sprintf("excharge json.Marshal is fail error:%+v/data:%+v", err, this))
}
sstr := string(jsonStr)
log.Info(fmt.Sprintf("recharg topay json data :%+v", sstr))
return jsonStr
}
// GetHeader 获取请求头信息
func (this *Exchg) GetHeader() map[string]string {
header := make(map[string]string, 0)
return header
}
// GetURL 获取请求地址
func (*Exchg) GetURL() string {
return webg.Conf.URL.TransactionUrl + "/api/recharge/withdraw"
}
// 防洗钱校验
// 提现防洗钱限制, 防止用户用usdt充值, 其它方式提现洗钱
// 例如: 用户usdt充值1000, 则用户只能用usdt提现1000,
//
// 且, 用户usdt充值1000未提现时, 此时用其它方式提现,
// 则, 余额 - 提现金额 >= 1000
//
// eType: 提现方式
// allMoney: 可提现总金额
// money: 提现金额
// usdtAmount: usdt可提现额度
// uid: 提现用户id
func CheckMoney(eType string, allMoney, money, usdtAmount int64, uid uint64) bool {
//usdt方式提现
if eType == wdordmod.TypeUsdt && money*100 > usdtAmount {
log.Error("用户: " + strconv.FormatInt(int64(uid), 10) + ", USDT方式可提现余额为: " + strconv.FormatInt(usdtAmount, 10))
return false
}
//可提现金额
ktx_Amount := allMoney*100 - usdtAmount
//非usdt方式提现
if eType != wdordmod.TypeUsdt && ktx_Amount < money*100 {
log.Error("用户: " + strconv.FormatInt(int64(uid), 10) + ", 当前方式可提现金额为: " + strconv.FormatInt(ktx_Amount, 10) + ", 其它金额请通过USDT提现!")
return false
}
return true
}