upd sing method

master
冯凯 2023-11-05 14:45:37 +08:00
parent a1959f22f3
commit f2b021c824
4 changed files with 80 additions and 0 deletions

View File

@ -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>

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}