add random pay

This commit is contained in:
lwl0608 2024-07-11 10:03:25 +08:00
parent 425c0eddc9
commit e3adc95d15
2 changed files with 8 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package main
import ( import (
"fmt" "fmt"
"math/rand"
"net" "net"
"net/http" "net/http"
"os" "os"
@ -31,6 +32,8 @@ func main() {
logger.Recover() logger.Recover()
}() }()
rand.Seed(time.Now().UnixNano())
// 加载配置 // 加载配置
// 1.默认配置 // 1.默认配置
configPath := consts.ProductionConfigPath configPath := consts.ProductionConfigPath

View File

@ -6,6 +6,7 @@ import (
"fmt" "fmt"
"github.com/go-pay/gopay" "github.com/go-pay/gopay"
"github.com/go-pay/gopay/alipay" "github.com/go-pay/gopay/alipay"
"math/rand"
"net/http" "net/http"
"service/bizcommon/util" "service/bizcommon/util"
"service/library/configcenter" "service/library/configcenter"
@ -26,6 +27,10 @@ const (
var allAlipayClients = map[string]*AlipayClient{} var allAlipayClients = map[string]*AlipayClient{}
func GetDefaultAlipayClient() *AlipayClient { func GetDefaultAlipayClient() *AlipayClient {
rate := rand.Intn(100)
if rate < 50 {
return allAlipayClients[AppIdMiYuanTianShi]
}
return allAlipayClients[AppIdLanXing01] return allAlipayClients[AppIdLanXing01]
} }