定时器测试1

pull/2/head
ZhiShuo_Lou 2023-10-28 20:51:53 +08:00
parent 6860cd013b
commit 2ffeb09176
1 changed files with 8 additions and 6 deletions

View File

@ -1,9 +1,10 @@
package com.ruoyi.mybasic.timer;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.mybasic.common.domain.response.PurseResponse;
import com.ruoyi.mybasic.service.PurseServiceTwo;
import com.ruoyi.mybasic.controller.PurseControllerTwo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@ -16,7 +17,7 @@ import org.springframework.stereotype.Component;
public class SysUserPurse {
@Autowired
private PurseServiceTwo purseServiceTwo;
private PurseControllerTwo purseControllerTwo;
@Autowired
private RedisService redisService;
@ -32,14 +33,15 @@ public class SysUserPurse {
System.out.println("~~~~~~定时器开始扫描钱包余额~~~~~~");
//获取用户的编号
Long userId = SecurityUtils.getUserId();
userId = (long)110;
//根据用户编号查询用户钱包
PurseResponse purseResponse = purseServiceTwo.purseObject(userId);
if (null == purseResponse){
R<PurseResponse> purseResponseR = purseControllerTwo.purseObject();
PurseResponse data = purseResponseR.getData();
if (null == data){
throw new RuntimeException("查无此用户!");
}
//钱包余额
Integer balanceFee = purseResponse.getBalanceFee();
Integer balanceFee = data.getBalanceFee();
//将余额存入redis
redisService.setCacheObject(userId + PURSE_NAME,balanceFee);
}