| | |
| | | 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; |
| | |
| | | */ |
| | | @Service |
| | | public class GoldCornMakeServiceImpl implements GoldCornMakeService { |
| | | Logger taskLogger = LoggerFactory.getLogger("taskLog"); |
| | | |
| | | @Resource |
| | | private GoldCornGetFrequencyConfigService goldCornGetFrequencyConfigService; |
| | |
| | | query.setUid(user.getId()); |
| | | query.setType(type); |
| | | |
| | | try { |
| | | //间隔判断 |
| | | if (config.getMinSpaceTime() != null) { |
| | | List<GoldCornGetRecord> list = goldCornGetRecordService.list(query, 1, 1); |
| | |
| | | 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; |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | @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, "用户不存在"); |