| | |
| | | package cn.lili.modules.lmk.service.impl; |
| | | |
| | | import cn.lili.common.utils.StringUtils; |
| | | import cn.lili.modules.lmk.domain.entity.ActivityRefPrize; |
| | | import cn.lili.modules.lmk.service.ActivityRefPrizeService; |
| | | import cn.lili.modules.promotion.entity.vos.CouponVO; |
| | | import cn.lili.modules.promotion.service.CouponService; |
| | | import cn.lili.utils.COSUtil; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import cn.lili.modules.lmk.domain.entity.PrizeDraw; |
| | | import cn.lili.modules.lmk.mapper.PrizeDrawMapper; |
| | |
| | | import cn.lili.utils.PageUtil; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.util.Assert; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | public class PrizeDrawServiceImpl extends ServiceImpl<PrizeDrawMapper, PrizeDraw> implements PrizeDrawService { |
| | | |
| | | private final PrizeDrawMapper prizeDrawMapper; |
| | | |
| | | private final ActivityRefPrizeService activityRefPrizeService; |
| | | |
| | | private final CouponService couponService; |
| | | |
| | | private final COSUtil cOSUtil; |
| | | |
| | | @Override |
| | | public Result canUpDatePrizeDraw(String prizeDrawId) { |
| | | PrizeDraw prizeDraw = baseMapper.selectById(prizeDrawId); |
| | | CouponVO detail = new CouponVO(); |
| | | if (StringUtils.isNotBlank(prizeDraw.getCouponId())){ |
| | | detail = couponService.getDetail(prizeDraw.getCouponId()); |
| | | } |
| | | Result result = Result.ok(); |
| | | result.data(detail); |
| | | Object data = activityRefPrizeService.getPrizeByIdAndPrizeActivityId(prizeDrawId).get("data"); |
| | | |
| | | if (data instanceof List<?>) { |
| | | List<?> rawList = (List<?>) data; |
| | | List<ActivityRefPrize> list = new ArrayList<>(); |
| | | for (Object item : rawList) { |
| | | if (item instanceof ActivityRefPrize) { |
| | | list.add((ActivityRefPrize) item); |
| | | } |
| | | } |
| | | if (CollectionUtils.isEmpty(list)) { |
| | | return result.put("state",true); |
| | | }else{ |
| | | return result.put("state",false); |
| | | } |
| | | // 使用 list |
| | | } |
| | | return result.put("state",false); |
| | | } |
| | | |
| | | /** |
| | | * 添加 |
| | |
| | | @Override |
| | | public Result update(PrizeDrawForm form) { |
| | | PrizeDraw entity = baseMapper.selectById(form.getId()); |
| | | |
| | | // 为空抛IllegalArgumentException,做全局异常处理 |
| | | Assert.notNull(entity, "记录不存在"); |
| | | BeanUtils.copyProperties(form, entity); |
| | |
| | | public Result page(PrizeDrawQuery query) { |
| | | IPage<PrizeDrawVO> page = PageUtil.getPage(query, PrizeDrawVO.class); |
| | | baseMapper.getPage(page, query); |
| | | for (PrizeDrawVO vo : page.getRecords()) { |
| | | if (StringUtils.isNotBlank(vo.getPrizeCover())){ |
| | | vo.setPrizeCoverUrl(cOSUtil.getPreviewUrl(vo.getPrizeCover())); |
| | | } |
| | | if (StringUtils.isNotBlank(vo.getPrizeImg())){ |
| | | vo.setPrizeImgUrl(cOSUtil.getPreviewUrl(vo.getPrizeImg())); |
| | | } |
| | | } |
| | | return Result.ok().data(page.getRecords()).total(page.getTotal()); |
| | | } |
| | | |