admin
2022-09-30 ffc56f912da5d6d842142ae4ea1856bc56f8bcb9
app/src/main/java/com/yeshi/makemoney/app/service/impl/goldcorn/GoldCornMakeServiceImpl.java
@@ -23,6 +23,8 @@
import com.yeshi.makemoney.app.utils.factory.UserMoneyRecordFactory;
import com.yeshi.makemoney.app.utils.factory.goldcorn.GoldCornConsumeRecordFactory;
import com.yeshi.makemoney.app.utils.goldcorn.GoldCornUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -45,6 +47,7 @@
 */
@Service
public class GoldCornMakeServiceImpl implements GoldCornMakeService {
    Logger taskLogger = LoggerFactory.getLogger("taskLog");
    @Resource
    private GoldCornGetFrequencyConfigService goldCornGetFrequencyConfigService;
@@ -92,6 +95,7 @@
        query.setUid(user.getId());
        query.setType(type);
        try {
        //间隔判断
        if (config.getMinSpaceTime() != null) {
            List<GoldCornGetRecord> list = goldCornGetRecordService.list(query, 1, 1);
@@ -129,7 +133,15 @@
            String msg = String.format("超出%s次/%s的限制", config.getLimitCount(), config.getTimeUnit().getName());
            throw new GoldCornMakeException(GoldCornMakeException.CODE_GET_FREQUENCY_COUNT_LIMIT, msg);
        }
        return config.getLimitCount() - (countMap.get(type) != null ? countMap.get(type) : 0);
        } catch (GoldCornMakeException e) {
            //频率限制
            taskLogger.error("#频率受限# uid:{} type:{} time:{}  msg:{}", user.getId(), type.name(), TimeUtil.getGernalTime(time.getTime(), "yyyy-MM-dd HH:mm:ss SSS"), e.getMsg());
            throw e;
        }
    }
@@ -359,6 +371,17 @@
    @Transactional(rollbackFor = Exception.class)
    @Override
    public GoldCornMakeResultDTO scanNews(Long uid, boolean isDouble, Date time, int num) throws GoldCornGetPriceException, UserInfoException, GoldCornMakeException, GoldCornGetFrequencyConfigException {
        //防刷机制
        if (num < 0) {
            num = 0;
        }
        //1个很大的数
        if (num > 20) {
            num = 1;
        }
        UserInfo user = userInfoService.get(uid);
        if (user == null) {
            throw new UserInfoException(UserInfoException.CODE_NOT_EXIST, "用户不存在");