peng
昨天 bf6989e1f9cc614cf0439f048280cbcdb78d4009
framework/src/main/java/cn/lili/modules/lmk/service/impl/PrizeServiceImpl.java
@@ -7,6 +7,7 @@
import cn.lili.common.security.context.UserContext;
import cn.lili.common.utils.StringUtils;
import cn.lili.modules.lmk.domain.entity.*;
import cn.lili.modules.lmk.domain.form.AddPrizeNumForm;
import cn.lili.modules.lmk.domain.query.PrizeRecordTimeQuery;
import cn.lili.modules.lmk.domain.vo.PrizeDetailVO;
import cn.lili.modules.lmk.domain.vo.PrizeProbabilityVO;
@@ -56,6 +57,7 @@
    private final RocketmqCustomProperties rocketmqCustomProperties;
    private final RocketMQTemplate rocketMQTemplate;
    private final COSUtil cosUtil;
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Result prize(String prizeId) {
@@ -174,7 +176,7 @@
        prizeRecordTimeQuery.setEndTime(endTime);
        prizeRecordTimeQuery.setRecordActivityId(prizeId);
        prizeRecordListByTime = prizeRecordService.getPrizeRecordListByTime(prizeRecordTimeQuery);
        prizeRecordListByTime.stream().filter(item->{
        prizeRecordListByTime.stream().filter(item -> {
            return item.getActivityPrizeRefId() != null;
        }).forEach(item -> {
            ActivityRefPrize activityRefPrize = canPrizeMap.get(item.getActivityPrizeRefId());
@@ -384,7 +386,7 @@
        if (useNum >= maxPrize) {
            return Result.ok().data(0);
        } else {
            return Result.ok().data(userPrizeNum>maxPrize?maxPrize-useNum:notUseNum);
            return Result.ok().data(userPrizeNum > maxPrize ? maxPrize - useNum : notUseNum);
        }
    }
@@ -421,16 +423,16 @@
        }
        PrizeDetailVO data = prizeActivityService.prizeInfo(prizeActivityId);
        String activityCover = data.getActivityCover();
        if (StringUtils.isNotBlank(activityCover)&&!activityCover.contains("http")) {
        if (StringUtils.isNotBlank(activityCover) && !activityCover.contains("http")) {
            data.setActivityCover(cosUtil.getPreviewUrl(activityCover));
        }
        data.getPrizeInfoVOS().forEach(info -> {
            String prizeImg = info.getPrizeImg();
            String prizeCover = info.getPrizeCover();
            if (StringUtils.isNotBlank(prizeImg)&&!prizeImg.contains("http")) {
            if (StringUtils.isNotBlank(prizeImg) && !prizeImg.contains("http")) {
                info.setPrizeImg(cosUtil.getPreviewUrl(prizeImg));
            }
            if (StringUtils.isNotBlank(prizeCover)&&!prizeCover.contains("http")) {
            if (StringUtils.isNotBlank(prizeCover) && !prizeCover.contains("http")) {
                info.setPrizeCover(cosUtil.getPreviewUrl(prizeCover));
            }
        });
@@ -441,4 +443,51 @@
    public Result grantRecord(String prizeActivityId) {
        return prizeDrawService.grantRecord(prizeActivityId);
    }
    @Override
    public Result addPrizeNum(AddPrizeNumForm addPrizeNumForm) {
        PrizeActivity activity = prizeActivityService.getById(addPrizeNumForm.getPrizeActivityId());
        if (activity == null) {
            throw new ServiceException("当前活动不存在");
        }
        if (!PrizeActivityStatusEnum.ON.name().equals(activity.getEnableStatus())) {
            throw new ServiceException("当前活动没开启");
        }
        Date date = new Date();
        //活动结束不需要添加
        if (date.after(activity.getEndTime())) {
            throw new ServiceException("当前活动已结束");
        }
        Integer maxPrize = activity.getMaxPrize();
        String userId = addPrizeNumForm.getUserId();
        List<PrizeNumber> prizeNumberList = getPrizeNumberList(activity.getId(), userId);
        if (prizeNumberList.size() >= maxPrize) {
            throw new ServiceException("抽奖次数已达到上限了");
        }
        PrizeUserActionEnum actionEnum = PrizeUserActionEnum.select(addPrizeNumForm.getAddType());
        if (actionEnum == null) {
            throw new ServiceException("当前类型不存在");
        }
       Boolean check ;
         //todo 进行数据校验
        switch (actionEnum) {
            case BUY:
                System.err.println("BUY");
                break;
            case SHARE:
                //直接获得抽奖次数
                System.err.println("SHARE");
                break;
            case SEE_SHOP:
                System.err.println("SEE_SHOP");
                break;
            case SEE_VIDEO:
                System.err.println("SEE_VIDEO");
                break;
            default:
                break;
        }
        return null;
    }
}