- 修复将易联云token中的ExpireIn处理错误(没有当成秒)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user