rentaiming
2024-06-22 a4abf8a27c46cbadbbd4b339fff573209e7f2f9c
ruoyi-modules/ruoyi-auction/src/main/java/com/ruoyi/auction/service/impl/AuctionSalesroomServiceImpl.java
@@ -53,7 +53,6 @@
import com.ruoyi.common.core.utils.page.Checker;
import com.ruoyi.common.core.utils.page.CollUtils;
import com.ruoyi.common.core.utils.page.PageDTO;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.system.api.RemoteFileService;
import com.ruoyi.system.api.constants.NotificationTypeConstant;
import com.ruoyi.system.api.domain.AppMiniLoginVO;
@@ -64,6 +63,7 @@
import com.ruoyi.system.api.domain.OrderAuctionBond;
import com.ruoyi.system.api.domain.PromotionVideo;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.domain.WebsocketMessageDTO;
import com.ruoyi.system.api.domain.dto.AppMiniLoginDTO;
import com.ruoyi.system.api.domain.dto.AuctionSalesroomDTO;
import com.ruoyi.system.api.domain.dto.BidDTO;
@@ -85,7 +85,6 @@
import com.ruoyi.system.api.feignClient.OrderClient;
import com.ruoyi.system.api.feignClient.PromotionClient;
import com.ruoyi.system.api.feignClient.SysUserClient;
import com.ruoyi.system.api.util.WebSocketUsers;
import io.seata.spring.annotation.GlobalTransactional;
import java.io.IOException;
import java.math.BigDecimal;
@@ -103,8 +102,6 @@
import java.util.function.Function;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import lombok.Data;
import org.apache.http.HttpResponse;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.util.EntityUtils;
@@ -243,9 +240,9 @@
        if (sysUser==null){
            throw new ServiceException("手机号未注册");
        }
        if (!SecurityUtils.matchesPassword(arepartAuctionBidRecordDTO.getPassword(), sysUser.getPassword())){
    /*   if (!SecurityUtils.matchesPassword(arepartAuctionBidRecordDTO.getPassword(), sysUser.getPassword())){
            throw new ServiceException("密码输入错误");
        }
        }*/
        LambdaQueryWrapper<AuctionSalesroom> wrapper=Wrappers.lambdaQuery();
        wrapper.eq(AuctionSalesroom::getAuctionSalesroomNo,arepartAuctionBidRecordDTO.getAuctionSalesroomQrcode());
@@ -473,6 +470,7 @@
        LambdaQueryWrapper<AuctionBrowseRecord> wrapper3=Wrappers.lambdaQuery();
        wrapper3.eq(AuctionBrowseRecord::getDelFlag,0);
        wrapper3.eq(AuctionBrowseRecord::getTargetId,memberAuctionSalesroomDTO.getAuctionSalesroomId());
        wrapper3.eq(AuctionBrowseRecord::getBrowseType,AuctionOrderTypeEnum.AUCTION_ITEMS);
        wrapper3.eq(AuctionBrowseRecord::getMemberId,memberAuctionSalesroomDTO.getMemberId());
        wrapper3.ge(AuctionBrowseRecord::getCreateTime, now)
                .le(AuctionBrowseRecord::getCreateTime, newTime7);
@@ -644,21 +642,17 @@
            map.put("auctionSalesroomId", bidVO.getAuctionSalesroomId());
            map.put("byId", byId.getStatus());
            map.put("lastBidAmount",one2.getLastBidAmount());
            map.put("message_type", "start");
            map.put("message_type", "BidRecor");
            map.put("type",3);
            String msg = null;
            try {
                msg = objectMapper.writeValueAsString(map);
            } catch (JsonProcessingException e) {
            }
            String finalMsg = msg;
            Thread socketSender=new Thread(()->{
                try {
                    Thread.sleep(1000);//先休眠1秒
                    WebSocketUsers.sendMessageToUsersByType(ClientTypeEnum.MEMBER.getCode(), finalMsg);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            });
                    sysUserClient.pushByClientType(WebsocketMessageDTO.builder().message(finalMsg)
                            .clientType(ClientTypeEnum.MEMBER).build(), SecurityConstants.INNER);
@@ -712,21 +706,17 @@
            map.put("auctionSalesroomId", bidVO.getAuctionSalesroomId());
            map.put("byId", byId.getStartStatus());
            map.put("lastBidAmount",one2.getLastBidAmount());
            map.put("message_type", "start");
            map.put("message_type", "BidRecor");
            map.put("type",4);
            String msg = null;
            try {
                msg = objectMapper.writeValueAsString(map);
            } catch (JsonProcessingException e) {
            }
            String finalMsg = msg;
            Thread socketSender=new Thread(()->{
                try {
                    Thread.sleep(1000);//先休眠1秒
                    WebSocketUsers.sendMessageToUsersByType(ClientTypeEnum.MEMBER.getCode(), finalMsg);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            });
            sysUserClient.pushByClientType(WebsocketMessageDTO.builder().message(finalMsg)
                            .clientType(ClientTypeEnum.MEMBER).build(), SecurityConstants.INNER);
        }
    }
@@ -776,7 +766,9 @@
                                query.getEndTime()), AuctionSalesroom::getStartTime,
                        query.getStartTime(),
                        query.getEndTime())
                .orderByDesc(AuctionSalesroom::getCreateTime)
                .page(new Page<>(query.getPageCurr(), query.getPageSize()));
        List<AuctionSalesroom> records = page.getRecords();
        if (StringUtils.isNull(records)) {
            return PageDTO.empty(page);
@@ -1080,6 +1072,7 @@
                .between(StringUtils.isNotNull(query.getStartTime()) && StringUtils.isNotNull(
                                query.getEndTime()), AuctionSalesroom::getStartTime, query.getStartTime(),
                        query.getEndTime())
                .orderByAsc(AuctionSalesroom::getStartTime)
                .page(new Page<>(query.getPageCurr(), query.getPageSize()));
        List<AuctionSalesroom> records = page.getRecords();
        if (StringUtils.isNull(records)) {
@@ -1282,13 +1275,22 @@
     * @param id 拍卖场商品id
     */
    @Override
    public void stopCurrentGoods(Long id) {
    public void stopCurrentGoods(Long id) throws JsonProcessingException {
        AuctionSalesroomGoods auctionSalesroomGoods = auctionSalesroomGoodsMapper.selectById(id);
        if (StringUtils.isNull(auctionSalesroomGoods)) {
            throw new ServiceException("拍卖商品不存在");
        }
        auctionSalesroomGoods.setStatus(AuctionGoodsStatusEnum.ENDED);
        auctionSalesroomGoodsMapper.updateById(auctionSalesroomGoods);
        Map<String, Object> map = new ConcurrentHashMap<>();
        map.put("notification_type", NotificationTypeConstant.AUCTION_SALESROOM_GOODS);
        map.put("auctionSalesroomId", auctionSalesroomGoods.getAuctionSalesroomId().toString());
        map.put("auctionSalesroomGoodsId", auctionSalesroomGoods.getId().toString());
        map.put("AuctionTypeEnum", auctionSalesroomGoods.getStatus());
        map.put("message_type", "stop");
        map.put("type", "2");
        String msg = objectMapper.writeValueAsString(map);
        sysUserClient.pushAll(msg, SecurityConstants.INNER);
    }
    /**
@@ -1297,13 +1299,22 @@
     * @param id 拍卖场商品id
     */
    @Override
    public void startNextGoods(Long id) {
    public void startNextGoods(Long id) throws JsonProcessingException {
        AuctionSalesroomGoods auctionSalesroomGoods = auctionSalesroomGoodsMapper.selectById(id);
        if (StringUtils.isNull(auctionSalesroomGoods)) {
            throw new ServiceException("拍卖商品不存在");
        }
        auctionSalesroomGoods.setStatus(AuctionGoodsStatusEnum.IN_PROGRESS);
        auctionSalesroomGoodsMapper.updateById(auctionSalesroomGoods);
        Map<String, Object> map = new ConcurrentHashMap<>();
        map.put("notification_type", NotificationTypeConstant.AUCTION_SALESROOM_GOODS);
        map.put("auctionSalesroomId", auctionSalesroomGoods.getAuctionSalesroomId().toString());
        map.put("auctionSalesroomGoodsId", auctionSalesroomGoods.getId().toString());
        map.put("AuctionTypeEnum", auctionSalesroomGoods.getStatus());
        map.put("message_type", "start");
        map.put("type", "2");
        String msg = objectMapper.writeValueAsString(map);
        sysUserClient.pushAll(msg, SecurityConstants.INNER);
    }
    /**
@@ -1318,6 +1329,8 @@
        if (StringUtils.isNull(data)) {
            throw new ServiceException("视频不存在");
        }
        iAuctionVideoService.remove(Wrappers.<AuctionVideo>lambdaQuery().eq
                (AuctionVideo::getAuctionSalesroomId, dto.getAuctionSalesroomId()));
        AuctionVideo auctionVideo = new AuctionVideo();
        auctionVideo.setAuctionSalesroomId(dto.getAuctionSalesroomId());
        auctionVideo.setPromotionVideoId(dto.getVideoId());
@@ -1333,7 +1346,7 @@
    @Override
    public void stopPlay(Long auctionSalesroomId) {
        iAuctionVideoService.remove(Wrappers.<AuctionVideo>lambdaQuery().eq
                (AuctionVideo::getAuctionSalesroomId, 1L));
                (AuctionVideo::getAuctionSalesroomId, auctionSalesroomId));
    }
    /**
@@ -1363,10 +1376,13 @@
        Map<String, Object> map = new ConcurrentHashMap<>();
        map.put("notification_type", NotificationTypeConstant.AUCTION_SALESROOM);
        map.put("auctionSalesroomId", auctionSalesroom.getId());
        map.put("auctionSalesroomId", auctionSalesroom.getId().toString());
        map.put("AuctionTypeEnum", auctionSalesroom.getStatus());
        map.put("message_type", "start");
        map.put("type", "1");
        String msg = objectMapper.writeValueAsString(map);
        WebSocketUsers.sendMessageToUsersByType(ClientTypeEnum.AUCTIONEER.getCode(), msg);
        sysUserClient.pushByClientType(WebsocketMessageDTO.builder().message(msg)
                .clientType(ClientTypeEnum.AUCTIONEER).build(), SecurityConstants.INNER);
    }
    @Override
@@ -1374,17 +1390,24 @@
    @Transactional
    public void stopCurrentAuctionSalesroom(Long auctionSalesroomId)
            throws JsonProcessingException {
        // 修改拍卖场开始状态
        AuctionSalesroom auctionSalesroom = this.getById(auctionSalesroomId);
        auctionSalesroom.setStatus(AuctionStartStatusEnum.ENDED);
        auctionSalesroom.setEndTime(LocalDateTime.now());
        auctionSalesroomMapper.updateById(auctionSalesroom);
        LambdaQueryWrapper<AuctionSalesroomGoods> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(AuctionSalesroomGoods::getStatus, AuctionGoodsStatusEnum.WAITING);
        wrapper.eq(AuctionSalesroomGoods::getAuctionSalesroomId, auctionSalesroomId);
        wrapper.orderByDesc(AuctionSalesroomGoods::getSortNum);
        List<AuctionSalesroomGoods> auctionSalesroomGoods = auctionSalesroomGoodsMapper.selectList(
                wrapper);
        long count = auctionSalesroomGoods.stream()
                .filter(goods -> goods.getStatus().equals(AuctionGoodsStatusEnum.IN_PROGRESS))
                .count();
        if (count > 0) {
            throw new ServiceException("当前拍卖场正在拍卖商品,不能停止");
        }
        // 修改拍卖场开始状态
        AuctionSalesroom auctionSalesroom = this.getById(auctionSalesroomId);
        auctionSalesroom.setStatus(AuctionStartStatusEnum.ENDED);
        auctionSalesroom.setEndTime(LocalDateTime.now());
        auctionSalesroomMapper.updateById(auctionSalesroom);
        if (StringUtils.isNotEmpty(auctionSalesroomGoods)) {
            List<GoodsStockUpdDTO> dtoList = new ArrayList<>();
            for (AuctionSalesroomGoods salesroomGoods : auctionSalesroomGoods) {
@@ -1413,10 +1436,13 @@
        }
        Map<String, Object> map = new ConcurrentHashMap<>();
        map.put("notification_type", NotificationTypeConstant.AUCTION_SALESROOM);
        map.put("auctionSalesroomId", auctionSalesroom.getId());
        map.put("auctionSalesroomId", auctionSalesroom.getId().toString());
        map.put("AuctionTypeEnum",auctionSalesroom.getStatus());
        map.put("message_type", "end");
        map.put("type", "1");
        String msg = objectMapper.writeValueAsString(map);
        WebSocketUsers.sendMessageToUsersByType(ClientTypeEnum.AUCTIONEER.getCode(), msg);
        sysUserClient.pushByClientType(WebsocketMessageDTO.builder().message(msg)
                .clientType(ClientTypeEnum.AUCTIONEER).build(), SecurityConstants.INNER);
    }
    @Override