giftService-整合newGetById方法
This commit is contained in:
@@ -99,7 +99,7 @@ public class FirstChargeRewardAdminService {
|
||||
|
||||
Byte rewardType = reward.getRewardType();
|
||||
if(rewardType.equals(Constant.firstChargeRewardType.GIFT)){
|
||||
Gift gift = giftService.newGetGiftById(rewardId.intValue());
|
||||
Gift gift = giftService.getGiftById(rewardId.intValue());
|
||||
if(gift == null){
|
||||
throw new ServiceException("礼物不存在");
|
||||
}
|
||||
@@ -162,7 +162,7 @@ public class FirstChargeRewardAdminService {
|
||||
Byte rewardType = reward.getRewardType();
|
||||
Long rewardId = reward.getRewardId();
|
||||
if(rewardType.equals(Constant.firstChargeRewardType.GIFT)){
|
||||
Gift gift = giftService.newGetGiftById(rewardId.intValue());
|
||||
Gift gift = giftService.getGiftById(rewardId.intValue());
|
||||
if(gift == null){
|
||||
throw new ServiceException("礼物不存在");
|
||||
}
|
||||
|
@@ -162,7 +162,7 @@ public class GiftCompoundAdminService {
|
||||
}
|
||||
|
||||
private Gift getGift(Integer giftId){
|
||||
Gift gift = giftService.newGetGiftById(giftId);
|
||||
Gift gift = giftService.getGiftById(giftId);
|
||||
if (gift == null) {
|
||||
throw new ServiceException(BusiStatus.GIFT_IS_NOT_EXIST);
|
||||
}
|
||||
|
@@ -163,7 +163,7 @@ public class NewLuckyBagPoolAdminService {
|
||||
defaultShowRate = showRest - showWingRate;
|
||||
}
|
||||
|
||||
Gift refGift = giftService.newGetGiftById(giftId);
|
||||
Gift refGift = giftService.getGiftById(giftId);
|
||||
if (refGift == null) {
|
||||
throw new BusinessException("礼物不存在");
|
||||
}
|
||||
|
@@ -74,7 +74,7 @@ public class SeekElfinAdminService {
|
||||
List<Gift> giftList = new LinkedList<>();
|
||||
List<Integer> giftIdList = items.stream().map(SeekElfinProd::getGiftId).collect(Collectors.toList());
|
||||
for(Integer giftId : giftIdList){
|
||||
Gift gift = giftService.newGetGiftById(giftId);
|
||||
Gift gift = giftService.getGiftById(giftId);
|
||||
if(gift == null){
|
||||
throw new ServiceException(BusiStatus.PARAMERROR, "礼物不存在,请查询后重试");
|
||||
}
|
||||
|
@@ -362,7 +362,7 @@ public class GiftAdminController extends BaseController {
|
||||
|
||||
@RequestMapping(value = "/send", method = RequestMethod.POST)
|
||||
public void send(String erbanNo, Integer giftId, Integer giftNum) {
|
||||
Gift gift = giftService.newGetGiftById(giftId);
|
||||
Gift gift = giftService.getGiftById(giftId);
|
||||
|
||||
// 根据配置,发送微信提示消息
|
||||
List<String> erbanList = Arrays.asList(erbanNo.split(","));
|
||||
|
@@ -114,7 +114,7 @@ public class ActNewYearFireworkService implements InitializingBean, ApplicationL
|
||||
fVo.setPrice(fConfig.getPrice());
|
||||
|
||||
Set<Integer> giftIds = fConfig.getRatio().keySet();
|
||||
List<NewYearFireworkRewardVo> fireworkGiftVoList = giftIds.parallelStream().map(giftId-> giftService.newGetGiftById(giftId))
|
||||
List<NewYearFireworkRewardVo> fireworkGiftVoList = giftIds.parallelStream().map(giftId-> giftService.getGiftById(giftId))
|
||||
.sorted(Comparator.comparingInt(Gift::getSeqNo))
|
||||
.map(gift->{
|
||||
NewYearFireworkRewardVo giftVo = new NewYearFireworkRewardVo();
|
||||
@@ -196,7 +196,7 @@ public class ActNewYearFireworkService implements InitializingBean, ApplicationL
|
||||
for (Map.Entry<Integer, Integer> reward: rewardNumMap.entrySet()){
|
||||
Integer giftId = reward.getKey();
|
||||
Integer giftNum = reward.getValue();
|
||||
Gift gift = giftService.newGetGiftById(giftId);
|
||||
Gift gift = giftService.getGiftById(giftId);
|
||||
if (null == gift){
|
||||
log.error("[新年烟花活动] 给 {} 发奖时,找不到 {} 的礼物, {} 个", uid, giftId, giftNum);
|
||||
continue;
|
||||
@@ -289,11 +289,11 @@ public class ActNewYearFireworkService implements InitializingBean, ApplicationL
|
||||
bizExecutor.execute(()->{
|
||||
Users users = usersService.getUsersByUid(uid);
|
||||
|
||||
Gift drawGift = giftService.newGetGiftById(drawGiftId);
|
||||
Gift drawGift = giftService.getGiftById(drawGiftId);
|
||||
Set<String> keySet = giftWeightMap.keySet().stream().map(giftId-> String.format("%d_%d", type, giftId)).collect(Collectors.toSet());
|
||||
Map<String, Integer> todayOutputNumMap = dayOutputRecord.getAll(keySet).entrySet().stream().collect(HashMap::new, (map, item) -> {
|
||||
int giftId = Integer.parseInt(item.getKey().split("_")[1]);
|
||||
Gift gift = giftService.newGetGiftById(giftId);
|
||||
Gift gift = giftService.getGiftById(giftId);
|
||||
map.put(null != gift? gift.getGiftName(): item.getKey(), item.getValue());
|
||||
}, HashMap::putAll);
|
||||
log.info("[新年烟花活动] {} {} 在第 {} 个池 抽出 {} 被触发每日产出数量限制 {} 个, 目前已经产出 {}",
|
||||
@@ -316,11 +316,11 @@ public class ActNewYearFireworkService implements InitializingBean, ApplicationL
|
||||
bizExecutor.execute(()->{
|
||||
Users users = usersService.getUsersByUid(uid);
|
||||
|
||||
Gift drawGift = giftService.newGetGiftById(drawGiftId);
|
||||
Gift drawGift = giftService.getGiftById(drawGiftId);
|
||||
Set<String> keySet = giftWeightMap.keySet().stream().map(giftId-> String.format("%d_%d", type, giftId)).collect(Collectors.toSet());
|
||||
Map<String, Integer> todayOutputNumMap = dayOutputRecord.getAll(keySet).entrySet().stream().collect(HashMap::new, (map, item) -> {
|
||||
int giftId = Integer.parseInt(item.getKey().split("_")[1]);
|
||||
Gift gift = giftService.newGetGiftById(giftId);
|
||||
Gift gift = giftService.getGiftById(giftId);
|
||||
map.put(null != gift? gift.getGiftName(): item.getKey(), item.getValue());
|
||||
}, HashMap::putAll);
|
||||
log.info("[新年烟花活动] {} {} 在第 {} 个池 抽出 {} 被触发每日产出数量限制 {} 个的 70% ,目前已经产出 {}",
|
||||
@@ -341,11 +341,11 @@ public class ActNewYearFireworkService implements InitializingBean, ApplicationL
|
||||
bizExecutor.execute(()->{
|
||||
Users users = usersService.getUsersByUid(uid);
|
||||
|
||||
Gift drawGift = giftService.newGetGiftById(drawGiftId);
|
||||
Gift drawGift = giftService.getGiftById(drawGiftId);
|
||||
Set<String> keySet = giftWeightMap.keySet().stream().map(giftId-> String.format("%d_%d", type, giftId)).collect(Collectors.toSet());
|
||||
Map<String, Integer> todayOutputNumMap = dayOutputRecord.getAll(keySet).entrySet().stream().collect(HashMap::new, (map, item) -> {
|
||||
int giftId = Integer.parseInt(item.getKey().split("_")[1]);
|
||||
Gift gift = giftService.newGetGiftById(giftId);
|
||||
Gift gift = giftService.getGiftById(giftId);
|
||||
map.put(null != gift? gift.getGiftName(): item.getKey(), item.getValue());
|
||||
}, HashMap::putAll);
|
||||
log.info("[新年烟花活动] {} {} 抽出 {} 被触发的每日产出数量限制 {} 个的 50% , 目前已经产出 {}",
|
||||
|
@@ -125,7 +125,7 @@ public class ActSingleRoomRankService extends BaseService {
|
||||
awardPic = carGoods.getPic();
|
||||
}
|
||||
}else if(awardVo.getAwardType().equals(ActivityAwardTypeEnum.GIFT.getAwardType())){
|
||||
Gift gift = giftService.newGetGiftById(awardId);
|
||||
Gift gift = giftService.getGiftById(awardId);
|
||||
if(gift != null){
|
||||
awardName = gift.getGiftName();
|
||||
awardPic = gift.getPicUrl();
|
||||
|
@@ -121,7 +121,7 @@ public class ActValentineCpBuyService {
|
||||
|
||||
Integer giftId = configDto.getId();
|
||||
GiftService giftService = SpringContextHolder.getBean(GiftService.class);
|
||||
Gift keepsake = giftService.newGetGiftById(giftId);
|
||||
Gift keepsake = giftService.getGiftById(giftId);
|
||||
if (null == keepsake){
|
||||
log.error("[情人节cp活动] {} 购买 获取不到 {} 的礼物", uid, giftId);
|
||||
throw new ServiceException(BusiStatus.SERVER_BUSY);
|
||||
|
@@ -363,7 +363,7 @@ public class FirstChargeRewardService extends BaseService {
|
||||
}
|
||||
|
||||
private void sendGiftbyUser(Integer giftId, Long userId, Integer giftNum) {
|
||||
Gift gift = giftService.newGetGiftById(giftId);
|
||||
Gift gift = giftService.getGiftById(giftId);
|
||||
UserBackpackParam backpackParam = new UserBackpackParam();
|
||||
backpackParam.setGiftSeq(gift.getSeqNo());
|
||||
backpackParam.setGiftId(gift.getGiftId());
|
||||
|
@@ -181,7 +181,7 @@ public class GiftCompoundService {
|
||||
List<CompoundGiftVo> voList = new ArrayList<>();
|
||||
|
||||
rewardList.forEach(reward -> {
|
||||
Gift gift = giftService.newGetGiftById(reward.getGiftId());
|
||||
Gift gift = giftService.getGiftById(reward.getGiftId());
|
||||
GiftCompoundRewardPool pool = giftCompoundRewardPoolService.getOne(
|
||||
new LambdaQueryWrapper<GiftCompoundRewardPool>()
|
||||
.eq(GiftCompoundRewardPool::getRewardId, reward.getId())
|
||||
|
@@ -449,7 +449,7 @@ public class GiftSendService extends BaseService {
|
||||
public Gift getGiftByIdAllStatus(int giftId, int giftSource){
|
||||
Gift gift;
|
||||
if (giftSource == Constant.GiftSource.COMMON){
|
||||
gift = giftService.newGetGiftById(giftId);
|
||||
gift = giftService.getGiftById(giftId);
|
||||
} else if (giftSource == Constant.GiftSource.BACKPACK){
|
||||
// TODO 暂从db拿指定礼物(包括下架) 需优化.
|
||||
gift = giftService.getGiftByIdFromDb(giftId);
|
||||
|
@@ -2,18 +2,11 @@ package com.accompany.business.service.gift;
|
||||
|
||||
import com.accompany.business.model.Gift;
|
||||
import com.accompany.business.model.GiftExample;
|
||||
import com.accompany.business.model.GiftSendRecord;
|
||||
import com.accompany.business.model.UserPurse;
|
||||
import com.accompany.business.model.vip.VipInfo;
|
||||
import com.accompany.business.mybatismapper.GiftMapper;
|
||||
import com.accompany.business.service.AppVersionService;
|
||||
import com.accompany.business.service.SendChatRoomMsgService;
|
||||
import com.accompany.business.service.activity.WeekStarConfigService;
|
||||
import com.accompany.business.service.activity.WeekStarService;
|
||||
import com.accompany.business.service.purse.UserPurseService;
|
||||
import com.accompany.business.service.record.BillRecordService;
|
||||
import com.accompany.business.service.room.RoomService;
|
||||
import com.accompany.business.service.user.UsersService;
|
||||
import com.accompany.business.service.vip.VipAuthItemService;
|
||||
import com.accompany.business.util.ReplaceDomainUtil;
|
||||
import com.accompany.business.vo.*;
|
||||
@@ -37,8 +30,6 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.jms.core.JmsTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@@ -58,9 +49,6 @@ public class GiftService extends BaseService {
|
||||
@Autowired
|
||||
private GiftMapper giftMapper;
|
||||
@Autowired
|
||||
@Qualifier("jmsTemplate")
|
||||
private JmsTemplate jmsTemplate;
|
||||
@Autowired
|
||||
private RoomExclusiveGiftService roomExclusiveGiftService;
|
||||
@Autowired
|
||||
private VipAuthItemService vipAuthItemService;
|
||||
@@ -214,32 +202,15 @@ public class GiftService extends BaseService {
|
||||
|
||||
public Gift getGiftById(Integer giftId) {
|
||||
String giftStr = jedisService.hget(RedisKey.gift.getKey(), giftId.toString());
|
||||
List<Gift> giftList = null;
|
||||
Gift gift = null;
|
||||
if (StringUtils.isEmpty(giftStr)) {
|
||||
return gift;
|
||||
if (StringUtils.isNotBlank(giftStr)){
|
||||
return gson.fromJson(giftStr, Gift.class);
|
||||
}
|
||||
gift = gson.fromJson(giftStr, Gift.class);
|
||||
return gift;
|
||||
}
|
||||
|
||||
public Gift newGetGiftById(Integer giftId) {
|
||||
String giftStr = jedisService.hget(RedisKey.gift.getKey(), giftId.toString());
|
||||
List<Gift> giftList = null;
|
||||
Gift gift = null;
|
||||
if (StringUtils.isEmpty(giftStr)) {
|
||||
GiftExample giftExample = new GiftExample();
|
||||
giftExample.createCriteria().andGiftIdEqualTo(giftId);
|
||||
giftList = giftMapper.selectByExample(giftExample);
|
||||
|
||||
if (CollectionUtils.isEmpty(giftList)) {
|
||||
return null;
|
||||
} else {
|
||||
gift = giftList.get(0);
|
||||
return gift;
|
||||
}
|
||||
Gift gift = giftMapper.selectByPrimaryKey(giftId);
|
||||
if (null != gift) {
|
||||
saveGiftCache(gift);
|
||||
}
|
||||
gift = gson.fromJson(giftStr, Gift.class);
|
||||
|
||||
return gift;
|
||||
}
|
||||
|
||||
|
@@ -27,11 +27,11 @@ import java.util.concurrent.ThreadLocalRandom;
|
||||
public class LuckyBagPoolService extends ServiceImpl<LuckyBagPoolMapper, LuckyBagPool> {
|
||||
|
||||
@Autowired
|
||||
GiftService giftService;
|
||||
private GiftService giftService;
|
||||
@Autowired
|
||||
SysConfService sysConfService;
|
||||
private SysConfService sysConfService;
|
||||
@Autowired
|
||||
LuckyBagPoolMapper luckyBagPoolMapper;
|
||||
private LuckyBagPoolMapper luckyBagPoolMapper;
|
||||
@Autowired
|
||||
private LuckyBagPoolClockingService luckyBagPoolClockingService;
|
||||
|
||||
|
@@ -16,6 +16,10 @@ public class ActiveMQService extends BaseService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ActiveMQService.class);
|
||||
|
||||
@Autowired
|
||||
@Qualifier( value = "jmsTemplate")
|
||||
private JmsTemplate jmsTemplate;
|
||||
|
||||
@Autowired
|
||||
@Qualifier( value = "giftJmsTemplate")
|
||||
private JmsTemplate giftJmsTemplate;
|
||||
@@ -24,10 +28,6 @@ public class ActiveMQService extends BaseService {
|
||||
@Qualifier( value = "openBoxJmsTemplate")
|
||||
private JmsTemplate openBoxJmsTemplate;
|
||||
|
||||
@Autowired
|
||||
@Qualifier( value = "jmsTemplate")
|
||||
private JmsTemplate jmsTemplate;
|
||||
|
||||
@Autowired
|
||||
@Qualifier( value = "cleanMusicJmsTemplate")
|
||||
private JmsTemplate cleanMusicJmsTemplate;
|
||||
|
@@ -162,7 +162,7 @@ public class SeekElfinServiceImpl extends BaseService implements SeekElfinServic
|
||||
Long uid = reqDTO.getUid();
|
||||
SeekElfinProd seekElfinProd = getSeekElfinProdById(reqDTO.getProdId());
|
||||
|
||||
Gift gift = giftService.newGetGiftById(seekElfinProd.getGiftId());
|
||||
Gift gift = giftService.getGiftById(seekElfinProd.getGiftId());
|
||||
if(gift == null){
|
||||
throw new ServiceException(BusiStatus.GIFT_IS_NOT_EXIST);
|
||||
}
|
||||
@@ -307,7 +307,7 @@ public class SeekElfinServiceImpl extends BaseService implements SeekElfinServic
|
||||
}
|
||||
recordDto.setNick(users != null ? users.getNick() : null);
|
||||
SeekElfinProd seekElfinProd = getSeekElfinProdById(record.getProdId());
|
||||
Gift gift = giftService.newGetGiftById(record.getReceiveGiftId());
|
||||
Gift gift = giftService.getGiftById(record.getReceiveGiftId());
|
||||
recordDto.setGiftName(gift != null ? gift.getGiftName() : null);
|
||||
recordDto.setProdName(seekElfinProd != null ? seekElfinProd.getProdName() : null);
|
||||
recordDto.setCreateTime(record.getCreateTime());
|
||||
|
@@ -446,7 +446,7 @@ public class UserBackpackService extends BaseService {
|
||||
|
||||
private UserBackpackParam buildUserBackpackParam(Long uid, BatchGiftParam compoundGift) {
|
||||
UserBackpackParam userBackpackParam = new UserBackpackParam();
|
||||
Gift giftById = giftService.newGetGiftById(compoundGift.getGiftId());
|
||||
Gift giftById = giftService.getGiftById(compoundGift.getGiftId());
|
||||
userBackpackParam.setUid(uid);
|
||||
userBackpackParam.setGiftId(compoundGift.getGiftId());
|
||||
userBackpackParam.setCount(compoundGift.getNum());
|
||||
|
@@ -3,7 +3,6 @@ package com.accompany.business.config;
|
||||
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.ActiveMQPrefetchPolicy;
|
||||
import org.apache.activemq.command.ActiveMQQueue;
|
||||
import org.apache.activemq.command.ActiveMQTopic;
|
||||
import org.apache.activemq.pool.PooledConnectionFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -20,7 +19,6 @@ import org.springframework.stereotype.Component;
|
||||
import javax.jms.ConnectionFactory;
|
||||
import javax.jms.DeliveryMode;
|
||||
import javax.jms.Queue;
|
||||
import javax.jms.Topic;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
|
@@ -1,8 +1,6 @@
|
||||
package com.accompany.business.mq;
|
||||
|
||||
import com.accompany.business.message.BoxPrizeMessage;
|
||||
import com.accompany.business.message.YidunIMAntiMessage;
|
||||
import com.accompany.business.service.box.BoxPrizeMessageService;
|
||||
import com.accompany.business.service.netease.YidunAntiHandleService;
|
||||
import com.accompany.common.redis.RedisKey;
|
||||
import com.accompany.core.service.common.JedisService;
|
||||
@@ -22,9 +20,9 @@ public class YidunIMTextAntiMessageListener {
|
||||
private static final Logger logger = LoggerFactory.getLogger(YidunIMTextAntiMessageListener.class);
|
||||
|
||||
@Autowired
|
||||
YidunAntiHandleService yidunAntiHandleService;
|
||||
private YidunAntiHandleService yidunAntiHandleService;
|
||||
@Autowired
|
||||
JedisService jedisService;
|
||||
private JedisService jedisService;
|
||||
|
||||
@JmsListeners(value = {
|
||||
@JmsListener(destination = "yindun-text-anti-queue",containerFactory = "yidunIMAntiContainer")
|
||||
|
@@ -51,9 +51,6 @@ public class TicketServices implements InitializingBean{
|
||||
@Qualifier( value = "adPlatformLoginMsgJmsTemplate")
|
||||
private JmsTemplate adPlatformLoginMsgJmsTemplate;
|
||||
|
||||
@Autowired
|
||||
private AccountManageService accountManageService;
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
Assert.notNull(ticketStore, "ticketStore can't be null");
|
||||
|
Reference in New Issue
Block a user