From bb690517428797a281e2a6bb89ae151a7318e048 Mon Sep 17 00:00:00 2001 From: gazebo Date: Sat, 31 Aug 2019 11:26:50 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E4=BF=AE=E5=A4=8D=E5=B0=86=E6=98=93?= =?UTF-8?q?=E8=81=94=E4=BA=91token=E4=B8=AD=E7=9A=84ExpireIn=E5=A4=84?= =?UTF-8?q?=E7=90=86=E9=94=99=E8=AF=AF=EF=BC=88=E6=B2=A1=E6=9C=89=E5=BD=93?= =?UTF-8?q?=E6=88=90=E7=A7=92=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxutils/netprinter/netprinter.go | 4 +++- business/partner/printer/yilianyun/yilianyun.go | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/business/jxutils/netprinter/netprinter.go b/business/jxutils/netprinter/netprinter.go index 9b0f1c182..83bc6e3af 100644 --- a/business/jxutils/netprinter/netprinter.go +++ b/business/jxutils/netprinter/netprinter.go @@ -143,13 +143,14 @@ func RebindAllPrinters(ctx *jxcontext.Context, isForce, isAsync bool) (hint stri for _, v := range storeList { var bindResult partner.BindPrinterResult if err = utils.UnmarshalUseNumber([]byte(v.PrinterBindInfo), &bindResult); err == nil { - if isForce || now.Sub(utils.Timestamp2Time(bindResult.ExpiresAt)) > -48*time.Hour { + if isForce || now.Sub(utils.Timestamp2Time(bindResult.ExpiresAt)) > -3*24*time.Hour { needRebindList = append(needRebindList, v) bindResultMap[v.ID] = &bindResult } } } + globals.SugarLogger.Debugf("RebindAllPrinters len(needRebindList):%d", len(needRebindList)) if len(needRebindList) > 0 { db := dao.GetDB() task := tasksch.NewSeqTask("RebindAllPrinters", ctx, @@ -157,6 +158,7 @@ func RebindAllPrinters(ctx *jxcontext.Context, isForce, isAsync bool) (hint stri store := needRebindList[step] if handler := partner.GetPrinterPlatformFromVendorID(store.PrinterVendorID); handler != nil { bindResult, err2 := handler.RebindPrinter(ctx, bindResultMap[store.ID]) + globals.SugarLogger.Debugf("RebindAllPrinters storeID:%d, result:%s, err:%v", store.ID, utils.Format4Output(bindResult, true), err2) if err = err2; err == nil { store.PrinterSN = bindResult.PrinterSN store.PrinterKey = bindResult.PrinterKey diff --git a/business/partner/printer/yilianyun/yilianyun.go b/business/partner/printer/yilianyun/yilianyun.go index 47bddd467..68c45292b 100644 --- a/business/partner/printer/yilianyun/yilianyun.go +++ b/business/partner/printer/yilianyun/yilianyun.go @@ -257,7 +257,7 @@ func yilianyunToken2BindResult(tokenInfo *yilianyunapi.TokenInfo) (bindResult *p PrinterSN: tokenInfo.MachineCode, PrinterKey: tokenInfo.AccessToken, PrinterKey2: tokenInfo.RefreshToken, - ExpiresAt: time.Now().Add(time.Duration(tokenInfo.ExpiresIn)).Unix(), + ExpiresAt: time.Now().Add(time.Duration(tokenInfo.ExpiresIn) * time.Second).Unix(), } }