mitao
2024-06-20 89c1c5d8ddca497df3094d84d307322e3a685bfd
ruoyi-modules/ruoyi-auction/src/main/java/com/ruoyi/auction/service/impl/AuctionSalesroomServiceImpl.java
@@ -103,6 +103,8 @@
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;
@@ -205,6 +207,7 @@
    private static final String ALIPAY_PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlW2RMACojdqTa8H+j6411Lm5UipGXXbQiswq50rUflwjTj843zNVaVpk8uJmbdmtUBJlmblgBS/a31O4L4LrHB8WxJ+w0f9DBNTq9T6b80MiAVnU/3gXK365DmbzPWS5pR9wEgJVHnfOFUbsB5AVFHV0m9hUZcPv7xveuEp3BEoD5smaDJByR+KgFw0Q0JgINhhE6bsEa3UgJ198af269LtQ5HJl1TWLI8aeqW14HrxyADIt49NB9KZ8MOdKP+66HWcrXlipKFHtccy3dff72DqPmFdESoXfLXKZyhU5w9v4Q5F6UoAGTPwl9KQwikTobNeJ/7su7X3AB6+C14J4sQIDAQAB";
    private static final ObjectMapper objectMapper = new ObjectMapper();
    @Override
    public List<AuctionSalesroom> getAuctionBidRecordList(AuctionSalesroomDTO ationSalesroomGoodsDTO) {
@@ -348,7 +351,7 @@
        R<SysUser> sysUserR = sysUserClient.queryUserByPhone(appMiniLoginDto.getPhone());
        SysUser data = sysUserR.getData();
        appMiniLoginVo.setSysUser(data);
        appMiniLoginVo.setPhone(appMiniLoginDto.getAuth_code());
        appMiniLoginVo.setPhone(appMiniLoginDto.getPhone());
            return appMiniLoginVo;
    }
@@ -629,6 +632,36 @@
            }
            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", "start");
            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();
                }
            });
        }else {
            AuctionGoods byId = auctionGoodsService.getById(bidVO.getTargetId());
            if (byId.getStartingPrice().doubleValue()>bidVO.getLastBidAmount().doubleValue()){
@@ -652,6 +685,8 @@
                one.setLastBidTime(LocalDateTime.now());
                one.setBidCount(one.getBidCount()+1);
                auctionBidRecordService.updateById(one);
            }else{
                one=new AuctionBidRecord();
                one.setAuctionSalesroomId(bidVO.getAuctionSalesroomId());
@@ -664,6 +699,34 @@
                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);
            Map<String, Object> map = new ConcurrentHashMap<>();
            map.put("notification_type", NotificationTypeConstant.AUCTION_SALESROOM);
            map.put("auctionSalesroomId", bidVO.getAuctionSalesroomId());
            map.put("byId", byId.getStartStatus());
            map.put("lastBidAmount",one2.getLastBidAmount());
            map.put("message_type", "start");
            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();
                }
            });
        }
    }