rentaiming
2024-07-10 b29becf95484be48aa09e87fcc7cc19f94cf9c81
ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/GoodsSeckillServiceImpl.java
@@ -22,8 +22,10 @@
import com.ruoyi.goods.controller.management.dto.GoodsSeckillQuery;
import com.ruoyi.goods.controller.management.dto.GoodsSeckillUpd;
import com.ruoyi.goods.controller.management.vo.GoodsSeckillVO;
import com.ruoyi.goods.domain.GoodsSeckillAppointment;
import com.ruoyi.goods.domain.MemberGoodsCollection;
import com.ruoyi.goods.mapper.GoodsSeckillMapper;
import com.ruoyi.goods.service.IGoodsSeckillAppointmentService;
import com.ruoyi.goods.service.IGoodsSeckillService;
import com.ruoyi.goods.service.IGoodsSkuService;
import com.ruoyi.goods.service.IMemberGoodsCollectionService;
@@ -36,6 +38,7 @@
import com.ruoyi.system.api.domain.GoodsSeckill;
import com.ruoyi.system.api.domain.GoodsSeries;
import com.ruoyi.system.api.domain.GoodsSku;
import com.ruoyi.system.api.domain.WebsocketMessageDTO;
import com.ruoyi.system.api.domain.dto.HomeGoodsSkuDTO;
import com.ruoyi.system.api.domain.dto.ListStatusDTO;
import com.ruoyi.system.api.domain.vo.HomeGoodsSeckillInfoVO;
@@ -43,7 +46,6 @@
import com.ruoyi.system.api.feignClient.GoodsSkuClient;
import com.ruoyi.system.api.feignClient.OrderClient;
import com.ruoyi.system.api.feignClient.SysUserClient;
import com.ruoyi.system.api.util.WebSocketUsers;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@@ -84,6 +86,10 @@
    @Resource
    private IMemberGoodsCollectionService iMemberGoodsCollectionService;
    @Resource
    private IGoodsSeckillAppointmentService iGoodsSeckillAppointmentService;
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void addGoodsSeckill(GoodsSeckillDTO dto) {
@@ -221,7 +227,8 @@
        map.put("target_id", seckillId);
        map.put("message_type", "start");
        String msg = objectMapper.writeValueAsString(map);
        WebSocketUsers.sendMessageToUsersByType(ClientTypeEnum.MEMBER.getCode(), msg);
        sysUserClient.pushByClientType(WebsocketMessageDTO.builder().message(msg)
                .clientType(ClientTypeEnum.MEMBER).build(), SecurityConstants.INNER);
        log.info("===================>发送websocket通知,消息体{}", msg);
    }
@@ -248,7 +255,8 @@
        map.put("target_id", seckillId);
        map.put("message_type", "end");
        String msg = objectMapper.writeValueAsString(map);
        WebSocketUsers.sendMessageToUsersByType(ClientTypeEnum.MEMBER.getCode(), msg);
        sysUserClient.pushByClientType(WebsocketMessageDTO.builder().message(msg)
                .clientType(ClientTypeEnum.MEMBER).build(), SecurityConstants.INNER);
        log.info("===================>发送websocket通知,消息体{}", msg);
    }
@@ -256,8 +264,7 @@
    public PageDTO<HomeGoodsSeckillVO> getHomeGoodsSeckillVOList(HomeGoodsSkuDTO homeGoodsSkuDTO) {
        LambdaQueryWrapper<GoodsSku> wrapper3= Wrappers.lambdaQuery();
        wrapper3.eq(GoodsSku::getDelFlag,0);
        wrapper3.eq(GoodsSku::getListingStatus,0);
        if (homeGoodsSkuDTO.getSkuName()!=null){
        if (homeGoodsSkuDTO.getSkuName()!=null && homeGoodsSkuDTO.getSkuName()!=""){
            wrapper3.like(GoodsSku::getSkuName,homeGoodsSkuDTO.getSkuName());
        }
        if (homeGoodsSkuDTO.getBrandId()!=null){
@@ -351,8 +358,11 @@
        in.add(0);
        in.add(1);
        wrapper4.in(GoodsSeckill::getStartStatus,in);
        wrapper4.in(GoodsSeckill::getGoodsSkuId,goodsSkuIdList);
        wrapper4.orderByAsc(GoodsSeckill::getSortNum);
        if(goodsSkuIdList.size()>0){
            wrapper4.in(GoodsSeckill::getGoodsSkuId,goodsSkuIdList);
        }
        wrapper4.orderByDesc(GoodsSeckill::getSortNum);
        Page<GoodsSeckill> page2 = this.page(page, wrapper4);
        PageDTO<HomeGoodsSeckillVO> HomeGoodsSeckillVOPageDTO = PageDTO.of(page2, HomeGoodsSeckillVO.class);
@@ -379,10 +389,19 @@
        GoodsCategory data1 = goodsSkuClient.getCategoryOne(data6.getCategoryId(), SecurityConstants.INNER).getData();
        GoodsSeries data2 = goodsSkuClient.getSeriesOne(data6.getSeriesId(), SecurityConstants.INNER).getData();
        GoodsFlavorType data3 = goodsSkuClient.getFlavorTypeOne(data6.getFlavorTypeId(), SecurityConstants.INNER).getData();
        homeGoodsSeckillInfoVO.setBrand(data.getBrandName());
        if(data!=null){
            homeGoodsSeckillInfoVO.setBrand(data.getBrandName());
        }
        if(data1!=null){
        homeGoodsSeckillInfoVO.setCategory(data1.getCategoryName());
        }
            if(data2!=null){
        homeGoodsSeckillInfoVO.setSeries(data2.getSeriesName());
            }
                if(data3!=null){
        homeGoodsSeckillInfoVO.setFlavorType(data3.getFlavorTypeName());
                }
        homeGoodsSeckillInfoVO.setPrice(data6.getPrice());
        homeGoodsSeckillInfoVO.setSoldQuantity(byId.getSoldQuantity());
        homeGoodsSeckillInfoVO.setUnit(data6.getUnit());
@@ -410,6 +429,18 @@
        }else{
            homeGoodsSeckillInfoVO.setIsCollection(1);
        }
        LambdaQueryWrapper<GoodsSeckillAppointment> wrapper4= Wrappers.lambdaQuery();
        wrapper4.eq(GoodsSeckillAppointment::getDelFlag,0);
        wrapper4.eq(GoodsSeckillAppointment::getMemberId,homeGoodsSkuDTO.getMemberId());
        wrapper4.eq(GoodsSeckillAppointment::getGoodsSeckillId,homeGoodsSkuDTO.getGoodsSkuId());
        List<GoodsSeckillAppointment> list2 = iGoodsSeckillAppointmentService.list(wrapper4);
        if (list2.size()>0){
            homeGoodsSeckillInfoVO.setIsAppointment(2);
        }else{
            homeGoodsSeckillInfoVO.setIsAppointment(1);
        }
        return homeGoodsSeckillInfoVO;
    }
}