mitao
2024-09-21 f44e4d609e7efaed9eac545137970b1e334f8106
ruoyi-modules/ruoyi-auction/src/main/java/com/ruoyi/auction/service/impl/AuctionSalesroomServiceImpl.java
@@ -25,7 +25,6 @@
import com.ruoyi.auction.controller.management.vo.MgtAuctionSalesroomScreenVO;
import com.ruoyi.auction.controller.management.vo.MgtAuctionSalesroomVO;
import com.ruoyi.auction.domain.AuctionBidRecord;
import com.ruoyi.auction.domain.AuctionBondJl;
import com.ruoyi.auction.domain.AuctionBrowseRecord;
import com.ruoyi.auction.domain.AuctionVideo;
import com.ruoyi.auction.mapper.AuctionBidRecordMapper;
@@ -61,6 +60,7 @@
import com.ruoyi.system.api.constants.ConfigEnum;
import com.ruoyi.system.api.constants.NotificationTypeConstant;
import com.ruoyi.system.api.domain.AppMiniLoginVO;
import com.ruoyi.system.api.domain.AuctionBondJl;
import com.ruoyi.system.api.domain.AuctionGoods;
import com.ruoyi.system.api.domain.AuctionSalesroom;
import com.ruoyi.system.api.domain.AuctionSalesroomGoods;
@@ -108,13 +108,17 @@
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpResponse;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.util.EntityUtils;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -126,6 +130,7 @@
 * @author mitao
 * @since 2024-05-16
 */
@Slf4j
@Service
public class AuctionSalesroomServiceImpl extends ServiceImpl<AuctionSalesroomMapper, AuctionSalesroom> implements IAuctionSalesroomService {
@@ -174,6 +179,9 @@
    @Resource
    private RemoteFileService remoteFileService;
    @Resource
    private RedissonClient redissonClient;
    public static RequestConfig config = RequestConfig.custom().setConnectTimeout(5000).setSocketTimeout(5000).build();
    // 配置您申请的KEY,在个人中心->我的数据,接口名称上方查看
    public static final String APPKEY = "";
@@ -402,7 +410,7 @@
            memberAuctionSalesroomVO.setSalesroomId(auctionSalesroom.getId());
            memberAuctionSalesroomVO.setStartTime(auctionSalesroom.getStartTime());
            memberAuctionSalesroomVO.setEndTime(auctionSalesroom.getEndTime());
            memberAuctionSalesroomVO.setCoverPic(auctionSalesroom.getCoverPic());
            memberAuctionSalesroomVO.setCoverPic(auctionSalesroom.getClientCoverPic());
            memberAuctionSalesroomVO.setBond(auctionSalesroom.getBond());
            memberAuctionSalesroomVO.setAuthentication(auctionSalesroom.getAuthentication());
            memberAuctionSalesroomDTO.setAuctionSalesroomId(auctionSalesroom.getId());
@@ -459,8 +467,17 @@
        memberAuctionSalesroomInfoVO.setEndTime(byId.getEndTime());
        memberAuctionSalesroomInfoVO.setType(byId.getType());
        memberAuctionSalesroomInfoVO.setDescription(byId.getDescription());
        memberAuctionSalesroomInfoVO.setSharePic(byId.getSharePic());
        memberAuctionSalesroomInfoVO.setShareTitle(byId.getShareTitle());
        if (StringUtils.isNotBlank(byId.getShareTitle())) {
            memberAuctionSalesroomInfoVO.setShareTitle(byId.getShareTitle());
        } else {
            memberAuctionSalesroomInfoVO.setShareTitle(byId.getSalesroomName());
        }
        if (StringUtils.isNotBlank(byId.getSharePic())) {
            memberAuctionSalesroomInfoVO.setSharePic(byId.getSharePic());
        } else {
            memberAuctionSalesroomInfoVO.setSharePic(byId.getCoverPic());
        }
        memberAuctionSalesroomInfoVO.setStartTime(byId.getStartTime());
        memberAuctionSalesroomInfoVO.setStatus(byId.getStatus());
        memberAuctionSalesroomInfoVO.setCoverPic(byId.getCoverPic());
@@ -663,149 +680,156 @@
    @Override
    public void SaveBid(BidDTO bidVO) {
        Member membeOne = memberClient.getMembeOne(bidVO.getMemberId(), SecurityConstants.INNER).getData();
        if (bidVO.getAuctionType()==2){
            AuctionSalesroomGoods byId = auctionSalesroomGoodsMapper.selectById(bidVO.getTargetId());
            if (byId.getStartingPrice().doubleValue()>bidVO.getLastBidAmount().doubleValue()){
                throw new ServiceException("出价不能比起拍价低");
            }
            AuctionSalesroom byId1 = this.getById(bidVO.getAuctionSalesroomId());
            if(byId1==null){
                LambdaQueryWrapper<AuctionSalesroom> wrapper= Wrappers.lambdaQuery();
                wrapper.eq(AuctionSalesroom::getAuctionSalesroomNo,bidVO.getAuctionSalesroomId());
                wrapper.eq(AuctionSalesroom::getDelFlag,0);
                AuctionSalesroom one = this.getOne(wrapper);
                bidVO.setAuctionSalesroomId(one.getId());
            }
        RLock lock = redissonClient.getLock(
                "bid-" + bidVO.getAuctionType() + "-" + bidVO.getTargetId());
        lock.lock(10, TimeUnit.SECONDS);
        try {
            Member membeOne = memberClient.getMembeOne(bidVO.getMemberId(), SecurityConstants.INNER)
                    .getData();
            if (bidVO.getAuctionType() == 2) {
                AuctionSalesroomGoods byId = auctionSalesroomGoodsMapper.selectById(
                        bidVO.getTargetId());
                if (byId.getStartingPrice().doubleValue() > bidVO.getLastBidAmount()
                        .doubleValue()) {
                    throw new ServiceException("出价不能比起拍价低");
                }
                AuctionSalesroom byId1 = this.getById(bidVO.getAuctionSalesroomId());
                if (byId1 == null) {
                    LambdaQueryWrapper<AuctionSalesroom> wrapper = Wrappers.lambdaQuery();
                    wrapper.eq(AuctionSalesroom::getAuctionSalesroomNo,
                            bidVO.getAuctionSalesroomId());
                    wrapper.eq(AuctionSalesroom::getDelFlag, 0);
                    AuctionSalesroom one = this.getOne(wrapper);
                    bidVO.setAuctionSalesroomId(one.getId());
                }
            LambdaQueryWrapper<AuctionBidRecord> wrapper3=Wrappers.lambdaQuery();
            wrapper3.eq(AuctionBidRecord::getAuctionSalesroomId,bidVO.getAuctionSalesroomId());
            wrapper3.eq(AuctionBidRecord::getTargetId,bidVO.getTargetId());
            wrapper3.eq(AuctionBidRecord::getDelFlag,0);
            wrapper3.orderByDesc(AuctionBidRecord::getLastBidAmount);
            wrapper3.last("limit 1");
            AuctionBidRecord one3 = auctionBidRecordService.getOne(wrapper3);
            if (byId.getSalesroomStock()==1){
                if (one3!=null){
                    if (bidVO.getLastBidAmount().doubleValue()<one3.getLastBidAmount().doubleValue()){
                        throw new ServiceException("出价不能比当前最高价低");
                LambdaQueryWrapper<AuctionBidRecord> wrapper3 = Wrappers.lambdaQuery();
                wrapper3.eq(AuctionBidRecord::getAuctionSalesroomId, bidVO.getAuctionSalesroomId());
                wrapper3.eq(AuctionBidRecord::getTargetId, bidVO.getTargetId());
                wrapper3.eq(AuctionBidRecord::getDelFlag, 0);
                wrapper3.orderByDesc(AuctionBidRecord::getLastBidAmount);
                wrapper3.last("limit 1");
                AuctionBidRecord one3 = auctionBidRecordService.getOne(wrapper3);
                if (byId.getSalesroomStock() == 1) {
                    if (one3 != null) {
                        if (bidVO.getLastBidAmount().doubleValue() < one3.getLastBidAmount()
                                .doubleValue()) {
                            throw new ServiceException("出价不能比当前最高价低");
                        }
                    }
                    if (one3 != null) {
                        if (bidVO.getLastBidAmount().doubleValue() < one3.getLastBidAmount()
                                .add(byId.getMinimumMarkupAmount()).doubleValue()) {
                            throw new ServiceException("出价不能比当前最高价低加每次加价低");
                        }
                    }
                }
                if (one3!=null){
                    if (bidVO.getLastBidAmount().doubleValue()<one3.getLastBidAmount().add(byId.getMinimumMarkupAmount()).doubleValue()){
                        throw new ServiceException("出价不能比当前最高价低加每次加价低");
                    }
                }
            }
            BigDecimal bigDecimal=byId.getStartingPrice().add(byId.getMinimumMarkupAmount());
            if (bigDecimal.doubleValue()>bidVO.getLastBidAmount().doubleValue()){
                throw new ServiceException("出价不能比每次最少加价低");
            }
            LambdaQueryWrapper<AuctionBidRecord> wrapper1=Wrappers.lambdaQuery();
            wrapper1.eq(AuctionBidRecord::getMemberId,bidVO.getMemberId());
            wrapper1.eq(AuctionBidRecord::getAuctionSalesroomId,bidVO.getAuctionSalesroomId());
            wrapper1.eq(AuctionBidRecord::getTargetId,bidVO.getTargetId());
            wrapper1.eq(AuctionBidRecord::getDelFlag,0);
            AuctionBidRecord one = auctionBidRecordService.getOne(wrapper1);
            if (one!=null){
                one.setLastBidAmount(bidVO.getLastBidAmount());
                one.setLastBidTime(LocalDateTime.now());
                one.setBidCount(one.getBidCount()+1);
                auctionBidRecordService.updateById(one);
            }else{
                one=new AuctionBidRecord();
                one.setAuctionSalesroomId(bidVO.getAuctionSalesroomId());
                one.setTargetId(bidVO.getTargetId());
                one.setMemberId(bidVO.getMemberId());
                one.setLastBidTime(LocalDateTime.now());
                if(membeOne.getRealName()!=null&&membeOne.getRealName()!=""){
                    one.setNickname(membeOne.getRealName());
                }else{
                    one.setNickname(membeOne.getNickname());
                BigDecimal bigDecimal = byId.getStartingPrice().add(byId.getMinimumMarkupAmount());
                if (bigDecimal.doubleValue() > bidVO.getLastBidAmount().doubleValue()) {
                    throw new ServiceException("出价不能比每次最少加价低");
                }
                one.setPhone(membeOne.getPhone());
                one.setAuctionType(AuctionOrderTypeEnum.AUCTION_ITEMS);
                one.setStatus(BidStatusEnum.ELIMINATE);
                one.setBidCount(1);
                one.setLastBidAmount(bidVO.getLastBidAmount());
                auctionBidRecordService.save(one);
            }
                LambdaQueryWrapper<AuctionBidRecord> wrapper1 = Wrappers.lambdaQuery();
                wrapper1.eq(AuctionBidRecord::getMemberId, bidVO.getMemberId());
                wrapper1.eq(AuctionBidRecord::getAuctionSalesroomId, bidVO.getAuctionSalesroomId());
                wrapper1.eq(AuctionBidRecord::getTargetId, bidVO.getTargetId());
                wrapper1.eq(AuctionBidRecord::getDelFlag, 0);
            LambdaQueryWrapper<AuctionBidRecord> wrapper2=Wrappers.lambdaQuery();
            wrapper2.eq(AuctionBidRecord::getAuctionSalesroomId,bidVO.getAuctionSalesroomId());
            wrapper2.eq(AuctionBidRecord::getTargetId,bidVO.getTargetId());
            wrapper2.eq(AuctionBidRecord::getDelFlag,0);
            wrapper2.orderByDesc(AuctionBidRecord::getLastBidAmount);
            AuctionBidRecord one2 = auctionBidRecordService.getOne(wrapper1);
            Map<String, Object> map = new ConcurrentHashMap<>();
            map.put("notification_type", NotificationTypeConstant.AUCTION_SALESROOM);
            map.put("auctionSalesroomId", bidVO.getAuctionSalesroomId());
            map.put("byId", byId.getStatus());
            map.put("lastBidAmount",one2.getLastBidAmount());
            map.put("message_type", "BidRecor");
            map.put("type",3);
            String msg = null;
            try {
                msg = objectMapper.writeValueAsString(map);
            } catch (JsonProcessingException e) {
            }
            String finalMsg = msg;
                    sysUserClient.pushByClientType(WebsocketMessageDTO.builder().message(finalMsg)
                            .clientType(ClientTypeEnum.MEMBER).build(), SecurityConstants.INNER);
        }else {
            AuctionGoods byId = auctionGoodsService.getById(bidVO.getTargetId());
            if (byId.getStartingPrice().doubleValue()>bidVO.getLastBidAmount().doubleValue()){
                throw new ServiceException("出价不能比起拍价低");
            }
            BigDecimal bigDecimal=byId.getStartingPrice().add(byId.getMinimumMarkupAmount());
            if (bigDecimal.doubleValue()>bidVO.getLastBidAmount().doubleValue()){
                throw new ServiceException("出价不能比每次最少加价低");
            }
            LambdaQueryWrapper<AuctionBidRecord> wrapper1=Wrappers.lambdaQuery();
            wrapper1.eq(AuctionBidRecord::getTargetId,bidVO.getTargetId());
            wrapper1.eq(AuctionBidRecord::getDelFlag,0);
            wrapper1.orderByDesc(AuctionBidRecord::getLastBidAmount);
            wrapper1.last("limit 1");
            AuctionBidRecord one = auctionBidRecordService.getOne(wrapper1);
            if (byId.getAuctionStock()==1){
                AuctionBidRecord one = auctionBidRecordService.getOne(wrapper1);
                if (one != null) {
                    BigDecimal bigDecimal1 = one.getLastBidAmount().add(byId.getMinimumMarkupAmount());
                    if (bigDecimal1.doubleValue() > bidVO.getLastBidAmount().doubleValue()) {
                        throw new ServiceException("出价不能比上次出价加每次最少加价低");
                    one.setLastBidAmount(bidVO.getLastBidAmount());
                    one.setLastBidTime(LocalDateTime.now());
                    one.setBidCount(one.getBidCount() + 1);
                    auctionBidRecordService.updateById(one);
                } else {
                    one = new AuctionBidRecord();
                    one.setAuctionSalesroomId(bidVO.getAuctionSalesroomId());
                    one.setTargetId(bidVO.getTargetId());
                    one.setMemberId(bidVO.getMemberId());
                    one.setLastBidTime(LocalDateTime.now());
                    if (membeOne.getRealName() != null && membeOne.getRealName() != "") {
                        one.setNickname(membeOne.getRealName());
                    } else {
                        one.setNickname(membeOne.getNickname());
                    }
                    one.setPhone(membeOne.getPhone());
                    one.setAuctionType(AuctionOrderTypeEnum.AUCTION_ITEMS);
                    one.setStatus(BidStatusEnum.ELIMINATE);
                    one.setBidCount(1);
                    one.setLastBidAmount(bidVO.getLastBidAmount());
                    auctionBidRecordService.save(one);
                }
            }
            LambdaQueryWrapper<AuctionBidRecord> wrapper3=Wrappers.lambdaQuery();
            wrapper3.eq(AuctionBidRecord::getTargetId,bidVO.getTargetId());
            wrapper3.eq(AuctionBidRecord::getDelFlag,0);
            wrapper3.eq(AuctionBidRecord::getMemberId,bidVO.getMemberId());
            wrapper3.orderByDesc(AuctionBidRecord::getLastBidAmount);
            wrapper3.last("limit 1");
            AuctionBidRecord one3 = auctionBidRecordService.getOne(wrapper3);
                if (one3!=null){
                LambdaQueryWrapper<AuctionBidRecord> wrapper2 = Wrappers.lambdaQuery();
                wrapper2.eq(AuctionBidRecord::getAuctionSalesroomId, bidVO.getAuctionSalesroomId());
                wrapper2.eq(AuctionBidRecord::getTargetId, bidVO.getTargetId());
                wrapper2.eq(AuctionBidRecord::getDelFlag, 0);
                wrapper2.orderByDesc(AuctionBidRecord::getLastBidAmount);
                AuctionBidRecord one2 = auctionBidRecordService.getOne(wrapper1);
                Map<String, Object> map = new ConcurrentHashMap<>();
                map.put("notification_type", NotificationTypeConstant.AUCTION_SALESROOM);
                map.put("auctionSalesroomId", bidVO.getAuctionSalesroomId());
                map.put("byId", byId.getStatus());
                map.put("lastBidAmount", one2.getLastBidAmount());
                map.put("message_type", "BidRecor");
                map.put("type", 3);
                String msg = null;
                try {
                    msg = objectMapper.writeValueAsString(map);
                } catch (JsonProcessingException e) {
                }
                String finalMsg = msg;
                sysUserClient.pushByClientType(WebsocketMessageDTO.builder().message(finalMsg)
                        .clientType(ClientTypeEnum.MEMBER).build(), SecurityConstants.INNER);
            } else {
                AuctionGoods byId = auctionGoodsService.getById(bidVO.getTargetId());
                if (byId.getStartingPrice().doubleValue() > bidVO.getLastBidAmount()
                        .doubleValue()) {
                    throw new ServiceException("出价不能比起拍价低");
                }
                BigDecimal bigDecimal = byId.getStartingPrice().add(byId.getMinimumMarkupAmount());
                if (bigDecimal.doubleValue() > bidVO.getLastBidAmount().doubleValue()) {
                    throw new ServiceException("出价不能比每次最少加价低");
                }
                LambdaQueryWrapper<AuctionBidRecord> wrapper1 = Wrappers.lambdaQuery();
                wrapper1.eq(AuctionBidRecord::getTargetId, bidVO.getTargetId());
                wrapper1.eq(AuctionBidRecord::getDelFlag, 0);
                wrapper1.orderByDesc(AuctionBidRecord::getLastBidAmount);
                wrapper1.last("limit 1");
                AuctionBidRecord one = auctionBidRecordService.getOne(wrapper1);
                if (byId.getAuctionStock() == 1) {
                    if (one != null) {
                        BigDecimal bigDecimal1 = one.getLastBidAmount()
                                .add(byId.getMinimumMarkupAmount());
                        if (bigDecimal1.doubleValue() > bidVO.getLastBidAmount().doubleValue()) {
                            throw new ServiceException("出价不能比上次出价加每次最少加价低");
                        }
                    }
                }
                LambdaQueryWrapper<AuctionBidRecord> wrapper3 = Wrappers.lambdaQuery();
                wrapper3.eq(AuctionBidRecord::getTargetId, bidVO.getTargetId());
                wrapper3.eq(AuctionBidRecord::getDelFlag, 0);
                wrapper3.eq(AuctionBidRecord::getMemberId, bidVO.getMemberId());
                wrapper3.orderByDesc(AuctionBidRecord::getLastBidAmount);
                wrapper3.last("limit 1");
                AuctionBidRecord one3 = auctionBidRecordService.getOne(wrapper3);
                if (one3 != null) {
                    one3.setLastBidAmount(bidVO.getLastBidAmount());
                    one3.setLastBidTime(LocalDateTime.now());
                    one3.setBidCount(one.getBidCount()+1);
                    one3.setBidCount(one.getBidCount() + 1);
                    auctionBidRecordService.updateById(one3);
                }else{
                    one3=new AuctionBidRecord();
                } else {
                    one3 = new AuctionBidRecord();
                    one3.setAuctionSalesroomId(bidVO.getAuctionSalesroomId());
                    one3.setTargetId(bidVO.getTargetId());
                    one3.setMemberId(bidVO.getMemberId());
                    if(membeOne.getRealName()!=null&&membeOne.getRealName()!=""){
                    if (membeOne.getRealName() != null && membeOne.getRealName() != "") {
                        one3.setNickname(membeOne.getRealName());
                    }else{
                    } else {
                        one3.setNickname(membeOne.getNickname());
                    }
                    one3.setPhone(membeOne.getPhone());
@@ -817,22 +841,27 @@
                    auctionBidRecordService.save(one3);
                }
            Map<String, Object> map = new ConcurrentHashMap<>();
            map.put("notification_type", NotificationTypeConstant.AUCTION_SALESROOM);
            map.put("auctionSalesroomId", byId.getId());
            map.put("byId", byId.getStartStatus());
            map.put("lastBidAmount",one3.getLastBidAmount());
            map.put("message_type", "BidRecor");
            map.put("type",4);
            String msg = null;
            try {
                msg = objectMapper.writeValueAsString(map);
            } catch (JsonProcessingException e) {
            }
            String finalMsg = msg;
            sysUserClient.pushByClientType(WebsocketMessageDTO.builder().message(finalMsg)
                            .clientType(ClientTypeEnum.MEMBER).build(), SecurityConstants.INNER);
                Map<String, Object> map = new ConcurrentHashMap<>();
                map.put("notification_type", NotificationTypeConstant.AUCTION_SALESROOM);
                map.put("auctionSalesroomId", byId.getId());
                map.put("byId", byId.getStartStatus());
                map.put("lastBidAmount", one3.getLastBidAmount());
                map.put("message_type", "BidRecor");
                map.put("type", 4);
                String msg = null;
                try {
                    msg = objectMapper.writeValueAsString(map);
                } catch (JsonProcessingException e) {
                }
                String finalMsg = msg;
                sysUserClient.pushByClientType(WebsocketMessageDTO.builder().message(finalMsg)
                        .clientType(ClientTypeEnum.MEMBER).build(), SecurityConstants.INNER);
            }
        } finally {
            if (lock.isLocked()) {
                lock.unlock();
            }
        }
    }
@@ -1038,35 +1067,17 @@
    }
    @Override
    public PageDTO<WdMemberAuctionSalesroomVO> getWdAuctionSalesroomList(MemberAuctionSalesroomDTO MemberAuctionSalesroomDTO) {
        MemberAuctionSalesroomDTO memberAuctionSalesroomDTO =new MemberAuctionSalesroomDTO();
        memberAuctionSalesroomDTO.setMemberId(MemberAuctionSalesroomDTO.getMemberId());
    public PageDTO<WdMemberAuctionSalesroomVO> getWdAuctionSalesroomList(
            MemberAuctionSalesroomDTO memberAuctionSalesroomDTO) {
        List<OrderAuctionBond> data = orderClient.getOrderAuctionBondList1(memberAuctionSalesroomDTO, SecurityConstants.INNER).getData();
        if (CollUtils.isEmpty(data)) {
            return PageDTO.empty(0L, 0L);
        }
        Set<Long> goodsSkuIdList = null;
        goodsSkuIdList = data.stream().map(OrderAuctionBond::getAuctionSalesroomId)
                    .collect(Collectors.toSet());
       /* MemberAuctionSalesroomWdDTO memberAuctionSalesroomWdDTO=new MemberAuctionSalesroomWdDTO();
        if (goodsSkuIdList.size()>0){
            memberAuctionSalesroomWdDTO.setGoodsSkuIdList(goodsSkuIdList);
        }else{
            Set<Long> goodsSkuIdList1 = new HashSet<>();
            goodsSkuIdList1.add(0L);
            memberAuctionSalesroomWdDTO.setGoodsSkuIdList(goodsSkuIdList1);
        }
        if(MemberAuctionSalesroomDTO.getStatus()!=4){
            if (MemberAuctionSalesroomDTO.getStatus()==0){
                memberAuctionSalesroomWdDTO.setStatus(5);
            }else{
                memberAuctionSalesroomWdDTO.setStatus(MemberAuctionSalesroomDTO.getStatus());
            }
        }*/
        Page<AuctionSalesroom> page = new Page<>();
        page.setSize(memberAuctionSalesroomDTO.getPageSize());
        page.setCurrent(memberAuctionSalesroomDTO.getPageCurr());
                .collect(Collectors.toSet());
        Page<AuctionSalesroom> page = new Page<>(memberAuctionSalesroomDTO.getPageCurr(),
                memberAuctionSalesroomDTO.getPageSize());
        LambdaQueryWrapper<AuctionSalesroom> wrapper1=Wrappers.lambdaQuery();
        if (goodsSkuIdList.size()>0){
            wrapper1.in(AuctionSalesroom::getId,goodsSkuIdList);
@@ -1075,20 +1086,18 @@
            goodsSkuIdList1.add(0L);
            wrapper1.in(AuctionSalesroom::getId,goodsSkuIdList);
        }
        if (MemberAuctionSalesroomDTO.getSalesroomName()!=null){
            wrapper1.like(AuctionSalesroom::getSalesroomName,MemberAuctionSalesroomDTO.getSalesroomName());
        if (memberAuctionSalesroomDTO.getSalesroomName() != null) {
            wrapper1.like(AuctionSalesroom::getSalesroomName,
                    memberAuctionSalesroomDTO.getSalesroomName());
        }
        wrapper1.eq(AuctionSalesroom::getDelFlag,0);
        if(MemberAuctionSalesroomDTO.getStatus()!=4){
             wrapper1.eq(AuctionSalesroom::getStatus,MemberAuctionSalesroomDTO.getStatus());
        if (memberAuctionSalesroomDTO.getStatus() != 4) {
            wrapper1.eq(AuctionSalesroom::getStatus, memberAuctionSalesroomDTO.getStatus());
        }
        wrapper1.last("ORDER BY\n" +
                "        CASE\n" +
                "        WHEN status = 0 THEN 2\n" +
                "        WHEN status = 1 THEN 1\n" +
                "        WHEN status = 2 THEN 3\n" +
                "        END,status asc LIMIT "+memberAuctionSalesroomDTO.getPageCurr()+","+memberAuctionSalesroomDTO.getPageSize());
        wrapper1.last(memberAuctionSalesroomDTO.getStatus() == 4, "ORDER BY\n"
                + "    FIELD(status, 1, 0, 2),\n"
                + "    start_time DESC");
        wrapper1.last(memberAuctionSalesroomDTO.getStatus() != 4, "ORDER BY start_time DESC");
        Page<AuctionSalesroom> auctionSalesroomList=this.page(page,wrapper1);
        PageDTO<WdMemberAuctionSalesroomVO> wdMemberAuctionSalesroomVOPageDTO = PageDTO.of(auctionSalesroomList, WdMemberAuctionSalesroomVO.class);
        List<WdMemberAuctionSalesroomVO> list = wdMemberAuctionSalesroomVOPageDTO.getList();
@@ -1096,7 +1105,8 @@
            auctionSalesroom.setSalesroomId(auctionSalesroom.getId());
            MemberAuctionSalesroomDTO memberAuctionSalesroomDTO1=new MemberAuctionSalesroomDTO();
            memberAuctionSalesroomDTO1.setAuctionSalesroomId(auctionSalesroom.getId());
            memberAuctionSalesroomDTO1.setMemberId(MemberAuctionSalesroomDTO.getMemberId());
            memberAuctionSalesroomDTO1.setMemberId(memberAuctionSalesroomDTO.getMemberId());
            auctionSalesroom.setIsBond(2);
            List<OrderAuctionBond> data1 = orderClient.getOrderAuctionBondList1(memberAuctionSalesroomDTO1, SecurityConstants.INNER).getData();
            if (data1.size()>0){
                auctionSalesroom.setBondTime(data1.get(0).getCreateTime());
@@ -1453,68 +1463,83 @@
     */
    @Override
    public void stopCurrentGoods(Long id) throws JsonProcessingException {
        AuctionSalesroomGoods auctionSalesroomGoods = auctionSalesroomGoodsMapper.selectById(id);
        if (StringUtils.isNull(auctionSalesroomGoods)) {
            throw new ServiceException("拍卖商品不存在");
        }
        AuctionSalesroom auctionSalesroom = this.getById(
                auctionSalesroomGoods.getAuctionSalesroomId());
        auctionSalesroomGoods.setStatus(AuctionGoodsStatusEnum.ENDED);
        auctionSalesroomGoodsMapper.updateById(auctionSalesroomGoods);
        List<AuctionBidRecord> auctionBidRecordList = auctionBidRecordMapper.selectList(
                Wrappers.lambdaQuery(AuctionBidRecord.class)
                        .eq(AuctionBidRecord::getAuctionSalesroomId,
                                auctionSalesroomGoods.getAuctionSalesroomId())
                        .eq(AuctionBidRecord::getTargetId, auctionSalesroomGoods.getId())
                        .eq(AuctionBidRecord::getAuctionType, AuctionOrderTypeEnum.AUCTION_ITEMS)
                        .orderByDesc(AuctionBidRecord::getLastBidAmount));
        if (CollUtils.isNotEmpty(auctionBidRecordList)) {
            List<AuctionBidRecord> auctionBidRecords = new ArrayList<>();
            if (auctionBidRecordList.size() >= auctionSalesroomGoods.getSalesroomStock()) {
                for (int i = 0; i < auctionSalesroomGoods.getSalesroomStock(); i++) {
                    AuctionBidRecord auctionBidRecord = auctionBidRecordList.get(i);
                    auctionBidRecord.setStatus(BidStatusEnum.SUCCESSFUL);
                    auctionBidRecordMapper.updateById(auctionBidRecord);
                    auctionBidRecords.add(auctionBidRecord);
                }
            } else {
                for (int i = 0; i < auctionBidRecordList.size(); i++) {
                    AuctionBidRecord auctionBidRecord = auctionBidRecordList.get(i);
                    auctionBidRecord.setStatus(BidStatusEnum.SUCCESSFUL);
                    auctionBidRecordMapper.updateById(auctionBidRecord);
                    auctionBidRecords.add(auctionBidRecord);
                }
                // 没有出价记录,回退库存
                GoodsStockUpdDTO goodsStockUpdDTO = new GoodsStockUpdDTO();
                goodsStockUpdDTO.setGoodsSkuId(auctionSalesroomGoods.getGoodsSkuId());
                goodsStockUpdDTO.setAuctionStock(
                        auctionSalesroomGoods.getSalesroomStock() - auctionBidRecordList.size());
                goodsSkuClient.updGoodsStock(Lists.newArrayList(goodsStockUpdDTO),
                        SecurityConstants.INNER);
        RLock lock = redissonClient.getLock("stopCurrentGoods" + id);
        lock.lock(10, TimeUnit.SECONDS);
        try {
            AuctionSalesroomGoods auctionSalesroomGoods = auctionSalesroomGoodsMapper.selectById(
                    id);
            if (StringUtils.isNull(auctionSalesroomGoods)) {
                throw new ServiceException("拍卖商品不存在");
            }
            for (AuctionBidRecord auctionBidRecord : auctionBidRecords) {
                addOrder(auctionBidRecord.getTargetId(), auctionBidRecord.getMemberId(),
                        auctionBidRecord.getLastBidAmount(),
                        auctionSalesroom.getBond());
            if (auctionSalesroomGoods.getStatus().equals(AuctionGoodsStatusEnum.IN_PROGRESS)) {
                AuctionSalesroom auctionSalesroom = this.getById(
                        auctionSalesroomGoods.getAuctionSalesroomId());
                auctionSalesroomGoods.setStatus(AuctionGoodsStatusEnum.ENDED);
                auctionSalesroomGoodsMapper.updateById(auctionSalesroomGoods);
                List<AuctionBidRecord> auctionBidRecordList = auctionBidRecordMapper.selectList(
                        Wrappers.lambdaQuery(AuctionBidRecord.class)
                                .eq(AuctionBidRecord::getAuctionSalesroomId,
                                        auctionSalesroomGoods.getAuctionSalesroomId())
                                .eq(AuctionBidRecord::getTargetId, auctionSalesroomGoods.getId())
                                .eq(AuctionBidRecord::getAuctionType,
                                        AuctionOrderTypeEnum.AUCTION_ITEMS)
                                .orderByDesc(AuctionBidRecord::getLastBidAmount)
                                .orderByAsc(AuctionBidRecord::getLastBidTime));
                if (CollUtils.isNotEmpty(auctionBidRecordList)) {
                    List<AuctionBidRecord> auctionBidRecords = new ArrayList<>();
                    if (auctionBidRecordList.size() >= auctionSalesroomGoods.getSalesroomStock()) {
                        for (int i = 0; i < auctionSalesroomGoods.getSalesroomStock(); i++) {
                            AuctionBidRecord auctionBidRecord = auctionBidRecordList.get(i);
                            auctionBidRecord.setStatus(BidStatusEnum.SUCCESSFUL);
                            auctionBidRecordMapper.updateById(auctionBidRecord);
                            auctionBidRecords.add(auctionBidRecord);
                        }
                    } else {
                        for (int i = 0; i < auctionBidRecordList.size(); i++) {
                            AuctionBidRecord auctionBidRecord = auctionBidRecordList.get(i);
                            auctionBidRecord.setStatus(BidStatusEnum.SUCCESSFUL);
                            auctionBidRecordMapper.updateById(auctionBidRecord);
                            auctionBidRecords.add(auctionBidRecord);
                        }
                        // 没有出价记录,回退库存
                        GoodsStockUpdDTO goodsStockUpdDTO = new GoodsStockUpdDTO();
                        goodsStockUpdDTO.setGoodsSkuId(auctionSalesroomGoods.getGoodsSkuId());
                        goodsStockUpdDTO.setAuctionStock(
                                auctionSalesroomGoods.getSalesroomStock()
                                        - auctionBidRecordList.size());
                        goodsSkuClient.updGoodsStock(Lists.newArrayList(goodsStockUpdDTO),
                                SecurityConstants.INNER);
                    }
                    for (AuctionBidRecord auctionBidRecord : auctionBidRecords) {
                        addOrder(auctionBidRecord.getTargetId(), auctionBidRecord.getMemberId(),
                                auctionBidRecord.getLastBidAmount(),
                                auctionSalesroom.getBond());
                    }
                } else {
                    // 没有出价记录,回退库存
                    GoodsStockUpdDTO goodsStockUpdDTO = new GoodsStockUpdDTO();
                    goodsStockUpdDTO.setGoodsSkuId(auctionSalesroomGoods.getGoodsSkuId());
                    goodsStockUpdDTO.setAuctionStock(
                            auctionSalesroomGoods.getSalesroomStock());
                    goodsSkuClient.updGoodsStock(Lists.newArrayList(goodsStockUpdDTO),
                            SecurityConstants.INNER);
                }
                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);
            }
        } else {
            // 没有出价记录,回退库存
            GoodsStockUpdDTO goodsStockUpdDTO = new GoodsStockUpdDTO();
            goodsStockUpdDTO.setGoodsSkuId(auctionSalesroomGoods.getGoodsSkuId());
            goodsStockUpdDTO.setAuctionStock(
                    auctionSalesroomGoods.getSalesroomStock());
            goodsSkuClient.updGoodsStock(Lists.newArrayList(goodsStockUpdDTO),
                    SecurityConstants.INNER);
        } finally {
            if (lock.isLocked()) {
                lock.unlock();
            }
        }
        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);
    }
    public void addOrder(Long goodsSkuId, Long memberId, BigDecimal lastBidAmount,
@@ -1541,7 +1566,7 @@
                        ConfigEnum.MEMBER_POINTS_POINTS.getKey())
                .getData();
        if (lastBidAmount.intValue() > 0) {
        if (lastBidAmount.compareTo(BigDecimal.ZERO) > 0) {
            BigDecimal divide = lastBidAmount.divide(
                    new BigDecimal(memberPointsMoney.getConfigValue()), 0,
                    RoundingMode.DOWN);
@@ -1567,6 +1592,7 @@
        order.setSkuName(goodsSku.getSkuName());
        order.setCoverPic(goodsSku.getCoverPic());
        order.setPrice(lastBidAmount);
        order.setGoodsId(auctionSalesroomGoods.getGoodsSkuId());
        orderClient.saveOrderOne(order, SecurityConstants.INNER);
    }
    /**
@@ -1658,8 +1684,7 @@
        map.put("message_type", "start");
        map.put("type", "1");
        String msg = objectMapper.writeValueAsString(map);
        sysUserClient.pushByClientType(WebsocketMessageDTO.builder().message(msg)
                .clientType(ClientTypeEnum.AUCTIONEER).build(), SecurityConstants.INNER);
        sysUserClient.pushAll(msg, SecurityConstants.INNER);
    }
    @Override
@@ -1704,7 +1729,8 @@
        List<AuctionBidRecord> auctionBidRecordList = auctionBidRecordMapper.selectList(
                Wrappers.<AuctionBidRecord>lambdaQuery()
                        .eq(AuctionBidRecord::getAuctionSalesroomId, auctionSalesroomId)
                        .ne(AuctionBidRecord::getStatus, BidStatusEnum.SUCCESSFUL));
                        .eq(AuctionBidRecord::getStatus, BidStatusEnum.SUCCESSFUL));
        log.info("拍卖场{},已中标的用户:{}", auctionSalesroomId, auctionBidRecordList);
        Set<Long> memberIdList = new HashSet<>();
        if (CollUtils.isNotEmpty(auctionBidRecordList)) {
            memberIdList = auctionBidRecordList.stream().map(AuctionBidRecord::getMemberId)
@@ -1721,8 +1747,7 @@
        map.put("message_type", "end");
        map.put("type", "1");
        String msg = objectMapper.writeValueAsString(map);
        sysUserClient.pushByClientType(WebsocketMessageDTO.builder().message(msg)
                .clientType(ClientTypeEnum.AUCTIONEER).build(), SecurityConstants.INNER);
        sysUserClient.pushAll(msg, SecurityConstants.INNER);
    }
    @Override
@@ -1764,4 +1789,25 @@
    public AuctionSalesroomGoods getAuctionSalesroomGoodsById(Long goodsSkuId) {
        return auctionSalesroomGoodsMapper.selectById(goodsSkuId);
    }
    @Override
    public AuctionBondJl getAuctionBondJLBySalesroomId(Long targetId, Long memberId,
            Integer bondType) {
        return auctionBondJlMapper.selectOne(
                Wrappers.lambdaQuery(AuctionBondJl.class).eq(AuctionBondJl::getMemberId, memberId)
                        .eq(AuctionBondJl::getAuctionSalesroomId, targetId)
                        .eq(AuctionBondJl::getBondType, bondType)
                        .last("limit 1"));
    }
    @Override
    public List<GoodsSku> getGoodsSkuByAuctionSalesroomGoodsSet(
            Set<Long> auctionSalesroomGoodsSet) {
        List<AuctionSalesroomGoods> auctionSalesroomGoodsList = auctionSalesroomGoodsMapper.selectBatchIds(
                auctionSalesroomGoodsSet);
        Set<Long> goodsSkuIdSet = auctionSalesroomGoodsList.stream()
                .map(AuctionSalesroomGoods::getGoodsSkuId).collect(
                        Collectors.toSet());
        return goodsSkuClient.getGoodsListByIds(goodsSkuIdSet, SecurityConstants.INNER).getData();
    }
}