| | |
| | | package com.panzhihua.service_community.service.impl; |
| | | |
| | | import cn.hutool.core.date.DateUnit; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | import com.panzhihua.service_community.entity.ComActRaffleRecord; |
| | | import com.panzhihua.service_community.service.ComActRaffleService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | |
| | | private ComActRafflePrizeDao comActRafflePrizeDao; |
| | | @Resource |
| | | private ComActRaffleRecordDao comActRaffleRecordDao; |
| | | @Resource |
| | | private RabbitTemplate rabbitTemplate; |
| | | @Override |
| | | public R pageList(CommonPage commonPage) { |
| | | return R.ok(this.baseMapper.pageList(new Page(commonPage.getPage(),commonPage.getSize()),commonPage)); |
| | |
| | | comActRaffle.setStatus(0); |
| | | int count= this.baseMapper.insert(comActRaffle); |
| | | if(count>0){ |
| | | rabbitTemplate.convertAndSend("raffle.exchange", "raffle.key", comActRaffle, message -> { |
| | | message.getMessageProperties().setHeader("x-delay", dateToSecond(comActRaffle.getStartTime())); |
| | | return message; |
| | | }); |
| | | if(!CollectionUtils.isEmpty(comActRaffleVO.getComActRafflePrizeVOList())){ |
| | | comActRaffleVO.getComActRafflePrizeVOList().forEach(comActRafflePrizeVO -> { |
| | | ComActRafflePrize comActRafflePrize=new ComActRafflePrize(); |
| | |
| | | ComActRaffleRecordVO comActRaffleRecordVO=comActRaffleRecordDao.selectByUserId(userId,id); |
| | | if(comActRaffleRecordVO!=null){ |
| | | comActRaffleVO.setComActRaffleRecordVO(comActRaffleRecordVO); |
| | | comActRaffleVO.setJoinStatus(0); |
| | | } |
| | | else { |
| | | if(comActRaffleVO.getStatus()==1){ |
| | | comActRaffleVO.setJoinStatus(1); |
| | | } |
| | | else { |
| | | comActRaffleVO.setJoinStatus(0); |
| | | } |
| | | } |
| | | } |
| | | return R.ok(comActRaffleVO); |
| | | } |
| | | private Long dateToSecond(Date expireTime){ |
| | | return DateUtil.between(new Date(),expireTime, DateUnit.MS); |
| | | } |
| | | } |