|
|
@@ -11,6 +11,7 @@ import ( |
|
|
|
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement" |
|
|
|
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" |
|
|
|
"code.fnuoos.com/EggPlanet/egg_system_rules.git/enum" |
|
|
|
enum2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/enum" |
|
|
|
md2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/md" |
|
|
|
"code.fnuoos.com/EggPlanet/egg_system_rules.git/rule" |
|
|
|
md3 "code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/md" |
|
|
@@ -19,6 +20,7 @@ import ( |
|
|
|
"fmt" |
|
|
|
"github.com/gin-gonic/gin" |
|
|
|
"github.com/go-pay/gopay" |
|
|
|
alipay2 "github.com/go-pay/gopay/alipay" |
|
|
|
"github.com/jinzhu/copier" |
|
|
|
"time" |
|
|
|
) |
|
|
@@ -400,7 +402,7 @@ func GetWithdrawCondition(c *gin.Context) { |
|
|
|
// @param Authorization header string true "验证参数Bearer和token空格拼接" |
|
|
|
// @Success 200 {string} "Url" |
|
|
|
// @Failure 400 {object} md.Response "具体错误" |
|
|
|
// @Router /api/v1/wallet/withdraw/launchBindAlipay [POST] |
|
|
|
// @Router /api/v1/wallet/withdraw/launchBindAlipay [GET] |
|
|
|
func LaunchBindAlipayAccount(c *gin.Context) { |
|
|
|
client, err := alipay.InitAlipay(nil) |
|
|
|
if err != nil { |
|
|
@@ -410,7 +412,54 @@ func LaunchBindAlipayAccount(c *gin.Context) { |
|
|
|
appId := client.AppId |
|
|
|
scope := "auth_user" |
|
|
|
|
|
|
|
resUrl := fmt.Sprintf("https://authweb.alipay.com/auth?auth_type=PURE_OAUTH_SDK&app_id=%s&scope=%s&state=init", appId, scope) |
|
|
|
redisConn := cache.GetPool().Get() |
|
|
|
sysCfgDb := implement.NewSysCfgDb(db.Db, redisConn) |
|
|
|
sysCfgs, err := sysCfgDb.SysCfgGetAll() |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
if sysCfgs == nil { |
|
|
|
e.OutErr(c, e.ERR_CFG_CACHE, nil) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
cfgMap := make(map[string]string, len(*sysCfgs)) |
|
|
|
for _, cfg := range *sysCfgs { |
|
|
|
cfgMap[cfg.Key] = cfg.Val |
|
|
|
} |
|
|
|
targetId := utils.UUIDHexString() |
|
|
|
|
|
|
|
alipayPrivateKey := cfgMap[enum2.AlipayPrivateKey] |
|
|
|
pid := cfgMap[enum2.AlipayPid] |
|
|
|
bm := make(gopay.BodyMap) |
|
|
|
bm.Set("apiname", "com.alipay.account.auth") |
|
|
|
bm.Set("app_id", appId) |
|
|
|
bm.Set("app_name", "mc") |
|
|
|
bm.Set("auth_type", "AUTHACCOUNT") |
|
|
|
bm.Set("biz_type", "openservice") |
|
|
|
bm.Set("pid", pid) |
|
|
|
bm.Set("product_id", "APP_FAST_LOGIN") |
|
|
|
bm.Set("scope", scope) |
|
|
|
bm.Set("sign_type", "RSA2") |
|
|
|
bm.Set("method", "alipay.open.auth.sdk.code.get") |
|
|
|
bm.Set("target_id", targetId) |
|
|
|
privateKey, err := utils.StringToPrivateKey(alipayPrivateKey) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
sign, err := alipay2.GetRsaSign(bm, alipay2.RSA2, privateKey) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
resUrl := fmt.Sprintf("apiname=com.alipay.account.auth&app_id=%s&app_name=mc&"+ |
|
|
|
"auth_type=AUTHACCOUNT&biz_type=openservice&method=alipay.open.auth.sdk.code.get"+ |
|
|
|
"&pid=%s&product_id=APP_FAST_LOGIN&scosspe=%s&sign_type=RSA2&"+ |
|
|
|
"target_id=%s&sign=%s", appId, pid, scope, targetId, sign) |
|
|
|
|
|
|
|
e.OutSuc(c, resUrl, nil) |
|
|
|
} |
|
|
|
|
|
|
|