From 9d31938d1a3e252c0e46b2dfe046f59426558e38 Mon Sep 17 00:00:00 2001 From: ztino <> Date: Thu, 7 Jan 2021 20:58:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96eid=E5=92=8Cfp=E7=9A=84?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/jdTdudfp.go | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/cmd/jdTdudfp.go b/cmd/jdTdudfp.go index 76eaaaf..da1b394 100644 --- a/cmd/jdTdudfp.go +++ b/cmd/jdTdudfp.go @@ -59,6 +59,12 @@ func startJdTdudfp(cmd *cobra.Command, args []string) { //商品链接 good_url,_:=cmd.Flags().GetString("good_url") + + //返回的eid和fp + returnEid:="" + returnFp:="" + + //获取到的eid和fp eid := "" fp := "" @@ -99,13 +105,23 @@ func startJdTdudfp(cmd *cobra.Command, args []string) { } value := string(res) - if !gjson.Valid(value) || gjson.Get(value, "eid").String() == "" || gjson.Get(value, "fp").String() == "" { + //判断_JdTdudfp是否能获取到eid和fp,如果不能去获取_JdEid和_JdJrTdRiskFpInfo获取到的值 + if gjson.Valid(value) && gjson.Get(value, "eid").String() != "" && gjson.Get(value, "fp").String() != "" { + returnEid = gjson.Get(value, "eid").String() + returnFp = gjson.Get(value, "fp").String() + }else{ + if eid!="" && fp!=""{ + returnEid=eid + returnFp=fp + } + } + + //eid,fp合法性判断 + if returnEid=="" || returnFp=="" { log.Println("获取失败,请重新尝试,返回信息:" + value) - } else { - eid := gjson.Get(value, "eid").String() - fp := gjson.Get(value, "fp").String() - log.Println("eid:" + eid) - log.Println("fp:" + fp) + }else{ + log.Println("eid:" + returnEid) + log.Println("fp:" + returnFp) //修改配置文件 confFile := "./conf.ini" @@ -115,14 +131,13 @@ func startJdTdudfp(cmd *cobra.Command, args []string) { os.Exit(0) } - cfg.SetValue("config", "eid", eid) - cfg.SetValue("config", "fp", fp) + cfg.SetValue("config", "eid", returnEid) + cfg.SetValue("config", "fp", returnFp) if err := goconfig.SaveConfigFile(cfg, confFile); err != nil { log.Println("保存配置文件失败,请手动填入配置文件") + }else{ + log.Println("eid, fp参数已经自动填入配置文件") } - - log.Println("eid, fp参数已经自动填入配置文件") } - } }