mirror of
https://github.com/linux-do/new-api.git
synced 2025-11-07 14:53:40 +08:00
修改stat接口返回值
This commit is contained in:
@@ -24,21 +24,28 @@ type AmountRequest struct {
|
||||
TopUpCode string `json:"top_up_code"`
|
||||
}
|
||||
|
||||
//var client, _ = epay.NewClientWithUrl(&epay.Config{
|
||||
// PartnerID: "1096",
|
||||
// Key: "n08V9LpE8JffA3NPP893689u8p39NV9J",
|
||||
//}, "https://api.lempay.org")
|
||||
|
||||
var client, _ = epay.NewClientWithUrl(&epay.Config{
|
||||
PartnerID: "1096",
|
||||
Key: "n08V9LpE8JffA3NPP893689u8p39NV9J",
|
||||
}, "https://api.lempay.org")
|
||||
PartnerID: "1064",
|
||||
Key: "nqrrZ5RjR86mKP8rKkyrOY5Pg8NmYfKR",
|
||||
}, "https://pay.yunjuw.cn")
|
||||
|
||||
func GetAmount(id int, count float64, topUpCode string) float64 {
|
||||
amount := count * 1.5
|
||||
if topUpCode != "" {
|
||||
if topUpCode == "nekoapi" {
|
||||
if id == 89 {
|
||||
amount = count * 1
|
||||
} else if id == 98 || id == 105 || id == 107 {
|
||||
amount = count * 0.8
|
||||
} else if id == 105 || id == 107 {
|
||||
amount = count * 1.2
|
||||
} else if id == 1 {
|
||||
amount = count * 1
|
||||
} else if id == 98 {
|
||||
amount = count * 1.1
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -61,15 +68,15 @@ func RequestEpay(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
if req.PaymentMethod == "zfb" {
|
||||
if amount > 400 {
|
||||
c.JSON(200, gin.H{"message": "支付宝最大充值400元", "data": amount, "count": 400})
|
||||
if amount > 2000 {
|
||||
c.JSON(200, gin.H{"message": "支付宝最大充值2000元", "data": amount, "count": 2000})
|
||||
return
|
||||
}
|
||||
req.PaymentMethod = "alipay"
|
||||
}
|
||||
if req.PaymentMethod == "wx" {
|
||||
if amount > 600 {
|
||||
c.JSON(200, gin.H{"message": "微信最大充值600元", "data": amount, "count": 600})
|
||||
if amount > 2000 {
|
||||
c.JSON(200, gin.H{"message": "微信最大充值2000元", "data": amount, "count": 2000})
|
||||
return
|
||||
}
|
||||
req.PaymentMethod = "wxpay"
|
||||
@@ -78,11 +85,18 @@ func RequestEpay(c *gin.Context) {
|
||||
returnUrl, _ := url.Parse("https://nekoapi.com/log")
|
||||
notifyUrl, _ := url.Parse("https://nekoapi.com/api/user/epay/notify")
|
||||
tradeNo := strconv.FormatInt(time.Now().Unix(), 10)
|
||||
payMoney := amount
|
||||
//if payMoney < 400 {
|
||||
// payMoney = amount * 0.99
|
||||
// if amount-payMoney > 2 {
|
||||
// payMoney = amount - 2
|
||||
// }
|
||||
//}
|
||||
uri, params, err := client.Purchase(&epay.PurchaseArgs{
|
||||
Type: epay.PurchaseType(req.PaymentMethod),
|
||||
ServiceTradeNo: "A" + tradeNo,
|
||||
Name: "B" + tradeNo,
|
||||
Money: strconv.FormatFloat(amount*0.99, 'f', 2, 64),
|
||||
Money: strconv.FormatFloat(payMoney, 'f', 2, 64),
|
||||
Device: epay.PC,
|
||||
NotifyUrl: notifyUrl,
|
||||
ReturnUrl: returnUrl,
|
||||
@@ -163,10 +177,10 @@ func RequestAmount(c *gin.Context) {
|
||||
c.JSON(200, gin.H{"message": "最小充值10刀", "data": GetAmount(id, 10, req.TopUpCode), "count": 10})
|
||||
return
|
||||
}
|
||||
if req.Amount > 400 {
|
||||
c.JSON(200, gin.H{"message": "最大充值400刀", "data": GetAmount(id, 400, req.TopUpCode), "count": 400})
|
||||
return
|
||||
}
|
||||
//if req.Amount > 1500 {
|
||||
// c.JSON(200, gin.H{"message": "最大充值1000刀", "data": GetAmount(id, 1000, req.TopUpCode), "count": 1500})
|
||||
// return
|
||||
//}
|
||||
}
|
||||
|
||||
c.JSON(200, gin.H{"message": "success", "data": GetAmount(id, float64(req.Amount), req.TopUpCode)})
|
||||
|
||||
Reference in New Issue
Block a user