|
|
|
@ -5,6 +5,7 @@ import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
import com.luoo.user.Scheduler.DrawLotteryScheduler;
|
|
|
|
|
import com.luoo.user.config.EnvConfig;
|
|
|
|
|
import com.luoo.user.config.MallConfig;
|
|
|
|
|
import com.luoo.user.dao.*;
|
|
|
|
|
import com.luoo.user.dto.point.DrawDTO;
|
|
|
|
|
import com.luoo.user.dto.point.LotteryParticipatedSearchDto;
|
|
|
|
@ -21,14 +22,14 @@ import constants.Constants;
|
|
|
|
|
import constants.ErrorConstants;
|
|
|
|
|
import constants.RabbitmqConstants;
|
|
|
|
|
import constants.TaskPointIdConstants;
|
|
|
|
|
import dto.MallProduct;
|
|
|
|
|
import dto.MallProductAttributeValue;
|
|
|
|
|
import dto.UserLoginDto;
|
|
|
|
|
import enums.PointEnums;
|
|
|
|
|
import enums.UserBetaEnum;
|
|
|
|
|
import enums.UserTypeEnum;
|
|
|
|
|
import enums.UserVipStatusEnum;
|
|
|
|
|
import enums.*;
|
|
|
|
|
import exception.BizException;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
|
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
@ -47,11 +48,9 @@ import javax.persistence.criteria.CriteriaQuery;
|
|
|
|
|
import javax.persistence.criteria.Predicate;
|
|
|
|
|
import javax.persistence.criteria.Root;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -99,6 +98,9 @@ public class LotteryService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private CommentDao commentDao;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private MallConfig mallConfig;
|
|
|
|
|
|
|
|
|
|
public LotteryService(LotteryDao lotteryDao, JwtUtil jwtUtil, IdWorker idWorker, RedisLockUtil redisLockUtil, RegionService regionService, LotteryRegionDao lotteryRegionDao, UserInfoDao userInfoDao, RabbitTemplate rabbitTemplate, LotteryUserDao lotteryUserDao, DrawLotteryScheduler drawLotteryScheduler, JPAQueryFactory jpaQueryFactory, EnvConfig envConfig, UserinfoShippingAddressService userinfoShippingAddressService, UserPointLogService userPointLogService,
|
|
|
|
|
UserPointLogDao userPointLogDao) {
|
|
|
|
|
this.lotteryDao = lotteryDao;
|
|
|
|
@ -317,6 +319,7 @@ public class LotteryService {
|
|
|
|
|
lottery.setStatus(PointEnums.LOTTERY_STATUS_SIGN.getCode());
|
|
|
|
|
|
|
|
|
|
lotteryDao.save(lottery);
|
|
|
|
|
shelving(lottery);
|
|
|
|
|
|
|
|
|
|
String result = drawLotteryScheduler.scheduleDraw(lottery.getApplyEndTime(), id);
|
|
|
|
|
|
|
|
|
@ -328,6 +331,40 @@ public class LotteryService {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 上架操作
|
|
|
|
|
*
|
|
|
|
|
* @param lottery 积分活动对象
|
|
|
|
|
*/
|
|
|
|
|
private void shelving(Lottery lottery) {
|
|
|
|
|
// 只有待上架允许上架
|
|
|
|
|
|
|
|
|
|
MallProduct mallProduct = MallProduct.builder()
|
|
|
|
|
.brandId(mallConfig.getBrandId())
|
|
|
|
|
.brandName(mallConfig.getBrandName())
|
|
|
|
|
.productCategoryName(mallConfig.getProductCategoryName())
|
|
|
|
|
.productCategoryId(mallConfig.getProductCategoryId())
|
|
|
|
|
.productAttributeCategoryId(mallConfig.getProductAttributeCategoryId())
|
|
|
|
|
.name(lottery.getTitle())
|
|
|
|
|
.pic(lottery.getImage())
|
|
|
|
|
.subTitle(lottery.getTitle())
|
|
|
|
|
.price(new BigDecimal(lottery.getPoint()))
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
List<MallProductAttributeValue> attributeValueList = new ArrayList<>();
|
|
|
|
|
attributeValueList.add(MallProductAttributeValue.builder().productAttributeId(mallConfig.getAlbumId()).value(lottery.getId()).build());
|
|
|
|
|
attributeValueList.add(MallProductAttributeValue.builder().productAttributeId(mallConfig.getAlbumName()).value(lottery.getTitle()).build());
|
|
|
|
|
// attributeValueList.add(MallProductAttributeValue.builder().productAttributeId(mallConfig.getSongId()).value(lottery.getId()).build());
|
|
|
|
|
// attributeValueList.add(MallProductAttributeValue.builder().productAttributeId(mallConfig.getArtistId()).value(lottery.getId()).build());
|
|
|
|
|
attributeValueList.add(MallProductAttributeValue.builder().productAttributeId(mallConfig.getArtistName()).value(lottery.getTitle()).build());
|
|
|
|
|
Map<String, Object> mallMqMap = new HashMap<>();
|
|
|
|
|
mallMqMap.put("lotteryId", lottery.getId());
|
|
|
|
|
mallMqMap.put("mallProduct", mallProduct);
|
|
|
|
|
mallMqMap.put("attributeValueList", attributeValueList);
|
|
|
|
|
|
|
|
|
|
rabbitTemplate.convertAndSend("luoo_mall_lottery_product_add", mallMqMap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 停止抽奖
|
|
|
|
|
*
|
|
|
|
|