upd sing method
parent
a1959f22f3
commit
f2b021c824
|
@ -32,6 +32,11 @@
|
|||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.health</groupId>
|
||||
<artifactId>health-wallet-remote</artifactId>
|
||||
<version>3.6.5</version>
|
||||
</dependency>
|
||||
<!-- rabbitMQ -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
|
|
@ -12,9 +12,32 @@ import org.apache.ibatis.annotations.Param;
|
|||
*/
|
||||
@Mapper
|
||||
public interface SysSignMapper {
|
||||
|
||||
/**
|
||||
* @description: 查询当前登录人的签到记录
|
||||
* @param:
|
||||
* @return: Result
|
||||
* @author 冯凯
|
||||
* @date: 2023/11/5 14:03
|
||||
*/
|
||||
Sign searchSignByUserId(@Param("userId") Long userId);
|
||||
|
||||
/**
|
||||
* @description: 修改签到次数
|
||||
* @param:
|
||||
* @return: Result
|
||||
* @author 冯凯
|
||||
* @date: 2023/11/5 14:04
|
||||
*/
|
||||
void updateSingAmountByUserId(Sign sign);
|
||||
|
||||
|
||||
/**
|
||||
* @description: 当前登录人进行签字
|
||||
* @param:
|
||||
* @return: Result
|
||||
* @author 冯凯
|
||||
* @date: 2023/11/5 14:04
|
||||
*/
|
||||
void signByUserId(Sign sign);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,23 @@ import com.health.system.common.domain.Sign;
|
|||
* @date 2023/11/5 9:02
|
||||
*/
|
||||
public interface SysSignService {
|
||||
|
||||
/**
|
||||
* @description: 查询当前登录人的签到记录
|
||||
* @param:
|
||||
* @return: Result
|
||||
* @author 冯凯
|
||||
* @date: 2023/11/5 14:03
|
||||
*/
|
||||
Sign searchSignByUserId(Long userId);
|
||||
|
||||
|
||||
/**
|
||||
* @description: 当前登录人进行签字
|
||||
* @param:
|
||||
* @return: Result
|
||||
* @author 冯凯
|
||||
* @date: 2023/11/5 14:04
|
||||
*/
|
||||
void signByUserId(Long userId);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
package com.health.system.server.service.impl;
|
||||
|
||||
import com.health.common.core.constant.SecurityConstants;
|
||||
import com.health.common.redis.service.RedisService;
|
||||
import com.health.system.common.domain.Sign;
|
||||
import com.health.system.server.mapper.SysSignMapper;
|
||||
import com.health.system.server.service.SysSignService;
|
||||
import com.health.wallet.common.domain.req.MoneyChangeRecordReq;
|
||||
import com.health.wallet.remote.RemoteWalletService;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.annotation.CreatedDate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -12,6 +16,7 @@ import java.time.LocalDate;
|
|||
import java.time.ZoneId;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
|
@ -29,6 +34,18 @@ public class SysSignServiceImpl implements SysSignService {
|
|||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
@Autowired
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
|
||||
@Autowired
|
||||
private RemoteWalletService remoteWalletService;
|
||||
/**
|
||||
* @description: 查询当前登录人的签到记录
|
||||
* @param:
|
||||
* @return: Result
|
||||
* @author 冯凯
|
||||
* @date: 2023/11/5 14:03
|
||||
*/
|
||||
@Override
|
||||
public Sign searchSignByUserId(Long userId) {
|
||||
|
||||
|
@ -89,13 +106,32 @@ public class SysSignServiceImpl implements SysSignService {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description: 当前登录人进行签字
|
||||
* @param:
|
||||
* @return: Result
|
||||
* @author 冯凯
|
||||
* @date: 2023/11/5 14:04
|
||||
*/
|
||||
@Override
|
||||
public void signByUserId(Long userId) {
|
||||
int hBalance=0;
|
||||
Sign sign = sysSignMapper.searchSignByUserId(userId);
|
||||
sign.setSignAmount(sign.getSignAmount()+1);
|
||||
sysSignMapper.signByUserId(sign);
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
// 将时间设置为第二天凌晨0点
|
||||
if (sign.getSignAmount()+1<=10){
|
||||
hBalance=sign.getSignAmount()+1;
|
||||
}else{
|
||||
hBalance=10;
|
||||
}
|
||||
MoneyChangeRecordReq moneyChangeRecordReq = new MoneyChangeRecordReq();
|
||||
moneyChangeRecordReq.setCreateTime(new Date());
|
||||
moneyChangeRecordReq.setCreateUser(userId);
|
||||
moneyChangeRecordReq.setWalletId(userId);
|
||||
moneyChangeRecordReq.setChangeAmount(hBalance);
|
||||
remoteWalletService.moneyChangeByOtherOperate(moneyChangeRecordReq, SecurityConstants.INNER);
|
||||
long expireTime = getExpireTime(calendar);
|
||||
redisService.setCacheObject("sign:"+userId,sign,expireTime, TimeUnit.SECONDS);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue