From 5814d15a328979d3d97a65a8e6e3e70b5204ca32 Mon Sep 17 00:00:00 2001
From: mitao <2763622819@qq.com>
Date: 星期一, 15 七月 2024 11:36:26 +0800
Subject: [PATCH] 修改bug

---
 ruoyi-modules/ruoyi-auction/src/main/java/com/ruoyi/auction/service/impl/AuctionSalesroomServiceImpl.java |  153 +++++++++++++++++++++++++++++++++++----------------
 1 files changed, 105 insertions(+), 48 deletions(-)

diff --git a/ruoyi-modules/ruoyi-auction/src/main/java/com/ruoyi/auction/service/impl/AuctionSalesroomServiceImpl.java b/ruoyi-modules/ruoyi-auction/src/main/java/com/ruoyi/auction/service/impl/AuctionSalesroomServiceImpl.java
index c23ef08..3a0ecae 100644
--- a/ruoyi-modules/ruoyi-auction/src/main/java/com/ruoyi/auction/service/impl/AuctionSalesroomServiceImpl.java
+++ b/ruoyi-modules/ruoyi-auction/src/main/java/com/ruoyi/auction/service/impl/AuctionSalesroomServiceImpl.java
@@ -53,6 +53,7 @@
 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;
@@ -240,14 +241,21 @@
         if (sysUser==null){
             throw new ServiceException("手机号未注册");
         }
-    /*   if (!SecurityUtils.matchesPassword(arepartAuctionBidRecordDTO.getPassword(), sysUser.getPassword())){
+        if (sysUser.getStatus().equals(1)){
+            throw new ServiceException("该拍卖师账号停用");
+        }
+
+      if (!SecurityUtils.matchesPassword(arepartAuctionBidRecordDTO.getPassword(), sysUser.getPassword())){
             throw new ServiceException("密码输入错误");
-        }*/
+        }
 
         LambdaQueryWrapper<AuctionSalesroom> wrapper=Wrappers.lambdaQuery();
         wrapper.eq(AuctionSalesroom::getAuctionSalesroomNo,arepartAuctionBidRecordDTO.getAuctionSalesroomQrcode());
         wrapper.eq(AuctionSalesroom::getDelFlag,0);
         AuctionSalesroom auctionBidRecord = this.getOne(wrapper);
+        if(auctionBidRecord.getType().getCode()==0){
+            throw new ServiceException("当前扫码是线下拍卖会");
+        }
         return auctionBidRecord;
     }
 
@@ -408,6 +416,12 @@
     @Override
     public MemberAuctionSalesroomInfoVO getMemberAuctionSalesroomInfo(MemberAuctionSalesroomDTO memberAuctionSalesroomDTO) {
         AuctionSalesroom byId = this.getById(memberAuctionSalesroomDTO.getAuctionSalesroomId());
+        if(byId==null){
+            LambdaQueryWrapper<AuctionSalesroom> wrapper=Wrappers.lambdaQuery();
+            wrapper.eq(AuctionSalesroom::getAuctionSalesroomNo,memberAuctionSalesroomDTO.getAuctionSalesroomId());
+            wrapper.eq(AuctionSalesroom::getDelFlag,0);
+            byId =this.getOne(wrapper);
+        }
         MemberAuctionSalesroomInfoVO memberAuctionSalesroomInfoVO=new MemberAuctionSalesroomInfoVO();
         memberAuctionSalesroomInfoVO.setId(byId.getId());
         memberAuctionSalesroomInfoVO.setBound(byId.getBond());
@@ -428,7 +442,10 @@
             memberAuctionSalesroomInfoVO.setIsApply(1);
         }
         List<ForepartAuctionSalesroomGoodsVO> forepartAuctionSalesroomGoodsVOS=new ArrayList<>();
-        List<AuctionSalesroomGoods> auctionSalesroomGoods = auctionSalesroomGoodsMapper.getAuctionSalesroomGoods(memberAuctionSalesroomDTO);
+        MemberAuctionSalesroomDTO memberAuctionSalesroomDTO1 =new MemberAuctionSalesroomDTO();
+        memberAuctionSalesroomDTO1.setAuctionSalesroomId(byId.getId());
+        memberAuctionSalesroomDTO1.setBackupStatus(false);
+        List<AuctionSalesroomGoods> auctionSalesroomGoods = auctionSalesroomGoodsMapper.getAuctionSalesroomGoods(memberAuctionSalesroomDTO1);
         for (AuctionSalesroomGoods salesroomGoods:auctionSalesroomGoods){
             ForepartAuctionSalesroomGoodsVO forepartAuctionSalesroomGoodsVO=new ForepartAuctionSalesroomGoodsVO();
             forepartAuctionSalesroomGoodsVO.setSalesroomId(byId.getId());
@@ -440,8 +457,10 @@
             forepartAuctionSalesroomGoodsVO.setCoverPic(goodsSku.getCoverPic());
             forepartAuctionSalesroomGoodsVO.setStartingPrice(salesroomGoods.getStartingPrice());
             forepartAuctionSalesroomGoodsVO.setSalesroomStock(salesroomGoods.getSalesroomStock());
-            forepartAuctionSalesroomGoodsVO.setGoodsSkustatus(salesroomGoods.getStatus());
+            forepartAuctionSalesroomGoodsVO.setGoodsSkustatus(salesroomGoods.getStatus().getCode());
             forepartAuctionSalesroomGoodsVO.setYears(String.valueOf(goodsSku.getYears()));
+            forepartAuctionSalesroomGoodsVO.setSpec(goodsSku.getSpec());
+            forepartAuctionSalesroomGoodsVO.setSpecUnit(goodsSku.getSpecUnit());
             LambdaQueryWrapper<AuctionBidRecord> wrapper1=Wrappers.lambdaQuery();
             wrapper1.eq(AuctionBidRecord::getMemberId,memberAuctionSalesroomDTO.getMemberId());
             wrapper1.eq(AuctionBidRecord::getAuctionSalesroomId,byId.getId());
@@ -470,6 +489,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);
@@ -598,11 +618,27 @@
                 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 (one3!=null){
+                if (bidVO.getLastBidAmount().doubleValue()<one3.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){
                 BigDecimal bigDecimal1=one.getLastBidAmount().add(byId.getMinimumMarkupAmount());
@@ -619,7 +655,12 @@
                 one.setTargetId(bidVO.getTargetId());
                 one.setMemberId(bidVO.getMemberId());
                 one.setLastBidTime(LocalDateTime.now());
-                one.setNickname(membeOne.getNickname());
+                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);
@@ -665,46 +706,57 @@
                 throw new ServiceException("出价不能比每次最少加价低");
             }
             LambdaQueryWrapper<AuctionBidRecord> wrapper1=Wrappers.lambdaQuery();
-            wrapper1.eq(AuctionBidRecord::getMemberId,bidVO.getMemberId());
             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 (one!=null){
-                BigDecimal bigDecimal1=one.getLastBidAmount().add(byId.getMinimumMarkupAmount());
-                if (bigDecimal1.doubleValue()<bidVO.getLastBidAmount().doubleValue()){
-                    throw new ServiceException("出价不能比上次出价加每次最少加价低");
+            if (byId.getAuctionStock()==1) {
+                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());
-                one.setAuctionType(AuctionOrderTypeEnum.REGULAR_ITEMS);
-                one.setStatus(BidStatusEnum.ELIMINATE);
-                one.setBidCount(1);
-                one.setLastBidAmount(bidVO.getLastBidAmount());
-                auctionBidRecordService.save(one);
             }
 
-            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);
+            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);
+                    auctionBidRecordService.updateById(one3);
+                }else{
+                    one3=new AuctionBidRecord();
+                    one3.setAuctionSalesroomId(bidVO.getAuctionSalesroomId());
+                    one3.setTargetId(bidVO.getTargetId());
+                    one3.setMemberId(bidVO.getMemberId());
+                    if(membeOne.getRealName()!=null||membeOne.getRealName()!=""){
+                        one3.setNickname(membeOne.getRealName());
+                    }else{
+                        one3.setNickname(membeOne.getNickname());
+                    }
+                    one3.setPhone(membeOne.getPhone());
+                    one3.setLastBidTime(LocalDateTime.now());
+                    one3.setAuctionType(AuctionOrderTypeEnum.REGULAR_ITEMS);
+                    one3.setStatus(BidStatusEnum.ELIMINATE);
+                    one3.setBidCount(1);
+                    one3.setLastBidAmount(bidVO.getLastBidAmount());
+                    auctionBidRecordService.save(one3);
+                }
 
             Map<String, Object> map = new ConcurrentHashMap<>();
             map.put("notification_type", NotificationTypeConstant.AUCTION_SALESROOM);
-            map.put("auctionSalesroomId", bidVO.getAuctionSalesroomId());
+            map.put("auctionSalesroomId", byId.getId());
             map.put("byId", byId.getStartStatus());
-            map.put("lastBidAmount",one2.getLastBidAmount());
+            map.put("lastBidAmount",one3.getLastBidAmount());
             map.put("message_type", "BidRecor");
             map.put("type",4);
             String msg = null;
@@ -777,18 +829,21 @@
         List<MgtAuctionSalesroomVO> list = auctionSalesroomVOPageDTO.getList();
         List<Long> auctionSalesroomIdList = list.stream().map(MgtAuctionSalesroomVO::getId)
                 .collect(Collectors.toList());
-        // 所有拍卖场的拍卖商品
-        List<AuctionSalesroomGoods> auctionSalesroomGoods = auctionSalesroomGoodsMapper.selectList(
-                Wrappers.<AuctionSalesroomGoods>lambdaQuery()
-                        .in(AuctionSalesroomGoods::getAuctionSalesroomId, auctionSalesroomIdList));
-        // 计算每个拍卖场所有拍品数量
-        Map<Long, Integer> map = auctionSalesroomGoods.stream()
-                .collect(Collectors.groupingBy(AuctionSalesroomGoods::getAuctionSalesroomId,
-                        Collectors.summingInt(AuctionSalesroomGoods::getSalesroomStock)));
-        for (MgtAuctionSalesroomVO mgtAuctionSalesroomVO : list) {
-            Integer i = map.get(mgtAuctionSalesroomVO.getId());
-            if (StringUtils.isNotNull(i)) {
-                mgtAuctionSalesroomVO.setAuctionGoodsNum(i);
+        if (StringUtils.isNotEmpty(auctionSalesroomIdList)) {
+            // 所有拍卖场的拍卖商品
+            List<AuctionSalesroomGoods> auctionSalesroomGoods = auctionSalesroomGoodsMapper.selectList(
+                    Wrappers.<AuctionSalesroomGoods>lambdaQuery()
+                            .in(AuctionSalesroomGoods::getAuctionSalesroomId,
+                                    auctionSalesroomIdList));
+            // 计算每个拍卖场所有拍品数量
+            Map<Long, Integer> map = auctionSalesroomGoods.stream()
+                    .collect(Collectors.groupingBy(AuctionSalesroomGoods::getAuctionSalesroomId,
+                            Collectors.summingInt(AuctionSalesroomGoods::getSalesroomStock)));
+            for (MgtAuctionSalesroomVO mgtAuctionSalesroomVO : list) {
+                Integer i = map.get(mgtAuctionSalesroomVO.getId());
+                if (StringUtils.isNotNull(i)) {
+                    mgtAuctionSalesroomVO.setAuctionGoodsNum(i);
+                }
             }
         }
         return auctionSalesroomVOPageDTO;
@@ -1117,7 +1172,9 @@
                 vo.setAuctionSalesroomGoodsVOS(collect);
                 if (StringUtils.isNotNull(vo.getCurrentAuctionSalesroomGoods())) {
                     int index = collect.indexOf(vo.getCurrentAuctionSalesroomGoods());
-                    vo.setNextAuctionSalesroomGoods(collect.get(index + 1));
+                    if (collect.size() > 1) {
+                        vo.setNextAuctionSalesroomGoods(collect.get(index + 1));
+                    }
                     // 分页查询当前拍品出价信息
                     List<AuctionBidRecord> list = auctionBidRecordService.lambdaQuery()
                             .eq(AuctionBidRecord::getTargetId,

--
Gitblit v1.7.1