From e9aef0d93143c0a4cb70b946d56110f1996c1e97 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Sat, 2 Dec 2023 09:43:16 +0800 Subject: [PATCH] test --- chain_transfer/svc/svc_turnchain.go | 48 +++++++++++++++++++++++++++++ zhimeng/pdd_convert_url.go | 4 +-- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/chain_transfer/svc/svc_turnchain.go b/chain_transfer/svc/svc_turnchain.go index cea3df2..f8938db 100644 --- a/chain_transfer/svc/svc_turnchain.go +++ b/chain_transfer/svc/svc_turnchain.go @@ -149,10 +149,34 @@ func PDDTurnChain(eg *xorm.Engine, dbName string, args map[string]string) (*md.C } miniApp := "0" isShares := "2" + masterPid := pid + pddPidData, _ := pdd.NewZhiMengPDDSDK(). + SelectFunction("get_pid_list"). + WithArgs(map[string]interface{}{ + "appkey": db.SysCfgGetWithDb(eg, dbName, md.KEY_CFG_ZM_AK), + "secret_key": db.SysCfgGetWithDb(eg, dbName, md.KEY_CFG_ZM_SK), + "pid": masterPid}, + ).Result() + if pddPidData != nil { + b, _ := json.Marshal(pddPidData.ToInterface()) + pddPid := gjson.GetBytes(b, "pdd_pid").String() + if pddPid == "" { + profile, _ := db.UserProfileFindByID(eg, 0) + if profile != nil { + masterPid = profile.AccPddSelfId + } + } + } else { + profile, _ := db.UserProfileFindByID(eg, 0) + if profile != nil { + masterPid = profile.AccPddSelfId + } + } urls, err = zhimeng.PDDConvertUrl( thirdZmAppKeyData.Val, thirdZmAppSecretData.Val, args["gid"], + masterPid, pid, "", miniApp, @@ -349,10 +373,34 @@ func ConvertUrl(eg *xorm.Engine, args map[string]string) (*md.ConvertedUrls, err } miniApp := "0" isShares := "2" + masterPid := pid + pddPidData, _ := pdd.NewZhiMengPDDSDK(). + SelectFunction("get_pid_list"). + WithArgs(map[string]interface{}{ + "appkey": db.SysCfgGetWithDb(eg, args["master_id"], md.KEY_CFG_ZM_AK), + "secret_key": db.SysCfgGetWithDb(eg, args["master_id"], md.KEY_CFG_ZM_SK), + "pid": masterPid}, + ).Result() + if pddPidData != nil { + b, _ := json.Marshal(pddPidData.ToInterface()) + pddPid := gjson.GetBytes(b, "pdd_pid").String() + if pddPid == "" { + profile, _ := db.UserProfileFindByID(eg, 0) + if profile != nil { + masterPid = profile.AccPddSelfId + } + } + } else { + profile, _ := db.UserProfileFindByID(eg, 0) + if profile != nil { + masterPid = profile.AccPddSelfId + } + } urls, err = zhimeng.PDDConvertUrl( thirdZmAppKeyData.Val, thirdZmAppSecretData.Val, args["gid"], + masterPid, pid, "", miniApp, diff --git a/zhimeng/pdd_convert_url.go b/zhimeng/pdd_convert_url.go index 3ba80cd..1446041 100644 --- a/zhimeng/pdd_convert_url.go +++ b/zhimeng/pdd_convert_url.go @@ -7,13 +7,13 @@ import ( "fmt" ) -func PDDConvertUrl(ak, sk, itemId, promoId, couponPrice, isWxMini, isBindUrl, isShare string) (*md.ConvertedUrls, error) { +func PDDConvertUrl(ak, sk, itemId, pid, promoId, couponPrice, isWxMini, isBindUrl, isShare string) (*md.ConvertedUrls, error) { args := map[string]interface{}{ "appkey": ak, "secret_key": sk, "gid": itemId, "goods_sign": itemId, - "pid": promoId, + "pid": pid, "open_app": "", // 具体规则请看智盟 "link_type": "", // todo 这几项按理来说做成配置项 "generate_we_app": isWxMini, // 生成微信小程序链接